@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
@@ -21,91 +21,90 @@ export type VersionDetails = {
21
21
  rootPath?: string;
22
22
  };
23
23
  export interface Config {
24
- name: string;
25
- version: string;
26
- channel: string;
27
- pjson: PJSON.CLI;
28
- root: string;
24
+ readonly name: string;
25
+ readonly version: string;
26
+ readonly channel: string;
27
+ readonly pjson: PJSON.CLI;
28
+ readonly root: string;
29
29
  /**
30
30
  * process.arch
31
31
  */
32
- arch: ArchTypes;
32
+ readonly arch: ArchTypes;
33
33
  /**
34
34
  * bin name of CLI command
35
35
  */
36
- bin: string;
36
+ readonly bin: string;
37
37
  /**
38
38
  * cache directory to use for CLI
39
39
  *
40
40
  * example ~/Library/Caches/mycli or ~/.cache/mycli
41
41
  */
42
- cacheDir: string;
42
+ readonly cacheDir: string;
43
43
  /**
44
44
  * config directory to use for CLI
45
45
  *
46
46
  * example: ~/.config/mycli
47
47
  */
48
- configDir: string;
48
+ readonly configDir: string;
49
49
  /**
50
50
  * data directory to use for CLI
51
51
  *
52
52
  * example: ~/.local/share/mycli
53
53
  */
54
- dataDir: string;
54
+ readonly dataDir: string;
55
55
  /**
56
56
  * base dirname to use in cacheDir/configDir/dataDir
57
57
  */
58
- dirname: string;
58
+ readonly dirname: string;
59
59
  /**
60
60
  * points to a file that should be appended to for error logs
61
61
  *
62
62
  * example: ~/Library/Caches/mycli/error.log
63
63
  */
64
- errlog: string;
64
+ readonly errlog: string;
65
65
  /**
66
66
  * path to home directory
67
67
  *
68
68
  * example: /home/myuser
69
69
  */
70
- home: string;
70
+ readonly home: string;
71
71
  /**
72
72
  * process.platform
73
73
  */
74
- platform: PlatformTypes;
74
+ readonly platform: PlatformTypes;
75
75
  /**
76
76
  * active shell
77
77
  */
78
- shell: string;
78
+ readonly shell: string;
79
79
  /**
80
80
  * user agent to use for http calls
81
81
  *
82
82
  * example: mycli/1.2.3 (darwin-x64) node-9.0.0
83
83
  */
84
- userAgent: string;
84
+ readonly userAgent: string;
85
85
  /**
86
86
  * if windows
87
87
  */
88
- windows: boolean;
88
+ readonly windows: boolean;
89
89
  /**
90
90
  * debugging level
91
91
  *
92
92
  * set by ${BIN}_DEBUG or DEBUG=$BIN
93
93
  */
94
- debug: number;
94
+ readonly debug: number;
95
95
  /**
96
96
  * npm registry to use for installing plugins
97
97
  */
98
- npmRegistry?: string;
99
- userPJSON?: PJSON.User;
100
- plugins: Plugin[];
101
- binPath?: string;
98
+ readonly npmRegistry?: string;
99
+ readonly plugins: Map<string, Plugin>;
100
+ readonly binPath?: string;
102
101
  /**
103
102
  * name of any bin aliases that will execute the cli
104
103
  */
105
- binAliases?: string[];
106
- nsisCustomization?: string;
107
- valid: boolean;
108
- flexibleTaxonomy?: boolean;
104
+ readonly binAliases?: string[];
105
+ readonly nsisCustomization?: string;
106
+ readonly valid: boolean;
107
+ readonly flexibleTaxonomy?: boolean;
109
108
  topicSeparator: ':' | ' ';
110
109
  readonly commands: Command.Loadable[];
111
110
  readonly topics: Topic[];
@@ -62,88 +62,26 @@ export type DefaultContext<T> = {
62
62
  /**
63
63
  * Type to define a default value for a flag.
64
64
  * @param context The context of the flag.
65
- * @param isWritingManifest Informs the function that a manifest file is being written.
66
- * The manifest file is used to store the flag definitions, with a default value if present, for a command and is published to npm.
67
- * When a manifest file is being written, the default value may contain data that should not be included in the manifest.
68
- * The plugin developer can use isWritingManifest to determine if the default value should be omitted from the manifest.
69
- * in the function's implementation.
70
- * @example
71
- * static flags = {
72
- * foo: flags.string({
73
- * defaultHelp: async (context, isWritingManifest) => {
74
- * if (isWritingManifest) {
75
- * return undefined
76
- * }
77
- * return 'value that is used outside a manifest'
78
- * },
79
- * }),
80
- * }
81
65
  */
82
- export type FlagDefault<T, P = CustomOptions> = T | ((context: DefaultContext<P & OptionFlag<T, P>>, isWritingManifest?: boolean) => Promise<T>);
66
+ export type FlagDefault<T, P = CustomOptions> = T | ((context: DefaultContext<P & OptionFlag<T, P>>) => Promise<T>);
83
67
  /**
84
68
  * Type to define a defaultHelp value for a flag.
85
69
  * The defaultHelp value is used in the help output for the flag and when writing a manifest.
86
70
  * It is also can be used to provide a value for the flag when issuing certain error messages.
87
71
  *
88
72
  * @param context The context of the flag.
89
- * @param isWritingManifest Informs the function that a manifest file is being written.
90
- * The manifest file is used to store the flag definitions, with a default value if present via defaultHelp, for a command and is published to npm.
91
- * When a manifest file is being written, the default value may contain data that should not be included in the manifest.
92
- * The plugin developer can use isWritingManifest to determine if the defaultHelp value should be omitted from the manifest.
93
- * in the function's implementation.
94
- * @example
95
- * static flags = {
96
- * foo: flags.string({
97
- * defaultHelp: async (context, isWritingManifest) => {
98
- * if (isWritingManifest) {
99
- * return undefined
100
- * }
101
- * return 'value that is used outside a manifest'
102
- * },
103
- * }),
104
- * }
105
73
  */
106
- export type FlagDefaultHelp<T, P = CustomOptions> = T | ((context: DefaultContext<P & OptionFlag<T, P>>, isWritingManifest?: boolean) => Promise<string | undefined>);
74
+ export type FlagDefaultHelp<T, P = CustomOptions> = T | ((context: DefaultContext<P & OptionFlag<T, P>>) => Promise<string | undefined>);
107
75
  /**
108
76
  * Type to define a default value for an arg.
109
77
  * @param context The context of the arg.
110
- * @param isWritingManifest Informs the function that a manifest file is being written.
111
- * The manifest file is used to store the arg definitions, with a default value if present, for a command and is published to npm.
112
- * When a manifest file is being written, the default value may contain data that should not be included in the manifest.
113
- * The plugin developer can use isWritingManifest to determine if the default value should be omitted from the manifest.
114
- * in the function's implementation.
115
- * @example
116
- * public static readonly args = {
117
- * one: Args.string({
118
- * default: async (context, isWritingManifest) => {
119
- * if (isWritingManifest) {
120
- * return undefined
121
- * }
122
- * return 'value that is used outside a manifest'
123
- * }),
124
- * };
125
78
  */
126
- export type ArgDefault<T, P = CustomOptions> = T | ((context: DefaultContext<Arg<T, P>>, isWritingManifest?: boolean) => Promise<T>);
79
+ export type ArgDefault<T, P = CustomOptions> = T | ((context: DefaultContext<Arg<T, P>>) => Promise<T>);
127
80
  /**
128
81
  * Type to define a defaultHelp value for an arg.
129
82
  * @param context The context of the arg.
130
- * @param isWritingManifest Informs the function that a manifest file is being written.
131
- * The manifest file is used to store the arg definitions, with a default value if present via defaultHelp, for a command and is published to npm.
132
- * When a manifest file is being written, the default value may contain data that should not be included in the manifest.
133
- * The plugin developer can use isWritingManifest to determine if the default value should be omitted from the manifest.
134
- * in the function's implementation.
135
- * @example
136
- * public static readonly args = {
137
- * one: Args.string({
138
- * defaultHelp: async (context, isWritingManifest) => {
139
- * if (isWritingManifest) {
140
- * return undefined
141
- * }
142
- * return 'value that is used outside a manifest'
143
- * }),
144
- * };
145
83
  */
146
- export type ArgDefaultHelp<T, P = CustomOptions> = T | ((context: DefaultContext<Arg<T, P>>, isWritingManifest?: boolean) => Promise<string | undefined>);
84
+ export type ArgDefaultHelp<T, P = CustomOptions> = T | ((context: DefaultContext<Arg<T, P>>) => Promise<string | undefined>);
147
85
  export type FlagRelationship = string | {
148
86
  name: string;
149
87
  when: (flags: Record<string, unknown>) => Promise<boolean>;
@@ -226,6 +164,11 @@ export type FlagProps = {
226
164
  * separate on spaces.
227
165
  */
228
166
  delimiter?: ',';
167
+ /**
168
+ * If true, the value returned by defaultHelp will not be cached in the oclif.manifest.json.
169
+ * This is helpful if the default value contains sensitive data that shouldn't be published to npm.
170
+ */
171
+ noCacheDefault?: boolean;
229
172
  };
230
173
  export type ArgProps = {
231
174
  name: string;
@@ -245,6 +188,11 @@ export type ArgProps = {
245
188
  required?: boolean;
246
189
  options?: string[];
247
190
  ignoreStdin?: boolean;
191
+ /**
192
+ * If true, the value returned by defaultHelp will not be cached in the oclif.manifest.json.
193
+ * This is helpful if the default value contains sensitive data that shouldn't be published to npm.
194
+ */
195
+ noCacheDefault?: boolean;
248
196
  };
249
197
  export type BooleanFlagProps = FlagProps & {
250
198
  type: 'boolean';
@@ -1,6 +1,7 @@
1
1
  import { HelpOptions } from './help';
2
2
  export interface PJSON {
3
3
  [k: string]: any;
4
+ version: string;
4
5
  dependencies?: {
5
6
  [name: string]: string;
6
7
  };
@@ -8,8 +8,10 @@ export interface PluginOptions {
8
8
  tag?: string;
9
9
  ignoreManifest?: boolean;
10
10
  errorOnManifestCreate?: boolean;
11
+ respectNoCacheDefault?: boolean;
11
12
  parent?: Plugin;
12
13
  children?: Plugin[];
14
+ flexibleTaxonomy?: boolean;
13
15
  }
14
16
  export interface Options extends PluginOptions {
15
17
  devPlugins?: boolean;
@@ -18,6 +20,7 @@ export interface Options extends PluginOptions {
18
20
  channel?: string;
19
21
  version?: string;
20
22
  enablePerf?: boolean;
23
+ plugins?: Map<string, Plugin>;
21
24
  }
22
25
  export interface Plugin {
23
26
  /**
@@ -78,5 +81,5 @@ export interface Plugin {
78
81
  findCommand(id: string, opts?: {
79
82
  must: boolean;
80
83
  }): Promise<Command.Class> | undefined;
81
- load(isWritingManifest: boolean): Promise<void>;
84
+ load(): Promise<void>;
82
85
  }
package/lib/main.d.ts CHANGED
@@ -2,52 +2,4 @@ import * as Interfaces from './interfaces';
2
2
  import { Config } from './config';
3
3
  export declare const helpAddition: (argv: string[], config: Interfaces.Config) => boolean;
4
4
  export declare const versionAddition: (argv: string[], config?: Interfaces.Config) => boolean;
5
- export declare function run(argv?: string[], options?: Interfaces.LoadOptions): Promise<unknown>;
6
- /**
7
- * Load and run oclif CLI
8
- *
9
- * @param options - options to load the CLI
10
- * @returns Promise<void>
11
- *
12
- * @example For ESM dev.js
13
- * ```
14
- * #!/usr/bin/env node
15
- * (async () => {
16
- * const oclif = await import('@oclif/core')
17
- * await oclif.execute({development: true, dir: import.meta.url})
18
- * })()
19
- * ```
20
- *
21
- * @example For ESM run.js
22
- * ```
23
- * #!/usr/bin/env node
24
- * (async () => {
25
- * const oclif = await import('@oclif/core')
26
- * await oclif.execute({dir: import.meta.url})
27
- * })()
28
- * ```
29
- *
30
- * @example For CJS dev.js
31
- * ```
32
- * #!/usr/bin/env node
33
- * (async () => {
34
- * const oclif = await import('@oclif/core')
35
- * await oclif.execute({development: true, dir: __dirname})
36
- * })()
37
- * ```
38
- *
39
- * @example For CJS run.js
40
- * ```
41
- * #!/usr/bin/env node
42
- * (async () => {
43
- * const oclif = await import('@oclif/core')
44
- * await oclif.execute({dir: __dirname})
45
- * })()
46
- * ```
47
- */
48
- export declare function execute(options: {
49
- dir: string;
50
- args?: string[];
51
- loadOptions?: Interfaces.LoadOptions;
52
- development?: boolean;
53
- }): Promise<void>;
5
+ export default function run(argv?: string[], options?: Interfaces.LoadOptions): Promise<unknown>;
package/lib/main.js CHANGED
@@ -1,14 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.execute = exports.run = exports.versionAddition = exports.helpAddition = void 0;
3
+ exports.versionAddition = exports.helpAddition = void 0;
4
4
  const url_1 = require("url");
5
5
  const util_1 = require("util");
6
6
  const url_2 = require("url");
7
7
  const config_1 = require("./config");
8
8
  const help_1 = require("./help");
9
- const settings_1 = require("./settings");
10
- const _1 = require(".");
11
- const stream_1 = require("./cli-ux/stream");
9
+ const stream_1 = require("./ux/stream");
12
10
  const performance_1 = require("./performance");
13
11
  const debug = require('debug')('oclif:main');
14
12
  const log = (message = '', ...args) => {
@@ -37,13 +35,13 @@ const versionAddition = (argv, config) => {
37
35
  };
38
36
  exports.versionAddition = versionAddition;
39
37
  async function run(argv, options) {
40
- const marker = performance_1.Performance.mark('main.run');
41
- const initMarker = performance_1.Performance.mark('main.run#init');
38
+ const marker = performance_1.default.mark('main.run');
39
+ const initMarker = performance_1.default.mark('main.run#init');
42
40
  const collectPerf = async () => {
43
41
  marker?.stop();
44
42
  initMarker?.stop();
45
- await performance_1.Performance.collect();
46
- performance_1.Performance.debug();
43
+ await performance_1.default.collect();
44
+ performance_1.default.debug();
47
45
  };
48
46
  debug(`process.execPath: ${process.execPath}`);
49
47
  debug(`process.execArgv: ${process.execArgv}`);
@@ -95,57 +93,4 @@ async function run(argv, options) {
95
93
  await collectPerf();
96
94
  }
97
95
  }
98
- exports.run = run;
99
- /**
100
- * Load and run oclif CLI
101
- *
102
- * @param options - options to load the CLI
103
- * @returns Promise<void>
104
- *
105
- * @example For ESM dev.js
106
- * ```
107
- * #!/usr/bin/env node
108
- * (async () => {
109
- * const oclif = await import('@oclif/core')
110
- * await oclif.execute({development: true, dir: import.meta.url})
111
- * })()
112
- * ```
113
- *
114
- * @example For ESM run.js
115
- * ```
116
- * #!/usr/bin/env node
117
- * (async () => {
118
- * const oclif = await import('@oclif/core')
119
- * await oclif.execute({dir: import.meta.url})
120
- * })()
121
- * ```
122
- *
123
- * @example For CJS dev.js
124
- * ```
125
- * #!/usr/bin/env node
126
- * (async () => {
127
- * const oclif = await import('@oclif/core')
128
- * await oclif.execute({development: true, dir: __dirname})
129
- * })()
130
- * ```
131
- *
132
- * @example For CJS run.js
133
- * ```
134
- * #!/usr/bin/env node
135
- * (async () => {
136
- * const oclif = await import('@oclif/core')
137
- * await oclif.execute({dir: __dirname})
138
- * })()
139
- * ```
140
- */
141
- async function execute(options) {
142
- if (options.development) {
143
- // In dev mode -> use ts-node and dev plugins
144
- process.env.NODE_ENV = 'development';
145
- settings_1.settings.debug = true;
146
- }
147
- await run(options.args ?? process.argv.slice(2), options.loadOptions ?? options.dir)
148
- .then(async () => (0, _1.flush)())
149
- .catch(_1.Errors.handle);
150
- }
151
- exports.execute = execute;
96
+ exports.default = run;
@@ -1,5 +1,4 @@
1
- import { Config as IConfig } from './interfaces';
2
- import { Plugin as IPlugin } from './interfaces';
1
+ import { Config as IConfig, Plugin as IPlugin } from './interfaces';
3
2
  /**
4
3
  * Provides a static class with several utility methods to work with Oclif config / plugin to load ESM or CJS Node
5
4
  * modules and source files.
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const path = require("path");
4
4
  const url = require("url");
5
- const fs = require("fs-extra");
5
+ const fs_1 = require("fs");
6
6
  const errors_1 = require("./errors");
7
7
  const config_1 = require("./config");
8
8
  const getPackageType = require('get-package-type');
@@ -131,10 +131,10 @@ class ModuleLoader {
131
131
  filePath = (isPlugin(config) ? (0, config_1.tsPath)(config.root, modulePath, config) : (0, config_1.tsPath)(config.root, modulePath)) ?? modulePath;
132
132
  let fileExists = false;
133
133
  let isDirectory = false;
134
- if (fs.existsSync(filePath)) {
134
+ if ((0, fs_1.existsSync)(filePath)) {
135
135
  fileExists = true;
136
136
  try {
137
- if (fs.lstatSync(filePath)?.isDirectory?.()) {
137
+ if ((0, fs_1.lstatSync)(filePath)?.isDirectory?.()) {
138
138
  fileExists = false;
139
139
  isDirectory = true;
140
140
  }
@@ -167,7 +167,7 @@ class ModuleLoader {
167
167
  // eslint-disable-next-line camelcase
168
168
  for (const extension of s_EXTENSIONS) {
169
169
  const testPath = `${filePath}${extension}`;
170
- if (fs.existsSync(testPath)) {
170
+ if ((0, fs_1.existsSync)(testPath)) {
171
171
  return testPath;
172
172
  }
173
173
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FailedFlagValidationError = exports.ArgInvalidOptionError = exports.FlagInvalidOptionError = exports.NonExistentFlagsError = exports.UnexpectedArgsError = exports.RequiredFlagError = exports.RequiredArgsError = exports.InvalidArgsSpecError = exports.CLIParseError = exports.CLIError = void 0;
4
4
  const errors_1 = require("../errors");
5
5
  const help_1 = require("./help");
6
- const list_1 = require("../cli-ux/list");
6
+ const list_1 = require("../ux/list");
7
7
  const chalk = require("chalk");
8
8
  const util_1 = require("../config/util");
9
9
  var errors_2 = require("../errors");
@@ -13,33 +13,7 @@ try {
13
13
  catch {
14
14
  debug = () => { };
15
15
  }
16
- /**
17
- * Support reading from stdin in Node 14 and older.
18
- *
19
- * This generally works for Node 14 and older EXCEPT when it's being
20
- * run from another process, in which case it will hang indefinitely. Because
21
- * of that issue we updated this to use AbortController but since AbortController
22
- * is only available in Node 16 and newer, we have to keep this legacy version.
23
- *
24
- * See these issues for more details on the hanging indefinitely bug:
25
- * https://github.com/oclif/core/issues/330
26
- * https://github.com/oclif/core/pull/363
27
- *
28
- * @returns Promise<string | null>
29
- */
30
- const readStdinLegacy = async () => {
31
- const { stdin } = process;
32
- let result;
33
- if (stdin.isTTY)
34
- return null;
35
- result = '';
36
- stdin.setEncoding('utf8');
37
- for await (const chunk of stdin) {
38
- result += chunk;
39
- }
40
- return result;
41
- };
42
- const readStdinWithTimeout = async () => {
16
+ const readStdin = async () => {
43
17
  const { stdin, stdout } = process;
44
18
  // process.stdin.isTTY is true whenever it's running in a terminal.
45
19
  // process.stdin.isTTY is undefined when it's running in a pipe, e.g. echo 'foo' | my-cli command
@@ -74,13 +48,6 @@ const readStdinWithTimeout = async () => {
74
48
  }, { once: true });
75
49
  });
76
50
  };
77
- const readStdin = async () => {
78
- const { stdin, version } = process;
79
- debug('stdin.isTTY', stdin.isTTY);
80
- const nodeMajorVersion = Number(version.split('.')[0].replace(/^v/, ''));
81
- debug('node version', nodeMajorVersion);
82
- return nodeMajorVersion > 14 ? readStdinWithTimeout() : readStdinLegacy();
83
- };
84
51
  function isNegativeNumber(input) {
85
52
  return /^-\d/g.test(input);
86
53
  }
@@ -32,7 +32,7 @@ declare class Marker {
32
32
  stop(): void;
33
33
  measure(): void;
34
34
  }
35
- export declare class Performance {
35
+ export default class Performance {
36
36
  private static markers;
37
37
  private static _results;
38
38
  private static _highlights;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Performance = void 0;
4
3
  const perf_hooks_1 = require("perf_hooks");
5
4
  const settings_1 = require("./settings");
6
5
  class Marker {
@@ -30,7 +29,7 @@ class Marker {
30
29
  }
31
30
  class Performance {
32
31
  static get enabled() {
33
- return settings_1.settings.performanceEnabled ?? false;
32
+ return settings_1.default.performanceEnabled ?? false;
34
33
  }
35
34
  static get results() {
36
35
  if (!Performance.enabled)
@@ -174,6 +173,6 @@ class Performance {
174
173
  }
175
174
  }
176
175
  }
177
- exports.Performance = Performance;
176
+ exports.default = Performance;
178
177
  Performance.markers = {};
179
178
  Performance._results = [];
package/lib/screen.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.errtermwidth = exports.stdtermwidth = void 0;
4
- const stream_1 = require("./cli-ux/stream");
4
+ const stream_1 = require("./ux/stream");
5
5
  const settings_1 = require("./settings");
6
6
  function termwidth(stream) {
7
7
  if (!stream.isTTY) {
@@ -16,6 +16,6 @@ function termwidth(stream) {
16
16
  }
17
17
  return width;
18
18
  }
19
- const columns = Number.parseInt(process.env.OCLIF_COLUMNS, 10) || settings_1.settings.columns;
19
+ const columns = Number.parseInt(process.env.OCLIF_COLUMNS, 10) || settings_1.default.columns;
20
20
  exports.stdtermwidth = columns || termwidth(stream_1.stdout);
21
21
  exports.errtermwidth = columns || termwidth(stream_1.stderr);
package/lib/settings.d.ts CHANGED
@@ -36,4 +36,5 @@ export type Settings = {
36
36
  */
37
37
  performanceEnabled?: boolean;
38
38
  };
39
- export declare const settings: Settings;
39
+ declare const settings: Settings;
40
+ export default settings;
package/lib/settings.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settings = void 0;
4
3
  // Set global.oclif to the new object if it wasn't set before
5
4
  if (!global.oclif)
6
5
  global.oclif = {};
7
- exports.settings = global.oclif;
6
+ const settings = global.oclif;
7
+ exports.default = settings;
@@ -31,8 +31,8 @@ class ActionBase {
31
31
  this._stdout(false);
32
32
  }
33
33
  get globals() {
34
- global['cli-ux'] = global['cli-ux'] || {};
35
- const globals = global['cli-ux'];
34
+ global.ux = global.ux || {};
35
+ const globals = global.ux;
36
36
  globals.action = globals.action || {};
37
37
  return globals;
38
38
  }
@@ -4,7 +4,6 @@ const chalk = require("chalk");
4
4
  const supportsColor = require("supports-color");
5
5
  const stripAnsi = require('strip-ansi');
6
6
  const ansiStyles = require('ansi-styles');
7
- const ansiEscapes = require('ansi-escapes');
8
7
  const screen_1 = require("../../screen");
9
8
  const spinners_1 = require("./spinners");
10
9
  const base_1 = require("./base");
@@ -65,6 +64,7 @@ class SpinnerAction extends base_1.ActionBase {
65
64
  _reset() {
66
65
  if (!this.output)
67
66
  return;
67
+ const ansiEscapes = require('ansi-escapes');
68
68
  const lines = this._lines(this.output);
69
69
  this._write(this.std, ansiEscapes.cursorLeft + ansiEscapes.cursorUp(lines) + ansiEscapes.eraseDown);
70
70
  this.output = undefined;
@@ -8,7 +8,6 @@ export interface ConfigMessage {
8
8
  export declare class Config {
9
9
  outputLevel: Levels;
10
10
  action: ActionBase;
11
- prideAction: ActionBase;
12
11
  errorsHandled: boolean;
13
12
  showStackTrace: boolean;
14
13
  get debug(): boolean;
@@ -1,25 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.config = exports.Config = void 0;
4
- const semver = require("semver");
5
4
  const util_1 = require("../util");
6
5
  const spinner_1 = require("./action/spinner");
7
6
  const spinner_2 = require("./action/spinner");
8
- const pride_spinner_1 = require("./action/pride-spinner");
9
- const version = semver.parse((0, util_1.requireJson)(__dirname, '..', '..', 'package.json').version);
10
7
  const g = global;
11
- const globals = g['cli-ux'] || (g['cli-ux'] = {});
8
+ const globals = g.ux || (g.ux = {});
12
9
  const actionType = (Boolean(process.stderr.isTTY) &&
13
10
  !process.env.CI &&
14
11
  !['dumb', 'emacs-color'].includes(process.env.TERM) &&
15
12
  'spinner') || 'simple';
16
13
  const Action = actionType === 'spinner' ? spinner_1.default : spinner_2.default;
17
- const PrideAction = actionType === 'spinner' ? pride_spinner_1.default : spinner_2.default;
18
14
  class Config {
19
15
  constructor() {
20
16
  this.outputLevel = 'info';
21
17
  this.action = new Action();
22
- this.prideAction = new PrideAction();
23
18
  this.errorsHandled = false;
24
19
  this.showStackTrace = true;
25
20
  }
@@ -38,10 +33,11 @@ class Config {
38
33
  }
39
34
  exports.Config = Config;
40
35
  function fetch() {
41
- if (globals[version.major])
42
- return globals[version.major];
43
- globals[version.major] = new Config();
44
- return globals[version.major];
36
+ const major = (0, util_1.requireJson)(__dirname, '..', '..', 'package.json').version.split('.')[0];
37
+ if (globals[major])
38
+ return globals[major];
39
+ globals[major] = new Config();
40
+ return globals[major];
45
41
  }
46
42
  exports.config = fetch();
47
43
  exports.default = exports.config;