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.
Files changed (105) hide show
  1. package/.oclif.manifest.json +1 -1
  2. package/CHANGELOG.md +5 -58
  3. package/README.md +97 -224
  4. package/bin/run +2 -5
  5. package/lib/app-command.d.ts +12 -0
  6. package/lib/app-command.js +26 -0
  7. package/lib/aws.d.ts +5 -5
  8. package/lib/aws.js +5 -5
  9. package/lib/command-base.d.ts +2 -2
  10. package/lib/command-base.js +3 -3
  11. package/lib/commands/base.d.ts +5 -0
  12. package/lib/commands/base.js +11 -0
  13. package/lib/commands/command.d.ts +17 -0
  14. package/lib/commands/command.js +23 -0
  15. package/lib/commands/hook.d.ts +18 -0
  16. package/lib/commands/hook.js +25 -0
  17. package/lib/commands/manifest.d.ts +2 -1
  18. package/lib/commands/manifest.js +7 -4
  19. package/lib/commands/multi.d.ts +5 -0
  20. package/lib/commands/multi.js +11 -0
  21. package/lib/commands/pack/deb.d.ts +3 -3
  22. package/lib/commands/pack/deb.js +12 -11
  23. package/lib/commands/pack/macos.d.ts +3 -4
  24. package/lib/commands/pack/macos.js +13 -19
  25. package/lib/commands/pack/tarballs.d.ts +3 -6
  26. package/lib/commands/pack/tarballs.js +7 -6
  27. package/lib/commands/pack/win.d.ts +3 -4
  28. package/lib/commands/pack/win.js +16 -28
  29. package/lib/commands/plugin.d.ts +5 -0
  30. package/lib/commands/plugin.js +11 -0
  31. package/lib/commands/promote.d.ts +3 -14
  32. package/lib/commands/promote.js +28 -27
  33. package/lib/commands/readme.d.ts +11 -13
  34. package/lib/commands/readme.js +36 -35
  35. package/lib/commands/single.d.ts +5 -0
  36. package/lib/commands/single.js +11 -0
  37. package/lib/commands/upload/deb.d.ts +3 -2
  38. package/lib/commands/upload/deb.js +9 -8
  39. package/lib/commands/upload/macos.d.ts +3 -2
  40. package/lib/commands/upload/macos.js +9 -8
  41. package/lib/commands/upload/tarballs.d.ts +3 -7
  42. package/lib/commands/upload/tarballs.js +20 -19
  43. package/lib/commands/upload/win.d.ts +3 -2
  44. package/lib/commands/upload/win.js +11 -10
  45. package/lib/generators/{cli.d.ts → app.d.ts} +21 -1
  46. package/lib/generators/app.js +459 -0
  47. package/lib/generators/command.d.ts +15 -0
  48. package/lib/generators/command.js +51 -0
  49. package/lib/generators/hook.d.ts +14 -0
  50. package/lib/generators/hook.js +51 -0
  51. package/lib/help-compatibility.d.ts +5 -4
  52. package/lib/help-compatibility.js +0 -1
  53. package/lib/index.d.ts +1 -1
  54. package/lib/index.js +2 -3
  55. package/lib/log.js +2 -3
  56. package/lib/tarballs/bin.d.ts +2 -2
  57. package/lib/tarballs/bin.js +1 -2
  58. package/lib/tarballs/build.js +28 -29
  59. package/lib/tarballs/config.d.ts +7 -6
  60. package/lib/tarballs/config.js +7 -6
  61. package/lib/tarballs/index.js +4 -4
  62. package/lib/tarballs/node.js +4 -5
  63. package/lib/upload-util.d.ts +3 -3
  64. package/lib/upload-util.js +1 -2
  65. package/lib/util.js +24 -27
  66. package/lib/version-indexes.d.ts +4 -2
  67. package/lib/version-indexes.js +5 -7
  68. package/package.json +24 -23
  69. package/templates/LICENSE.mit +21 -0
  70. package/templates/README.md.ejs +21 -0
  71. package/templates/appveyor.yml.ejs +33 -0
  72. package/templates/base/src/index.js +1 -0
  73. package/templates/base/src/index.ts +1 -0
  74. package/templates/base/test/index.test.js +8 -0
  75. package/templates/base/test/index.test.ts +9 -0
  76. package/templates/bin/run +5 -0
  77. package/templates/bin/run.cmd +3 -0
  78. package/templates/circle.yml.ejs +65 -0
  79. package/templates/editorconfig +11 -0
  80. package/templates/eslintrc +7 -0
  81. package/templates/eslintrc.typescript +10 -0
  82. package/templates/multi/src/index.js +1 -0
  83. package/templates/multi/src/index.ts +1 -0
  84. package/templates/plugin/bin/run +4 -0
  85. package/templates/plugin/src/index.ts +1 -0
  86. package/templates/scripts/setup_git +12 -0
  87. package/templates/single/bin/run.js +4 -0
  88. package/templates/single/bin/run.ts +13 -0
  89. package/templates/src/command.js.ejs +27 -0
  90. package/templates/src/command.ts.ejs +46 -0
  91. package/templates/src/hook.js.ejs +3 -0
  92. package/templates/src/hook.ts.ejs +7 -0
  93. package/templates/test/command.test.js.ejs +28 -0
  94. package/templates/test/command.test.ts.ejs +29 -0
  95. package/templates/test/hook.test.js.ejs +9 -0
  96. package/templates/test/hook.test.ts.ejs +9 -0
  97. package/templates/test/mocha.opts +4 -0
  98. package/templates/test/tsconfig.json +9 -0
  99. package/templates/travis.yml.ejs +14 -0
  100. package/templates/tsconfig.json +15 -0
  101. package/bin/dev +0 -19
  102. package/bin/dev.cmd +0 -3
  103. package/lib/commands/generate.d.ts +0 -11
  104. package/lib/commands/generate.js +0 -19
  105. 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
- (0, log_1.log)('createCloudfrontInvalidation', options.DistributionId, options.InvalidationBatch.Paths.Items);
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(null);
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
- (0, log_1.log)('s3:uploadFile', qq.prettifyPaths(local), `s3://${options.Bucket}/${options.Key}`);
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(null);
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
- (0, log_1.log)('s3:copyObject', `from s3://${options.CopySource}`, `to s3://${options.Bucket}/${options.Key}`);
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);
@@ -1,4 +1,4 @@
1
- import { Command } from '@oclif/core';
1
+ import Command from '@oclif/command';
2
2
  export default abstract class CommandBase extends Command {
3
- protected generate(type: string, generatorOptions?: object): Promise<void>;
3
+ protected generate(type: string, generatorOptions?: {}): Promise<void>;
4
4
  }
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@oclif/core");
3
+ const command_1 = require("@oclif/command");
4
4
  const yeoman_environment_1 = require("yeoman-environment");
5
- class CommandBase extends core_1.Command {
5
+ class CommandBase extends command_1.default {
6
6
  async generate(type, generatorOptions = {}) {
7
- const env = (0, yeoman_environment_1.createEnv)();
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,5 @@
1
+ import AppCommand from '../app-command';
2
+ export default class extends AppCommand {
3
+ static hidden: boolean;
4
+ type: string;
5
+ }
@@ -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
+ ];
@@ -1,5 +1,6 @@
1
- import { Command } from '@oclif/core';
1
+ import { Command } from '@oclif/command';
2
2
  export default class Manifest extends Command {
3
+ static hidden: boolean;
3
4
  static description: string;
4
5
  static args: {
5
6
  name: string;
@@ -1,23 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@oclif/core");
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 core_1.Command {
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 } = await this.parse(Manifest);
13
+ const { args } = this.parse(Manifest);
13
14
  const root = path.resolve(args.path);
14
- let plugin = new core_1.Plugin({ root, type: 'core', ignoreManifest: true, errorOnManifestCreate: true });
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,5 @@
1
+ import AppCommand from '../app-command';
2
+ export default class extends AppCommand {
3
+ static description: string;
4
+ type: string;
5
+ }
@@ -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/core';
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: Interfaces.OptionFlag<string>;
6
+ root: flags.IOptionFlag<string>;
7
7
  };
8
8
  run(): Promise<void>;
9
9
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@oclif/core");
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: ${(0, upload_util_1.debVersion)(config)}
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 core_1.Command {
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 } = await this.parse(PackDeb);
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 = (0, upload_util_1.templateShortKey)('deb', { bin: config.bin, versionShaRevision: (0, upload_util_1.debVersion)(buildConfig), arch: (0, upload_util_1.debArch)(arch) });
57
- const workspace = qq.join(buildConfig.tmp, 'apt', versionedDebBase.replace('.deb', '.apt'));
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, (0, upload_util_1.debArch)(arch)));
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(buildConfig.targets
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(buildConfig.tmp, 'apt', 'apt-ftparchive.conf');
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: core_1.Flags.string({ char: 'r', description: 'path to oclif CLI root', default: '.', required: true }),
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/core';
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: Interfaces.OptionFlag<string>;
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 core_1 = require("@oclif/core");
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, additionalCLI) => `#!/usr/bin/env bash
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, additionalCLI) => `#!/usr/bin/env bash
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, additionalCLI) => {
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 core_1.Command {
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 } = await this.parse(PackMacos);
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 = (0, upload_util_1.templateShortKey)('macos', { bin: config.bin, version: config.version, sha: buildConfig.gitSha });
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(buildConfig.tmp, 'macos/scripts');
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, flags['additional-cli']));
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', config.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: core_1.Flags.string({ char: 'r', description: 'path to oclif CLI root', default: '.', required: true }),
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/core';
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 core_1 = require("@oclif/core");
3
+ const command_1 = require("@oclif/command");
4
4
  const qq = require("qqjs");
5
5
  const Tarballs = require("../../tarballs");
6
- class PackTarballs extends core_1.Command {
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 } = await this.parse(PackTarballs);
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: core_1.Flags.string({ char: 'r', description: 'path to oclif CLI root', default: '.', required: true }),
25
- targets: core_1.Flags.string({ char: 't',
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: core_1.Flags.boolean({ description: 'also build xz', allowNo: true, default: true }),
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/core';
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: Interfaces.OptionFlag<string>;
7
- 'additional-cli': Interfaces.OptionFlag<string | undefined>;
6
+ root: flags.IOptionFlag<string>;
8
7
  };
9
8
  run(): Promise<void>;
10
9
  private checkForNSIS;
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@oclif/core");
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, additionalCLI = undefined) => `@echo off
9
+ cmd: (config) => `@echo off
10
10
  setlocal enableextensions
11
11
 
12
- set ${additionalCLI ? `${additionalCLI.toUpperCase()}_BINPATH` : config.scopedEnvVarKey('BINPATH')}=%~dp0\\${additionalCLI !== null && additionalCLI !== void 0 ? additionalCLI : config.bin}.cmd
13
- if exist "%LOCALAPPDATA%\\${config.dirname}\\client\\bin\\${additionalCLI !== null && additionalCLI !== void 0 ? additionalCLI : config.bin}.cmd" (
14
- "%LOCALAPPDATA%\\${config.dirname}\\client\\bin\\${additionalCLI !== null && additionalCLI !== void 0 ? additionalCLI : config.bin}.cmd" %*
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\\${additionalCLI ? `${additionalCLI}\\bin\\run` : 'bin\\run'}" %*
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 core_1.Command {
192
+ class PackWin extends command_1.Command {
194
193
  async run() {
195
194
  await this.checkForNSIS();
196
- const { flags } = await this.parse(PackWin);
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 = buildConfig.targets.filter(t => t.platform === 'win32').map(t => t.arch);
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(buildConfig.tmp, `windows-${arch}-installer`);
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 = (0, upload_util_1.templateShortKey)('win32', { bin: config.bin, version: config.version, sha: buildConfig.gitSha, arch });
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', 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.description = `create windows installer from oclif CLI
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: core_1.Flags.string({ char: 'r', description: 'path to oclif CLI root', default: '.', required: true }),
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,5 @@
1
+ import AppCommand from '../app-command';
2
+ export default class extends AppCommand {
3
+ static description: string;
4
+ type: string;
5
+ }
@@ -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';