oclif 2.0.0 → 2.0.1

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 (106) hide show
  1. package/.oclif.manifest.json +1 -1
  2. package/CHANGELOG.md +100 -11
  3. package/README.md +228 -101
  4. package/bin/dev +19 -0
  5. package/bin/dev.cmd +3 -0
  6. package/bin/run +5 -2
  7. package/lib/aws.d.ts +5 -5
  8. package/lib/aws.js +7 -5
  9. package/lib/command-base.d.ts +2 -2
  10. package/lib/command-base.js +3 -3
  11. package/lib/commands/generate.d.ts +11 -0
  12. package/lib/commands/generate.js +19 -0
  13. package/lib/commands/manifest.d.ts +1 -2
  14. package/lib/commands/manifest.js +4 -7
  15. package/lib/commands/pack/deb.d.ts +3 -3
  16. package/lib/commands/pack/deb.js +11 -12
  17. package/lib/commands/pack/macos.d.ts +4 -3
  18. package/lib/commands/pack/macos.js +19 -13
  19. package/lib/commands/pack/tarballs.d.ts +6 -3
  20. package/lib/commands/pack/tarballs.js +9 -7
  21. package/lib/commands/pack/win.d.ts +4 -3
  22. package/lib/commands/pack/win.js +29 -16
  23. package/lib/commands/promote.d.ts +14 -3
  24. package/lib/commands/promote.js +27 -28
  25. package/lib/commands/readme.d.ts +13 -11
  26. package/lib/commands/readme.js +33 -34
  27. package/lib/commands/upload/deb.d.ts +2 -3
  28. package/lib/commands/upload/deb.js +8 -9
  29. package/lib/commands/upload/macos.d.ts +2 -3
  30. package/lib/commands/upload/macos.js +8 -9
  31. package/lib/commands/upload/tarballs.d.ts +7 -3
  32. package/lib/commands/upload/tarballs.js +23 -20
  33. package/lib/commands/upload/win.d.ts +2 -3
  34. package/lib/commands/upload/win.js +10 -11
  35. package/lib/generators/{app.d.ts → cli.d.ts} +2 -22
  36. package/lib/generators/cli.js +182 -0
  37. package/lib/help-compatibility.d.ts +4 -5
  38. package/lib/help-compatibility.js +1 -0
  39. package/lib/index.d.ts +1 -1
  40. package/lib/index.js +3 -2
  41. package/lib/log.js +3 -2
  42. package/lib/tarballs/bin.d.ts +2 -2
  43. package/lib/tarballs/bin.js +2 -1
  44. package/lib/tarballs/build.js +29 -28
  45. package/lib/tarballs/config.d.ts +6 -7
  46. package/lib/tarballs/config.js +24 -12
  47. package/lib/tarballs/index.js +4 -4
  48. package/lib/tarballs/node.d.ts +7 -4
  49. package/lib/tarballs/node.js +5 -5
  50. package/lib/upload-util.d.ts +3 -3
  51. package/lib/upload-util.js +5 -2
  52. package/lib/util.js +24 -20
  53. package/lib/version-indexes.d.ts +2 -4
  54. package/lib/version-indexes.js +3 -1
  55. package/package.json +27 -27
  56. package/lib/app-command.d.ts +0 -12
  57. package/lib/app-command.js +0 -26
  58. package/lib/commands/base.d.ts +0 -5
  59. package/lib/commands/base.js +0 -11
  60. package/lib/commands/command.d.ts +0 -17
  61. package/lib/commands/command.js +0 -23
  62. package/lib/commands/hook.d.ts +0 -18
  63. package/lib/commands/hook.js +0 -25
  64. package/lib/commands/multi.d.ts +0 -5
  65. package/lib/commands/multi.js +0 -11
  66. package/lib/commands/plugin.d.ts +0 -5
  67. package/lib/commands/plugin.js +0 -11
  68. package/lib/commands/single.d.ts +0 -5
  69. package/lib/commands/single.js +0 -11
  70. package/lib/generators/app.js +0 -459
  71. package/lib/generators/command.d.ts +0 -15
  72. package/lib/generators/command.js +0 -51
  73. package/lib/generators/hook.d.ts +0 -14
  74. package/lib/generators/hook.js +0 -51
  75. package/templates/LICENSE.mit +0 -21
  76. package/templates/README.md.ejs +0 -21
  77. package/templates/appveyor.yml.ejs +0 -33
  78. package/templates/base/src/index.js +0 -1
  79. package/templates/base/src/index.ts +0 -1
  80. package/templates/base/test/index.test.js +0 -8
  81. package/templates/base/test/index.test.ts +0 -9
  82. package/templates/bin/run +0 -5
  83. package/templates/bin/run.cmd +0 -3
  84. package/templates/circle.yml.ejs +0 -65
  85. package/templates/editorconfig +0 -11
  86. package/templates/eslintrc +0 -7
  87. package/templates/eslintrc.typescript +0 -10
  88. package/templates/multi/src/index.js +0 -1
  89. package/templates/multi/src/index.ts +0 -1
  90. package/templates/plugin/bin/run +0 -4
  91. package/templates/plugin/src/index.ts +0 -1
  92. package/templates/scripts/setup_git +0 -12
  93. package/templates/single/bin/run.js +0 -4
  94. package/templates/single/bin/run.ts +0 -13
  95. package/templates/src/command.js.ejs +0 -27
  96. package/templates/src/command.ts.ejs +0 -46
  97. package/templates/src/hook.js.ejs +0 -3
  98. package/templates/src/hook.ts.ejs +0 -7
  99. package/templates/test/command.test.js.ejs +0 -28
  100. package/templates/test/command.test.ts.ejs +0 -29
  101. package/templates/test/hook.test.js.ejs +0 -9
  102. package/templates/test/hook.test.ts.ejs +0 -9
  103. package/templates/test/mocha.opts +0 -4
  104. package/templates/test/tsconfig.json +0 -9
  105. package/templates/travis.yml.ejs +0 -14
  106. package/templates/tsconfig.json +0 -15
@@ -1,23 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@oclif/command");
3
+ const core_1 = require("@oclif/core");
4
4
  const qq = require("qqjs");
5
5
  const aws_1 = require("../../aws");
6
6
  const log_1 = require("../../log");
7
7
  const Tarballs = require("../../tarballs");
8
8
  const upload_util_1 = require("../../upload-util");
9
- class UploadWin extends command_1.Command {
9
+ class UploadWin extends core_1.Command {
10
10
  async run() {
11
- const { flags } = this.parse(UploadWin);
11
+ const { flags } = await this.parse(UploadWin);
12
12
  const buildConfig = await Tarballs.buildConfig(flags.root);
13
- const { s3Config, version, config, dist, targets, gitSha } = buildConfig;
13
+ const { s3Config, config, dist } = buildConfig;
14
14
  const S3Options = {
15
15
  Bucket: s3Config.bucket,
16
16
  ACL: s3Config.acl || 'public-read',
17
17
  };
18
- const archs = targets.filter(t => t.platform === 'win32').map(t => t.arch);
18
+ const archs = buildConfig.targets.filter(t => t.platform === 'win32').map(t => t.arch);
19
19
  for (const arch of archs) {
20
- const templateKey = upload_util_1.templateShortKey('win32', { bin: config.bin, version: version, sha: gitSha, arch });
20
+ const templateKey = (0, upload_util_1.templateShortKey)('win32', { bin: config.bin, version: config.version, sha: buildConfig.gitSha, arch });
21
21
  const localKey = dist(`win32/${templateKey}`);
22
22
  // eslint-disable-next-line no-await-in-loop
23
23
  if (!await qq.exists(localKey))
@@ -25,9 +25,9 @@ class UploadWin extends command_1.Command {
25
25
  suggestions: ['Run "oclif-dev pack:win" before uploading'],
26
26
  });
27
27
  }
28
- const cloudKeyBase = upload_util_1.commitAWSDir(config.pjson.version, gitSha, s3Config);
28
+ const cloudKeyBase = (0, upload_util_1.commitAWSDir)(config.pjson.version, buildConfig.gitSha, s3Config);
29
29
  const uploadWin = async (arch) => {
30
- const templateKey = upload_util_1.templateShortKey('win32', { bin: config.bin, version: version, sha: gitSha, arch });
30
+ const templateKey = (0, upload_util_1.templateShortKey)('win32', { bin: config.bin, version: config.version, sha: buildConfig.gitSha, arch });
31
31
  const localExe = dist(`win32/${templateKey}`);
32
32
  const cloudKey = `${cloudKeyBase}/${templateKey}`;
33
33
  if (await qq.exists(localExe))
@@ -35,12 +35,11 @@ class UploadWin extends command_1.Command {
35
35
  };
36
36
  await uploadWin('x64');
37
37
  await uploadWin('x86');
38
- log_1.log(`done uploading windows executables for v${version}-${gitSha}`);
38
+ (0, log_1.log)(`done uploading windows executables for v${config.version}-${buildConfig.gitSha}`);
39
39
  }
40
40
  }
41
41
  exports.default = UploadWin;
42
- UploadWin.hidden = true;
43
42
  UploadWin.description = 'upload windows installers built with pack:win';
44
43
  UploadWin.flags = {
45
- root: command_1.flags.string({ char: 'r', description: 'path to oclif CLI root', default: '.', required: true }),
44
+ root: core_1.Flags.string({ char: 'r', description: 'path to oclif CLI root', default: '.', required: true }),
46
45
  };
@@ -2,19 +2,12 @@ import * as Generator from 'yeoman-generator';
2
2
  declare class App extends Generator {
3
3
  options: {
4
4
  defaults?: boolean;
5
- mocha: boolean;
6
- circleci: boolean;
7
- appveyor: boolean;
8
- typescript: boolean;
9
- eslint: boolean;
10
5
  yarn: boolean;
11
- travisci: boolean;
12
6
  };
13
7
  args: {
14
8
  [k: string]: string;
15
9
  };
16
- type: 'single' | 'multi' | 'plugin' | 'base';
17
- path: string;
10
+ name: string;
18
11
  pjson: any;
19
12
  githubUser: string | undefined;
20
13
  answers: {
@@ -39,26 +32,13 @@ declare class App extends Generator {
39
32
  travisci: boolean;
40
33
  };
41
34
  };
42
- mocha: boolean;
43
- circleci: boolean;
44
- appveyor: boolean;
45
- ts: boolean;
46
- eslint: boolean;
47
35
  yarn: boolean;
48
- travisci: boolean;
49
- get _ext(): "ts" | "js";
50
- get _bin(): any;
51
36
  repository?: string;
52
- constructor(args: any, opts: any);
37
+ constructor(args: string | string[], opts: Generator.GeneratorOptions);
53
38
  prompting(): Promise<void>;
54
39
  writing(): void;
55
40
  install(): Promise<void>;
56
41
  end(): void;
57
42
  private _gitignore;
58
- private _eslintignore;
59
- private _writeBase;
60
- private _writePlugin;
61
- private _writeSingle;
62
- private _writeMulti;
63
43
  }
64
44
  export = App;
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ const child_process_1 = require("child_process");
3
+ const fs = require("fs");
4
+ const _ = require("lodash");
5
+ const path = require("path");
6
+ const Generator = require("yeoman-generator");
7
+ const yosay = require("yosay");
8
+ const sortPjson = require('sort-pjson');
9
+ const fixpack = require('@oclif/fixpack');
10
+ const debug = require('debug')('generator-oclif');
11
+ const { version } = require('../../package.json');
12
+ const isWindows = process.platform === 'win32';
13
+ let hasYarn = false;
14
+ try {
15
+ (0, child_process_1.execSync)('yarn -v', { stdio: 'ignore' });
16
+ hasYarn = true;
17
+ }
18
+ catch (_a) { }
19
+ class App extends Generator {
20
+ constructor(args, opts) {
21
+ super(args, opts);
22
+ this.name = opts.name;
23
+ this.options = {
24
+ defaults: opts.defaults,
25
+ yarn: hasYarn,
26
+ };
27
+ }
28
+ async prompting() {
29
+ const msg = 'Time to build an oclif CLI!';
30
+ this.log(yosay(`${msg} Version: ${version}`));
31
+ (0, child_process_1.execSync)(`git clone https://github.com/oclif/hello-world.git ${path.resolve(this.name)}`);
32
+ fs.rmdirSync(`${path.resolve(this.name, '.git')}`, { recursive: true });
33
+ this.destinationRoot(path.resolve(this.name));
34
+ process.chdir(this.destinationRoot());
35
+ this.githubUser = await this.user.github.username().catch(debug);
36
+ this.pjson = Object.assign({ scripts: {}, engines: {}, devDependencies: {}, dependencies: {}, oclif: {} }, this.fs.readJSON('package.json', {}));
37
+ let repository = this.destinationRoot().split(path.sep).slice(-2).join('/');
38
+ if (this.githubUser)
39
+ repository = `${this.githubUser}/${repository.split('/')[1]}`;
40
+ const defaults = Object.assign(Object.assign({ name: this.determineAppname().replace(/ /g, '-'), version: '0.0.0', license: 'MIT', author: this.githubUser ? `${this.user.git.name()} @${this.githubUser}` : this.user.git.name(), dependencies: {}, repository }, this.pjson), { engines: Object.assign({ node: '>=8.0.0' }, this.pjson.engines), options: this.options });
41
+ this.repository = defaults.repository;
42
+ if (this.repository && this.repository.url) {
43
+ this.repository = this.repository.url;
44
+ }
45
+ if (this.options.defaults) {
46
+ this.answers = defaults;
47
+ }
48
+ else {
49
+ this.answers = await this.prompt([
50
+ {
51
+ type: 'input',
52
+ name: 'name',
53
+ message: 'npm package name',
54
+ default: defaults.name,
55
+ },
56
+ {
57
+ type: 'input',
58
+ name: 'bin',
59
+ message: 'command bin name the CLI will export',
60
+ default: (answers) => answers.name,
61
+ },
62
+ {
63
+ type: 'input',
64
+ name: 'description',
65
+ message: 'description',
66
+ default: defaults.description,
67
+ },
68
+ {
69
+ type: 'input',
70
+ name: 'author',
71
+ message: 'author',
72
+ default: defaults.author,
73
+ },
74
+ {
75
+ type: 'input',
76
+ name: 'version',
77
+ message: 'version',
78
+ default: defaults.version,
79
+ when: !this.pjson.version,
80
+ },
81
+ {
82
+ type: 'input',
83
+ name: 'license',
84
+ message: 'license',
85
+ default: defaults.license,
86
+ },
87
+ {
88
+ type: 'input',
89
+ name: 'github.user',
90
+ message: 'Who is the GitHub owner of repository (https://github.com/OWNER/repo)',
91
+ default: repository.split('/').slice(0, -1).pop(),
92
+ },
93
+ {
94
+ type: 'input',
95
+ name: 'github.repo',
96
+ message: 'What is the GitHub name of repository (https://github.com/owner/REPO)',
97
+ default: (answers) => (this.pjson.repository || answers.name || this.pjson.name).split('/').pop(),
98
+ },
99
+ {
100
+ type: 'list',
101
+ name: 'pkg',
102
+ message: 'Select a package manager',
103
+ choices: [
104
+ { name: 'npm', value: 'npm' },
105
+ { name: 'yarn', value: 'yarn' },
106
+ ],
107
+ default: () => this.options.yarn || hasYarn ? 1 : 0,
108
+ },
109
+ ]);
110
+ }
111
+ debug(this.answers);
112
+ if (!this.options.defaults) {
113
+ this.options = Object.assign(Object.assign({}, this.answers.ci), { yarn: this.answers.pkg === 'yarn' });
114
+ }
115
+ this.yarn = this.options.yarn;
116
+ this.pjson.name = this.answers.name || defaults.name;
117
+ this.pjson.description = this.answers.description || defaults.description;
118
+ this.pjson.version = this.answers.version || defaults.version;
119
+ this.pjson.engines.node = defaults.engines.node;
120
+ this.pjson.author = this.answers.author || defaults.author;
121
+ this.pjson.files = this.answers.files || defaults.files || '/lib';
122
+ this.pjson.license = this.answers.license || defaults.license;
123
+ // eslint-disable-next-line no-multi-assign
124
+ this.repository = this.pjson.repository = this.answers.github ? `${this.answers.github.user}/${this.answers.github.repo}` : defaults.repository;
125
+ this.pjson.homepage = `https://github.com/${this.repository}`;
126
+ this.pjson.bugs = `https://github.com/${this.repository}/issues`;
127
+ this.pjson.oclif.bin = this.answers.bin;
128
+ this.pjson.bin = {};
129
+ this.pjson.bin[this.pjson.oclif.bin] = './bin/run';
130
+ }
131
+ writing() {
132
+ if (this.pjson.oclif && Array.isArray(this.pjson.oclif.plugins)) {
133
+ this.pjson.oclif.plugins.sort();
134
+ }
135
+ if (this.fs.exists(this.destinationPath('./package.json'))) {
136
+ fixpack(this.destinationPath('./package.json'), require('@oclif/fixpack/config.json'));
137
+ }
138
+ if (_.isEmpty(this.pjson.oclif))
139
+ delete this.pjson.oclif;
140
+ this.pjson.files = _.uniq((this.pjson.files || []).sort());
141
+ this.fs.writeJSON(this.destinationPath('./package.json'), sortPjson(this.pjson));
142
+ this.fs.write(this.destinationPath('.gitignore'), this._gitignore());
143
+ }
144
+ async install() {
145
+ const dependencies = [];
146
+ const devDependencies = [];
147
+ if (isWindows)
148
+ devDependencies.push('rimraf');
149
+ const yarnOpts = {};
150
+ if (process.env.YARN_MUTEX)
151
+ yarnOpts.mutex = process.env.YARN_MUTEX;
152
+ const install = (deps, opts) => this.yarn ? this.yarnInstall(deps, opts) : this.npmInstall(deps, opts);
153
+ const dev = this.yarn ? { dev: true } : { 'save-dev': true };
154
+ const save = this.yarn ? {} : { save: true };
155
+ return Promise.all([
156
+ install(devDependencies, Object.assign(Object.assign(Object.assign({}, yarnOpts), dev), { ignoreScripts: true })),
157
+ install(dependencies, Object.assign(Object.assign({}, yarnOpts), save)),
158
+ ]).then(() => { });
159
+ }
160
+ end() {
161
+ this.spawnCommandSync(path.join('.', 'node_modules/.bin/oclif'), ['readme']);
162
+ console.log(`\nCreated ${this.pjson.name} in ${this.destinationRoot()}`);
163
+ }
164
+ _gitignore() {
165
+ const existing = this.fs.exists(this.destinationPath('.gitignore')) ? this.fs.read(this.destinationPath('.gitignore')).split('\n') : [];
166
+ return _([
167
+ '*-debug.log',
168
+ '*-error.log',
169
+ 'node_modules',
170
+ '/tmp',
171
+ '/dist',
172
+ this.yarn ? '/package-lock.json' : '/yarn.lock',
173
+ '/lib',
174
+ ])
175
+ .concat(existing)
176
+ .compact()
177
+ .uniq()
178
+ .sort()
179
+ .join('\n') + '\n';
180
+ }
181
+ }
182
+ module.exports = App;
@@ -1,12 +1,11 @@
1
- import { HelpBase } from '@oclif/plugin-help';
2
- import { Command } from '@oclif/config';
1
+ import { Interfaces, HelpBase } from '@oclif/core';
3
2
  interface MaybeCompatibleHelp extends HelpBase {
4
- formatCommand?: (command: Command) => string;
5
- command?: (command: Command) => string;
3
+ formatCommand?: (command: Interfaces.Command) => string;
4
+ command?: (command: Interfaces.Command) => string;
6
5
  }
7
6
  export declare class HelpCompatibilityWrapper {
8
7
  inner: MaybeCompatibleHelp;
9
8
  constructor(inner: MaybeCompatibleHelp);
10
- formatCommand(command: Command): string;
9
+ formatCommand(command: Interfaces.Command): string;
11
10
  }
12
11
  export {};
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HelpCompatibilityWrapper = void 0;
3
4
  class IncompatibleHelpError extends Error {
4
5
  constructor() {
5
6
  super(...arguments);
package/lib/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { run } from '@oclif/command';
1
+ export { run } from '@oclif/core';
2
2
  export { IManifest } from './tarballs';
package/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var command_1 = require("@oclif/command");
4
- exports.run = command_1.run;
3
+ exports.run = void 0;
4
+ var core_1 = require("@oclif/core");
5
+ Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
package/lib/log.js CHANGED
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.log = exports.debug = void 0;
3
4
  const cli_ux_1 = require("cli-ux");
4
5
  const qq = require("qqjs");
5
6
  const util = require("util");
6
7
  exports.debug = require('debug')('oclif');
7
8
  exports.debug.new = (name) => require('debug')(`oclif:${name}`);
8
9
  function log(format, ...args) {
9
- args = args.map(arg => qq.prettifyPaths(arg));
10
- exports.debug.enabled ? exports.debug(format, ...args) : cli_ux_1.default.log(`oclif: ${util.format(format, ...args)}`);
10
+ args = args.map((arg) => qq.prettifyPaths(arg));
11
+ exports.debug.enabled ? (0, exports.debug)(format, ...args) : cli_ux_1.default.log(`oclif: ${util.format(format, ...args)}`);
11
12
  }
12
13
  exports.log = log;
@@ -1,6 +1,6 @@
1
- import * as Config from '@oclif/config';
1
+ import { Interfaces } from '@oclif/core';
2
2
  export declare function writeBinScripts({ config, baseWorkspace, nodeVersion }: {
3
- config: Config.IConfig;
3
+ config: Interfaces.Config;
4
4
  baseWorkspace: string;
5
5
  nodeVersion: string;
6
6
  }): Promise<void>;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writeBinScripts = void 0;
3
4
  const qq = require("qqjs");
4
5
  async function writeBinScripts({ config, baseWorkspace, nodeVersion }) {
5
6
  const binPathEnvVar = config.scopedEnvVarKey('BINPATH');
@@ -7,7 +8,7 @@ async function writeBinScripts({ config, baseWorkspace, nodeVersion }) {
7
8
  const clientHomeEnvVar = config.scopedEnvVarKey('OCLIF_CLIENT_HOME');
8
9
  const writeWin32 = async () => {
9
10
  const { bin } = config;
10
- await qq.write([baseWorkspace, 'bin', `${bin}.cmd`], `@echo off
11
+ await qq.write([baseWorkspace, 'bin', `${config.bin}.cmd`], `@echo off
11
12
  setlocal enableextensions
12
13
 
13
14
  if not "%${redirectedEnvVar}%"=="1" if exist "%LOCALAPPDATA%\\${bin}\\client\\bin\\${bin}.cmd" (
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.build = void 0;
3
4
  const findYarnWorkspaceRoot = require("find-yarn-workspace-root");
4
5
  const path = require("path");
5
6
  const qq = require("qqjs");
@@ -11,14 +12,14 @@ const pack = async (from, to) => {
11
12
  const prevCwd = qq.cwd();
12
13
  qq.cd(path.dirname(from));
13
14
  await qq.mkdirp(path.dirname(to));
14
- log_1.log(`packing tarball from ${qq.prettifyPaths(from)} to ${qq.prettifyPaths(to)}`);
15
+ (0, log_1.log)(`packing tarball from ${qq.prettifyPaths(from)} to ${qq.prettifyPaths(to)}`);
15
16
  await (to.endsWith('gz') ?
16
17
  qq.x('tar', ['czf', to, path.basename(from)]) :
17
18
  qq.x(`tar c ${path.basename(from)} | xz > ${to}`));
18
19
  qq.cd(prevCwd);
19
20
  };
20
21
  async function build(c, options = {}) {
21
- const { xz, config, version, s3Config, gitSha, nodeVersion, targets, updateConfig } = c;
22
+ const { xz, config } = c;
22
23
  const prevCwd = qq.cwd();
23
24
  const packCLI = async () => {
24
25
  const stdout = await qq.x.stdout('npm', ['pack', '--unsafe-perm'], { cwd: c.root });
@@ -39,10 +40,10 @@ async function build(c, options = {}) {
39
40
  const updatePJSON = async () => {
40
41
  qq.cd(c.workspace());
41
42
  const pjson = await qq.readJSON('package.json');
42
- pjson.version = version;
43
+ pjson.version = config.version;
43
44
  pjson.oclif.update = pjson.oclif.update || {};
44
45
  pjson.oclif.update.s3 = pjson.oclif.update.s3 || {};
45
- pjson.oclif.update.s3.bucket = s3Config.bucket;
46
+ pjson.oclif.update.s3.bucket = c.s3Config.bucket;
46
47
  await qq.writeJSON('package.json', pjson);
47
48
  };
48
49
  const addDependencies = async () => {
@@ -75,27 +76,27 @@ async function build(c, options = {}) {
75
76
  };
76
77
  const buildTarget = async (target) => {
77
78
  const workspace = c.workspace(target);
78
- const gzLocalKey = upload_util_1.templateShortKey('versioned', '.tar.gz', {
79
+ const gzLocalKey = (0, upload_util_1.templateShortKey)('versioned', '.tar.gz', {
79
80
  arch: target.arch,
80
- bin: config.bin,
81
+ bin: c.config.bin,
81
82
  platform: target.platform,
82
- sha: gitSha,
83
+ sha: c.gitSha,
83
84
  version: config.version,
84
85
  });
85
- const xzLocalKey = upload_util_1.templateShortKey('versioned', '.tar.xz', {
86
+ const xzLocalKey = (0, upload_util_1.templateShortKey)('versioned', '.tar.xz', {
86
87
  arch: target.arch,
87
- bin: config.bin,
88
+ bin: c.config.bin,
88
89
  platform: target.platform,
89
- sha: gitSha,
90
+ sha: c.gitSha,
90
91
  version: config.version,
91
92
  });
92
93
  const base = path.basename(gzLocalKey);
93
- log_1.log(`building target ${base}`);
94
- log_1.log('copying workspace', c.workspace(), workspace);
94
+ (0, log_1.log)(`building target ${base}`);
95
+ (0, log_1.log)('copying workspace', c.workspace(), workspace);
95
96
  await qq.rm(workspace);
96
97
  await qq.cp(c.workspace(), workspace);
97
- await node_1.fetchNodeBinary({
98
- nodeVersion: nodeVersion,
98
+ await (0, node_1.fetchNodeBinary)({
99
+ nodeVersion: c.nodeVersion,
99
100
  output: path.join(workspace, 'bin', 'node'),
100
101
  platform: target.platform,
101
102
  arch: target.arch,
@@ -106,41 +107,41 @@ async function build(c, options = {}) {
106
107
  await pack(workspace, c.dist(gzLocalKey));
107
108
  if (xz)
108
109
  await pack(workspace, c.dist(xzLocalKey));
109
- if (!updateConfig.s3.host)
110
+ if (!c.updateConfig.s3.host)
110
111
  return;
111
- const rollout = (typeof updateConfig.autoupdate === 'object' && updateConfig.autoupdate.rollout);
112
- const gzCloudKey = `${upload_util_1.commitAWSDir(version, gitSha, updateConfig.s3)}/${gzLocalKey}`;
113
- const xzCloudKey = `${upload_util_1.commitAWSDir(version, gitSha, updateConfig.s3)}/${xzLocalKey}`;
112
+ const rollout = (typeof c.updateConfig.autoupdate === 'object' && c.updateConfig.autoupdate.rollout);
113
+ const gzCloudKey = `${(0, upload_util_1.commitAWSDir)(config.version, c.gitSha, c.updateConfig.s3)}/${gzLocalKey}`;
114
+ const xzCloudKey = `${(0, upload_util_1.commitAWSDir)(config.version, c.gitSha, c.updateConfig.s3)}/${xzLocalKey}`;
114
115
  const manifest = {
115
116
  rollout: rollout === false ? undefined : rollout,
116
- version: version,
117
- sha: gitSha,
118
- baseDir: upload_util_1.templateShortKey('baseDir', target, { bin: config.bin }),
117
+ version: config.version,
118
+ sha: c.gitSha,
119
+ baseDir: (0, upload_util_1.templateShortKey)('baseDir', target, { bin: c.config.bin }),
119
120
  gz: config.s3Url(gzCloudKey),
120
121
  xz: xz ? config.s3Url(xzCloudKey) : undefined,
121
122
  sha256gz: await qq.hash('sha256', c.dist(gzLocalKey)),
122
123
  sha256xz: xz ? await qq.hash('sha256', c.dist(xzLocalKey)) : undefined,
123
124
  node: {
124
125
  compatible: config.pjson.engines.node,
125
- recommended: nodeVersion,
126
+ recommended: c.nodeVersion,
126
127
  },
127
128
  };
128
- const manifestFilepath = c.dist(upload_util_1.templateShortKey('manifest', {
129
+ const manifestFilepath = c.dist((0, upload_util_1.templateShortKey)('manifest', {
129
130
  arch: target.arch,
130
- bin: config.bin,
131
+ bin: c.config.bin,
131
132
  platform: target.platform,
132
- sha: gitSha,
133
+ sha: c.gitSha,
133
134
  version: config.version,
134
135
  }));
135
136
  await qq.writeJSON(manifestFilepath, manifest);
136
137
  };
137
- log_1.log(`gathering workspace for ${config.bin} to ${c.workspace()}`);
138
+ (0, log_1.log)(`gathering workspace for ${config.bin} to ${c.workspace()}`);
138
139
  await extractCLI(await packCLI());
139
140
  await updatePJSON();
140
141
  await addDependencies();
141
- await bin_1.writeBinScripts({ config, baseWorkspace: c.workspace(), nodeVersion: nodeVersion });
142
+ await (0, bin_1.writeBinScripts)({ config, baseWorkspace: c.workspace(), nodeVersion: c.nodeVersion });
142
143
  await pretarball();
143
- for (const target of targets) {
144
+ for (const target of c.targets) {
144
145
  if (!options.platform || options.platform === target.platform) {
145
146
  // eslint-disable-next-line no-await-in-loop
146
147
  await buildTarget(target);
@@ -1,11 +1,10 @@
1
- import * as Config from '@oclif/config';
1
+ import { Interfaces } from '@oclif/core';
2
2
  export declare const TARGETS: string[];
3
3
  export interface BuildConfig {
4
4
  root: string;
5
5
  gitSha: string;
6
- config: Config.IConfig;
6
+ config: Interfaces.Config;
7
7
  nodeVersion: string;
8
- version: string;
9
8
  tmp: string;
10
9
  updateConfig: BuildConfig['config']['pjson']['oclif']['update'];
11
10
  s3Config: BuildConfig['updateConfig']['s3'] & {
@@ -14,12 +13,12 @@ export interface BuildConfig {
14
13
  };
15
14
  xz: boolean;
16
15
  targets: {
17
- platform: Config.PlatformTypes;
18
- arch: Config.ArchTypes;
16
+ platform: Interfaces.PlatformTypes;
17
+ arch: Interfaces.ArchTypes;
19
18
  }[];
20
19
  workspace(target?: {
21
- platform: Config.PlatformTypes;
22
- arch: Config.ArchTypes;
20
+ platform: Interfaces.PlatformTypes;
21
+ arch: Interfaces.ArchTypes;
23
22
  }): string;
24
23
  dist(input: string): string;
25
24
  }
@@ -1,18 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const Config = require("@oclif/config");
3
+ exports.buildConfig = exports.gitSha = exports.TARGETS = void 0;
4
+ const core_1 = require("@oclif/core");
4
5
  const path = require("path");
5
6
  const qq = require("qqjs");
7
+ const semver = require("semver");
6
8
  const util_1 = require("../util");
7
9
  const upload_util_1 = require("../upload-util");
10
+ const cli_ux_1 = require("cli-ux");
8
11
  exports.TARGETS = [
9
12
  'linux-x64',
10
13
  'linux-arm',
11
14
  'win32-x64',
12
15
  'win32-x86',
13
16
  'darwin-x64',
17
+ 'darwin-arm64',
14
18
  ];
15
- function gitSha(cwd, options = {}) {
19
+ async function gitSha(cwd, options = {}) {
16
20
  const args = options.short ? ['rev-parse', '--short', 'HEAD'] : ['rev-parse', 'HEAD'];
17
21
  return qq.x.stdout('git', args, { cwd });
18
22
  }
@@ -23,35 +27,43 @@ async function Tmp(config) {
23
27
  return tmp;
24
28
  }
25
29
  async function buildConfig(root, options = {}) {
26
- const config = await Config.load({ root: path.resolve(root), devPlugins: false, userPlugins: false });
30
+ const config = await core_1.Config.load({ root: path.resolve(root), devPlugins: false, userPlugins: false });
27
31
  root = config.root;
28
32
  const _gitSha = await gitSha(root, { short: true });
29
- const version = config.version.includes('-') ? `${config.version}.${_gitSha}` : config.version;
30
33
  // eslint-disable-next-line new-cap
31
34
  const tmp = await Tmp(config);
32
35
  const updateConfig = config.pjson.oclif.update || {};
33
36
  updateConfig.s3 = updateConfig.s3 || {};
37
+ const nodeVersion = updateConfig.node.version || process.versions.node;
38
+ const targets = (0, util_1.compact)(options.targets || updateConfig.node.targets || exports.TARGETS)
39
+ .filter(t => {
40
+ if (t === 'darwin-arm64' && semver.lt(nodeVersion, '16.0.0')) {
41
+ cli_ux_1.cli.warn('darwin-arm64 is only supported for node >=16.0.0. Skipping...');
42
+ return false;
43
+ }
44
+ return true;
45
+ })
46
+ .map(t => {
47
+ const [platform, arch] = t.split('-');
48
+ return { platform, arch };
49
+ });
34
50
  return {
35
51
  root,
36
52
  gitSha: _gitSha,
37
53
  config,
38
54
  tmp,
39
55
  updateConfig,
40
- version,
41
56
  xz: typeof options.xz === 'boolean' ? options.xz : Boolean(updateConfig.s3.xz),
42
57
  dist: (...args) => path.join(config.root, 'dist', ...args),
43
58
  s3Config: updateConfig.s3,
44
- nodeVersion: updateConfig.node.version || process.versions.node,
59
+ nodeVersion,
45
60
  workspace(target) {
46
61
  const base = qq.join(config.root, 'tmp');
47
62
  if (target && target.platform)
48
- return qq.join(base, [target.platform, target.arch].join('-'), upload_util_1.templateShortKey('baseDir', { bin: config.bin }));
49
- return qq.join(base, upload_util_1.templateShortKey('baseDir', { bin: config.bin }));
63
+ return qq.join(base, [target.platform, target.arch].join('-'), (0, upload_util_1.templateShortKey)('baseDir', { bin: config.bin }));
64
+ return qq.join(base, (0, upload_util_1.templateShortKey)('baseDir', { bin: config.bin }));
50
65
  },
51
- targets: util_1.compact(options.targets || updateConfig.node.targets || exports.TARGETS).map(t => {
52
- const [platform, arch] = t.split('-');
53
- return { platform, arch };
54
- }),
66
+ targets,
55
67
  };
56
68
  }
57
69
  exports.buildConfig = buildConfig;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./bin"), exports);
5
- tslib_1.__exportStar(require("./build"), exports);
6
- tslib_1.__exportStar(require("./config"), exports);
7
- tslib_1.__exportStar(require("./node"), exports);
4
+ (0, tslib_1.__exportStar)(require("./bin"), exports);
5
+ (0, tslib_1.__exportStar)(require("./build"), exports);
6
+ (0, tslib_1.__exportStar)(require("./config"), exports);
7
+ (0, tslib_1.__exportStar)(require("./node"), exports);
@@ -1,7 +1,10 @@
1
- export declare function fetchNodeBinary({ nodeVersion, output, platform, arch, tmp }: {
1
+ import { Interfaces } from '@oclif/core';
2
+ declare type Options = {
2
3
  nodeVersion: string;
3
4
  output: string;
4
- platform: string;
5
- arch: string;
5
+ platform: Interfaces.PlatformTypes;
6
+ arch: Interfaces.ArchTypes | 'armv7l';
6
7
  tmp: string;
7
- }): Promise<string>;
8
+ };
9
+ export declare function fetchNodeBinary({ nodeVersion, output, platform, arch, tmp }: Options): Promise<string>;
10
+ export {};