@salesforce/core 3.7.7 → 3.8.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/CHANGELOG.md +18 -0
- package/lib/config/config.d.ts +2 -0
- package/lib/config/config.js +9 -4
- package/lib/config/configFile.js +15 -13
- package/lib/config/keychainConfig.js +4 -3
- package/lib/crypto/keyChainImpl.js +10 -8
- package/lib/exported.d.ts +2 -3
- package/lib/exported.js +0 -1
- package/lib/global.js +2 -2
- package/lib/globalInfo/sfdxDataHandler.d.ts +1 -1
- package/lib/globalInfo/sfdxDataHandler.js +5 -4
- package/lib/logger.js +12 -10
- package/lib/messages.d.ts +40 -1
- package/lib/messages.js +52 -9
- package/lib/org/authInfo.d.ts +13 -0
- package/lib/org/authInfo.js +18 -2
- package/lib/org/org.js +3 -3
- package/lib/schema/validator.js +4 -4
- package/lib/sfError.d.ts +0 -5
- package/lib/sfError.js +0 -7
- package/lib/sfProject.js +2 -2
- package/lib/util/internal.d.ts +26 -0
- package/lib/util/internal.js +62 -4
- package/package.json +5 -5
- package/lib/util/fs.d.ts +0 -201
- package/lib/util/fs.js +0 -378
package/lib/org/authInfo.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.AuthInfo = exports.DEFAULT_CONNECTED_APP_INFO = void 0;
|
|
|
10
10
|
const crypto_1 = require("crypto");
|
|
11
11
|
const path_1 = require("path");
|
|
12
12
|
const os = require("os");
|
|
13
|
+
const fs = require("fs");
|
|
13
14
|
const kit_1 = require("@salesforce/kit");
|
|
14
15
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
15
16
|
const jsforce_1 = require("jsforce");
|
|
@@ -19,7 +20,6 @@ const config_1 = require("../config/config");
|
|
|
19
20
|
const configAggregator_1 = require("../config/configAggregator");
|
|
20
21
|
const logger_1 = require("../logger");
|
|
21
22
|
const sfError_1 = require("../sfError");
|
|
22
|
-
const fs_1 = require("../util/fs");
|
|
23
23
|
const sfdc_1 = require("../util/sfdc");
|
|
24
24
|
const globalInfo_1 = require("../globalInfo");
|
|
25
25
|
const messages_1 = require("../messages");
|
|
@@ -398,6 +398,22 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
398
398
|
sfdxAuthUrl += `${(0, ts_types_1.ensure)(decryptedFields.refreshToken, 'undefined refreshToken')}@${instanceUrl}`;
|
|
399
399
|
return sfdxAuthUrl;
|
|
400
400
|
}
|
|
401
|
+
/**
|
|
402
|
+
* Convenience function to handle typical side effects encountered when dealing with an AuthInfo.
|
|
403
|
+
* Given the values supplied in parameter sideEffects, this functions will set auth alias, default auth
|
|
404
|
+
* and default dev hub.
|
|
405
|
+
*
|
|
406
|
+
* @param sideEffects - instance of AuthSideEffects
|
|
407
|
+
*/
|
|
408
|
+
async handleAliasAndDefaultSettings(sideEffects) {
|
|
409
|
+
if (sideEffects.alias)
|
|
410
|
+
await this.setAlias(sideEffects.alias);
|
|
411
|
+
if (sideEffects.setDefault)
|
|
412
|
+
await this.setAsDefault({ org: true });
|
|
413
|
+
if (sideEffects.setDefaultDevHub)
|
|
414
|
+
await this.setAsDefault({ devHub: true });
|
|
415
|
+
await this.save();
|
|
416
|
+
}
|
|
401
417
|
/**
|
|
402
418
|
* Set the target-env (default) or the target-dev-hub to the alias if
|
|
403
419
|
* it exists otherwise to the username. Method will try to set the local
|
|
@@ -584,7 +600,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
584
600
|
}
|
|
585
601
|
// Build OAuth config for a JWT auth flow
|
|
586
602
|
async buildJwtConfig(options) {
|
|
587
|
-
const privateKeyContents = await
|
|
603
|
+
const privateKeyContents = await fs.promises.readFile((0, ts_types_1.ensure)(options.privateKey), 'utf8');
|
|
588
604
|
const { loginUrl = sfdcUrl_1.SfdcUrl.PRODUCTION } = options;
|
|
589
605
|
const url = new sfdcUrl_1.SfdcUrl(loginUrl);
|
|
590
606
|
const createdOrgInstance = (0, ts_types_1.getString)(options, 'createdOrgInstance', '').trim().toLowerCase();
|
package/lib/org/org.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.Org = exports.SandboxEvents = exports.OrgTypes = void 0;
|
|
10
10
|
const path_1 = require("path");
|
|
11
|
+
const fs = require("fs");
|
|
11
12
|
const kit_1 = require("@salesforce/kit");
|
|
12
13
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
13
14
|
const config_1 = require("../config/config");
|
|
@@ -18,7 +19,6 @@ const global_1 = require("../global");
|
|
|
18
19
|
const lifecycleEvents_1 = require("../lifecycleEvents");
|
|
19
20
|
const logger_1 = require("../logger");
|
|
20
21
|
const sfError_1 = require("../sfError");
|
|
21
|
-
const fs_1 = require("../util/fs");
|
|
22
22
|
const sfdc_1 = require("../util/sfdc");
|
|
23
23
|
const webOAuthServer_1 = require("../webOAuthServer");
|
|
24
24
|
const messages_1 = require("../messages");
|
|
@@ -147,7 +147,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
147
147
|
}
|
|
148
148
|
throw err;
|
|
149
149
|
}
|
|
150
|
-
return this.manageDelete(async () => await
|
|
150
|
+
return this.manageDelete(async () => await fs.promises.rmdir(dataPath), dataPath, throwWhenRemoveFails);
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
153
|
* @ignore
|
|
@@ -850,7 +850,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
850
850
|
catch (err) {
|
|
851
851
|
const error = err;
|
|
852
852
|
this.logger.debug('Exception while calling writeSandboxAuthFile %s', err);
|
|
853
|
-
if ((error === null || error === void 0 ? void 0 : error.name) === '
|
|
853
|
+
if ((error === null || error === void 0 ? void 0 : error.name) === 'JwtAuthError' && ((_a = error === null || error === void 0 ? void 0 : error.stack) === null || _a === void 0 ? void 0 : _a.includes("user hasn't approved"))) {
|
|
854
854
|
waitingOnAuth = true;
|
|
855
855
|
}
|
|
856
856
|
else {
|
package/lib/schema/validator.js
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.SchemaValidator = void 0;
|
|
10
10
|
const path = require("path");
|
|
11
|
+
const fs = require("fs");
|
|
11
12
|
const kit_1 = require("@salesforce/kit");
|
|
12
13
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
13
14
|
const validator = require("jsen");
|
|
14
15
|
const sfError_1 = require("../sfError");
|
|
15
|
-
const fs_1 = require("../util/fs");
|
|
16
16
|
/**
|
|
17
17
|
* Loads a JSON schema and performs validations against JSON objects.
|
|
18
18
|
*/
|
|
@@ -33,7 +33,7 @@ class SchemaValidator {
|
|
|
33
33
|
*/
|
|
34
34
|
async load() {
|
|
35
35
|
if (!this.schema) {
|
|
36
|
-
this.schema = await
|
|
36
|
+
this.schema = (0, kit_1.parseJsonMap)(await fs.promises.readFile(this.schemaPath, 'utf8'));
|
|
37
37
|
this.logger.debug(`Schema loaded for ${this.schemaPath}`);
|
|
38
38
|
}
|
|
39
39
|
return this.schema;
|
|
@@ -43,7 +43,7 @@ class SchemaValidator {
|
|
|
43
43
|
*/
|
|
44
44
|
loadSync() {
|
|
45
45
|
if (!this.schema) {
|
|
46
|
-
this.schema =
|
|
46
|
+
this.schema = (0, kit_1.parseJsonMap)(fs.readFileSync(this.schemaPath, 'utf8'));
|
|
47
47
|
this.logger.debug(`Schema loaded for ${this.schemaPath}`);
|
|
48
48
|
}
|
|
49
49
|
return this.schema;
|
|
@@ -125,7 +125,7 @@ class SchemaValidator {
|
|
|
125
125
|
loadExternalSchema(uri) {
|
|
126
126
|
const schemaPath = path.join(this.schemasDir, `${uri}.json`);
|
|
127
127
|
try {
|
|
128
|
-
return
|
|
128
|
+
return (0, kit_1.parseJsonMap)(fs.readFileSync(schemaPath, 'utf8'));
|
|
129
129
|
}
|
|
130
130
|
catch (err) {
|
|
131
131
|
if (err.code === 'ENOENT') {
|
package/lib/sfError.d.ts
CHANGED
|
@@ -68,11 +68,6 @@ export declare class SfError extends NamedError {
|
|
|
68
68
|
* Convert an {@link SfError} state to an object. Returns a plain object representing the state of this error.
|
|
69
69
|
*/
|
|
70
70
|
toObject(): JsonMap;
|
|
71
|
-
/**
|
|
72
|
-
* @deprecated Does nothing. Do not use. This is kept around to support older versions of SfdxCommand.
|
|
73
|
-
* @param commandName
|
|
74
|
-
*/
|
|
75
|
-
setCommandName(): void;
|
|
76
71
|
}
|
|
77
72
|
/**
|
|
78
73
|
* @deprecated use SfError instead
|
package/lib/sfError.js
CHANGED
|
@@ -109,13 +109,6 @@ class SfError extends kit_1.NamedError {
|
|
|
109
109
|
}
|
|
110
110
|
return obj;
|
|
111
111
|
}
|
|
112
|
-
/**
|
|
113
|
-
* @deprecated Does nothing. Do not use. This is kept around to support older versions of SfdxCommand.
|
|
114
|
-
* @param commandName
|
|
115
|
-
*/
|
|
116
|
-
setCommandName() {
|
|
117
|
-
/** Do nothing. */
|
|
118
|
-
}
|
|
119
112
|
}
|
|
120
113
|
exports.SfError = SfError;
|
|
121
114
|
/**
|
package/lib/sfProject.js
CHANGED
|
@@ -8,13 +8,13 @@ exports.SfdxProjectJson = exports.SfdxProject = exports.SfProject = exports.SfPr
|
|
|
8
8
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
9
|
*/
|
|
10
10
|
const path_1 = require("path");
|
|
11
|
+
const fs = require("fs");
|
|
11
12
|
const kit_1 = require("@salesforce/kit");
|
|
12
13
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
13
14
|
const sfdcUrl_1 = require("./util/sfdcUrl");
|
|
14
15
|
const configAggregator_1 = require("./config/configAggregator");
|
|
15
16
|
const configFile_1 = require("./config/configFile");
|
|
16
17
|
const validator_1 = require("./schema/validator");
|
|
17
|
-
const fs_1 = require("./util/fs");
|
|
18
18
|
const internal_1 = require("./util/internal");
|
|
19
19
|
const sfError_1 = require("./sfError");
|
|
20
20
|
const sfdc_1 = require("./util/sfdc");
|
|
@@ -248,7 +248,7 @@ class SfProjectJson extends configFile_1.ConfigFile {
|
|
|
248
248
|
return this.getContents().packageDirectories && this.getContents().packageDirectories.length > 1;
|
|
249
249
|
}
|
|
250
250
|
doesPackageExist(packagePath) {
|
|
251
|
-
return
|
|
251
|
+
return fs.existsSync(packagePath);
|
|
252
252
|
}
|
|
253
253
|
validateKeys() {
|
|
254
254
|
// Verify that the configObject does not have upper case keys; throw if it does. Must be heads down camel case.
|
package/lib/util/internal.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Optional } from '@salesforce/ts-types';
|
|
1
2
|
/**
|
|
2
3
|
* The name of the project config file.
|
|
3
4
|
*
|
|
@@ -30,3 +31,28 @@ export declare function resolveProjectPath(dir?: string): Promise<string>;
|
|
|
30
31
|
* @ignore
|
|
31
32
|
*/
|
|
32
33
|
export declare function resolveProjectPathSync(dir?: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* These methods were moved from the deprecated 'fs' module in v2 and are only used in sfdx-core above
|
|
36
|
+
*
|
|
37
|
+
* They were migrated into the 'traverse' constant in order to stub them in unit tests
|
|
38
|
+
*/
|
|
39
|
+
export declare const traverse: {
|
|
40
|
+
/**
|
|
41
|
+
* Searches a file path in an ascending manner (until reaching the filesystem root) for the first occurrence a
|
|
42
|
+
* specific file name. Resolves with the directory path containing the located file, or `null` if the file was
|
|
43
|
+
* not found.
|
|
44
|
+
*
|
|
45
|
+
* @param dir The directory path in which to start the upward search.
|
|
46
|
+
* @param file The file name to look for.
|
|
47
|
+
*/
|
|
48
|
+
forFile: (dir: string, file: string) => Promise<Optional<string>>;
|
|
49
|
+
/**
|
|
50
|
+
* Searches a file path synchronously in an ascending manner (until reaching the filesystem root) for the first occurrence a
|
|
51
|
+
* specific file name. Resolves with the directory path containing the located file, or `null` if the file was
|
|
52
|
+
* not found.
|
|
53
|
+
*
|
|
54
|
+
* @param dir The directory path in which to start the upward search.
|
|
55
|
+
* @param file The file name to look for.
|
|
56
|
+
*/
|
|
57
|
+
forFileSync: (dir: string, file: string) => Optional<string>;
|
|
58
|
+
};
|
package/lib/util/internal.js
CHANGED
|
@@ -6,9 +6,10 @@
|
|
|
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
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.resolveProjectPathSync = exports.resolveProjectPath = exports.SFDX_PROJECT_JSON = void 0;
|
|
9
|
+
exports.traverse = exports.resolveProjectPathSync = exports.resolveProjectPath = exports.SFDX_PROJECT_JSON = void 0;
|
|
10
|
+
const fs = require("fs");
|
|
11
|
+
const path_1 = require("path");
|
|
10
12
|
const messages_1 = require("../messages");
|
|
11
|
-
const fs_1 = require("./fs");
|
|
12
13
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
13
14
|
const messages = messages_1.Messages.load('@salesforce/core', 'config', ['invalidProjectWorkspace']);
|
|
14
15
|
/**
|
|
@@ -31,7 +32,7 @@ exports.SFDX_PROJECT_JSON = 'sfdx-project.json';
|
|
|
31
32
|
* @ignore
|
|
32
33
|
*/
|
|
33
34
|
async function resolveProjectPath(dir = process.cwd()) {
|
|
34
|
-
const projectPath = await
|
|
35
|
+
const projectPath = await exports.traverse.forFile(dir, exports.SFDX_PROJECT_JSON);
|
|
35
36
|
if (!projectPath) {
|
|
36
37
|
throw messages.createError('invalidProjectWorkspace');
|
|
37
38
|
}
|
|
@@ -51,11 +52,68 @@ exports.resolveProjectPath = resolveProjectPath;
|
|
|
51
52
|
* @ignore
|
|
52
53
|
*/
|
|
53
54
|
function resolveProjectPathSync(dir = process.cwd()) {
|
|
54
|
-
const projectPath =
|
|
55
|
+
const projectPath = exports.traverse.forFileSync(dir, exports.SFDX_PROJECT_JSON);
|
|
55
56
|
if (!projectPath) {
|
|
56
57
|
throw messages.createError('invalidProjectWorkspace');
|
|
57
58
|
}
|
|
58
59
|
return projectPath;
|
|
59
60
|
}
|
|
60
61
|
exports.resolveProjectPathSync = resolveProjectPathSync;
|
|
62
|
+
/**
|
|
63
|
+
* These methods were moved from the deprecated 'fs' module in v2 and are only used in sfdx-core above
|
|
64
|
+
*
|
|
65
|
+
* They were migrated into the 'traverse' constant in order to stub them in unit tests
|
|
66
|
+
*/
|
|
67
|
+
exports.traverse = {
|
|
68
|
+
/**
|
|
69
|
+
* Searches a file path in an ascending manner (until reaching the filesystem root) for the first occurrence a
|
|
70
|
+
* specific file name. Resolves with the directory path containing the located file, or `null` if the file was
|
|
71
|
+
* not found.
|
|
72
|
+
*
|
|
73
|
+
* @param dir The directory path in which to start the upward search.
|
|
74
|
+
* @param file The file name to look for.
|
|
75
|
+
*/
|
|
76
|
+
forFile: async (dir, file) => {
|
|
77
|
+
let foundProjectDir;
|
|
78
|
+
try {
|
|
79
|
+
fs.statSync((0, path_1.join)(dir, file));
|
|
80
|
+
foundProjectDir = dir;
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
if (err && err.code === 'ENOENT') {
|
|
84
|
+
const nextDir = (0, path_1.resolve)(dir, '..');
|
|
85
|
+
if (nextDir !== dir) {
|
|
86
|
+
// stop at root
|
|
87
|
+
foundProjectDir = await exports.traverse.forFile(nextDir, file);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return foundProjectDir;
|
|
92
|
+
},
|
|
93
|
+
/**
|
|
94
|
+
* Searches a file path synchronously in an ascending manner (until reaching the filesystem root) for the first occurrence a
|
|
95
|
+
* specific file name. Resolves with the directory path containing the located file, or `null` if the file was
|
|
96
|
+
* not found.
|
|
97
|
+
*
|
|
98
|
+
* @param dir The directory path in which to start the upward search.
|
|
99
|
+
* @param file The file name to look for.
|
|
100
|
+
*/
|
|
101
|
+
forFileSync: (dir, file) => {
|
|
102
|
+
let foundProjectDir;
|
|
103
|
+
try {
|
|
104
|
+
fs.statSync((0, path_1.join)(dir, file));
|
|
105
|
+
foundProjectDir = dir;
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
if (err && err.code === 'ENOENT') {
|
|
109
|
+
const nextDir = (0, path_1.resolve)(dir, '..');
|
|
110
|
+
if (nextDir !== dir) {
|
|
111
|
+
// stop at root
|
|
112
|
+
foundProjectDir = exports.traverse.forFileSync(nextDir, file);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return foundProjectDir;
|
|
117
|
+
},
|
|
118
|
+
};
|
|
61
119
|
//# sourceMappingURL=internal.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
|
|
5
5
|
"main": "lib/exported",
|
|
6
6
|
"types": "lib/exported.d.ts",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"!lib/**/*.map"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@oclif/core": "^1.
|
|
37
|
+
"@oclif/core": "^1.5.1",
|
|
38
38
|
"@salesforce/bunyan": "^2.0.0",
|
|
39
|
-
"@salesforce/kit": "^1.5.
|
|
39
|
+
"@salesforce/kit": "^1.5.34",
|
|
40
40
|
"@salesforce/schemas": "^1.1.0",
|
|
41
41
|
"@salesforce/ts-types": "^1.5.20",
|
|
42
42
|
"@types/graceful-fs": "^4.1.5",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"ts-retry-promise": "^0.6.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@salesforce/dev-config": "^3.0.
|
|
60
|
-
"@salesforce/dev-scripts": "^2.0.
|
|
59
|
+
"@salesforce/dev-config": "^3.0.1",
|
|
60
|
+
"@salesforce/dev-scripts": "^2.0.1",
|
|
61
61
|
"@salesforce/prettier-config": "^0.0.2",
|
|
62
62
|
"@salesforce/ts-sinon": "^1.3.21",
|
|
63
63
|
"@types/archiver": "^5.3.1",
|
package/lib/util/fs.d.ts
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { AnyJson, JsonMap, Optional } from '@salesforce/ts-types';
|
|
3
|
-
import * as fsLib from 'graceful-fs';
|
|
4
|
-
import * as mkdirpLib from 'mkdirp';
|
|
5
|
-
declare type PerformFunction = (filePath: string, file?: string, dir?: string) => Promise<void>;
|
|
6
|
-
declare type PerformFunctionSync = (filePath: string, file?: string, dir?: string) => void;
|
|
7
|
-
export declare type WriteJsonOptions = {
|
|
8
|
-
/**
|
|
9
|
-
* The number of indent spaces
|
|
10
|
-
*/
|
|
11
|
-
space?: number;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated Use fs/promises instead
|
|
15
|
-
*/
|
|
16
|
-
export declare const fs: typeof fsLib & {
|
|
17
|
-
/**
|
|
18
|
-
* The default file system mode to use when creating directories.
|
|
19
|
-
*/
|
|
20
|
-
DEFAULT_USER_DIR_MODE: string;
|
|
21
|
-
/**
|
|
22
|
-
* The default file system mode to use when creating files.
|
|
23
|
-
*/
|
|
24
|
-
DEFAULT_USER_FILE_MODE: string;
|
|
25
|
-
/**
|
|
26
|
-
* A convenience reference to {@link https://nodejs.org/api/fsLib.html#fs_fs_constants}
|
|
27
|
-
* to reduce the need to import multiple `fs` modules.
|
|
28
|
-
*/
|
|
29
|
-
constants: typeof fsLib.constants;
|
|
30
|
-
/**
|
|
31
|
-
* Promisified version of {@link https://nodejs.org/api/fsLib.html#fs_fs_readfile_path_options_callback|fsLib.readFile}.
|
|
32
|
-
*/
|
|
33
|
-
readFile: typeof fsLib.readFile.__promisify__;
|
|
34
|
-
/**
|
|
35
|
-
* Promisified version of {@link https://nodejs.org/api/fsLib.html#fs_fs_readdir_path_options_callback|fsLib.readdir}.
|
|
36
|
-
*/
|
|
37
|
-
readdir: typeof fsLib.readdir.__promisify__;
|
|
38
|
-
/**
|
|
39
|
-
* Promisified version of {@link https://nodejs.org/api/fsLib.html#fs_fs_writefile_file_data_options_callback|fsLib.writeFile}.
|
|
40
|
-
*/
|
|
41
|
-
writeFile: typeof fsLib.writeFile.__promisify__;
|
|
42
|
-
/**
|
|
43
|
-
* Promisified version of {@link https://nodejs.org/api/fsLib.html#fs_fs_access_path_mode_callback|fsLib.access}.
|
|
44
|
-
*/
|
|
45
|
-
access: typeof fsLib.access.__promisify__;
|
|
46
|
-
/**
|
|
47
|
-
* Promisified version of {@link https://nodejs.org/api/fsLib.html#fs_fs_open_path_flags_mode_callback|fsLib.open}.
|
|
48
|
-
*/
|
|
49
|
-
open: typeof fsLib.open.__promisify__;
|
|
50
|
-
/**
|
|
51
|
-
* Promisified version of {@link https://nodejs.org/api/fsLib.html#fs_fs_unlink_path_callback|fsLib.unlink}.
|
|
52
|
-
*/
|
|
53
|
-
unlink: typeof fsLib.unlink.__promisify__;
|
|
54
|
-
/**
|
|
55
|
-
* Promisified version of {@link https://nodejs.org/api/fsLib.html#fs_fs_readdir_path_options_callback|fsLib.rmdir}.
|
|
56
|
-
*/
|
|
57
|
-
rmdir: typeof fsLib.rmdir.__promisify__;
|
|
58
|
-
/**
|
|
59
|
-
* Promisified version of {@link https://nodejs.org/api/fsLib.html#fs_fs_fstat_fd_callback|fsLib.stat}.
|
|
60
|
-
*/
|
|
61
|
-
stat: typeof fsLib.stat.__promisify__;
|
|
62
|
-
/**
|
|
63
|
-
* Promisified version of {@link https://npmjs.com/package/mkdirp|mkdirp}.
|
|
64
|
-
*/
|
|
65
|
-
mkdirp: (folderPath: string, mode?: string | object | undefined) => Promise<string | undefined>;
|
|
66
|
-
mkdirpSync: typeof mkdirpLib.sync;
|
|
67
|
-
/**
|
|
68
|
-
* Deletes a folder recursively, removing all descending files and folders.
|
|
69
|
-
*
|
|
70
|
-
* **Throws** *PathIsNullOrUndefined* The path is not defined.
|
|
71
|
-
* **Throws** *DirMissingOrNoAccess* The folder or any sub-folder is missing or has no access.
|
|
72
|
-
*
|
|
73
|
-
* @param {string} dirPath The path to remove.
|
|
74
|
-
*/
|
|
75
|
-
remove: (dirPath: string) => Promise<void>;
|
|
76
|
-
/**
|
|
77
|
-
* Deletes a folder recursively, removing all descending files and folders.
|
|
78
|
-
*
|
|
79
|
-
* NOTE: It is recommended to call the asynchronous `remove` when possible as it will remove all files in parallel rather than serially.
|
|
80
|
-
*
|
|
81
|
-
* **Throws** *PathIsNullOrUndefined* The path is not defined.
|
|
82
|
-
* **Throws** *DirMissingOrNoAccess* The folder or any sub-folder is missing or has no access.
|
|
83
|
-
*
|
|
84
|
-
* @param {string} dirPath The path to remove.
|
|
85
|
-
*/
|
|
86
|
-
removeSync: (dirPath: string) => void;
|
|
87
|
-
/**
|
|
88
|
-
* Searches a file path in an ascending manner (until reaching the filesystem root) for the first occurrence a
|
|
89
|
-
* specific file name. Resolves with the directory path containing the located file, or `null` if the file was
|
|
90
|
-
* not found.
|
|
91
|
-
*
|
|
92
|
-
* @param dir The directory path in which to start the upward search.
|
|
93
|
-
* @param file The file name to look for.
|
|
94
|
-
*/
|
|
95
|
-
traverseForFile: (dir: string, file: string) => Promise<Optional<string>>;
|
|
96
|
-
/**
|
|
97
|
-
* Searches a file path synchronously in an ascending manner (until reaching the filesystem root) for the first occurrence a
|
|
98
|
-
* specific file name. Resolves with the directory path containing the located file, or `null` if the file was
|
|
99
|
-
* not found.
|
|
100
|
-
*
|
|
101
|
-
* @param dir The directory path in which to start the upward search.
|
|
102
|
-
* @param file The file name to look for.
|
|
103
|
-
*/
|
|
104
|
-
traverseForFileSync: (dir: string, file: string) => Optional<string>;
|
|
105
|
-
/**
|
|
106
|
-
* Read a file and convert it to JSON. Returns the contents of the file as a JSON object
|
|
107
|
-
*
|
|
108
|
-
* @param jsonPath The path of the file.
|
|
109
|
-
* @param throwOnEmpty Whether to throw an error if the JSON file is empty.
|
|
110
|
-
*/
|
|
111
|
-
readJson: (jsonPath: string, throwOnEmpty?: boolean | undefined) => Promise<AnyJson>;
|
|
112
|
-
/**
|
|
113
|
-
* Read a file and convert it to JSON. Returns the contents of the file as a JSON object
|
|
114
|
-
*
|
|
115
|
-
* @param jsonPath The path of the file.
|
|
116
|
-
* @param throwOnEmpty Whether to throw an error if the JSON file is empty.
|
|
117
|
-
*/
|
|
118
|
-
readJsonSync: (jsonPath: string, throwOnEmpty?: boolean | undefined) => AnyJson;
|
|
119
|
-
/**
|
|
120
|
-
* Read a file and convert it to JSON, throwing an error if the parsed contents are not a `JsonMap`.
|
|
121
|
-
*
|
|
122
|
-
* @param jsonPath The path of the file.
|
|
123
|
-
* @param throwOnEmpty Whether to throw an error if the JSON file is empty.
|
|
124
|
-
*/
|
|
125
|
-
readJsonMap: <T extends JsonMap = JsonMap>(jsonPath: string, throwOnEmpty?: boolean | undefined) => Promise<T>;
|
|
126
|
-
/**
|
|
127
|
-
* Read a file and convert it to JSON, throwing an error if the parsed contents are not a `JsonMap`.
|
|
128
|
-
*
|
|
129
|
-
* @param jsonPath The path of the file.
|
|
130
|
-
* @param throwOnEmpty Whether to throw an error if the JSON file is empty.
|
|
131
|
-
*/
|
|
132
|
-
readJsonMapSync: <T_1 extends JsonMap = JsonMap>(jsonPath: string, throwOnEmpty?: boolean | undefined) => T_1;
|
|
133
|
-
/**
|
|
134
|
-
* Convert a JSON-compatible object to a `string` and write it to a file.
|
|
135
|
-
*
|
|
136
|
-
* @param jsonPath The path of the file to write.
|
|
137
|
-
* @param data The JSON object to write.
|
|
138
|
-
*/
|
|
139
|
-
writeJson: (jsonPath: string, data: AnyJson, options?: WriteJsonOptions) => Promise<void>;
|
|
140
|
-
/**
|
|
141
|
-
* Convert a JSON-compatible object to a `string` and write it to a file.
|
|
142
|
-
*
|
|
143
|
-
* @param jsonPath The path of the file to write.
|
|
144
|
-
* @param data The JSON object to write.
|
|
145
|
-
*/
|
|
146
|
-
writeJsonSync: (jsonPath: string, data: AnyJson, options?: WriteJsonOptions) => void;
|
|
147
|
-
/**
|
|
148
|
-
* Checks if a file path exists
|
|
149
|
-
*
|
|
150
|
-
* @param filePath the file path to check the existence of
|
|
151
|
-
*/
|
|
152
|
-
fileExists: (filePath: string) => Promise<boolean>;
|
|
153
|
-
/**
|
|
154
|
-
* Checks if a file path exists
|
|
155
|
-
*
|
|
156
|
-
* @param filePath the file path to check the existence of
|
|
157
|
-
*/
|
|
158
|
-
fileExistsSync: (filePath: string) => boolean;
|
|
159
|
-
/**
|
|
160
|
-
* Recursively act on all files or directories in a directory
|
|
161
|
-
*
|
|
162
|
-
* @param dir path to directory
|
|
163
|
-
* @param perform function to be run on contents of dir
|
|
164
|
-
* @param onType optional parameter to specify type to actOn
|
|
165
|
-
* @returns void
|
|
166
|
-
*/
|
|
167
|
-
actOn: (dir: string, perform: PerformFunction, onType?: 'file' | 'dir' | 'all') => Promise<void>;
|
|
168
|
-
/**
|
|
169
|
-
* Recursively act on all files or directories in a directory
|
|
170
|
-
*
|
|
171
|
-
* @param dir path to directory
|
|
172
|
-
* @param perform function to be run on contents of dir
|
|
173
|
-
* @param onType optional parameter to specify type to actOn
|
|
174
|
-
* @returns void
|
|
175
|
-
*/
|
|
176
|
-
actOnSync: (dir: string, perform: PerformFunctionSync, onType?: 'file' | 'dir' | 'all') => void;
|
|
177
|
-
/**
|
|
178
|
-
* Checks if files are the same
|
|
179
|
-
*
|
|
180
|
-
* @param file1Path the first file path to check
|
|
181
|
-
* @param file2Path the second file path to check
|
|
182
|
-
* @returns boolean
|
|
183
|
-
*/
|
|
184
|
-
areFilesEqual: (file1Path: string, file2Path: string) => Promise<boolean>;
|
|
185
|
-
/**
|
|
186
|
-
* Checks if files are the same
|
|
187
|
-
*
|
|
188
|
-
* @param file1Path the first file path to check
|
|
189
|
-
* @param file2Path the second file path to check
|
|
190
|
-
* @returns boolean
|
|
191
|
-
*/
|
|
192
|
-
areFilesEqualSync: (file1Path: string, file2Path: string) => boolean;
|
|
193
|
-
/**
|
|
194
|
-
* Creates a hash for the string that's passed in
|
|
195
|
-
*
|
|
196
|
-
* @param contents The string passed into the function
|
|
197
|
-
* @returns string
|
|
198
|
-
*/
|
|
199
|
-
getContentHash(contents: string | Buffer): string;
|
|
200
|
-
};
|
|
201
|
-
export {};
|