Skip to content

Commit

Permalink
Merge branch 'migrate-sf-plugin' into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
nvuillam committed Sep 8, 2024
2 parents 69bbe4d + fa5063f commit e5ec951
Show file tree
Hide file tree
Showing 6 changed files with 2,316 additions and 1,330 deletions.
2 changes: 2 additions & 0 deletions .github/linters/.cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"emailservices",
"emailvalid",
"emptyitems",
"errorflow",
"erroronwarnings",
"errorprone",
"eslintcache",
Expand Down Expand Up @@ -686,6 +687,7 @@
"regexes",
"relatedentitytype",
"relatednotifications",
"releaseupdates",
"remotesites",
"removedonly",
"removepackagexml",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"@actions/github": "^6.0.0",
"@gitbeaker/node": "^35.8.1",
"@oclif/core": "^4.0.19",
"@oclif/core": "^4.0.21",
"@salesforce/core": "^8.5.3",
"@salesforce/sf-plugins-core": "^11.3.7",
"@slack/types": "^2.12.0",
Expand Down Expand Up @@ -85,7 +85,7 @@
"@types/ws": "^8.5.12",
"@types/xml2js": "^0.4.14",
"eslint-plugin-sf-plugin": "^1.18.6",
"oclif": "^4.14.0",
"oclif": "^4.14.31",
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
},
Expand Down
6 changes: 5 additions & 1 deletion src/commands/hardis/org/monitor/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,14 @@ This command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.co

// Write output file
if (this.diffFiles.length > 0) {
const filesHumanUnformatted = MetadataUtils.getMetadataPrettyNames(this.diffFiles.map((diffFile) => diffFile.path), false);
const severityIconLog = getSeverityIcon('log');
this.outputFile = await generateReportPath('backup-updated-files', this.outputFile);
this.diffFilesSimplified = this.diffFiles.map((diffFile) => {
return {
File: diffFile.path.replace('force-app/main/default/', ''),
ChangeType: diffFile.index === '?' ? 'A' : diffFile.index,
FileHuman: filesHumanUnformatted.get(diffFile.path) || diffFile.path.replace('force-app/main/default/', ''),
WorkingDir: diffFile.working_dir === '?' ? '' : diffFile.working_dir,
PrevName: diffFile?.from || '',
severity: 'log',
Expand All @@ -214,6 +216,7 @@ This command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.co
let notifText = `No updates detected in ${orgMarkdown}`;
let notifAttachments: MessageAttachment[] = [];
if (this.diffFiles.length > 0) {
const filesHumanFormatted = MetadataUtils.getMetadataPrettyNames(this.diffFiles.map((diffFile) => diffFile.path), true);
notifSeverity = 'info';
notifText = `Updates detected in ${orgMarkdown}`;
notifAttachments = [
Expand All @@ -224,7 +227,7 @@ This command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.co
if (diffFile.index && diffFile.index !== ' ') {
flag = ` (${diffFile.index === '?' ? 'A' : diffFile.index})`;
}
const line = `• ${diffFile.path.replace('force-app/main/default/', '')}` + flag;
const line = `• ${filesHumanFormatted.get(diffFile.path)}` + flag;
return line;
})
.join('\n'),
Expand Down Expand Up @@ -256,4 +259,5 @@ This command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.co

return { outputString: 'BackUp processed on org ' + flags['target-org'].getConnection().instanceUrl };
}

}
27 changes: 27 additions & 0 deletions src/common/metadata-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,33 @@ Issue tracking: https://github.com/forcedotcom/cli/issues/2426`)
const filesSorted = files.sort((a, b) => (a.path > b.path ? 1 : -1));
return filesSorted;
}

public static getMetadataPrettyNames(metadataFilePaths: string[], bold = false): Map<string, string> {
const metadataList = listMetadataTypes();
const metadataFilePathsHuman = new Map<string, string>();
for (const fileRaw of metadataFilePaths) {
const file = fileRaw.replace(/\\/g, '/').replace('force-app/main/default/', '');
let fileHuman = "" + file;
for (const metadataDesc of metadataList) {
if (file.includes(metadataDesc.directoryName || "THEREISNOT")) {
const endOfPath = file.split(metadataDesc.directoryName + "/")[1];
const suffix = metadataDesc.suffix ?? "THEREISNOT";
let metadataName = endOfPath.includes("." + suffix + "-meta.xml") ?
endOfPath.replace("." + suffix + "-meta.xml", "") :
endOfPath.includes("." + suffix) ?
endOfPath.replace("." + suffix, "") :
endOfPath;
if (bold) {
metadataName = "*" + metadataName + "*";
}
fileHuman = metadataDesc.xmlName + " " + metadataName;
continue;
}
}
metadataFilePathsHuman.set(fileRaw, fileHuman);
}
return metadataFilePathsHuman;
}
}

export { MetadataUtils };
Loading

0 comments on commit e5ec951

Please sign in to comment.