@salesforce/plugin-devops-center 0.1.0-beta.1

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.
Files changed (135) hide show
  1. package/LICENSE.txt +12 -0
  2. package/README.md +245 -0
  3. package/lib/commands/deploy/pipeline/report.d.ts +15 -0
  4. package/lib/commands/deploy/pipeline/report.js +42 -0
  5. package/lib/commands/deploy/pipeline/report.js.map +1 -0
  6. package/lib/commands/deploy/pipeline/resume.d.ts +12 -0
  7. package/lib/commands/deploy/pipeline/resume.js +28 -0
  8. package/lib/commands/deploy/pipeline/resume.js.map +1 -0
  9. package/lib/commands/deploy/pipeline.d.ts +26 -0
  10. package/lib/commands/deploy/pipeline.js +50 -0
  11. package/lib/commands/deploy/pipeline.js.map +1 -0
  12. package/lib/common/base/abstractPromote.d.ts +69 -0
  13. package/lib/common/base/abstractPromote.js +173 -0
  14. package/lib/common/base/abstractPromote.js.map +1 -0
  15. package/lib/common/base/abstractReportOnPromote.d.ts +17 -0
  16. package/lib/common/base/abstractReportOnPromote.js +64 -0
  17. package/lib/common/base/abstractReportOnPromote.js.map +1 -0
  18. package/lib/common/base/abstractResume.d.ts +37 -0
  19. package/lib/common/base/abstractResume.js +90 -0
  20. package/lib/common/base/abstractResume.js.map +1 -0
  21. package/lib/common/constants.d.ts +9 -0
  22. package/lib/common/constants.js +20 -0
  23. package/lib/common/constants.js.map +1 -0
  24. package/lib/common/deployPipelineCache.d.ts +39 -0
  25. package/lib/common/deployPipelineCache.js +81 -0
  26. package/lib/common/deployPipelineCache.js.map +1 -0
  27. package/lib/common/flags/flags.d.ts +19 -0
  28. package/lib/common/flags/flags.js +84 -0
  29. package/lib/common/flags/flags.js.map +1 -0
  30. package/lib/common/flags/promote/promoteFlags.d.ts +12 -0
  31. package/lib/common/flags/promote/promoteFlags.js +52 -0
  32. package/lib/common/flags/promote/promoteFlags.js.map +1 -0
  33. package/lib/common/index.d.ts +2 -0
  34. package/lib/common/index.js +18 -0
  35. package/lib/common/index.js.map +1 -0
  36. package/lib/common/outputColumns.d.ts +17 -0
  37. package/lib/common/outputColumns.js +24 -0
  38. package/lib/common/outputColumns.js.map +1 -0
  39. package/lib/common/outputService/aorOutputService.d.ts +43 -0
  40. package/lib/common/outputService/aorOutputService.js +50 -0
  41. package/lib/common/outputService/aorOutputService.js.map +1 -0
  42. package/lib/common/outputService/deployCommandOutputService.d.ts +12 -0
  43. package/lib/common/outputService/deployCommandOutputService.js +28 -0
  44. package/lib/common/outputService/deployCommandOutputService.js.map +1 -0
  45. package/lib/common/outputService/deploySummaryBuilder.d.ts +32 -0
  46. package/lib/common/outputService/deploySummaryBuilder.js +185 -0
  47. package/lib/common/outputService/deploySummaryBuilder.js.map +1 -0
  48. package/lib/common/outputService/deploymentResultOutputService.d.ts +23 -0
  49. package/lib/common/outputService/deploymentResultOutputService.js +18 -0
  50. package/lib/common/outputService/deploymentResultOutputService.js.map +1 -0
  51. package/lib/common/outputService/index.d.ts +6 -0
  52. package/lib/common/outputService/index.js +20 -0
  53. package/lib/common/outputService/index.js.map +1 -0
  54. package/lib/common/outputService/outputService.d.ts +27 -0
  55. package/lib/common/outputService/outputService.js +30 -0
  56. package/lib/common/outputService/outputService.js.map +1 -0
  57. package/lib/common/outputService/outputServiceFactory.d.ts +27 -0
  58. package/lib/common/outputService/outputServiceFactory.js +39 -0
  59. package/lib/common/outputService/outputServiceFactory.js.map +1 -0
  60. package/lib/common/outputService/outputUtils.d.ts +3 -0
  61. package/lib/common/outputService/outputUtils.js +26 -0
  62. package/lib/common/outputService/outputUtils.js.map +1 -0
  63. package/lib/common/outputService/promoteOutputService.d.ts +30 -0
  64. package/lib/common/outputService/promoteOutputService.js +55 -0
  65. package/lib/common/outputService/promoteOutputService.js.map +1 -0
  66. package/lib/common/outputService/reportOutputService.d.ts +21 -0
  67. package/lib/common/outputService/reportOutputService.js +54 -0
  68. package/lib/common/outputService/reportOutputService.js.map +1 -0
  69. package/lib/common/outputService/resumeCommandOutputService.d.ts +12 -0
  70. package/lib/common/outputService/resumeCommandOutputService.js +30 -0
  71. package/lib/common/outputService/resumeCommandOutputService.js.map +1 -0
  72. package/lib/common/outputService/resumeOutputService.d.ts +15 -0
  73. package/lib/common/outputService/resumeOutputService.js +19 -0
  74. package/lib/common/outputService/resumeOutputService.js.map +1 -0
  75. package/lib/common/selectors/asyncOperationResultsSelector.d.ts +7 -0
  76. package/lib/common/selectors/asyncOperationResultsSelector.js +21 -0
  77. package/lib/common/selectors/asyncOperationResultsSelector.js.map +1 -0
  78. package/lib/common/selectors/deployComponentsSelector.d.ts +3 -0
  79. package/lib/common/selectors/deployComponentsSelector.js +18 -0
  80. package/lib/common/selectors/deployComponentsSelector.js.map +1 -0
  81. package/lib/common/selectors/deployProgressSummarySelector.d.ts +13 -0
  82. package/lib/common/selectors/deployProgressSummarySelector.js +24 -0
  83. package/lib/common/selectors/deployProgressSummarySelector.js.map +1 -0
  84. package/lib/common/selectors/deploymentResultsSelector.d.ts +7 -0
  85. package/lib/common/selectors/deploymentResultsSelector.js +24 -0
  86. package/lib/common/selectors/deploymentResultsSelector.js.map +1 -0
  87. package/lib/common/selectors/environmentSelector.d.ts +11 -0
  88. package/lib/common/selectors/environmentSelector.js +22 -0
  89. package/lib/common/selectors/environmentSelector.js.map +1 -0
  90. package/lib/common/selectors/namedCredentialSelector.d.ts +6 -0
  91. package/lib/common/selectors/namedCredentialSelector.js +24 -0
  92. package/lib/common/selectors/namedCredentialSelector.js.map +1 -0
  93. package/lib/common/selectors/pipelineStageSelector.d.ts +7 -0
  94. package/lib/common/selectors/pipelineStageSelector.js +22 -0
  95. package/lib/common/selectors/pipelineStageSelector.js.map +1 -0
  96. package/lib/common/selectors/workItemSelector.d.ts +11 -0
  97. package/lib/common/selectors/workItemSelector.js +22 -0
  98. package/lib/common/selectors/workItemSelector.js.map +1 -0
  99. package/lib/common/types.d.ts +98 -0
  100. package/lib/common/types.js +24 -0
  101. package/lib/common/types.js.map +1 -0
  102. package/lib/common/utils.d.ts +75 -0
  103. package/lib/common/utils.js +176 -0
  104. package/lib/common/utils.js.map +1 -0
  105. package/lib/configMeta.d.ts +13 -0
  106. package/lib/configMeta.js +28 -0
  107. package/lib/configMeta.js.map +1 -0
  108. package/lib/streamer/doceMonitor.d.ts +7 -0
  109. package/lib/streamer/doceMonitor.js +9 -0
  110. package/lib/streamer/doceMonitor.js.map +1 -0
  111. package/lib/streamer/doceStream.d.ts +20 -0
  112. package/lib/streamer/doceStream.js +33 -0
  113. package/lib/streamer/doceStream.js.map +1 -0
  114. package/lib/streamer/processors/asyncOpStream.d.ts +20 -0
  115. package/lib/streamer/processors/asyncOpStream.js +48 -0
  116. package/lib/streamer/processors/asyncOpStream.js.map +1 -0
  117. package/lib/streamer/sObjectStream.d.ts +22 -0
  118. package/lib/streamer/sObjectStream.js +40 -0
  119. package/lib/streamer/sObjectStream.js.map +1 -0
  120. package/messages/aorOperations.output.md +8 -0
  121. package/messages/cache.md +3 -0
  122. package/messages/commonErrors.md +31 -0
  123. package/messages/commonFlags.md +53 -0
  124. package/messages/config.md +3 -0
  125. package/messages/deploy.output.md +31 -0
  126. package/messages/deploy.pipeline.md +37 -0
  127. package/messages/deploy.pipeline.report.md +49 -0
  128. package/messages/deploy.pipeline.resume.md +23 -0
  129. package/messages/promoteFlags.md +53 -0
  130. package/messages/resume.output.md +4 -0
  131. package/oclif.manifest.json +247 -0
  132. package/package.json +115 -0
  133. package/schemas/deploy-pipeline-report.json +25 -0
  134. package/schemas/deploy-pipeline-resume.json +25 -0
  135. package/schemas/deploy-pipeline.json +25 -0
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PromoteCommand = void 0;
4
+ /*
5
+ * Copyright (c) 2023, salesforce.com, inc.
6
+ * All rights reserved.
7
+ * Licensed under the BSD 3-Clause license.
8
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
9
+ */
10
+ const core_1 = require("@salesforce/core");
11
+ const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
12
+ const deployPipelineCache_1 = require("../deployPipelineCache");
13
+ const asyncOpStream_1 = require("../../streamer/processors/asyncOpStream");
14
+ const __1 = require("..");
15
+ const flags_1 = require("../flags/flags");
16
+ const promoteFlags_1 = require("../flags/promote/promoteFlags");
17
+ const constants_1 = require("../constants");
18
+ const types_1 = require("../types");
19
+ const utils_1 = require("../utils");
20
+ const outputService_1 = require("../outputService");
21
+ core_1.Messages.importMessagesDirectory(__dirname);
22
+ const messages = core_1.Messages.loadMessages('@salesforce/plugin-devops-center', 'commonErrors');
23
+ class PromoteCommand extends sf_plugins_core_1.SfCommand {
24
+ constructor() {
25
+ super(...arguments);
26
+ this.numRetries409 = 50; // this is the number of times we retry if we get a http-409-Conflict response
27
+ }
28
+ async init() {
29
+ await super.init();
30
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
31
+ const { flags } = await this.parse({
32
+ flags: this.ctor.flags,
33
+ baseFlags: super.ctor.baseFlags,
34
+ });
35
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
36
+ this.flags = flags;
37
+ this.outputService = new outputService_1.OutputServiceFactory().forDeployment(this.flags, this.flags['devops-center-username'].getConnection());
38
+ }
39
+ async executePromotion() {
40
+ (0, __1.validateTestFlags)(this.flags['test-level'], this.flags.tests);
41
+ const doceOrg = this.flags['devops-center-username'];
42
+ this.targetStage = await (0, __1.fetchAndValidatePipelineStage)(doceOrg, this.flags['devops-center-project-name'], this.flags['branch-name']);
43
+ this.sourceStageId = this.getSourceStageId();
44
+ const asyncOperationId = await this.requestPromotionFlow(doceOrg);
45
+ this.outputService.setAorId(asyncOperationId);
46
+ this.outputService.printAorId();
47
+ // eslint-disable-next-line @typescript-eslint/await-thenable
48
+ await this.outputService.printOpSummary();
49
+ await deployPipelineCache_1.DeployPipelineCache.set(asyncOperationId, {});
50
+ if (this.flags.async) {
51
+ return {
52
+ jobId: asyncOperationId,
53
+ status: types_1.AsyncOperationStatus.InProgress,
54
+ };
55
+ }
56
+ const doceMonitor = new asyncOpStream_1.default(doceOrg, this.flags.wait, asyncOperationId, this.outputService);
57
+ await doceMonitor.monitor();
58
+ if (this.outputService.getStatus() === types_1.AsyncOperationStatus.Completed) {
59
+ await this.outputService.displayEndResults();
60
+ }
61
+ // get final state of the async job
62
+ const asyncJob = await (0, utils_1.fetchAsyncOperationResult)(doceOrg.getConnection(), asyncOperationId);
63
+ return {
64
+ jobId: asyncOperationId,
65
+ status: asyncJob.sf_devops__Status__c,
66
+ message: asyncJob.sf_devops__Message__c,
67
+ errorDetails: asyncJob.sf_devops__Error_Details__c,
68
+ };
69
+ }
70
+ /**
71
+ *
72
+ * Sends an Http request to the target org to initiate a promotion.
73
+ *
74
+ * @param doceOrg target org.
75
+ * @returns Aor Id of promote operation.
76
+ */
77
+ async requestPromotionFlow(doceOrg) {
78
+ let spinnerStarted = false;
79
+ try {
80
+ return await this.requestPromotion(doceOrg);
81
+ }
82
+ catch (error) {
83
+ const err = error;
84
+ // if we get a 409 error then call the retry flow
85
+ if (err.errorCode === constants_1.HTTP_CONFLICT_CODE) {
86
+ this.spinner.start('Synchronization of source control system events in progress');
87
+ spinnerStarted = true;
88
+ return await this.retryRequestPromotion(doceOrg, this.numRetries409);
89
+ }
90
+ throw error;
91
+ }
92
+ finally {
93
+ if (spinnerStarted)
94
+ this.spinner.stop();
95
+ }
96
+ }
97
+ /**
98
+ *
99
+ * Sends an Http request to the target org to initiate a promotion.
100
+ * If it gets a 409/Conflict it will retry till the request successes,
101
+ * gets a differenct error or run out of retry attempts.
102
+ *
103
+ * @param doceOrg target org.
104
+ * @param numRetries Amount of remaining retry attempts.
105
+ * @returns Aor Id of promote operation
106
+ */
107
+ async retryRequestPromotion(doceOrg, numRetries) {
108
+ try {
109
+ return await this.requestPromotion(doceOrg);
110
+ }
111
+ catch (error) {
112
+ const err = error;
113
+ // if we still get a 409 error and haven't run out of retry attempts then retry again
114
+ if (err.errorCode === constants_1.HTTP_CONFLICT_CODE && numRetries > 1) {
115
+ return this.retryRequestPromotion(doceOrg, numRetries - 1);
116
+ }
117
+ throw error;
118
+ }
119
+ }
120
+ getTargetStage() {
121
+ return this.targetStage;
122
+ }
123
+ /**
124
+ * Default function for catching commands errors.
125
+ *
126
+ * @param error
127
+ * @returns
128
+ */
129
+ catch(error) {
130
+ if (error.name.includes('GenericTimeoutError')) {
131
+ const err = messages.createError('error.ClientTimeout', [this.config.bin, this.id]);
132
+ return super.catch({ ...error, name: err.name, message: err.message, code: err.code });
133
+ }
134
+ return super.catch(error);
135
+ }
136
+ async requestPromotion(targetOrg) {
137
+ this.buildPromoteOptions();
138
+ const req = {
139
+ method: 'POST',
140
+ url: `${constants_1.REST_PROMOTE_BASE_URL}${this.targetStage.sf_devops__Pipeline__r.sf_devops__Project__c}/pipelineName/${this.sourceStageId}`,
141
+ body: JSON.stringify({
142
+ changeBundleName: this.flags['bundle-version-name'],
143
+ promoteOptions: this.deployOptions,
144
+ }),
145
+ };
146
+ return targetOrg.getConnection().request(req);
147
+ }
148
+ buildPromoteOptions() {
149
+ this.deployOptions = {
150
+ fullDeploy: this.flags['deploy-all'],
151
+ testLevel: this.flags['test-level'] ?? 'Default',
152
+ runTests: this.flags.tests ? this.flags.tests.join(',') : undefined,
153
+ // get more promote options from the concrete implementation if needed
154
+ ...this.getPromoteOptions(),
155
+ };
156
+ }
157
+ }
158
+ exports.PromoteCommand = PromoteCommand;
159
+ // common flags that can be inherited by any command that extends PromoteCommand
160
+ PromoteCommand.baseFlags = {
161
+ 'branch-name': promoteFlags_1.branchName,
162
+ 'bundle-version-name': promoteFlags_1.bundleVersionName,
163
+ 'deploy-all': promoteFlags_1.deployAll,
164
+ 'devops-center-project-name': flags_1.devopsCenterProjectName,
165
+ 'devops-center-username': (0, flags_1.requiredDoceOrgFlag)(),
166
+ tests: promoteFlags_1.specificTests,
167
+ 'test-level': (0, promoteFlags_1.testLevel)(),
168
+ async: promoteFlags_1.async,
169
+ wait: flags_1.wait,
170
+ verbose: flags_1.verbose,
171
+ concise: flags_1.concise,
172
+ };
173
+ //# sourceMappingURL=abstractPromote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstractPromote.js","sourceRoot":"","sources":["../../../src/common/base/abstractPromote.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,2CAA0D;AAC1D,iEAAwD;AAGxD,gEAA6D;AAC7D,2EAAuE;AACvE,0BAMY;AACZ,0CAAsG;AACtG,gEAOuC;AAGvC,4CAAyE;AACzE,oCAAgF;AAChF,oCAAqD;AACrD,oDAA8E;AAE9E,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,kCAAkC,EAAE,cAAc,CAAC,CAAC;AAM3F,MAAsB,cAA2C,SAAQ,2BAAgC;IAAzG;;QAoBU,kBAAa,GAAG,EAAE,CAAC,CAAC,8EAA8E;IA0K5G,CAAC;IAtKQ,KAAK,CAAC,IAAI;QACf,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,mEAAmE;QACnE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC;YACjC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK;YACtB,SAAS,EAAG,KAAK,CAAC,IAA8B,CAAC,SAAS;SAC3D,CAAC,CAAC;QACH,mEAAmE;QACnE,IAAI,CAAC,KAAK,GAAG,KAAiB,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,IAAI,oCAAoB,EAAE,CAAC,aAAa,CAC3D,IAAI,CAAC,KAAK,EACT,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAS,CAAC,aAAa,EAAE,CAC9D,CAAC;IACJ,CAAC;IAES,KAAK,CAAC,gBAAgB;QAC9B,IAAA,qBAAiB,EAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,KAAK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AI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;YACnE,sEAAsE;YACtE,GAAG,IAAI,CAAC,iBAAiB,EAAE;SAC5B,CAAC;IACJ,CAAC;;AA/KH,wCA8LC;AA7LC,gFAAgF;AAClE,wBAAS,GAAG;IACxB,aAAa,EAAE,yBAAU;IACzB,qBAAqB,EAAE,gCAAiB;IACxC,YAAY,EAAE,wBAAS;IACvB,4BAA4B,EAAE,+BAAuB;IACrD,wBAAwB,EAAE,IAAA,2BAAmB,GAAE;IAC/C,KAAK,EAAE,4BAAa;IACpB,YAAY,EAAE,IAAA,wBAAS,GAAE;IACzB,KAAK,EAAL,oBAAK;IACL,IAAI,EAAJ,YAAI;IACJ,OAAO,EAAP,eAAO;IACP,OAAO,EAAP,eAAO;CACR,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Org } from '@salesforce/core';
2
+ import { SfCommand } from '@salesforce/sf-plugins-core';
3
+ import { Interfaces } from '@oclif/core';
4
+ import { PromotePipelineResult } from '../../common';
5
+ export type Flags<T extends typeof SfCommand> = Interfaces.InferredFlags<(typeof ReportOnPromoteCommand)['baseFlags'] & T['flags']>;
6
+ export declare abstract class ReportOnPromoteCommand<T extends typeof SfCommand> extends SfCommand<PromotePipelineResult> {
7
+ static baseFlags: {
8
+ 'devops-center-username': Interfaces.OptionFlag<Org | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ };
10
+ protected flags: Flags<T>;
11
+ protected abstract operationName: string;
12
+ init(): Promise<void>;
13
+ /**
14
+ * Prints a report of an async operation.
15
+ */
16
+ protected getOperationReport(): Promise<PromotePipelineResult>;
17
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReportOnPromoteCommand = void 0;
4
+ /*
5
+ * Copyright (c) 2023, salesforce.com, inc.
6
+ * All rights reserved.
7
+ * Licensed under the BSD 3-Clause license.
8
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
9
+ */
10
+ const core_1 = require("@salesforce/core");
11
+ const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
12
+ const deployPipelineCache_1 = require("../../common/deployPipelineCache");
13
+ const flags_1 = require("../../common/flags/flags");
14
+ const deploymentResultsSelector_1 = require("./../selectors/deploymentResultsSelector");
15
+ const outputServiceFactory_1 = require("./../outputService/outputServiceFactory");
16
+ core_1.Messages.importMessagesDirectory(__dirname);
17
+ const messages = core_1.Messages.loadMessages('@salesforce/plugin-devops-center', 'commonErrors');
18
+ class ReportOnPromoteCommand extends sf_plugins_core_1.SfCommand {
19
+ async init() {
20
+ await super.init();
21
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
22
+ const { flags } = await this.parse({
23
+ flags: this.ctor.flags,
24
+ baseFlags: super.ctor.baseFlags,
25
+ });
26
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
27
+ this.flags = flags;
28
+ }
29
+ /**
30
+ * Prints a report of an async operation.
31
+ */
32
+ async getOperationReport() {
33
+ const asyncJobId = this.flags['use-most-recent']
34
+ ? (await deployPipelineCache_1.DeployPipelineCache.create()).getLatestKeyOrThrow()
35
+ : this.flags['job-id'];
36
+ const org = this.flags['devops-center-username'];
37
+ try {
38
+ // query the deployment result related to the promote operation.
39
+ const operationResult = await (0, deploymentResultsSelector_1.selectOneDeploymentResultByAsyncJobId)(org.getConnection(), asyncJobId);
40
+ if (!this.jsonEnabled()) {
41
+ const displayer = new outputServiceFactory_1.OutputServiceFactory().forPromotionReport(this.flags, operationResult, this.operationName);
42
+ displayer.printOpSummary();
43
+ }
44
+ return {
45
+ jobId: asyncJobId,
46
+ status: operationResult.sf_devops__Status__r.sf_devops__Status__c,
47
+ message: operationResult.sf_devops__Status__r.sf_devops__Message__c,
48
+ errorDetails: operationResult.sf_devops__Status__r.sf_devops__Error_Details__c,
49
+ };
50
+ }
51
+ catch (err) {
52
+ const error = err;
53
+ if (error.name === 'SingleRecordQuery_NoRecords') {
54
+ throw messages.createError('error.InvalidAorId', [asyncJobId]);
55
+ }
56
+ throw err;
57
+ }
58
+ }
59
+ }
60
+ exports.ReportOnPromoteCommand = ReportOnPromoteCommand;
61
+ ReportOnPromoteCommand.baseFlags = {
62
+ 'devops-center-username': (0, flags_1.requiredDoceOrgFlag)(),
63
+ };
64
+ //# sourceMappingURL=abstractReportOnPromote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstractReportOnPromote.js","sourceRoot":"","sources":["../../../src/common/base/abstractReportOnPromote.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,2CAAiD;AACjD,iEAAwD;AAExD,0EAAuE;AAEvE,oDAA+D;AAE/D,wFAAiG;AAEjG,kFAA+E;AAE/E,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,kCAAkC,EAAE,cAAc,CAAC,CAAC;AAM3F,MAAsB,sBAAmD,SAAQ,2BAAgC;IAOxG,KAAK,CAAC,IAAI;QACf,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,mEAAmE;QACnE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC;YACjC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK;YACtB,SAAS,EAAG,KAAK,CAAC,IAAsC,CAAC,SAAS;SACnE,CAAC,CAAC;QACH,mEAAmE;QACnE,IAAI,CAAC,KAAK,GAAG,KAAiB,CAAC;IACjC,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,kBAAkB;QAChC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC;YAC9C,CAAC,CAAC,CAAC,MAAM,yCAAmB,CAAC,MAAM,EAAE,CAAC,CAAC,mBAAmB,EAAE;YAC5D,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAY,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAQ,CAAC;QAExD,IAAI;YACF,gEAAgE;YAChE,MAAM,eAAe,GAAqB,MAAM,IAAA,iEAAqC,EACnF,GAAG,CAAC,aAAa,EAAE,EACnB,UAAU,CACX,CAAC;YACF,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE;gBACvB,MAAM,SAAS,GAAkB,IAAI,2CAAoB,EAAE,CAAC,kBAAkB,CAC5E,IAAI,CAAC,KAAK,EACV,eAAe,EACf,IAAI,CAAC,aAAa,CACnB,CAAC;gBACF,SAAS,CAAC,cAAc,EAAE,CAAC;aAC5B;YAED,OAAO;gBACL,KAAK,EAAE,UAAU;gBACjB,MAAM,EAAE,eAAe,CAAC,oBAAoB,CAAC,oBAAoB;gBACjE,OAAO,EAAE,eAAe,CAAC,oBAAoB,CAAC,qBAAqB;gBACnE,YAAY,EAAE,eAAe,CAAC,oBAAoB,CAAC,2BAA2B;aAC/E,CAAC;SACH;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,KAAK,GAAG,GAAY,CAAC;YAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,6BAA6B,EAAE;gBAChD,MAAM,QAAQ,CAAC,WAAW,CAAC,oBAAoB,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;aAChE;YACD,MAAM,GAAG,CAAC;SACX;IACH,CAAC;;AAvDH,wDAwDC;AAvDe,gCAAS,GAAG;IACxB,wBAAwB,EAAE,IAAA,2BAAmB,GAAE;CAChD,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { Org, SfError } from '@salesforce/core';
2
+ import { SfCommand } from '@salesforce/sf-plugins-core';
3
+ import { Interfaces } from '@oclif/core';
4
+ import { AsyncOperationStatus, PromotePipelineResult } from '../../common';
5
+ /**
6
+ * Helper to determine if an operation has finished and therefore is not resumable
7
+ *
8
+ * @param status status of the async operation
9
+ * @returns true if the operation has finished
10
+ */
11
+ export declare function isNotResumable(status: AsyncOperationStatus): boolean;
12
+ export type Flags<T extends typeof SfCommand> = Interfaces.InferredFlags<(typeof ResumeCommand)['baseFlags'] & T['flags']>;
13
+ /**
14
+ *
15
+ * Base class with the common logic to resume an in progress opeation
16
+ */
17
+ export declare abstract class ResumeCommand<T extends typeof SfCommand> extends SfCommand<PromotePipelineResult> {
18
+ static baseFlags: {
19
+ 'devops-center-username': Interfaces.OptionFlag<Org | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
20
+ 'job-id': Interfaces.OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
21
+ 'use-most-recent': Interfaces.BooleanFlag<boolean>;
22
+ wait: Interfaces.OptionFlag<import("@salesforce/kit").Duration, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
23
+ };
24
+ protected flags: Flags<T>;
25
+ private outputService;
26
+ protected abstract operationType: string;
27
+ protected abstract baseCommand: string;
28
+ init(): Promise<void>;
29
+ protected resumeOperation(): Promise<PromotePipelineResult>;
30
+ /**
31
+ * Default function for catching commands errors.
32
+ *
33
+ * @param error
34
+ * @returns
35
+ */
36
+ protected catch(error: Error | SfError): Promise<SfCommand.Error>;
37
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ResumeCommand = exports.isNotResumable = void 0;
4
+ /*
5
+ * Copyright (c) 2023, salesforce.com, inc.
6
+ * All rights reserved.
7
+ * Licensed under the BSD 3-Clause license.
8
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
9
+ */
10
+ const core_1 = require("@salesforce/core");
11
+ const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
12
+ const common_1 = require("../../common");
13
+ const flags_1 = require("../../common/flags/flags");
14
+ const deployPipelineCache_1 = require("./../deployPipelineCache");
15
+ const outputService_1 = require("./../outputService");
16
+ core_1.Messages.importMessagesDirectory(__dirname);
17
+ const messages = core_1.Messages.loadMessages('@salesforce/plugin-devops-center', 'commonErrors');
18
+ /**
19
+ * Helper to determine if an operation has finished and therefore is not resumable
20
+ *
21
+ * @param status status of the async operation
22
+ * @returns true if the operation has finished
23
+ */
24
+ function isNotResumable(status) {
25
+ return [common_1.AsyncOperationStatus.Completed, common_1.AsyncOperationStatus.Error, common_1.AsyncOperationStatus.Ignored].includes(status);
26
+ }
27
+ exports.isNotResumable = isNotResumable;
28
+ /**
29
+ *
30
+ * Base class with the common logic to resume an in progress opeation
31
+ */
32
+ class ResumeCommand extends sf_plugins_core_1.SfCommand {
33
+ async init() {
34
+ await super.init();
35
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
36
+ const { flags } = await this.parse({
37
+ flags: this.ctor.flags,
38
+ baseFlags: super.ctor.baseFlags,
39
+ }); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
40
+ this.flags = flags;
41
+ this.outputService = new outputService_1.OutputServiceFactory().forResume(this.operationType);
42
+ }
43
+ async resumeOperation() {
44
+ const asyncJobId = this.flags['use-most-recent']
45
+ ? (await deployPipelineCache_1.DeployPipelineCache.create()).getLatestKeyOrThrow()
46
+ : this.flags['job-id'];
47
+ // get the latest state of the async job and validate that it's resumable
48
+ const doceOrg = this.flags['devops-center-username'];
49
+ let asyncJob = await (0, common_1.fetchAsyncOperationResult)(doceOrg.getConnection(), asyncJobId);
50
+ if (asyncJob.sf_devops__Status__c && isNotResumable(asyncJob.sf_devops__Status__c)) {
51
+ throw messages.createError('error.JobNotResumable', [asyncJobId, asyncJob.sf_devops__Status__c]);
52
+ }
53
+ // it is resumable so we can start monitoring the operation
54
+ this.outputService.setAorId(asyncJobId);
55
+ this.outputService.printOpSummary();
56
+ this.outputService.printAorId();
57
+ const streamer = (0, common_1.getAsyncOperationStreamer)(doceOrg, this.flags.wait, asyncJobId, this.outputService);
58
+ await streamer.monitor();
59
+ // get final state of the async job
60
+ asyncJob = await (0, common_1.fetchAsyncOperationResult)(doceOrg.getConnection(), asyncJobId);
61
+ return {
62
+ jobId: asyncJobId,
63
+ status: asyncJob.sf_devops__Status__c,
64
+ message: asyncJob.sf_devops__Message__c,
65
+ errorDetails: asyncJob.sf_devops__Error_Details__c,
66
+ };
67
+ }
68
+ /**
69
+ * Default function for catching commands errors.
70
+ *
71
+ * @param error
72
+ * @returns
73
+ */
74
+ catch(error) {
75
+ if (error.name.includes('GenericTimeoutError')) {
76
+ const err = messages.createError('error.ClientTimeout', [this.config.bin, this.baseCommand]);
77
+ return super.catch({ ...error, name: err.name, message: err.message, code: err.code });
78
+ }
79
+ return super.catch(error);
80
+ }
81
+ }
82
+ exports.ResumeCommand = ResumeCommand;
83
+ // common flags that can be inherited by any command that extends ResumeCommand
84
+ ResumeCommand.baseFlags = {
85
+ 'devops-center-username': (0, flags_1.requiredDoceOrgFlag)(),
86
+ 'job-id': flags_1.jobId,
87
+ 'use-most-recent': flags_1.useMostRecent,
88
+ wait: flags_1.wait,
89
+ };
90
+ //# sourceMappingURL=abstractResume.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstractResume.js","sourceRoot":"","sources":["../../../src/common/base/abstractResume.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,2CAA0D;AAC1D,iEAAwD;AAExD,yCAMsB;AACtB,oDAA2F;AAE3F,kEAA+D;AAC/D,sDAA+E;AAE/E,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,kCAAkC,EAAE,cAAc,CAAC,CAAC;AAE3F;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,MAA4B;IACzD,OAAO,CAAC,6BAAoB,CAAC,SAAS,EAAE,6BAAoB,CAAC,KAAK,EAAE,6BAAoB,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACrH,CAAC;AAFD,wCAEC;AAMD;;;GAGG;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";
2
+ export declare const ASYNC_OPERATION_CDC = "/data/Async_Operation_Result__ChangeEvent";
3
+ export declare const REST_PROMOTE_BASE_URL = "/services/apexrest/sf_devops/pipeline/promote/v1/";
4
+ export declare const HTTP_CONFLICT_CODE = "CONFLICT";
5
+ export declare enum AsyncOperationType {
6
+ AD_HOC_PROMOTE = "AD_HOC_PROMOTE",
7
+ VERSIONED_PROMOTE = "VERSIONED_PROMOTE",
8
+ SOUP_PROMOTE = "SOUP_PROMOTE"
9
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2023, salesforce.com, inc.
4
+ * All rights reserved.
5
+ * Licensed under the BSD 3-Clause license.
6
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.AsyncOperationType = exports.HTTP_CONFLICT_CODE = exports.REST_PROMOTE_BASE_URL = exports.ASYNC_OPERATION_CDC = exports.APPROVED = void 0;
10
+ exports.APPROVED = 'Approved';
11
+ exports.ASYNC_OPERATION_CDC = '/data/Async_Operation_Result__ChangeEvent';
12
+ exports.REST_PROMOTE_BASE_URL = '/services/apexrest/sf_devops/pipeline/promote/v1/';
13
+ exports.HTTP_CONFLICT_CODE = 'CONFLICT';
14
+ var AsyncOperationType;
15
+ (function (AsyncOperationType) {
16
+ AsyncOperationType["AD_HOC_PROMOTE"] = "AD_HOC_PROMOTE";
17
+ AsyncOperationType["VERSIONED_PROMOTE"] = "VERSIONED_PROMOTE";
18
+ AsyncOperationType["SOUP_PROMOTE"] = "SOUP_PROMOTE";
19
+ })(AsyncOperationType = exports.AsyncOperationType || (exports.AsyncOperationType = {}));
20
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,QAAQ,GAAG,UAAU,CAAC;AACtB,QAAA,mBAAmB,GAAG,2CAA2C,CAAC;AAClE,QAAA,qBAAqB,GAAG,mDAAmD,CAAC;AAC5E,QAAA,kBAAkB,GAAG,UAAU,CAAC;AAC7C,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,uDAAiC,CAAA;IACjC,6DAAuC,CAAA;IACvC,mDAA6B,CAAA;AAC/B,CAAC,EAJW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAI7B"}
@@ -0,0 +1,39 @@
1
+ import { TTLConfig } from '@salesforce/core';
2
+ import { JsonMap } from '@salesforce/ts-types';
3
+ export type AsyncOperationData = Record<string, never>;
4
+ /**
5
+ * Caches the AOR data
6
+ *
7
+ * @author JuanStenghele-sf
8
+ */
9
+ export declare class DeployPipelineCache extends TTLConfig<TTLConfig.Options, AsyncOperationData> {
10
+ /**
11
+ * Returns the cache's filename
12
+ */
13
+ static getFileName(): string;
14
+ /**
15
+ * Returns the cache's options
16
+ */
17
+ static getDefaultOptions(): TTLConfig.Options;
18
+ /**
19
+ * Caches the data sent
20
+ */
21
+ static set(aorId: string, data: AsyncOperationData): Promise<void>;
22
+ /**
23
+ * Removes the data associated with the aorId
24
+ */
25
+ static unset(aorId: string): Promise<void>;
26
+ /**
27
+ * Updates the aorId with the data sent
28
+ * Merges the data sent with the existing one
29
+ */
30
+ static update(aorId: string, data: JsonMap): Promise<void>;
31
+ /**
32
+ * Returns the data associated with the aorId
33
+ */
34
+ get(aorId: string): TTLConfig.Entry<AsyncOperationData>;
35
+ /**
36
+ * Returns the latest data cached or throws if can't find any.
37
+ */
38
+ getLatestKeyOrThrow(): string;
39
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2023, salesforce.com, inc.
4
+ * All rights reserved.
5
+ * Licensed under the BSD 3-Clause license.
6
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.DeployPipelineCache = void 0;
10
+ const core_1 = require("@salesforce/core");
11
+ const kit_1 = require("@salesforce/kit");
12
+ core_1.Messages.importMessagesDirectory(__dirname);
13
+ const cacheMessages = core_1.Messages.loadMessages('@salesforce/plugin-devops-center', 'cache');
14
+ /**
15
+ * Caches the AOR data
16
+ *
17
+ * @author JuanStenghele-sf
18
+ */
19
+ class DeployPipelineCache extends core_1.TTLConfig {
20
+ /**
21
+ * Returns the cache's filename
22
+ */
23
+ static getFileName() {
24
+ return 'deploy-pipeline-cache.json';
25
+ }
26
+ /**
27
+ * Returns the cache's options
28
+ */
29
+ static getDefaultOptions() {
30
+ return {
31
+ isGlobal: true,
32
+ isState: false,
33
+ filename: this.getFileName(),
34
+ stateFolder: core_1.Global.SF_STATE_FOLDER,
35
+ ttl: kit_1.Duration.days(3),
36
+ };
37
+ }
38
+ /**
39
+ * Caches the data sent
40
+ */
41
+ static async set(aorId, data) {
42
+ const cache = await DeployPipelineCache.create();
43
+ cache.set(aorId, data);
44
+ await cache.write();
45
+ }
46
+ /**
47
+ * Removes the data associated with the aorId
48
+ */
49
+ static async unset(aorId) {
50
+ const cache = await DeployPipelineCache.create();
51
+ cache.unset(aorId);
52
+ await cache.write();
53
+ }
54
+ /**
55
+ * Updates the aorId with the data sent
56
+ * Merges the data sent with the existing one
57
+ */
58
+ static async update(aorId, data) {
59
+ const cache = await DeployPipelineCache.create();
60
+ cache.update(aorId, data);
61
+ await cache.write();
62
+ }
63
+ /**
64
+ * Returns the data associated with the aorId
65
+ */
66
+ get(aorId) {
67
+ return super.get(aorId);
68
+ }
69
+ /**
70
+ * Returns the latest data cached or throws if can't find any.
71
+ */
72
+ getLatestKeyOrThrow() {
73
+ const aorId = this.getLatestKey();
74
+ if (!aorId) {
75
+ throw cacheMessages.createError('error.NoRecentAorId');
76
+ }
77
+ return aorId;
78
+ }
79
+ }
80
+ exports.DeployPipelineCache = DeployPipelineCache;
81
+ //# sourceMappingURL=deployPipelineCache.js.map
@@ -0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AAM,mBAAmB,CAAC,MAAM,EAAE,CAAC;QACjD,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC1B,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IAED;;OAEG;IACI,GAAG,CAAC,KAAa;QACtB,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED;;OAEG;IACI,mBAAmB;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAClC,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,aAAa,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;SACxD;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAlED,kDAkEC"}
@@ -0,0 +1,19 @@
1
+ import { Org } from '@salesforce/core';
2
+ import { Duration } from '@salesforce/kit';
3
+ import { BooleanFlag, OptionFlag } from '@oclif/core/lib/interfaces';
4
+ export declare const devopsCenterProjectName: OptionFlag<string>;
5
+ /**
6
+ * Wait flag
7
+ * This is used to determine how many minutes we are going to stream results before giving back the control of the terminal to the user.
8
+ */
9
+ export declare const wait: OptionFlag<Duration>;
10
+ /**
11
+ * Custom flag for the target devops center org.
12
+ * Makes this flag required and validates that passed in alias/username corresponds to an authenticated org.
13
+ * If no value is passed in, then it looks for the alias/username set in the --target-devops-center config variable.
14
+ */
15
+ export declare const requiredDoceOrgFlag: import("@oclif/core/lib/interfaces/parser").FlagDefinition<Org, Record<string, unknown>>;
16
+ export declare const jobId: OptionFlag<string | undefined>;
17
+ export declare const useMostRecent: BooleanFlag<boolean>;
18
+ export declare const verbose: BooleanFlag<boolean>;
19
+ export declare const concise: BooleanFlag<boolean>;