@salesforce/core 8.31.4 → 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.
- package/lib/fs/fs.js +2 -2
- package/lib/global.js +2 -1
- package/lib/org/authRemover.d.ts +21 -1
- package/lib/org/authRemover.js +22 -1
- package/lib/util/isWeb.d.ts +1 -0
- package/lib/util/isWeb.js +16 -0
- package/package.json +1 -1
package/lib/fs/fs.js
CHANGED
|
@@ -34,9 +34,9 @@ const nodeFs = __importStar(require("node:fs"));
|
|
|
34
34
|
// yes, we're going to import it even though it might not be used.
|
|
35
35
|
// the alternatives were all worse without top-level await (iife, runtime errors from something trying to use it before it's initialized)
|
|
36
36
|
const memfs = __importStar(require("memfs"));
|
|
37
|
-
const
|
|
37
|
+
const isWeb_1 = require("../util/isWeb");
|
|
38
38
|
const getVirtualFs = (memfsVolume) => {
|
|
39
|
-
if (isWeb()) {
|
|
39
|
+
if (process.env.FORCE_MEMFS === 'true' || (0, isWeb_1.isWeb)()) {
|
|
40
40
|
const memfsInstance = memfs.createFsFromVolume(memfsVolume ?? new memfs.Volume());
|
|
41
41
|
// Start with memfs instance and only override problematic methods
|
|
42
42
|
const webFs = {
|
package/lib/global.js
CHANGED
|
@@ -34,6 +34,7 @@ const os = __importStar(require("node:os"));
|
|
|
34
34
|
const path = __importStar(require("node:path"));
|
|
35
35
|
const kit_1 = require("@salesforce/kit");
|
|
36
36
|
const fs_1 = require("./fs/fs");
|
|
37
|
+
const isWeb_1 = require("./util/isWeb");
|
|
37
38
|
const sfError_1 = require("./sfError");
|
|
38
39
|
/**
|
|
39
40
|
* Represents an environment mode. Supports `production`, `development`, `demo`, and `test`
|
|
@@ -74,7 +75,7 @@ class Global {
|
|
|
74
75
|
* Whether the code is running in a web browser.
|
|
75
76
|
*/
|
|
76
77
|
static get isWeb() {
|
|
77
|
-
return
|
|
78
|
+
return (0, isWeb_1.isWeb)();
|
|
78
79
|
}
|
|
79
80
|
/**
|
|
80
81
|
* The full system path to the global sfdx state folder.
|
package/lib/org/authRemover.d.ts
CHANGED
|
@@ -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
|
+
};
|
package/lib/org/authRemover.js
CHANGED
|
@@ -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
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isWeb: () => boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.isWeb = void 0;
|
|
10
|
+
const isWeb = () => {
|
|
11
|
+
if (process.versions.bun)
|
|
12
|
+
return false;
|
|
13
|
+
return 'window' in globalThis || 'self' in globalThis;
|
|
14
|
+
};
|
|
15
|
+
exports.isWeb = isWeb;
|
|
16
|
+
//# sourceMappingURL=isWeb.js.map
|