@oclif/core 2.0.0-beta.4 → 2.0.0-beta.6

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.
@@ -6,27 +6,54 @@ import { IPromptOptions } from './prompt';
6
6
  import * as styled from './styled';
7
7
  import { Table } from './styled';
8
8
  import * as uxPrompt from './prompt';
9
+ import uxWait from './wait';
10
+ export declare class ux {
11
+ static config: Config;
12
+ static get prompt(): typeof uxPrompt.prompt;
13
+ /**
14
+ * "press anykey to continue"
15
+ */
16
+ static get anykey(): typeof uxPrompt.anykey;
17
+ static get confirm(): typeof uxPrompt.confirm;
18
+ static get action(): ActionBase;
19
+ static get prideAction(): ActionBase;
20
+ static styledObject(obj: any, keys?: string[]): void;
21
+ static get styledHeader(): typeof styled.styledHeader;
22
+ static get styledJSON(): typeof styled.styledJSON;
23
+ static get table(): typeof styled.Table.table;
24
+ static get tree(): typeof styled.tree;
25
+ static get wait(): typeof uxWait;
26
+ static get progress(): typeof styled.progress;
27
+ static done(): Promise<void>;
28
+ static trace(format: string, ...args: string[]): void;
29
+ static debug(format: string, ...args: string[]): void;
30
+ static info(format: string, ...args: string[]): void;
31
+ static log(format?: string, ...args: string[]): void;
32
+ static url(text: string, uri: string, params?: {}): void;
33
+ static annotation(text: string, annotation: string): void;
34
+ static flush(ms?: number): Promise<void>;
35
+ }
9
36
  declare const action: ActionBase;
10
- declare const annotation: (text: string, annotation: string) => void;
37
+ declare const annotation: typeof ux.annotation;
11
38
  declare const anykey: typeof uxPrompt.anykey;
12
39
  declare const confirm: typeof uxPrompt.confirm;
13
- declare const debug: (format: string, ...args: string[]) => void;
14
- declare const done: () => Promise<void>;
40
+ declare const debug: typeof ux.debug;
41
+ declare const done: typeof ux.done;
15
42
  declare const error: typeof Errors.error;
16
43
  declare const exit: typeof Errors.exit;
17
- declare const flush: (ms?: number) => Promise<void>;
18
- declare const info: (format: string, ...args: string[]) => void;
19
- declare const log: (format?: string, ...args: string[]) => void;
44
+ declare const flush: typeof ux.flush;
45
+ declare const info: typeof ux.info;
46
+ declare const log: typeof ux.log;
20
47
  declare const prideAction: ActionBase;
21
48
  declare const progress: typeof styled.progress;
22
49
  declare const prompt: typeof uxPrompt.prompt;
23
50
  declare const styledHeader: typeof styled.styledHeader;
24
51
  declare const styledJSON: typeof styled.styledJSON;
25
- declare const styledObject: (obj: any, keys?: string[]) => void;
52
+ declare const styledObject: typeof ux.styledObject;
26
53
  declare const table: typeof styled.Table.table;
27
- declare const trace: (format: string, ...args: string[]) => void;
54
+ declare const trace: typeof ux.trace;
28
55
  declare const tree: typeof styled.tree;
29
- declare const url: (text: string, uri: string, params?: {}) => void;
56
+ declare const url: typeof ux.url;
30
57
  declare const wait: (ms?: number) => Promise<void>;
31
58
  declare const warn: typeof Errors.warn;
32
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, };
@@ -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 = void 0;
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;
4
4
  const Errors = require("../errors");
5
5
  const util = require("util");
6
6
  const base_1 = require("./action/base");
@@ -24,7 +24,7 @@ function timeout(p, ms) {
24
24
  t.unref();
25
25
  });
26
26
  }
27
- return Promise.race([p, wait(ms, true).then(() => ux.error('timed out'))]);
27
+ return Promise.race([p, wait(ms, true).then(() => Errors.error('timed out'))]);
28
28
  }
29
29
  async function _flush() {
30
30
  const p = new Promise(resolve => {
@@ -36,70 +36,67 @@ async function _flush() {
36
36
  }
37
37
  return p;
38
38
  }
39
- const ux = {
40
- config: config_1.config,
41
- warn: Errors.warn,
42
- error: Errors.error,
43
- exit: Errors.exit,
44
- get prompt() {
39
+ class ux {
40
+ static get prompt() {
45
41
  return uxPrompt.prompt;
46
- },
42
+ }
47
43
  /**
48
44
  * "press anykey to continue"
49
45
  */
50
- get anykey() {
46
+ static get anykey() {
51
47
  return uxPrompt.anykey;
52
- },
53
- get confirm() {
48
+ }
49
+ static get confirm() {
54
50
  return uxPrompt.confirm;
55
- },
56
- get action() {
51
+ }
52
+ static get action() {
57
53
  return config_1.config.action;
58
- },
59
- get prideAction() {
54
+ }
55
+ static get prideAction() {
60
56
  return config_1.config.prideAction;
61
- },
62
- styledObject(obj, keys) {
63
- ux.info(styled.styledObject(obj, keys));
64
- },
65
- get styledHeader() {
57
+ }
58
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
59
+ static styledObject(obj, keys) {
60
+ this.info(styled.styledObject(obj, keys));
61
+ }
62
+ static get styledHeader() {
66
63
  return styled.styledHeader;
67
- },
68
- get styledJSON() {
64
+ }
65
+ static get styledJSON() {
69
66
  return styled.styledJSON;
70
- },
71
- get table() {
67
+ }
68
+ static get table() {
72
69
  return styled.Table.table;
73
- },
74
- get tree() {
70
+ }
71
+ static get tree() {
75
72
  return styled.tree;
76
- },
77
- get wait() {
73
+ }
74
+ static get wait() {
78
75
  return wait_1.default;
79
- },
80
- get progress() {
76
+ }
77
+ static get progress() {
81
78
  return styled.progress;
82
- },
83
- async done() {
79
+ }
80
+ static async done() {
84
81
  config_1.config.action.stop();
85
- },
86
- trace(format, ...args) {
82
+ }
83
+ static trace(format, ...args) {
87
84
  if (this.config.outputLevel === 'trace') {
88
85
  process.stdout.write(util.format(format, ...args) + '\n');
89
86
  }
90
- },
91
- debug(format, ...args) {
87
+ }
88
+ static debug(format, ...args) {
92
89
  if (['trace', 'debug'].includes(this.config.outputLevel)) {
93
90
  process.stdout.write(util.format(format, ...args) + '\n');
94
91
  }
95
- },
96
- info(format, ...args) {
92
+ }
93
+ static info(format, ...args) {
97
94
  process.stdout.write(util.format(format, ...args) + '\n');
98
- },
99
- log(format, ...args) {
95
+ }
96
+ static log(format, ...args) {
100
97
  this.info(format || '', ...args);
101
- },
102
- url(text, uri, params = {}) {
98
+ }
99
+ static url(text, uri, params = {}) {
103
100
  const supports = require('supports-hyperlinks');
104
101
  if (supports.stdout) {
105
102
  this.log(hyperlinker(text, uri, params));
@@ -107,8 +104,8 @@ const ux = {
107
104
  else {
108
105
  this.log(uri);
109
106
  }
110
- },
111
- annotation(text, annotation) {
107
+ }
108
+ static annotation(text, annotation) {
112
109
  const supports = require('supports-hyperlinks');
113
110
  if (supports.stdout) {
114
111
  // \u001b]8;;https://google.com\u0007sometext\u001b]8;;\u0007
@@ -117,56 +114,58 @@ const ux = {
117
114
  else {
118
115
  this.log(text);
119
116
  }
120
- },
121
- async flush(ms = 10000) {
117
+ }
118
+ static async flush(ms = 10000) {
122
119
  await timeout(_flush(), ms);
123
- },
124
- };
120
+ }
121
+ }
122
+ exports.ux = ux;
123
+ ux.config = config_1.config;
125
124
  const action = ux.action;
126
125
  exports.action = action;
127
- const annotation = ux.annotation.bind(ux);
126
+ const annotation = ux.annotation;
128
127
  exports.annotation = annotation;
129
- const anykey = ux.anykey.bind(ux);
128
+ const anykey = ux.anykey;
130
129
  exports.anykey = anykey;
131
- const confirm = ux.confirm.bind(ux);
130
+ const confirm = ux.confirm;
132
131
  exports.confirm = confirm;
133
- const debug = ux.debug.bind(ux);
132
+ const debug = ux.debug;
134
133
  exports.debug = debug;
135
- const done = ux.done.bind(ux);
134
+ const done = ux.done;
136
135
  exports.done = done;
137
- const error = ux.error.bind(ux);
136
+ const error = Errors.error;
138
137
  exports.error = error;
139
- const exit = ux.exit.bind(ux);
138
+ const exit = Errors.exit;
140
139
  exports.exit = exit;
141
- const flush = ux.flush.bind(ux);
140
+ const flush = ux.flush;
142
141
  exports.flush = flush;
143
- const info = ux.info.bind(ux);
142
+ const info = ux.info;
144
143
  exports.info = info;
145
- const log = ux.log.bind(ux);
144
+ const log = ux.log;
146
145
  exports.log = log;
147
146
  const prideAction = ux.prideAction;
148
147
  exports.prideAction = prideAction;
149
- const progress = ux.progress.bind(ux);
148
+ const progress = ux.progress;
150
149
  exports.progress = progress;
151
- const prompt = ux.prompt.bind(ux);
150
+ const prompt = ux.prompt;
152
151
  exports.prompt = prompt;
153
- const styledHeader = ux.styledHeader.bind(ux);
152
+ const styledHeader = ux.styledHeader;
154
153
  exports.styledHeader = styledHeader;
155
- const styledJSON = ux.styledJSON.bind(ux);
154
+ const styledJSON = ux.styledJSON;
156
155
  exports.styledJSON = styledJSON;
157
- const styledObject = ux.styledObject.bind(ux);
156
+ const styledObject = ux.styledObject;
158
157
  exports.styledObject = styledObject;
159
158
  const table = ux.table;
160
159
  exports.table = table;
161
- const trace = ux.trace.bind(ux);
160
+ const trace = ux.trace;
162
161
  exports.trace = trace;
163
- const tree = ux.tree.bind(ux);
162
+ const tree = ux.tree;
164
163
  exports.tree = tree;
165
- const url = ux.url.bind(ux);
164
+ const url = ux.url;
166
165
  exports.url = url;
167
- const wait = ux.wait.bind(ux);
166
+ const wait = ux.wait;
168
167
  exports.wait = wait;
169
- const warn = ux.warn.bind(ux);
168
+ const warn = Errors.warn;
170
169
  exports.warn = warn;
171
170
  const cliuxProcessExitHandler = async () => {
172
171
  try {
package/lib/command.d.ts CHANGED
@@ -118,7 +118,7 @@ export declare abstract class Command {
118
118
  export declare namespace Command {
119
119
  type Class = typeof Command & {
120
120
  id: string;
121
- run(argv?: string[], config?: LoadOptions): PromiseLike<any>;
121
+ run(argv?: string[], config?: LoadOptions): Promise<any>;
122
122
  };
123
123
  interface Loadable extends Cached {
124
124
  load(): Promise<Command.Class>;
package/lib/command.js CHANGED
@@ -63,6 +63,11 @@ class Command {
63
63
  }
64
64
  const config = await config_1.Config.load(opts || require.main?.filename || __dirname);
65
65
  const cmd = new this(argv, config);
66
+ if (!cmd.id) {
67
+ const id = cmd.constructor.name.toLowerCase();
68
+ cmd.id = id;
69
+ cmd.ctor.id = id;
70
+ }
66
71
  return cmd._run();
67
72
  }
68
73
  static get baseFlags() {
package/lib/index.d.ts CHANGED
@@ -12,5 +12,5 @@ import { Hook } from './interfaces/hooks';
12
12
  import { settings, Settings } from './settings';
13
13
  import { HelpSection, HelpSectionRenderer, HelpSectionKeyValueTable } from './help/formatter';
14
14
  import * as ux from './cli-ux';
15
- declare const flush: (ms?: number) => Promise<void>;
15
+ declare const flush: typeof ux.ux.flush;
16
16
  export { Args, Command, CommandHelp, Config, Errors, Flags, loadHelpClass, Help, HelpBase, HelpSection, HelpSectionRenderer, HelpSectionKeyValueTable, Hook, Interfaces, Parser, Plugin, run, toCached, tsPath, toStandardizedId, toConfiguredId, settings, Settings, flush, ux, execute, };
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": "2.0.0-beta.4",
4
+ "version": "2.0.0-beta.6",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {