sfdx-hardis 6.9.1-alpha202510270034.0 → 6.10.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/CHANGELOG.md +4 -3
- package/lib/commands/hardis/org/diagnose/storage-stats.d.ts +18 -0
- package/lib/commands/hardis/org/diagnose/storage-stats.js +278 -0
- package/lib/commands/hardis/org/diagnose/storage-stats.js.map +1 -0
- package/lib/commands/hardis/project/deploy/notify.js +23 -19
- package/lib/commands/hardis/project/deploy/notify.js.map +1 -1
- package/lib/commands/hardis/project/deploy/quick.js +2 -3
- package/lib/commands/hardis/project/deploy/quick.js.map +1 -1
- package/lib/commands/hardis/project/deploy/start.js +5 -4
- package/lib/commands/hardis/project/deploy/start.js.map +1 -1
- package/lib/commands/hardis/project/deploy/validate.js +3 -4
- package/lib/commands/hardis/project/deploy/validate.js.map +1 -1
- package/lib/commands/hardis/source/deploy.js +3 -4
- package/lib/commands/hardis/source/deploy.js.map +1 -1
- package/lib/common/gitProvider/azureDevops.d.ts +0 -1
- package/lib/common/gitProvider/azureDevops.js +3 -71
- package/lib/common/gitProvider/azureDevops.js.map +1 -1
- package/lib/common/gitProvider/bitbucket.d.ts +0 -1
- package/lib/common/gitProvider/bitbucket.js +2 -81
- package/lib/common/gitProvider/bitbucket.js.map +1 -1
- package/lib/common/gitProvider/gitProviderRoot.d.ts +0 -1
- package/lib/common/gitProvider/gitProviderRoot.js +0 -6
- package/lib/common/gitProvider/gitProviderRoot.js.map +1 -1
- package/lib/common/gitProvider/github.d.ts +0 -1
- package/lib/common/gitProvider/github.js +1 -74
- package/lib/common/gitProvider/github.js.map +1 -1
- package/lib/common/gitProvider/gitlab.d.ts +0 -3
- package/lib/common/gitProvider/gitlab.js +2 -110
- package/lib/common/gitProvider/gitlab.js.map +1 -1
- package/lib/common/gitProvider/index.d.ts +1 -1
- package/lib/common/gitProvider/index.js +5 -12
- package/lib/common/gitProvider/index.js.map +1 -1
- package/lib/common/utils/dataUtils.d.ts +2 -2
- package/lib/common/utils/dataUtils.js +1 -5
- package/lib/common/utils/dataUtils.js.map +1 -1
- package/lib/common/utils/deployTips.js +1 -2
- package/lib/common/utils/deployTips.js.map +1 -1
- package/lib/common/utils/deployUtils.d.ts +7 -0
- package/lib/common/utils/deployUtils.js +75 -28
- package/lib/common/utils/deployUtils.js.map +1 -1
- package/lib/common/utils/gitUtils.d.ts +0 -2
- package/lib/common/utils/gitUtils.js +1 -7
- package/lib/common/utils/gitUtils.js.map +1 -1
- package/oclif.manifest.json +663 -549
- package/package.json +1 -1
- package/lib/common/actionsProvider/actionsProvider.d.ts +0 -37
- package/lib/common/actionsProvider/actionsProvider.js +0 -56
- package/lib/common/actionsProvider/actionsProvider.js.map +0 -1
- package/lib/common/actionsProvider/apexAction.d.ts +0 -6
- package/lib/common/actionsProvider/apexAction.js +0 -35
- package/lib/common/actionsProvider/apexAction.js.map +0 -1
- package/lib/common/actionsProvider/commandAction.d.ts +0 -6
- package/lib/common/actionsProvider/commandAction.js +0 -28
- package/lib/common/actionsProvider/commandAction.js.map +0 -1
- package/lib/common/actionsProvider/dataAction.d.ts +0 -6
- package/lib/common/actionsProvider/dataAction.js +0 -43
- package/lib/common/actionsProvider/dataAction.js.map +0 -1
- package/lib/common/actionsProvider/manualAction.d.ts +0 -6
- package/lib/common/actionsProvider/manualAction.js +0 -26
- package/lib/common/actionsProvider/manualAction.js.map +0 -1
- package/lib/common/actionsProvider/publishCommunityAction.d.ts +0 -6
- package/lib/common/actionsProvider/publishCommunityAction.js +0 -30
- package/lib/common/actionsProvider/publishCommunityAction.js.map +0 -1
- package/lib/common/utils/prePostCommandUtils.d.ts +0 -7
- package/lib/common/utils/prePostCommandUtils.js +0 -272
- package/lib/common/utils/prePostCommandUtils.js.map +0 -1
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Swiss-army-knife Toolbox for Salesforce.\n Allows you to define a complete CD/CD Pipeline.\n Orchestrate base commands and assist users with interactive wizards",
|
|
4
4
|
"author": "NicolasVuillamy @nvuillam",
|
|
5
5
|
"bugs": "https://github.com/hardisgroupcom/sfdx-hardis/issues",
|
|
6
|
-
"version": "6.
|
|
6
|
+
"version": "6.10.0",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@actions/github": "^6.0.1",
|
|
9
9
|
"@cparra/apexdocs": "^3.14.1",
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { CommonPullRequestInfo } from '../gitProvider/index.js';
|
|
2
|
-
export interface PrePostCommand {
|
|
3
|
-
id: string;
|
|
4
|
-
label: string;
|
|
5
|
-
type: 'command' | 'data' | 'apex' | 'publish-community' | 'manual';
|
|
6
|
-
parameters?: {
|
|
7
|
-
apexScript?: string;
|
|
8
|
-
sfdmuProject?: string;
|
|
9
|
-
communityName?: string;
|
|
10
|
-
instructions?: string;
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
};
|
|
13
|
-
command: string;
|
|
14
|
-
context: 'all' | 'check-deployment-only' | 'process-deployment-only';
|
|
15
|
-
skipIfError?: boolean;
|
|
16
|
-
allowFailure?: boolean;
|
|
17
|
-
runOnlyOnceByOrg?: boolean;
|
|
18
|
-
pullRequest?: CommonPullRequestInfo;
|
|
19
|
-
result?: ActionResult;
|
|
20
|
-
}
|
|
21
|
-
export type ActionResult = {
|
|
22
|
-
statusCode: 'success' | 'failed' | 'skipped' | "manual";
|
|
23
|
-
output?: string;
|
|
24
|
-
skippedReason?: string;
|
|
25
|
-
};
|
|
26
|
-
export declare abstract class ActionsProvider {
|
|
27
|
-
static buildActionInstance(cmd: PrePostCommand): Promise<ActionsProvider>;
|
|
28
|
-
getLabel(): string;
|
|
29
|
-
/**
|
|
30
|
-
* Perform pre-run validations for the given command.
|
|
31
|
-
* Return null when the command is valid and may proceed.
|
|
32
|
-
* Return an ActionResult when the command must be short-circuited
|
|
33
|
-
* (for example: missing parameters -> failed, or manual -> skipped).
|
|
34
|
-
*/
|
|
35
|
-
checkValidityIssues(cmd: PrePostCommand): Promise<ActionResult | null>;
|
|
36
|
-
run(cmd: PrePostCommand): Promise<ActionResult>;
|
|
37
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { SfError } from '@salesforce/core';
|
|
2
|
-
import c from 'chalk';
|
|
3
|
-
import { uxLog } from '../utils/index.js';
|
|
4
|
-
export class ActionsProvider {
|
|
5
|
-
static async buildActionInstance(cmd) {
|
|
6
|
-
let actionInstance = null;
|
|
7
|
-
const type = cmd.type || 'command';
|
|
8
|
-
if (type === 'command') {
|
|
9
|
-
const CommandAction = await import('./commandAction.js');
|
|
10
|
-
actionInstance = new CommandAction.CommandAction();
|
|
11
|
-
}
|
|
12
|
-
else if (type === 'apex') {
|
|
13
|
-
const ApexAction = await import('./apexAction.js');
|
|
14
|
-
actionInstance = new ApexAction.ApexAction();
|
|
15
|
-
}
|
|
16
|
-
else if (type === 'data') {
|
|
17
|
-
const DataAction = await import('./dataAction.js');
|
|
18
|
-
actionInstance = new DataAction.DataAction();
|
|
19
|
-
}
|
|
20
|
-
else if (type === 'publish-community') {
|
|
21
|
-
const PublishCommunityAction = await import('./publishCommunityAction.js');
|
|
22
|
-
actionInstance = new PublishCommunityAction.PublishCommunityAction();
|
|
23
|
-
}
|
|
24
|
-
else if (type === 'manual') {
|
|
25
|
-
const ManualAction = await import('./manualAction.js');
|
|
26
|
-
actionInstance = new ManualAction.ManualAction();
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
uxLog("error", this, c.yellow(`[DeploymentActions] Action type [${cmd.type}] is not yet implemented for action [${cmd.id}]: ${cmd.label}`));
|
|
30
|
-
cmd.result = {
|
|
31
|
-
statusCode: "failed",
|
|
32
|
-
skippedReason: `Action type [${cmd.type}] is not implemented`
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
return actionInstance;
|
|
36
|
-
}
|
|
37
|
-
getLabel() {
|
|
38
|
-
throw new SfError('getLabel should be implemented on this call');
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Perform pre-run validations for the given command.
|
|
42
|
-
* Return null when the command is valid and may proceed.
|
|
43
|
-
* Return an ActionResult when the command must be short-circuited
|
|
44
|
-
* (for example: missing parameters -> failed, or manual -> skipped).
|
|
45
|
-
*/
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
47
|
-
async checkValidityIssues(cmd) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
51
|
-
async run(cmd) {
|
|
52
|
-
uxLog('warning', this, c.yellow(`run is not implemented on ${this.getLabel()}`));
|
|
53
|
-
return { statusCode: 'skipped', skippedReason: 'Not implemented' };
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=actionsProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"actionsProvider.js","sourceRoot":"","sources":["../../../src/common/actionsProvider/actionsProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,CAAC,MAAM,OAAO,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AA+B1C,MAAM,OAAgB,eAAe;IAE5B,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAmB;QACzD,IAAI,cAAc,GAAQ,IAAI,CAAC;QAC/B,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,SAAS,CAAC;QACnC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;YACzD,cAAc,GAAG,IAAI,aAAa,CAAC,aAAa,EAAE,CAAC;QACrD,CAAC;aACI,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACzB,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC;YACnD,c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6B,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;QACjF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAC;IACrE,CAAC;CACF"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ActionsProvider, ActionResult, PrePostCommand } from './actionsProvider.js';
|
|
2
|
-
export declare class ApexAction extends ActionsProvider {
|
|
3
|
-
getLabel(): string;
|
|
4
|
-
checkValidity(cmd: PrePostCommand): Promise<ActionResult | null>;
|
|
5
|
-
run(cmd: PrePostCommand): Promise<ActionResult>;
|
|
6
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ActionsProvider } from './actionsProvider.js';
|
|
2
|
-
import { execCommand, uxLog } from '../utils/index.js';
|
|
3
|
-
import fs from 'fs-extra';
|
|
4
|
-
import c from 'chalk';
|
|
5
|
-
export class ApexAction extends ActionsProvider {
|
|
6
|
-
getLabel() {
|
|
7
|
-
return 'ApexAction';
|
|
8
|
-
}
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
|
-
async checkValidity(cmd) {
|
|
11
|
-
const apexScript = cmd.parameters?.apexScript || '';
|
|
12
|
-
if (!apexScript) {
|
|
13
|
-
uxLog('error', this, c.red(`[DeploymentActions] No apexScript parameter provided for action [${cmd.id}]: ${cmd.label}`));
|
|
14
|
-
return { statusCode: 'failed', skippedReason: 'No apexScript parameter provided' };
|
|
15
|
-
}
|
|
16
|
-
if (!fs.existsSync(apexScript)) {
|
|
17
|
-
uxLog('error', this, c.red(`[DeploymentActions] Apex script file ${apexScript} does not exist for action [${cmd.id}]: ${cmd.label}`));
|
|
18
|
-
return { statusCode: 'failed', skippedReason: `Apex script file ${apexScript} does not exist` };
|
|
19
|
-
}
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
async run(cmd) {
|
|
23
|
-
const validity = await this.checkValidityIssues(cmd);
|
|
24
|
-
if (validity)
|
|
25
|
-
return validity;
|
|
26
|
-
const apexScript = cmd.parameters?.apexScript || '';
|
|
27
|
-
const apexCommand = `sf apex run --file ${apexScript}`;
|
|
28
|
-
const res = await execCommand(apexCommand, null, { fail: false, output: true });
|
|
29
|
-
if (res.status === 0) {
|
|
30
|
-
return { statusCode: 'success', output: (res.stdout || '') + '\n' + (res.stderr || '') };
|
|
31
|
-
}
|
|
32
|
-
return { statusCode: 'failed', output: (res.stdout || '') + '\n' + (res.stderr || '') };
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=apexAction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apexAction.js","sourceRoot":"","sources":["../../../src/common/actionsProvider/apexAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAgC,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,CAAC,MAAM,OAAO,CAAC;AAEtB,MAAM,OAAO,UAAW,SAAQ,eAAe;IACtC,QAAQ;QACb,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,6DAA6D;IACtD,KAAK,CAAC,aAAa,CAAC,GAAmB;QAC5C,MAAM,UAAU,GAAI,GAAG,CAAC,UAAU,EAAE,UAAqB,IAAI,EAAE,CAAC;QAChE,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,oEAAoE,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YACzH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,kCAAkC,EAAE,CAAC;QACrF,CAAC;QACD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/B,KAAK,CAAC,O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|
3
|
-
getLabel(): string;
|
|
4
|
-
checkValidityIssues(cmd: PrePostCommand): Promise<ActionResult | null>;
|
|
5
|
-
run(cmd: PrePostCommand): Promise<ActionResult>;
|
|
6
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ActionsProvider } from './actionsProvider.js';
|
|
2
|
-
import { execCommand, uxLog } from '../utils/index.js';
|
|
3
|
-
import c from 'chalk';
|
|
4
|
-
export class CommandAction extends ActionsProvider {
|
|
5
|
-
getLabel() {
|
|
6
|
-
return 'CommandAction';
|
|
7
|
-
}
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9
|
-
async checkValidityIssues(cmd) {
|
|
10
|
-
const command = cmd.command;
|
|
11
|
-
if (!command) {
|
|
12
|
-
uxLog('error', this, c.red(`[DeploymentActions] No command provided for action [${cmd.id}]: ${cmd.label}`));
|
|
13
|
-
return { statusCode: 'failed', skippedReason: 'No command provided' };
|
|
14
|
-
}
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
async run(cmd) {
|
|
18
|
-
const validity = await this.checkValidityIssues(cmd);
|
|
19
|
-
if (validity)
|
|
20
|
-
return validity;
|
|
21
|
-
const res = await execCommand(cmd.command, null, { fail: false, output: true });
|
|
22
|
-
if (res.status === 0) {
|
|
23
|
-
return { statusCode: 'success', output: (res.stdout || '') + '\n' + (res.stderr || '') };
|
|
24
|
-
}
|
|
25
|
-
return { statusCode: 'failed', output: (res.stdout || '') + '\n' + (res.stderr || '') };
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=commandAction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commandAction.js","sourceRoot":"","sources":["../../../src/common/actionsProvider/commandAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAgC,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;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IAC1F,CAAC;CACF"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ActionsProvider, ActionResult, PrePostCommand } from './actionsProvider.js';
|
|
2
|
-
export declare class DataAction extends ActionsProvider {
|
|
3
|
-
getLabel(): string;
|
|
4
|
-
checkValidityIssues(cmd: PrePostCommand): Promise<ActionResult | null>;
|
|
5
|
-
run(cmd: PrePostCommand): Promise<ActionResult>;
|
|
6
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { ActionsProvider } from './actionsProvider.js';
|
|
2
|
-
import { uxLog } from '../utils/index.js';
|
|
3
|
-
import c from 'chalk';
|
|
4
|
-
import { findDataWorkspaceByName, importData } from '../utils/dataUtils.js';
|
|
5
|
-
export class DataAction extends ActionsProvider {
|
|
6
|
-
getLabel() {
|
|
7
|
-
return 'DataAction';
|
|
8
|
-
}
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
|
-
async checkValidityIssues(cmd) {
|
|
11
|
-
const sfdmuProject = cmd.parameters?.sfdmuProject || '';
|
|
12
|
-
if (!sfdmuProject) {
|
|
13
|
-
uxLog('error', this, c.red(`[DeploymentActions] No sfdmuProject parameter provided for action ${cmd.label}`));
|
|
14
|
-
return { statusCode: 'failed', skippedReason: 'No sfdmuProject parameter provided' };
|
|
15
|
-
}
|
|
16
|
-
const sfdmuProjectPath = await findDataWorkspaceByName(sfdmuProject, false);
|
|
17
|
-
if (!sfdmuProjectPath) {
|
|
18
|
-
uxLog('error', this, c.red(`[DeploymentActions] Data workspace ${sfdmuProject} does not exist for action ${cmd.label}`));
|
|
19
|
-
return { statusCode: 'failed', skippedReason: `Data workspace ${sfdmuProject} does not exist` };
|
|
20
|
-
}
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
async run(cmd) {
|
|
24
|
-
const validity = await this.checkValidityIssues(cmd);
|
|
25
|
-
if (validity)
|
|
26
|
-
return validity;
|
|
27
|
-
const sfdmuProject = cmd.parameters?.sfdmuProject || '';
|
|
28
|
-
const sfdmuProjectPath = await findDataWorkspaceByName(sfdmuProject);
|
|
29
|
-
let res;
|
|
30
|
-
try {
|
|
31
|
-
res = await importData(sfdmuProjectPath, null, { fail: false, output: true });
|
|
32
|
-
if (res.status === 0) {
|
|
33
|
-
return { statusCode: 'success', output: (res.stdout || '') + '\n' + (res.stderr || '') };
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
uxLog('error', this, c.red(`[DeploymentActions] Error during data import for action ${cmd.label}: ${error}`));
|
|
38
|
-
return { statusCode: 'failed', output: `Error during data import: ${error}` };
|
|
39
|
-
}
|
|
40
|
-
return { statusCode: 'failed', output: (res.stdout || '') + '\n' + (res.stderr || '') };
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=dataAction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dataAction.js","sourceRoot":"","sources":["../../../src/common/actionsProvider/dataAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAgC,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,CAAC,MAAM,OAAO,CAAC;AACtB,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAE5E,MAAM,OAAO,UAAW,SAAQ,eAAe;IACtC,QAAQ;QACb,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,6DAA6D;IACtD,KAAK,CAAC,mBAAmB,CAAC,GAAmB;QAClD,MAAM,YAAY,GAAI,GAAG,CAAC,UAAU,EAAE,YAAuB,IAAI,EAAE,CAAC;QACpE,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,qEAAqE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC9G,OAAO,EAA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AI,EAAE,CAAC,CAAC,GAAG,CAAC,2DAA2D,GAAG,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC;YAC9G,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,6BAA6B,KAAK,EAAE,EAAE,CAAC;QAChF,CAAC;QACD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,CAAC;IAC1F,CAAC;CACF"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ActionsProvider, ActionResult, PrePostCommand } from './actionsProvider.js';
|
|
2
|
-
export declare class ManualAction extends ActionsProvider {
|
|
3
|
-
getLabel(): string;
|
|
4
|
-
checkValidityIssues(cmd: PrePostCommand): Promise<ActionResult | null>;
|
|
5
|
-
run(cmd: PrePostCommand): Promise<ActionResult>;
|
|
6
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ActionsProvider } from './actionsProvider.js';
|
|
2
|
-
import { uxLog } from '../utils/index.js';
|
|
3
|
-
import c from 'chalk';
|
|
4
|
-
export class ManualAction extends ActionsProvider {
|
|
5
|
-
getLabel() {
|
|
6
|
-
return 'ManualAction';
|
|
7
|
-
}
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9
|
-
async checkValidityIssues(cmd) {
|
|
10
|
-
const instructions = cmd.parameters?.instructions || '';
|
|
11
|
-
if (!instructions) {
|
|
12
|
-
uxLog('warning', this, c.yellow(`[DeploymentActions] No instructions for manual action [${cmd.id}]: ${cmd.label}`));
|
|
13
|
-
return { statusCode: 'skipped', skippedReason: 'No instructions provided' };
|
|
14
|
-
}
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
async run(cmd) {
|
|
18
|
-
const validity = await this.checkValidityIssues(cmd);
|
|
19
|
-
if (validity)
|
|
20
|
-
return validity;
|
|
21
|
-
const instructions = cmd.parameters?.instructions || '';
|
|
22
|
-
// Manual actions are not executed automatically. We just record the instructions.
|
|
23
|
-
return { statusCode: 'manual', skippedReason: 'Manual action - see output for instructions', output: instructions };
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=manualAction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manualAction.js","sourceRoot":"","sources":["../../../src/common/actionsProvider/manualAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAgC,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,CAAC,MAAM,OAAO,CAAC;AAEtB,MAAM,OAAO,YAAa,SAAQ,eAAe;IACxC,QAAQ;QACb,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,6DAA6D;IACtD,KAAK,CAAC,mBAAmB,CAAC,GAAmB;QAClD,MAAM,YAAY,GAAI,GAAG,CAAC,UAAU,EAAE,YAAuB,IAAI,EAAE,CAAC;QACpE,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,KAAK,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,0DAA0D,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YACpH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,0BAA0B,EAAE,CAAC;QAC9E,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,GAAmB;QAClC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACrD,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAC9B,MAAM,YAAY,GAAI,GAAG,CAAC,UAAU,EAAE,YAAuB,IAAI,EAAE,CAAC;QACpE,kFAAkF;QAClF,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,6CAA6C,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IACtH,CAAC;CACF"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ActionsProvider, ActionResult, PrePostCommand } from './actionsProvider.js';
|
|
2
|
-
export declare class PublishCommunityAction extends ActionsProvider {
|
|
3
|
-
getLabel(): string;
|
|
4
|
-
checkValidityIssues(cmd: PrePostCommand): Promise<ActionResult | null>;
|
|
5
|
-
run(cmd: PrePostCommand): Promise<ActionResult>;
|
|
6
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ActionsProvider } from './actionsProvider.js';
|
|
2
|
-
import { execCommand, uxLog } from '../utils/index.js';
|
|
3
|
-
import c from 'chalk';
|
|
4
|
-
export class PublishCommunityAction extends ActionsProvider {
|
|
5
|
-
getLabel() {
|
|
6
|
-
return 'PublishCommunityAction';
|
|
7
|
-
}
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9
|
-
async checkValidityIssues(cmd) {
|
|
10
|
-
const communityName = cmd.parameters?.communityName || '';
|
|
11
|
-
if (!communityName) {
|
|
12
|
-
uxLog('error', this, c.red(`[DeploymentActions] No communityName parameter provided for action [${cmd.id}]: ${cmd.label}`));
|
|
13
|
-
return { statusCode: 'failed', skippedReason: 'No communityName parameter provided' };
|
|
14
|
-
}
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
async run(cmd) {
|
|
18
|
-
const validity = await this.checkValidityIssues(cmd);
|
|
19
|
-
if (validity)
|
|
20
|
-
return validity;
|
|
21
|
-
const communityName = cmd.parameters?.communityName || '';
|
|
22
|
-
const publishCmd = `sf community publish -n "${communityName}"`;
|
|
23
|
-
const res = await execCommand(publishCmd, null, { fail: false, output: true });
|
|
24
|
-
if (res.status === 0) {
|
|
25
|
-
return { statusCode: 'success', output: (res.stdout || '') + '\n' + (res.stderr || '') };
|
|
26
|
-
}
|
|
27
|
-
return { statusCode: 'failed', output: (res.stdout || '') + '\n' + (res.stderr || '') };
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=publishCommunityAction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"publishCommunityAction.js","sourceRoot":"","sources":["../../../src/common/actionsProvider/publishCommunityAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAgC,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,CAAC,MAAM,OAAO,CAAC;AAEtB,MAAM,OAAO,sBAAuB,SAAQ,eAAe;IAClD,QAAQ;QACb,OAAO,wBAAwB,CAAC;IAClC,CAAC;IAED,6DAA6D;IACtD,KAAK,CAAC,mBAAmB,CAAC,GAAmB;QAClD,MAAM,aAAa,GAAI,GAAG,CAAC,UAAU,EAAE,aAAwB,IAAI,EAAE,CAAC;QACtE,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,uEAAuE,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC5H,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,qCAAqC,EAAE,CAAC;QACxF,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,GAAmB;QAClC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACrD,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAC9B,MAAM,aAAa,GAAI,GAAG,CAAC,UAAU,EAAE,aAAwB,IAAI,EAAE,CAAC;QACtE,MAAM,UAAU,GAAG,4BAA4B,aAAa,GAAG,CAAC;QAChE,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,UAAU,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/E,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,CAAC;QAC3F,CAAC;QACD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,CAAC;IAC1F,CAAC;CACF"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Connection } from '@salesforce/core';
|
|
2
|
-
export declare function executePrePostCommands(property: 'commandsPreDeploy' | 'commandsPostDeploy', options: {
|
|
3
|
-
success: boolean;
|
|
4
|
-
checkOnly: boolean;
|
|
5
|
-
conn: Connection;
|
|
6
|
-
extraCommands?: any[];
|
|
7
|
-
}): Promise<void>;
|
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
import { SfError } from '@salesforce/core';
|
|
2
|
-
import c from 'chalk';
|
|
3
|
-
import fs from 'fs-extra';
|
|
4
|
-
import yaml from 'js-yaml';
|
|
5
|
-
import * as path from 'path';
|
|
6
|
-
import { getConfig } from '../../config/index.js';
|
|
7
|
-
import { uxLog } from './index.js';
|
|
8
|
-
import { GitProvider } from '../gitProvider/index.js';
|
|
9
|
-
import { checkSfdxHardisTraceAvailable, listMajorOrgs } from './orgConfigUtils.js';
|
|
10
|
-
import { soqlQuery } from './apiUtils.js';
|
|
11
|
-
// data import moved to DataAction class in actionsProvider
|
|
12
|
-
import { getPullRequestData, setPullRequestData } from './gitUtils.js';
|
|
13
|
-
import { ActionsProvider } from '../actionsProvider/actionsProvider.js';
|
|
14
|
-
export async function executePrePostCommands(property, options) {
|
|
15
|
-
const actionLabel = property === 'commandsPreDeploy' ? 'Pre-deployment actions' : 'Post-deployment actions';
|
|
16
|
-
uxLog("action", this, c.cyan(`[DeploymentActions] Listing ${actionLabel}...`));
|
|
17
|
-
const branchConfig = await getConfig('branch');
|
|
18
|
-
const commands = [...(branchConfig[property] || []), ...(options.extraCommands || [])];
|
|
19
|
-
await completeWithCommandsFromPullRequests(property, commands, options.checkOnly);
|
|
20
|
-
if (commands.length === 0) {
|
|
21
|
-
uxLog("action", this, c.cyan(`[DeploymentActions] No ${actionLabel} defined in branch config or pull requests`));
|
|
22
|
-
uxLog("log", this, c.grey(`No ${property} found to run`));
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
uxLog("action", this, c.cyan(`[DeploymentActions] Found ${commands.length} ${actionLabel} to run`));
|
|
26
|
-
uxLog("log", this, c.grey(commands.map(c => `- ${c.label} (${c.type || 'command'})`).join('\n')));
|
|
27
|
-
for (const cmd of commands) {
|
|
28
|
-
const actionsInstance = await ActionsProvider.buildActionInstance(cmd);
|
|
29
|
-
const actionsIssues = await actionsInstance.checkValidityIssues(cmd);
|
|
30
|
-
if (actionsIssues) {
|
|
31
|
-
cmd.result = actionsIssues;
|
|
32
|
-
uxLog("error", this, c.red(`[DeploymentActions] Action ${cmd.label} is not valid: ${actionsIssues.skippedReason}`));
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
// If if skipIfError is true and deployment failed
|
|
36
|
-
if (options.success === false && cmd.skipIfError === true) {
|
|
37
|
-
uxLog("action", this, c.yellow(`[DeploymentActions] Skipping ${cmd.label} (skipIfError=true) `));
|
|
38
|
-
cmd.result = {
|
|
39
|
-
statusCode: "skipped",
|
|
40
|
-
skippedReason: "skipIfError is true and deployment failed"
|
|
41
|
-
};
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
// Skip if we are in another context than the requested one
|
|
45
|
-
const cmdContext = cmd.context || "all";
|
|
46
|
-
if (cmdContext === "check-deployment-only" && options.checkOnly === false) {
|
|
47
|
-
uxLog("action", this, c.grey(`[DeploymentActions] Skipping ${cmd.label}: check-deployment-only action, and we are in process deployment mode`));
|
|
48
|
-
cmd.result = {
|
|
49
|
-
statusCode: "skipped",
|
|
50
|
-
skippedReason: "Action context is check-deployment-only but we are in process deployment mode"
|
|
51
|
-
};
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
if (cmdContext === "process-deployment-only" && options.checkOnly === true) {
|
|
55
|
-
uxLog("action", this, c.grey(`[DeploymentActions] Skipping ${cmd.label}: process-deployment-only action as we are in check deployment mode`));
|
|
56
|
-
cmd.result = {
|
|
57
|
-
statusCode: "skipped",
|
|
58
|
-
skippedReason: "Action context is process-deployment-only but we are in check deployment mode"
|
|
59
|
-
};
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
const runOnlyOnceByOrg = cmd.runOnlyOnceByOrg || false;
|
|
63
|
-
if (runOnlyOnceByOrg) {
|
|
64
|
-
await checkSfdxHardisTraceAvailable(options.conn);
|
|
65
|
-
const commandTraceQuery = `SELECT Id,CreatedDate FROM SfdxHardisTrace__c WHERE Type__c='${property}' AND Key__c='${cmd.id}' LIMIT 1`;
|
|
66
|
-
const commandTraceRes = await soqlQuery(commandTraceQuery, options.conn);
|
|
67
|
-
if (commandTraceRes?.records?.length > 0) {
|
|
68
|
-
uxLog("action", this, c.grey(`[DeploymentActions] Skipping ${cmd.label}: it has been defined with runOnlyOnceByOrg and has already been run on ${commandTraceRes.records[0].CreatedDate}`));
|
|
69
|
-
cmd.result = {
|
|
70
|
-
statusCode: "skipped",
|
|
71
|
-
skippedReason: "runOnlyOnceByOrg is true and command has already been run on this org"
|
|
72
|
-
};
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
// Run command
|
|
77
|
-
uxLog("action", this, c.cyan(`[DeploymentActions] Running action ${cmd.label}`));
|
|
78
|
-
await executeAction(cmd);
|
|
79
|
-
if (cmd.result?.statusCode === "success" && runOnlyOnceByOrg) {
|
|
80
|
-
const hardisTraceRecord = {
|
|
81
|
-
Name: property + "--" + cmd.id,
|
|
82
|
-
Type__c: property,
|
|
83
|
-
Key__c: cmd.id
|
|
84
|
-
};
|
|
85
|
-
const insertRes = await options.conn.insert("SfdxHardisTrace__c", [hardisTraceRecord]);
|
|
86
|
-
if (insertRes[0].success) {
|
|
87
|
-
uxLog("success", this, c.green(`[DeploymentActions] Stored SfdxHardisTrace__c entry ${insertRes[0].id} with command [${cmd.id}] so it is not run again in the future (runOnlyOnceByOrg: true)`));
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
uxLog("error", this, c.red(`[DeploymentActions] Error storing SfdxHardisTrace__c entry :` + JSON.stringify(insertRes, null, 2)));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else if (cmd.result?.statusCode === "failed" && cmd.allowFailure !== true) {
|
|
94
|
-
uxLog("error", this, c.red(`[DeploymentActions] Action ${cmd.label} failed, stopping execution of further actions.`));
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
manageResultMarkdownBody(property, commands);
|
|
99
|
-
// Check commands results
|
|
100
|
-
const failedCommands = commands.filter(c => c.result?.statusCode === "failed");
|
|
101
|
-
if (failedCommands.length > 0) {
|
|
102
|
-
uxLog("error", this, c.red(`[DeploymentActions] ${failedCommands.length} action(s) failed during ${actionLabel}:`));
|
|
103
|
-
// throw error if failed and allowFailure is not set
|
|
104
|
-
const failedAndNotAllowFailure = failedCommands.filter(c => c.allowFailure !== true);
|
|
105
|
-
if (failedAndNotAllowFailure.length > 0) {
|
|
106
|
-
let prData = getPullRequestData();
|
|
107
|
-
prData = Object.assign(prData, {
|
|
108
|
-
title: "❌ Error: Failed deployment actions",
|
|
109
|
-
messageKey: prData.messageKey ?? 'deployment',
|
|
110
|
-
});
|
|
111
|
-
setPullRequestData(prData);
|
|
112
|
-
await GitProvider.managePostPullRequestComment(options.checkOnly);
|
|
113
|
-
throw new SfError(`One or more ${actionLabel} have failed. See logs for more details.`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
async function completeWithCommandsFromPullRequests(property, commands, checkOnly) {
|
|
118
|
-
await checkForDraftCommandsFile(property, checkOnly);
|
|
119
|
-
const pullRequests = await listAllPullRequestsToUse();
|
|
120
|
-
for (const pr of pullRequests) {
|
|
121
|
-
// Check if there is a .sfdx-hardis.PULL_REQUEST_ID.yml file in the PR
|
|
122
|
-
const prConfigFileName = path.join("scripts", "actions", `.sfdx-hardis.${pr.idStr}.yml`);
|
|
123
|
-
if (fs.existsSync(prConfigFileName)) {
|
|
124
|
-
try {
|
|
125
|
-
const prConfig = await fs.readFile(prConfigFileName, 'utf8');
|
|
126
|
-
const prConfigParsed = yaml.load(prConfig);
|
|
127
|
-
if (prConfigParsed && prConfigParsed[property] && Array.isArray(prConfigParsed[property])) {
|
|
128
|
-
const prConfigCommands = prConfigParsed[property];
|
|
129
|
-
for (const cmd of prConfigCommands) {
|
|
130
|
-
cmd.pullRequest = pr;
|
|
131
|
-
commands.push(cmd);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
catch (e) {
|
|
136
|
-
uxLog("error", this, c.red(`Error while parsing ${prConfigFileName} file: ${e.message}`));
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
let _cachedPullRequests = null;
|
|
142
|
-
async function listAllPullRequestsToUse() {
|
|
143
|
-
if (_cachedPullRequests) {
|
|
144
|
-
return _cachedPullRequests;
|
|
145
|
-
}
|
|
146
|
-
const gitProvider = await GitProvider.getInstance();
|
|
147
|
-
if (!gitProvider) {
|
|
148
|
-
uxLog("warning", this, c.yellow('No git provider configured, skipping retrieval of commands from pull requests'));
|
|
149
|
-
return [];
|
|
150
|
-
}
|
|
151
|
-
const pullRequestInfo = await gitProvider.getPullRequestInfo();
|
|
152
|
-
if (!pullRequestInfo) {
|
|
153
|
-
uxLog("warning", this, c.yellow('No pull request info available, skipping retrieval of commands from pull requests'));
|
|
154
|
-
return [];
|
|
155
|
-
}
|
|
156
|
-
const majorOrgs = await listMajorOrgs();
|
|
157
|
-
const childBranchesNames = recursiveGetChildBranches(pullRequestInfo.targetBranch, majorOrgs);
|
|
158
|
-
const pullRequests = await gitProvider.listPullRequestsInBranchSinceLastMerge(pullRequestInfo.sourceBranch, pullRequestInfo.targetBranch, [...childBranchesNames]);
|
|
159
|
-
pullRequests.reverse(); // Oldest PR first
|
|
160
|
-
if (!pullRequests.some(pr => pr.idStr === pullRequestInfo.idStr)) {
|
|
161
|
-
pullRequests.push(pullRequestInfo);
|
|
162
|
-
}
|
|
163
|
-
_cachedPullRequests = pullRequests;
|
|
164
|
-
return pullRequests;
|
|
165
|
-
}
|
|
166
|
-
function recursiveGetChildBranches(branchName, majorOrgs, collected = new Set()) {
|
|
167
|
-
const directChildren = majorOrgs
|
|
168
|
-
.filter((o) => o.mergeTargets.includes(branchName))
|
|
169
|
-
.map((o) => o.branchName);
|
|
170
|
-
for (const child of directChildren) {
|
|
171
|
-
if (!collected.has(child)) {
|
|
172
|
-
collected.add(child);
|
|
173
|
-
recursiveGetChildBranches(child, majorOrgs, collected);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return collected;
|
|
177
|
-
}
|
|
178
|
-
async function checkForDraftCommandsFile(property, checkOnly) {
|
|
179
|
-
const prConfigFileName = path.join("scripts", "actions", `.sfdx-hardis.draft.yml`);
|
|
180
|
-
if (fs.existsSync(prConfigFileName)) {
|
|
181
|
-
let suggestedFileName = ".sfdx-hardis.PULL_REQUEST_ID.yml (ex: .sfdx-hardis.123.yml)";
|
|
182
|
-
const prInfo = await GitProvider.getPullRequestInfo();
|
|
183
|
-
if (prInfo && prInfo.idStr) {
|
|
184
|
-
suggestedFileName = `.sfdx-hardis.${prInfo.idStr}.yml`;
|
|
185
|
-
}
|
|
186
|
-
const errorMessage = `Draft deployment actions file ${prConfigFileName} found.
|
|
187
|
-
|
|
188
|
-
Please assign it to a Pull Request before proceeding, or delete the file it if you don't need it.
|
|
189
|
-
|
|
190
|
-
To assign it, rename .sfdx-hardis.draft.yml into ${suggestedFileName}.
|
|
191
|
-
`;
|
|
192
|
-
const propertyFormatted = property === 'commandsPreDeploy' ? 'preDeployCommandsResultMarkdownBody' : 'postDeployCommandsResultMarkdownBody';
|
|
193
|
-
let prData = getPullRequestData();
|
|
194
|
-
prData = Object.assign(prData, {
|
|
195
|
-
title: "❌ Error: Draft deployment actions file found",
|
|
196
|
-
messageKey: prData.messageKey ?? 'deployment',
|
|
197
|
-
[propertyFormatted]: errorMessage
|
|
198
|
-
});
|
|
199
|
-
setPullRequestData(prData);
|
|
200
|
-
await GitProvider.managePostPullRequestComment(checkOnly);
|
|
201
|
-
uxLog("error", this, c.red(`[DeploymentActions] ${errorMessage}`));
|
|
202
|
-
throw new SfError(`Draft commands file ${prConfigFileName} found. Please assign it to a Pull Request or delete it before proceeding.`);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
async function executeAction(cmd) {
|
|
206
|
-
// Use ActionsProvider classes to execute actions
|
|
207
|
-
const actionInstance = await ActionsProvider.buildActionInstance(cmd);
|
|
208
|
-
try {
|
|
209
|
-
const res = await actionInstance.run(cmd);
|
|
210
|
-
cmd.result = res;
|
|
211
|
-
}
|
|
212
|
-
catch (e) {
|
|
213
|
-
uxLog("error", this, c.red(`[DeploymentActions] Exception while running action ${cmd.label}: ${e.message}`));
|
|
214
|
-
cmd.result = {
|
|
215
|
-
statusCode: 'failed',
|
|
216
|
-
output: e.message
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
function manageResultMarkdownBody(property, commands) {
|
|
221
|
-
let markdownBody = `### ${property === 'commandsPreDeploy' ? 'Pre-deployment Actions' : 'Post-deployment Actions'} Results\n\n`;
|
|
222
|
-
// Build markdown table
|
|
223
|
-
markdownBody += `| <!-- --> | Label | Type | Status | Details |\n`;
|
|
224
|
-
markdownBody += `|:--------:|-------|------|--------|---------|\n`;
|
|
225
|
-
for (const cmd of commands) {
|
|
226
|
-
const statusIcon = cmd.result?.statusCode === "manual" ?
|
|
227
|
-
"- [ ]" :
|
|
228
|
-
cmd.result?.statusCode === "success" ? '✅' :
|
|
229
|
-
(cmd.result?.statusCode === "failed" && cmd.allowFailure === true) ? '⚠️' :
|
|
230
|
-
(cmd.result?.statusCode === "failed") ? '❌' :
|
|
231
|
-
cmd.result?.statusCode === "skipped" ? '⚪' : '❓';
|
|
232
|
-
const statusCol = `${cmd.result?.statusCode || 'not run'}`;
|
|
233
|
-
const detailCol = cmd.result?.statusCode === "skipped" ?
|
|
234
|
-
(cmd.result?.skippedReason || '<!-- -->') :
|
|
235
|
-
(cmd.result?.statusCode === "failed" && cmd.allowFailure === true) ?
|
|
236
|
-
(cmd.result.skippedReason ? `${cmd.result.skippedReason} (Allowed to fail)` : "(Allowed to fail)") :
|
|
237
|
-
(cmd.result?.statusCode === "failed" && cmd.result.skippedReason) ?
|
|
238
|
-
cmd.result.skippedReason :
|
|
239
|
-
"See details below";
|
|
240
|
-
const labelCol = cmd.pullRequest ?
|
|
241
|
-
`${cmd.label} ([${cmd.pullRequest.idStr || "?"}](${cmd.pullRequest.webUrl || ""}))` :
|
|
242
|
-
cmd.label;
|
|
243
|
-
markdownBody += `| ${statusIcon} | ${labelCol} | ${cmd.type || 'command'} | ${statusCol} | ${detailCol} |\n`;
|
|
244
|
-
}
|
|
245
|
-
// Add details in html <detail> blocks, embedded in a root <details> block to avoid markdown rendering issues
|
|
246
|
-
markdownBody += `\n<details>\n<summary>Expand to see details for each action</summary>\n\n`;
|
|
247
|
-
for (const cmd of commands) {
|
|
248
|
-
if (cmd.result?.output) {
|
|
249
|
-
// Truncate output if too long
|
|
250
|
-
const maxOutputLength = 10000;
|
|
251
|
-
let outputForMarkdown = cmd.result.output;
|
|
252
|
-
if (outputForMarkdown.length > maxOutputLength) {
|
|
253
|
-
outputForMarkdown = outputForMarkdown.substring(0, maxOutputLength) + `\n\n... Output truncated to ${maxOutputLength} characters ...`;
|
|
254
|
-
}
|
|
255
|
-
const labeTitle = cmd.pullRequest ?
|
|
256
|
-
`${cmd.label} (${cmd.pullRequest.idStr || "?"})` :
|
|
257
|
-
cmd.label;
|
|
258
|
-
markdownBody += `\n<details id="command-${cmd.id}">\n<summary>${labeTitle}</summary>\n\n`;
|
|
259
|
-
markdownBody += '```\n';
|
|
260
|
-
markdownBody += outputForMarkdown;
|
|
261
|
-
markdownBody += '\n```\n';
|
|
262
|
-
markdownBody += '</details>\n';
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
markdownBody += `\n</details>\n`;
|
|
266
|
-
const propertyFormatted = property === 'commandsPreDeploy' ? 'preDeployCommandsResultMarkdownBody' : 'postDeployCommandsResultMarkdownBody';
|
|
267
|
-
const prData = {
|
|
268
|
-
[propertyFormatted]: markdownBody
|
|
269
|
-
};
|
|
270
|
-
setPullRequestData(prData);
|
|
271
|
-
}
|
|
272
|
-
//# sourceMappingURL=prePostCommandUtils.js.map
|