oclif 2.0.0-main.9 → 2.0.0-master.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/CHANGELOG.md +5 -58
- package/README.md +97 -224
- package/bin/run +2 -5
- package/lib/app-command.d.ts +12 -0
- package/lib/app-command.js +26 -0
- package/lib/aws.d.ts +5 -5
- package/lib/aws.js +5 -5
- package/lib/command-base.d.ts +2 -2
- package/lib/command-base.js +3 -3
- package/lib/commands/base.d.ts +5 -0
- package/lib/commands/base.js +11 -0
- package/lib/commands/command.d.ts +17 -0
- package/lib/commands/command.js +23 -0
- package/lib/commands/hook.d.ts +18 -0
- package/lib/commands/hook.js +25 -0
- package/lib/commands/manifest.d.ts +2 -1
- package/lib/commands/manifest.js +7 -4
- package/lib/commands/multi.d.ts +5 -0
- package/lib/commands/multi.js +11 -0
- package/lib/commands/pack/deb.d.ts +3 -3
- package/lib/commands/pack/deb.js +12 -11
- package/lib/commands/pack/macos.d.ts +3 -4
- package/lib/commands/pack/macos.js +13 -19
- package/lib/commands/pack/tarballs.d.ts +3 -6
- package/lib/commands/pack/tarballs.js +7 -6
- package/lib/commands/pack/win.d.ts +3 -4
- package/lib/commands/pack/win.js +16 -28
- package/lib/commands/plugin.d.ts +5 -0
- package/lib/commands/plugin.js +11 -0
- package/lib/commands/promote.d.ts +3 -14
- package/lib/commands/promote.js +28 -27
- package/lib/commands/readme.d.ts +11 -13
- package/lib/commands/readme.js +36 -35
- package/lib/commands/single.d.ts +5 -0
- package/lib/commands/single.js +11 -0
- package/lib/commands/upload/deb.d.ts +3 -2
- package/lib/commands/upload/deb.js +9 -8
- package/lib/commands/upload/macos.d.ts +3 -2
- package/lib/commands/upload/macos.js +9 -8
- package/lib/commands/upload/tarballs.d.ts +3 -7
- package/lib/commands/upload/tarballs.js +20 -19
- package/lib/commands/upload/win.d.ts +3 -2
- package/lib/commands/upload/win.js +11 -10
- package/lib/generators/{cli.d.ts → app.d.ts} +21 -1
- package/lib/generators/app.js +459 -0
- package/lib/generators/command.d.ts +15 -0
- package/lib/generators/command.js +51 -0
- package/lib/generators/hook.d.ts +14 -0
- package/lib/generators/hook.js +51 -0
- package/lib/help-compatibility.d.ts +5 -4
- package/lib/help-compatibility.js +0 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -3
- package/lib/log.js +2 -3
- package/lib/tarballs/bin.d.ts +2 -2
- package/lib/tarballs/bin.js +1 -2
- package/lib/tarballs/build.js +28 -29
- package/lib/tarballs/config.d.ts +7 -6
- package/lib/tarballs/config.js +7 -6
- package/lib/tarballs/index.js +4 -4
- package/lib/tarballs/node.js +4 -5
- package/lib/upload-util.d.ts +3 -3
- package/lib/upload-util.js +1 -2
- package/lib/util.js +24 -27
- package/lib/version-indexes.d.ts +4 -2
- package/lib/version-indexes.js +5 -7
- package/package.json +24 -23
- package/templates/LICENSE.mit +21 -0
- package/templates/README.md.ejs +21 -0
- package/templates/appveyor.yml.ejs +33 -0
- package/templates/base/src/index.js +1 -0
- package/templates/base/src/index.ts +1 -0
- package/templates/base/test/index.test.js +8 -0
- package/templates/base/test/index.test.ts +9 -0
- package/templates/bin/run +5 -0
- package/templates/bin/run.cmd +3 -0
- package/templates/circle.yml.ejs +65 -0
- package/templates/editorconfig +11 -0
- package/templates/eslintrc +7 -0
- package/templates/eslintrc.typescript +10 -0
- package/templates/multi/src/index.js +1 -0
- package/templates/multi/src/index.ts +1 -0
- package/templates/plugin/bin/run +4 -0
- package/templates/plugin/src/index.ts +1 -0
- package/templates/scripts/setup_git +12 -0
- package/templates/single/bin/run.js +4 -0
- package/templates/single/bin/run.ts +13 -0
- package/templates/src/command.js.ejs +27 -0
- package/templates/src/command.ts.ejs +46 -0
- package/templates/src/hook.js.ejs +3 -0
- package/templates/src/hook.ts.ejs +7 -0
- package/templates/test/command.test.js.ejs +28 -0
- package/templates/test/command.test.ts.ejs +29 -0
- package/templates/test/hook.test.js.ejs +9 -0
- package/templates/test/hook.test.ts.ejs +9 -0
- package/templates/test/mocha.opts +4 -0
- package/templates/test/tsconfig.json +9 -0
- package/templates/travis.yml.ejs +14 -0
- package/templates/tsconfig.json +15 -0
- package/bin/dev +0 -19
- package/bin/dev.cmd +0 -3
- package/lib/commands/generate.d.ts +0 -11
- package/lib/commands/generate.js +0 -19
- package/lib/generators/cli.js +0 -183
package/lib/aws.js
CHANGED
|
@@ -38,12 +38,12 @@ exports.default = {
|
|
|
38
38
|
get cloudfront() {
|
|
39
39
|
return {
|
|
40
40
|
createCloudfrontInvalidation: (options) => new Promise((resolve, reject) => {
|
|
41
|
-
|
|
41
|
+
log_1.log('createCloudfrontInvalidation', options.DistributionId, options.InvalidationBatch.Paths.Items);
|
|
42
42
|
aws.cloudfront.createInvalidation(options, err => {
|
|
43
43
|
if (err)
|
|
44
44
|
reject(err);
|
|
45
45
|
else
|
|
46
|
-
resolve(
|
|
46
|
+
resolve();
|
|
47
47
|
});
|
|
48
48
|
}),
|
|
49
49
|
};
|
|
@@ -51,13 +51,13 @@ exports.default = {
|
|
|
51
51
|
get s3() {
|
|
52
52
|
return {
|
|
53
53
|
uploadFile: (local, options) => new Promise((resolve, reject) => {
|
|
54
|
-
|
|
54
|
+
log_1.log('s3:uploadFile', qq.prettifyPaths(local), `s3://${options.Bucket}/${options.Key}`);
|
|
55
55
|
options.Body = fs.createReadStream(local);
|
|
56
56
|
aws.s3.upload(options, err => {
|
|
57
57
|
if (err)
|
|
58
58
|
reject(err);
|
|
59
59
|
else
|
|
60
|
-
resolve(
|
|
60
|
+
resolve();
|
|
61
61
|
});
|
|
62
62
|
}),
|
|
63
63
|
headObject: (options) => new Promise((resolve, reject) => {
|
|
@@ -70,7 +70,7 @@ exports.default = {
|
|
|
70
70
|
});
|
|
71
71
|
}),
|
|
72
72
|
copyObject: (options) => new Promise((resolve, reject) => {
|
|
73
|
-
|
|
73
|
+
log_1.log('s3:copyObject', `from s3://${options.CopySource}`, `to s3://${options.Bucket}/${options.Key}`);
|
|
74
74
|
aws.s3.copyObject(options, function (err, data) {
|
|
75
75
|
if (err)
|
|
76
76
|
reject(err);
|
package/lib/command-base.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Command from '@oclif/command';
|
|
2
2
|
export default abstract class CommandBase extends Command {
|
|
3
|
-
protected generate(type: string, generatorOptions?:
|
|
3
|
+
protected generate(type: string, generatorOptions?: {}): Promise<void>;
|
|
4
4
|
}
|
package/lib/command-base.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const command_1 = require("@oclif/command");
|
|
4
4
|
const yeoman_environment_1 = require("yeoman-environment");
|
|
5
|
-
class CommandBase extends
|
|
5
|
+
class CommandBase extends command_1.default {
|
|
6
6
|
async generate(type, generatorOptions = {}) {
|
|
7
|
-
const env =
|
|
7
|
+
const env = yeoman_environment_1.createEnv();
|
|
8
8
|
env.register(require.resolve(`./generators/${type}`), `oclif:${type}`);
|
|
9
9
|
await new Promise((resolve, reject) => {
|
|
10
10
|
env.run(`oclif:${type}`, generatorOptions, ((err, results) => {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const app_command_1 = require("../app-command");
|
|
4
|
+
class default_1 extends app_command_1.default {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.type = 'base';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.default = default_1;
|
|
11
|
+
default_1.hidden = true;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
2
|
+
import Base from '../command-base';
|
|
3
|
+
export interface Options {
|
|
4
|
+
name: string;
|
|
5
|
+
defaults?: boolean;
|
|
6
|
+
force?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export default abstract class AppCommand extends Base {
|
|
9
|
+
static description: string;
|
|
10
|
+
static flags: flags.Input<any>;
|
|
11
|
+
static args: {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
required: boolean;
|
|
15
|
+
}[];
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const command_1 = require("@oclif/command");
|
|
4
|
+
const command_base_1 = require("../command-base");
|
|
5
|
+
class AppCommand extends command_base_1.default {
|
|
6
|
+
async run() {
|
|
7
|
+
const { flags, args } = this.parse(AppCommand);
|
|
8
|
+
await super.generate('command', {
|
|
9
|
+
name: args.name,
|
|
10
|
+
defaults: flags.defaults,
|
|
11
|
+
force: flags.force,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.default = AppCommand;
|
|
16
|
+
AppCommand.description = 'add a command to an existing CLI or plugin';
|
|
17
|
+
AppCommand.flags = {
|
|
18
|
+
defaults: command_1.flags.boolean({ description: 'use defaults for every setting' }),
|
|
19
|
+
force: command_1.flags.boolean({ description: 'overwrite existing files' }),
|
|
20
|
+
};
|
|
21
|
+
AppCommand.args = [
|
|
22
|
+
{ name: 'name', description: 'name of command', required: true },
|
|
23
|
+
];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { flags } from '@oclif/command';
|
|
2
|
+
import Base from '../command-base';
|
|
3
|
+
export interface Options {
|
|
4
|
+
name: string;
|
|
5
|
+
defaults?: boolean;
|
|
6
|
+
force?: boolean;
|
|
7
|
+
event: string;
|
|
8
|
+
}
|
|
9
|
+
export default abstract class HookCommand extends Base {
|
|
10
|
+
static description: string;
|
|
11
|
+
static flags: flags.Input<any>;
|
|
12
|
+
static args: {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
required: boolean;
|
|
16
|
+
}[];
|
|
17
|
+
run(): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const command_1 = require("@oclif/command");
|
|
4
|
+
const command_base_1 = require("../command-base");
|
|
5
|
+
class HookCommand extends command_base_1.default {
|
|
6
|
+
async run() {
|
|
7
|
+
const { flags, args } = this.parse(HookCommand);
|
|
8
|
+
await super.generate('hook', {
|
|
9
|
+
name: args.name,
|
|
10
|
+
event: flags.event,
|
|
11
|
+
defaults: flags.defaults,
|
|
12
|
+
force: flags.force,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.default = HookCommand;
|
|
17
|
+
HookCommand.description = 'add a hook to an existing CLI or plugin';
|
|
18
|
+
HookCommand.flags = {
|
|
19
|
+
defaults: command_1.flags.boolean({ description: 'use defaults for every setting' }),
|
|
20
|
+
force: command_1.flags.boolean({ description: 'overwrite existing files' }),
|
|
21
|
+
event: command_1.flags.string({ description: 'event to run hook on', default: 'init' }),
|
|
22
|
+
};
|
|
23
|
+
HookCommand.args = [
|
|
24
|
+
{ name: 'name', description: 'name of hook (snake_case)', required: true },
|
|
25
|
+
];
|
package/lib/commands/manifest.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const command_1 = require("@oclif/command");
|
|
4
|
+
const Config = require("@oclif/config");
|
|
4
5
|
const fs = require("fs-extra");
|
|
5
6
|
const path = require("path");
|
|
6
|
-
class Manifest extends
|
|
7
|
+
class Manifest extends command_1.Command {
|
|
7
8
|
async run() {
|
|
8
9
|
try {
|
|
9
10
|
fs.unlinkSync('oclif.manifest.json');
|
|
10
11
|
}
|
|
11
12
|
catch (_a) { }
|
|
12
|
-
const { args } =
|
|
13
|
+
const { args } = this.parse(Manifest);
|
|
13
14
|
const root = path.resolve(args.path);
|
|
14
|
-
let plugin = new
|
|
15
|
+
let plugin = new Config.Plugin({ root, type: 'core', ignoreManifest: true, errorOnManifestCreate: true });
|
|
15
16
|
if (!plugin)
|
|
16
17
|
throw new Error('plugin not found');
|
|
17
18
|
await plugin.load();
|
|
18
19
|
if (!plugin.valid) {
|
|
19
20
|
const p = require.resolve('@oclif/plugin-legacy', { paths: [process.cwd()] });
|
|
20
21
|
const { PluginLegacy } = require(p);
|
|
22
|
+
delete plugin.name;
|
|
21
23
|
plugin = new PluginLegacy(this.config, plugin);
|
|
22
24
|
await plugin.load();
|
|
23
25
|
}
|
|
@@ -31,6 +33,7 @@ class Manifest extends core_1.Command {
|
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
exports.default = Manifest;
|
|
36
|
+
Manifest.hidden = true;
|
|
34
37
|
Manifest.description = 'generates plugin manifest json';
|
|
35
38
|
Manifest.args = [
|
|
36
39
|
{ name: 'path', description: 'path to plugin', default: '.' },
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const app_command_1 = require("../app-command");
|
|
4
|
+
class default_1 extends app_command_1.default {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.type = 'multi';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.default = default_1;
|
|
11
|
+
default_1.description = 'generate a new multi-command CLI';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Command } from '@oclif/
|
|
2
|
-
import { Interfaces } from '@oclif/core';
|
|
1
|
+
import { Command, flags } from '@oclif/command';
|
|
3
2
|
export default class PackDeb extends Command {
|
|
3
|
+
static hidden: boolean;
|
|
4
4
|
static description: string;
|
|
5
5
|
static flags: {
|
|
6
|
-
root:
|
|
6
|
+
root: flags.IOptionFlag<string>;
|
|
7
7
|
};
|
|
8
8
|
run(): Promise<void>;
|
|
9
9
|
}
|
package/lib/commands/pack/deb.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const command_1 = require("@oclif/command");
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const qq = require("qqjs");
|
|
6
6
|
const Tarballs = require("../../tarballs");
|
|
@@ -28,7 +28,7 @@ export ${config.scopedEnvVarKey('UPDATE_INSTRUCTIONS')}="update with \\"sudo apt
|
|
|
28
28
|
`,
|
|
29
29
|
/* eslint-enable no-useless-escape */
|
|
30
30
|
control: (config, arch) => `Package: ${config.config.bin}
|
|
31
|
-
Version: ${
|
|
31
|
+
Version: ${upload_util_1.debVersion(config)}
|
|
32
32
|
Section: main
|
|
33
33
|
Priority: standard
|
|
34
34
|
Architecture: ${arch}
|
|
@@ -41,34 +41,34 @@ APT::FTPArchive::Release {
|
|
|
41
41
|
Suite "stable";
|
|
42
42
|
`,
|
|
43
43
|
};
|
|
44
|
-
class PackDeb extends
|
|
44
|
+
class PackDeb extends command_1.Command {
|
|
45
45
|
async run() {
|
|
46
46
|
if (process.platform !== 'linux')
|
|
47
47
|
throw new Error('debian packing must be run on linux');
|
|
48
|
-
const { flags } =
|
|
48
|
+
const { flags } = this.parse(PackDeb);
|
|
49
49
|
const buildConfig = await Tarballs.buildConfig(flags.root);
|
|
50
|
-
const { config } = buildConfig;
|
|
50
|
+
const { config, tmp, targets } = buildConfig;
|
|
51
51
|
await Tarballs.build(buildConfig, { platform: 'linux', pack: false });
|
|
52
52
|
const dist = buildConfig.dist('deb');
|
|
53
53
|
await qq.emptyDir(dist);
|
|
54
54
|
const build = async (arch) => {
|
|
55
55
|
const target = { platform: 'linux', arch };
|
|
56
|
-
const versionedDebBase =
|
|
57
|
-
const workspace = qq.join(
|
|
56
|
+
const versionedDebBase = upload_util_1.templateShortKey('deb', { bin: config.bin, versionShaRevision: upload_util_1.debVersion(buildConfig), arch: upload_util_1.debArch(arch) });
|
|
57
|
+
const workspace = qq.join(tmp, 'apt', versionedDebBase.replace('.deb', '.apt'));
|
|
58
58
|
await qq.rm(workspace);
|
|
59
59
|
await qq.mkdirp([workspace, 'DEBIAN']);
|
|
60
60
|
await qq.mkdirp([workspace, 'usr/bin']);
|
|
61
61
|
await qq.mkdirp([workspace, 'usr/lib']);
|
|
62
62
|
await qq.mv(buildConfig.workspace(target), [workspace, 'usr/lib', config.dirname]);
|
|
63
63
|
await qq.write([workspace, 'usr/lib', config.dirname, 'bin', config.bin], scripts.bin(config));
|
|
64
|
-
await qq.write([workspace, 'DEBIAN/control'], scripts.control(buildConfig,
|
|
64
|
+
await qq.write([workspace, 'DEBIAN/control'], scripts.control(buildConfig, upload_util_1.debArch(arch)));
|
|
65
65
|
await qq.chmod([workspace, 'usr/lib', config.dirname, 'bin', config.bin], 0o755);
|
|
66
66
|
await qq.x(`ln -s "../lib/${config.dirname}/bin/${config.bin}" "${workspace}/usr/bin/${config.bin}"`);
|
|
67
67
|
await qq.x(`chown -R root "${workspace}"`);
|
|
68
68
|
await qq.x(`chgrp -R root "${workspace}"`);
|
|
69
69
|
await qq.x(`dpkg --build "${workspace}" "${qq.join(dist, versionedDebBase)}"`);
|
|
70
70
|
};
|
|
71
|
-
const arches = _.uniq(
|
|
71
|
+
const arches = _.uniq(targets
|
|
72
72
|
.filter(t => t.platform === 'linux')
|
|
73
73
|
.map(t => t.arch));
|
|
74
74
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -78,7 +78,7 @@ class PackDeb extends core_1.Command {
|
|
|
78
78
|
await qq.x('gzip -c Packages > Packages.gz', { cwd: dist });
|
|
79
79
|
await qq.x('bzip2 -k Packages', { cwd: dist });
|
|
80
80
|
await qq.x('xz -k Packages', { cwd: dist });
|
|
81
|
-
const ftparchive = qq.join(
|
|
81
|
+
const ftparchive = qq.join(tmp, 'apt', 'apt-ftparchive.conf');
|
|
82
82
|
await qq.write(ftparchive, scripts.ftparchive(config));
|
|
83
83
|
await qq.x(`apt-ftparchive -c "${ftparchive}" release . > Release`, { cwd: dist });
|
|
84
84
|
const gpgKey = config.scopedEnvVar('DEB_KEY');
|
|
@@ -89,7 +89,8 @@ class PackDeb extends core_1.Command {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
exports.default = PackDeb;
|
|
92
|
+
PackDeb.hidden = true;
|
|
92
93
|
PackDeb.description = 'pack CLI into debian package';
|
|
93
94
|
PackDeb.flags = {
|
|
94
|
-
root:
|
|
95
|
+
root: command_1.flags.string({ char: 'r', description: 'path to oclif CLI root', default: '.', required: true }),
|
|
95
96
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Command } from '@oclif/
|
|
2
|
-
import { Interfaces } from '@oclif/core';
|
|
1
|
+
import { Command, flags } from '@oclif/command';
|
|
3
2
|
export default class PackMacos extends Command {
|
|
3
|
+
static hidden: boolean;
|
|
4
4
|
static description: string;
|
|
5
5
|
static flags: {
|
|
6
|
-
root:
|
|
7
|
-
'additional-cli': Interfaces.OptionFlag<string | undefined>;
|
|
6
|
+
root: flags.IOptionFlag<string>;
|
|
8
7
|
};
|
|
9
8
|
run(): Promise<void>;
|
|
10
9
|
}
|
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const command_1 = require("@oclif/command");
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const qq = require("qqjs");
|
|
6
6
|
const Tarballs = require("../../tarballs");
|
|
7
7
|
const upload_util_1 = require("../../upload-util");
|
|
8
8
|
const scripts = {
|
|
9
|
-
preinstall: (config
|
|
9
|
+
preinstall: (config) => `#!/usr/bin/env bash
|
|
10
10
|
sudo rm -rf /usr/local/lib/${config.dirname}
|
|
11
11
|
sudo rm -rf /usr/local/${config.bin}
|
|
12
12
|
sudo rm -rf /usr/local/bin/${config.bin}
|
|
13
|
-
${additionalCLI ?
|
|
14
|
-
`sudo rm -rf /usr/local/${additionalCLI}
|
|
15
|
-
sudo rm -rf /usr/local/bin/${additionalCLI}` : ''}
|
|
16
13
|
`,
|
|
17
|
-
postinstall: (config
|
|
14
|
+
postinstall: (config) => `#!/usr/bin/env bash
|
|
18
15
|
set -x
|
|
19
16
|
sudo mkdir -p /usr/local/bin
|
|
20
17
|
sudo ln -sf /usr/local/lib/${config.dirname}/bin/${config.bin} /usr/local/bin/${config.bin}
|
|
21
|
-
${additionalCLI ? `sudo ln -sf /usr/local/lib/${config.dirname}/bin/${additionalCLI} /usr/local/bin/${additionalCLI}` : ''}
|
|
22
18
|
`,
|
|
23
|
-
uninstall: (config
|
|
19
|
+
uninstall: (config) => {
|
|
24
20
|
const packageIdentifier = config.pjson.oclif.macos.identifier;
|
|
25
21
|
return `#!/usr/bin/env bash
|
|
26
22
|
|
|
@@ -61,7 +57,6 @@ done
|
|
|
61
57
|
echo "Application uninstalling process started"
|
|
62
58
|
# remove link to shorcut file
|
|
63
59
|
find "/usr/local/bin/" -name "${config.bin}" | xargs rm
|
|
64
|
-
${additionalCLI ? `find "/usr/local/bin/" -name "${additionalCLI}" | xargs rm` : ''}
|
|
65
60
|
if [ $? -eq 0 ]
|
|
66
61
|
then
|
|
67
62
|
echo "[1/3] [DONE] Successfully deleted shortcut links"
|
|
@@ -92,13 +87,13 @@ exit 0
|
|
|
92
87
|
`;
|
|
93
88
|
},
|
|
94
89
|
};
|
|
95
|
-
class PackMacos extends
|
|
90
|
+
class PackMacos extends command_1.Command {
|
|
96
91
|
async run() {
|
|
97
92
|
if (process.platform !== 'darwin')
|
|
98
93
|
this.error('must be run from macos');
|
|
99
|
-
const { flags } =
|
|
94
|
+
const { flags } = this.parse(PackMacos);
|
|
100
95
|
const buildConfig = await Tarballs.buildConfig(flags.root);
|
|
101
|
-
const { config } = buildConfig;
|
|
96
|
+
const { config, tmp, gitSha, version } = buildConfig;
|
|
102
97
|
const c = config.pjson.oclif;
|
|
103
98
|
if (!c.macos)
|
|
104
99
|
this.error('package.json is missing an oclif.macos config');
|
|
@@ -107,15 +102,15 @@ class PackMacos extends core_1.Command {
|
|
|
107
102
|
const macos = c.macos;
|
|
108
103
|
const packageIdentifier = macos.identifier;
|
|
109
104
|
await Tarballs.build(buildConfig, { platform: 'darwin', pack: false });
|
|
110
|
-
const templateKey =
|
|
105
|
+
const templateKey = upload_util_1.templateShortKey('macos', { bin: config.bin, version: config.version, sha: gitSha });
|
|
111
106
|
const dist = buildConfig.dist(`macos/${templateKey}`);
|
|
112
107
|
await qq.emptyDir(path.dirname(dist));
|
|
113
|
-
const scriptsDir = qq.join(
|
|
108
|
+
const scriptsDir = qq.join(tmp, 'macos/scripts');
|
|
114
109
|
const rootDir = buildConfig.workspace({ platform: 'darwin', arch: 'x64' });
|
|
115
110
|
const writeScript = async (script) => {
|
|
116
111
|
const path = script === 'uninstall' ? [rootDir, 'bin'] : [scriptsDir];
|
|
117
112
|
path.push(script);
|
|
118
|
-
await qq.write(path, scripts[script](config
|
|
113
|
+
await qq.write(path, scripts[script](config));
|
|
119
114
|
await qq.chmod(path, 0o755);
|
|
120
115
|
};
|
|
121
116
|
await writeScript('preinstall');
|
|
@@ -125,7 +120,7 @@ class PackMacos extends core_1.Command {
|
|
|
125
120
|
const args = [
|
|
126
121
|
'--root', rootDir,
|
|
127
122
|
'--identifier', packageIdentifier,
|
|
128
|
-
'--version',
|
|
123
|
+
'--version', version,
|
|
129
124
|
'--install-location', `/usr/local/lib/${config.dirname}`,
|
|
130
125
|
'--scripts', scriptsDir,
|
|
131
126
|
];
|
|
@@ -142,9 +137,8 @@ class PackMacos extends core_1.Command {
|
|
|
142
137
|
}
|
|
143
138
|
}
|
|
144
139
|
exports.default = PackMacos;
|
|
140
|
+
PackMacos.hidden = true;
|
|
145
141
|
PackMacos.description = 'pack CLI into macOS .pkg';
|
|
146
142
|
PackMacos.flags = {
|
|
147
|
-
root:
|
|
148
|
-
'additional-cli': core_1.Flags.string({ description: `an Oclif CLI other than the one listed in config.bin that should be made available to the user
|
|
149
|
-
the CLI should already exist in a directory named after the CLI that is the root of the tarball produced by "oclif pack:tarballs"`, hidden: true }),
|
|
143
|
+
root: command_1.flags.string({ char: 'r', description: 'path to oclif CLI root', default: '.', required: true }),
|
|
150
144
|
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { Command } from '@oclif/
|
|
1
|
+
import { Command, flags } from '@oclif/command';
|
|
2
2
|
export default class PackTarballs extends Command {
|
|
3
|
+
static hidden: boolean;
|
|
3
4
|
static description: string;
|
|
4
|
-
static flags:
|
|
5
|
-
root: import("@oclif/core/lib/interfaces").OptionFlag<string>;
|
|
6
|
-
targets: import("@oclif/core/lib/interfaces").OptionFlag<string>;
|
|
7
|
-
xz: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
8
|
-
};
|
|
5
|
+
static flags: flags.Input<any>;
|
|
9
6
|
run(): Promise<void>;
|
|
10
7
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const command_1 = require("@oclif/command");
|
|
4
4
|
const qq = require("qqjs");
|
|
5
5
|
const Tarballs = require("../../tarballs");
|
|
6
|
-
class PackTarballs extends
|
|
6
|
+
class PackTarballs extends command_1.Command {
|
|
7
7
|
async run() {
|
|
8
8
|
const prevCwd = qq.cwd();
|
|
9
9
|
if (process.platform === 'win32')
|
|
10
10
|
throw new Error('pack does not function on windows');
|
|
11
|
-
const { flags } =
|
|
11
|
+
const { flags } = this.parse(PackTarballs);
|
|
12
12
|
const targets = flags.targets.split(',');
|
|
13
13
|
const buildConfig = await Tarballs.buildConfig(flags.root, { xz: flags.xz, targets: targets });
|
|
14
14
|
await Tarballs.build(buildConfig);
|
|
@@ -16,15 +16,16 @@ class PackTarballs extends core_1.Command {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
exports.default = PackTarballs;
|
|
19
|
+
PackTarballs.hidden = true;
|
|
19
20
|
PackTarballs.description = `packages oclif CLI into tarballs
|
|
20
21
|
|
|
21
22
|
This can be used to create oclif CLIs that use the system node or that come preloaded with a node binary.
|
|
22
23
|
`;
|
|
23
24
|
PackTarballs.flags = {
|
|
24
|
-
root:
|
|
25
|
-
targets:
|
|
25
|
+
root: command_1.flags.string({ char: 'r', description: 'path to oclif CLI root', default: '.', required: true }),
|
|
26
|
+
targets: command_1.flags.string({ char: 't',
|
|
26
27
|
description: 'comma-separated targets to pack (e.g.: linux-arm,win32-x64)',
|
|
27
28
|
default: Tarballs.TARGETS.join(','),
|
|
28
29
|
}),
|
|
29
|
-
xz:
|
|
30
|
+
xz: command_1.flags.boolean({ description: 'also build xz', allowNo: true, default: true }),
|
|
30
31
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Command } from '@oclif/
|
|
2
|
-
import { Interfaces } from '@oclif/core';
|
|
1
|
+
import { Command, flags } from '@oclif/command';
|
|
3
2
|
export default class PackWin extends Command {
|
|
3
|
+
static hidden: boolean;
|
|
4
4
|
static description: string;
|
|
5
5
|
static flags: {
|
|
6
|
-
root:
|
|
7
|
-
'additional-cli': Interfaces.OptionFlag<string | undefined>;
|
|
6
|
+
root: flags.IOptionFlag<string>;
|
|
8
7
|
};
|
|
9
8
|
run(): Promise<void>;
|
|
10
9
|
private checkForNSIS;
|
package/lib/commands/pack/win.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const command_1 = require("@oclif/command");
|
|
4
4
|
const qq = require("qqjs");
|
|
5
5
|
const Tarballs = require("../../tarballs");
|
|
6
6
|
const upload_util_1 = require("../../upload-util");
|
|
7
7
|
const scripts = {
|
|
8
8
|
/* eslint-disable no-useless-escape */
|
|
9
|
-
cmd: (config
|
|
9
|
+
cmd: (config) => `@echo off
|
|
10
10
|
setlocal enableextensions
|
|
11
11
|
|
|
12
|
-
set ${
|
|
13
|
-
if exist "%LOCALAPPDATA%\\${config.dirname}\\client\\bin\\${
|
|
14
|
-
"%LOCALAPPDATA%\\${config.dirname}\\client\\bin\\${
|
|
12
|
+
set ${config.scopedEnvVarKey('BINPATH')}=%~dp0\\${config.bin}.cmd
|
|
13
|
+
if exist "%LOCALAPPDATA%\\${config.dirname}\\client\\bin\\${config.bin}.cmd" (
|
|
14
|
+
"%LOCALAPPDATA%\\${config.dirname}\\client\\bin\\${config.bin}.cmd" %*
|
|
15
15
|
) else (
|
|
16
|
-
"%~dp0\\..\\client\\bin\\node.exe" "%~dp0\\..\\client
|
|
16
|
+
"%~dp0\\..\\client\\bin\\node.exe" "%~dp0\\..\\client\\bin\\run" %*
|
|
17
17
|
)
|
|
18
18
|
`,
|
|
19
19
|
sh: (config) => `#!/bin/sh
|
|
@@ -188,33 +188,28 @@ done:
|
|
|
188
188
|
Exch $R1 ; $R1=old$R1, stack=[result,...]
|
|
189
189
|
FunctionEnd
|
|
190
190
|
`,
|
|
191
|
-
/* eslint-enable no-useless-escape */
|
|
192
191
|
};
|
|
193
|
-
class PackWin extends
|
|
192
|
+
class PackWin extends command_1.Command {
|
|
194
193
|
async run() {
|
|
195
194
|
await this.checkForNSIS();
|
|
196
|
-
const { flags } =
|
|
195
|
+
const { flags } = this.parse(PackWin);
|
|
197
196
|
const buildConfig = await Tarballs.buildConfig(flags.root);
|
|
198
|
-
const { config } = buildConfig;
|
|
197
|
+
const { config, version, gitSha, targets, tmp } = buildConfig;
|
|
199
198
|
await Tarballs.build(buildConfig, { platform: 'win32', pack: false });
|
|
200
|
-
const arches =
|
|
199
|
+
const arches = targets.filter(t => t.platform === 'win32').map(t => t.arch);
|
|
201
200
|
for (const arch of arches) {
|
|
202
|
-
const installerBase = qq.join(
|
|
201
|
+
const installerBase = qq.join(tmp, `windows-${arch}-installer`);
|
|
203
202
|
// eslint-disable-next-line no-await-in-loop
|
|
204
203
|
await qq.write([installerBase, `bin/${config.bin}.cmd`], scripts.cmd(config));
|
|
205
204
|
// eslint-disable-next-line no-await-in-loop
|
|
206
205
|
await qq.write([installerBase, `bin/${config.bin}`], scripts.sh(config));
|
|
207
|
-
if (flags['additional-cli']) {
|
|
208
|
-
await qq.write([installerBase, `bin/${flags['additional-cli']}.cmd`], scripts.cmd(config, flags['additional-cli'])); // eslint-disable-line no-await-in-loop
|
|
209
|
-
await qq.write([installerBase, `bin/${flags['additional-cli']}`], scripts.sh({ bin: flags['additional-cli'] })); // eslint-disable-line no-await-in-loop
|
|
210
|
-
}
|
|
211
206
|
// eslint-disable-next-line no-await-in-loop
|
|
212
207
|
await qq.write([installerBase, `${config.bin}.nsi`], scripts.nsis(config, arch));
|
|
213
208
|
// eslint-disable-next-line no-await-in-loop
|
|
214
209
|
await qq.mv(buildConfig.workspace({ platform: 'win32', arch }), [installerBase, 'client']);
|
|
215
210
|
// eslint-disable-next-line no-await-in-loop
|
|
216
211
|
await qq.x(`makensis ${installerBase}/${config.bin}.nsi | grep -v "\\[compress\\]" | grep -v "^File: Descending to"`);
|
|
217
|
-
const templateKey =
|
|
212
|
+
const templateKey = upload_util_1.templateShortKey('win32', { bin: config.bin, version: version, sha: gitSha, arch });
|
|
218
213
|
const o = buildConfig.dist(`win32/${templateKey}`);
|
|
219
214
|
// eslint-disable-next-line no-await-in-loop
|
|
220
215
|
await qq.mv([installerBase, 'installer.exe'], o);
|
|
@@ -223,14 +218,10 @@ class PackWin extends core_1.Command {
|
|
|
223
218
|
const buildLocationUnsigned = o.replace(`${arch}.exe`, `${arch}-unsigned.exe`);
|
|
224
219
|
// eslint-disable-next-line no-await-in-loop
|
|
225
220
|
await qq.mv(o, buildLocationUnsigned);
|
|
226
|
-
const pass = config.scopedEnvVar('WINDOWS_SIGNING_PASS');
|
|
227
|
-
if (!pass) {
|
|
228
|
-
throw new Error(`${config.scopedEnvVarKey('WINDOWS_SIGNING_PASS')} not set in the environment`);
|
|
229
|
-
}
|
|
230
221
|
/* eslint-disable array-element-newline */
|
|
231
222
|
const args = [
|
|
232
223
|
'-pkcs12', windows.keypath,
|
|
233
|
-
'-pass',
|
|
224
|
+
'-pass', config.scopedEnvVar('WINDOWS_SIGNING_PASS'),
|
|
234
225
|
'-n', windows.name,
|
|
235
226
|
'-i', windows.homepage || config.pjson.homepage,
|
|
236
227
|
'-h', 'sha512',
|
|
@@ -260,11 +251,8 @@ class PackWin extends core_1.Command {
|
|
|
260
251
|
}
|
|
261
252
|
}
|
|
262
253
|
exports.default = PackWin;
|
|
263
|
-
PackWin.
|
|
264
|
-
|
|
265
|
-
This command requires WINDOWS_SIGNING (prefixed with the name of your executable, e.g. OCLIF_WINDOWS_SIGNING_PASS) to be set in the environment`;
|
|
254
|
+
PackWin.hidden = true;
|
|
255
|
+
PackWin.description = 'create windows installer from oclif CLI';
|
|
266
256
|
PackWin.flags = {
|
|
267
|
-
root:
|
|
268
|
-
'additional-cli': core_1.Flags.string({ description: `an Oclif CLI other than the one listed in config.bin that should be made available to the user
|
|
269
|
-
the CLI should already exist in a directory named after the CLI that is the root of the tarball produced by "oclif pack:tarballs"`, hidden: true }),
|
|
257
|
+
root: command_1.flags.string({ char: 'r', description: 'path to oclif CLI root', default: '.', required: true }),
|
|
270
258
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const app_command_1 = require("../app-command");
|
|
4
|
+
class default_1 extends app_command_1.default {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.type = 'plugin';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.default = default_1;
|
|
11
|
+
default_1.description = 'create a new CLI plugin';
|