Skip to content

Commit 411d011

Browse files
shetzelprashanthjossvc-cli-bot
authored
feat: Pr/875 (#885)
* fix(mixedcontentsourceadapter.ts): error - Delete operation of experiencepropertytype metadata this change is to fix the error during delete operation for experiencepropertytype metadata api. as the bundle is all json files and there is no xml file in place delete operation is failing when the metadata API is failing in the backend and this is the fix for same. * feat(mixedcontentsourceadapter.ts): error during delete operation of experiencepropertytype bundle This change is to fix the error during the delete operation for experiencepropertytype metadata bundle. As the bundle is all JSON files and there is no XML file in the bundle there will be an error when the delete operation fails in the backend and this is the fix for the same. * fix(mixedcontentsourceadapter.test.ts): error during delete operation of experiencepropertytype This change is to fix the error during the delete operation for experiencepropertytype metadata bundle. As the bundle is all JSON files and there is no XML file in the bundle there will be an error when the delete operation fails in the backend and this is the fix for the same. * test: record perf * fix: lint fix * test: record perf --------- Co-authored-by: Prashanth Josyula <prashanth.16@gmail.com> Co-authored-by: svc-cli-bot <svc_cli_bot@salesforce.com>
1 parent c0ef12f commit 411d011

File tree

12 files changed

+112
-32
lines changed

12 files changed

+112
-32
lines changed

src/registry/metadataRegistry.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3388,6 +3388,7 @@
33883388
"inFolder": false,
33893389
"strictDirectoryName": true,
33903390
"supportsPartialDelete": true,
3391+
"metaFileSuffix": "schema.json",
33913392
"strategies": {
33923393
"adapter": "bundle"
33933394
}

src/resolve/adapters/mixedContentSourceAdapter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Licensed under the BSD 3-Clause license.
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
7-
import { dirname, basename, sep } from 'path';
7+
import { dirname, basename, sep, join } from 'path';
88
import { Messages, SfError } from '@salesforce/core';
99
import { baseName } from '../../utils/path';
1010
import { SourcePath } from '../../common';
@@ -68,6 +68,7 @@ export class MixedContentSourceAdapter extends BaseSourceAdapter {
6868
name: baseName(contentPath),
6969
type: this.type,
7070
content: contentPath,
71+
xml: this.type.metaFileSuffix && join(contentPath, this.type.metaFileSuffix),
7172
},
7273
this.tree,
7374
this.forceIgnore

test/mock/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export {
1313
mixedContentDirectory,
1414
mixedContentInFolder,
1515
mixedContentSingleFile,
16+
experiencePropertyTypeContentSingleFile,
1617
decomposed,
1718
nonDecomposed,
1819
decomposedtoplevel,
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (c) 2020, salesforce.com, inc.
3+
* All rights reserved.
4+
* Licensed under the BSD 3-Clause license.
5+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6+
*/
7+
import { join } from 'path';
8+
9+
import { registry, SourceComponent } from '../../../src';
10+
11+
/**
12+
* Experience Property Type Bundle will be of the following shape:
13+
*
14+
* experiencePropertyTypeBundles/
15+
* ├── prop1/
16+
* | ├── schema.json
17+
* | ├── design.json
18+
*
19+
* schema.json is always expected to be in the bundle, while design.json is optional.
20+
*
21+
* NOTE: there is no -meta.xml. schema.json acts as the meta XML file.
22+
*/
23+
24+
// This is the type defined in metadataRegistry.json
25+
const type = registry.types.experiencepropertytypebundle;
26+
27+
// This will be the root directory experiencePropertyTypeBundles.It is something like /path/to/experiencePropertyTypeBundles
28+
export const TYPE_DIRECTORY = join('path', 'to', type.directoryName);
29+
30+
// This is the name of the property type we are creating.
31+
export const COMPONENT_NAME = 'prop1';
32+
33+
// This is the schema.json and design.json paths inside the property type.
34+
export const CONTENT_NAMES = [type.metaFileSuffix, 'design.json'];
35+
36+
// This is the complete path to the content. It is something like /path/to/experiencePropertyTypeBundles/prop1/schema.json.
37+
export const CONTENT_PATHS = CONTENT_NAMES.map((n) => join(TYPE_DIRECTORY, join(COMPONENT_NAME, n)));
38+
39+
// Finally we construct our component.
40+
export const COMPONENT = SourceComponent.createVirtualComponent(
41+
{
42+
name: COMPONENT_NAME,
43+
type,
44+
content: join(TYPE_DIRECTORY, COMPONENT_NAME),
45+
xml: CONTENT_PATHS[0],
46+
},
47+
[
48+
{
49+
dirPath: TYPE_DIRECTORY,
50+
children: [COMPONENT_NAME],
51+
},
52+
]
53+
);

test/mock/type-constants/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as document from './documentConstants';
1111
import * as mixedContentDirectory from './staticresourceConstant';
1212
import * as mixedContentInFolder from './documentFolderConstant';
1313
import * as mixedContentSingleFile from './staticresourceComponentConstant';
14+
import * as experiencePropertyTypeContentSingleFile from './experiencePropertyTypeBundleConstants';
1415
import * as decomposed from './customObjectConstant';
1516
import * as decomposedtoplevel from './customObjectTranslationConstant';
1617
import * as nonDecomposed from './customlabelsConstant';
@@ -32,4 +33,5 @@ export {
3233
nestedTypes,
3334
lwcBundle,
3435
digitalExperienceBundle,
36+
experiencePropertyTypeContentSingleFile,
3537
};
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
[
22
{
33
"name": "componentSetCreate",
4-
"duration": 345.28876100000343
4+
"duration": 360.789472000004
55
},
66
{
77
"name": "sourceToMdapi",
8-
"duration": 8330.387101
8+
"duration": 8919.91247500002
99
},
1010
{
1111
"name": "sourceToZip",
12-
"duration": 5822.162848000007
12+
"duration": 6025.233091000002
1313
},
1414
{
1515
"name": "mdapiToSource",
16-
"duration": 6123.899523999979
16+
"duration": 6253.451692000002
1717
}
18-
]
18+
]
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
[
22
{
33
"name": "componentSetCreate",
4-
"duration": 675.3449159999727
4+
"duration": 744.0605729999952
55
},
66
{
77
"name": "sourceToMdapi",
8-
"duration": 11995.010080000007
8+
"duration": 13127.422728999984
99
},
1010
{
1111
"name": "sourceToZip",
12-
"duration": 9518.928809000005
12+
"duration": 10371.91620399995
1313
},
1414
{
1515
"name": "mdapiToSource",
16-
"duration": 7432.586432000011
16+
"duration": 7902.201856
1717
}
18-
]
18+
]
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
[
22
{
33
"name": "componentSetCreate",
4-
"duration": 1170.5348080000258
4+
"duration": 1188.3639100000146
55
},
66
{
77
"name": "sourceToMdapi",
8-
"duration": 17969.274023000035
8+
"duration": 18936.191220000037
99
},
1010
{
1111
"name": "sourceToZip",
12-
"duration": 14706.58613000001
12+
"duration": 15125.748401999997
1313
},
1414
{
1515
"name": "mdapiToSource",
16-
"duration": 13242.275161000027
16+
"duration": 12817.04882299999
1717
}
18-
]
18+
]
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
[
22
{
33
"name": "componentSetCreate",
4-
"duration": 222.67407499998808
4+
"duration": 226.34448500000872
55
},
66
{
77
"name": "sourceToMdapi",
8-
"duration": 6166.7441540000145
8+
"duration": 4705.3344459999935
99
},
1010
{
1111
"name": "sourceToZip",
12-
"duration": 4826.558009000029
12+
"duration": 4886.161657999997
1313
},
1414
{
1515
"name": "mdapiToSource",
16-
"duration": 4281.85755700001
16+
"duration": 4058.82406600003
1717
}
18-
]
18+
]
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
[
22
{
33
"name": "componentSetCreate",
4-
"duration": 442.19902300002286
4+
"duration": 447.82590599998366
55
},
66
{
77
"name": "sourceToMdapi",
8-
"duration": 8834.219169000047
8+
"duration": 8922.643469000002
99
},
1010
{
1111
"name": "sourceToZip",
12-
"duration": 7419.940933000005
12+
"duration": 6673.310636000009
1313
},
1414
{
1515
"name": "mdapiToSource",
16-
"duration": 5108.842208000016
16+
"duration": 4866.022824999993
1717
}
18-
]
18+
]
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
[
22
{
33
"name": "componentSetCreate",
4-
"duration": 780.378497000027
4+
"duration": 774.8018560000346
55
},
66
{
77
"name": "sourceToMdapi",
8-
"duration": 12146.644433000009
8+
"duration": 12633.609111000027
99
},
1010
{
1111
"name": "sourceToZip",
12-
"duration": 10558.852648
12+
"duration": 10770.84330399998
1313
},
1414
{
1515
"name": "mdapiToSource",
16-
"duration": 9052.254910999967
16+
"duration": 8976.685232000018
1717
}
18-
]
18+
]

test/resolve/adapters/mixedContentSourceAdapter.test.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
MIXED_CONTENT_DIRECTORY_CONTENT_PATH,
1616
MIXED_CONTENT_DIRECTORY_VIRTUAL_FS_NO_XML,
1717
} from '../../mock/type-constants/staticresourceConstant';
18-
import { mixedContentDirectory, mixedContentSingleFile } from '../../mock';
18+
import { mixedContentDirectory, mixedContentSingleFile, experiencePropertyTypeContentSingleFile } from '../../mock';
1919

2020
const messages = Messages.load('@salesforce/source-deploy-retrieve', 'sdr', ['error_expected_source_files']);
2121

@@ -77,6 +77,28 @@ describe('MixedContentSourceAdapter', () => {
7777
});
7878
});
7979

80+
describe('Experience Property Type File Content', () => {
81+
const component = experiencePropertyTypeContentSingleFile.COMPONENT;
82+
const adapter = new MixedContentSourceAdapter(
83+
registry.types.experiencepropertytypebundle,
84+
registryAccess,
85+
undefined,
86+
component.tree
87+
);
88+
89+
it('Should return expected SourceComponent when given a schema.json path', () => {
90+
const result = adapter.getComponent(component.xml);
91+
92+
expect(result).to.deep.equal(component);
93+
});
94+
95+
it('Should return expected SourceComponent when given a source path', () => {
96+
const result = adapter.getComponent(component.content);
97+
98+
expect(result).to.deep.equal(component);
99+
});
100+
});
101+
80102
describe('Directory Content', () => {
81103
const {
82104
MIXED_CONTENT_DIRECTORY_COMPONENT,

0 commit comments

Comments
 (0)