-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathbuild.js
68 lines (65 loc) · 3.29 KB
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/node
/* eslint-disable */
const fs = require("fs-extra");
const { getAllTips } = require("./lib/common/utils/deployTipsList");
class SfdxHardisBuilder {
run() {
console.log("Start additional building of sfdx-hardis repository...");
this.buildDeployTipsDoc();
}
buildDeployTipsDoc() {
console.log("Building deployTips doc...");
const deployTipsDocFile = "./docs/deployTips.md";
const deployTips = getAllTips();
const deployTipsMd = [
"---",
"title: How to solve Salesforce DX Deployment errors",
"description: Learn how to fix issues that can happen during sfdx deployments",
"---",
"<!-- markdownlint-disable MD013 -->",
"",
"# Salesforce deployment errors tips",
"",
"This page summarizes all errors that can be detected by sfdx-hardis wrapper commands",
"",
"| sfdx command | sfdx-hardis wrapper command |",
"| :----------- | :-------------------------- |",
"| [sfdx force:source:deploy](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_source.htm#cli_reference_force_source_deploy) | [sfdx hardis:source:deploy](https://sfdx-hardis.cloudity.com/hardis/source/deploy/) |",
"| [sfdx force:source:push](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_source.htm#cli_reference_force_source_push) | [sfdx hardis:source:push](https://sfdx-hardis.cloudity.com/hardis/source/push/) |",
"| [sfdx force:mdapi:deploy](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_mdapi.htm#cli_reference_force_mdapi_beta_deploy) | [sfdx hardis:mdapi:deploy](https://sfdx-hardis.cloudity.com/hardis/mdapi/deploy/) |",
"",
"You can also use this function on a [sfdx-hardis Salesforce CI/CD project](https://sfdx-hardis.cloudity.com/salesforce-ci-cd-home/)",
"",
"If you see a deployment error which is not here yet, please [add it in this file](https://github.com/hardisgroupcom/sfdx-hardis/blob/main/src/common/utils/deployTipsList.ts) :)",
"",
"Example:",
"",
"![Deployment Tip example](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/deploy-tip-example.jpg)",
""
];
for (const tip of deployTips) {
if (!tip.label) {
throw new Error(`Missing label for ${JSON.stringify(tip)}`);
}
deployTipsMd.push(`## ${tip.label}`);
deployTipsMd.push("");
if (tip.expressionRegex) {
deployTipsMd.push(...tip.expressionRegex.map((regEx) => "- `" + regEx.toString().slice(1).replace("/gm", "") + "`"));
}
if (tip.expressionString) {
deployTipsMd.push(...tip.expressionString.map((str) => "- `" + str + "`"));
}
deployTipsMd.push(...["", "**Resolution tip**", ""]);
if (!tip.tip) {
throw new Error(`Missing tip for ${JSON.stringify(tip)}`);
}
deployTipsMd.push("```shell");
deployTipsMd.push(...tip.tip.split("\n"));
deployTipsMd.push("```");
deployTipsMd.push("");
}
fs.writeFileSync(deployTipsDocFile, deployTipsMd.join("\n") + "\n");
console.log("Written doc file " + deployTipsDocFile);
}
}
new SfdxHardisBuilder().run();