Skip to content
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

Qa/1442 #1447

Closed
wants to merge 7 commits into from
Closed
1,294 changes: 655 additions & 639 deletions METADATA_SUPPORT.md

Large diffs are not rendered by default.

52 changes: 50 additions & 2 deletions src/registry/metadataRegistry.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
"siteDotComSites": "sitedotcom",
"sites": "customsite",
"staticresources": "staticresource",
"waveTemplates": "wavetemplatebundle"
"waveTemplates": "wavetemplatebundle",
"appTemplates": "appframeworktemplatebundle"
},
"suffixes": {
"Canvas": "canvasmetadata",
Expand Down Expand Up @@ -521,7 +522,11 @@
"xml": "emailservicesfunction",
"xorghub": "xorghub",
"ecaPush": "extlclntapppushsettings",
"ecaPushPlcy": "extlclntapppushconfigurablepolicies"
"ecaPushPlcy": "extlclntapppushconfigurablepolicies",
"ChoiceList": "choicelist",
"ConvIntelligenceSignalRule": "convintelligencesignalrule",
"PublicKeyCertificate": "publickeycertificate",
"PublicKeyCertificateSet": "publickeycertificateset"
},
"types": {
"accesscontrolpolicy": {
Expand Down Expand Up @@ -4639,6 +4644,49 @@
"directoryName": "extlClntAppPushPolicies",
"inFolder": false,
"strictDirectoryName": false
},
"appframeworktemplatebundle": {
"directoryName": "appTemplates",
"id": "appframeworktemplatebundle",
"name": "AppFrameworkTemplateBundle",
"inFolder": false,
"strategies": {
"adapter": "bundle"
},
"strictDirectoryName": true,
"supportsPartialDelete": true
},
"choicelist": {
"id": "choicelist",
"name": "ChoiceList",
"suffix": "ChoiceList",
"directoryName": "ChoiceList",
"inFolder": false,
"strictDirectoryName": false
},
"convintelligencesignalrule": {
"id": "convintelligencesignalrule",
"name": "ConvIntelligenceSignalRule",
"suffix": "ConvIntelligenceSignalRule",
"directoryName": "ConvIntelligenceSignalRule",
"inFolder": false,
"strictDirectoryName": false
},
"publickeycertificate": {
"id": "publickeycertificate",
"name": "PublicKeyCertificate",
"suffix": "PublicKeyCertificate",
"directoryName": "PublicKeyCertificate",
"inFolder": false,
"strictDirectoryName": false
},
"publickeycertificateset": {
"id": "publickeycertificateset",
"name": "PublicKeyCertificateSet",
"suffix": "PublicKeyCertificateSet",
"directoryName": "PublicKeyCertificateSet",
"inFolder": false,
"strictDirectoryName": false
}
}
}
21 changes: 15 additions & 6 deletions src/utils/filePathGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,26 @@ export const filePathsFromMetadataComponent = (

// lwc, aura, waveTemplate, experiencePropertyType
if (type.strategies?.adapter === 'bundle') {
const mappings = new Map<string, string>([
['ExperiencePropertyTypeBundle', join(packageDirWithTypeDir, `${fullName}${sep}schema.json`)],
['WaveTemplateBundle', join(packageDirWithTypeDir, `${fullName}${sep}template-info.json`)],
['LightningComponentBundle', join(packageDirWithTypeDir, `${fullName}${sep}${fullName}.js${META_XML_SUFFIX}`)],
['AuraDefinitionBundle', join(packageDirWithTypeDir, `${fullName}${sep}${fullName}.cmp${META_XML_SUFFIX}`)],
const mappings = new Map<string, string[]>([
['ExperiencePropertyTypeBundle', [join(packageDirWithTypeDir, `${fullName}${sep}schema.json`)]],
['WaveTemplateBundle', [join(packageDirWithTypeDir, `${fullName}${sep}template-info.json`)]],
['LightningComponentBundle', [join(packageDirWithTypeDir, `${fullName}${sep}${fullName}.js${META_XML_SUFFIX}`)]],
['AuraDefinitionBundle', [join(packageDirWithTypeDir, `${fullName}${sep}${fullName}.cmp${META_XML_SUFFIX}`)]],
[
'AppFrameworkTemplateBundle',
[
join(packageDirWithTypeDir, `${fullName}${sep}template-info.json`),
join(packageDirWithTypeDir, `${fullName}${sep}layout.json`),
],
],
]);

const matched = mappings.get(type.name);
if (!matched) {
throw messages.createError('unsupportedBundleType', [type.name]);
}
return [matched];

return matched;
}

throw messages.createError('filePathGeneratorNoTypeSupport', [type.name]);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"templateType": "App",
"label": "my test template",
"name": "test_template",
"namespace": null,
"assetVersion": 63.0,
"maxAppCount": null,
"layoutDefinition": "layout.json",
"tags": {},
"chainDefinitions": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>force-app</members>
<name>AppFrameworkTemplateBundle</name>
</types>
<version>62.0</version>
</Package>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"templateType": "App",
"label": "my test template",
"name": "test_template",
"namespace": null,
"assetVersion": 63.0,
"maxAppCount": null,
"layoutDefinition": "layout.json",
"tags": {},
"chainDefinitions": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"templateType": "App",
"label": "my test template",
"name": "test_template",
"namespace": null,
"assetVersion": 63.0,
"maxAppCount": null,
"layoutDefinition": "layout.json",
"tags": {},
"chainDefinitions": []
}
11 changes: 11 additions & 0 deletions test/snapshot/sampleProjects/appTemplates/sfdx-project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"packageDirectories": [
{
"default": true,
"path": "force-app"
}
],
"name": "appTemplatesTestProject",
"namespace": "",
"sourceApiVersion": "62.0"
}
53 changes: 53 additions & 0 deletions test/snapshot/sampleProjects/appTemplates/snapshots.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2024, 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 * as fs from 'node:fs';
import * as path from 'node:path';
import {
FORCE_APP,
MDAPI_OUT,
dirsAreIdentical,
fileSnap,
mdapiToSource,
sourceToMdapi,
} from '../../helper/conversions';

// we don't want failing tests outputting over each other
/* eslint-disable no-await-in-loop */

describe('appTemplates', () => {
const testDir = path.join('test', 'snapshot', 'sampleProjects', 'appTemplates');
let sourceFiles: string[];
let mdFiles: string[];

before(async () => {
sourceFiles = await mdapiToSource(testDir);
mdFiles = await sourceToMdapi(testDir);
});

it('verify source files', async () => {
for (const file of sourceFiles) {
await fileSnap(file, testDir);
}
dirsAreIdentical(
path.join(testDir, FORCE_APP),
path.join(testDir, '__snapshots__', 'verify-source-files.expected', FORCE_APP)
);
});

it('verify md files', async () => {
for (const file of mdFiles) {
await fileSnap(file, testDir);
}
});

after(async () => {
await Promise.all([
fs.promises.rm(path.join(testDir, FORCE_APP), { recursive: true, force: true }),
fs.promises.rm(path.join(testDir, MDAPI_OUT), { recursive: true, force: true }),
]);
});
});
17 changes: 17 additions & 0 deletions test/utils/filePathGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@ const testData = {
},
],
},
bundleAppTemplates: {
fullName: 'test_template',
typeName: 'AppFrameworkTemplateBundle',
expectedFilePaths: [
getFilePath('appTemplates/test_template/template-info.json'),
getFilePath('appTemplates/test_template/layout.json'),
],
expectedComponents: [
{
content: getFilePath('appTemplates/test_template'),
},
],
},
nonDecomposedExplicit: {
fullName: 'CustomLabels',
typeName: 'CustomLabels',
Expand Down Expand Up @@ -304,6 +317,10 @@ describe('generating virtual tree from component name/type', () => {
it('waveTemplate', () => {
runTest(testData.bundleWave);
});

it('appFrameworkTemplate', () => {
runTest(testData.bundleAppTemplates);
});
});

describe('adapter = nondecomposed', () => {
Expand Down
Loading