oclif 3.11.3 → 3.13.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/bin/dev.cmd +1 -1
- package/bin/dev.js +6 -0
- package/bin/run.js +6 -0
- package/lib/aws.js +5 -1
- package/lib/commands/generate/command.d.ts +2 -2
- package/lib/commands/generate/command.js +3 -3
- package/lib/commands/generate/hook.d.ts +2 -2
- package/lib/commands/generate/hook.js +3 -3
- package/lib/commands/generate.d.ts +2 -2
- package/lib/commands/generate.js +3 -3
- package/lib/commands/manifest.js +14 -8
- package/lib/commands/pack/win.js +1 -0
- package/lib/commands/promote.js +35 -7
- package/lib/commands/readme.js +6 -6
- package/lib/commands/upload/deb.js +2 -2
- package/lib/commands/upload/macos.js +1 -1
- package/lib/commands/upload/tarballs.js +3 -3
- package/lib/commands/upload/win.js +1 -1
- package/lib/generators/cli.js +41 -8
- package/lib/generators/command.js +1 -1
- package/lib/upload-util.js +1 -1
- package/lib/util.d.ts +1 -0
- package/lib/util.js +8 -1
- package/lib/version-indexes.js +4 -1
- package/package.json +6 -6
- package/bin/dev +0 -18
- package/bin/run +0 -5
- package/lib/command-base.d.ts +0 -4
- package/lib/command-base.js +0 -14
package/.oclif.manifest.json
CHANGED
package/bin/dev.cmd
CHANGED
package/bin/dev.js
ADDED
package/bin/run.js
ADDED
package/lib/aws.js
CHANGED
|
@@ -20,7 +20,11 @@ const aws = {
|
|
|
20
20
|
},
|
|
21
21
|
get s3() {
|
|
22
22
|
try {
|
|
23
|
-
cache.s3 = cache.s3 || new (require('aws-sdk/clients/s3'))(
|
|
23
|
+
cache.s3 = cache.s3 || new (require('aws-sdk/clients/s3'))({
|
|
24
|
+
...this.creds,
|
|
25
|
+
endpoint: process.env.AWS_S3_ENDPOINT,
|
|
26
|
+
s3ForcePathStyle: Boolean(process.env.AWS_S3_FORCE_PATH_STYLE),
|
|
27
|
+
});
|
|
24
28
|
return cache.s3;
|
|
25
29
|
}
|
|
26
30
|
catch (error) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class GenerateCommand extends
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class GenerateCommand extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static flags: {
|
|
5
5
|
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const command_base_1 = require("./../../command-base");
|
|
4
3
|
const core_1 = require("@oclif/core");
|
|
5
|
-
|
|
4
|
+
const util_1 = require("../../util");
|
|
5
|
+
class GenerateCommand extends core_1.Command {
|
|
6
6
|
async run() {
|
|
7
7
|
const { args, flags } = await this.parse(GenerateCommand);
|
|
8
|
-
await
|
|
8
|
+
await (0, util_1.generate)('command', {
|
|
9
9
|
name: args.name,
|
|
10
10
|
force: flags.force,
|
|
11
11
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class GenerateHook extends
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
export default class GenerateHook extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static flags: {
|
|
5
5
|
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const command_base_1 = require("./../../command-base");
|
|
4
3
|
const core_1 = require("@oclif/core");
|
|
5
|
-
|
|
4
|
+
const util_1 = require("../../util");
|
|
5
|
+
class GenerateHook extends core_1.Command {
|
|
6
6
|
async run() {
|
|
7
7
|
const { args, flags } = await this.parse(GenerateHook);
|
|
8
|
-
await
|
|
8
|
+
await (0, util_1.generate)('hook', {
|
|
9
9
|
name: args.name,
|
|
10
10
|
event: flags.event,
|
|
11
11
|
force: flags.force,
|
package/lib/commands/generate.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const core_1 = require("@oclif/core");
|
|
4
|
-
const
|
|
5
|
-
class Generate extends
|
|
4
|
+
const util_1 = require("../util");
|
|
5
|
+
class Generate extends core_1.Command {
|
|
6
6
|
async run() {
|
|
7
7
|
const { args } = await this.parse(Generate);
|
|
8
|
-
await
|
|
8
|
+
await (0, util_1.generate)('cli', {
|
|
9
9
|
name: args.name,
|
|
10
10
|
force: true,
|
|
11
11
|
});
|
package/lib/commands/manifest.js
CHANGED
|
@@ -11,7 +11,7 @@ async function fileExists(filePath) {
|
|
|
11
11
|
await fs.access(filePath);
|
|
12
12
|
return true;
|
|
13
13
|
}
|
|
14
|
-
catch
|
|
14
|
+
catch {
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -22,7 +22,7 @@ class Manifest extends core_1.Command {
|
|
|
22
22
|
try {
|
|
23
23
|
fs.unlinkSync('oclif.manifest.json');
|
|
24
24
|
}
|
|
25
|
-
catch
|
|
25
|
+
catch { }
|
|
26
26
|
const { args } = await this.parse(Manifest);
|
|
27
27
|
const root = path.resolve(args.path);
|
|
28
28
|
const packageJson = fs.readJSONSync('package.json');
|
|
@@ -51,10 +51,16 @@ class Manifest extends core_1.Command {
|
|
|
51
51
|
jitPluginManifests = await Promise.all(promises);
|
|
52
52
|
core_1.ux.action.stop();
|
|
53
53
|
}
|
|
54
|
-
let plugin = new core_1.Plugin({
|
|
54
|
+
let plugin = new core_1.Plugin({
|
|
55
|
+
root,
|
|
56
|
+
type: 'core',
|
|
57
|
+
ignoreManifest: true,
|
|
58
|
+
errorOnManifestCreate: true,
|
|
59
|
+
respectNoCacheDefault: true,
|
|
60
|
+
});
|
|
55
61
|
if (!plugin)
|
|
56
62
|
throw new Error('plugin not found');
|
|
57
|
-
await plugin.load(
|
|
63
|
+
await plugin.load();
|
|
58
64
|
if (!plugin.valid) {
|
|
59
65
|
const p = require.resolve('@oclif/plugin-legacy', { paths: [process.cwd()] });
|
|
60
66
|
const { PluginLegacy } = require(p);
|
|
@@ -67,7 +73,7 @@ class Manifest extends core_1.Command {
|
|
|
67
73
|
const dotfile = plugin.pjson.files.find((f) => f.endsWith('.oclif.manifest.json'));
|
|
68
74
|
const file = path.join(plugin.root, `${dotfile ? '.' : ''}oclif.manifest.json`);
|
|
69
75
|
for (const manifest of jitPluginManifests) {
|
|
70
|
-
plugin.manifest.commands =
|
|
76
|
+
plugin.manifest.commands = { ...plugin.manifest.commands, ...manifest.commands };
|
|
71
77
|
}
|
|
72
78
|
fs.writeFileSync(file, JSON.stringify(plugin.manifest, null, 2));
|
|
73
79
|
this.log(`wrote manifest to ${file}`);
|
|
@@ -76,11 +82,11 @@ class Manifest extends core_1.Command {
|
|
|
76
82
|
try {
|
|
77
83
|
this.executeCommand(`git clone --branch ${tag} ${repoUrl} ${fullPath} --depth 1`);
|
|
78
84
|
}
|
|
79
|
-
catch
|
|
85
|
+
catch {
|
|
80
86
|
try {
|
|
81
87
|
this.executeCommand(`git clone --branch v${tag} ${repoUrl} ${fullPath} --depth 1`);
|
|
82
88
|
}
|
|
83
|
-
catch
|
|
89
|
+
catch {
|
|
84
90
|
throw new Error(`Unable to clone repo ${repoUrl} with tag ${tag}`);
|
|
85
91
|
}
|
|
86
92
|
}
|
|
@@ -88,7 +94,7 @@ class Manifest extends core_1.Command {
|
|
|
88
94
|
executeCommand(command, options) {
|
|
89
95
|
const debugString = (options === null || options === void 0 ? void 0 : options.cwd) ? `executing command: ${command} in ${options.cwd}` : `executing command: ${command}`;
|
|
90
96
|
this.debug(debugString);
|
|
91
|
-
const result = (0, shelljs_1.exec)(command,
|
|
97
|
+
const result = (0, shelljs_1.exec)(command, { ...options, silent: true, async: false });
|
|
92
98
|
if (result.code !== 0) {
|
|
93
99
|
this.error(result.stderr);
|
|
94
100
|
}
|
package/lib/commands/pack/win.js
CHANGED
|
@@ -287,6 +287,7 @@ async function signWindows(o, arch, config, windows) {
|
|
|
287
287
|
'-pass', pass,
|
|
288
288
|
'-n', `"${windows.name}"`,
|
|
289
289
|
'-i', windows.homepage || config.pjson.homepage,
|
|
290
|
+
'-t', 'http://timestamp.digicert.com',
|
|
290
291
|
'-h', 'sha512',
|
|
291
292
|
'-in', buildLocationUnsigned,
|
|
292
293
|
'-out', o,
|
package/lib/commands/promote.js
CHANGED
|
@@ -42,7 +42,11 @@ class Promote extends core_1.Command {
|
|
|
42
42
|
});
|
|
43
43
|
// strip version & sha so update/scripts can point to a static channel manifest
|
|
44
44
|
const unversionedManifest = manifest.replace(`-v${flags.version}-${flags.sha}`, '');
|
|
45
|
-
await aws_1.default.s3.copyObject(
|
|
45
|
+
await aws_1.default.s3.copyObject({
|
|
46
|
+
...awsDefaults,
|
|
47
|
+
CopySource: cloudBucketCommitKey(manifest),
|
|
48
|
+
Key: cloudChannelKey(unversionedManifest),
|
|
49
|
+
});
|
|
46
50
|
};
|
|
47
51
|
const promoteGzTarballs = async (target) => {
|
|
48
52
|
const versionedTarGzName = (0, upload_util_1.templateShortKey)('versioned', '.tar.gz', {
|
|
@@ -56,7 +60,11 @@ class Promote extends core_1.Command {
|
|
|
56
60
|
// strip version & sha so update/scripts can point to a static channel tarball
|
|
57
61
|
const unversionedTarGzName = versionedTarGzName.replace(`-v${flags.version}-${flags.sha}`, '');
|
|
58
62
|
const unversionedTarGzKey = cloudChannelKey(unversionedTarGzName);
|
|
59
|
-
await Promise.all([aws_1.default.s3.copyObject(
|
|
63
|
+
await Promise.all([aws_1.default.s3.copyObject({
|
|
64
|
+
...awsDefaults,
|
|
65
|
+
CopySource: versionedTarGzKey,
|
|
66
|
+
Key: unversionedTarGzKey,
|
|
67
|
+
})].concat(flags.indexes ? [(0, version_indexes_1.appendToIndex)({ ...indexDefaults, originalUrl: versionedTarGzKey, filename: unversionedTarGzName })] : []));
|
|
60
68
|
};
|
|
61
69
|
const promoteXzTarballs = async (target) => {
|
|
62
70
|
const versionedTarXzName = (0, upload_util_1.templateShortKey)('versioned', '.tar.xz', {
|
|
@@ -70,7 +78,11 @@ class Promote extends core_1.Command {
|
|
|
70
78
|
// strip version & sha so update/scripts can point to a static channel tarball
|
|
71
79
|
const unversionedTarXzName = versionedTarXzName.replace(`-v${flags.version}-${flags.sha}`, '');
|
|
72
80
|
const unversionedTarXzKey = cloudChannelKey(unversionedTarXzName);
|
|
73
|
-
await Promise.all([aws_1.default.s3.copyObject(
|
|
81
|
+
await Promise.all([aws_1.default.s3.copyObject({
|
|
82
|
+
...awsDefaults,
|
|
83
|
+
CopySource: versionedTarXzKey,
|
|
84
|
+
Key: unversionedTarXzKey,
|
|
85
|
+
})].concat(flags.indexes ? [(0, version_indexes_1.appendToIndex)({ ...indexDefaults, originalUrl: versionedTarXzKey, filename: unversionedTarXzName })] : []));
|
|
74
86
|
};
|
|
75
87
|
const promoteMacInstallers = async () => {
|
|
76
88
|
this.log(`Promoting macos pkgs to ${flags.channel}`);
|
|
@@ -80,7 +92,11 @@ class Promote extends core_1.Command {
|
|
|
80
92
|
const darwinCopySource = cloudBucketCommitKey(darwinPkg);
|
|
81
93
|
// strip version & sha so scripts can point to a static channel pkg
|
|
82
94
|
const unversionedPkg = darwinPkg.replace(`-v${flags.version}-${flags.sha}`, '');
|
|
83
|
-
await Promise.all([aws_1.default.s3.copyObject(
|
|
95
|
+
await Promise.all([aws_1.default.s3.copyObject({
|
|
96
|
+
...awsDefaults,
|
|
97
|
+
CopySource: darwinCopySource,
|
|
98
|
+
Key: cloudChannelKey(unversionedPkg),
|
|
99
|
+
})].concat(flags.indexes ? [(0, version_indexes_1.appendToIndex)({ ...indexDefaults, originalUrl: darwinCopySource, filename: unversionedPkg })] : []));
|
|
84
100
|
}));
|
|
85
101
|
};
|
|
86
102
|
const promoteWindowsInstallers = async () => {
|
|
@@ -92,7 +108,11 @@ class Promote extends core_1.Command {
|
|
|
92
108
|
const winCopySource = cloudBucketCommitKey(winPkg);
|
|
93
109
|
// strip version & sha so scripts can point to a static channel exe
|
|
94
110
|
const unversionedExe = winPkg.replace(`-v${flags.version}-${flags.sha}`, '');
|
|
95
|
-
await Promise.all([aws_1.default.s3.copyObject(
|
|
111
|
+
await Promise.all([aws_1.default.s3.copyObject({
|
|
112
|
+
...awsDefaults,
|
|
113
|
+
CopySource: winCopySource,
|
|
114
|
+
Key: cloudChannelKey(unversionedExe),
|
|
115
|
+
})].concat(flags.indexes ? [(0, version_indexes_1.appendToIndex)({ ...indexDefaults, originalUrl: winCopySource, filename: unversionedExe })] : []));
|
|
96
116
|
core_1.ux.action.stop('successfully');
|
|
97
117
|
}));
|
|
98
118
|
};
|
|
@@ -128,8 +148,16 @@ class Promote extends core_1.Command {
|
|
|
128
148
|
// with this, the docs are correct. The copies are all done in parallel so it shouldn't be too costly.
|
|
129
149
|
const workaroundKey = cloudChannelKey(`apt/./${artifact}`);
|
|
130
150
|
return [
|
|
131
|
-
aws_1.default.s3.copyObject(
|
|
132
|
-
|
|
151
|
+
aws_1.default.s3.copyObject({
|
|
152
|
+
...awsDefaults,
|
|
153
|
+
CopySource: debCopySource,
|
|
154
|
+
Key: debKey,
|
|
155
|
+
}),
|
|
156
|
+
aws_1.default.s3.copyObject({
|
|
157
|
+
...awsDefaults,
|
|
158
|
+
CopySource: debCopySource,
|
|
159
|
+
Key: workaroundKey,
|
|
160
|
+
}),
|
|
133
161
|
];
|
|
134
162
|
}));
|
|
135
163
|
};
|
package/lib/commands/readme.js
CHANGED
|
@@ -21,16 +21,16 @@ class Readme extends core_1.Command {
|
|
|
21
21
|
const p = require.resolve('@oclif/plugin-legacy', { paths: [cwd] });
|
|
22
22
|
const plugin = new core_1.Plugin({ root: p, type: 'core' });
|
|
23
23
|
await plugin.load();
|
|
24
|
-
config.plugins.
|
|
24
|
+
config.plugins.set(plugin.name, plugin);
|
|
25
25
|
}
|
|
26
|
-
catch
|
|
26
|
+
catch { }
|
|
27
27
|
await config.runHook('init', { id: 'readme', argv: this.argv });
|
|
28
28
|
this.HelpClass = await (0, core_1.loadHelpClass)(config);
|
|
29
29
|
let readme = await fs.readFile(readmePath, 'utf8');
|
|
30
30
|
let commands = config.commands
|
|
31
31
|
.filter(c => !c.hidden && c.pluginType === 'core')
|
|
32
32
|
.filter(c => flags.aliases ? true : !c.aliases.includes(c.id))
|
|
33
|
-
.map(c => c.id === '.' ?
|
|
33
|
+
.map(c => c.id === '.' ? { ...c, id: '' } : c);
|
|
34
34
|
this.debug('commands:', commands.map(c => c.id).length);
|
|
35
35
|
commands = (0, util_1.uniqBy)(commands, c => c.id);
|
|
36
36
|
commands = (0, util_1.sortBy)(commands, c => c.id);
|
|
@@ -127,7 +127,7 @@ USAGE
|
|
|
127
127
|
try {
|
|
128
128
|
// copy c to keep the command ID with colons, see:
|
|
129
129
|
// https://github.com/oclif/oclif/pull/1165#discussion_r1282305242
|
|
130
|
-
const command =
|
|
130
|
+
const command = { ...c };
|
|
131
131
|
return (0, util_1.compact)([
|
|
132
132
|
header(),
|
|
133
133
|
title,
|
|
@@ -143,7 +143,7 @@ USAGE
|
|
|
143
143
|
const pluginName = c.pluginName;
|
|
144
144
|
if (!pluginName)
|
|
145
145
|
return;
|
|
146
|
-
const plugin = config.plugins.
|
|
146
|
+
const plugin = config.plugins.get(pluginName);
|
|
147
147
|
if (!plugin)
|
|
148
148
|
return;
|
|
149
149
|
const repo = this.repo(plugin);
|
|
@@ -162,7 +162,7 @@ USAGE
|
|
|
162
162
|
return `_See code: [${label}](${_.template(template)({ repo, version, commandPath, config, c })})_`;
|
|
163
163
|
}
|
|
164
164
|
repo(plugin) {
|
|
165
|
-
const pjson =
|
|
165
|
+
const pjson = { ...plugin.pjson };
|
|
166
166
|
normalize(pjson);
|
|
167
167
|
const repo = pjson.repository && pjson.repository.url;
|
|
168
168
|
if (!repo)
|
|
@@ -24,7 +24,7 @@ class UploadDeb extends core_1.Command {
|
|
|
24
24
|
const cloudKeyBase = (0, upload_util_1.commitAWSDir)(config.pjson.version, buildConfig.gitSha, s3Config);
|
|
25
25
|
const upload = (file) => {
|
|
26
26
|
const cloudKey = `${cloudKeyBase}/apt/${file}`;
|
|
27
|
-
return aws_1.default.s3.uploadFile(dist(file),
|
|
27
|
+
return aws_1.default.s3.uploadFile(dist(file), { ...S3Options, CacheControl: 'max-age=86400', Key: cloudKey });
|
|
28
28
|
};
|
|
29
29
|
// apt expects ../apt/dists/versionName/[artifacts] but oclif wants versions/sha/apt/[artifacts]
|
|
30
30
|
// see https://github.com/oclif/oclif/issues/347 for the AWS-redirect that solves this
|
|
@@ -32,7 +32,7 @@ class UploadDeb extends core_1.Command {
|
|
|
32
32
|
// with this, the docs are correct. The copies are all done in parallel so it shouldn't be too costly.
|
|
33
33
|
const uploadWorkaround = (file) => {
|
|
34
34
|
const cloudKey = `${cloudKeyBase}/apt/./${file}`;
|
|
35
|
-
return aws_1.default.s3.uploadFile(dist(file),
|
|
35
|
+
return aws_1.default.s3.uploadFile(dist(file), { ...S3Options, CacheControl: 'max-age=86400', Key: cloudKey });
|
|
36
36
|
};
|
|
37
37
|
const uploadDeb = async (arch) => {
|
|
38
38
|
const deb = (0, upload_util_1.templateShortKey)('deb', { bin: config.bin, versionShaRevision: (0, upload_util_1.debVersion)(buildConfig), arch: arch });
|
|
@@ -23,7 +23,7 @@ class UploadMacos extends core_1.Command {
|
|
|
23
23
|
const cloudKey = `${cloudKeyBase}/${templateKey}`;
|
|
24
24
|
const localPkg = dist(`macos/${templateKey}`);
|
|
25
25
|
if (fs.existsSync(localPkg))
|
|
26
|
-
await aws_1.default.s3.uploadFile(localPkg,
|
|
26
|
+
await aws_1.default.s3.uploadFile(localPkg, { ...S3Options, CacheControl: 'max-age=86400', Key: cloudKey });
|
|
27
27
|
else
|
|
28
28
|
this.error('Cannot find macOS pkg', {
|
|
29
29
|
suggestions: ['Run "oclif pack macos" before uploading'],
|
|
@@ -16,7 +16,7 @@ class UploadTarballs extends core_1.Command {
|
|
|
16
16
|
const { s3Config, dist, config, xz } = buildConfig;
|
|
17
17
|
// fail early if targets are not built
|
|
18
18
|
for (const target of buildConfig.targets) {
|
|
19
|
-
const tarball = dist((0, upload_util_1.templateShortKey)('versioned',
|
|
19
|
+
const tarball = dist((0, upload_util_1.templateShortKey)('versioned', { ext: '.tar.gz', bin: config.bin, version: config.version, sha: buildConfig.gitSha, ...target }));
|
|
20
20
|
if (!fs.existsSync(tarball))
|
|
21
21
|
this.error(`Cannot find a tarball ${tarball} for ${target.platform}-${target.arch}`, {
|
|
22
22
|
suggestions: [`Run "oclif pack --target ${target.platform}-${target.arch}" before uploading`],
|
|
@@ -39,11 +39,11 @@ class UploadTarballs extends core_1.Command {
|
|
|
39
39
|
const releaseTarballs = async (ext) => {
|
|
40
40
|
const localKey = (0, upload_util_1.templateShortKey)('versioned', ext, shortKeyInputs);
|
|
41
41
|
const cloudKey = `${(0, upload_util_1.commitAWSDir)(config.version, buildConfig.gitSha, s3Config)}/${localKey}`;
|
|
42
|
-
await aws_1.default.s3.uploadFile(dist(localKey),
|
|
42
|
+
await aws_1.default.s3.uploadFile(dist(localKey), { ...S3Options, CacheControl: 'max-age=604800', ContentType: 'application/gzip', Key: cloudKey });
|
|
43
43
|
};
|
|
44
44
|
const manifest = (0, upload_util_1.templateShortKey)('manifest', shortKeyInputs);
|
|
45
45
|
const cloudKey = `${(0, upload_util_1.commitAWSDir)(config.version, buildConfig.gitSha, s3Config)}/${manifest}`;
|
|
46
|
-
await Promise.all([releaseTarballs('.tar.gz'), aws_1.default.s3.uploadFile(dist(manifest),
|
|
46
|
+
await Promise.all([releaseTarballs('.tar.gz'), aws_1.default.s3.uploadFile(dist(manifest), { ...S3Options, CacheControl: 'max-age=86400', ContentType: 'application/json', Key: cloudKey })].concat(xz ? [releaseTarballs('.tar.xz')] : []));
|
|
47
47
|
};
|
|
48
48
|
if (buildConfig.targets.length > 0)
|
|
49
49
|
(0, log_1.log)('uploading targets');
|
|
@@ -30,7 +30,7 @@ class UploadWin extends core_1.Command {
|
|
|
30
30
|
const localExe = dist(`win32/${templateKey}`);
|
|
31
31
|
const cloudKey = `${cloudKeyBase}/${templateKey}`;
|
|
32
32
|
if (fs.existsSync(localExe))
|
|
33
|
-
await aws_1.default.s3.uploadFile(localExe,
|
|
33
|
+
await aws_1.default.s3.uploadFile(localExe, { ...S3Options, CacheControl: 'max-age=86400', Key: cloudKey });
|
|
34
34
|
};
|
|
35
35
|
await Promise.all([uploadWin('x64'), uploadWin('x86')]);
|
|
36
36
|
(0, log_1.log)(`done uploading windows executables for v${config.version}-${buildConfig.gitSha}`);
|
package/lib/generators/cli.js
CHANGED
|
@@ -12,7 +12,7 @@ try {
|
|
|
12
12
|
(0, child_process_1.execSync)('yarn -v', { stdio: 'ignore' });
|
|
13
13
|
hasYarn = true;
|
|
14
14
|
}
|
|
15
|
-
catch
|
|
15
|
+
catch { }
|
|
16
16
|
class CLI extends Generator {
|
|
17
17
|
constructor(args, opts) {
|
|
18
18
|
super(args, opts);
|
|
@@ -23,11 +23,10 @@ class CLI extends Generator {
|
|
|
23
23
|
yarn: hasYarn,
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
// eslint-disable-next-line complexity
|
|
27
26
|
async prompting() {
|
|
28
27
|
const msg = 'Time to build an oclif CLI!';
|
|
29
28
|
this.log(`${msg} Version: ${version}`);
|
|
30
|
-
const { moduleType } =
|
|
29
|
+
const { moduleType } = await this.prompt([
|
|
31
30
|
{
|
|
32
31
|
type: 'list',
|
|
33
32
|
name: 'moduleType',
|
|
@@ -38,7 +37,7 @@ class CLI extends Generator {
|
|
|
38
37
|
],
|
|
39
38
|
default: 'cjs',
|
|
40
39
|
},
|
|
41
|
-
])
|
|
40
|
+
]);
|
|
42
41
|
const repo = moduleType === 'esm' ? 'hello-world-esm' : 'hello-world';
|
|
43
42
|
(0, child_process_1.execSync)(`git clone https://github.com/oclif/${repo}.git "${path.resolve(this.name)}" --depth=1`);
|
|
44
43
|
fs.rmSync(`${path.resolve(this.name, '.git')}`, { recursive: true });
|
|
@@ -46,11 +45,41 @@ class CLI extends Generator {
|
|
|
46
45
|
this.env.cwd = this.destinationPath();
|
|
47
46
|
this.githubUser = await this.user.github.username().catch(debug);
|
|
48
47
|
// establish order of properties in the resulting package.json
|
|
49
|
-
this.pjson =
|
|
48
|
+
this.pjson = {
|
|
49
|
+
name: '',
|
|
50
|
+
version: '',
|
|
51
|
+
description: '',
|
|
52
|
+
author: '',
|
|
53
|
+
bin: {},
|
|
54
|
+
homepage: '',
|
|
55
|
+
license: '',
|
|
56
|
+
main: '',
|
|
57
|
+
repository: '',
|
|
58
|
+
files: [],
|
|
59
|
+
dependencies: {},
|
|
60
|
+
devDependencies: {},
|
|
61
|
+
oclif: {},
|
|
62
|
+
scripts: {},
|
|
63
|
+
engines: {},
|
|
64
|
+
...this.fs.readJSON(path.join(this.env.cwd, 'package.json'), {}),
|
|
65
|
+
};
|
|
50
66
|
let repository = this.destinationRoot().split(path.sep).slice(-2).join('/');
|
|
51
67
|
if (this.githubUser)
|
|
52
68
|
repository = `${this.githubUser}/${repository.split('/')[1]}`;
|
|
53
|
-
const defaults =
|
|
69
|
+
const defaults = {
|
|
70
|
+
...this.pjson,
|
|
71
|
+
name: this.name ? this.name.replace(/ /g, '-') : this.determineAppname().replace(/ /g, '-'),
|
|
72
|
+
version: '0.0.0',
|
|
73
|
+
license: 'MIT',
|
|
74
|
+
author: this.githubUser ? `${this.user.git.name()} @${this.githubUser}` : this.user.git.name(),
|
|
75
|
+
dependencies: {},
|
|
76
|
+
repository,
|
|
77
|
+
engines: {
|
|
78
|
+
node: '>=12.0.0',
|
|
79
|
+
...this.pjson.engines,
|
|
80
|
+
},
|
|
81
|
+
options: this.options,
|
|
82
|
+
};
|
|
54
83
|
this.repository = defaults.repository;
|
|
55
84
|
if (this.repository && this.repository.url) {
|
|
56
85
|
this.repository = this.repository.url;
|
|
@@ -123,7 +152,11 @@ class CLI extends Generator {
|
|
|
123
152
|
}
|
|
124
153
|
debug(this.answers);
|
|
125
154
|
if (!this.options.defaults) {
|
|
126
|
-
this.options =
|
|
155
|
+
this.options = {
|
|
156
|
+
...this.answers.ci,
|
|
157
|
+
yarn: this.answers.pkg === 'yarn',
|
|
158
|
+
force: true,
|
|
159
|
+
};
|
|
127
160
|
}
|
|
128
161
|
this.yarn = this.options.yarn;
|
|
129
162
|
this.env.options.nodePackageManager = this.yarn ? 'yarn' : 'npm';
|
|
@@ -166,7 +199,7 @@ class CLI extends Generator {
|
|
|
166
199
|
// this in a spawned process. Setting the NODE_ENV to production will silence these warnings. This
|
|
167
200
|
// doesn't affect the behavior of the command in production since the NODE_ENV is already set to production
|
|
168
201
|
// in that scenario.
|
|
169
|
-
env:
|
|
202
|
+
env: { ...process.env, NODE_ENV: 'production' },
|
|
170
203
|
});
|
|
171
204
|
console.log(`\nCreated ${this.pjson.name} in ${this.destinationRoot()}`);
|
|
172
205
|
}
|
|
@@ -32,7 +32,7 @@ class Command extends Generator {
|
|
|
32
32
|
bin = bin.split('/').pop();
|
|
33
33
|
const cmd = `${bin} ${this.options.name}`;
|
|
34
34
|
const commandPath = this.destinationPath(`src/commands/${cmdPath}.ts`);
|
|
35
|
-
const opts =
|
|
35
|
+
const opts = { ...this.options, bin, cmd, _, type: 'command', path: commandPath };
|
|
36
36
|
this.fs.copyTpl(this.templatePath('src/command.ts.ejs'), commandPath, opts);
|
|
37
37
|
if (this.hasMocha()) {
|
|
38
38
|
this.fs.copyTpl(this.templatePath('test/command.test.ts.ejs'), this.destinationPath(`test/commands/${cmdPath}.test.ts`), opts);
|
package/lib/upload-util.js
CHANGED
|
@@ -37,7 +37,7 @@ options = { root: '.' }) {
|
|
|
37
37
|
win32: '<%- bin %>-v<%- version %>-<%- sha %>-<%- arch %>.exe',
|
|
38
38
|
deb: '<%- bin %>_<%- versionShaRevision %>_<%- arch %>.deb',
|
|
39
39
|
};
|
|
40
|
-
return _.template(templates[type])(
|
|
40
|
+
return _.template(templates[type])({ ...options });
|
|
41
41
|
}
|
|
42
42
|
exports.templateShortKey = templateShortKey;
|
|
43
43
|
function debArch(arch) {
|
package/lib/util.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare function generate(type: string, generatorOptions?: Record<string, unknown>): Promise<void>;
|
|
1
2
|
export declare function castArray<T>(input?: T | T[]): T[];
|
|
2
3
|
export declare function uniqBy<T>(arr: T[], fn: (cur: T) => any): T[];
|
|
3
4
|
export declare function compact<T>(a: (T | undefined)[]): T[];
|
package/lib/util.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hash = exports.prettifyPaths = exports.sortVersionsObjectByKeysDesc = exports.template = exports.sortBy = exports.compact = exports.uniqBy = exports.castArray = void 0;
|
|
3
|
+
exports.hash = exports.prettifyPaths = exports.sortVersionsObjectByKeysDesc = exports.template = exports.sortBy = exports.compact = exports.uniqBy = exports.castArray = exports.generate = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const os = require("os");
|
|
6
6
|
const crypto = require("node:crypto");
|
|
7
7
|
const log_1 = require("./log");
|
|
8
8
|
const fs = require("fs-extra");
|
|
9
|
+
const yeoman_environment_1 = require("yeoman-environment");
|
|
10
|
+
async function generate(type, generatorOptions = {}) {
|
|
11
|
+
const env = (0, yeoman_environment_1.createEnv)();
|
|
12
|
+
env.register(require.resolve(`./generators/${type}`), `oclif:${type}`);
|
|
13
|
+
return env.run(`oclif:${type}`, generatorOptions);
|
|
14
|
+
}
|
|
15
|
+
exports.generate = generate;
|
|
9
16
|
function castArray(input) {
|
|
10
17
|
if (input === undefined)
|
|
11
18
|
return [];
|
package/lib/version-indexes.js
CHANGED
|
@@ -59,7 +59,10 @@ const appendToIndex = async (input) => {
|
|
|
59
59
|
debug(`error on ${key}`, error);
|
|
60
60
|
}
|
|
61
61
|
// appends new version from this promotion if not already present (idempotent)
|
|
62
|
-
await fs.writeJSON(jsonFileName, sortVersionsObjectByKeysDesc(
|
|
62
|
+
await fs.writeJSON(jsonFileName, sortVersionsObjectByKeysDesc({
|
|
63
|
+
...existing,
|
|
64
|
+
[version]: originalUrl.replace(s3Config.bucket, s3Config.host),
|
|
65
|
+
}, s3Config.indexVersionLimit), { spaces: 2 });
|
|
63
66
|
// put the file back in the same place
|
|
64
67
|
await aws_1.default.s3.uploadFile(jsonFileName, {
|
|
65
68
|
Bucket: s3Config.bucket,
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oclif",
|
|
3
3
|
"description": "oclif: create your own CLI",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.13.0",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bin": {
|
|
7
|
-
"oclif": "bin/run"
|
|
7
|
+
"oclif": "bin/run.js"
|
|
8
8
|
},
|
|
9
9
|
"bugs": "https://github.com/oclif/oclif/issues",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@oclif/core": "^
|
|
11
|
+
"@oclif/core": "^3.0.0-beta.4",
|
|
12
12
|
"@oclif/plugin-help": "^5.2.14",
|
|
13
13
|
"@oclif/plugin-not-found": "^2.3.32",
|
|
14
14
|
"@oclif/plugin-warn-if-update-available": "^2.0.44",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@types/yeoman-generator": "^5.2.11",
|
|
43
43
|
"chai": "^4.3.7",
|
|
44
44
|
"conventional-changelog-cli": "^2.2.2",
|
|
45
|
-
"eslint": "^
|
|
45
|
+
"eslint": "^8.47.0",
|
|
46
46
|
"eslint-config-oclif": "^4.0.0",
|
|
47
47
|
"eslint-config-oclif-typescript": "^1.0.2",
|
|
48
48
|
"fancy-test": "^1.4.10",
|
|
@@ -124,11 +124,11 @@
|
|
|
124
124
|
"lint": "nps lint",
|
|
125
125
|
"postpack": "shx rm .oclif.manifest.json",
|
|
126
126
|
"posttest": "yarn run lint",
|
|
127
|
-
"prepack": "shx rm -rf lib && tsc && bin/dev manifest .",
|
|
127
|
+
"prepack": "shx rm -rf lib && tsc && bin/dev.js manifest .",
|
|
128
128
|
"test": "nps test && yarn test:unit && yarn test:integration",
|
|
129
129
|
"test:integration": "mocha --forbid-only \"test/integration/*.test.ts\"",
|
|
130
130
|
"test:unit": "mocha --forbid-only \"test/unit/*.test.ts\"",
|
|
131
|
-
"version": "bin/dev readme && git add README.md"
|
|
131
|
+
"version": "bin/dev.js readme && git add README.md"
|
|
132
132
|
},
|
|
133
133
|
"publishConfig": {
|
|
134
134
|
"registry": "https://registry.npmjs.org"
|
package/bin/dev
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const oclif = require('@oclif/core')
|
|
4
|
-
|
|
5
|
-
const path = require('path')
|
|
6
|
-
const project = path.join(__dirname, '..', 'tsconfig.json')
|
|
7
|
-
|
|
8
|
-
// In dev mode -> use ts-node and dev plugins
|
|
9
|
-
process.env.NODE_ENV = 'development'
|
|
10
|
-
|
|
11
|
-
require('ts-node').register({project})
|
|
12
|
-
|
|
13
|
-
// In dev mode, always show stack traces
|
|
14
|
-
oclif.settings.debug = true;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// Start the CLI
|
|
18
|
-
oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
|
package/bin/run
DELETED
package/lib/command-base.d.ts
DELETED
package/lib/command-base.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@oclif/core");
|
|
4
|
-
const yeoman_environment_1 = require("yeoman-environment");
|
|
5
|
-
class CommandBase extends core_1.Command {
|
|
6
|
-
async generate(type, generatorOptions = {}) {
|
|
7
|
-
const env = (0, yeoman_environment_1.createEnv)();
|
|
8
|
-
env.register(require.resolve(`./generators/${type}`), `oclif:${type}`);
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
await env.run(`oclif:${type}`, generatorOptions);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.default = CommandBase;
|