@salesforce/core 8.18.6 → 8.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/config/config.js +7 -30
- package/lib/config/configFile.d.ts +1 -1
- package/lib/config/configFile.js +18 -41
- package/lib/crypto/crypto.js +1 -3
- package/lib/crypto/keyChainImpl.d.ts +2 -2
- package/lib/crypto/keyChainImpl.js +10 -11
- package/lib/deviceOauthService.js +2 -2
- package/lib/fs/fs.d.ts +6 -0
- package/lib/fs/fs.js +79 -0
- package/lib/fs/types.d.ts +31 -0
- package/lib/fs/types.js +3 -0
- package/lib/global.js +5 -5
- package/lib/index.d.ts +4 -1
- package/lib/index.js +4 -1
- package/lib/lifecycleEvents.js +0 -3
- package/lib/logger/cleanup.js +3 -26
- package/lib/logger/logger.d.ts +1 -1
- package/lib/logger/logger.js +1 -1
- package/lib/messages.js +2 -1
- package/lib/org/authInfo.js +6 -6
- package/lib/org/connection.d.ts +1 -1
- package/lib/org/connection.js +5 -3
- package/lib/org/org.js +18 -20
- package/lib/org/permissionSetAssignment.js +4 -8
- package/lib/org/scratchOrgCreate.js +1 -1
- package/lib/org/scratchOrgInfoApi.js +2 -2
- package/lib/org/scratchOrgInfoGenerator.js +3 -3
- package/lib/org/scratchOrgSettingsGenerator.js +1 -1
- package/lib/org/user.js +4 -3
- package/lib/schema/validator.js +5 -5
- package/lib/sfProject.js +2 -25
- package/lib/stateAggregator/accessors/aliasAccessor.js +14 -7
- package/lib/stateAggregator/accessors/orgAccessor.d.ts +2 -2
- package/lib/stateAggregator/accessors/orgAccessor.js +3 -3
- package/lib/status/myDomainResolver.d.ts +0 -2
- package/lib/status/myDomainResolver.js +0 -12
- package/lib/status/streamingClient.d.ts +2 -2
- package/lib/status/streamingClient.js +11 -11
- package/lib/testSetup.js +3 -3
- package/lib/util/directoryWriter.js +7 -7
- package/lib/util/fileLocking.d.ts +3 -1
- package/lib/util/fileLocking.js +19 -31
- package/lib/util/findUppercaseKeys.js +2 -2
- package/lib/util/internal.js +3 -26
- package/lib/util/lockRetryOptions.d.ts +1 -2
- package/lib/util/lockRetryOptions.js +2 -5
- package/lib/util/sfdcUrl.js +3 -2
- package/lib/util/time.js +2 -2
- package/lib/webOAuthServer.js +7 -7
- package/package.json +5 -3
package/lib/config/config.js
CHANGED
|
@@ -1,39 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2025, salesforce.com, inc.
|
|
4
4
|
* All rights reserved.
|
|
5
5
|
* Licensed under the BSD 3-Clause license.
|
|
6
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
-
}) : function(o, v) {
|
|
22
|
-
o["default"] = v;
|
|
23
|
-
});
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
9
|
exports.Config = exports.SfProperty = exports.SFDX_ALLOWED_PROPERTIES = exports.SfdxPropertyKeys = exports.SF_ALLOWED_PROPERTIES = exports.SfConfigProperties = void 0;
|
|
33
10
|
const node_path_1 = require("node:path");
|
|
34
|
-
const fs = __importStar(require("node:fs"));
|
|
35
|
-
const kit_1 = require("@salesforce/kit");
|
|
36
11
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
12
|
+
const kit_1 = require("@salesforce/kit");
|
|
13
|
+
const fs_1 = require("../fs/fs");
|
|
37
14
|
const global_1 = require("../global");
|
|
38
15
|
const logger_1 = require("../logger/logger");
|
|
39
16
|
const messages_1 = require("../messages");
|
|
@@ -534,8 +511,8 @@ const buildSfdxPath = (options) => {
|
|
|
534
511
|
const writeToSfdx = async (path, contents) => {
|
|
535
512
|
try {
|
|
536
513
|
const translated = translateToSfdx(contents);
|
|
537
|
-
await fs.promises.mkdir((0, node_path_1.dirname)(path), { recursive: true });
|
|
538
|
-
await fs.promises.writeFile(path, JSON.stringify(translated, null, 2));
|
|
514
|
+
await fs_1.fs.promises.mkdir((0, node_path_1.dirname)(path), { recursive: true });
|
|
515
|
+
await fs_1.fs.promises.writeFile(path, JSON.stringify(translated, null, 2));
|
|
539
516
|
}
|
|
540
517
|
catch (e) {
|
|
541
518
|
const logger = logger_1.Logger.childFromRoot('core:config:writeToSfdx');
|
|
@@ -545,8 +522,8 @@ const writeToSfdx = async (path, contents) => {
|
|
|
545
522
|
/** turn the sfdx config file into a LWWState based on its contents and its timestamp */
|
|
546
523
|
const stateFromSfdxFileSync = (path, config) => {
|
|
547
524
|
try {
|
|
548
|
-
const fileContents = fs.readFileSync(path, 'utf8');
|
|
549
|
-
const mtimeNs = fs.statSync(path, { bigint: true }).mtimeNs;
|
|
525
|
+
const fileContents = fs_1.fs.readFileSync(path, 'utf8');
|
|
526
|
+
const mtimeNs = fs_1.fs.statSync(path, { bigint: true }).mtimeNs;
|
|
550
527
|
const translatedContents = translateToSf((0, kit_1.parseJsonMap)(fileContents, path), config);
|
|
551
528
|
// get the file timestamp
|
|
552
529
|
return (0, lwwMap_1.stateFromContents)(translatedContents, mtimeNs);
|
package/lib/config/configFile.js
CHANGED
|
@@ -5,36 +5,13 @@
|
|
|
5
5
|
* Licensed under the BSD 3-Clause license.
|
|
6
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
-
}) : function(o, v) {
|
|
22
|
-
o["default"] = v;
|
|
23
|
-
});
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
9
|
exports.ConfigFile = void 0;
|
|
33
|
-
const fs = __importStar(require("node:fs"));
|
|
34
|
-
const node_fs_1 = require("node:fs");
|
|
35
10
|
const node_os_1 = require("node:os");
|
|
36
11
|
const node_path_1 = require("node:path");
|
|
12
|
+
const node_fs_1 = require("node:fs");
|
|
37
13
|
const kit_1 = require("@salesforce/kit");
|
|
14
|
+
const fs_1 = require("../fs/fs");
|
|
38
15
|
const global_1 = require("../global");
|
|
39
16
|
const logger_1 = require("../logger/logger");
|
|
40
17
|
const sfError_1 = require("../sfError");
|
|
@@ -57,7 +34,7 @@ const lwwMap_1 = require("./lwwMap");
|
|
|
57
34
|
* const myConfig = await MyConfig.create({
|
|
58
35
|
* isGlobal: true
|
|
59
36
|
* });
|
|
60
|
-
* myConfig.set('
|
|
37
|
+
* myConfig.set('myKey', 'myValue');
|
|
61
38
|
* await myConfig.write();
|
|
62
39
|
* ```
|
|
63
40
|
*/
|
|
@@ -136,7 +113,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
136
113
|
*/
|
|
137
114
|
async access(perm) {
|
|
138
115
|
try {
|
|
139
|
-
await fs.promises.access(this.getPath(), perm);
|
|
116
|
+
await fs_1.fs.promises.access(this.getPath(), perm);
|
|
140
117
|
return true;
|
|
141
118
|
}
|
|
142
119
|
catch (err) {
|
|
@@ -153,7 +130,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
153
130
|
*/
|
|
154
131
|
accessSync(perm) {
|
|
155
132
|
try {
|
|
156
|
-
fs.accessSync(this.getPath(), perm);
|
|
133
|
+
fs_1.fs.accessSync(this.getPath(), perm);
|
|
157
134
|
return true;
|
|
158
135
|
}
|
|
159
136
|
catch (err) {
|
|
@@ -176,8 +153,8 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
176
153
|
if (!this.hasRead || force) {
|
|
177
154
|
this.logger.debug(`Reading config file: ${this.getPath()} because ${!this.hasRead ? 'hasRead is false' : 'force parameter is true'}`);
|
|
178
155
|
await (0, fileLocking_1.pollUntilUnlock)(this.getPath());
|
|
179
|
-
const obj = (0, kit_1.parseJsonMap)(await fs.promises.readFile(this.getPath(), 'utf8'), this.getPath());
|
|
180
|
-
this.setContentsFromFileContents(obj, (await fs.promises.stat(this.getPath(), { bigint: true })).mtimeNs);
|
|
156
|
+
const obj = (0, kit_1.parseJsonMap)(await fs_1.fs.promises.readFile(this.getPath(), 'utf8'), this.getPath());
|
|
157
|
+
this.setContentsFromFileContents(obj, (await fs_1.fs.promises.stat(this.getPath(), { bigint: true })).mtimeNs);
|
|
181
158
|
}
|
|
182
159
|
// Necessarily set this even when an error happens to avoid infinite re-reading.
|
|
183
160
|
// To attempt another read, pass `force=true`.
|
|
@@ -213,8 +190,8 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
213
190
|
if (!this.hasRead || force) {
|
|
214
191
|
(0, fileLocking_1.pollUntilUnlockSync)(this.getPath());
|
|
215
192
|
this.logger.debug(`Reading config file: ${this.getPath()}`);
|
|
216
|
-
const obj = (0, kit_1.parseJsonMap)(fs.readFileSync(this.getPath(), 'utf8'));
|
|
217
|
-
this.setContentsFromFileContents(obj, fs.statSync(this.getPath(), { bigint: true }).mtimeNs);
|
|
193
|
+
const obj = (0, kit_1.parseJsonMap)(fs_1.fs.readFileSync(this.getPath(), 'utf8'));
|
|
194
|
+
this.setContentsFromFileContents(obj, fs_1.fs.statSync(this.getPath(), { bigint: true }).mtimeNs);
|
|
218
195
|
}
|
|
219
196
|
// Necessarily set this even when an error happens to avoid infinite re-reading.
|
|
220
197
|
// To attempt another read, pass `force=true`.
|
|
@@ -248,7 +225,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
248
225
|
// lock the file. Returns an unlock function to call when done.
|
|
249
226
|
try {
|
|
250
227
|
const fileTimestamp = await getNsTimeStamp(this.getPath());
|
|
251
|
-
const fileContents = (0, kit_1.parseJsonMap)(await fs.promises.readFile(this.getPath(), 'utf8'), this.getPath());
|
|
228
|
+
const fileContents = (0, kit_1.parseJsonMap)(await fs_1.fs.promises.readFile(this.getPath(), 'utf8'), this.getPath());
|
|
252
229
|
this.logAndMergeContents(fileTimestamp, fileContents);
|
|
253
230
|
}
|
|
254
231
|
catch (err) {
|
|
@@ -269,7 +246,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
269
246
|
try {
|
|
270
247
|
// get the file modstamp. Do this after the lock acquisition in case the file is being written to.
|
|
271
248
|
const fileTimestamp = getNsTimeStampSync(this.getPath());
|
|
272
|
-
const fileContents = (0, kit_1.parseJsonMap)(fs.readFileSync(this.getPath(), 'utf8'), this.getPath());
|
|
249
|
+
const fileContents = (0, kit_1.parseJsonMap)(fs_1.fs.readFileSync(this.getPath(), 'utf8'), this.getPath());
|
|
273
250
|
this.logAndMergeContents(fileTimestamp, fileContents);
|
|
274
251
|
}
|
|
275
252
|
catch (err) {
|
|
@@ -297,7 +274,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
297
274
|
* {@link fs.stat}
|
|
298
275
|
*/
|
|
299
276
|
async stat() {
|
|
300
|
-
return fs.promises.stat(this.getPath());
|
|
277
|
+
return fs_1.fs.promises.stat(this.getPath());
|
|
301
278
|
}
|
|
302
279
|
/**
|
|
303
280
|
* Get the stats of the file. Returns the stats of the file.
|
|
@@ -305,7 +282,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
305
282
|
* {@link fs.stat}
|
|
306
283
|
*/
|
|
307
284
|
statSync() {
|
|
308
|
-
return fs.statSync(this.getPath());
|
|
285
|
+
return fs_1.fs.statSync(this.getPath());
|
|
309
286
|
}
|
|
310
287
|
/**
|
|
311
288
|
* Delete the config file if it exists.
|
|
@@ -316,7 +293,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
316
293
|
async unlink() {
|
|
317
294
|
const exists = await this.exists();
|
|
318
295
|
if (exists) {
|
|
319
|
-
return fs.promises.unlink(this.getPath());
|
|
296
|
+
return fs_1.fs.promises.unlink(this.getPath());
|
|
320
297
|
}
|
|
321
298
|
throw new sfError_1.SfError(`Target file doesn't exist. path: ${this.getPath()}`, 'TargetFileNotFound');
|
|
322
299
|
}
|
|
@@ -329,7 +306,7 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
329
306
|
unlinkSync() {
|
|
330
307
|
const exists = this.existsSync();
|
|
331
308
|
if (exists) {
|
|
332
|
-
return fs.unlinkSync(this.getPath());
|
|
309
|
+
return fs_1.fs.unlinkSync(this.getPath());
|
|
333
310
|
}
|
|
334
311
|
throw new sfError_1.SfError(`Target file doesn't exist. path: ${this.getPath()}`, 'TargetFileNotFound');
|
|
335
312
|
}
|
|
@@ -394,8 +371,8 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
394
371
|
}
|
|
395
372
|
}
|
|
396
373
|
exports.ConfigFile = ConfigFile;
|
|
397
|
-
const getNsTimeStamp = async (filePath) => getNsTimeStampFromStatus(await fs.promises.stat(filePath, { bigint: true }));
|
|
398
|
-
const getNsTimeStampSync = (filePath) => getNsTimeStampFromStatus(fs.statSync(filePath, { bigint: true }));
|
|
374
|
+
const getNsTimeStamp = async (filePath) => getNsTimeStampFromStatus(await fs_1.fs.promises.stat(filePath, { bigint: true }));
|
|
375
|
+
const getNsTimeStampSync = (filePath) => getNsTimeStampFromStatus(fs_1.fs.statSync(filePath, { bigint: true }));
|
|
399
376
|
/** in browser environment, memfs is missing the bigInt ns timestamp, so we generate it from the ms */
|
|
400
|
-
const getNsTimeStampFromStatus = (stats) => stats.mtimeNs
|
|
377
|
+
const getNsTimeStampFromStatus = (stats) => 'mtimeNs' in stats ? stats.mtimeNs : BigInt(stats.mtimeMs) * BigInt(1_000_000);
|
|
401
378
|
//# sourceMappingURL=configFile.js.map
|
package/lib/crypto/crypto.js
CHANGED
|
@@ -367,9 +367,7 @@ class Crypto extends kit_1.AsyncOptionalCreatable {
|
|
|
367
367
|
});
|
|
368
368
|
}
|
|
369
369
|
async getKeyChain(platform) {
|
|
370
|
-
|
|
371
|
-
this.options.keychain = await (0, keyChain_1.retrieveKeychain)(platform);
|
|
372
|
-
}
|
|
370
|
+
this.options.keychain ??= await (0, keyChain_1.retrieveKeychain)(platform);
|
|
373
371
|
return this.options.keychain;
|
|
374
372
|
}
|
|
375
373
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as childProcess from 'node:child_process';
|
|
2
|
-
import * as nodeFs from 'node:fs';
|
|
3
2
|
import { Nullable } from '@salesforce/ts-types';
|
|
4
|
-
|
|
3
|
+
import { fs } from '../fs/fs';
|
|
4
|
+
export type FsIfc = Pick<typeof fs, 'statSync'>;
|
|
5
5
|
/**
|
|
6
6
|
* Basic keychain interface.
|
|
7
7
|
*/
|
|
@@ -31,13 +31,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.keyChainImpl = exports.GenericWindowsKeychainAccess = exports.GenericUnixKeychainAccess = exports.GenericKeychainAccess = exports.KeychainAccess = void 0;
|
|
33
33
|
const childProcess = __importStar(require("node:child_process"));
|
|
34
|
-
const nodeFs = __importStar(require("node:fs"));
|
|
35
|
-
const fs = __importStar(require("node:fs"));
|
|
36
34
|
const os = __importStar(require("node:os"));
|
|
37
35
|
const node_os_1 = require("node:os");
|
|
38
36
|
const path = __importStar(require("node:path"));
|
|
39
37
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
40
38
|
const kit_1 = require("@salesforce/kit");
|
|
39
|
+
const fs_1 = require("../fs/fs");
|
|
41
40
|
const global_1 = require("../global");
|
|
42
41
|
const messages_1 = require("../messages");
|
|
43
42
|
;
|
|
@@ -252,7 +251,7 @@ const linuxImpl = {
|
|
|
252
251
|
setCommandFunc(opts, fn) {
|
|
253
252
|
const secretTool = fn(linuxImpl.getProgram(), linuxImpl.setProgramOptions(opts));
|
|
254
253
|
if (secretTool.stdin) {
|
|
255
|
-
secretTool.stdin.write(`${opts.password}\n`);
|
|
254
|
+
secretTool.stdin.write(`${opts.password ?? ''}\n`);
|
|
256
255
|
}
|
|
257
256
|
return secretTool;
|
|
258
257
|
},
|
|
@@ -351,8 +350,8 @@ async function writeFile(opts, fn) {
|
|
|
351
350
|
[SecretField.SERVICE]: opts.service,
|
|
352
351
|
};
|
|
353
352
|
const secretFile = getSecretFile();
|
|
354
|
-
await fs.promises.mkdir(path.dirname(secretFile), { recursive: true });
|
|
355
|
-
await fs.promises.writeFile(secretFile, JSON.stringify(contents, null, 4), { mode: '600' });
|
|
353
|
+
await fs_1.fs.promises.mkdir(path.dirname(secretFile), { recursive: true });
|
|
354
|
+
await fs_1.fs.promises.writeFile(secretFile, JSON.stringify(contents, null, 4), { mode: '600' });
|
|
356
355
|
fn(null, contents);
|
|
357
356
|
}
|
|
358
357
|
catch (err) {
|
|
@@ -361,7 +360,7 @@ async function writeFile(opts, fn) {
|
|
|
361
360
|
}
|
|
362
361
|
async function readFile() {
|
|
363
362
|
// The file and access is validated before this method is called
|
|
364
|
-
const fileContents = (0, kit_1.parseJsonMap)(await fs.promises.readFile(getSecretFile(), 'utf8'));
|
|
363
|
+
const fileContents = (0, kit_1.parseJsonMap)(await fs_1.fs.promises.readFile(getSecretFile(), 'utf8'));
|
|
365
364
|
return {
|
|
366
365
|
account: (0, ts_types_1.ensureString)(fileContents[SecretField.ACCOUNT]),
|
|
367
366
|
password: (0, ts_types_1.asString)(fileContents[SecretField.KEY]),
|
|
@@ -427,7 +426,7 @@ class GenericKeychainAccess {
|
|
|
427
426
|
async isValidFileAccess(cb) {
|
|
428
427
|
try {
|
|
429
428
|
const root = (0, node_os_1.homedir)();
|
|
430
|
-
await fs.promises.access(path.join(root, global_1.Global.SFDX_STATE_FOLDER), fs.constants.R_OK | fs.constants.X_OK | fs.constants.W_OK);
|
|
429
|
+
await fs_1.fs.promises.access(path.join(root, global_1.Global.SFDX_STATE_FOLDER), fs_1.fs.constants.R_OK | fs_1.fs.constants.X_OK | fs_1.fs.constants.W_OK);
|
|
431
430
|
await cb(null);
|
|
432
431
|
}
|
|
433
432
|
catch (err) {
|
|
@@ -448,7 +447,7 @@ class GenericUnixKeychainAccess extends GenericKeychainAccess {
|
|
|
448
447
|
}
|
|
449
448
|
else {
|
|
450
449
|
const secretFile = getSecretFile();
|
|
451
|
-
const stats = await fs.promises.stat(secretFile);
|
|
450
|
+
const stats = await fs_1.fs.promises.stat(secretFile);
|
|
452
451
|
const octalModeStr = (stats.mode & 0o777).toString(8);
|
|
453
452
|
const EXPECTED_OCTAL_PERM_VALUE = '600';
|
|
454
453
|
if (octalModeStr === EXPECTED_OCTAL_PERM_VALUE) {
|
|
@@ -474,7 +473,7 @@ class GenericWindowsKeychainAccess extends GenericKeychainAccess {
|
|
|
474
473
|
}
|
|
475
474
|
else {
|
|
476
475
|
try {
|
|
477
|
-
await fs.promises.access(getSecretFile(), fs.constants.R_OK | fs.constants.W_OK);
|
|
476
|
+
await fs_1.fs.promises.access(getSecretFile(), fs_1.fs.constants.R_OK | fs_1.fs.constants.W_OK);
|
|
478
477
|
await cb(null);
|
|
479
478
|
}
|
|
480
479
|
catch (e) {
|
|
@@ -493,8 +492,8 @@ exports.keyChainImpl = {
|
|
|
493
492
|
generic_unix: new GenericUnixKeychainAccess(),
|
|
494
493
|
// eslint-disable-next-line camelcase
|
|
495
494
|
generic_windows: new GenericWindowsKeychainAccess(),
|
|
496
|
-
darwin: new KeychainAccess(darwinImpl,
|
|
497
|
-
linux: new KeychainAccess(linuxImpl,
|
|
495
|
+
darwin: new KeychainAccess(darwinImpl, fs_1.fs),
|
|
496
|
+
linux: new KeychainAccess(linuxImpl, fs_1.fs),
|
|
498
497
|
validateProgram: _validateProgram,
|
|
499
498
|
};
|
|
500
499
|
//# sourceMappingURL=keyChainImpl.js.map
|
|
@@ -114,8 +114,8 @@ class DeviceOauthService extends kit_1.AsyncCreatable {
|
|
|
114
114
|
}
|
|
115
115
|
async init() {
|
|
116
116
|
this.logger = await logger_1.Logger.child(this.constructor.name);
|
|
117
|
-
this.logger.debug(`this.options.clientId: ${this.options.clientId}`);
|
|
118
|
-
this.logger.debug(`this.options.loginUrl: ${this.options.loginUrl}`);
|
|
117
|
+
this.logger.debug(`this.options.clientId: ${this.options.clientId ?? '<undefined>'}`);
|
|
118
|
+
this.logger.debug(`this.options.loginUrl: ${this.options.loginUrl ?? '<undefined>'}`);
|
|
119
119
|
}
|
|
120
120
|
getLoginOptions(url) {
|
|
121
121
|
const form = new form_data_1.default();
|
package/lib/fs/fs.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as memfs from 'memfs';
|
|
2
|
+
import type { VirtualFs } from './types';
|
|
3
|
+
export declare let fs: VirtualFs;
|
|
4
|
+
export declare const getVirtualFs: (memfsVolume?: memfs.Volume) => VirtualFs;
|
|
5
|
+
export declare const setFs: (providedFs: VirtualFs) => void;
|
|
6
|
+
export declare const resetFs: () => void;
|
package/lib/fs/fs.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.resetFs = exports.setFs = exports.getVirtualFs = exports.fs = void 0;
|
|
33
|
+
const nodeFs = __importStar(require("node:fs"));
|
|
34
|
+
// yes, we're going to import it even though it might not be used.
|
|
35
|
+
// the alternatives were all worse without top-level await (iife, runtime errors from something trying to use it before it's initialized)
|
|
36
|
+
const memfs = __importStar(require("memfs"));
|
|
37
|
+
const isWeb = () => process.env.FORCE_MEMFS === 'true' || 'window' in globalThis || 'self' in globalThis;
|
|
38
|
+
const getVirtualFs = (memfsVolume) => {
|
|
39
|
+
if (isWeb()) {
|
|
40
|
+
const memfsInstance = memfs.createFsFromVolume(memfsVolume ?? new memfs.Volume());
|
|
41
|
+
// Start with memfs instance and only override problematic methods
|
|
42
|
+
const webFs = {
|
|
43
|
+
...memfsInstance,
|
|
44
|
+
// Override only the methods that have incompatible signatures
|
|
45
|
+
promises: {
|
|
46
|
+
...memfsInstance.promises,
|
|
47
|
+
writeFile: async (file, data, options) => {
|
|
48
|
+
const finalOptions = typeof options === 'string' ? { encoding: options } : options;
|
|
49
|
+
await memfsInstance.promises.writeFile(file, data, finalOptions);
|
|
50
|
+
},
|
|
51
|
+
readFile: async (path, encoding) => {
|
|
52
|
+
const result = await memfsInstance.promises.readFile(path, encoding);
|
|
53
|
+
return encoding === 'utf8' ? String(result) : Buffer.from(result);
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
readFileSync: (path, encoding) => {
|
|
57
|
+
const result = memfsInstance.readFileSync(path, encoding);
|
|
58
|
+
return encoding === 'utf8' ? String(result) : Buffer.from(result);
|
|
59
|
+
},
|
|
60
|
+
writeFileSync: (file, data, encoding) => {
|
|
61
|
+
memfsInstance.writeFileSync(file, data, { encoding });
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
return webFs;
|
|
65
|
+
}
|
|
66
|
+
return nodeFs;
|
|
67
|
+
};
|
|
68
|
+
exports.getVirtualFs = getVirtualFs;
|
|
69
|
+
const setFs = (providedFs) => {
|
|
70
|
+
exports.fs = providedFs;
|
|
71
|
+
};
|
|
72
|
+
exports.setFs = setFs;
|
|
73
|
+
const resetFs = () => {
|
|
74
|
+
exports.fs = (0, exports.getVirtualFs)();
|
|
75
|
+
};
|
|
76
|
+
exports.resetFs = resetFs;
|
|
77
|
+
// Initialize fs at module load time
|
|
78
|
+
exports.fs = (0, exports.getVirtualFs)();
|
|
79
|
+
//# sourceMappingURL=fs.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type * as nodeFs from 'node:fs';
|
|
2
|
+
import type { IFs as MemFs } from 'memfs';
|
|
3
|
+
type NodeFs = typeof nodeFs;
|
|
4
|
+
type CommonKeys<T, U> = keyof T & keyof U;
|
|
5
|
+
type IntersectionType<T, U> = {
|
|
6
|
+
[K in CommonKeys<T, U>]: T[K] extends (...args: any[]) => any ? T[K] extends U[K] ? T[K] : U[K] extends T[K] ? U[K] : any : T[K] extends U[K] ? T[K] : U[K] extends T[K] ? U[K] : T[K];
|
|
7
|
+
};
|
|
8
|
+
type BaseVirtualFs = IntersectionType<NodeFs, MemFs>;
|
|
9
|
+
export type VirtualFs = Omit<BaseVirtualFs, 'writeFileSync' | 'readFileSync' | 'statSync' | 'promises' | 'mkdtempSync' | 'createWriteStream' | 'mkdirSync'> & {
|
|
10
|
+
promises: Omit<BaseVirtualFs['promises'], 'writeFile' | 'readFile'> & {
|
|
11
|
+
writeFile: (file: string, data: string | Buffer, options?: BufferEncoding | {
|
|
12
|
+
encoding?: BufferEncoding;
|
|
13
|
+
mode?: string | number;
|
|
14
|
+
}) => Promise<void>;
|
|
15
|
+
readFile: {
|
|
16
|
+
(path: string): Promise<Buffer>;
|
|
17
|
+
(path: string, encoding: BufferEncoding): Promise<string>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
readFileSync: {
|
|
21
|
+
(path: string): Buffer;
|
|
22
|
+
(path: string, encoding: BufferEncoding): string;
|
|
23
|
+
};
|
|
24
|
+
writeFileSync: (file: string, data: string | Buffer, encoding?: BufferEncoding) => void;
|
|
25
|
+
/** there are some differences between node:fs and memfs for statSync around bigint stats. Be careful if using those */
|
|
26
|
+
statSync: typeof nodeFs.statSync;
|
|
27
|
+
mkdtempSync: typeof nodeFs.mkdtempSync;
|
|
28
|
+
createWriteStream: typeof nodeFs.createWriteStream;
|
|
29
|
+
mkdirSync: typeof nodeFs.mkdirSync;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
package/lib/fs/types.js
ADDED
package/lib/global.js
CHANGED
|
@@ -30,10 +30,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.Global = exports.Mode = void 0;
|
|
33
|
-
const fs = __importStar(require("node:fs"));
|
|
34
33
|
const os = __importStar(require("node:os"));
|
|
35
34
|
const path = __importStar(require("node:path"));
|
|
36
35
|
const kit_1 = require("@salesforce/kit");
|
|
36
|
+
const fs_1 = require("./fs/fs");
|
|
37
37
|
const sfError_1 = require("./sfError");
|
|
38
38
|
/**
|
|
39
39
|
* Represents an environment mode. Supports `production`, `development`, `demo`, and `test`
|
|
@@ -74,7 +74,7 @@ class Global {
|
|
|
74
74
|
* Whether the code is running in a web browser.
|
|
75
75
|
*/
|
|
76
76
|
static get isWeb() {
|
|
77
|
-
return 'window' in globalThis;
|
|
77
|
+
return 'window' in globalThis || 'self' in globalThis;
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* The full system path to the global sfdx state folder.
|
|
@@ -120,11 +120,11 @@ class Global {
|
|
|
120
120
|
static async createDir(dirPath) {
|
|
121
121
|
const resolvedPath = dirPath ? path.join(Global.SFDX_DIR, dirPath) : Global.SFDX_DIR;
|
|
122
122
|
try {
|
|
123
|
-
if (process.platform === 'win32') {
|
|
124
|
-
await fs.promises.mkdir(resolvedPath, { recursive: true });
|
|
123
|
+
if (process.platform === 'win32' || Global.isWeb) {
|
|
124
|
+
await fs_1.fs.promises.mkdir(resolvedPath, { recursive: true });
|
|
125
125
|
}
|
|
126
126
|
else {
|
|
127
|
-
await fs.promises.mkdir(resolvedPath, { recursive: true, mode: 0o700 });
|
|
127
|
+
await fs_1.fs.promises.mkdir(resolvedPath, { recursive: true, mode: 0o700 });
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
catch (error) {
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { OAuth2Config } from '@jsforce/jsforce-node';
|
|
2
|
+
export { OAuth2Config };
|
|
2
3
|
export { ConfigFile } from './config/configFile';
|
|
3
4
|
export { TTLConfig } from './config/ttlConfig';
|
|
4
5
|
export { envVars, EnvironmentVariable, SUPPORTED_ENV_VARS, EnvVars } from './config/envVars';
|
|
@@ -38,4 +39,6 @@ export { ScratchOrgLifecycleEvent, scratchOrgLifecycleEventName, scratchOrgLifec
|
|
|
38
39
|
export { ScratchOrgCache } from './org/scratchOrgCache';
|
|
39
40
|
export { default as ScratchOrgSettingsGenerator } from './org/scratchOrgSettingsGenerator';
|
|
40
41
|
export * from './util/sfdc';
|
|
42
|
+
/** for use by other libraries that need to support web and node */
|
|
43
|
+
export { fs } from './fs/fs';
|
|
41
44
|
export * from './util/mutex';
|
package/lib/index.js
CHANGED
|
@@ -24,7 +24,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.scratchOrgResume = exports.scratchOrgCreate = exports.lockInit = exports.PermissionSetAssignment = exports.User = exports.REQUIRED_FIELDS = exports.DefaultUserFields = exports.MyDomainResolver = exports.StreamingClient = exports.CometClient = exports.PollingClient = exports.SfError = exports.SchemaValidator = exports.SfProjectJson = exports.SfProject = exports.ORG_CONFIG_ALLOWED_PROPERTIES = exports.OrgConfigProperties = exports.OrgTypes = exports.SandboxEvents = exports.Org = exports.Messages = exports.Logger = exports.LoggerLevel = exports.generateApiName = exports.getJwtAudienceUrl = exports.SfdcUrl = exports.WebOAuthServer = exports.Lifecycle = exports.Global = exports.Mode = exports.SFDX_HTTP_HEADERS = exports.Connection = exports.AuthRemover = exports.AuthInfo = exports.ConfigAggregator = exports.SandboxRequestCache = exports.SF_ALLOWED_PROPERTIES = exports.SFDX_ALLOWED_PROPERTIES = exports.SfConfigProperties = exports.SfdxPropertyKeys = exports.Config = exports.OrgUsersConfig = exports.DeviceOauthService = exports.StateAggregator = exports.EnvVars = exports.SUPPORTED_ENV_VARS = exports.EnvironmentVariable = exports.envVars = exports.TTLConfig = exports.ConfigFile = void 0;
|
|
27
|
-
exports.ScratchOrgSettingsGenerator = exports.ScratchOrgCache = exports.scratchOrgLifecycleStages = exports.scratchOrgLifecycleEventName = void 0;
|
|
27
|
+
exports.fs = exports.ScratchOrgSettingsGenerator = exports.ScratchOrgCache = exports.scratchOrgLifecycleStages = exports.scratchOrgLifecycleEventName = void 0;
|
|
28
28
|
const messages_1 = require("./messages");
|
|
29
29
|
;
|
|
30
30
|
var configFile_1 = require("./config/configFile");
|
|
@@ -118,5 +118,8 @@ var scratchOrgSettingsGenerator_1 = require("./org/scratchOrgSettingsGenerator")
|
|
|
118
118
|
Object.defineProperty(exports, "ScratchOrgSettingsGenerator", { enumerable: true, get: function () { return __importDefault(scratchOrgSettingsGenerator_1).default; } });
|
|
119
119
|
// Utility sub-modules
|
|
120
120
|
__exportStar(require("./util/sfdc"), exports);
|
|
121
|
+
/** for use by other libraries that need to support web and node */
|
|
122
|
+
var fs_1 = require("./fs/fs");
|
|
123
|
+
Object.defineProperty(exports, "fs", { enumerable: true, get: function () { return fs_1.fs; } });
|
|
121
124
|
__exportStar(require("./util/mutex"), exports);
|
|
122
125
|
//# sourceMappingURL=index.js.map
|
package/lib/lifecycleEvents.js
CHANGED
|
@@ -31,9 +31,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.cloneUniqueListeners = exports.Lifecycle = void 0;
|
|
33
33
|
const semver_1 = require("semver");
|
|
34
|
-
// needed for TS to not put everything inside /lib/src
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
36
|
-
// @ts-ignore
|
|
37
34
|
const pjson = __importStar(require("../package.json"));
|
|
38
35
|
const logger_1 = require("./logger/logger");
|
|
39
36
|
/**
|
package/lib/logger/cleanup.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.getOldLogFiles = exports.cleanup = void 0;
|
|
27
4
|
/*
|
|
@@ -30,8 +7,8 @@ exports.getOldLogFiles = exports.cleanup = void 0;
|
|
|
30
7
|
* Licensed under the BSD 3-Clause license.
|
|
31
8
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
32
9
|
*/
|
|
33
|
-
const fs = __importStar(require("node:fs"));
|
|
34
10
|
const node_path_1 = require("node:path");
|
|
11
|
+
const fs_1 = require("../fs/fs");
|
|
35
12
|
const global_1 = require("../global");
|
|
36
13
|
const logger_1 = require("./logger");
|
|
37
14
|
/**
|
|
@@ -55,10 +32,10 @@ const shouldClean = Math.random() * CLEAN_ODDS > CLEAN_ODDS - 1;
|
|
|
55
32
|
const cleanup = async (maxMs = MAX_FILE_AGE_MS, force = false) => {
|
|
56
33
|
if (shouldClean || force) {
|
|
57
34
|
try {
|
|
58
|
-
const filesToConsider = await fs.promises // get the files in that dir
|
|
35
|
+
const filesToConsider = await fs_1.fs.promises // get the files in that dir
|
|
59
36
|
.readdir(global_1.Global.SF_DIR);
|
|
60
37
|
const filesToDelete = (0, exports.getOldLogFiles)(filesToConsider, maxMs);
|
|
61
|
-
await Promise.all(filesToDelete.map((f) => fs.promises.unlink((0, node_path_1.join)(global_1.Global.SF_DIR, f))));
|
|
38
|
+
await Promise.all(filesToDelete.map((f) => fs_1.fs.promises.unlink((0, node_path_1.join)(global_1.Global.SF_DIR, f))));
|
|
62
39
|
}
|
|
63
40
|
catch (e) {
|
|
64
41
|
// we never, ever, ever throw since we're not awaiting this promise, so just log a warning
|
package/lib/logger/logger.d.ts
CHANGED
package/lib/logger/logger.js
CHANGED
|
@@ -132,8 +132,8 @@ class Logger {
|
|
|
132
132
|
const commonOptions = {
|
|
133
133
|
name: options.name ?? Logger.ROOT_NAME,
|
|
134
134
|
base: options.fields ?? {},
|
|
135
|
-
level,
|
|
136
135
|
enabled,
|
|
136
|
+
...(global_1.Global.isWeb ? { browser: { asObject: true } } : {}),
|
|
137
137
|
};
|
|
138
138
|
if (Boolean(options.useMemoryLogger) || global_1.Global.getEnvironmentMode() === global_1.Mode.TEST || !enabled) {
|
|
139
139
|
this.memoryLogger = new memoryLogger_1.MemoryLogger();
|
package/lib/messages.js
CHANGED
|
@@ -30,11 +30,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.Messages = void 0;
|
|
33
|
-
const fs = __importStar(require("node:fs"));
|
|
34
33
|
const os = __importStar(require("node:os"));
|
|
35
34
|
const path = __importStar(require("node:path"));
|
|
36
35
|
const util = __importStar(require("node:util"));
|
|
37
36
|
const node_url_1 = require("node:url");
|
|
37
|
+
// this can use `real fs` because messages are bundled during build by the ts transform
|
|
38
|
+
const fs = __importStar(require("node:fs"));
|
|
38
39
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
39
40
|
const kit_1 = require("@salesforce/kit");
|
|
40
41
|
const logger_1 = require("./logger/logger");
|