@oclif/core 2.14.0 → 3.0.0-beta.10

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 (52) hide show
  1. package/README.md +8 -6
  2. package/flush.js +1 -1
  3. package/handle.js +1 -1
  4. package/lib/cli-ux/action/base.js +2 -2
  5. package/lib/cli-ux/config.d.ts +0 -1
  6. package/lib/cli-ux/config.js +1 -4
  7. package/lib/cli-ux/exit.d.ts +1 -1
  8. package/lib/cli-ux/exit.js +1 -1
  9. package/lib/cli-ux/flush.d.ts +1 -0
  10. package/lib/cli-ux/flush.js +28 -0
  11. package/lib/cli-ux/index.d.ts +1 -3
  12. package/lib/cli-ux/index.js +7 -31
  13. package/lib/cli-ux/styled/json.js +1 -1
  14. package/lib/command.d.ts +2 -0
  15. package/lib/config/config.d.ts +8 -12
  16. package/lib/config/config.js +73 -162
  17. package/lib/config/index.d.ts +2 -1
  18. package/lib/config/index.js +2 -1
  19. package/lib/config/plugin-loader.d.ts +30 -0
  20. package/lib/config/plugin-loader.js +129 -0
  21. package/lib/config/plugin.d.ts +5 -10
  22. package/lib/config/plugin.js +21 -17
  23. package/lib/config/ts-node.d.ts +3 -2
  24. package/lib/config/ts-node.js +83 -36
  25. package/lib/errors/errors/cli.d.ts +1 -0
  26. package/lib/errors/errors/cli.js +1 -0
  27. package/lib/errors/handle.d.ts +2 -2
  28. package/lib/errors/handle.js +3 -3
  29. package/lib/errors/index.d.ts +1 -0
  30. package/lib/errors/index.js +8 -1
  31. package/lib/execute.d.ts +49 -0
  32. package/lib/execute.js +62 -0
  33. package/lib/flags.js +4 -3
  34. package/lib/help/index.js +2 -2
  35. package/lib/index.d.ts +6 -4
  36. package/lib/index.js +9 -6
  37. package/lib/interfaces/config.d.ts +25 -26
  38. package/lib/interfaces/index.d.ts +14 -14
  39. package/lib/interfaces/parser.d.ts +14 -66
  40. package/lib/interfaces/pjson.d.ts +2 -0
  41. package/lib/interfaces/plugin.d.ts +8 -3
  42. package/lib/interfaces/ts-config.d.ts +9 -0
  43. package/lib/main.d.ts +1 -54
  44. package/lib/main.js +10 -72
  45. package/lib/module-loader.d.ts +1 -2
  46. package/lib/module-loader.js +5 -5
  47. package/lib/parser/parse.js +1 -34
  48. package/lib/performance.d.ts +1 -1
  49. package/lib/performance.js +1 -2
  50. package/package.json +14 -13
  51. package/lib/cli-ux/action/pride-spinner.d.ts +0 -4
  52. package/lib/cli-ux/action/pride-spinner.js +0 -30
@@ -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[];
@@ -1,14 +1,14 @@
1
- export { AlphabetLowercase, AlphabetUppercase } from './alphabet';
2
- export { Config, ArchTypes, PlatformTypes, LoadOptions, VersionDetails, PluginVersionDetail } from './config';
3
- export { OclifError, PrettyPrintableError, CommandError } from './errors';
4
- export { HelpOptions } from './help';
5
- export { Hook, Hooks } from './hooks';
6
- export { Manifest } from './manifest';
7
- export { S3Manifest } from './s3-manifest';
8
- export { BooleanFlag, Flag, OptionFlag, Deprecation } from './parser';
9
- export { PJSON } from './pjson';
10
- export { Plugin, PluginOptions, Options } from './plugin';
11
- export { Topic } from './topic';
12
- export { TSConfig } from './ts-config';
13
- export { InferredFlags } from './flags';
14
- export { InferredArgs } from './args';
1
+ export type { AlphabetLowercase, AlphabetUppercase } from './alphabet';
2
+ export type { Config, ArchTypes, PlatformTypes, LoadOptions, VersionDetails, PluginVersionDetail } from './config';
3
+ export type { OclifError, PrettyPrintableError, CommandError } from './errors';
4
+ export type { HelpOptions } from './help';
5
+ export type { Hook, Hooks } from './hooks';
6
+ export type { Manifest } from './manifest';
7
+ export type { S3Manifest } from './s3-manifest';
8
+ export type { Arg, BooleanFlag, CustomOptions, Deprecation, Flag, FlagDefinition, OptionFlag, } from './parser';
9
+ export type { PJSON } from './pjson';
10
+ export type { Plugin, PluginOptions, Options } from './plugin';
11
+ export type { Topic } from './topic';
12
+ export type { TSConfig } from './ts-config';
13
+ export type { InferredFlags } from './flags';
14
+ export type { InferredArgs } from './args';
@@ -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
  };
@@ -12,6 +13,7 @@ export interface PJSON {
12
13
  bin?: string;
13
14
  dirname?: string;
14
15
  hooks?: Record<string, string | string[]>;
16
+ plugins?: string[];
15
17
  };
16
18
  }
17
19
  export declare namespace PJSON {
@@ -1,4 +1,3 @@
1
- import { Config } from './config';
2
1
  import { Command } from '../command';
3
2
  import { PJSON } from './pjson';
4
3
  import { Topic } from './topic';
@@ -9,8 +8,10 @@ export interface PluginOptions {
9
8
  tag?: string;
10
9
  ignoreManifest?: boolean;
11
10
  errorOnManifestCreate?: boolean;
11
+ respectNoCacheDefault?: boolean;
12
12
  parent?: Plugin;
13
13
  children?: Plugin[];
14
+ flexibleTaxonomy?: boolean;
14
15
  }
15
16
  export interface Options extends PluginOptions {
16
17
  devPlugins?: boolean;
@@ -19,7 +20,7 @@ export interface Options extends PluginOptions {
19
20
  channel?: string;
20
21
  version?: string;
21
22
  enablePerf?: boolean;
22
- config?: Config;
23
+ plugins?: Map<string, Plugin>;
23
24
  }
24
25
  export interface Plugin {
25
26
  /**
@@ -51,6 +52,10 @@ export interface Plugin {
51
52
  * examples: core, link, user, dev
52
53
  */
53
54
  type: string;
55
+ /**
56
+ * Plugin is written in ESM or CommonJS
57
+ */
58
+ moduleType: 'module' | 'commonjs';
54
59
  /**
55
60
  * base path of plugin
56
61
  */
@@ -76,5 +81,5 @@ export interface Plugin {
76
81
  findCommand(id: string, opts?: {
77
82
  must: boolean;
78
83
  }): Promise<Command.Class> | undefined;
79
- load(isWritingManifest: boolean): Promise<void>;
84
+ load(): Promise<void>;
80
85
  }
@@ -7,5 +7,14 @@ export interface TSConfig {
7
7
  esModuleInterop?: boolean;
8
8
  experimentalDecorators?: boolean;
9
9
  emitDecoratorMetadata?: boolean;
10
+ module?: string;
11
+ moduleResolution?: string;
12
+ sourceMap?: boolean;
13
+ jsx?: boolean;
14
+ };
15
+ 'ts-node'?: {
16
+ esm?: boolean;
17
+ experimentalSpecifierResolution?: 'node' | 'explicit';
18
+ scope?: boolean;
10
19
  };
11
20
  }
package/lib/main.d.ts CHANGED
@@ -2,57 +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 ts-node
15
- * // eslint-disable-next-line node/shebang
16
- * (async () => {
17
- * const oclif = await import('@oclif/core')
18
- * await oclif.execute({type: 'esm', development: true, dir: import.meta.url})
19
- * })()
20
- * ```
21
- *
22
- * @example For ESM run.js
23
- * ```
24
- * #!/usr/bin/env node
25
- * // eslint-disable-next-line node/shebang
26
- * (async () => {
27
- * const oclif = await import('@oclif/core')
28
- * await oclif.execute({type: 'esm', dir: import.meta.url})
29
- * })()
30
- * ```
31
- *
32
- * @example For CJS dev.js
33
- * ```
34
- * #!/usr/bin/env node
35
- * // eslint-disable-next-line node/shebang
36
- * (async () => {
37
- * const oclif = await import('@oclif/core')
38
- * await oclif.execute({type: 'cjs', development: true, dir: __dirname})
39
- * })()
40
- * ```
41
- *
42
- * @example For CJS run.js
43
- * ```
44
- * #!/usr/bin/env node
45
- * // eslint-disable-next-line node/shebang
46
- * (async () => {
47
- * const oclif = await import('@oclif/core')
48
- * await oclif.execute({type: 'cjs', dir: import.meta.url})
49
- * })()
50
- * ```
51
- */
52
- export declare function execute(options: {
53
- type: 'cjs' | 'esm';
54
- dir: string;
55
- args?: string[];
56
- loadOptions?: Interfaces.LoadOptions;
57
- development?: boolean;
58
- }): Promise<void>;
5
+ export default function run(argv?: string[], options?: Interfaces.LoadOptions): Promise<unknown>;
package/lib/main.js CHANGED
@@ -1,16 +1,14 @@
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 path_1 = require("path");
12
9
  const stream_1 = require("./cli-ux/stream");
13
10
  const performance_1 = require("./performance");
11
+ const debug = require('debug')('oclif:main');
14
12
  const log = (message = '', ...args) => {
15
13
  message = typeof message === 'string' ? message : (0, util_1.inspect)(message);
16
14
  stream_1.stdout.write((0, util_1.format)(message, ...args) + '\n');
@@ -37,14 +35,17 @@ 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
  };
46
+ debug(`process.execPath: ${process.execPath}`);
47
+ debug(`process.execArgv: ${process.execArgv}`);
48
+ debug('process.argv: %O', process.argv);
48
49
  argv = argv ?? process.argv.slice(2);
49
50
  // Handle the case when a file URL string or URL is passed in such as 'import.meta.url'; covert to file path.
50
51
  if (options && ((typeof options === 'string' && options.startsWith('file://')) || options instanceof url_2.URL)) {
@@ -92,67 +93,4 @@ async function run(argv, options) {
92
93
  await collectPerf();
93
94
  }
94
95
  }
95
- exports.run = run;
96
- function getTsConfigPath(dir, type) {
97
- return type === 'cjs' ? (0, path_1.join)(dir, '..', 'tsconfig.json') : (0, path_1.join)((0, path_1.dirname)((0, url_1.fileURLToPath)(dir)), '..', 'tsconfig.json');
98
- }
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 ts-node
108
- * // eslint-disable-next-line node/shebang
109
- * (async () => {
110
- * const oclif = await import('@oclif/core')
111
- * await oclif.execute({type: 'esm', development: true, dir: import.meta.url})
112
- * })()
113
- * ```
114
- *
115
- * @example For ESM run.js
116
- * ```
117
- * #!/usr/bin/env node
118
- * // eslint-disable-next-line node/shebang
119
- * (async () => {
120
- * const oclif = await import('@oclif/core')
121
- * await oclif.execute({type: 'esm', dir: import.meta.url})
122
- * })()
123
- * ```
124
- *
125
- * @example For CJS dev.js
126
- * ```
127
- * #!/usr/bin/env node
128
- * // eslint-disable-next-line node/shebang
129
- * (async () => {
130
- * const oclif = await import('@oclif/core')
131
- * await oclif.execute({type: 'cjs', development: true, dir: __dirname})
132
- * })()
133
- * ```
134
- *
135
- * @example For CJS run.js
136
- * ```
137
- * #!/usr/bin/env node
138
- * // eslint-disable-next-line node/shebang
139
- * (async () => {
140
- * const oclif = await import('@oclif/core')
141
- * await oclif.execute({type: 'cjs', dir: import.meta.url})
142
- * })()
143
- * ```
144
- */
145
- async function execute(options) {
146
- if (options.development) {
147
- // In dev mode -> use ts-node and dev plugins
148
- process.env.NODE_ENV = 'development';
149
- require('ts-node').register({
150
- project: getTsConfigPath(options.dir, options.type),
151
- });
152
- settings_1.settings.debug = true;
153
- }
154
- await run(options.args ?? process.argv.slice(2), options.loadOptions ?? options.dir)
155
- .then(async () => (0, _1.flush)())
156
- .catch(_1.Errors.handle);
157
- }
158
- 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.
@@ -4,13 +4,16 @@ const path = require("path");
4
4
  const url = require("url");
5
5
  const fs_1 = require("fs");
6
6
  const errors_1 = require("./errors");
7
- const Config = require("./config");
7
+ const config_1 = require("./config");
8
8
  const getPackageType = require('get-package-type');
9
9
  /**
10
10
  * Defines file extension resolution when source files do not have an extension.
11
11
  */
12
12
  // eslint-disable-next-line camelcase
13
13
  const s_EXTENSIONS = ['.ts', '.js', '.mjs', '.cjs'];
14
+ const isPlugin = (config) => {
15
+ return config.type !== undefined;
16
+ };
14
17
  /**
15
18
  * Provides a static class with several utility methods to work with Oclif config / plugin to load ESM or CJS Node
16
19
  * modules and source files.
@@ -120,15 +123,12 @@ class ModuleLoader {
120
123
  static resolvePath(config, modulePath) {
121
124
  let isESM;
122
125
  let filePath;
123
- const isPlugin = (config) => {
124
- return config.type !== undefined;
125
- };
126
126
  try {
127
127
  filePath = require.resolve(modulePath);
128
128
  isESM = ModuleLoader.isPathModule(filePath);
129
129
  }
130
130
  catch {
131
- filePath = isPlugin(config) ? Config.tsPath(config.root, modulePath, config.type) : Config.tsPath(config.root, modulePath);
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
134
  if ((0, fs_1.existsSync)(filePath)) {
@@ -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 {
@@ -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 = [];