@salesforce/plugin-release-management 4.5.26 → 4.6.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/README.md +112 -135
- package/bin/dev.js +8 -6
- package/bin/run.js +7 -5
- package/lib/amazonS3.d.ts +4 -8
- package/lib/amazonS3.js +76 -81
- package/lib/amazonS3.js.map +1 -1
- package/lib/codeSigning/NpmName.js +5 -9
- package/lib/codeSigning/NpmName.js.map +1 -1
- package/lib/codeSigning/SimplifiedSigning.d.ts +1 -1
- package/lib/codeSigning/SimplifiedSigning.js +16 -21
- package/lib/codeSigning/SimplifiedSigning.js.map +1 -1
- package/lib/codeSigning/error.js +2 -6
- package/lib/codeSigning/error.js.map +1 -1
- package/lib/codeSigning/packAndSign.d.ts +2 -2
- package/lib/codeSigning/packAndSign.js +45 -44
- package/lib/codeSigning/packAndSign.js.map +1 -1
- package/lib/codeSigning/upload.d.ts +1 -1
- package/lib/codeSigning/upload.js +4 -8
- package/lib/codeSigning/upload.js.map +1 -1
- package/lib/commands/channel/promote.d.ts +11 -4
- package/lib/commands/channel/promote.js +113 -115
- package/lib/commands/channel/promote.js.map +1 -1
- package/lib/commands/cli/artifacts/compare.js +58 -52
- package/lib/commands/cli/artifacts/compare.js.map +1 -1
- package/lib/commands/cli/install/jit/test.d.ts +1 -1
- package/lib/commands/cli/install/jit/test.js +18 -21
- package/lib/commands/cli/install/jit/test.js.map +1 -1
- package/lib/commands/cli/install/test.d.ts +4 -4
- package/lib/commands/cli/install/test.js +114 -106
- package/lib/commands/cli/install/test.js.map +1 -1
- package/lib/commands/cli/release/automerge.d.ts +5 -5
- package/lib/commands/cli/release/automerge.js +44 -47
- package/lib/commands/cli/release/automerge.js.map +1 -1
- package/lib/commands/cli/release/build.d.ts +12 -12
- package/lib/commands/cli/release/build.js +78 -81
- package/lib/commands/cli/release/build.js.map +1 -1
- package/lib/commands/cli/releasenotes.d.ts +4 -4
- package/lib/commands/cli/releasenotes.js +49 -54
- package/lib/commands/cli/releasenotes.js.map +1 -1
- package/lib/commands/cli/tarballs/prepare.js +31 -33
- package/lib/commands/cli/tarballs/prepare.js.map +1 -1
- package/lib/commands/cli/tarballs/smoke.js +33 -32
- package/lib/commands/cli/tarballs/smoke.js.map +1 -1
- package/lib/commands/cli/tarballs/verify.d.ts +1 -1
- package/lib/commands/cli/tarballs/verify.js +58 -62
- package/lib/commands/cli/tarballs/verify.js.map +1 -1
- package/lib/commands/cli/versions/inspect.d.ts +4 -3
- package/lib/commands/cli/versions/inspect.js +79 -84
- package/lib/commands/cli/versions/inspect.js.map +1 -1
- package/lib/commands/dependabot/automerge.d.ts +6 -6
- package/lib/commands/dependabot/automerge.js +48 -48
- package/lib/commands/dependabot/automerge.js.map +1 -1
- package/lib/commands/github/check/closed.d.ts +7 -5
- package/lib/commands/github/check/closed.js +25 -28
- package/lib/commands/github/check/closed.js.map +1 -1
- package/lib/commands/npm/dependencies/pin.d.ts +3 -3
- package/lib/commands/npm/dependencies/pin.js +21 -24
- package/lib/commands/npm/dependencies/pin.js.map +1 -1
- package/lib/commands/npm/package/release.d.ts +11 -12
- package/lib/commands/npm/package/release.js +58 -61
- package/lib/commands/npm/package/release.js.map +1 -1
- package/lib/commands/repositories/index.d.ts +4 -3
- package/lib/commands/repositories/index.js +17 -20
- package/lib/commands/repositories/index.js.map +1 -1
- package/lib/dependabot.d.ts +1 -1
- package/lib/dependabot.js +13 -17
- package/lib/dependabot.js.map +1 -1
- package/lib/dependencies.d.ts +1 -1
- package/lib/dependencies.js +3 -7
- package/lib/dependencies.js.map +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib/jit.js +18 -22
- package/lib/jit.js.map +1 -1
- package/lib/package.d.ts +0 -2
- package/lib/package.js +36 -59
- package/lib/package.js.map +1 -1
- package/lib/registry.js +19 -18
- package/lib/registry.js.map +1 -1
- package/lib/repositories.js +5 -9
- package/lib/repositories.js.map +1 -1
- package/lib/repository.d.ts +5 -7
- package/lib/repository.js +41 -43
- package/lib/repository.js.map +1 -1
- package/lib/types.js +4 -7
- package/lib/types.js.map +1 -1
- package/npm-shrinkwrap.json +2992 -2265
- package/oclif.manifest.json +17 -69
- package/package.json +12 -11
- package/lib/commands/cli/schemas/compare.d.ts +0 -19
- package/lib/commands/cli/schemas/compare.js +0 -114
- package/lib/commands/cli/schemas/compare.js.map +0 -1
- package/messages/cli.schemas.compare.md +0 -7
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
2
|
/*
|
|
4
3
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
5
4
|
* All rights reserved.
|
|
6
5
|
* Licensed under the BSD 3-Clause license.
|
|
7
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
8
7
|
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.api = void 0;
|
|
11
8
|
/* eslint-disable no-underscore-dangle */
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
import fs from 'node:fs/promises';
|
|
10
|
+
import cp from 'node:child_process';
|
|
11
|
+
import { EOL } from 'node:os';
|
|
12
|
+
import { join as pathJoin } from 'node:path';
|
|
13
|
+
import { Logger } from '@salesforce/core';
|
|
14
|
+
import { NamedError } from '@salesforce/kit';
|
|
15
|
+
import { ProxyAgent } from 'proxy-agent';
|
|
16
|
+
import { signVerifyUpload as sign2, getSfdxProperty } from './SimplifiedSigning.js';
|
|
17
|
+
import { ExecProcessFailed } from './error.js';
|
|
18
|
+
import { parseNpmName } from './NpmName.js';
|
|
22
19
|
class PathGetter {
|
|
20
|
+
static packageJson = 'package.json';
|
|
21
|
+
_packageJson;
|
|
22
|
+
_packageJsonBak;
|
|
23
|
+
_target;
|
|
24
|
+
_cwd;
|
|
23
25
|
constructor(target) {
|
|
24
26
|
this._cwd = process.cwd();
|
|
25
27
|
if (!target) {
|
|
@@ -29,10 +31,10 @@ class PathGetter {
|
|
|
29
31
|
this._target = target;
|
|
30
32
|
}
|
|
31
33
|
else {
|
|
32
|
-
this._target = (
|
|
34
|
+
this._target = pathJoin(this._cwd, target);
|
|
33
35
|
}
|
|
34
|
-
this._packageJson = (
|
|
35
|
-
this._packageJsonBak = (
|
|
36
|
+
this._packageJson = pathJoin(this._target, PathGetter.packageJson);
|
|
37
|
+
this._packageJsonBak = pathJoin(this._target, `${PathGetter.packageJson}.bak`);
|
|
36
38
|
}
|
|
37
39
|
get packageJson() {
|
|
38
40
|
return this._packageJson;
|
|
@@ -44,16 +46,15 @@ class PathGetter {
|
|
|
44
46
|
return this._target;
|
|
45
47
|
}
|
|
46
48
|
getFile(filename) {
|
|
47
|
-
return (
|
|
49
|
+
return pathJoin(this._target, filename);
|
|
48
50
|
}
|
|
49
51
|
getIgnoreFile(filename) {
|
|
50
|
-
return (
|
|
52
|
+
return pathJoin(this._cwd, filename);
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
|
-
PathGetter.packageJson = 'package.json';
|
|
54
55
|
let cliUx;
|
|
55
56
|
let pathGetter;
|
|
56
|
-
|
|
57
|
+
export const api = {
|
|
57
58
|
setUx(ux) {
|
|
58
59
|
cliUx = ux;
|
|
59
60
|
},
|
|
@@ -65,14 +66,14 @@ exports.api = {
|
|
|
65
66
|
pathGetter = new PathGetter();
|
|
66
67
|
return new Promise((resolve, reject) => {
|
|
67
68
|
const command = 'npm pack -p';
|
|
68
|
-
|
|
69
|
+
cp.exec(command, { cwd: pathGetter.target, maxBuffer: 1024 * 4096 },
|
|
69
70
|
// we expect an error code from this command, so we're adding it to the normal Error type
|
|
70
71
|
(error, stdout, stderr) => {
|
|
71
72
|
if (error?.code) {
|
|
72
|
-
return reject(new
|
|
73
|
+
return reject(new ExecProcessFailed(command, error['code'], stderr));
|
|
73
74
|
}
|
|
74
75
|
else {
|
|
75
|
-
const output = stdout.split(
|
|
76
|
+
const output = stdout.split(EOL);
|
|
76
77
|
if (output.length > 1) {
|
|
77
78
|
// note the output end with a newline;
|
|
78
79
|
const path = output[output.length - 2];
|
|
@@ -80,11 +81,11 @@ exports.api = {
|
|
|
80
81
|
return resolve(pathGetter.getFile(path));
|
|
81
82
|
}
|
|
82
83
|
else {
|
|
83
|
-
return reject(new
|
|
84
|
+
return reject(new NamedError('UnexpectedNpmFormat', `Npm pack did not return an expected tgz filename result: [${path}]`));
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
else {
|
|
87
|
-
return reject(new
|
|
88
|
+
return reject(new NamedError('UnexpectedNpmFormat', `The output from the npm utility is unexpected [${stdout}]`));
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
});
|
|
@@ -112,10 +113,10 @@ exports.api = {
|
|
|
112
113
|
validateNpmIgnorePatterns(content) {
|
|
113
114
|
const validate = (pattern) => {
|
|
114
115
|
if (!content) {
|
|
115
|
-
throw new
|
|
116
|
+
throw new NamedError('MissingNpmIgnoreFile', 'Missing .npmignore file. The following patterns are required in for code signing: *.tgz, *.sig, package.json.bak.');
|
|
116
117
|
}
|
|
117
118
|
if (!content.includes(pattern)) {
|
|
118
|
-
throw new
|
|
119
|
+
throw new NamedError('MissingNpmIgnorePattern', `.npmignore is missing ${pattern}. The following patterns are required for code signing: *.tgz, *.sig, package.json.bak`);
|
|
119
120
|
}
|
|
120
121
|
};
|
|
121
122
|
validate('*.tgz');
|
|
@@ -130,7 +131,7 @@ exports.api = {
|
|
|
130
131
|
validateNpmFilePatterns(patterns) {
|
|
131
132
|
const validate = (pattern) => {
|
|
132
133
|
if (patterns.includes(pattern)) {
|
|
133
|
-
throw new
|
|
134
|
+
throw new NamedError('ForbiddenFilePattern', 'the files property in package.json should not include the following: *.tgz, *.sig, package.json.bak');
|
|
134
135
|
}
|
|
135
136
|
};
|
|
136
137
|
validate('*.tgz');
|
|
@@ -158,7 +159,7 @@ exports.api = {
|
|
|
158
159
|
// Restore the package.json file so it doesn't show a git diff.
|
|
159
160
|
await fs.access(pathGetter.packageJsonBak);
|
|
160
161
|
cliUx.log(`Restoring package.json from ${pathGetter.packageJsonBak}`);
|
|
161
|
-
await
|
|
162
|
+
await api.copyPackageDotJson(pathGetter.packageJsonBak, pathGetter.packageJson);
|
|
162
163
|
await fs.unlink(pathGetter.packageJsonBak);
|
|
163
164
|
},
|
|
164
165
|
/**
|
|
@@ -169,51 +170,51 @@ exports.api = {
|
|
|
169
170
|
* @return {Promise<SigningResponse>} The SigningResponse
|
|
170
171
|
*/
|
|
171
172
|
async packSignVerifyModifyPackageJSON(targetPackagePath) {
|
|
172
|
-
const logger = await
|
|
173
|
+
const logger = await Logger.child('packAndSign');
|
|
173
174
|
pathGetter = new PathGetter(targetPackagePath);
|
|
174
175
|
try {
|
|
175
176
|
// read package.json info
|
|
176
|
-
const packageJsonContent = await
|
|
177
|
+
const packageJsonContent = await api.retrievePackageJson();
|
|
177
178
|
const packageJson = JSON.parse(packageJsonContent);
|
|
178
179
|
logger.debug('parsed the package.json content');
|
|
179
180
|
if (packageJson.files) {
|
|
180
181
|
// validate that files property does not include forbidden patterns
|
|
181
|
-
|
|
182
|
+
api.validateNpmFilePatterns(packageJson.files);
|
|
182
183
|
}
|
|
183
184
|
else {
|
|
184
185
|
// validate npm ignore has what we name.
|
|
185
|
-
const npmIgnoreContent = await
|
|
186
|
-
|
|
186
|
+
const npmIgnoreContent = await api.retrieveIgnoreFile('.npmignore');
|
|
187
|
+
api.validateNpmIgnorePatterns(npmIgnoreContent);
|
|
187
188
|
logger.debug('validated the expected npm ignore patterns');
|
|
188
189
|
}
|
|
189
190
|
// Recommend updating git ignore to match npmignore.
|
|
190
191
|
const filename = '.gitignore';
|
|
191
|
-
const gitIgnoreContent = await
|
|
192
|
+
const gitIgnoreContent = await api.retrieveIgnoreFile(filename);
|
|
192
193
|
try {
|
|
193
|
-
|
|
194
|
+
api.validateNpmIgnorePatterns(gitIgnoreContent);
|
|
194
195
|
logger.debug('validated the expected git ignore patterns');
|
|
195
196
|
}
|
|
196
197
|
catch (e) {
|
|
197
198
|
cliUx.warn(`WARNING: The following patterns are recommended in ${filename} for code signing: *.tgz, *.sig, package.json.bak.`);
|
|
198
199
|
}
|
|
199
200
|
// get the packageJson name/version
|
|
200
|
-
const npmName =
|
|
201
|
+
const npmName = parseNpmName(packageJson.name);
|
|
201
202
|
logger.debug(`parsed the following npmName components: ${JSON.stringify(npmName, null, 4)}`);
|
|
202
203
|
npmName.tag = packageJson.version;
|
|
203
204
|
// make a backup of the packageJson
|
|
204
|
-
await
|
|
205
|
+
await api.copyPackageDotJson(pathGetter.packageJson, pathGetter.packageJsonBak);
|
|
205
206
|
logger.debug('made a backup of the package.json file.');
|
|
206
207
|
cliUx.log(`Backed up ${pathGetter.packageJson} to ${pathGetter.packageJsonBak}`);
|
|
207
208
|
const packageNameWithOrWithoutScope = npmName.scope ? `@${npmName.scope}/${npmName.name}` : npmName.name;
|
|
208
209
|
// we have to modify package.json with security URLs BEFORE packing
|
|
209
210
|
// update the package.json object with the signature urls and write it to disk.
|
|
210
|
-
packageJson.sfdx =
|
|
211
|
-
await
|
|
211
|
+
packageJson.sfdx = getSfdxProperty(packageNameWithOrWithoutScope, npmName.tag);
|
|
212
|
+
await api.writePackageJson(packageJson);
|
|
212
213
|
cliUx.log('Successfully updated package.json with public key and signature file locations.');
|
|
213
214
|
cliUx.styledJSON(packageJson.sfdx);
|
|
214
|
-
const filepath = await
|
|
215
|
+
const filepath = await api.pack();
|
|
215
216
|
cliUx.log(`Packed tgz to ${filepath}`);
|
|
216
|
-
const signResponse = await (
|
|
217
|
+
const signResponse = await sign2({
|
|
217
218
|
upload: true,
|
|
218
219
|
targetFileToSign: filepath,
|
|
219
220
|
packageName: packageNameWithOrWithoutScope,
|
|
@@ -223,13 +224,13 @@ exports.api = {
|
|
|
223
224
|
}
|
|
224
225
|
finally {
|
|
225
226
|
// prevent any publish-time changes from persisting to git
|
|
226
|
-
await
|
|
227
|
+
await api.revertPackageJsonIfExists();
|
|
227
228
|
}
|
|
228
229
|
},
|
|
229
230
|
// preserve previous behavior when the param was used.
|
|
230
231
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
231
232
|
getAgentForUri(url) {
|
|
232
|
-
const agent = new
|
|
233
|
+
const agent = new ProxyAgent();
|
|
233
234
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
234
235
|
return { https: agent, http: agent };
|
|
235
236
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packAndSign.js","sourceRoot":"","sources":["../../src/codeSigning/packAndSign.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"packAndSign.js","sourceRoot":"","sources":["../../src/codeSigning/packAndSign.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,yCAAyC;AAEzC,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,WAAW,CAAC;AAG7C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,gBAAgB,IAAI,KAAK,EAAmB,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,UAAU;IACN,MAAM,CAAC,WAAW,GAAG,cAAc,CAAC;IAEpC,YAAY,CAAS;IACrB,eAAe,CAAS;IACxB,OAAO,CAAS;IAChB,IA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,mEAAmE;YACnE,+EAA+E;YAC/E,WAAW,CAAC,IAAI,GAAG,eAAe,CAAC,6BAA6B,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;YAC/E,MAAM,GAAG,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;YACxC,KAAK,CAAC,GAAG,CAAC,iFAAiF,CAAC,CAAC;YAC7F,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YAEnC,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;YAClC,KAAK,CAAC,GAAG,CAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAC;YAEvC,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC;gBAC/B,MAAM,EAAE,IAAI;gBACZ,gBAAgB,EAAE,QAAQ;gBAC1B,WAAW,EAAE,6BAA6B;gBAC1C,cAAc,EAAE,OAAO,CAAC,GAAG;aAC5B,CAAC,CAAC;YAEH,OAAO,YAAY,CAAC;QACtB,CAAC;gBAAS,CAAC;YACT,0DAA0D;YAC1D,MAAM,GAAG,CAAC,yBAAyB,EAAE,CAAC;QACxC,CAAC;IACH,CAAC;IAED,sDAAsD;IACtD,6DAA6D;IAC7D,cAAc,CAAC,GAAW;QACxB,MAAM,KAAK,GAAG,IAAI,UAAU,EAAE,CAAC;QAC/B,sDAAsD;QACtD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACvC,CAAC;CACF,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import AWS from 'aws-sdk';
|
|
2
2
|
export declare function putObject(bucket: string, key: string, body: string): Promise<AWS.S3.PutObjectOutput>;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
3
|
* All rights reserved.
|
|
5
4
|
* Licensed under the BSD 3-Clause license.
|
|
6
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const packAndSign_1 = require("./packAndSign");
|
|
12
|
-
async function putObject(bucket, key, body) {
|
|
7
|
+
import AWS from 'aws-sdk';
|
|
8
|
+
import { api } from './packAndSign.js';
|
|
9
|
+
export async function putObject(bucket, key, body) {
|
|
13
10
|
return new Promise((resolve, reject) => {
|
|
14
|
-
const agent =
|
|
11
|
+
const agent = api.getAgentForUri('https://s3.amazonaws.com');
|
|
15
12
|
const s3 = new AWS.S3({
|
|
16
13
|
httpOptions: { agent: agent.http },
|
|
17
14
|
httpsOptions: { agent: agent.https },
|
|
@@ -24,5 +21,4 @@ async function putObject(bucket, key, body) {
|
|
|
24
21
|
});
|
|
25
22
|
});
|
|
26
23
|
}
|
|
27
|
-
exports.putObject = putObject;
|
|
28
24
|
//# sourceMappingURL=upload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../../src/codeSigning/upload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../../src/codeSigning/upload.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,GAAG,MAAM,SAAS,CAAC;AAG1B,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAGvC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAc,EAAE,GAAW,EAAE,IAAY;IACvE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,GAAG,CAAC,cAAc,CAAC,0BAA0B,CAAW,CAAC;QACvE,MAAM,EAAE,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC;YACpB,WAAW,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE;YAClC,YAAY,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE;SACd,CAAC,CAAC;QAC1B,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACnE,IAAI,GAAG;gBAAE,MAAM,CAAC,GAAG,CAAC,CAAC;YACrB,IAAI,IAAI;gBAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { Interfaces } from '@oclif/core';
|
|
2
|
-
import { AnyJson } from '@salesforce/ts-types';
|
|
3
2
|
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
4
|
-
import { CLI } from '../../types';
|
|
5
|
-
export
|
|
3
|
+
import { CLI } from '../../types.js';
|
|
4
|
+
export type PromoteResult = {
|
|
5
|
+
dryRun: boolean;
|
|
6
|
+
cli: CLI;
|
|
7
|
+
target: string;
|
|
8
|
+
sha: string;
|
|
9
|
+
version: string;
|
|
10
|
+
platforms: string[];
|
|
11
|
+
};
|
|
12
|
+
export default class Promote extends SfCommand<PromoteResult> {
|
|
6
13
|
static readonly description: string;
|
|
7
14
|
static readonly summary: string;
|
|
8
15
|
static readonly examples: string[];
|
|
@@ -20,7 +27,7 @@ export default class Promote extends SfCommand<AnyJson> {
|
|
|
20
27
|
version: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
21
28
|
};
|
|
22
29
|
private flags;
|
|
23
|
-
run(): Promise<
|
|
30
|
+
run(): Promise<PromoteResult>;
|
|
24
31
|
/**
|
|
25
32
|
* validate flag combinations
|
|
26
33
|
*
|
|
@@ -1,31 +1,110 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
3
|
* All rights reserved.
|
|
5
4
|
* Licensed under the BSD 3-Clause license.
|
|
6
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const messages = core_1.Messages.loadMessages('@salesforce/plugin-release-management', 'channel.promote');
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import { valid as validSemVer } from 'semver';
|
|
9
|
+
import shelljs from 'shelljs';
|
|
10
|
+
import { Logger, Messages, SfError } from '@salesforce/core';
|
|
11
|
+
import { ensureString, isString } from '@salesforce/ts-types';
|
|
12
|
+
import { SfCommand, Flags, arrayWithDeprecation } from '@salesforce/sf-plugins-core';
|
|
13
|
+
import { AmazonS3 } from '../../amazonS3.js';
|
|
14
|
+
import { verifyDependencies } from '../../dependencies.js';
|
|
15
|
+
import { CLI, Channel } from '../../types.js';
|
|
16
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
17
|
+
const messages = Messages.loadMessages('@salesforce/plugin-release-management', 'channel.promote');
|
|
20
18
|
const TARGETS = ['linux-x64', 'linux-arm', 'win32-x64', 'win32-x86', 'darwin-x64'];
|
|
21
|
-
class Promote extends
|
|
19
|
+
export default class Promote extends SfCommand {
|
|
20
|
+
static description = messages.getMessage('description');
|
|
21
|
+
static summary = messages.getMessage('summary');
|
|
22
|
+
static examples = messages.getMessages('examples');
|
|
23
|
+
static flags = {
|
|
24
|
+
dryrun: Flags.boolean({
|
|
25
|
+
char: 'd',
|
|
26
|
+
default: false,
|
|
27
|
+
summary: messages.getMessage('flags.dryrun.summary'),
|
|
28
|
+
}),
|
|
29
|
+
'promote-to-channel': Flags.string({
|
|
30
|
+
char: 't',
|
|
31
|
+
default: Channel.STABLE,
|
|
32
|
+
summary: messages.getMessage('flags.promote-to-channel.summary'),
|
|
33
|
+
// options: Object.values(Channel),
|
|
34
|
+
required: true,
|
|
35
|
+
aliases: ['target'],
|
|
36
|
+
}),
|
|
37
|
+
'promote-from-channel': Flags.string({
|
|
38
|
+
char: 'C',
|
|
39
|
+
summary: messages.getMessage('flags.promote-from-channel.summary'),
|
|
40
|
+
// options: Object.values(Channel),
|
|
41
|
+
exactlyOne: ['sha', 'version', 'promote-from-channel'],
|
|
42
|
+
aliases: ['candidate'],
|
|
43
|
+
}),
|
|
44
|
+
platform: arrayWithDeprecation({
|
|
45
|
+
char: 'p',
|
|
46
|
+
summary: messages.getMessage('flags.platform.summary'),
|
|
47
|
+
options: ['win', 'macos', 'deb'],
|
|
48
|
+
}),
|
|
49
|
+
cli: Flags.custom({
|
|
50
|
+
options: Object.values(CLI),
|
|
51
|
+
})({
|
|
52
|
+
char: 'c',
|
|
53
|
+
summary: messages.getMessage('flags.cli.summary'),
|
|
54
|
+
required: true,
|
|
55
|
+
}),
|
|
56
|
+
sha: Flags.string({
|
|
57
|
+
char: 's',
|
|
58
|
+
summary: messages.getMessage('flags.sha.summary'),
|
|
59
|
+
exactlyOne: ['sha', 'version', 'promote-from-channel'],
|
|
60
|
+
parse: (input) => Promise.resolve(input.slice(0, 7)),
|
|
61
|
+
validate: (input) => {
|
|
62
|
+
if (input.length < 7) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
'max-age': Flags.integer({
|
|
69
|
+
char: 'm',
|
|
70
|
+
summary: messages.getMessage('flags.max-age.summary'),
|
|
71
|
+
default: 300,
|
|
72
|
+
aliases: ['maxage'],
|
|
73
|
+
}),
|
|
74
|
+
indexes: Flags.boolean({
|
|
75
|
+
char: 'i',
|
|
76
|
+
summary: messages.getMessage('flags.indexes.summary'),
|
|
77
|
+
default: true,
|
|
78
|
+
allowNo: true,
|
|
79
|
+
}),
|
|
80
|
+
xz: Flags.boolean({
|
|
81
|
+
char: 'x',
|
|
82
|
+
summary: messages.getMessage('flags.xz.summary'),
|
|
83
|
+
default: true,
|
|
84
|
+
allowNo: true,
|
|
85
|
+
}),
|
|
86
|
+
'architecture-target': arrayWithDeprecation({
|
|
87
|
+
char: 'T',
|
|
88
|
+
summary: messages.getMessage('targets'),
|
|
89
|
+
options: TARGETS,
|
|
90
|
+
aliases: ['targets'],
|
|
91
|
+
}),
|
|
92
|
+
version: Flags.string({
|
|
93
|
+
char: 'v',
|
|
94
|
+
summary: messages.getMessage('flags.version.summary'),
|
|
95
|
+
exactlyOne: ['sha', 'version', 'promote-from-channel'],
|
|
96
|
+
parse: (input) => Promise.resolve(input.trim()),
|
|
97
|
+
validate: (input) => validSemVer(input) !== null,
|
|
98
|
+
}),
|
|
99
|
+
};
|
|
100
|
+
flags;
|
|
22
101
|
async run() {
|
|
23
102
|
const { flags } = await this.parse(Promote);
|
|
24
103
|
this.flags = flags;
|
|
25
104
|
this.validateFlags();
|
|
26
105
|
// preparing parameters for call to oclif promote commands
|
|
27
106
|
const cli = this.flags.cli;
|
|
28
|
-
const target =
|
|
107
|
+
const target = ensureString(this.flags['promote-to-channel']);
|
|
29
108
|
const indexes = this.flags.indexes ? '--indexes' : '';
|
|
30
109
|
const xz = this.flags.xz ? '--xz' : '--no-xz';
|
|
31
110
|
const { sha, version } = await determineShaAndVersion(cli, this.flags['promote-from-channel'], this.flags.version, this.flags.sha);
|
|
@@ -45,11 +124,11 @@ class Promote extends sf_plugins_core_1.SfCommand {
|
|
|
45
124
|
indexes,
|
|
46
125
|
xz,
|
|
47
126
|
];
|
|
48
|
-
const results =
|
|
127
|
+
const results = shelljs.exec(`yarn oclif promote ${params.join(' ')}`);
|
|
49
128
|
this.log(results.stdout);
|
|
50
129
|
}
|
|
51
130
|
else if (!this.flags.json) {
|
|
52
|
-
this.log(messages.getMessage('DryRunMessage', [cli, version, sha, target, this.flags.platform?.join(', ') ?? 'all'].map((s) =>
|
|
131
|
+
this.log(messages.getMessage('DryRunMessage', [cli, version, sha, target, this.flags.platform?.join(', ') ?? 'all'].map((s) => chalk.bold(s))));
|
|
53
132
|
}
|
|
54
133
|
return {
|
|
55
134
|
dryRun: !!this.flags.dryrun,
|
|
@@ -68,101 +147,20 @@ class Promote extends sf_plugins_core_1.SfCommand {
|
|
|
68
147
|
validateFlags() {
|
|
69
148
|
// cannot promote when channel names are the same
|
|
70
149
|
if (this.flags['promote-from-channel'] && this.flags['promote-from-channel'] === this.flags['promote-to-channel']) {
|
|
71
|
-
throw new
|
|
150
|
+
throw new SfError(messages.getMessage('CannotPromoteToSameChannel'));
|
|
72
151
|
}
|
|
73
152
|
// make sure necessary runtime dependencies are present
|
|
74
|
-
const deps =
|
|
153
|
+
const deps = verifyDependencies(this.flags, (dep) => dep.name.startsWith('AWS'), (args) => !args.dryrun);
|
|
75
154
|
if (deps.failures > 0) {
|
|
76
155
|
const errType = 'MissingDependencies';
|
|
77
156
|
const missing = deps.results
|
|
78
157
|
.filter((d) => d.passed === false)
|
|
79
158
|
.map((d) => d.message)
|
|
80
|
-
.filter(
|
|
81
|
-
throw new
|
|
159
|
+
.filter(isString);
|
|
160
|
+
throw new SfError(messages.getMessage(errType), errType, missing);
|
|
82
161
|
}
|
|
83
162
|
}
|
|
84
163
|
}
|
|
85
|
-
Promote.description = messages.getMessage('description');
|
|
86
|
-
Promote.summary = messages.getMessage('summary');
|
|
87
|
-
Promote.examples = messages.getMessages('examples');
|
|
88
|
-
Promote.flags = {
|
|
89
|
-
dryrun: sf_plugins_core_1.Flags.boolean({
|
|
90
|
-
char: 'd',
|
|
91
|
-
default: false,
|
|
92
|
-
summary: messages.getMessage('flags.dryrun.summary'),
|
|
93
|
-
}),
|
|
94
|
-
'promote-to-channel': sf_plugins_core_1.Flags.string({
|
|
95
|
-
char: 't',
|
|
96
|
-
default: types_1.Channel.STABLE,
|
|
97
|
-
summary: messages.getMessage('flags.promote-to-channel.summary'),
|
|
98
|
-
// options: Object.values(Channel),
|
|
99
|
-
required: true,
|
|
100
|
-
aliases: ['target'],
|
|
101
|
-
}),
|
|
102
|
-
'promote-from-channel': sf_plugins_core_1.Flags.string({
|
|
103
|
-
char: 'C',
|
|
104
|
-
summary: messages.getMessage('flags.promote-from-channel.summary'),
|
|
105
|
-
// options: Object.values(Channel),
|
|
106
|
-
exactlyOne: ['sha', 'version', 'promote-from-channel'],
|
|
107
|
-
aliases: ['candidate'],
|
|
108
|
-
}),
|
|
109
|
-
platform: (0, sf_plugins_core_1.arrayWithDeprecation)({
|
|
110
|
-
char: 'p',
|
|
111
|
-
summary: messages.getMessage('flags.platform.summary'),
|
|
112
|
-
options: ['win', 'macos', 'deb'],
|
|
113
|
-
}),
|
|
114
|
-
cli: sf_plugins_core_1.Flags.custom({
|
|
115
|
-
options: Object.values(types_1.CLI),
|
|
116
|
-
})({
|
|
117
|
-
char: 'c',
|
|
118
|
-
summary: messages.getMessage('flags.cli.summary'),
|
|
119
|
-
required: true,
|
|
120
|
-
}),
|
|
121
|
-
sha: sf_plugins_core_1.Flags.string({
|
|
122
|
-
char: 's',
|
|
123
|
-
summary: messages.getMessage('flags.sha.summary'),
|
|
124
|
-
exactlyOne: ['sha', 'version', 'promote-from-channel'],
|
|
125
|
-
parse: (input) => Promise.resolve(input.slice(0, 7)),
|
|
126
|
-
validate: (input) => {
|
|
127
|
-
if (input.length < 7) {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
return true;
|
|
131
|
-
},
|
|
132
|
-
}),
|
|
133
|
-
'max-age': sf_plugins_core_1.Flags.integer({
|
|
134
|
-
char: 'm',
|
|
135
|
-
summary: messages.getMessage('flags.max-age.summary'),
|
|
136
|
-
default: 300,
|
|
137
|
-
aliases: ['maxage'],
|
|
138
|
-
}),
|
|
139
|
-
indexes: sf_plugins_core_1.Flags.boolean({
|
|
140
|
-
char: 'i',
|
|
141
|
-
summary: messages.getMessage('flags.indexes.summary'),
|
|
142
|
-
default: true,
|
|
143
|
-
allowNo: true,
|
|
144
|
-
}),
|
|
145
|
-
xz: sf_plugins_core_1.Flags.boolean({
|
|
146
|
-
char: 'x',
|
|
147
|
-
summary: messages.getMessage('flags.xz.summary'),
|
|
148
|
-
default: true,
|
|
149
|
-
allowNo: true,
|
|
150
|
-
}),
|
|
151
|
-
'architecture-target': (0, sf_plugins_core_1.arrayWithDeprecation)({
|
|
152
|
-
char: 'T',
|
|
153
|
-
summary: messages.getMessage('targets'),
|
|
154
|
-
options: TARGETS,
|
|
155
|
-
aliases: ['targets'],
|
|
156
|
-
}),
|
|
157
|
-
version: sf_plugins_core_1.Flags.string({
|
|
158
|
-
char: 'v',
|
|
159
|
-
summary: messages.getMessage('flags.version.summary'),
|
|
160
|
-
exactlyOne: ['sha', 'version', 'promote-from-channel'],
|
|
161
|
-
parse: (input) => Promise.resolve(input.trim()),
|
|
162
|
-
validate: (input) => (0, semver_1.valid)(input) !== null,
|
|
163
|
-
}),
|
|
164
|
-
};
|
|
165
|
-
exports.default = Promote;
|
|
166
164
|
/**
|
|
167
165
|
* find a manifest file in the channel
|
|
168
166
|
*
|
|
@@ -171,7 +169,7 @@ exports.default = Promote;
|
|
|
171
169
|
* @private
|
|
172
170
|
*/
|
|
173
171
|
const findManifestForCandidate = async (cli, channel) => {
|
|
174
|
-
const amazonS3 = new
|
|
172
|
+
const amazonS3 = new AmazonS3({ cli, channel });
|
|
175
173
|
return amazonS3.getManifestFromChannel(channel);
|
|
176
174
|
};
|
|
177
175
|
/**
|
|
@@ -182,7 +180,7 @@ const findManifestForCandidate = async (cli, channel) => {
|
|
|
182
180
|
* @private
|
|
183
181
|
*/
|
|
184
182
|
const findVersionForSha = async (cli, sha) => {
|
|
185
|
-
const amazonS3 = new
|
|
183
|
+
const amazonS3 = new AmazonS3({ cli });
|
|
186
184
|
const foundVersionPrefix = (await Promise.all((await amazonS3.listCommonPrefixes('versions')).map(async (versionPrefix) => amazonS3.listCommonPrefixes(versionPrefix))))
|
|
187
185
|
.flat()
|
|
188
186
|
.find((s) => s.replace(/\/$/, '').endsWith(sha));
|
|
@@ -191,8 +189,8 @@ const findVersionForSha = async (cli, sha) => {
|
|
|
191
189
|
// when reversed after split version number should occupy entry 1 of the array
|
|
192
190
|
return foundVersionPrefix?.replace(/\/$/, '').split('/').reverse()[1];
|
|
193
191
|
}
|
|
194
|
-
const error = new
|
|
195
|
-
const logger =
|
|
192
|
+
const error = new SfError(messages.getMessage('CouldNotLocateVersionForSha', [sha]));
|
|
193
|
+
const logger = Logger.childFromRoot('Promote.findVersionForSha');
|
|
196
194
|
logger.debug(error);
|
|
197
195
|
throw error;
|
|
198
196
|
};
|
|
@@ -212,15 +210,15 @@ const determineShaAndVersion = async (cli, candidate, version, sha) => {
|
|
|
212
210
|
return { sha: manifest.sha, version: manifest.version };
|
|
213
211
|
}
|
|
214
212
|
else if (version) {
|
|
215
|
-
const shaFromVersion = await findShaForVersion(cli,
|
|
216
|
-
return { sha: shaFromVersion, version:
|
|
213
|
+
const shaFromVersion = await findShaForVersion(cli, ensureString(version));
|
|
214
|
+
return { sha: shaFromVersion, version: ensureString(version) };
|
|
217
215
|
}
|
|
218
216
|
else if (sha) {
|
|
219
|
-
|
|
217
|
+
ensureString(sha);
|
|
220
218
|
const versionFromSha = await findVersionForSha(cli, sha);
|
|
221
219
|
return { sha, version: versionFromSha };
|
|
222
220
|
}
|
|
223
|
-
throw new
|
|
221
|
+
throw new SfError(messages.getMessage('CouldNotDetermineShaAndVersion'));
|
|
224
222
|
};
|
|
225
223
|
/**
|
|
226
224
|
* find the sha that was uploaded most recently for the named version
|
|
@@ -230,8 +228,8 @@ const determineShaAndVersion = async (cli, candidate, version, sha) => {
|
|
|
230
228
|
* @private
|
|
231
229
|
*/
|
|
232
230
|
const findShaForVersion = async (cli, version) => {
|
|
233
|
-
const logger =
|
|
234
|
-
const amazonS3 = new
|
|
231
|
+
const logger = Logger.childFromRoot('Promote.findShaForVersion');
|
|
232
|
+
const amazonS3 = new AmazonS3({ cli });
|
|
235
233
|
const versions = await amazonS3.listCommonPrefixes('versions');
|
|
236
234
|
const foundVersion = versions.find((v) => v.endsWith(`${version}/`));
|
|
237
235
|
if (foundVersion) {
|
|
@@ -240,7 +238,7 @@ const findShaForVersion = async (cli, version) => {
|
|
|
240
238
|
logger.debug(`Looking for version ${version} for cli ${cli} shas. Found ${versionShas.length} entries`);
|
|
241
239
|
const manifestForMostRecentSha = (await Promise.all(versionShas.map(async (versionSha) => {
|
|
242
240
|
if (!versionSha) {
|
|
243
|
-
throw new
|
|
241
|
+
throw new SfError(`Could not find prefix for ${versionSha}`);
|
|
244
242
|
}
|
|
245
243
|
const versionShaContents = (await amazonS3.listKeyContents(versionSha));
|
|
246
244
|
return versionShaContents.map((content) => ({
|
|
@@ -257,14 +255,14 @@ const findShaForVersion = async (cli, version) => {
|
|
|
257
255
|
ResponseContentType: 'application/json',
|
|
258
256
|
});
|
|
259
257
|
if (!manifest.Body) {
|
|
260
|
-
throw new
|
|
258
|
+
throw new SfError(`Could not load manifest body from S3 getObject response for ${manifestForMostRecentSha.Key}`);
|
|
261
259
|
}
|
|
262
260
|
logger.debug(`Loaded manifest ${manifestForMostRecentSha.Key} contents: ${String(manifest)}`);
|
|
263
261
|
const json = JSON.parse(String(manifest.Body));
|
|
264
262
|
return json.sha;
|
|
265
263
|
}
|
|
266
264
|
}
|
|
267
|
-
const error = new
|
|
265
|
+
const error = new SfError(messages.getMessage('CouldNotLocateShaForVersion', [version]));
|
|
268
266
|
logger.debug(error);
|
|
269
267
|
throw error;
|
|
270
268
|
};
|