@salesforce/core 8.31.5 → 8.32.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.
@@ -23,11 +23,22 @@ import { AuthFields } from './authInfo';
23
23
  * );
24
24
  * await remover.removeAuth(auth.username);
25
25
  * ```
26
+ *
27
+ * Pass a `projectPath` to resolve local config from a specific project instead of `process.cwd()`,
28
+ * and `skipCache` to re-read config from disk when the process-cached aggregator can't be trusted:
29
+ *
30
+ * ```
31
+ * const remover = await AuthRemover.create({ projectPath: '/path/to/project', skipCache: true });
32
+ * await remover.removeAuth('example@mycompany.com');
33
+ * ```
26
34
  */
27
- export declare class AuthRemover extends AsyncOptionalCreatable {
35
+ export declare class AuthRemover extends AsyncOptionalCreatable<AuthRemoverOptions> {
28
36
  private config;
29
37
  private stateAggregator;
30
38
  private logger;
39
+ private readonly projectPath?;
40
+ private readonly skipCache?;
41
+ constructor(options?: AuthRemoverOptions);
31
42
  /**
32
43
  * Removes the authentication and any configs or aliases associated with it
33
44
  *
@@ -85,3 +96,12 @@ export declare class AuthRemover extends AsyncOptionalCreatable {
85
96
  */
86
97
  private unsetAliases;
87
98
  }
99
+ export type AuthRemoverOptions = {
100
+ /** an absolute path to the project root, used to resolve local config; defaults to `process.cwd()` */
101
+ projectPath?: string;
102
+ /**
103
+ * re-read config from disk instead of trusting the process-cached ConfigAggregator. Set `true`
104
+ * when the config may have changed out of process or before this call. Defaults to `false`.
105
+ */
106
+ skipCache?: boolean;
107
+ };
@@ -37,11 +37,26 @@ const messages = new messages_1.Messages('@salesforce/core', 'auth', new Map([["
37
37
  * );
38
38
  * await remover.removeAuth(auth.username);
39
39
  * ```
40
+ *
41
+ * Pass a `projectPath` to resolve local config from a specific project instead of `process.cwd()`,
42
+ * and `skipCache` to re-read config from disk when the process-cached aggregator can't be trusted:
43
+ *
44
+ * ```
45
+ * const remover = await AuthRemover.create({ projectPath: '/path/to/project', skipCache: true });
46
+ * await remover.removeAuth('example@mycompany.com');
47
+ * ```
40
48
  */
41
49
  class AuthRemover extends kit_1.AsyncOptionalCreatable {
42
50
  config;
43
51
  stateAggregator;
44
52
  logger;
53
+ projectPath;
54
+ skipCache;
55
+ constructor(options) {
56
+ super(options);
57
+ this.projectPath = options?.projectPath;
58
+ this.skipCache = options?.skipCache;
59
+ }
45
60
  /**
46
61
  * Removes the authentication and any configs or aliases associated with it
47
62
  *
@@ -91,7 +106,13 @@ class AuthRemover extends kit_1.AsyncOptionalCreatable {
91
106
  }
92
107
  async init() {
93
108
  this.logger = await logger_1.Logger.child(this.constructor.name);
94
- this.config = await configAggregator_1.ConfigAggregator.create();
109
+ this.config = await configAggregator_1.ConfigAggregator.create(this.projectPath ? { projectPath: this.projectPath } : undefined);
110
+ // ConfigAggregator.create returns a process-cached instance keyed by projectPath, so its
111
+ // in-memory config may be stale (set out of process, or before this call). When the caller
112
+ // can't trust the cache, skipCache re-reads from disk so unsetConfigValues sees current values.
113
+ if (this.skipCache) {
114
+ await this.config.reload();
115
+ }
95
116
  this.stateAggregator = await stateAggregator_1.StateAggregator.getInstance();
96
117
  await this.stateAggregator.orgs.readAll();
97
118
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "8.31.5",
3
+ "version": "8.32.0",
4
4
  "description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
5
5
  "main": "lib/index",
6
6
  "types": "lib/index.d.ts",