@oclif/core 2.10.1 → 2.11.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/lib/command.d.ts +1 -0
- package/lib/command.js +11 -1
- package/lib/config/config.d.ts +11 -0
- package/lib/config/config.js +15 -2
- package/lib/interfaces/config.d.ts +1 -0
- package/package.json +1 -1
package/lib/command.d.ts
CHANGED
|
@@ -124,6 +124,7 @@ export declare abstract class Command {
|
|
|
124
124
|
protected toSuccessJson(result: unknown): any;
|
|
125
125
|
protected toErrorJson(err: unknown): any;
|
|
126
126
|
protected logJson(json: unknown): void;
|
|
127
|
+
private removeEnvVar;
|
|
127
128
|
}
|
|
128
129
|
export declare namespace Command {
|
|
129
130
|
type Class = typeof Command & {
|
package/lib/command.js
CHANGED
|
@@ -112,7 +112,7 @@ class Command {
|
|
|
112
112
|
let result;
|
|
113
113
|
try {
|
|
114
114
|
// remove redirected env var to allow subsessions to run autoupdated client
|
|
115
|
-
|
|
115
|
+
this.removeEnvVar('REDIRECTED');
|
|
116
116
|
await this.init();
|
|
117
117
|
result = await this.run();
|
|
118
118
|
}
|
|
@@ -256,6 +256,16 @@ class Command {
|
|
|
256
256
|
logJson(json) {
|
|
257
257
|
cli_ux_1.ux.styledJSON(json);
|
|
258
258
|
}
|
|
259
|
+
removeEnvVar(envVar) {
|
|
260
|
+
const keys = [];
|
|
261
|
+
try {
|
|
262
|
+
keys.push(...this.config.scopedEnvVarKeys(envVar));
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
keys.push(this.config.scopedEnvVarKey(envVar));
|
|
266
|
+
}
|
|
267
|
+
keys.map(key => delete process.env[key]);
|
|
268
|
+
}
|
|
259
269
|
}
|
|
260
270
|
exports.Command = Command;
|
|
261
271
|
Command._base = `${pjson.name}@${pjson.version}`;
|
package/lib/config/config.d.ts
CHANGED
|
@@ -50,7 +50,18 @@ export declare class Config implements IConfig {
|
|
|
50
50
|
runCommand<T = unknown>(id: string, argv?: string[], cachedCommand?: Command.Loadable | null): Promise<T>;
|
|
51
51
|
scopedEnvVar(k: string): string | undefined;
|
|
52
52
|
scopedEnvVarTrue(k: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* this DOES NOT account for bin aliases, use scopedEnvVarKeys instead which will account for bin aliases
|
|
55
|
+
* @param {string} k, the unscoped key you want to get the value for
|
|
56
|
+
* @returns {string} returns the env var key
|
|
57
|
+
*/
|
|
53
58
|
scopedEnvVarKey(k: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* gets the scoped env var keys for a given key, including bin aliases
|
|
61
|
+
* @param {string} k, the env key e.g. 'debug'
|
|
62
|
+
* @returns {string[]} e.g. ['SF_DEBUG', 'SFDX_DEBUG']
|
|
63
|
+
*/
|
|
64
|
+
scopedEnvVarKeys(k: string): string[];
|
|
54
65
|
findCommand(id: string, opts: {
|
|
55
66
|
must: true;
|
|
56
67
|
}): Command.Loadable;
|
package/lib/config/config.js
CHANGED
|
@@ -333,18 +333,31 @@ class Config {
|
|
|
333
333
|
return result;
|
|
334
334
|
}
|
|
335
335
|
scopedEnvVar(k) {
|
|
336
|
-
return process.env[this.
|
|
336
|
+
return process.env[this.scopedEnvVarKeys(k).find(k => process.env[k])];
|
|
337
337
|
}
|
|
338
338
|
scopedEnvVarTrue(k) {
|
|
339
|
-
const v = process.env[this.
|
|
339
|
+
const v = process.env[this.scopedEnvVarKeys(k).find(k => process.env[k])];
|
|
340
340
|
return v === '1' || v === 'true';
|
|
341
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* this DOES NOT account for bin aliases, use scopedEnvVarKeys instead which will account for bin aliases
|
|
344
|
+
* @param {string} k, the unscoped key you want to get the value for
|
|
345
|
+
* @returns {string} returns the env var key
|
|
346
|
+
*/
|
|
342
347
|
scopedEnvVarKey(k) {
|
|
343
348
|
return [this.bin, k]
|
|
344
349
|
.map(p => p.replace(/@/g, '').replace(/[/-]/g, '_'))
|
|
345
350
|
.join('_')
|
|
346
351
|
.toUpperCase();
|
|
347
352
|
}
|
|
353
|
+
/**
|
|
354
|
+
* gets the scoped env var keys for a given key, including bin aliases
|
|
355
|
+
* @param {string} k, the env key e.g. 'debug'
|
|
356
|
+
* @returns {string[]} e.g. ['SF_DEBUG', 'SFDX_DEBUG']
|
|
357
|
+
*/
|
|
358
|
+
scopedEnvVarKeys(k) {
|
|
359
|
+
return [this.bin, ...this.binAliases ?? []].map(alias => [alias.replace(/@/g, '').replace(/[/-]/g, '_'), k].join('_').toUpperCase());
|
|
360
|
+
}
|
|
348
361
|
findCommand(id, opts = {}) {
|
|
349
362
|
const lookupId = this.getCmdLookupId(id);
|
|
350
363
|
const command = this._commands.get(lookupId);
|
|
@@ -130,6 +130,7 @@ export interface Config {
|
|
|
130
130
|
findMatches(id: string, argv: string[]): Command.Loadable[];
|
|
131
131
|
scopedEnvVar(key: string): string | undefined;
|
|
132
132
|
scopedEnvVarKey(key: string): string;
|
|
133
|
+
scopedEnvVarKeys(key: string): string[];
|
|
133
134
|
scopedEnvVarTrue(key: string): boolean;
|
|
134
135
|
s3Url(key: string): string;
|
|
135
136
|
s3Key(type: 'versioned' | 'unversioned', ext: '.tar.gz' | '.tar.xz', options?: Config.s3Key.Options): string;
|