Skip to content

Pr/875 #885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/registry/metadataRegistry.json
Original file line number Diff line number Diff line change
Expand Up @@ -3388,6 +3388,7 @@
"inFolder": false,
"strictDirectoryName": true,
"supportsPartialDelete": true,
"metaFileSuffix": "schema.json",
"strategies": {
"adapter": "bundle"
}
Expand Down
3 changes: 2 additions & 1 deletion src/resolve/adapters/mixedContentSourceAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { dirname, basename, sep } from 'path';
import { dirname, basename, sep, join } from 'path';
import { Messages, SfError } from '@salesforce/core';
import { baseName } from '../../utils/path';
import { SourcePath } from '../../common';
Expand Down Expand Up @@ -68,6 +68,7 @@ export class MixedContentSourceAdapter extends BaseSourceAdapter {
name: baseName(contentPath),
type: this.type,
content: contentPath,
xml: this.type.metaFileSuffix && join(contentPath, this.type.metaFileSuffix),
},
this.tree,
this.forceIgnore
Expand Down
1 change: 1 addition & 0 deletions test/mock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export {
mixedContentDirectory,
mixedContentInFolder,
mixedContentSingleFile,
experiencePropertyTypeContentSingleFile,
decomposed,
nonDecomposed,
decomposedtoplevel,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { join } from 'path';

import { registry, SourceComponent } from '../../../src';

/**
* Experience Property Type Bundle will be of the following shape:
*
* experiencePropertyTypeBundles/
* ├── prop1/
* | ├── schema.json
* | ├── design.json
*
* schema.json is always expected to be in the bundle, while design.json is optional.
*
* NOTE: there is no -meta.xml. schema.json acts as the meta XML file.
*/

// This is the type defined in metadataRegistry.json
const type = registry.types.experiencepropertytypebundle;

// This will be the root directory experiencePropertyTypeBundles.It is something like /path/to/experiencePropertyTypeBundles
export const TYPE_DIRECTORY = join('path', 'to', type.directoryName);

// This is the name of the property type we are creating.
export const COMPONENT_NAME = 'prop1';

// This is the schema.json and design.json paths inside the property type.
export const CONTENT_NAMES = [type.metaFileSuffix, 'design.json'];

// This is the complete path to the content. It is something like /path/to/experiencePropertyTypeBundles/prop1/schema.json.
export const CONTENT_PATHS = CONTENT_NAMES.map((n) => join(TYPE_DIRECTORY, join(COMPONENT_NAME, n)));

// Finally we construct our component.
export const COMPONENT = SourceComponent.createVirtualComponent(
{
name: COMPONENT_NAME,
type,
content: join(TYPE_DIRECTORY, COMPONENT_NAME),
xml: CONTENT_PATHS[0],
},
[
{
dirPath: TYPE_DIRECTORY,
children: [COMPONENT_NAME],
},
]
);
2 changes: 2 additions & 0 deletions test/mock/type-constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as document from './documentConstants';
import * as mixedContentDirectory from './staticresourceConstant';
import * as mixedContentInFolder from './documentFolderConstant';
import * as mixedContentSingleFile from './staticresourceComponentConstant';
import * as experiencePropertyTypeContentSingleFile from './experiencePropertyTypeBundleConstants';
import * as decomposed from './customObjectConstant';
import * as decomposedtoplevel from './customObjectTranslationConstant';
import * as nonDecomposed from './customlabelsConstant';
Expand All @@ -32,4 +33,5 @@ export {
nestedTypes,
lwcBundle,
digitalExperienceBundle,
experiencePropertyTypeContentSingleFile,
};
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[
{
"name": "componentSetCreate",
"duration": 345.28876100000343
"duration": 360.789472000004
},
{
"name": "sourceToMdapi",
"duration": 8330.387101
"duration": 8919.91247500002
},
{
"name": "sourceToZip",
"duration": 5822.162848000007
"duration": 6025.233091000002
},
{
"name": "mdapiToSource",
"duration": 6123.899523999979
"duration": 6253.451692000002
}
]
]
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[
{
"name": "componentSetCreate",
"duration": 675.3449159999727
"duration": 744.0605729999952
},
{
"name": "sourceToMdapi",
"duration": 11995.010080000007
"duration": 13127.422728999984
},
{
"name": "sourceToZip",
"duration": 9518.928809000005
"duration": 10371.91620399995
},
{
"name": "mdapiToSource",
"duration": 7432.586432000011
"duration": 7902.201856
}
]
]
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[
{
"name": "componentSetCreate",
"duration": 1170.5348080000258
"duration": 1188.3639100000146
},
{
"name": "sourceToMdapi",
"duration": 17969.274023000035
"duration": 18936.191220000037
},
{
"name": "sourceToZip",
"duration": 14706.58613000001
"duration": 15125.748401999997
},
{
"name": "mdapiToSource",
"duration": 13242.275161000027
"duration": 12817.04882299999
}
]
]
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[
{
"name": "componentSetCreate",
"duration": 222.67407499998808
"duration": 226.34448500000872
},
{
"name": "sourceToMdapi",
"duration": 6166.7441540000145
"duration": 4705.3344459999935
},
{
"name": "sourceToZip",
"duration": 4826.558009000029
"duration": 4886.161657999997
},
{
"name": "mdapiToSource",
"duration": 4281.85755700001
"duration": 4058.82406600003
}
]
]
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[
{
"name": "componentSetCreate",
"duration": 442.19902300002286
"duration": 447.82590599998366
},
{
"name": "sourceToMdapi",
"duration": 8834.219169000047
"duration": 8922.643469000002
},
{
"name": "sourceToZip",
"duration": 7419.940933000005
"duration": 6673.310636000009
},
{
"name": "mdapiToSource",
"duration": 5108.842208000016
"duration": 4866.022824999993
}
]
]
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[
{
"name": "componentSetCreate",
"duration": 780.378497000027
"duration": 774.8018560000346
},
{
"name": "sourceToMdapi",
"duration": 12146.644433000009
"duration": 12633.609111000027
},
{
"name": "sourceToZip",
"duration": 10558.852648
"duration": 10770.84330399998
},
{
"name": "mdapiToSource",
"duration": 9052.254910999967
"duration": 8976.685232000018
}
]
]
24 changes: 23 additions & 1 deletion test/resolve/adapters/mixedContentSourceAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
MIXED_CONTENT_DIRECTORY_CONTENT_PATH,
MIXED_CONTENT_DIRECTORY_VIRTUAL_FS_NO_XML,
} from '../../mock/type-constants/staticresourceConstant';
import { mixedContentDirectory, mixedContentSingleFile } from '../../mock';
import { mixedContentDirectory, mixedContentSingleFile, experiencePropertyTypeContentSingleFile } from '../../mock';

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

Expand Down Expand Up @@ -77,6 +77,28 @@ describe('MixedContentSourceAdapter', () => {
});
});

describe('Experience Property Type File Content', () => {
const component = experiencePropertyTypeContentSingleFile.COMPONENT;
const adapter = new MixedContentSourceAdapter(
registry.types.experiencepropertytypebundle,
registryAccess,
undefined,
component.tree
);

it('Should return expected SourceComponent when given a schema.json path', () => {
const result = adapter.getComponent(component.xml);

expect(result).to.deep.equal(component);
});

it('Should return expected SourceComponent when given a source path', () => {
const result = adapter.getComponent(component.content);

expect(result).to.deep.equal(component);
});
});

describe('Directory Content', () => {
const {
MIXED_CONTENT_DIRECTORY_COMPONENT,
Expand Down