oclif 4.0.0 → 4.0.2

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/lib/aws.d.ts CHANGED
@@ -1,14 +1,5 @@
1
1
  import * as CloudFront from 'aws-sdk/clients/cloudfront';
2
2
  import * as S3 from 'aws-sdk/clients/s3';
3
- export declare namespace upload {
4
- interface Options {
5
- localFile: string;
6
- s3Params: {
7
- Bucket: string;
8
- Key: string;
9
- };
10
- }
11
- }
12
3
  declare const _default: {
13
4
  readonly cloudfront: {
14
5
  createCloudfrontInvalidation: (options: CloudFront.Types.CreateInvalidationRequest) => Promise<unknown>;
package/lib/aws.js CHANGED
@@ -34,8 +34,9 @@ const aws = {
34
34
  return cache.s3;
35
35
  }
36
36
  catch (error) {
37
- if (error.code === 'MODULE_NOT_FOUND')
38
- throw new Error(`${error.message}\naws-sdk is needed to run this command.\nInstall aws-sdk as a devDependency in your CLI. \`yarn add -D aws-sdk\``);
37
+ const { code, message } = error;
38
+ if (code === 'MODULE_NOT_FOUND')
39
+ throw new Error(`${message}\naws-sdk is needed to run this command.\nInstall aws-sdk as a devDependency in your CLI. \`yarn add -D aws-sdk\``);
39
40
  throw error;
40
41
  }
41
42
  },
@@ -268,7 +268,7 @@ the CLI should already exist in a directory named after the CLI that is the root
268
268
  });
269
269
  const o = buildConfig.dist(`win32/${templateKey}`);
270
270
  await (0, fs_extra_1.move)(path.join(installerBase, 'installer.exe'), o);
271
- const windows = config.pjson.oclif.windows;
271
+ const { windows } = config.pjson.oclif;
272
272
  if (windows && windows.name && windows.keypath) {
273
273
  await signWindows(o, arch, config, windows);
274
274
  }
@@ -282,9 +282,10 @@ the CLI should already exist in a directory named after the CLI that is the root
282
282
  await exec('makensis');
283
283
  }
284
284
  catch (error) {
285
- if (error.code === 1)
285
+ const { code } = error;
286
+ if (code === 1)
286
287
  return;
287
- if (error.code === 127)
288
+ if (code === 127)
288
289
  this.error('install makensis');
289
290
  else
290
291
  throw error;
@@ -61,9 +61,10 @@ class Promote extends core_1.Command {
61
61
  });
62
62
  };
63
63
  const promoteGzTarballs = async (target) => {
64
- const versionedTarGzName = (0, upload_util_1.templateShortKey)('versioned', '.tar.gz', {
64
+ const versionedTarGzName = (0, upload_util_1.templateShortKey)('versioned', {
65
65
  arch: target.arch,
66
66
  bin: config.bin,
67
+ ext: '.tar.gz',
67
68
  platform: target.platform,
68
69
  sha: flags.sha,
69
70
  version: flags.version,
@@ -84,9 +85,10 @@ class Promote extends core_1.Command {
84
85
  ]);
85
86
  };
86
87
  const promoteXzTarballs = async (target) => {
87
- const versionedTarXzName = (0, upload_util_1.templateShortKey)('versioned', '.tar.xz', {
88
+ const versionedTarXzName = (0, upload_util_1.templateShortKey)('versioned', {
88
89
  arch: target.arch,
89
90
  bin: config.bin,
91
+ ext: '.tar.xz',
90
92
  platform: target.platform,
91
93
  sha: flags.sha,
92
94
  version: flags.version,
@@ -129,7 +129,8 @@ Customize the code URL prefix by setting oclif.repositoryPrefix in package.json.
129
129
  ]).join('\n\n');
130
130
  }
131
131
  catch (error) {
132
- this.error(error.message);
132
+ const { message } = error;
133
+ this.error(message);
133
134
  }
134
135
  }
135
136
  replaceTag(readme, tag, body) {
@@ -40,7 +40,7 @@ class UploadDeb extends core_1.Command {
40
40
  };
41
41
  const uploadDeb = async (arch) => {
42
42
  const deb = (0, upload_util_1.templateShortKey)('deb', {
43
- arch: arch,
43
+ arch,
44
44
  bin: config.bin,
45
45
  versionShaRevision: (0, upload_util_1.debVersion)(buildConfig),
46
46
  });
@@ -51,7 +51,7 @@ class UploadTarballs extends core_1.Command {
51
51
  version: config.version,
52
52
  };
53
53
  const releaseTarballs = async (ext) => {
54
- const localKey = (0, upload_util_1.templateShortKey)('versioned', ext, shortKeyInputs);
54
+ const localKey = (0, upload_util_1.templateShortKey)('versioned', { ...shortKeyInputs, ext });
55
55
  const cloudKey = `${(0, upload_util_1.commitAWSDir)(config.version, buildConfig.gitSha, s3Config)}/${localKey}`;
56
56
  await aws_1.default.s3.uploadFile(dist(localKey), {
57
57
  ...S3Options,
@@ -1,3 +1,4 @@
1
+ import { Interfaces } from '@oclif/core';
1
2
  import * as Generator from 'yeoman-generator';
2
3
  export default class CLI extends Generator {
3
4
  answers: {
@@ -29,7 +30,7 @@ export default class CLI extends Generator {
29
30
  force: boolean;
30
31
  yarn: boolean;
31
32
  };
32
- pjson: any;
33
+ pjson: Interfaces.PJSON.Plugin;
33
34
  repository?: string;
34
35
  yarn: boolean;
35
36
  constructor(args: string | string[], opts: Generator.GeneratorOptions);
@@ -13,6 +13,9 @@ try {
13
13
  hasYarn = true;
14
14
  }
15
15
  catch { }
16
+ function removeKey(obj, key) {
17
+ delete obj[key];
18
+ }
16
19
  class CLI extends Generator {
17
20
  answers;
18
21
  githubUser;
@@ -42,7 +45,6 @@ class CLI extends Generator {
42
45
  });
43
46
  console.log(`\nCreated ${this.pjson.name} in ${this.destinationRoot()}`);
44
47
  }
45
- // eslint-disable-next-line complexity
46
48
  async prompting() {
47
49
  const msg = 'Time to build an oclif CLI!';
48
50
  this.log(`${msg} Version: ${version}`);
@@ -80,6 +82,7 @@ class CLI extends Generator {
80
82
  license: '',
81
83
  main: '',
82
84
  name: '',
85
+ // @ts-expect-error because required props will be added later
83
86
  oclif: {},
84
87
  repository: '',
85
88
  scripts: {},
@@ -90,6 +93,8 @@ class CLI extends Generator {
90
93
  if (this.githubUser)
91
94
  repository = `${this.githubUser}/${repository.split('/')[1]}`;
92
95
  const defaults = {
96
+ description: '',
97
+ files: [],
93
98
  ...this.pjson,
94
99
  author: this.githubUser ? `${this.user.git.name()} @${this.githubUser}` : this.user.git.name(),
95
100
  bin: this.name,
@@ -104,10 +109,6 @@ class CLI extends Generator {
104
109
  repository,
105
110
  version: '0.0.0',
106
111
  };
107
- this.repository = defaults.repository;
108
- if (this.repository && this.repository.url) {
109
- this.repository = this.repository.url;
110
- }
111
112
  this.answers = this.options.defaults
112
113
  ? defaults
113
114
  : await this.prompt([
@@ -208,7 +209,7 @@ class CLI extends Generator {
208
209
  this.pjson.oclif.plugins.sort();
209
210
  }
210
211
  if ((0, util_1.isEmpty)(this.pjson.oclif))
211
- delete this.pjson.oclif;
212
+ removeKey(this.pjson, 'oclif');
212
213
  this.pjson.files = (0, util_1.uniq)((this.pjson.files || []).sort());
213
214
  this.fs.writeJSON(this.destinationPath('./package.json'), this.pjson);
214
215
  this.fs.write(this.destinationPath('.gitignore'), this._gitignore());
package/lib/log.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export declare const debug: any;
2
- export declare function log(format: string, ...args: any[]): void;
2
+ export declare function log(format: string, ...args: unknown[]): void;
@@ -94,16 +94,18 @@ async function build(c, options = {}) {
94
94
  };
95
95
  const buildTarget = async (target) => {
96
96
  const workspace = c.workspace(target);
97
- const gzLocalKey = (0, upload_util_1.templateShortKey)('versioned', '.tar.gz', {
97
+ const gzLocalKey = (0, upload_util_1.templateShortKey)('versioned', {
98
98
  arch: target.arch,
99
99
  bin: c.config.bin,
100
+ ext: '.tar.gz',
100
101
  platform: target.platform,
101
102
  sha: c.gitSha,
102
103
  version: config.version,
103
104
  });
104
- const xzLocalKey = (0, upload_util_1.templateShortKey)('versioned', '.tar.xz', {
105
+ const xzLocalKey = (0, upload_util_1.templateShortKey)('versioned', {
105
106
  arch: target.arch,
106
107
  bin: c.config.bin,
108
+ ext: '.tar.xz',
107
109
  platform: target.platform,
108
110
  sha: c.gitSha,
109
111
  version: config.version,
@@ -140,7 +142,7 @@ async function build(c, options = {}) {
140
142
  ...(xz ? [(0, util_1.hash)('sha256', c.dist(xzLocalKey))] : []),
141
143
  ]);
142
144
  const manifest = {
143
- baseDir: (0, upload_util_1.templateShortKey)('baseDir', target, { bin: c.config.bin }),
145
+ baseDir: (0, upload_util_1.templateShortKey)('baseDir', { ...target, bin: c.config.bin }),
144
146
  gz: config.s3Url(gzCloudKey),
145
147
  node: {
146
148
  compatible: config.pjson.engines.node,
@@ -2,7 +2,16 @@ import { Interfaces } from '@oclif/core';
2
2
  import { BuildConfig as TarballConfig } from './tarballs/config';
3
3
  export declare function commitAWSDir(version: string, sha: string, s3Config: TarballConfig['s3Config']): string;
4
4
  export declare function channelAWSDir(channel: string, s3Config: TarballConfig['s3Config']): string;
5
- export declare function templateShortKey(type: 'deb' | 'macos' | 'win32' | keyof Interfaces.PJSON.S3.Templates, ext?: '.tar.gz' | '.tar.xz' | Interfaces.Config.s3Key.Options, options?: Interfaces.Config.s3Key.Options): string;
5
+ type TemplateOptions = {
6
+ arch?: DebArch | Interfaces.ArchTypes;
7
+ bin?: string;
8
+ ext?: '.tar.gz' | '.tar.xz';
9
+ sha?: string;
10
+ version?: string;
11
+ versionShaRevision?: string;
12
+ } | Interfaces.Config.s3Key.Options;
13
+ export declare function templateShortKey(type: 'deb' | 'macos' | 'win32' | keyof Interfaces.PJSON.S3.Templates, options?: TemplateOptions): string;
6
14
  export type DebArch = 'amd64' | 'arm64' | 'armel' | 'i386';
7
15
  export declare function debArch(arch: Interfaces.ArchTypes): DebArch;
8
16
  export declare function debVersion(buildConfig: TarballConfig): string;
17
+ export {};
@@ -1,33 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.debVersion = exports.debArch = exports.templateShortKey = exports.channelAWSDir = exports.commitAWSDir = void 0;
4
- const path = require("node:path");
4
+ const node_path_1 = require("node:path");
5
5
  const template = require("lodash.template");
6
6
  function commitAWSDir(version, sha, s3Config) {
7
7
  let s3SubDir = s3Config.folder || '';
8
8
  if (s3SubDir !== '' && s3SubDir.slice(-1) !== '/')
9
9
  s3SubDir = `${s3SubDir}/`;
10
- return path.join(s3SubDir, 'versions', version, sha);
10
+ return (0, node_path_1.join)(s3SubDir, 'versions', version, sha);
11
11
  }
12
12
  exports.commitAWSDir = commitAWSDir;
13
13
  function channelAWSDir(channel, s3Config) {
14
14
  let s3SubDir = s3Config.folder || '';
15
15
  if (s3SubDir !== '' && s3SubDir.slice(-1) !== '/')
16
16
  s3SubDir = `${s3SubDir}/`;
17
- return path.join(s3SubDir, 'channels', channel);
17
+ return (0, node_path_1.join)(s3SubDir, 'channels', channel);
18
18
  }
19
19
  exports.channelAWSDir = channelAWSDir;
20
- // to-do:
21
- // When this pkg starts using oclif/core
22
- // refactor this key name lookup
23
- // helper to oclif/core
24
- function templateShortKey(type, ext,
25
- // eslint-disable-next-line unicorn/no-object-as-default-parameter
26
- options = { root: '.' }) {
27
- if (typeof ext === 'object')
28
- options = Object.assign(options, ext);
29
- else if (ext)
30
- options.ext = ext;
20
+ // TODO: refactor this key name lookup helper to oclif/core
21
+ function templateShortKey(type, options) {
22
+ if (!options)
23
+ options = {
24
+ root: '.',
25
+ };
31
26
  const templates = {
32
27
  baseDir: '<%- bin %>',
33
28
  deb: '<%- bin %>_<%- versionShaRevision %>_<%- arch %>.deb',
package/lib/util.d.ts CHANGED
@@ -1,17 +1,15 @@
1
1
  export declare function castArray<T>(input?: T | T[]): T[];
2
- export declare function uniqBy<T>(arr: T[], fn: (cur: T) => any): T[];
2
+ export declare function uniqBy<T>(arr: T[], fn: (cur: T) => unknown): T[];
3
3
  export declare function compact<T>(a: (T | undefined)[]): T[];
4
4
  export declare function uniq<T>(arr: T[]): T[];
5
- export declare function sortBy<T>(arr: T[], fn: (i: T) => sort.Types | sort.Types[]): T[];
6
- export declare namespace sort {
7
- type Types = boolean | number | string | undefined;
8
- }
9
- export declare const template: (context: any) => (t: string | undefined) => string;
5
+ type Types = boolean | number | string | undefined;
6
+ export declare function sortBy<T>(arr: T[], fn: (i: T) => Types | Types[]): T[];
7
+ export declare const template: (context: object | undefined) => (t: string | undefined) => string;
10
8
  interface VersionsObject {
11
9
  [key: string]: string;
12
10
  }
13
11
  export declare const sortVersionsObjectByKeysDesc: (input: VersionsObject) => VersionsObject;
14
- export declare const prettifyPaths: (input: string) => string;
12
+ export declare const prettifyPaths: (input: unknown) => string;
15
13
  export declare const hash: (algo: string, fp: string | string[]) => Promise<string>;
16
14
  export declare function checkFor7Zip(): Promise<void>;
17
15
  export declare function isEmpty(obj: Record<string, unknown>): boolean;
package/lib/util.js CHANGED
@@ -104,7 +104,8 @@ async function checkFor7Zip() {
104
104
  await exec('7z');
105
105
  }
106
106
  catch (error) {
107
- if (error.code === 127)
107
+ const { code } = error;
108
+ if (code === 127)
108
109
  core_1.Errors.error('install 7-zip to package windows tarball');
109
110
  else
110
111
  throw error;
@@ -679,5 +679,5 @@
679
679
  ]
680
680
  }
681
681
  },
682
- "version": "4.0.0"
682
+ "version": "4.0.2"
683
683
  }
package/package.json CHANGED
@@ -1,21 +1,20 @@
1
1
  {
2
2
  "name": "oclif",
3
3
  "description": "oclif: create your own CLI",
4
- "version": "4.0.0",
4
+ "version": "4.0.2",
5
5
  "author": "Salesforce",
6
6
  "bin": {
7
7
  "oclif": "bin/run.js"
8
8
  },
9
9
  "bugs": "https://github.com/oclif/oclif/issues",
10
10
  "dependencies": {
11
- "@oclif/core": "^3.0.1",
11
+ "@oclif/core": "^3.0.4",
12
12
  "@oclif/plugin-help": "^5.2.14",
13
13
  "@oclif/plugin-not-found": "^2.3.32",
14
14
  "@oclif/plugin-warn-if-update-available": "^2.0.44",
15
15
  "async-retry": "^1.3.3",
16
16
  "aws-sdk": "^2.1231.0",
17
17
  "change-case": "^4",
18
- "concurrently": "^7.6.0",
19
18
  "debug": "^4.3.3",
20
19
  "eslint-plugin-perfectionist": "^2.1.0",
21
20
  "find-yarn-workspace-root": "^2.0.0",
@@ -47,7 +46,7 @@
47
46
  "chai": "^4.3.7",
48
47
  "commitlint": "^17.7.2",
49
48
  "conventional-changelog-cli": "^2.2.2",
50
- "eslint-config-oclif-typescript": "^2.0.1",
49
+ "eslint-config-oclif-typescript": "^3.0.1",
51
50
  "eslint-config-oclif": "^5.0.0",
52
51
  "eslint-config-prettier": "^9.0.0",
53
52
  "eslint": "^8.50.0",