oclif 3.3.0 → 3.4.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/.oclif.manifest.json +1 -1
- package/lib/aws.js +2 -2
- package/lib/commands/pack/deb.js +46 -28
- package/lib/commands/pack/macos.js +24 -20
- package/lib/commands/pack/tarballs.js +0 -3
- package/lib/commands/pack/win.js +43 -41
- package/lib/commands/promote.js +73 -112
- package/lib/commands/upload/deb.js +27 -15
- package/lib/commands/upload/macos.js +3 -5
- package/lib/commands/upload/tarballs.js +12 -27
- package/lib/commands/upload/win.js +4 -6
- package/lib/log.js +2 -2
- package/lib/tarballs/bin.js +7 -8
- package/lib/tarballs/build.js +48 -49
- package/lib/tarballs/config.js +9 -6
- package/lib/tarballs/node.js +28 -18
- package/lib/util.d.ts +2 -0
- package/lib/util.js +21 -1
- package/package.json +8 -10
package/lib/commands/promote.js
CHANGED
|
@@ -9,24 +9,29 @@ const upload_util_1 = require("../upload-util");
|
|
|
9
9
|
const version_indexes_1 = require("../version-indexes");
|
|
10
10
|
class Promote extends core_1.Command {
|
|
11
11
|
async run() {
|
|
12
|
-
var _a;
|
|
12
|
+
var _a, _b;
|
|
13
13
|
const { flags } = await this.parse(Promote);
|
|
14
|
-
const maxAge = `max-age=${flags['max-age']}`;
|
|
15
14
|
const buildConfig = await Tarballs.buildConfig(flags.root, { targets: (_a = flags === null || flags === void 0 ? void 0 : flags.targets) === null || _a === void 0 ? void 0 : _a.split(',') });
|
|
16
15
|
const { s3Config, config } = buildConfig;
|
|
17
16
|
const indexDefaults = {
|
|
18
17
|
version: flags.version,
|
|
19
18
|
s3Config,
|
|
20
|
-
maxAge
|
|
19
|
+
maxAge: `max-age=${flags['max-age']}`,
|
|
21
20
|
};
|
|
22
21
|
if (!s3Config.bucket)
|
|
23
22
|
this.error('Cannot determine S3 bucket for promotion');
|
|
23
|
+
const awsDefaults = {
|
|
24
|
+
Bucket: s3Config.bucket,
|
|
25
|
+
ACL: (_b = s3Config.acl) !== null && _b !== void 0 ? _b : 'public-read',
|
|
26
|
+
MetadataDirective: 'REPLACE',
|
|
27
|
+
CacheControl: indexDefaults.maxAge,
|
|
28
|
+
};
|
|
24
29
|
const cloudBucketCommitKey = (shortKey) => path.join(s3Config.bucket, (0, upload_util_1.commitAWSDir)(flags.version, flags.sha, s3Config), shortKey);
|
|
25
30
|
const cloudChannelKey = (shortKey) => path.join((0, upload_util_1.channelAWSDir)(flags.channel, s3Config), shortKey);
|
|
26
31
|
// copy tarballs manifests
|
|
27
32
|
if (buildConfig.targets.length > 0)
|
|
28
33
|
this.log(`Promoting buildmanifests & unversioned tarballs to ${flags.channel}`);
|
|
29
|
-
|
|
34
|
+
const promoteManifest = async (target) => {
|
|
30
35
|
const manifest = (0, upload_util_1.templateShortKey)('manifest', {
|
|
31
36
|
arch: target.arch,
|
|
32
37
|
bin: config.bin,
|
|
@@ -34,19 +39,11 @@ class Promote extends core_1.Command {
|
|
|
34
39
|
sha: flags.sha,
|
|
35
40
|
version: flags.version,
|
|
36
41
|
});
|
|
37
|
-
const copySource = cloudBucketCommitKey(manifest);
|
|
38
42
|
// strip version & sha so update/scripts can point to a static channel manifest
|
|
39
43
|
const unversionedManifest = manifest.replace(`-v${flags.version}-${flags.sha}`, '');
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Bucket: s3Config.bucket,
|
|
44
|
-
ACL: s3Config.acl || 'public-read',
|
|
45
|
-
CopySource: copySource,
|
|
46
|
-
Key: key,
|
|
47
|
-
CacheControl: maxAge,
|
|
48
|
-
MetadataDirective: 'REPLACE',
|
|
49
|
-
});
|
|
44
|
+
await aws_1.default.s3.copyObject(Object.assign(Object.assign({}, awsDefaults), { CopySource: cloudBucketCommitKey(manifest), Key: cloudChannelKey(unversionedManifest) }));
|
|
45
|
+
};
|
|
46
|
+
const promoteGzTarballs = async (target) => {
|
|
50
47
|
const versionedTarGzName = (0, upload_util_1.templateShortKey)('versioned', '.tar.gz', {
|
|
51
48
|
arch: target.arch,
|
|
52
49
|
bin: config.bin,
|
|
@@ -58,119 +55,83 @@ class Promote extends core_1.Command {
|
|
|
58
55
|
// strip version & sha so update/scripts can point to a static channel tarball
|
|
59
56
|
const unversionedTarGzName = versionedTarGzName.replace(`-v${flags.version}-${flags.sha}`, '');
|
|
60
57
|
const unversionedTarGzKey = cloudChannelKey(unversionedTarGzName);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
await Promise.all([aws_1.default.s3.copyObject(Object.assign(Object.assign({}, awsDefaults), { CopySource: versionedTarGzKey, Key: unversionedTarGzKey }))].concat(flags.indexes ? [(0, version_indexes_1.appendToIndex)(Object.assign(Object.assign({}, indexDefaults), { originalUrl: versionedTarGzKey, filename: unversionedTarGzName }))] : []));
|
|
59
|
+
};
|
|
60
|
+
const promoteXzTarballs = async (target) => {
|
|
61
|
+
const versionedTarXzName = (0, upload_util_1.templateShortKey)('versioned', '.tar.xz', {
|
|
62
|
+
arch: target.arch,
|
|
63
|
+
bin: config.bin,
|
|
64
|
+
platform: target.platform,
|
|
65
|
+
sha: flags.sha,
|
|
66
|
+
version: flags.version,
|
|
69
67
|
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
platform: target.platform,
|
|
78
|
-
sha: flags.sha,
|
|
79
|
-
version: flags.version,
|
|
80
|
-
});
|
|
81
|
-
const versionedTarXzKey = cloudBucketCommitKey(versionedTarXzName);
|
|
82
|
-
// strip version & sha so update/scripts can point to a static channel tarball
|
|
83
|
-
const unversionedTarXzName = versionedTarXzName.replace(`-v${flags.version}-${flags.sha}`, '');
|
|
84
|
-
const unversionedTarXzKey = cloudChannelKey(unversionedTarXzName);
|
|
85
|
-
// eslint-disable-next-line no-await-in-loop
|
|
86
|
-
await aws_1.default.s3.copyObject({
|
|
87
|
-
Bucket: s3Config.bucket,
|
|
88
|
-
ACL: s3Config.acl || 'public-read',
|
|
89
|
-
CopySource: versionedTarXzKey,
|
|
90
|
-
Key: unversionedTarXzKey,
|
|
91
|
-
CacheControl: maxAge,
|
|
92
|
-
MetadataDirective: 'REPLACE',
|
|
93
|
-
});
|
|
94
|
-
// eslint-disable-next-line no-await-in-loop
|
|
95
|
-
if (flags.indexes)
|
|
96
|
-
await (0, version_indexes_1.appendToIndex)(Object.assign(Object.assign({}, indexDefaults), { originalUrl: versionedTarXzKey, filename: unversionedTarXzName }));
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
// copy darwin pkg
|
|
100
|
-
if (flags.macos) {
|
|
68
|
+
const versionedTarXzKey = cloudBucketCommitKey(versionedTarXzName);
|
|
69
|
+
// strip version & sha so update/scripts can point to a static channel tarball
|
|
70
|
+
const unversionedTarXzName = versionedTarXzName.replace(`-v${flags.version}-${flags.sha}`, '');
|
|
71
|
+
const unversionedTarXzKey = cloudChannelKey(unversionedTarXzName);
|
|
72
|
+
await Promise.all([aws_1.default.s3.copyObject(Object.assign(Object.assign({}, awsDefaults), { CopySource: versionedTarXzKey, Key: unversionedTarXzKey }))].concat(flags.indexes ? [(0, version_indexes_1.appendToIndex)(Object.assign(Object.assign({}, indexDefaults), { originalUrl: versionedTarXzKey, filename: unversionedTarXzName }))] : []));
|
|
73
|
+
};
|
|
74
|
+
const promoteMacInstallers = async () => {
|
|
101
75
|
this.log(`Promoting macos pkgs to ${flags.channel}`);
|
|
102
76
|
const arches = _.uniq(buildConfig.targets.filter(t => t.platform === 'darwin').map(t => t.arch));
|
|
103
|
-
|
|
77
|
+
await Promise.all(arches.map(async (arch) => {
|
|
104
78
|
const darwinPkg = (0, upload_util_1.templateShortKey)('macos', { bin: config.bin, version: flags.version, sha: flags.sha, arch });
|
|
105
79
|
const darwinCopySource = cloudBucketCommitKey(darwinPkg);
|
|
106
80
|
// strip version & sha so scripts can point to a static channel pkg
|
|
107
81
|
const unversionedPkg = darwinPkg.replace(`-v${flags.version}-${flags.sha}`, '');
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
CopySource: darwinCopySource,
|
|
114
|
-
Key: darwinKey,
|
|
115
|
-
CacheControl: maxAge,
|
|
116
|
-
MetadataDirective: 'REPLACE',
|
|
117
|
-
});
|
|
118
|
-
// eslint-disable-next-line no-await-in-loop
|
|
119
|
-
if (flags.indexes)
|
|
120
|
-
await (0, version_indexes_1.appendToIndex)(Object.assign(Object.assign({}, indexDefaults), { originalUrl: darwinCopySource, filename: unversionedPkg }));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
// copy win exe
|
|
124
|
-
if (flags.win) {
|
|
82
|
+
await Promise.all([aws_1.default.s3.copyObject(Object.assign(Object.assign({}, awsDefaults), { CopySource: darwinCopySource, Key: cloudChannelKey(unversionedPkg) }))].concat(flags.indexes ? [(0, version_indexes_1.appendToIndex)(Object.assign(Object.assign({}, indexDefaults), { originalUrl: darwinCopySource, filename: unversionedPkg }))] : []));
|
|
83
|
+
}));
|
|
84
|
+
};
|
|
85
|
+
const promoteWindowsInstallers = async () => {
|
|
86
|
+
// copy win exe
|
|
125
87
|
this.log(`Promoting windows exe to ${flags.channel}`);
|
|
126
|
-
const
|
|
127
|
-
|
|
88
|
+
const arches = buildConfig.targets.filter(t => t.platform === 'win32').map(t => t.arch);
|
|
89
|
+
await Promise.all(arches.map(async (arch) => {
|
|
128
90
|
const winPkg = (0, upload_util_1.templateShortKey)('win32', { bin: config.bin, version: flags.version, sha: flags.sha, arch });
|
|
129
91
|
const winCopySource = cloudBucketCommitKey(winPkg);
|
|
130
92
|
// strip version & sha so scripts can point to a static channel exe
|
|
131
93
|
const unversionedExe = winPkg.replace(`-v${flags.version}-${flags.sha}`, '');
|
|
132
|
-
|
|
133
|
-
// eslint-disable-next-line no-await-in-loop
|
|
134
|
-
await aws_1.default.s3.copyObject({
|
|
135
|
-
Bucket: s3Config.bucket,
|
|
136
|
-
ACL: s3Config.acl || 'public-read',
|
|
137
|
-
CopySource: winCopySource,
|
|
138
|
-
Key: winKey,
|
|
139
|
-
CacheControl: maxAge,
|
|
140
|
-
});
|
|
141
|
-
// eslint-disable-next-line no-await-in-loop
|
|
142
|
-
if (flags.indexes)
|
|
143
|
-
await (0, version_indexes_1.appendToIndex)(Object.assign(Object.assign({}, indexDefaults), { originalUrl: winCopySource, filename: unversionedExe }));
|
|
94
|
+
await Promise.all([aws_1.default.s3.copyObject(Object.assign(Object.assign({}, awsDefaults), { CopySource: winCopySource, Key: cloudChannelKey(unversionedExe) }))].concat(flags.indexes ? [(0, version_indexes_1.appendToIndex)(Object.assign(Object.assign({}, indexDefaults), { originalUrl: winCopySource, filename: unversionedExe }))] : []));
|
|
144
95
|
core_1.CliUx.ux.action.stop('successfully');
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
96
|
+
}));
|
|
97
|
+
};
|
|
98
|
+
const promoteDebianAptPackages = async () => {
|
|
99
|
+
// copy debian artifacts
|
|
100
|
+
const debArtifacts = [
|
|
101
|
+
(0, upload_util_1.templateShortKey)('deb', { bin: config.bin, versionShaRevision: (0, upload_util_1.debVersion)(buildConfig), arch: 'amd64' }),
|
|
102
|
+
(0, upload_util_1.templateShortKey)('deb', { bin: config.bin, versionShaRevision: (0, upload_util_1.debVersion)(buildConfig), arch: 'i386' }),
|
|
103
|
+
'Packages.gz',
|
|
104
|
+
'Packages.xz',
|
|
105
|
+
'Packages.bz2',
|
|
106
|
+
'Release',
|
|
107
|
+
'InRelease',
|
|
108
|
+
'Release.gpg',
|
|
109
|
+
];
|
|
159
110
|
this.log(`Promoting debian artifacts to ${flags.channel}`);
|
|
160
|
-
|
|
111
|
+
await Promise.all(debArtifacts.flatMap(artifact => {
|
|
161
112
|
const debCopySource = cloudBucketCommitKey(`apt/${artifact}`);
|
|
162
113
|
const debKey = cloudChannelKey(`apt/${artifact}`);
|
|
163
|
-
//
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
}
|
|
114
|
+
// apt expects ../apt/dists/versionName/[artifacts] but oclif wants varsions/sha/apt/[artifacts]
|
|
115
|
+
// see https://github.com/oclif/oclif/issues/347 for the AWS-redirect that solves this
|
|
116
|
+
// this workaround puts the code in both places that the redirect was doing
|
|
117
|
+
// with this, the docs are correct. The copies are all done in parallel so it shouldn't be too costly.
|
|
118
|
+
const workaroundKey = cloudChannelKey(`apt/./${artifact}`);
|
|
119
|
+
return [
|
|
120
|
+
aws_1.default.s3.copyObject(Object.assign(Object.assign({}, awsDefaults), { CopySource: debCopySource, Key: debKey })),
|
|
121
|
+
aws_1.default.s3.copyObject(Object.assign(Object.assign({}, awsDefaults), { CopySource: debCopySource, Key: workaroundKey })),
|
|
122
|
+
];
|
|
123
|
+
}));
|
|
124
|
+
};
|
|
125
|
+
await Promise.all(buildConfig.targets.flatMap(target => [
|
|
126
|
+
// always promote the manifest and gz
|
|
127
|
+
promoteManifest(target),
|
|
128
|
+
promoteGzTarballs(target),
|
|
129
|
+
])
|
|
130
|
+
// optionally promote other artifacts depending on the specified flags
|
|
131
|
+
.concat(flags.xz ? buildConfig.targets.map(target => promoteXzTarballs(target)) : [])
|
|
132
|
+
.concat(flags.macos ? [promoteMacInstallers()] : [])
|
|
133
|
+
.concat(flags.win ? [promoteWindowsInstallers()] : [])
|
|
134
|
+
.concat(flags.deb ? [promoteDebianAptPackages()] : []));
|
|
174
135
|
}
|
|
175
136
|
}
|
|
176
137
|
exports.default = Promote;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
|
-
const
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
5
6
|
const aws_1 = require("../../aws");
|
|
6
7
|
const log_1 = require("../../log");
|
|
7
8
|
const Tarballs = require("../../tarballs");
|
|
@@ -11,12 +12,12 @@ class UploadDeb extends core_1.Command {
|
|
|
11
12
|
const { flags } = await this.parse(UploadDeb);
|
|
12
13
|
const buildConfig = await Tarballs.buildConfig(flags.root);
|
|
13
14
|
const { s3Config, config } = buildConfig;
|
|
14
|
-
const dist = (f) => buildConfig.dist(
|
|
15
|
+
const dist = (f) => buildConfig.dist(path.join('deb', f));
|
|
15
16
|
const S3Options = {
|
|
16
17
|
Bucket: s3Config.bucket,
|
|
17
18
|
ACL: s3Config.acl || 'public-read',
|
|
18
19
|
};
|
|
19
|
-
if (!
|
|
20
|
+
if (!fs.existsSync(dist('Release')))
|
|
20
21
|
this.error('Cannot find debian artifacts', {
|
|
21
22
|
suggestions: ['Run "oclif pack deb" before uploading'],
|
|
22
23
|
});
|
|
@@ -25,21 +26,32 @@ class UploadDeb extends core_1.Command {
|
|
|
25
26
|
const cloudKey = `${cloudKeyBase}/apt/${file}`;
|
|
26
27
|
return aws_1.default.s3.uploadFile(dist(file), Object.assign(Object.assign({}, S3Options), { CacheControl: 'max-age=86400', Key: cloudKey }));
|
|
27
28
|
};
|
|
29
|
+
// apt expects ../apt/dists/versionName/[artifacts] but oclif wants versions/sha/apt/[artifacts]
|
|
30
|
+
// see https://github.com/oclif/oclif/issues/347 for the AWS-redirect that solves this
|
|
31
|
+
// this workaround puts the code in both places that the redirect was doing
|
|
32
|
+
// with this, the docs are correct. The copies are all done in parallel so it shouldn't be too costly.
|
|
33
|
+
const uploadWorkaround = (file) => {
|
|
34
|
+
const cloudKey = `${cloudKeyBase}/apt/./${file}`;
|
|
35
|
+
return aws_1.default.s3.uploadFile(dist(file), Object.assign(Object.assign({}, S3Options), { CacheControl: 'max-age=86400', Key: cloudKey }));
|
|
36
|
+
};
|
|
28
37
|
const uploadDeb = async (arch) => {
|
|
29
38
|
const deb = (0, upload_util_1.templateShortKey)('deb', { bin: config.bin, versionShaRevision: (0, upload_util_1.debVersion)(buildConfig), arch: arch });
|
|
30
|
-
if (
|
|
31
|
-
await upload(deb);
|
|
39
|
+
if (fs.existsSync(dist(deb)))
|
|
40
|
+
await Promise.all([upload(deb), uploadWorkaround(deb)]);
|
|
32
41
|
};
|
|
33
|
-
|
|
34
|
-
await
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
(0, log_1.log)(`starting upload of deb artifacts for v${config.version}-${buildConfig.gitSha}`);
|
|
43
|
+
await Promise.all([
|
|
44
|
+
uploadDeb('amd64'),
|
|
45
|
+
uploadDeb('i386'),
|
|
46
|
+
upload('Packages.gz'),
|
|
47
|
+
upload('Packages.xz'),
|
|
48
|
+
upload('Packages.bz2'),
|
|
49
|
+
upload('Release'),
|
|
50
|
+
uploadWorkaround('Packages.gz'),
|
|
51
|
+
uploadWorkaround('Packages.xz'),
|
|
52
|
+
uploadWorkaround('Packages.bz2'),
|
|
53
|
+
uploadWorkaround('Release'),
|
|
54
|
+
].concat(fs.existsSync(dist('InRelease')) ? [upload('InRelease'), uploadWorkaround('InRelease')] : [], fs.existsSync(dist('Release.gpg')) ? [upload('Release.gpg'), uploadWorkaround('Release.gpg')] : []));
|
|
43
55
|
(0, log_1.log)(`done uploading deb artifacts for v${config.version}-${buildConfig.gitSha}`);
|
|
44
56
|
}
|
|
45
57
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const _ = require("lodash");
|
|
4
|
-
const
|
|
4
|
+
const fs = require("fs");
|
|
5
5
|
const core_1 = require("@oclif/core");
|
|
6
6
|
const aws_1 = require("../../aws");
|
|
7
7
|
const log_1 = require("../../log");
|
|
@@ -22,7 +22,7 @@ class UploadMacos extends core_1.Command {
|
|
|
22
22
|
const templateKey = (0, upload_util_1.templateShortKey)('macos', { bin: config.bin, version: config.version, sha: buildConfig.gitSha, arch });
|
|
23
23
|
const cloudKey = `${cloudKeyBase}/${templateKey}`;
|
|
24
24
|
const localPkg = dist(`macos/${templateKey}`);
|
|
25
|
-
if (
|
|
25
|
+
if (fs.existsSync(localPkg))
|
|
26
26
|
await aws_1.default.s3.uploadFile(localPkg, Object.assign(Object.assign({}, S3Options), { CacheControl: 'max-age=86400', Key: cloudKey }));
|
|
27
27
|
else
|
|
28
28
|
this.error('Cannot find macOS pkg', {
|
|
@@ -32,9 +32,7 @@ class UploadMacos extends core_1.Command {
|
|
|
32
32
|
const arches = _.uniq(buildConfig.targets
|
|
33
33
|
.filter(t => t.platform === 'darwin')
|
|
34
34
|
.map(t => t.arch));
|
|
35
|
-
|
|
36
|
-
for (const a of arches)
|
|
37
|
-
await upload(a);
|
|
35
|
+
await Promise.all(arches.map(a => upload(a)));
|
|
38
36
|
(0, log_1.log)(`done uploading macos pkgs for v${config.version}-${buildConfig.gitSha}`);
|
|
39
37
|
}
|
|
40
38
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
|
-
const
|
|
4
|
+
const fs = require("fs");
|
|
5
5
|
const aws_1 = require("../../aws");
|
|
6
6
|
const log_1 = require("../../log");
|
|
7
7
|
const Tarballs = require("../../tarballs");
|
|
@@ -17,8 +17,7 @@ class UploadTarballs extends core_1.Command {
|
|
|
17
17
|
// fail early if targets are not built
|
|
18
18
|
for (const target of buildConfig.targets) {
|
|
19
19
|
const tarball = dist((0, upload_util_1.templateShortKey)('versioned', Object.assign({ ext: '.tar.gz', bin: config.bin, version: config.version, sha: buildConfig.gitSha }, target)));
|
|
20
|
-
|
|
21
|
-
if (!await qq.exists(tarball))
|
|
20
|
+
if (!fs.existsSync(tarball))
|
|
22
21
|
this.error(`Cannot find a tarball ${tarball} for ${target.platform}-${target.arch}`, {
|
|
23
22
|
suggestions: [`Run "oclif pack --target ${target.platform}-${target.arch}" before uploading`],
|
|
24
23
|
});
|
|
@@ -28,25 +27,7 @@ class UploadTarballs extends core_1.Command {
|
|
|
28
27
|
ACL: s3Config.acl || 'public-read',
|
|
29
28
|
};
|
|
30
29
|
const uploadTarball = async (options) => {
|
|
31
|
-
const
|
|
32
|
-
const releaseTarballs = async (ext) => {
|
|
33
|
-
const localKey = (0, upload_util_1.templateShortKey)('versioned', ext, {
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
|
|
35
|
-
arch: options === null || options === void 0 ? void 0 : options.arch,
|
|
36
|
-
bin: config.bin,
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
|
|
38
|
-
platform: options === null || options === void 0 ? void 0 : options.platform,
|
|
39
|
-
sha: buildConfig.gitSha,
|
|
40
|
-
version: config.version,
|
|
41
|
-
});
|
|
42
|
-
const cloudKey = `${(0, upload_util_1.commitAWSDir)(config.version, buildConfig.gitSha, s3Config)}/${localKey}`;
|
|
43
|
-
await aws_1.default.s3.uploadFile(dist(localKey), Object.assign(Object.assign({}, TarballS3Options), { ContentType: 'application/gzip', Key: cloudKey }));
|
|
44
|
-
};
|
|
45
|
-
await releaseTarballs('.tar.gz');
|
|
46
|
-
if (xz)
|
|
47
|
-
await releaseTarballs('.tar.xz');
|
|
48
|
-
const ManifestS3Options = Object.assign(Object.assign({}, S3Options), { CacheControl: 'max-age=86400', ContentType: 'application/json' });
|
|
49
|
-
const manifest = (0, upload_util_1.templateShortKey)('manifest', {
|
|
30
|
+
const shortKeyInputs = {
|
|
50
31
|
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
|
|
51
32
|
arch: options === null || options === void 0 ? void 0 : options.arch,
|
|
52
33
|
bin: config.bin,
|
|
@@ -54,15 +35,19 @@ class UploadTarballs extends core_1.Command {
|
|
|
54
35
|
platform: options === null || options === void 0 ? void 0 : options.platform,
|
|
55
36
|
sha: buildConfig.gitSha,
|
|
56
37
|
version: config.version,
|
|
57
|
-
}
|
|
38
|
+
};
|
|
39
|
+
const releaseTarballs = async (ext) => {
|
|
40
|
+
const localKey = (0, upload_util_1.templateShortKey)('versioned', ext, shortKeyInputs);
|
|
41
|
+
const cloudKey = `${(0, upload_util_1.commitAWSDir)(config.version, buildConfig.gitSha, s3Config)}/${localKey}`;
|
|
42
|
+
await aws_1.default.s3.uploadFile(dist(localKey), Object.assign(Object.assign({}, S3Options), { CacheControl: 'max-age=604800', ContentType: 'application/gzip', Key: cloudKey }));
|
|
43
|
+
};
|
|
44
|
+
const manifest = (0, upload_util_1.templateShortKey)('manifest', shortKeyInputs);
|
|
58
45
|
const cloudKey = `${(0, upload_util_1.commitAWSDir)(config.version, buildConfig.gitSha, s3Config)}/${manifest}`;
|
|
59
|
-
await aws_1.default.s3.uploadFile(dist(manifest), Object.assign(Object.assign({},
|
|
46
|
+
await Promise.all([releaseTarballs('.tar.gz'), aws_1.default.s3.uploadFile(dist(manifest), Object.assign(Object.assign({}, S3Options), { CacheControl: 'max-age=86400', ContentType: 'application/json', Key: cloudKey }))].concat(xz ? [releaseTarballs('.tar.xz')] : []));
|
|
60
47
|
};
|
|
61
48
|
if (buildConfig.targets.length > 0)
|
|
62
49
|
(0, log_1.log)('uploading targets');
|
|
63
|
-
|
|
64
|
-
for (const target of buildConfig.targets)
|
|
65
|
-
await uploadTarball(target);
|
|
50
|
+
await Promise.all(buildConfig.targets.map(t => uploadTarball(t)));
|
|
66
51
|
(0, log_1.log)(`done uploading tarballs & manifests for v${config.version}-${buildConfig.gitSha}`);
|
|
67
52
|
}
|
|
68
53
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
|
-
const
|
|
4
|
+
const fs = require("fs");
|
|
5
5
|
const aws_1 = require("../../aws");
|
|
6
6
|
const log_1 = require("../../log");
|
|
7
7
|
const Tarballs = require("../../tarballs");
|
|
@@ -19,8 +19,7 @@ class UploadWin extends core_1.Command {
|
|
|
19
19
|
for (const arch of archs) {
|
|
20
20
|
const templateKey = (0, upload_util_1.templateShortKey)('win32', { bin: config.bin, version: config.version, sha: buildConfig.gitSha, arch });
|
|
21
21
|
const localKey = dist(`win32/${templateKey}`);
|
|
22
|
-
|
|
23
|
-
if (!await qq.exists(localKey))
|
|
22
|
+
if (!fs.existsSync(localKey))
|
|
24
23
|
this.error(`Cannot find Windows exe for ${arch}`, {
|
|
25
24
|
suggestions: ['Run "oclif pack win" before uploading'],
|
|
26
25
|
});
|
|
@@ -30,11 +29,10 @@ class UploadWin extends core_1.Command {
|
|
|
30
29
|
const templateKey = (0, upload_util_1.templateShortKey)('win32', { bin: config.bin, version: config.version, sha: buildConfig.gitSha, arch });
|
|
31
30
|
const localExe = dist(`win32/${templateKey}`);
|
|
32
31
|
const cloudKey = `${cloudKeyBase}/${templateKey}`;
|
|
33
|
-
if (
|
|
32
|
+
if (fs.existsSync(localExe))
|
|
34
33
|
await aws_1.default.s3.uploadFile(localExe, Object.assign(Object.assign({}, S3Options), { CacheControl: 'max-age=86400', Key: cloudKey }));
|
|
35
34
|
};
|
|
36
|
-
await uploadWin('x64');
|
|
37
|
-
await uploadWin('x86');
|
|
35
|
+
await Promise.all([uploadWin('x64'), uploadWin('x86')]);
|
|
38
36
|
(0, log_1.log)(`done uploading windows executables for v${config.version}-${buildConfig.gitSha}`);
|
|
39
37
|
}
|
|
40
38
|
}
|
package/lib/log.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.log = exports.debug = void 0;
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
|
-
const qq = require("qqjs");
|
|
6
5
|
const util = require("util");
|
|
6
|
+
const util_1 = require("./util");
|
|
7
7
|
exports.debug = require('debug')('oclif');
|
|
8
8
|
exports.debug.new = (name) => require('debug')(`oclif:${name}`);
|
|
9
9
|
function log(format, ...args) {
|
|
10
|
-
args = args.map((arg) =>
|
|
10
|
+
args = args.map((arg) => (0, util_1.prettifyPaths)(arg));
|
|
11
11
|
exports.debug.enabled ? (0, exports.debug)(format, ...args) : core_1.CliUx.ux.log(`oclif: ${util.format(format, ...args)}`);
|
|
12
12
|
}
|
|
13
13
|
exports.log = log;
|
package/lib/tarballs/bin.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.writeBinScripts = void 0;
|
|
4
|
-
const
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
5
6
|
async function writeBinScripts({ config, baseWorkspace, nodeVersion }) {
|
|
6
7
|
const binPathEnvVar = config.scopedEnvVarKey('BINPATH');
|
|
7
8
|
const redirectedEnvVar = config.scopedEnvVarKey('REDIRECTED');
|
|
8
9
|
const clientHomeEnvVar = config.scopedEnvVarKey('OCLIF_CLIENT_HOME');
|
|
9
10
|
const writeWin32 = async () => {
|
|
10
11
|
const { bin } = config;
|
|
11
|
-
await
|
|
12
|
+
await fs.promises.writeFile(path.join(baseWorkspace, 'bin', `${config.bin}.cmd`), `@echo off
|
|
12
13
|
setlocal enableextensions
|
|
13
14
|
|
|
14
15
|
if not "%${redirectedEnvVar}%"=="1" if exist "%LOCALAPPDATA%\\${bin}\\client\\bin\\${bin}.cmd" (
|
|
@@ -34,8 +35,8 @@ if exist "%~dp0..\\bin\\node.exe" (
|
|
|
34
35
|
// `)
|
|
35
36
|
};
|
|
36
37
|
const writeUnix = async () => {
|
|
37
|
-
const bin =
|
|
38
|
-
await
|
|
38
|
+
const bin = path.join(baseWorkspace, 'bin', config.bin);
|
|
39
|
+
await fs.promises.writeFile(bin, `#!/usr/bin/env bash
|
|
39
40
|
set -e
|
|
40
41
|
echoerr() { echo "$@" 1>&2; }
|
|
41
42
|
|
|
@@ -80,10 +81,8 @@ else
|
|
|
80
81
|
fi
|
|
81
82
|
"\$NODE" "\$DIR/run" "\$@"
|
|
82
83
|
fi
|
|
83
|
-
|
|
84
|
-
await qq.chmod(bin, 0o755);
|
|
84
|
+
`, { mode: 0o755 });
|
|
85
85
|
};
|
|
86
|
-
await writeWin32();
|
|
87
|
-
await writeUnix();
|
|
86
|
+
await Promise.all([writeWin32(), writeUnix()]);
|
|
88
87
|
}
|
|
89
88
|
exports.writeBinScripts = writeBinScripts;
|