oclif 4.1.5-dev.0 → 4.2.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 +60 -38
- package/lib/commands/promote.js +2 -3
- package/lib/tarballs/config.d.ts +5 -14
- package/lib/tarballs/config.js +2 -6
- package/lib/version-indexes.js +1 -2
- package/oclif.manifest.json +1 -1
- package/package.json +2 -3
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 * as CloudFront from 'aws-sdk/clients/cloudfront';
|
|
2
|
+
import * as S3 from 'aws-sdk/clients/s3';
|
|
3
3
|
declare const _default: {
|
|
4
4
|
readonly cloudfront: {
|
|
5
|
-
createCloudfrontInvalidation: (options: CreateInvalidationRequest) => Promise<
|
|
5
|
+
createCloudfrontInvalidation: (options: CloudFront.Types.CreateInvalidationRequest) => Promise<unknown>;
|
|
6
6
|
};
|
|
7
7
|
readonly s3: {
|
|
8
|
-
copyObject: (options: CopyObjectRequest) => Promise<
|
|
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<
|
|
8
|
+
copyObject: (options: S3.Types.CopyObjectRequest) => Promise<unknown>;
|
|
9
|
+
deleteObjects: (options: S3.Types.DeleteObjectsRequest) => Promise<S3.DeleteObjectsOutput>;
|
|
10
|
+
getObject: (options: S3.Types.GetObjectRequest) => Promise<S3.GetObjectOutput>;
|
|
11
|
+
headObject: (options: S3.Types.HeadObjectRequest) => Promise<S3.HeadObjectOutput>;
|
|
12
|
+
listObjects: (options: S3.Types.ListObjectsV2Request) => Promise<S3.ListObjectsV2Output>;
|
|
13
|
+
uploadFile: (local: string, options: S3.Types.PutObjectRequest) => Promise<unknown>;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
export default _default;
|
package/lib/aws.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
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");
|
|
5
3
|
const fs_extra_1 = require("fs-extra");
|
|
6
4
|
const log_1 = require("./log");
|
|
7
5
|
const util_1 = require("./util");
|
|
@@ -9,8 +7,7 @@ const debug = log_1.debug.new('aws');
|
|
|
9
7
|
const cache = {};
|
|
10
8
|
const aws = {
|
|
11
9
|
get cloudfront() {
|
|
12
|
-
cache.cloudfront =
|
|
13
|
-
cache.cloudfront || new (require('@aws-sdk/client-cloudfront').CloudFrontClient)({ credentials: this.creds });
|
|
10
|
+
cache.cloudfront = cache.cloudfront || new (require('aws-sdk/clients/cloudfront'))(this.creds);
|
|
14
11
|
return cache.cloudfront;
|
|
15
12
|
},
|
|
16
13
|
get creds() {
|
|
@@ -29,18 +26,17 @@ const aws = {
|
|
|
29
26
|
try {
|
|
30
27
|
cache.s3 =
|
|
31
28
|
cache.s3 ??
|
|
32
|
-
new (require('
|
|
33
|
-
|
|
29
|
+
new (require('aws-sdk/clients/s3'))({
|
|
30
|
+
...this.creds,
|
|
34
31
|
endpoint: process.env.AWS_S3_ENDPOINT,
|
|
35
|
-
|
|
36
|
-
region: process.env.AWS_REGION ?? 'us-east-1',
|
|
32
|
+
s3ForcePathStyle: Boolean(process.env.AWS_S3_FORCE_PATH_STYLE),
|
|
37
33
|
});
|
|
38
34
|
return cache.s3;
|
|
39
35
|
}
|
|
40
36
|
catch (error) {
|
|
41
37
|
const { code, message } = error;
|
|
42
38
|
if (code === 'MODULE_NOT_FOUND')
|
|
43
|
-
throw new Error(`${message}\
|
|
39
|
+
throw new Error(`${message}\naws-sdk is needed to run this command.\nInstall aws-sdk as a devDependency in your CLI. \`yarn add -D aws-sdk\``);
|
|
44
40
|
throw error;
|
|
45
41
|
}
|
|
46
42
|
},
|
|
@@ -49,11 +45,13 @@ exports.default = {
|
|
|
49
45
|
get cloudfront() {
|
|
50
46
|
return {
|
|
51
47
|
createCloudfrontInvalidation: (options) => new Promise((resolve, reject) => {
|
|
52
|
-
(0, log_1.log)('createCloudfrontInvalidation', options.DistributionId, options.InvalidationBatch
|
|
53
|
-
aws.cloudfront
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
(0, log_1.log)('createCloudfrontInvalidation', options.DistributionId, options.InvalidationBatch.Paths.Items);
|
|
49
|
+
aws.cloudfront.createInvalidation(options, (err) => {
|
|
50
|
+
if (err)
|
|
51
|
+
reject(err);
|
|
52
|
+
else
|
|
53
|
+
resolve(null);
|
|
54
|
+
});
|
|
57
55
|
}),
|
|
58
56
|
};
|
|
59
57
|
},
|
|
@@ -61,47 +59,71 @@ exports.default = {
|
|
|
61
59
|
return {
|
|
62
60
|
copyObject: (options) => new Promise((resolve, reject) => {
|
|
63
61
|
(0, log_1.log)('s3:copyObject', `from s3://${options.CopySource}`, `to s3://${options.Bucket}/${options.Key}`);
|
|
64
|
-
aws.s3
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
aws.s3.copyObject(options, (err, data) => {
|
|
63
|
+
if (err)
|
|
64
|
+
reject(err);
|
|
65
|
+
else
|
|
66
|
+
resolve(data);
|
|
67
|
+
});
|
|
68
68
|
}),
|
|
69
69
|
deleteObjects: (options) => new Promise((resolve, reject) => {
|
|
70
70
|
debug('deleteObjects', `s3://${options.Bucket}`);
|
|
71
|
-
aws.s3
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
aws.s3.deleteObjects(options, (err, deletedObjects) => {
|
|
72
|
+
if (err)
|
|
73
|
+
reject(err);
|
|
74
|
+
resolve(deletedObjects);
|
|
75
|
+
});
|
|
75
76
|
}),
|
|
76
77
|
getObject: (options) => new Promise((resolve, reject) => {
|
|
77
78
|
debug('getObject', `s3://${options.Bucket}/${options.Key}`);
|
|
78
|
-
aws.s3
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
aws.s3.getObject(options, (err, data) => {
|
|
80
|
+
if (err)
|
|
81
|
+
reject(err);
|
|
82
|
+
else
|
|
83
|
+
resolve(data);
|
|
84
|
+
});
|
|
82
85
|
}),
|
|
83
86
|
headObject: (options) => new Promise((resolve, reject) => {
|
|
84
87
|
debug('s3:headObject', `s3://${options.Bucket}/${options.Key}`);
|
|
85
|
-
aws.s3
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
aws.s3.headObject(options, (err, data) => {
|
|
89
|
+
if (err)
|
|
90
|
+
reject(err);
|
|
91
|
+
else
|
|
92
|
+
resolve(data);
|
|
93
|
+
});
|
|
89
94
|
}),
|
|
90
95
|
listObjects: (options) => new Promise((resolve, reject) => {
|
|
91
96
|
debug('listObjects', `s3://${options.Bucket}/${options.Prefix}`);
|
|
92
|
-
aws.s3
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
aws.s3.listObjectsV2(options, (err, objects) => {
|
|
98
|
+
if (err)
|
|
99
|
+
reject(err);
|
|
100
|
+
resolve(objects);
|
|
101
|
+
});
|
|
96
102
|
}),
|
|
97
103
|
uploadFile: (local, options) => new Promise((resolve, reject) => {
|
|
98
104
|
(0, log_1.log)('s3:uploadFile', (0, util_1.prettifyPaths)(local), `s3://${options.Bucket}/${options.Key}`);
|
|
99
105
|
options.Body = (0, fs_extra_1.createReadStream)(local);
|
|
100
|
-
aws.s3
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
106
|
+
aws.s3.upload(options, (err) => {
|
|
107
|
+
if (err)
|
|
108
|
+
reject(err);
|
|
109
|
+
else
|
|
110
|
+
resolve(null);
|
|
111
|
+
});
|
|
104
112
|
}),
|
|
105
113
|
};
|
|
106
114
|
},
|
|
107
115
|
};
|
|
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,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
4
3
|
const core_1 = require("@oclif/core");
|
|
5
4
|
const path = require("node:path");
|
|
6
5
|
const aws_1 = require("../aws");
|
|
@@ -35,10 +34,10 @@ class Promote extends core_1.Command {
|
|
|
35
34
|
if (!s3Config.bucket)
|
|
36
35
|
this.error('Cannot determine S3 bucket for promotion');
|
|
37
36
|
const awsDefaults = {
|
|
38
|
-
ACL: s3Config.acl ??
|
|
37
|
+
ACL: s3Config.acl ?? 'public-read',
|
|
39
38
|
Bucket: s3Config.bucket,
|
|
40
39
|
CacheControl: indexDefaults.maxAge,
|
|
41
|
-
MetadataDirective:
|
|
40
|
+
MetadataDirective: 'REPLACE',
|
|
42
41
|
};
|
|
43
42
|
const cloudBucketCommitKey = (shortKey) => path.join(s3Config.bucket, (0, upload_util_1.commitAWSDir)(flags.version, flags.sha, s3Config), shortKey);
|
|
44
43
|
const cloudChannelKey = (shortKey) => path.join((0, upload_util_1.channelAWSDir)(flags.channel, s3Config), shortKey);
|
package/lib/tarballs/config.d.ts
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import { ObjectCannedACL } from '@aws-sdk/client-s3';
|
|
2
1
|
import { Interfaces } from '@oclif/core';
|
|
3
2
|
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
|
-
};
|
|
15
3
|
export interface BuildConfig {
|
|
16
4
|
config: Interfaces.Config;
|
|
17
5
|
dist(input: string): string;
|
|
@@ -19,13 +7,16 @@ export interface BuildConfig {
|
|
|
19
7
|
nodeOptions: string[];
|
|
20
8
|
nodeVersion: string;
|
|
21
9
|
root: string;
|
|
22
|
-
s3Config:
|
|
10
|
+
s3Config: BuildConfig['updateConfig']['s3'] & {
|
|
11
|
+
folder?: string;
|
|
12
|
+
indexVersionLimit?: number;
|
|
13
|
+
};
|
|
23
14
|
targets: {
|
|
24
15
|
arch: Interfaces.ArchTypes;
|
|
25
16
|
platform: Interfaces.PlatformTypes;
|
|
26
17
|
}[];
|
|
27
18
|
tmp: string;
|
|
28
|
-
updateConfig:
|
|
19
|
+
updateConfig: BuildConfig['config']['pjson']['oclif']['update'];
|
|
29
20
|
workspace(target?: {
|
|
30
21
|
arch: Interfaces.ArchTypes;
|
|
31
22
|
platform: Interfaces.PlatformTypes;
|
package/lib/tarballs/config.js
CHANGED
|
@@ -28,7 +28,7 @@ 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 =
|
|
31
|
+
const updateConfig = config.pjson.oclif.update || {};
|
|
32
32
|
updateConfig.s3 = updateConfig.s3 || {};
|
|
33
33
|
const nodeVersion = updateConfig.node.version || process.versions.node;
|
|
34
34
|
const nodeOptions = (0, util_1.castArray)(updateConfig.node.options ?? []);
|
|
@@ -44,10 +44,6 @@ async function buildConfig(root, options = {}) {
|
|
|
44
44
|
const [platform, arch] = t.split('-');
|
|
45
45
|
return { arch, platform };
|
|
46
46
|
});
|
|
47
|
-
const s3Config = {
|
|
48
|
-
...updateConfig.s3,
|
|
49
|
-
acl: updateConfig.s3.acl,
|
|
50
|
-
};
|
|
51
47
|
return {
|
|
52
48
|
config,
|
|
53
49
|
dist: (...args) => path.join(config.root, 'dist', ...args),
|
|
@@ -55,7 +51,7 @@ async function buildConfig(root, options = {}) {
|
|
|
55
51
|
nodeOptions,
|
|
56
52
|
nodeVersion,
|
|
57
53
|
root,
|
|
58
|
-
s3Config,
|
|
54
|
+
s3Config: updateConfig.s3,
|
|
59
55
|
targets,
|
|
60
56
|
tmp,
|
|
61
57
|
updateConfig,
|
package/lib/version-indexes.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
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");
|
|
5
4
|
const fs = require("fs-extra");
|
|
6
5
|
const path = require("node:path");
|
|
7
6
|
const aws_1 = require("./aws");
|
|
@@ -66,7 +65,7 @@ const appendToIndex = async (input) => {
|
|
|
66
65
|
}, s3Config.indexVersionLimit), { spaces: 2 });
|
|
67
66
|
// put the file back in the same place
|
|
68
67
|
await aws_1.default.s3.uploadFile(jsonFileName, {
|
|
69
|
-
ACL: s3Config.acl
|
|
68
|
+
ACL: s3Config.acl || 'public-read',
|
|
70
69
|
Bucket: s3Config.bucket,
|
|
71
70
|
CacheControl: maxAge,
|
|
72
71
|
Key: key,
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oclif",
|
|
3
3
|
"description": "oclif: create your own CLI",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.2.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",
|
|
13
11
|
"@oclif/core": "^3.16.0",
|
|
14
12
|
"@oclif/plugin-help": "^6.0.9",
|
|
15
13
|
"@oclif/plugin-not-found": "^3.0.7",
|
|
16
14
|
"@oclif/plugin-warn-if-update-available": "^3.0.8",
|
|
17
15
|
"async-retry": "^1.3.3",
|
|
16
|
+
"aws-sdk": "^2.1231.0",
|
|
18
17
|
"change-case": "^4",
|
|
19
18
|
"debug": "^4.3.3",
|
|
20
19
|
"eslint-plugin-perfectionist": "^2.1.0",
|