sf-decomposer 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +9 -0
- package/README.md +341 -0
- package/lib/commands/decomposer/decompose.d.ts +17 -0
- package/lib/commands/decomposer/decompose.js +70 -0
- package/lib/commands/decomposer/decompose.js.map +1 -0
- package/lib/commands/decomposer/recompose.d.ts +16 -0
- package/lib/commands/decomposer/recompose.js +64 -0
- package/lib/commands/decomposer/recompose.js.map +1 -0
- package/lib/helpers/constants.d.ts +5 -0
- package/lib/helpers/constants.js +7 -0
- package/lib/helpers/constants.js.map +1 -0
- package/lib/hooks/scopedPostRetrieve.d.ts +12 -0
- package/lib/hooks/scopedPostRetrieve.js +51 -0
- package/lib/hooks/scopedPostRetrieve.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -0
- package/lib/metadata/getPackageDirectories.d.ts +1 -0
- package/lib/metadata/getPackageDirectories.js +50 -0
- package/lib/metadata/getPackageDirectories.js.map +1 -0
- package/lib/metadata/getRegistryValuesBySuffix.d.ts +9 -0
- package/lib/metadata/getRegistryValuesBySuffix.js +38 -0
- package/lib/metadata/getRegistryValuesBySuffix.js.map +1 -0
- package/lib/metadata/getUniqueIdElements.d.ts +1 -0
- package/lib/metadata/getUniqueIdElements.js +13 -0
- package/lib/metadata/getUniqueIdElements.js.map +1 -0
- package/lib/metadata/uniqueIdElements.json +66 -0
- package/lib/service/checkLogforErrors.d.ts +2 -0
- package/lib/service/checkLogforErrors.js +29 -0
- package/lib/service/checkLogforErrors.js.map +1 -0
- package/lib/service/decomposeFileHandler.d.ts +7 -0
- package/lib/service/decomposeFileHandler.js +74 -0
- package/lib/service/decomposeFileHandler.js.map +1 -0
- package/lib/service/moveFiles.d.ts +1 -0
- package/lib/service/moveFiles.js +17 -0
- package/lib/service/moveFiles.js.map +1 -0
- package/lib/service/recomposeFileHandler.d.ts +6 -0
- package/lib/service/recomposeFileHandler.js +82 -0
- package/lib/service/recomposeFileHandler.js.map +1 -0
- package/lib/service/renameBotVersionFiles.d.ts +1 -0
- package/lib/service/renameBotVersionFiles.js +23 -0
- package/lib/service/renameBotVersionFiles.js.map +1 -0
- package/messages/decomposer.decompose.md +36 -0
- package/messages/decomposer.recompose.md +30 -0
- package/oclif.lock +12481 -0
- package/oclif.manifest.json +166 -0
- package/package.json +202 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* eslint-disable no-await-in-loop */
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { resolve, join } from 'node:path';
|
|
5
|
+
import { readFile, readdir, stat } from 'node:fs/promises';
|
|
6
|
+
import { simpleGit } from 'simple-git';
|
|
7
|
+
import { SFDX_PROJECT_FILE_NAME } from '../helpers/constants.js';
|
|
8
|
+
export async function getPackageDirectories(metaDirectory) {
|
|
9
|
+
const options = {
|
|
10
|
+
baseDir: process.cwd(),
|
|
11
|
+
binary: 'git',
|
|
12
|
+
maxConcurrentProcesses: 6,
|
|
13
|
+
trimmed: true,
|
|
14
|
+
};
|
|
15
|
+
const git = simpleGit(options);
|
|
16
|
+
const repoRoot = (await git.revparse('--show-toplevel')).trim();
|
|
17
|
+
const dxConfigPath = resolve(repoRoot, SFDX_PROJECT_FILE_NAME);
|
|
18
|
+
if (!existsSync(dxConfigPath)) {
|
|
19
|
+
throw Error(`Salesforce DX Config File does not exist in this path: ${dxConfigPath}`);
|
|
20
|
+
}
|
|
21
|
+
const sfdxProjectRaw = await readFile(dxConfigPath, 'utf-8');
|
|
22
|
+
const sfdxProject = JSON.parse(sfdxProjectRaw);
|
|
23
|
+
const packageDirectories = sfdxProject.packageDirectories.map((directory) => resolve(repoRoot, directory.path));
|
|
24
|
+
const metadataPaths = [];
|
|
25
|
+
for (const directory of packageDirectories) {
|
|
26
|
+
const filePath = await searchRecursively(directory, metaDirectory);
|
|
27
|
+
if (filePath !== undefined) {
|
|
28
|
+
metadataPaths.push(resolve(filePath));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return metadataPaths;
|
|
32
|
+
}
|
|
33
|
+
async function searchRecursively(dxDirectory, subDirectoryName) {
|
|
34
|
+
const files = await readdir(dxDirectory);
|
|
35
|
+
for (const file of files) {
|
|
36
|
+
const filePath = join(dxDirectory, file);
|
|
37
|
+
const stats = await stat(filePath);
|
|
38
|
+
if (stats.isDirectory() && file !== subDirectoryName) {
|
|
39
|
+
const result = await searchRecursively(filePath, subDirectoryName);
|
|
40
|
+
if (result) {
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (stats.isDirectory() && file === subDirectoryName) {
|
|
45
|
+
return filePath;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=getPackageDirectories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPackageDirectories.js","sourceRoot":"","sources":["../../src/metadata/getPackageDirectories.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAA+B,MAAM,YAAY,CAAC;AAEpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAMjE,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,aAAqB;IAC/D,MAAM,OAAO,GAA8B;QACzC,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE;QACtB,MAAM,EAAE,KAAK;QACb,sBAAsB,EAAE,CAAC;QACzB,OAAO,EAAE,IAAI;KACd,CAAC;IACF,MAAM,GAAG,GAAc,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CAAC,QAAQ,CAAC,CAAC;QACnC,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;YACrD,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;YACnE,IAAI,MAAM,EAAE,CAAC;gBACX,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;YAC5D,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface MetaAttributes {
|
|
2
|
+
metaSuffix: string;
|
|
3
|
+
strictDirectoryName: boolean;
|
|
4
|
+
folderType: string;
|
|
5
|
+
metadataPaths: string[];
|
|
6
|
+
uniqueIdElements: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function getRegistryValuesBySuffix(metaSuffix: string, command: string): Promise<MetaAttributes>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { RegistryAccess } from '@salesforce/source-deploy-retrieve';
|
|
3
|
+
import { DEFAULT_UNIQUE_ID_ELEMENTS } from '../helpers/constants.js';
|
|
4
|
+
import { getUniqueIdElements } from './getUniqueIdElements.js';
|
|
5
|
+
import { getPackageDirectories } from './getPackageDirectories.js';
|
|
6
|
+
export async function getRegistryValuesBySuffix(metaSuffix, command) {
|
|
7
|
+
if (metaSuffix === 'object') {
|
|
8
|
+
throw Error('Custom Objects are not supported by this plugin.');
|
|
9
|
+
}
|
|
10
|
+
if (metaSuffix === 'botVersion') {
|
|
11
|
+
throw Error('`botVersion` suffix should not be used. Please use `bot` to decompose/recompose bot and bot version files.');
|
|
12
|
+
}
|
|
13
|
+
const registryAccess = new RegistryAccess();
|
|
14
|
+
const metadataTypeEntry = registryAccess.getTypeBySuffix(metaSuffix);
|
|
15
|
+
if (metadataTypeEntry === undefined)
|
|
16
|
+
throw Error(`Metadata type not found for the given suffix: ${metaSuffix}.`);
|
|
17
|
+
if (metadataTypeEntry.strategies?.adapter &&
|
|
18
|
+
['matchingContentFile', 'digitalExperience', 'mixedContent', 'bundle'].includes(metadataTypeEntry.strategies.adapter)) {
|
|
19
|
+
throw Error(`Metadata types with ${metadataTypeEntry.strategies.adapter} strategies are not supported by this plugin.`);
|
|
20
|
+
}
|
|
21
|
+
let uniqueIdElements;
|
|
22
|
+
if (command === 'decompose')
|
|
23
|
+
uniqueIdElements = await getUniqueIdElements(metaSuffix);
|
|
24
|
+
const metadataPaths = await getPackageDirectories(`${metadataTypeEntry.directoryName}`);
|
|
25
|
+
if (metadataPaths.length === 0)
|
|
26
|
+
throw Error(`No directories named ${metadataTypeEntry.directoryName} were found in any package directory.`);
|
|
27
|
+
const metaAttributes = {
|
|
28
|
+
metaSuffix: metadataTypeEntry.suffix,
|
|
29
|
+
strictDirectoryName: metadataTypeEntry.strictDirectoryName,
|
|
30
|
+
folderType: metadataTypeEntry.folderType,
|
|
31
|
+
metadataPaths,
|
|
32
|
+
uniqueIdElements: uniqueIdElements
|
|
33
|
+
? `${DEFAULT_UNIQUE_ID_ELEMENTS},${uniqueIdElements}`
|
|
34
|
+
: DEFAULT_UNIQUE_ID_ELEMENTS,
|
|
35
|
+
};
|
|
36
|
+
return metaAttributes;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=getRegistryValuesBySuffix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRegistryValuesBySuffix.js","sourceRoot":"","sources":["../../src/metadata/getRegistryValuesBySuffix.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,cAAc,EAAgB,MAAM,oCAAoC,CAAC;AAElF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,m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AmB,EAAE,iBAAiB,CAAC,mBAA8B;QACrE,UAAU,EAAE,iBAAiB,CAAC,UAAoB;QAClD,aAAa;QACb,gBAAgB,EAAE,gBAAgB;YAChC,CAAC,CAAC,GAAG,0BAA0B,IAAI,gBAAgB,EAAE;YACrD,CAAC,CAAC,0BAA0B;KAC/B,CAAC;IACF,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getUniqueIdElements(metaSuffix: string): Promise<string | undefined>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
export async function getUniqueIdElements(metaSuffix) {
|
|
4
|
+
const fileContent = await readFile(new URL('./uniqueIdElements.json', import.meta.url), 'utf-8');
|
|
5
|
+
const jsonData = JSON.parse(fileContent);
|
|
6
|
+
if (metaSuffix in jsonData) {
|
|
7
|
+
return jsonData[metaSuffix].uniqueIdElements.join(',');
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=getUniqueIdElements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUniqueIdElements.js","sourceRoot":"","sources":["../../src/metadata/getUniqueIdElements.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAQ5C,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,UAAkB;IAC1D,MAAM,WAAW,GAAW,MAAM,QAAQ,CAAC,IAAI,GAAG,CAAC,yBAAyB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;IACzG,MAAM,QAAQ,GAAqB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAqB,CAAC;IAE/E,IAAI,UAAU,IAAI,QAAQ,EAAE,CAAC;QAC3B,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,CAAC;SAAM,CAAC;QACN,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"profile": {
|
|
3
|
+
"uniqueIdElements": [
|
|
4
|
+
"application",
|
|
5
|
+
"apexClass",
|
|
6
|
+
"externalDataSource",
|
|
7
|
+
"flow",
|
|
8
|
+
"object",
|
|
9
|
+
"apexPage",
|
|
10
|
+
"recordType",
|
|
11
|
+
"tab",
|
|
12
|
+
"field",
|
|
13
|
+
"startAddress",
|
|
14
|
+
"dataCategoryGroup",
|
|
15
|
+
"layout",
|
|
16
|
+
"weekdayStart",
|
|
17
|
+
"friendlyname"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
"permissionset": {
|
|
21
|
+
"uniqueIdElements": [
|
|
22
|
+
"application",
|
|
23
|
+
"apexClass",
|
|
24
|
+
"externalDataSource",
|
|
25
|
+
"flow",
|
|
26
|
+
"object",
|
|
27
|
+
"apexPage",
|
|
28
|
+
"recordType",
|
|
29
|
+
"tab",
|
|
30
|
+
"field"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"flow": {
|
|
34
|
+
"uniqueIdElements": [
|
|
35
|
+
"apexClass",
|
|
36
|
+
"object",
|
|
37
|
+
"field",
|
|
38
|
+
"layout",
|
|
39
|
+
"actionName",
|
|
40
|
+
"targetReference",
|
|
41
|
+
"assignToReference",
|
|
42
|
+
"choiceText",
|
|
43
|
+
"promptText"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"globalValueSetTranslation": {
|
|
47
|
+
"uniqueIdElements": ["masterLabel"]
|
|
48
|
+
},
|
|
49
|
+
"standardValueSetTranslation": {
|
|
50
|
+
"uniqueIdElements": ["masterLabel"]
|
|
51
|
+
},
|
|
52
|
+
"bot": {
|
|
53
|
+
"uniqueIdElements": [
|
|
54
|
+
"developerName",
|
|
55
|
+
"stepIdentifier",
|
|
56
|
+
"invocationActionName",
|
|
57
|
+
"parameterName",
|
|
58
|
+
"nlpProviderType",
|
|
59
|
+
"dialog",
|
|
60
|
+
"chatButtonName"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
"marketingappextension": {
|
|
64
|
+
"uniqueIdElements": ["apiName"]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
export async function readOriginalLogFile(logFile) {
|
|
4
|
+
let originalLog;
|
|
5
|
+
try {
|
|
6
|
+
originalLog = (await readFile(logFile, 'utf-8')).split('\n');
|
|
7
|
+
}
|
|
8
|
+
catch (err) {
|
|
9
|
+
originalLog = [];
|
|
10
|
+
}
|
|
11
|
+
return originalLog;
|
|
12
|
+
}
|
|
13
|
+
export async function checkLogForErrors(logFile, originalLogContents) {
|
|
14
|
+
let currentLog;
|
|
15
|
+
const newErrors = [];
|
|
16
|
+
try {
|
|
17
|
+
currentLog = (await readFile(logFile, 'utf-8')).split('\n');
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
return newErrors;
|
|
21
|
+
}
|
|
22
|
+
for (const line of currentLog) {
|
|
23
|
+
if (!originalLogContents.includes(line) && line.includes('[ERROR]')) {
|
|
24
|
+
newErrors.push(line);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return newErrors;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=checkLogforErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkLogforErrors.js","sourceRoot":"","sources":["../../src/service/checkLogforErrors.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAe;IACvD,IAAI,WAAqB,CAAC;IAC1B,IAAI,CAAC;QACH,WAAW,GAAG,CAAC,MAAM,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,WAAW,GAAG,EAAE,CAAC;IACnB,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAAe,EAAE,mBAA6B;IACpF,IAAI,UAAoB,CAAC;IACzB,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,IAAI,CAAC;QACH,UAAU,GAAG,CAAC,MAAM,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC9B,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACpE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function decomposeFileHandler(metaAttributes: {
|
|
2
|
+
metadataPaths: string[];
|
|
3
|
+
metaSuffix: string;
|
|
4
|
+
strictDirectoryName: boolean;
|
|
5
|
+
folderType: string;
|
|
6
|
+
uniqueIdElements: string;
|
|
7
|
+
}, prepurge: boolean, postpurge: boolean, debug: boolean, format: string): Promise<void>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* eslint-disable no-await-in-loop */
|
|
3
|
+
import { resolve, join } from 'node:path';
|
|
4
|
+
import { readdir, stat, rm } from 'node:fs/promises';
|
|
5
|
+
import { DisassembleXMLFileHandler, setLogLevel } from 'xml-disassembler';
|
|
6
|
+
import { XmlToYamlDisassembler } from 'xml2yaml-disassembler';
|
|
7
|
+
import { XmlToJsonDisassembler } from 'xml2json-disassembler';
|
|
8
|
+
import { CUSTOM_LABELS_FILE } from '../helpers/constants.js';
|
|
9
|
+
import { moveFiles } from './moveFiles.js';
|
|
10
|
+
export async function decomposeFileHandler(metaAttributes, prepurge, postpurge, debug, format) {
|
|
11
|
+
const { metadataPaths, metaSuffix, strictDirectoryName, folderType, uniqueIdElements } = metaAttributes;
|
|
12
|
+
if (debug)
|
|
13
|
+
setLogLevel('debug');
|
|
14
|
+
for (const metadataPath of metadataPaths) {
|
|
15
|
+
if (strictDirectoryName || folderType) {
|
|
16
|
+
await subDirectoryHandler(metadataPath, uniqueIdElements, prepurge, postpurge, format);
|
|
17
|
+
}
|
|
18
|
+
else if (metaSuffix === 'labels') {
|
|
19
|
+
// do not use the prePurge flag in the xml-disassembler package for labels due to file moving
|
|
20
|
+
if (prepurge)
|
|
21
|
+
await prePurgeLabels(metadataPath);
|
|
22
|
+
const labelFilePath = resolve(metadataPath, CUSTOM_LABELS_FILE);
|
|
23
|
+
await disassembleHandler(labelFilePath, uniqueIdElements, false, postpurge, format);
|
|
24
|
+
// move labels from the directory they are created in
|
|
25
|
+
await moveLabels(metadataPath);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
await disassembleHandler(metadataPath, uniqueIdElements, prepurge, postpurge, format);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function disassembleHandler(filePath, uniqueIdElements, prepurge, postpurge, format) {
|
|
33
|
+
let handler;
|
|
34
|
+
if (format === 'yaml') {
|
|
35
|
+
handler = new XmlToYamlDisassembler();
|
|
36
|
+
}
|
|
37
|
+
else if (format === 'json') {
|
|
38
|
+
handler = new XmlToJsonDisassembler();
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
handler = new DisassembleXMLFileHandler();
|
|
42
|
+
}
|
|
43
|
+
await handler.disassemble({
|
|
44
|
+
filePath,
|
|
45
|
+
uniqueIdElements,
|
|
46
|
+
prePurge: prepurge,
|
|
47
|
+
postPurge: postpurge,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async function prePurgeLabels(metadataPath) {
|
|
51
|
+
const subFiles = await readdir(metadataPath);
|
|
52
|
+
for (const subFile of subFiles) {
|
|
53
|
+
const subfilePath = join(metadataPath, subFile);
|
|
54
|
+
if ((await stat(subfilePath)).isFile() && subFile !== CUSTOM_LABELS_FILE) {
|
|
55
|
+
await rm(subfilePath, { recursive: true });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async function moveLabels(metadataPath) {
|
|
60
|
+
const sourceDirectory = join(metadataPath, 'CustomLabels', 'labels');
|
|
61
|
+
const destinationDirectory = metadataPath;
|
|
62
|
+
await moveFiles(sourceDirectory, destinationDirectory, () => true);
|
|
63
|
+
await rm(join(metadataPath, 'CustomLabels'), { recursive: true });
|
|
64
|
+
}
|
|
65
|
+
async function subDirectoryHandler(metadataPath, uniqueIdElements, prepurge, postpurge, format) {
|
|
66
|
+
const subFiles = await readdir(metadataPath);
|
|
67
|
+
for (const subFile of subFiles) {
|
|
68
|
+
const subFilePath = join(metadataPath, subFile);
|
|
69
|
+
if ((await stat(subFilePath)).isDirectory()) {
|
|
70
|
+
await disassembleHandler(subFilePath, uniqueIdElements, prepurge, postpurge, format);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=decomposeFileHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decomposeFileHandler.js","sourceRoot":"","sources":["../../src/service/decomposeFileHandler.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AACrC,OAAO,EAAE,OAA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C;IAC1C,MAAM,SAAS,CAAC,eAAe,EAAE,oBAAoB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACnE,MAAM,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACpE,CAAC;AAED,KAAK,UAAU,mBAAmB,CAChC,YAAoB,EACpB,gBAAwB,EACxB,QAAiB,EACjB,SAAkB,EAClB,MAAc;IAEd,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;IAC7C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAChD,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YAC5C,MAAM,kBAAkB,CAAC,WAAW,EAAE,gBAAgB,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function moveFiles(sourceDirectory: string, destinationDirectory: string, predicate: (fileName: string) => boolean): Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* eslint-disable no-await-in-loop */
|
|
3
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { move } from 'fs-extra';
|
|
6
|
+
export async function moveFiles(sourceDirectory, destinationDirectory, predicate) {
|
|
7
|
+
const files = await readdir(sourceDirectory);
|
|
8
|
+
for (const file of files) {
|
|
9
|
+
const fileStat = await stat(join(sourceDirectory, file));
|
|
10
|
+
if (fileStat.isFile() && predicate(file)) {
|
|
11
|
+
const sourceFile = join(sourceDirectory, file);
|
|
12
|
+
const destinationFile = join(destinationDirectory, file);
|
|
13
|
+
await move(sourceFile, destinationFile, { overwrite: true });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=moveFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moveFiles.js","sourceRoot":"","sources":["../../src/service/moveFiles.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,eAAuB,EACvB,oBAA4B,EAC5B,SAAwC;IAExC,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC;QACzD,IAAI,QAAQ,CAAC,MAAM,EAAE,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;YACzC,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;YAC/C,MAAM,eAAe,GAAG,IAAI,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC;YACzD,MAAM,IAAI,CAAC,UAAU,EAAE,eAAe,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* eslint-disable no-await-in-loop */
|
|
3
|
+
import { readdir, stat, rm } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { ReassembleXMLFileHandler, setLogLevel } from 'xml-disassembler';
|
|
6
|
+
import { YamlToXmlReassembler } from 'xml2yaml-disassembler';
|
|
7
|
+
import { JsonToXmlReassembler } from 'xml2json-disassembler';
|
|
8
|
+
import { CUSTOM_LABELS_FILE } from '../helpers/constants.js';
|
|
9
|
+
import { renameBotVersionFile } from './renameBotVersionFiles.js';
|
|
10
|
+
import { moveFiles } from './moveFiles.js';
|
|
11
|
+
export async function recomposeFileHandler(metaAttributes, postpurge, debug, format) {
|
|
12
|
+
const { metaSuffix, strictDirectoryName, folderType, metadataPaths } = metaAttributes;
|
|
13
|
+
if (debug)
|
|
14
|
+
setLogLevel('debug');
|
|
15
|
+
for (const metadataPath of metadataPaths) {
|
|
16
|
+
if (metaSuffix === 'labels') {
|
|
17
|
+
await reassembleLabels(metadataPath, metaSuffix, postpurge, format);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
let recurse = false;
|
|
21
|
+
if (strictDirectoryName || folderType)
|
|
22
|
+
recurse = true;
|
|
23
|
+
await reassembleDirectories(metadataPath, metaSuffix, recurse, postpurge, format);
|
|
24
|
+
}
|
|
25
|
+
if (metaSuffix === 'bot')
|
|
26
|
+
await renameBotVersionFile(metadataPath);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async function reassembleHandler(filePath, fileExtension, postPurge, format) {
|
|
30
|
+
let handler;
|
|
31
|
+
if (format === 'yaml') {
|
|
32
|
+
handler = new YamlToXmlReassembler();
|
|
33
|
+
}
|
|
34
|
+
else if (format === 'json') {
|
|
35
|
+
handler = new JsonToXmlReassembler();
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
handler = new ReassembleXMLFileHandler();
|
|
39
|
+
}
|
|
40
|
+
await handler.reassemble({
|
|
41
|
+
filePath,
|
|
42
|
+
fileExtension,
|
|
43
|
+
postPurge,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async function reassembleLabels(metadataPath, metaSuffix, postpurge, format) {
|
|
47
|
+
let sourceDirectory = metadataPath;
|
|
48
|
+
let destinationDirectory = join(metadataPath, 'CustomLabels', 'labels');
|
|
49
|
+
await moveFiles(sourceDirectory, destinationDirectory, (fileName) => fileName !== CUSTOM_LABELS_FILE);
|
|
50
|
+
// do not use postpurge flag due to file moving
|
|
51
|
+
await reassembleHandler(join(metadataPath, 'CustomLabels'), `${metaSuffix}-meta.xml`, false, format);
|
|
52
|
+
sourceDirectory = join(metadataPath, 'CustomLabels', 'labels');
|
|
53
|
+
destinationDirectory = metadataPath;
|
|
54
|
+
await moveFiles(sourceDirectory, destinationDirectory, () => true);
|
|
55
|
+
await rm(join(metadataPath, 'CustomLabels'), { recursive: true });
|
|
56
|
+
if (postpurge)
|
|
57
|
+
await deleteFilesInDirectory(destinationDirectory);
|
|
58
|
+
}
|
|
59
|
+
async function deleteFilesInDirectory(directory) {
|
|
60
|
+
const files = await readdir(directory);
|
|
61
|
+
for (const file of files) {
|
|
62
|
+
const filePath = join(directory, file);
|
|
63
|
+
const fileStat = await stat(filePath);
|
|
64
|
+
if (fileStat.isFile() && file !== CUSTOM_LABELS_FILE) {
|
|
65
|
+
await rm(filePath);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function reassembleDirectories(metadataPath, metaSuffix, recurse, postpurge, format) {
|
|
70
|
+
const subdirectories = (await readdir(metadataPath)).map((file) => join(metadataPath, file));
|
|
71
|
+
for (const subdirectory of subdirectories) {
|
|
72
|
+
const subDirStat = await stat(subdirectory);
|
|
73
|
+
if (subDirStat.isDirectory() && recurse) {
|
|
74
|
+
// recursively call this function and set recurse to false
|
|
75
|
+
await reassembleDirectories(subdirectory, metaSuffix, false, postpurge, format);
|
|
76
|
+
}
|
|
77
|
+
else if (subDirStat.isDirectory()) {
|
|
78
|
+
await reassembleHandler(subdirectory, `${metaSuffix}-meta.xml`, postpurge, format);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=recomposeFileHandler.js.map
|
|
@@ -0,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AE,SAAS,EAAE,MAAM,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renameBotVersionFile(metadataPath: string): Promise<void>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* eslint-disable no-await-in-loop */
|
|
3
|
+
import { lstat, readdir, rename } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
export async function renameBotVersionFile(metadataPath) {
|
|
6
|
+
const subDirectories = await readdir(metadataPath);
|
|
7
|
+
for (const subDirectory of subDirectories) {
|
|
8
|
+
const subDirectoryPath = join(metadataPath, subDirectory);
|
|
9
|
+
const stats = await lstat(subDirectoryPath);
|
|
10
|
+
if (stats.isDirectory()) {
|
|
11
|
+
const files = await readdir(subDirectoryPath);
|
|
12
|
+
for (const file of files) {
|
|
13
|
+
// Check if the bot meta file name contains "v" followed by a number
|
|
14
|
+
if (/v\d+\.bot-meta\.xml$/.test(file)) {
|
|
15
|
+
const sourcePath = join(subDirectoryPath, file);
|
|
16
|
+
const destinationPath = join(subDirectoryPath, file.replace('bot-meta.xml', 'botVersion-meta.xml'));
|
|
17
|
+
await rename(sourcePath, destinationPath);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=renameBotVersionFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renameBotVersionFiles.js","sourceRoot":"","sources":["../../src/service/renameBotVersionFiles.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AACrC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,YAAoB;IAC7D,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;IACnD,KAAK,MAAM,YAAY,IAAI,cAAc,EAAE,CAAC;QAC1C,MAAM,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QAE1D,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC5C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,gBAAgB,CAAC,CAAC;YAC9C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,oEAAoE;gBACpE,IAAI,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;oBACtC,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;oBAChD,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,qBAAqB,CAAC,CAAC,CAAC;oBACpG,MAAM,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;gBAC5C,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Decomposes the metadata files created by retrievals.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
This command will read all of the original metadata files and separate them into smaller files.
|
|
8
|
+
|
|
9
|
+
These smaller decomposed files can be XMLs, YAMLs, or JSONs.
|
|
10
|
+
|
|
11
|
+
You should use this to create files for version control after retrieving metadata from an org.
|
|
12
|
+
|
|
13
|
+
# examples
|
|
14
|
+
|
|
15
|
+
- `sf decomposer decompose -m "flow" -f "xml" --prepurge --postpurge --debug`
|
|
16
|
+
- `sf decomposer decompose -m "flow" -m "labels" -f "xml" --prepurge --postpurge --debug`
|
|
17
|
+
|
|
18
|
+
# flags.metadata-type.summary
|
|
19
|
+
|
|
20
|
+
The metadata suffix to process, such as 'flow', 'labels', etc. You can provide this flag multiple times to process multiple metadata types at once.
|
|
21
|
+
|
|
22
|
+
# flags.prepurge.summary
|
|
23
|
+
|
|
24
|
+
If provided, purge directories of pre-existing decomposed files.
|
|
25
|
+
|
|
26
|
+
# flags.postpurge.summary
|
|
27
|
+
|
|
28
|
+
If provided, purge the original files after decomposing them.
|
|
29
|
+
|
|
30
|
+
# flags.debug.summary
|
|
31
|
+
|
|
32
|
+
If provided, debug to log file.
|
|
33
|
+
|
|
34
|
+
# flags.format.summary
|
|
35
|
+
|
|
36
|
+
File format for the decomposed files.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Recomposes the files created by the `decompose` command prior to deployments.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
This command will read all of the decomposed files and recreate deployment compatible metadata files in each package directory.
|
|
8
|
+
|
|
9
|
+
You should run this before you deploy the metadata to an org.
|
|
10
|
+
|
|
11
|
+
# examples
|
|
12
|
+
|
|
13
|
+
- `sf decomposer recompose -m "flow" -f "xml" --postpurge --debug`
|
|
14
|
+
- `sf decomposer recompose -m "flow" -m "labels" -f "xml" --postpurge --debug`
|
|
15
|
+
|
|
16
|
+
# flags.metadata-type.summary
|
|
17
|
+
|
|
18
|
+
The metadata suffix to process, such as 'flow', 'labels', etc. You can provide this flag multiple times to process multiple metadata types at once.
|
|
19
|
+
|
|
20
|
+
# flags.postpurge.summary
|
|
21
|
+
|
|
22
|
+
If provided, purge the decomposed files after recomposing them.
|
|
23
|
+
|
|
24
|
+
# flags.debug.summary
|
|
25
|
+
|
|
26
|
+
If provided, debug to log file.
|
|
27
|
+
|
|
28
|
+
# flags.format.summary
|
|
29
|
+
|
|
30
|
+
File format for the decomposed files.
|