@oclif/core 2.11.4 → 2.11.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.
@@ -8,7 +8,7 @@ export interface OclifError {
8
8
  }
9
9
  export interface PrettyPrintableError {
10
10
  /**
11
- * messsage to display related to the error
11
+ * message to display related to the error
12
12
  */
13
13
  message?: string;
14
14
  /**
@@ -11,11 +11,6 @@ const getPackageType = require('get-package-type');
11
11
  */
12
12
  // eslint-disable-next-line camelcase
13
13
  const s_EXTENSIONS = ['.ts', '.js', '.mjs', '.cjs'];
14
- /**
15
- * Provides a mechanism to use dynamic import / import() with tsconfig -> module: commonJS as otherwise import() gets
16
- * transpiled to require().
17
- */
18
- const _importDynamic = new Function('modulePath', 'return import(modulePath)'); // eslint-disable-line no-new-func
19
14
  /**
20
15
  * Provides a static class with several utility methods to work with Oclif config / plugin to load ESM or CJS Node
21
16
  * modules and source files.
@@ -45,8 +40,8 @@ class ModuleLoader {
45
40
  let isESM;
46
41
  try {
47
42
  ({ isESM, filePath } = ModuleLoader.resolvePath(config, modulePath));
48
- // It is important to await on _importDynamic to catch the error code.
49
- return isESM ? await _importDynamic(url.pathToFileURL(filePath)) : require(filePath);
43
+ // It is important to await on import to catch the error code.
44
+ return isESM ? await import(url.pathToFileURL(filePath).href) : require(filePath);
50
45
  }
51
46
  catch (error) {
52
47
  if (error.code === 'MODULE_NOT_FOUND' || error.code === 'ERR_MODULE_NOT_FOUND') {
@@ -77,7 +72,7 @@ class ModuleLoader {
77
72
  let isESM;
78
73
  try {
79
74
  ({ isESM, filePath } = ModuleLoader.resolvePath(config, modulePath));
80
- const module = isESM ? await _importDynamic(url.pathToFileURL(filePath)) : require(filePath);
75
+ const module = isESM ? await import(url.pathToFileURL(filePath).href) : require(filePath);
81
76
  return { isESM, module, filePath };
82
77
  }
83
78
  catch (error) {
@@ -22,8 +22,9 @@ export declare class InvalidArgsSpecError extends CLIParseError {
22
22
  }
23
23
  export declare class RequiredArgsError extends CLIParseError {
24
24
  args: Arg<any>[];
25
- constructor({ args, parse }: CLIParseErrorOptions & {
25
+ constructor({ args, parse, flagsWithMultiple }: CLIParseErrorOptions & {
26
26
  args: Arg<any>[];
27
+ flagsWithMultiple?: string[];
27
28
  });
28
29
  }
29
30
  export declare class RequiredFlagError extends CLIParseError {
@@ -30,13 +30,18 @@ class InvalidArgsSpecError extends CLIParseError {
30
30
  }
31
31
  exports.InvalidArgsSpecError = InvalidArgsSpecError;
32
32
  class RequiredArgsError extends CLIParseError {
33
- constructor({ args, parse }) {
33
+ constructor({ args, parse, flagsWithMultiple }) {
34
34
  let message = `Missing ${args.length} required arg${args.length === 1 ? '' : 's'}`;
35
35
  const namedArgs = args.filter(a => a.name);
36
36
  if (namedArgs.length > 0) {
37
37
  const list = (0, list_1.renderList)(namedArgs.map(a => [a.name, a.description]));
38
38
  message += `:\n${list}`;
39
39
  }
40
+ if (flagsWithMultiple?.length) {
41
+ const flags = flagsWithMultiple.map(f => `--${f}`).join(', ');
42
+ message += `\n\nNote: ${flags} allow${flagsWithMultiple.length === 1 ? 's' : ''} multiple values. Because of this you need to provide all arguments before providing ${flagsWithMultiple.length === 1 ? 'that flag' : 'those flags'}.`;
43
+ message += '\nAlternatively, you can use "--" to signify the end of the flags and the beginning of arguments.';
44
+ }
40
45
  super({ parse, message });
41
46
  this.args = args;
42
47
  }
@@ -30,7 +30,10 @@ async function validate(parse) {
30
30
  }
31
31
  }
32
32
  if (missingRequiredArgs.length > 0) {
33
- throw new errors_1.RequiredArgsError({ parse, args: missingRequiredArgs });
33
+ const flagsWithMultiple = Object.entries(parse.input.flags)
34
+ .filter(([_, flagDef]) => flagDef.type === 'option' && Boolean(flagDef.multiple))
35
+ .map(([name]) => name);
36
+ throw new errors_1.RequiredArgsError({ parse, args: missingRequiredArgs, flagsWithMultiple });
34
37
  }
35
38
  }
36
39
  async function validateFlags() {
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.11.4",
4
+ "version": "2.11.6",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {