@oclif/core 1.18.0 → 1.19.0
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/lib/command.d.ts +2 -1
- package/lib/command.js +13 -8
- package/package.json +1 -1
package/lib/command.d.ts
CHANGED
|
@@ -97,7 +97,8 @@ export default abstract class Command {
|
|
|
97
97
|
*/
|
|
98
98
|
abstract run(): PromiseLike<any>;
|
|
99
99
|
protected init(): Promise<any>;
|
|
100
|
-
protected
|
|
100
|
+
protected warnIfFlagDeprecated(flags: Record<string, unknown>): void;
|
|
101
|
+
protected warnIfCommandDeprecated(): void;
|
|
101
102
|
protected parse<F extends Interfaces.FlagOutput, G extends Interfaces.FlagOutput, A extends {
|
|
102
103
|
[name: string]: any;
|
|
103
104
|
}>(options?: Interfaces.Input<F, G>, argv?: string[]): Promise<Interfaces.ParserOutput<F, G, A>>;
|
package/lib/command.js
CHANGED
|
@@ -126,18 +126,21 @@ class Command {
|
|
|
126
126
|
const g = global;
|
|
127
127
|
g['http-call'] = g['http-call'] || {};
|
|
128
128
|
g['http-call'].userAgent = this.config.userAgent;
|
|
129
|
-
this.
|
|
129
|
+
this.warnIfCommandDeprecated();
|
|
130
130
|
}
|
|
131
|
-
|
|
131
|
+
warnIfFlagDeprecated(flags) {
|
|
132
|
+
for (const flag of Object.keys(flags)) {
|
|
133
|
+
const deprecated = this.ctor.flags[flag]?.deprecated;
|
|
134
|
+
if (deprecated) {
|
|
135
|
+
this.warn((0, util_2.formatFlagDeprecationWarning)(flag, deprecated));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
warnIfCommandDeprecated() {
|
|
132
140
|
if (this.ctor.state === 'deprecated') {
|
|
133
141
|
const cmdName = (0, index_1.toConfiguredId)(this.ctor.id, this.config);
|
|
134
142
|
this.warn((0, util_2.formatCommandDeprecationWarning)(cmdName, this.ctor.deprecationOptions));
|
|
135
143
|
}
|
|
136
|
-
for (const [flag, opts] of Object.entries(this.ctor.flags ?? {})) {
|
|
137
|
-
if (opts.deprecated) {
|
|
138
|
-
this.warn((0, util_2.formatFlagDeprecationWarning)(flag, opts.deprecated));
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
144
|
}
|
|
142
145
|
async parse(options, argv = this.argv) {
|
|
143
146
|
if (!options)
|
|
@@ -146,7 +149,9 @@ class Command {
|
|
|
146
149
|
// the spread operator doesn't work with getters so we have to manually add it here
|
|
147
150
|
opts.flags = options?.flags;
|
|
148
151
|
opts.args = options?.args;
|
|
149
|
-
|
|
152
|
+
const results = await Parser.parse(argv, opts);
|
|
153
|
+
this.warnIfFlagDeprecated(results.flags ?? {});
|
|
154
|
+
return results;
|
|
150
155
|
}
|
|
151
156
|
async catch(err) {
|
|
152
157
|
process.exitCode = process.exitCode ?? err.exitCode ?? 1;
|