@oclif/core 1.10.0 → 1.12.1

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.12.1](https://github.com/oclif/core/compare/v1.12.0...v1.12.1) (2022-07-21)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * flag setter order ([#450](https://github.com/oclif/core/issues/450)) ([a02f86c](https://github.com/oclif/core/commit/a02f86cb1094a86ba0cd8689fd82908ff3d46386))
11
+
12
+ ## [1.12.0](https://github.com/oclif/core/compare/v1.11.0...v1.12.0) (2022-07-20)
13
+
14
+
15
+ ### Features
16
+
17
+ * improve the instantiation of global flags ([#445](https://github.com/oclif/core/issues/445)) ([d264535](https://github.com/oclif/core/commit/d2645358ccf1cddd0bb65d236e73ecf4c5ac7c0c))
18
+
19
+ ## [1.11.0](https://github.com/oclif/core/compare/v1.10.0...v1.11.0) (2022-07-18)
20
+
21
+
22
+ ### Features
23
+
24
+ * print error info when module not found ([#427](https://github.com/oclif/core/issues/427)) ([223e79b](https://github.com/oclif/core/commit/223e79b363ad01da327e264244daf23810849d70))
25
+
5
26
  ## [1.10.0](https://github.com/oclif/core/compare/v1.9.10...v1.10.0) (2022-07-15)
6
27
 
7
28
 
package/lib/command.d.ts CHANGED
@@ -55,7 +55,9 @@ export default abstract class Command {
55
55
  */
56
56
  static examples: Interfaces.Example[];
57
57
  static parserOptions: {};
58
- static enableJsonFlag: boolean;
58
+ static _enableJsonFlag: boolean;
59
+ static get enableJsonFlag(): boolean;
60
+ static set enableJsonFlag(value: boolean);
59
61
  /**
60
62
  * instantiate and run the command
61
63
  * @param {Interfaces.Command.Class} this Class
package/lib/command.js CHANGED
@@ -39,20 +39,27 @@ class Command {
39
39
  this.debug = () => { };
40
40
  }
41
41
  }
42
+ static get enableJsonFlag() {
43
+ return this._enableJsonFlag;
44
+ }
45
+ static set enableJsonFlag(value) {
46
+ this._enableJsonFlag = value;
47
+ if (value)
48
+ this.globalFlags = jsonFlag;
49
+ }
42
50
  static get globalFlags() {
43
51
  return this._globalFlags;
44
52
  }
45
53
  static set globalFlags(flags) {
46
- this._globalFlags = this.enableJsonFlag ?
47
- Object.assign({}, jsonFlag, this.globalFlags, flags) :
48
- Object.assign({}, this.globalFlags, flags);
54
+ this._globalFlags = Object.assign({}, this.globalFlags, flags);
55
+ this.flags = {}; // force the flags setter to run
49
56
  }
50
57
  static get flags() {
51
58
  return this._flags;
52
59
  }
53
60
  static set flags(flags) {
54
- this.globalFlags = {};
55
- this._flags = Object.assign({}, this.globalFlags, flags);
61
+ var _a;
62
+ this._flags = Object.assign({}, (_a = this._flags) !== null && _a !== void 0 ? _a : {}, this.globalFlags, flags);
56
63
  }
57
64
  get ctor() {
58
65
  return this.constructor;
@@ -123,7 +130,7 @@ class Command {
123
130
  options = this.constructor;
124
131
  const opts = { context: this, ...options };
125
132
  // the spread operator doesn't work with getters so we have to manually add it here
126
- opts.flags = options === null || options === void 0 ? void 0 : options.flags;
133
+ opts.flags = Object.assign({}, options === null || options === void 0 ? void 0 : options.flags, options === null || options === void 0 ? void 0 : options.globalFlags);
127
134
  return Parser.parse(argv, opts);
128
135
  }
129
136
  async catch(err) {
@@ -169,7 +176,7 @@ Command.aliases = [];
169
176
  Command.strict = true;
170
177
  Command.parse = true;
171
178
  Command.parserOptions = {};
172
- Command.enableJsonFlag = false;
179
+ Command._enableJsonFlag = false;
173
180
  // eslint-disable-next-line valid-jsdoc
174
181
  /**
175
182
  * instantiate and run the command
@@ -160,6 +160,7 @@ export declare type EnumFlagOptions<T> = Partial<OptionFlag<T>> & {
160
160
  export declare type Flag<T> = BooleanFlag<T> | OptionFlag<T>;
161
161
  export declare type Input<TFlags extends FlagOutput> = {
162
162
  flags?: FlagInput<TFlags>;
163
+ globalFlags?: FlagInput<TFlags>;
163
164
  args?: ArgInput;
164
165
  strict?: boolean;
165
166
  context?: any;
@@ -82,7 +82,7 @@ class ModuleLoader {
82
82
  }
83
83
  catch (error) {
84
84
  if (error.code === 'MODULE_NOT_FOUND' || error.code === 'ERR_MODULE_NOT_FOUND') {
85
- throw new errors_1.ModuleLoadError(`${isESM ? 'import()' : 'require'} failed to load ${filePath || modulePath}`);
85
+ throw new errors_1.ModuleLoadError(`${isESM ? 'import()' : 'require'} failed to load ${filePath || modulePath}: ${error.message}`);
86
86
  }
87
87
  throw error;
88
88
  }
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": "1.10.0",
4
+ "version": "1.12.1",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {