oclif 4.1.4 → 4.1.5-dev.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/bin/dev.js +1 -1
- package/bin/run.js +1 -1
- package/lib/aws.d.ts +9 -9
- package/lib/aws.js +38 -60
- package/lib/commands/promote.js +3 -2
- package/lib/tarballs/bin.d.ts +2 -1
- package/lib/tarballs/bin.js +7 -6
- package/lib/tarballs/build.js +1 -1
- package/lib/tarballs/config.d.ts +15 -5
- package/lib/tarballs/config.js +8 -2
- package/lib/version-indexes.js +2 -1
- package/oclif.manifest.json +1 -1
- package/package.json +3 -2
package/bin/dev.js
CHANGED
package/bin/run.js
CHANGED
package/lib/aws.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { CreateInvalidationCommandOutput, CreateInvalidationRequest } from '@aws-sdk/client-cloudfront';
|
|
2
|
+
import { CopyObjectOutput, CopyObjectRequest, DeleteObjectsOutput, DeleteObjectsRequest, GetObjectOutput, GetObjectRequest, HeadObjectOutput, HeadObjectRequest, ListObjectsV2Output, ListObjectsV2Request, PutObjectOutput, PutObjectRequest } from '@aws-sdk/client-s3';
|
|
3
3
|
declare const _default: {
|
|
4
4
|
readonly cloudfront: {
|
|
5
|
-
createCloudfrontInvalidation: (options:
|
|
5
|
+
createCloudfrontInvalidation: (options: CreateInvalidationRequest) => Promise<CreateInvalidationCommandOutput>;
|
|
6
6
|
};
|
|
7
7
|
readonly s3: {
|
|
8
|
-
copyObject: (options:
|
|
9
|
-
deleteObjects: (options:
|
|
10
|
-
getObject: (options:
|
|
11
|
-
headObject: (options:
|
|
12
|
-
listObjects: (options:
|
|
13
|
-
uploadFile: (local: string, options:
|
|
8
|
+
copyObject: (options: CopyObjectRequest) => Promise<CopyObjectOutput>;
|
|
9
|
+
deleteObjects: (options: DeleteObjectsRequest) => Promise<DeleteObjectsOutput>;
|
|
10
|
+
getObject: (options: GetObjectRequest) => Promise<GetObjectOutput>;
|
|
11
|
+
headObject: (options: HeadObjectRequest) => Promise<HeadObjectOutput>;
|
|
12
|
+
listObjects: (options: ListObjectsV2Request) => Promise<ListObjectsV2Output>;
|
|
13
|
+
uploadFile: (local: string, options: PutObjectRequest) => Promise<PutObjectOutput>;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
export default _default;
|
package/lib/aws.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const client_cloudfront_1 = require("@aws-sdk/client-cloudfront");
|
|
4
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
3
5
|
const fs_extra_1 = require("fs-extra");
|
|
4
6
|
const log_1 = require("./log");
|
|
5
7
|
const util_1 = require("./util");
|
|
@@ -7,7 +9,8 @@ const debug = log_1.debug.new('aws');
|
|
|
7
9
|
const cache = {};
|
|
8
10
|
const aws = {
|
|
9
11
|
get cloudfront() {
|
|
10
|
-
cache.cloudfront =
|
|
12
|
+
cache.cloudfront =
|
|
13
|
+
cache.cloudfront || new (require('@aws-sdk/client-cloudfront').CloudFrontClient)({ credentials: this.creds });
|
|
11
14
|
return cache.cloudfront;
|
|
12
15
|
},
|
|
13
16
|
get creds() {
|
|
@@ -26,17 +29,18 @@ const aws = {
|
|
|
26
29
|
try {
|
|
27
30
|
cache.s3 =
|
|
28
31
|
cache.s3 ??
|
|
29
|
-
new (require('aws-sdk/
|
|
30
|
-
|
|
32
|
+
new (require('@aws-sdk/client-s3').S3Client)({
|
|
33
|
+
credentials: this.creds,
|
|
31
34
|
endpoint: process.env.AWS_S3_ENDPOINT,
|
|
32
|
-
|
|
35
|
+
forcePathStyle: Boolean(process.env.AWS_S3_FORCE_PATH_STYLE),
|
|
36
|
+
region: process.env.AWS_REGION ?? 'us-east-1',
|
|
33
37
|
});
|
|
34
38
|
return cache.s3;
|
|
35
39
|
}
|
|
36
40
|
catch (error) {
|
|
37
41
|
const { code, message } = error;
|
|
38
42
|
if (code === 'MODULE_NOT_FOUND')
|
|
39
|
-
throw new Error(`${message}\
|
|
43
|
+
throw new Error(`${message}\n@aws-sdk/client-s3 is needed to run this command.\nInstall @aws-sdk/client-s3 as a devDependency in your CLI. \`yarn add -D @aws-sdk/client-s3\``);
|
|
40
44
|
throw error;
|
|
41
45
|
}
|
|
42
46
|
},
|
|
@@ -45,13 +49,11 @@ exports.default = {
|
|
|
45
49
|
get cloudfront() {
|
|
46
50
|
return {
|
|
47
51
|
createCloudfrontInvalidation: (options) => new Promise((resolve, reject) => {
|
|
48
|
-
(0, log_1.log)('createCloudfrontInvalidation', options.DistributionId, options.InvalidationBatch
|
|
49
|
-
aws.cloudfront
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
resolve(null);
|
|
54
|
-
});
|
|
52
|
+
(0, log_1.log)('createCloudfrontInvalidation', options.DistributionId, options.InvalidationBatch?.Paths?.Items);
|
|
53
|
+
aws.cloudfront
|
|
54
|
+
?.send(new client_cloudfront_1.CreateInvalidationCommand(options))
|
|
55
|
+
.then((data) => resolve(data))
|
|
56
|
+
.catch((error) => reject(error));
|
|
55
57
|
}),
|
|
56
58
|
};
|
|
57
59
|
},
|
|
@@ -59,71 +61,47 @@ exports.default = {
|
|
|
59
61
|
return {
|
|
60
62
|
copyObject: (options) => new Promise((resolve, reject) => {
|
|
61
63
|
(0, log_1.log)('s3:copyObject', `from s3://${options.CopySource}`, `to s3://${options.Bucket}/${options.Key}`);
|
|
62
|
-
aws.s3
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
resolve(data);
|
|
67
|
-
});
|
|
64
|
+
aws.s3
|
|
65
|
+
?.send(new client_s3_1.CopyObjectCommand(options))
|
|
66
|
+
.then((data) => resolve(data))
|
|
67
|
+
.catch((error) => reject(error));
|
|
68
68
|
}),
|
|
69
69
|
deleteObjects: (options) => new Promise((resolve, reject) => {
|
|
70
70
|
debug('deleteObjects', `s3://${options.Bucket}`);
|
|
71
|
-
aws.s3
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
71
|
+
aws.s3
|
|
72
|
+
?.send(new client_s3_1.DeleteObjectsCommand(options))
|
|
73
|
+
.then((data) => resolve(data))
|
|
74
|
+
.catch((error) => reject(error));
|
|
76
75
|
}),
|
|
77
76
|
getObject: (options) => new Promise((resolve, reject) => {
|
|
78
77
|
debug('getObject', `s3://${options.Bucket}/${options.Key}`);
|
|
79
|
-
aws.s3
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
resolve(data);
|
|
84
|
-
});
|
|
78
|
+
aws.s3
|
|
79
|
+
?.send(new client_s3_1.GetObjectCommand(options))
|
|
80
|
+
.then((data) => resolve(data))
|
|
81
|
+
.catch((error) => reject(error));
|
|
85
82
|
}),
|
|
86
83
|
headObject: (options) => new Promise((resolve, reject) => {
|
|
87
84
|
debug('s3:headObject', `s3://${options.Bucket}/${options.Key}`);
|
|
88
|
-
aws.s3
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
resolve(data);
|
|
93
|
-
});
|
|
85
|
+
aws.s3
|
|
86
|
+
?.send(new client_s3_1.HeadObjectCommand(options))
|
|
87
|
+
.then((data) => resolve(data))
|
|
88
|
+
.catch((error) => reject(error));
|
|
94
89
|
}),
|
|
95
90
|
listObjects: (options) => new Promise((resolve, reject) => {
|
|
96
91
|
debug('listObjects', `s3://${options.Bucket}/${options.Prefix}`);
|
|
97
|
-
aws.s3
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
92
|
+
aws.s3
|
|
93
|
+
?.send(new client_s3_1.ListObjectsV2Command(options))
|
|
94
|
+
.then((data) => resolve(data))
|
|
95
|
+
.catch((error) => reject(error));
|
|
102
96
|
}),
|
|
103
97
|
uploadFile: (local, options) => new Promise((resolve, reject) => {
|
|
104
98
|
(0, log_1.log)('s3:uploadFile', (0, util_1.prettifyPaths)(local), `s3://${options.Bucket}/${options.Key}`);
|
|
105
99
|
options.Body = (0, fs_extra_1.createReadStream)(local);
|
|
106
|
-
aws.s3
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
resolve(null);
|
|
111
|
-
});
|
|
100
|
+
aws.s3
|
|
101
|
+
?.send(new client_s3_1.PutObjectCommand(options))
|
|
102
|
+
.then((data) => resolve(data))
|
|
103
|
+
.catch((error) => reject(error));
|
|
112
104
|
}),
|
|
113
105
|
};
|
|
114
106
|
},
|
|
115
107
|
};
|
|
116
|
-
// export const getObject = (options: S3.Types.GetObjectRequest) => new Promise<S3.GetObjectOutput>((resolve, reject) => {
|
|
117
|
-
// debug('getObject', `s3://${options.Bucket}/${options.Key}`)
|
|
118
|
-
// aws.s3().getObject(options, (err, data) => {
|
|
119
|
-
// if (err) reject(err)
|
|
120
|
-
// else resolve(data)
|
|
121
|
-
// })
|
|
122
|
-
// })
|
|
123
|
-
// export const listObjects = (options: S3.Types.ListObjectsV2Request) => new Promise<S3.ListObjectsV2Output>((resolve, reject) => {
|
|
124
|
-
// debug('listObjects', `s3://${options.Bucket}/${options.Prefix}`)
|
|
125
|
-
// s3().listObjectsV2(options, (err, objects) => {
|
|
126
|
-
// if (err) reject(err)
|
|
127
|
-
// else resolve(objects)
|
|
128
|
-
// })
|
|
129
|
-
// })
|
package/lib/commands/promote.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
3
4
|
const core_1 = require("@oclif/core");
|
|
4
5
|
const path = require("node:path");
|
|
5
6
|
const aws_1 = require("../aws");
|
|
@@ -34,10 +35,10 @@ class Promote extends core_1.Command {
|
|
|
34
35
|
if (!s3Config.bucket)
|
|
35
36
|
this.error('Cannot determine S3 bucket for promotion');
|
|
36
37
|
const awsDefaults = {
|
|
37
|
-
ACL: s3Config.acl ??
|
|
38
|
+
ACL: s3Config.acl ?? client_s3_1.ObjectCannedACL.public_read,
|
|
38
39
|
Bucket: s3Config.bucket,
|
|
39
40
|
CacheControl: indexDefaults.maxAge,
|
|
40
|
-
MetadataDirective:
|
|
41
|
+
MetadataDirective: client_s3_1.MetadataDirective.REPLACE,
|
|
41
42
|
};
|
|
42
43
|
const cloudBucketCommitKey = (shortKey) => path.join(s3Config.bucket, (0, upload_util_1.commitAWSDir)(flags.version, flags.sha, s3Config), shortKey);
|
|
43
44
|
const cloudChannelKey = (shortKey) => path.join((0, upload_util_1.channelAWSDir)(flags.channel, s3Config), shortKey);
|
package/lib/tarballs/bin.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Interfaces } from '@oclif/core';
|
|
2
|
-
export declare function writeBinScripts({ baseWorkspace, config, nodeVersion, }: {
|
|
2
|
+
export declare function writeBinScripts({ baseWorkspace, config, nodeOptions, nodeVersion, }: {
|
|
3
3
|
baseWorkspace: string;
|
|
4
4
|
config: Interfaces.Config;
|
|
5
|
+
nodeOptions: string[];
|
|
5
6
|
nodeVersion: string;
|
|
6
7
|
}): Promise<void>;
|
package/lib/tarballs/bin.js
CHANGED
|
@@ -6,7 +6,7 @@ const fs = require("node:fs");
|
|
|
6
6
|
const path = require("node:path");
|
|
7
7
|
const node_util_1 = require("node:util");
|
|
8
8
|
const exec = (0, node_util_1.promisify)(node_child_process_1.exec);
|
|
9
|
-
async function writeBinScripts({ baseWorkspace, config, nodeVersion, }) {
|
|
9
|
+
async function writeBinScripts({ baseWorkspace, config, nodeOptions, nodeVersion, }) {
|
|
10
10
|
const binPathEnvVar = config.scopedEnvVarKey('BINPATH');
|
|
11
11
|
const redirectedEnvVar = config.scopedEnvVarKey('REDIRECTED');
|
|
12
12
|
const clientHomeEnvVar = config.scopedEnvVarKey('OCLIF_CLIENT_HOME');
|
|
@@ -21,12 +21,13 @@ if not "%${redirectedEnvVar}%"=="1" if exist "%LOCALAPPDATA%\\${bin}\\client\\bi
|
|
|
21
21
|
)
|
|
22
22
|
|
|
23
23
|
if not defined ${binPathEnvVar} set ${binPathEnvVar}="%~dp0${bin}.cmd"
|
|
24
|
+
|
|
24
25
|
if exist "%~dp0..\\bin\\node.exe" (
|
|
25
|
-
"%~dp0..\\bin\\node.exe" "%~dp0..\\bin\\run" %*
|
|
26
|
+
"%~dp0..\\bin\\node.exe" ${`${nodeOptions.join(' ')} `}"%~dp0..\\bin\\run" %*
|
|
26
27
|
) else if exist "%LOCALAPPDATA%\\oclif\\node\\node-${nodeVersion}.exe" (
|
|
27
|
-
"%LOCALAPPDATA%\\oclif\\node\\node-${nodeVersion}.exe" "%~dp0..\\bin\\run" %*
|
|
28
|
+
"%LOCALAPPDATA%\\oclif\\node\\node-${nodeVersion}.exe" ${`${nodeOptions.join(' ')} `}"%~dp0..\\bin\\run" %*
|
|
28
29
|
) else (
|
|
29
|
-
node "%~dp0..\\bin\\run" %*
|
|
30
|
+
node ${`${nodeOptions.join(' ')} `}"%~dp0..\\bin\\run" %*
|
|
30
31
|
)
|
|
31
32
|
`);
|
|
32
33
|
};
|
|
@@ -73,9 +74,9 @@ else
|
|
|
73
74
|
exit 1
|
|
74
75
|
fi
|
|
75
76
|
if [ "\$DEBUG" == "*" ]; then
|
|
76
|
-
echoerr ${binPathEnvVar}="\$${binPathEnvVar}" "\$NODE" "\$DIR/run" "\$@"
|
|
77
|
+
echoerr ${binPathEnvVar}="\$${binPathEnvVar}" "\$NODE" ${`${nodeOptions.join(' ')} `}"\$DIR/run" "\$@"
|
|
77
78
|
fi
|
|
78
|
-
"\$NODE" "\$DIR/run" "\$@"
|
|
79
|
+
"\$NODE" ${`${nodeOptions.join(' ')} `}"\$DIR/run" "\$@"
|
|
79
80
|
fi
|
|
80
81
|
`, { mode: 0o755 });
|
|
81
82
|
};
|
package/lib/tarballs/build.js
CHANGED
|
@@ -201,7 +201,7 @@ async function build(c, options = {}) {
|
|
|
201
201
|
await extractCLI(options.tarball ?? (await packCLI()));
|
|
202
202
|
await updatePJSON();
|
|
203
203
|
await addDependencies();
|
|
204
|
-
await (0, bin_1.writeBinScripts)({ baseWorkspace: c.workspace(), config, nodeVersion: c.nodeVersion });
|
|
204
|
+
await (0, bin_1.writeBinScripts)({ baseWorkspace: c.workspace(), config, nodeOptions: c.nodeOptions, nodeVersion: c.nodeVersion });
|
|
205
205
|
await pretarball();
|
|
206
206
|
const targetsToBuild = c.targets.filter((t) => !options.platform || options.platform === t.platform);
|
|
207
207
|
if (options.parallel) {
|
package/lib/tarballs/config.d.ts
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
|
+
import { ObjectCannedACL } from '@aws-sdk/client-s3';
|
|
1
2
|
import { Interfaces } from '@oclif/core';
|
|
2
3
|
export declare const TARGETS: string[];
|
|
4
|
+
export type S3Config = BuildConfig['updateConfig']['s3'] & {
|
|
5
|
+
folder?: string;
|
|
6
|
+
indexVersionLimit?: number;
|
|
7
|
+
} & {
|
|
8
|
+
acl?: ObjectCannedACL;
|
|
9
|
+
};
|
|
10
|
+
export type UpdateConfig = BuildConfig['config']['pjson']['oclif']['update'] & {
|
|
11
|
+
s3?: BuildConfig['config']['pjson']['oclif']['update']['s3'] & {
|
|
12
|
+
acl?: ObjectCannedACL;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
3
15
|
export interface BuildConfig {
|
|
4
16
|
config: Interfaces.Config;
|
|
5
17
|
dist(input: string): string;
|
|
6
18
|
gitSha: string;
|
|
19
|
+
nodeOptions: string[];
|
|
7
20
|
nodeVersion: string;
|
|
8
21
|
root: string;
|
|
9
|
-
s3Config:
|
|
10
|
-
folder?: string;
|
|
11
|
-
indexVersionLimit?: number;
|
|
12
|
-
};
|
|
22
|
+
s3Config: S3Config;
|
|
13
23
|
targets: {
|
|
14
24
|
arch: Interfaces.ArchTypes;
|
|
15
25
|
platform: Interfaces.PlatformTypes;
|
|
16
26
|
}[];
|
|
17
27
|
tmp: string;
|
|
18
|
-
updateConfig:
|
|
28
|
+
updateConfig: UpdateConfig;
|
|
19
29
|
workspace(target?: {
|
|
20
30
|
arch: Interfaces.ArchTypes;
|
|
21
31
|
platform: Interfaces.PlatformTypes;
|
package/lib/tarballs/config.js
CHANGED
|
@@ -28,9 +28,10 @@ async function buildConfig(root, options = {}) {
|
|
|
28
28
|
const _gitSha = await gitSha(root, { short: true });
|
|
29
29
|
// eslint-disable-next-line new-cap
|
|
30
30
|
const tmp = await Tmp(config);
|
|
31
|
-
const updateConfig = config.pjson.oclif.update || {};
|
|
31
|
+
const updateConfig = (config.pjson.oclif.update || {});
|
|
32
32
|
updateConfig.s3 = updateConfig.s3 || {};
|
|
33
33
|
const nodeVersion = updateConfig.node.version || process.versions.node;
|
|
34
|
+
const nodeOptions = (0, util_1.castArray)(updateConfig.node.options ?? []);
|
|
34
35
|
const targets = (0, util_1.compact)(options.targets || updateConfig.node.targets || exports.TARGETS)
|
|
35
36
|
.filter((t) => {
|
|
36
37
|
if (t === 'darwin-arm64' && semver.lt(nodeVersion, '16.0.0')) {
|
|
@@ -43,13 +44,18 @@ async function buildConfig(root, options = {}) {
|
|
|
43
44
|
const [platform, arch] = t.split('-');
|
|
44
45
|
return { arch, platform };
|
|
45
46
|
});
|
|
47
|
+
const s3Config = {
|
|
48
|
+
...updateConfig.s3,
|
|
49
|
+
acl: updateConfig.s3.acl,
|
|
50
|
+
};
|
|
46
51
|
return {
|
|
47
52
|
config,
|
|
48
53
|
dist: (...args) => path.join(config.root, 'dist', ...args),
|
|
49
54
|
gitSha: _gitSha,
|
|
55
|
+
nodeOptions,
|
|
50
56
|
nodeVersion,
|
|
51
57
|
root,
|
|
52
|
-
s3Config
|
|
58
|
+
s3Config,
|
|
53
59
|
targets,
|
|
54
60
|
tmp,
|
|
55
61
|
updateConfig,
|
package/lib/version-indexes.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.appendToIndex = void 0;
|
|
4
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
4
5
|
const fs = require("fs-extra");
|
|
5
6
|
const path = require("node:path");
|
|
6
7
|
const aws_1 = require("./aws");
|
|
@@ -65,7 +66,7 @@ const appendToIndex = async (input) => {
|
|
|
65
66
|
}, s3Config.indexVersionLimit), { spaces: 2 });
|
|
66
67
|
// put the file back in the same place
|
|
67
68
|
await aws_1.default.s3.uploadFile(jsonFileName, {
|
|
68
|
-
ACL: s3Config.acl
|
|
69
|
+
ACL: s3Config.acl ?? client_s3_1.ObjectCannedACL.public_read,
|
|
69
70
|
Bucket: s3Config.bucket,
|
|
70
71
|
CacheControl: maxAge,
|
|
71
72
|
Key: key,
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oclif",
|
|
3
3
|
"description": "oclif: create your own CLI",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.5-dev.0",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bin": {
|
|
7
7
|
"oclif": "bin/run.js"
|
|
8
8
|
},
|
|
9
9
|
"bugs": "https://github.com/oclif/oclif/issues",
|
|
10
10
|
"dependencies": {
|
|
11
|
+
"@aws-sdk/client-cloudfront": "^3.468.0",
|
|
12
|
+
"@aws-sdk/client-s3": "^3.468.0",
|
|
11
13
|
"@oclif/core": "^3.16.0",
|
|
12
14
|
"@oclif/plugin-help": "^6.0.9",
|
|
13
15
|
"@oclif/plugin-not-found": "^3.0.7",
|
|
14
16
|
"@oclif/plugin-warn-if-update-available": "^3.0.8",
|
|
15
17
|
"async-retry": "^1.3.3",
|
|
16
|
-
"aws-sdk": "^2.1231.0",
|
|
17
18
|
"change-case": "^4",
|
|
18
19
|
"debug": "^4.3.3",
|
|
19
20
|
"eslint-plugin-perfectionist": "^2.1.0",
|