@oclif/core 3.0.0-beta.2 → 3.0.0-beta.3

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 (81) hide show
  1. package/README.md +9 -7
  2. package/lib/command.d.ts +2 -0
  3. package/lib/command.js +4 -4
  4. package/lib/config/config.d.ts +7 -13
  5. package/lib/config/config.js +85 -139
  6. package/lib/config/index.d.ts +2 -1
  7. package/lib/config/index.js +2 -1
  8. package/lib/config/plugin-loader.d.ts +30 -0
  9. package/lib/config/plugin-loader.js +129 -0
  10. package/lib/config/plugin.d.ts +4 -10
  11. package/lib/config/plugin.js +19 -16
  12. package/lib/config/ts-node.js +2 -2
  13. package/lib/errors/config.js +5 -5
  14. package/lib/errors/handle.d.ts +2 -2
  15. package/lib/errors/handle.js +4 -5
  16. package/lib/errors/index.d.ts +1 -1
  17. package/lib/errors/index.js +1 -1
  18. package/lib/errors/logger.js +3 -3
  19. package/lib/execute.d.ts +49 -0
  20. package/lib/execute.js +62 -0
  21. package/lib/flags.js +6 -4
  22. package/lib/help/index.js +3 -3
  23. package/lib/index.d.ts +9 -7
  24. package/lib/index.js +13 -19
  25. package/lib/interfaces/config.d.ts +25 -26
  26. package/lib/interfaces/parser.d.ts +14 -66
  27. package/lib/interfaces/pjson.d.ts +1 -0
  28. package/lib/interfaces/plugin.d.ts +4 -1
  29. package/lib/main.d.ts +1 -49
  30. package/lib/main.js +7 -62
  31. package/lib/module-loader.d.ts +1 -2
  32. package/lib/module-loader.js +4 -4
  33. package/lib/parser/errors.js +1 -1
  34. package/lib/parser/parse.js +1 -34
  35. package/lib/performance.d.ts +1 -1
  36. package/lib/performance.js +2 -3
  37. package/lib/screen.js +2 -2
  38. package/lib/settings.d.ts +2 -1
  39. package/lib/settings.js +2 -2
  40. package/lib/{cli-ux → ux}/action/base.js +2 -2
  41. package/lib/{cli-ux → ux}/action/spinner.js +1 -1
  42. package/lib/{cli-ux → ux}/config.d.ts +0 -1
  43. package/lib/{cli-ux → ux}/config.js +6 -10
  44. package/lib/{cli-ux → ux}/exit.d.ts +1 -1
  45. package/lib/{cli-ux → ux}/exit.js +1 -1
  46. package/lib/ux/flush.d.ts +1 -0
  47. package/lib/ux/flush.js +27 -0
  48. package/lib/{cli-ux → ux}/index.d.ts +8 -27
  49. package/lib/{cli-ux → ux}/index.js +21 -80
  50. package/lib/{cli-ux → ux}/prompt.js +2 -2
  51. package/lib/{cli-ux → ux}/styled/json.js +3 -3
  52. package/package.json +17 -14
  53. package/flush.d.ts +0 -3
  54. package/flush.js +0 -1
  55. package/handle.js +0 -1
  56. package/lib/cli-ux/action/pride-spinner.d.ts +0 -4
  57. package/lib/cli-ux/action/pride-spinner.js +0 -30
  58. /package/lib/{cli-ux → ux}/action/base.d.ts +0 -0
  59. /package/lib/{cli-ux → ux}/action/simple.d.ts +0 -0
  60. /package/lib/{cli-ux → ux}/action/simple.js +0 -0
  61. /package/lib/{cli-ux → ux}/action/spinner.d.ts +0 -0
  62. /package/lib/{cli-ux → ux}/action/spinners.d.ts +0 -0
  63. /package/lib/{cli-ux → ux}/action/spinners.js +0 -0
  64. /package/lib/{cli-ux → ux}/list.d.ts +0 -0
  65. /package/lib/{cli-ux → ux}/list.js +0 -0
  66. /package/lib/{cli-ux → ux}/prompt.d.ts +0 -0
  67. /package/lib/{cli-ux → ux}/stream.d.ts +0 -0
  68. /package/lib/{cli-ux → ux}/stream.js +0 -0
  69. /package/lib/{cli-ux → ux}/styled/index.d.ts +0 -0
  70. /package/lib/{cli-ux → ux}/styled/index.js +0 -0
  71. /package/lib/{cli-ux → ux}/styled/json.d.ts +0 -0
  72. /package/lib/{cli-ux → ux}/styled/object.d.ts +0 -0
  73. /package/lib/{cli-ux → ux}/styled/object.js +0 -0
  74. /package/lib/{cli-ux → ux}/styled/progress.d.ts +0 -0
  75. /package/lib/{cli-ux → ux}/styled/progress.js +0 -0
  76. /package/lib/{cli-ux → ux}/styled/table.d.ts +0 -0
  77. /package/lib/{cli-ux → ux}/styled/table.js +0 -0
  78. /package/lib/{cli-ux → ux}/styled/tree.d.ts +0 -0
  79. /package/lib/{cli-ux → ux}/styled/tree.js +0 -0
  80. /package/lib/{cli-ux → ux}/wait.d.ts +0 -0
  81. /package/lib/{cli-ux → ux}/wait.js +0 -0
@@ -1,5 +1,5 @@
1
1
  export declare class ExitError extends Error {
2
- 'cli-ux': {
2
+ ux: {
3
3
  exit: number;
4
4
  };
5
5
  code: 'EEXIT';
@@ -6,7 +6,7 @@ class ExitError extends Error {
6
6
  const code = 'EEXIT';
7
7
  super(error ? error.message : `${code}: ${status}`);
8
8
  this.error = error;
9
- this['cli-ux'] = { exit: status };
9
+ this.ux = { exit: status };
10
10
  this.code = code;
11
11
  }
12
12
  }
@@ -0,0 +1 @@
1
+ export default function flush(ms?: number): Promise<void>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const __1 = require("..");
4
+ function timeout(p, ms) {
5
+ function wait(ms, unref = false) {
6
+ return new Promise(resolve => {
7
+ const t = setTimeout(() => resolve(null), ms);
8
+ if (unref)
9
+ t.unref();
10
+ });
11
+ }
12
+ return Promise.race([p, wait(ms, true).then(() => __1.Errors.error('timed out'))]);
13
+ }
14
+ async function _flush() {
15
+ const p = new Promise(resolve => {
16
+ __1.stdout.once('drain', () => resolve(null));
17
+ });
18
+ const flushed = __1.stdout.write('');
19
+ if (flushed) {
20
+ return Promise.resolve();
21
+ }
22
+ return p;
23
+ }
24
+ async function flush(ms = 10000) {
25
+ await timeout(_flush(), ms);
26
+ }
27
+ exports.default = flush;
@@ -1,4 +1,3 @@
1
- import * as Errors from '../errors';
2
1
  import { ActionBase } from './action/base';
3
2
  import { config, Config } from './config';
4
3
  import { ExitError } from './exit';
@@ -7,7 +6,7 @@ import * as styled from './styled';
7
6
  import { Table } from './styled';
8
7
  import * as uxPrompt from './prompt';
9
8
  import uxWait from './wait';
10
- export declare class ux {
9
+ export default class ux {
11
10
  static config: Config;
12
11
  static get prompt(): typeof uxPrompt.prompt;
13
12
  /**
@@ -16,7 +15,6 @@ export declare class ux {
16
15
  static get anykey(): typeof uxPrompt.anykey;
17
16
  static get confirm(): typeof uxPrompt.confirm;
18
17
  static get action(): ActionBase;
19
- static get prideAction(): ActionBase;
20
18
  static styledObject(obj: any, keys?: string[]): void;
21
19
  static styledHeader(header: string): void;
22
20
  static get styledJSON(): typeof styled.styledJSON;
@@ -32,28 +30,11 @@ export declare class ux {
32
30
  static url(text: string, uri: string, params?: {}): void;
33
31
  static annotation(text: string, annotation: string): void;
34
32
  static flush(ms?: number): Promise<void>;
33
+ static error(err: Error | string, options?: {
34
+ code?: string;
35
+ exit?: number;
36
+ }): never;
37
+ static exit(code?: number): never;
38
+ static warn(err: Error | string): void;
35
39
  }
36
- declare const action: ActionBase;
37
- declare const annotation: typeof ux.annotation;
38
- declare const anykey: typeof uxPrompt.anykey;
39
- declare const confirm: typeof uxPrompt.confirm;
40
- declare const debug: typeof ux.debug;
41
- declare const done: typeof ux.done;
42
- declare const error: typeof Errors.error;
43
- declare const exit: typeof Errors.exit;
44
- declare const flush: typeof ux.flush;
45
- declare const info: typeof ux.info;
46
- declare const log: typeof ux.log;
47
- declare const prideAction: ActionBase;
48
- declare const progress: typeof styled.progress;
49
- declare const prompt: typeof uxPrompt.prompt;
50
- declare const styledHeader: typeof ux.styledHeader;
51
- declare const styledJSON: typeof styled.styledJSON;
52
- declare const styledObject: typeof ux.styledObject;
53
- declare const table: typeof styled.Table.table;
54
- declare const trace: typeof ux.trace;
55
- declare const tree: typeof styled.tree;
56
- declare const url: typeof ux.url;
57
- declare const wait: (ms?: number) => Promise<void>;
58
- declare const warn: typeof Errors.warn;
59
- export { action, ActionBase, annotation, anykey, config, Config, confirm, debug, done, error, exit, ExitError, flush, info, IPromptOptions, log, prideAction, progress, prompt, styledHeader, styledJSON, styledObject, table, Table, trace, tree, url, wait, warn, };
40
+ export { ActionBase, config, Config, ExitError, IPromptOptions, Table, };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.warn = exports.wait = exports.url = exports.tree = exports.trace = exports.Table = exports.table = exports.styledObject = exports.styledJSON = exports.styledHeader = exports.prompt = exports.progress = exports.prideAction = exports.log = exports.info = exports.flush = exports.ExitError = exports.exit = exports.error = exports.done = exports.debug = exports.confirm = exports.Config = exports.config = exports.anykey = exports.annotation = exports.ActionBase = exports.action = exports.ux = void 0;
3
+ exports.Table = exports.ExitError = exports.Config = exports.config = exports.ActionBase = void 0;
4
4
  const Errors = require("../errors");
5
5
  const util = require("util");
6
6
  const chalk = require("chalk");
@@ -17,27 +17,8 @@ Object.defineProperty(exports, "Table", { enumerable: true, get: function () { r
17
17
  const uxPrompt = require("./prompt");
18
18
  const wait_1 = require("./wait");
19
19
  const stream_1 = require("./stream");
20
+ const flush_1 = require("./flush");
20
21
  const hyperlinker = require('hyperlinker');
21
- function timeout(p, ms) {
22
- function wait(ms, unref = false) {
23
- return new Promise(resolve => {
24
- const t = setTimeout(() => resolve(null), ms);
25
- if (unref)
26
- t.unref();
27
- });
28
- }
29
- return Promise.race([p, wait(ms, true).then(() => Errors.error('timed out'))]);
30
- }
31
- async function _flush() {
32
- const p = new Promise(resolve => {
33
- stream_1.stdout.once('drain', () => resolve(null));
34
- });
35
- const flushed = stream_1.stdout.write('');
36
- if (flushed) {
37
- return Promise.resolve();
38
- }
39
- return p;
40
- }
41
22
  class ux {
42
23
  static get prompt() {
43
24
  return uxPrompt.prompt;
@@ -54,15 +35,12 @@ class ux {
54
35
  static get action() {
55
36
  return config_1.config.action;
56
37
  }
57
- static get prideAction() {
58
- return config_1.config.prideAction;
59
- }
60
38
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
61
39
  static styledObject(obj, keys) {
62
- this.info(styled.styledObject(obj, keys));
40
+ this.log(styled.styledObject(obj, keys));
63
41
  }
64
42
  static styledHeader(header) {
65
- this.info(chalk.dim('=== ') + chalk.bold(header) + '\n');
43
+ this.log(chalk.dim('=== ') + chalk.bold(header) + '\n');
66
44
  }
67
45
  static get styledJSON() {
68
46
  return styled.styledJSON;
@@ -83,12 +61,12 @@ class ux {
83
61
  config_1.config.action.stop();
84
62
  }
85
63
  static trace(format, ...args) {
86
- if (this.config.outputLevel === 'trace') {
64
+ if (ux.config.outputLevel === 'trace') {
87
65
  stream_1.stdout.write(util.format(format, ...args) + '\n');
88
66
  }
89
67
  }
90
68
  static debug(format, ...args) {
91
- if (['trace', 'debug'].includes(this.config.outputLevel)) {
69
+ if (['trace', 'debug'].includes(ux.config.outputLevel)) {
92
70
  stream_1.stdout.write(util.format(format, ...args) + '\n');
93
71
  }
94
72
  }
@@ -118,58 +96,21 @@ class ux {
118
96
  }
119
97
  }
120
98
  static async flush(ms = 10000) {
121
- await timeout(_flush(), ms);
99
+ await (0, flush_1.default)(ms);
100
+ }
101
+ static error(err, options = {}) {
102
+ throw Errors.error(err, options);
103
+ }
104
+ static exit(code = 0) {
105
+ throw Errors.exit(code);
106
+ }
107
+ static warn(err) {
108
+ Errors.warn(err);
122
109
  }
123
110
  }
124
- exports.ux = ux;
111
+ exports.default = ux;
125
112
  ux.config = config_1.config;
126
- const action = ux.action;
127
- exports.action = action;
128
- const annotation = ux.annotation;
129
- exports.annotation = annotation;
130
- const anykey = ux.anykey;
131
- exports.anykey = anykey;
132
- const confirm = ux.confirm;
133
- exports.confirm = confirm;
134
- const debug = ux.debug;
135
- exports.debug = debug;
136
- const done = ux.done;
137
- exports.done = done;
138
- const error = Errors.error;
139
- exports.error = error;
140
- const exit = Errors.exit;
141
- exports.exit = exit;
142
- const flush = ux.flush;
143
- exports.flush = flush;
144
- const info = ux.info;
145
- exports.info = info;
146
- const log = ux.log;
147
- exports.log = log;
148
- const prideAction = ux.prideAction;
149
- exports.prideAction = prideAction;
150
- const progress = ux.progress;
151
- exports.progress = progress;
152
- const prompt = ux.prompt;
153
- exports.prompt = prompt;
154
- const styledHeader = ux.styledHeader;
155
- exports.styledHeader = styledHeader;
156
- const styledJSON = ux.styledJSON;
157
- exports.styledJSON = styledJSON;
158
- const styledObject = ux.styledObject;
159
- exports.styledObject = styledObject;
160
- const table = ux.table;
161
- exports.table = table;
162
- const trace = ux.trace;
163
- exports.trace = trace;
164
- const tree = ux.tree;
165
- exports.tree = tree;
166
- const url = ux.url;
167
- exports.url = url;
168
- const wait = ux.wait;
169
- exports.wait = wait;
170
- const warn = Errors.warn;
171
- exports.warn = warn;
172
- const cliuxProcessExitHandler = async () => {
113
+ const uxProcessExitHandler = async () => {
173
114
  try {
174
115
  await ux.done();
175
116
  }
@@ -180,7 +121,7 @@ const cliuxProcessExitHandler = async () => {
180
121
  };
181
122
  // to avoid MaxListenersExceededWarning
182
123
  // only attach named listener once
183
- const cliuxListener = process.listeners('exit').find(fn => fn.name === cliuxProcessExitHandler.name);
184
- if (!cliuxListener) {
185
- process.once('exit', cliuxProcessExitHandler);
124
+ const uxListener = process.listeners('exit').find(fn => fn.name === uxProcessExitHandler.name);
125
+ if (!uxListener) {
126
+ process.once('exit', uxProcessExitHandler);
186
127
  }
@@ -5,8 +5,6 @@ const Errors = require("../errors");
5
5
  const config_1 = require("./config");
6
6
  const chalk = require("chalk");
7
7
  const stream_1 = require("./stream");
8
- const ansiEscapes = require('ansi-escapes');
9
- const passwordPrompt = require('password-prompt');
10
8
  function normal(options, retries = 100) {
11
9
  if (retries < 0)
12
10
  throw new Error('no input');
@@ -58,6 +56,7 @@ async function single(options) {
58
56
  return response;
59
57
  }
60
58
  function replacePrompt(prompt) {
59
+ const ansiEscapes = require('ansi-escapes');
61
60
  stream_1.stderr.write(ansiEscapes.cursorHide + ansiEscapes.cursorUp(1) + ansiEscapes.cursorLeft + prompt +
62
61
  ansiEscapes.cursorDown(1) + ansiEscapes.cursorLeft + ansiEscapes.cursorShow);
63
62
  }
@@ -72,6 +71,7 @@ async function _prompt(name, inputOptions = {}) {
72
71
  default: '',
73
72
  ...inputOptions,
74
73
  };
74
+ const passwordPrompt = require('password-prompt');
75
75
  switch (options.type) {
76
76
  case 'normal':
77
77
  return normal(options);
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const chalk = require("chalk");
4
- const index_1 = require("../../index");
4
+ const index_1 = require("../index");
5
5
  function styledJSON(obj) {
6
6
  const json = JSON.stringify(obj, null, 2);
7
7
  if (!chalk.level) {
8
- index_1.ux.info(json);
8
+ index_1.default.info(json);
9
9
  return;
10
10
  }
11
11
  const cardinal = require('cardinal');
12
12
  const theme = require('cardinal/themes/jq');
13
- index_1.ux.info(cardinal.highlight(json, { json: true, theme }));
13
+ index_1.default.info(cardinal.highlight(json, { json: true, theme }));
14
14
  }
15
15
  exports.default = styledJSON;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "3.0.0-beta.2",
4
+ "version": "3.0.0-beta.3",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {
@@ -14,7 +14,6 @@
14
14
  "cli-progress": "^3.12.0",
15
15
  "debug": "^4.3.4",
16
16
  "ejs": "^3.1.8",
17
- "fs-extra": "^9.1.0",
18
17
  "get-package-type": "^0.1.0",
19
18
  "globby": "^11.1.0",
20
19
  "hyperlinker": "^1.0.0",
@@ -24,7 +23,6 @@
24
23
  "natural-orderby": "^2.0.3",
25
24
  "object-treeify": "^1.1.33",
26
25
  "password-prompt": "^1.1.2",
27
- "semver": "^7.5.3",
28
26
  "slice-ansi": "^4.0.0",
29
27
  "string-width": "^4.2.3",
30
28
  "strip-ansi": "^6.0.1",
@@ -39,15 +37,15 @@
39
37
  "devDependencies": {
40
38
  "@commitlint/config-conventional": "^12.1.4",
41
39
  "@oclif/plugin-help": "^5.2.8",
42
- "@oclif/plugin-plugins": "^2.4.7",
43
- "@oclif/test": "^2.3.15",
40
+ "@oclif/plugin-plugins": "^3.3.0",
41
+ "@oclif/test": "^2.4.7",
44
42
  "@types/ansi-styles": "^3.2.1",
45
43
  "@types/benchmark": "^2.1.2",
46
44
  "@types/chai": "^4.3.4",
47
45
  "@types/chai-as-promised": "^7.1.5",
48
46
  "@types/clean-stack": "^2.1.1",
49
47
  "@types/ejs": "^3.1.2",
50
- "@types/fs-extra": "^9.0.13",
48
+ "@types/glob": "^8.1.0",
51
49
  "@types/indent-string": "^4.0.1",
52
50
  "@types/js-yaml": "^3.12.7",
53
51
  "@types/mocha": "^8.2.3",
@@ -55,8 +53,7 @@
55
53
  "@types/node": "^16",
56
54
  "@types/node-notifier": "^8.0.2",
57
55
  "@types/proxyquire": "^1.3.28",
58
- "@types/semver": "^7.5.0",
59
- "@types/shelljs": "^0.8.11",
56
+ "@types/shelljs": "^0.8.12",
60
57
  "@types/slice-ansi": "^4.0.0",
61
58
  "@types/strip-ansi": "^5.2.1",
62
59
  "@types/supports-color": "^8.1.1",
@@ -83,20 +80,26 @@
83
80
  "typescript": "^4.9.5"
84
81
  },
85
82
  "engines": {
86
- "node": ">=14.0.0"
83
+ "node": ">=16.0.0"
87
84
  },
88
85
  "files": [
89
- "/lib",
90
- "/flush.js",
91
- "/flush.d.ts",
92
- "/handle.js"
86
+ "/lib"
93
87
  ],
94
88
  "homepage": "https://github.com/oclif/core",
95
89
  "keywords": [
96
90
  "oclif"
97
91
  ],
98
92
  "license": "MIT",
99
- "main": "lib/index.js",
93
+ "exports": {
94
+ ".": "./lib/index.js",
95
+ "./execute": "./lib/execute.js",
96
+ "./flush": "./lib/ux/flush.js",
97
+ "./handle": "./lib/errors/handle.js",
98
+ "./interfaces": "./lib/interfaces/index.js",
99
+ "./run": "./lib/main.js",
100
+ "./settings": "./lib/settings.js",
101
+ "./ux": "./lib/ux/index.js"
102
+ },
100
103
  "repository": "oclif/core",
101
104
  "oclif": {
102
105
  "bin": "oclif",
package/flush.d.ts DELETED
@@ -1,3 +0,0 @@
1
- declare const flush: () => Promise<void>
2
-
3
- export = flush
package/flush.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('./lib').flush
package/handle.js DELETED
@@ -1 +0,0 @@
1
- module.exports = error => require('./lib/errors/handle').handle(error)
@@ -1,4 +0,0 @@
1
- import SpinnerAction from './spinner';
2
- export default class PrideSpinnerAction extends SpinnerAction {
3
- protected _frame(): string;
4
- }
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const chalk = require("chalk");
4
- const supportsColor = require("supports-color");
5
- const spinner_1 = require("./spinner");
6
- function color(s, frameIndex) {
7
- const prideColors = [
8
- chalk.keyword('pink'),
9
- chalk.red,
10
- chalk.keyword('orange'),
11
- chalk.yellow,
12
- chalk.green,
13
- chalk.cyan,
14
- chalk.blue,
15
- chalk.magenta,
16
- ];
17
- if (!supportsColor)
18
- return s;
19
- const has256 = supportsColor.stdout ? supportsColor.stdout.has256 : (process.env.TERM || '').includes('256');
20
- const prideColor = prideColors[frameIndex] || prideColors[0];
21
- return has256 ? prideColor(s) : chalk.magenta(s);
22
- }
23
- class PrideSpinnerAction extends spinner_1.default {
24
- _frame() {
25
- const frame = this.frames[this.frameIndex];
26
- this.frameIndex = ++this.frameIndex % this.frames.length;
27
- return color(frame, this.frameIndex);
28
- }
29
- }
30
- exports.default = PrideSpinnerAction;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes