Skip to content

Commit

Permalink
feat: Adds a new metadata bundle type for AppFrameworkTemplates (#1442)
Browse files Browse the repository at this point in the history
* feat(appFrameworkTemplateBundle): add support for appFrameworkTemplateBundle to sdr

* feat(appFrameworkTemplateBundle): add empty obj layout.json files

* feat(appFrameworkTemplateBundle): add straight empty layout.json files

* feat(appFrameworkTemplateBundle): trying to fix the layout.json test failures

* feat(appFrameworkTemplateBundle): {} layout.json

* feat(appFrameworkTemplateBundle): {} with another line layout.json

* feat(appFrameworkTemplateBundle): update type to string, string[] instead of | string[]
  • Loading branch information
rvwatch authored Oct 28, 2024
1 parent e59c087 commit 699cf7a
Show file tree
Hide file tree
Showing 13 changed files with 845 additions and 647 deletions.
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

0 comments on commit 699cf7a

Please sign in to comment.