@salesforce/core 3.7.5 → 3.7.8
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 +219 -0
- package/README.md +4 -4
- package/lib/config/config.d.ts +7 -5
- package/lib/config/config.js +14 -9
- package/lib/config/configAggregator.d.ts +2 -2
- package/lib/config/configAggregator.js +2 -2
- package/lib/config/configFile.d.ts +2 -2
- package/lib/config/configFile.js +22 -20
- package/lib/config/configStore.js +7 -6
- package/lib/config/keychainConfig.js +4 -3
- package/lib/crypto/keyChainImpl.js +12 -11
- package/lib/deviceOauthService.js +2 -2
- package/lib/exported.d.ts +6 -5
- package/lib/exported.js +11 -7
- package/lib/global.js +2 -2
- package/lib/globalInfo/accessors/aliasAccessor.js +2 -2
- package/lib/globalInfo/sfdxDataHandler.d.ts +1 -1
- package/lib/globalInfo/sfdxDataHandler.js +5 -4
- package/lib/lifecycleEvents.js +1 -1
- package/lib/logger.d.ts +3 -3
- package/lib/logger.js +20 -19
- package/lib/messages.d.ts +42 -3
- package/lib/messages.js +55 -12
- package/lib/org/authInfo.d.ts +1 -1
- package/lib/org/authInfo.js +8 -9
- package/lib/org/authRemover.d.ts +2 -2
- package/lib/org/authRemover.js +2 -2
- package/lib/org/connection.d.ts +7 -2
- package/lib/org/connection.js +17 -4
- package/lib/org/org.d.ts +16 -6
- package/lib/org/org.js +54 -51
- package/lib/org/permissionSetAssignment.js +2 -2
- package/lib/org/scratchOrgCreate.d.ts +43 -0
- package/lib/org/scratchOrgCreate.js +142 -0
- package/lib/org/scratchOrgErrorCodes.d.ts +4 -0
- package/lib/org/scratchOrgErrorCodes.js +62 -0
- package/lib/org/scratchOrgFeatureDeprecation.d.ts +26 -0
- package/lib/org/scratchOrgFeatureDeprecation.js +110 -0
- package/lib/org/scratchOrgInfoApi.d.ts +94 -0
- package/lib/org/scratchOrgInfoApi.js +350 -0
- package/lib/org/scratchOrgInfoGenerator.d.ts +63 -0
- package/lib/org/scratchOrgInfoGenerator.js +223 -0
- package/lib/org/scratchOrgSettingsGenerator.d.ts +56 -0
- package/lib/org/scratchOrgSettingsGenerator.js +210 -0
- package/lib/org/user.js +8 -7
- package/lib/schema/printer.js +2 -2
- package/lib/schema/validator.d.ts +4 -4
- package/lib/schema/validator.js +13 -13
- package/lib/{sfdxError.d.ts → sfError.d.ts} +14 -14
- package/lib/{sfdxError.js → sfError.js} +20 -21
- package/lib/{sfdxProject.d.ts → sfProject.d.ts} +37 -27
- package/lib/{sfdxProject.js → sfProject.js} +77 -65
- package/lib/status/pollingClient.d.ts +2 -2
- package/lib/status/pollingClient.js +10 -4
- package/lib/status/streamingClient.d.ts +1 -1
- package/lib/status/streamingClient.js +6 -6
- package/lib/testSetup.d.ts +4 -4
- package/lib/testSetup.js +8 -8
- package/lib/util/internal.d.ts +28 -2
- package/lib/util/internal.js +64 -6
- package/lib/util/jsonXmlTools.d.ts +14 -0
- package/lib/util/jsonXmlTools.js +41 -0
- package/lib/util/mapKeys.d.ts +14 -0
- package/lib/util/mapKeys.js +48 -0
- package/lib/util/sfdcUrl.d.ts +2 -2
- package/lib/util/sfdcUrl.js +2 -2
- package/lib/util/zipWriter.d.ts +14 -0
- package/lib/util/zipWriter.js +68 -0
- package/lib/webOAuthServer.js +11 -11
- package/messages/org.md +4 -0
- package/messages/scratchOrgCreate.md +27 -0
- package/messages/scratchOrgErrorCodes.md +99 -0
- package/messages/scratchOrgFeatureDeprecation.md +11 -0
- package/messages/scratchOrgInfoApi.md +11 -0
- package/messages/scratchOrgInfoGenerator.md +19 -0
- package/messages/user.md +4 -0
- package/package.json +4 -1
- package/lib/util/fs.d.ts +0 -201
- package/lib/util/fs.js +0 -378
|
@@ -54,7 +54,7 @@ export declare type ProjectJson = ConfigContents & {
|
|
|
54
54
|
* be in a top level property that represents your project or plugin.
|
|
55
55
|
*
|
|
56
56
|
* ```
|
|
57
|
-
* const project = await
|
|
57
|
+
* const project = await SfProject.resolve();
|
|
58
58
|
* const projectJson = await project.resolveProjectConfig();
|
|
59
59
|
* const myPluginProperties = projectJson.get('myplugin') || {};
|
|
60
60
|
* myPluginProperties.myprop = 'someValue';
|
|
@@ -64,7 +64,7 @@ export declare type ProjectJson = ConfigContents & {
|
|
|
64
64
|
*
|
|
65
65
|
* **See** [force:project:create](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_create_new.htm)
|
|
66
66
|
*/
|
|
67
|
-
export declare class
|
|
67
|
+
export declare class SfProjectJson extends ConfigFile {
|
|
68
68
|
static BLOCKLIST: string[];
|
|
69
69
|
static getFileName(): string;
|
|
70
70
|
static getDefaultOptions(isGlobal?: boolean): ConfigFile.Options;
|
|
@@ -115,7 +115,7 @@ export declare class SfdxProjectJson extends ConfigFile {
|
|
|
115
115
|
*/
|
|
116
116
|
getUniquePackageDirectories(): NamedPackageDir[];
|
|
117
117
|
/**
|
|
118
|
-
* Get a list of the unique package names from within sfdx-project.json. Use {@link
|
|
118
|
+
* Get a list of the unique package names from within sfdx-project.json. Use {@link SfProject.getUniquePackageDirectories}
|
|
119
119
|
* for data other than the names.
|
|
120
120
|
*/
|
|
121
121
|
getUniquePackageNames(): string[];
|
|
@@ -131,51 +131,51 @@ export declare class SfdxProjectJson extends ConfigFile {
|
|
|
131
131
|
private validateKeys;
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
134
|
-
* Represents an SFDX project directory. This directory contains a {@link
|
|
134
|
+
* Represents an SFDX project directory. This directory contains a {@link SfProjectJson} config file as well as
|
|
135
135
|
* a hidden .sfdx folder that contains all the other local project config files.
|
|
136
136
|
*
|
|
137
137
|
* ```
|
|
138
|
-
* const project = await
|
|
138
|
+
* const project = await SfProject.resolve();
|
|
139
139
|
* const projectJson = await project.resolveProjectConfig();
|
|
140
140
|
* console.log(projectJson.sfdcLoginUrl);
|
|
141
141
|
* ```
|
|
142
142
|
*/
|
|
143
|
-
export declare class
|
|
143
|
+
export declare class SfProject {
|
|
144
144
|
private path;
|
|
145
145
|
private static instances;
|
|
146
146
|
private projectConfig;
|
|
147
|
-
private
|
|
148
|
-
private
|
|
147
|
+
private sfProjectJson;
|
|
148
|
+
private sfProjectJsonGlobal;
|
|
149
149
|
private packageDirectories?;
|
|
150
150
|
private activePackage;
|
|
151
151
|
/**
|
|
152
|
-
* Do not directly construct instances of this class -- use {@link
|
|
152
|
+
* Do not directly construct instances of this class -- use {@link SfProject.resolve} instead.
|
|
153
153
|
*
|
|
154
154
|
* @ignore
|
|
155
155
|
*/
|
|
156
|
-
|
|
156
|
+
protected constructor(path: string);
|
|
157
157
|
/**
|
|
158
158
|
* Get a Project from a given path or from the working directory.
|
|
159
159
|
*
|
|
160
160
|
* @param path The path of the project.
|
|
161
161
|
*
|
|
162
|
-
* **Throws** *{@link
|
|
162
|
+
* **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
|
|
163
163
|
*/
|
|
164
|
-
static resolve(path?: string): Promise<
|
|
164
|
+
static resolve(path?: string): Promise<SfProject>;
|
|
165
165
|
/**
|
|
166
166
|
* Get a Project from a given path or from the working directory.
|
|
167
167
|
*
|
|
168
168
|
* @param path The path of the project.
|
|
169
169
|
*
|
|
170
|
-
* **Throws** *{@link
|
|
170
|
+
* **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
|
|
171
171
|
*/
|
|
172
|
-
static getInstance(path?: string):
|
|
172
|
+
static getInstance(path?: string): SfProject;
|
|
173
173
|
/**
|
|
174
174
|
* Performs an upward directory search for an sfdx project file. Returns the absolute path to the project.
|
|
175
175
|
*
|
|
176
176
|
* @param dir The directory path to start traversing from.
|
|
177
177
|
*
|
|
178
|
-
* **Throws** *{@link
|
|
178
|
+
* **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
|
|
179
179
|
*
|
|
180
180
|
* **See** {@link traverseForFile}
|
|
181
181
|
*
|
|
@@ -187,7 +187,7 @@ export declare class SfdxProject {
|
|
|
187
187
|
*
|
|
188
188
|
* @param dir The directory path to start traversing from.
|
|
189
189
|
*
|
|
190
|
-
* **Throws** *{@link
|
|
190
|
+
* **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
|
|
191
191
|
*
|
|
192
192
|
* **See** {@link traverseForFileSync}
|
|
193
193
|
*
|
|
@@ -202,24 +202,24 @@ export declare class SfdxProject {
|
|
|
202
202
|
* Get the sfdx-project.json config. The global sfdx-project.json is used for user defaults
|
|
203
203
|
* that are not checked in to the project specific file.
|
|
204
204
|
*
|
|
205
|
-
* *Note:* When reading values from {@link
|
|
206
|
-
* {@link
|
|
205
|
+
* *Note:* When reading values from {@link SfProjectJson}, it is recommended to use
|
|
206
|
+
* {@link SfProject.resolveProjectConfig} instead.
|
|
207
207
|
*
|
|
208
208
|
* @param isGlobal True to get the global project file, otherwise the local project config.
|
|
209
209
|
*/
|
|
210
|
-
|
|
210
|
+
retrieveSfProjectJson(isGlobal?: boolean): Promise<SfProjectJson>;
|
|
211
211
|
/**
|
|
212
212
|
* Get the sfdx-project.json config. The global sfdx-project.json is used for user defaults
|
|
213
213
|
* that are not checked in to the project specific file.
|
|
214
214
|
*
|
|
215
|
-
* *Note:* When reading values from {@link
|
|
216
|
-
* {@link
|
|
215
|
+
* *Note:* When reading values from {@link SfProjectJson}, it is recommended to use
|
|
216
|
+
* {@link SfProject.resolveProjectConfig} instead.
|
|
217
217
|
*
|
|
218
|
-
* This is the sync method of {@link
|
|
218
|
+
* This is the sync method of {@link SfProject.resolveSfProjectJson}
|
|
219
219
|
*
|
|
220
220
|
* @param isGlobal True to get the global project file, otherwise the local project config.
|
|
221
221
|
*/
|
|
222
|
-
|
|
222
|
+
getSfProjectJson(isGlobal?: boolean): SfProjectJson;
|
|
223
223
|
/**
|
|
224
224
|
* Returns a read-only list of `packageDirectories` within sfdx-project.json, first reading
|
|
225
225
|
* and validating the file if necessary. i.e. modifying this array will not affect the
|
|
@@ -238,7 +238,7 @@ export declare class SfdxProject {
|
|
|
238
238
|
*/
|
|
239
239
|
getUniquePackageDirectories(): NamedPackageDir[];
|
|
240
240
|
/**
|
|
241
|
-
* Get a list of the unique package names from within sfdx-project.json. Use {@link
|
|
241
|
+
* Get a list of the unique package names from within sfdx-project.json. Use {@link SfProject.getUniquePackageDirectories}
|
|
242
242
|
* for data other than the names.
|
|
243
243
|
*/
|
|
244
244
|
getUniquePackageNames(): string[];
|
|
@@ -293,11 +293,11 @@ export declare class SfdxProject {
|
|
|
293
293
|
*/
|
|
294
294
|
getDefaultPackage(): NamedPackageDir;
|
|
295
295
|
/**
|
|
296
|
-
* The project config is resolved from local and global {@link
|
|
296
|
+
* The project config is resolved from local and global {@link SfProjectJson},
|
|
297
297
|
* {@link ConfigAggregator}, and a set of defaults. It is recommended to use
|
|
298
|
-
* this when reading values from
|
|
298
|
+
* this when reading values from SfProjectJson.
|
|
299
299
|
*
|
|
300
|
-
* The global {@link
|
|
300
|
+
* The global {@link SfProjectJson} is used to allow the user to provide default values they
|
|
301
301
|
* may not want checked into their project's source.
|
|
302
302
|
*
|
|
303
303
|
* @returns A resolved config object that contains a bunch of different
|
|
@@ -305,3 +305,13 @@ export declare class SfdxProject {
|
|
|
305
305
|
*/
|
|
306
306
|
resolveProjectConfig(): Promise<JsonMap>;
|
|
307
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* @deprecated use SfProject instead
|
|
310
|
+
*/
|
|
311
|
+
export declare class SfdxProject extends SfProject {
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* @deprecated use SfProjectJson instead
|
|
315
|
+
*/
|
|
316
|
+
export declare class SfdxProjectJson extends SfProjectJson {
|
|
317
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SfdxProject = exports.
|
|
3
|
+
exports.SfdxProjectJson = exports.SfdxProject = exports.SfProject = exports.SfProjectJson = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
6
6
|
* All rights reserved.
|
|
@@ -8,15 +8,15 @@ exports.SfdxProject = exports.SfdxProjectJson = void 0;
|
|
|
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
|
-
const
|
|
19
|
+
const sfError_1 = require("./sfError");
|
|
20
20
|
const sfdc_1 = require("./util/sfdc");
|
|
21
21
|
const messages_1 = require("./messages");
|
|
22
22
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
@@ -36,7 +36,7 @@ const coreMessages = messages_1.Messages.load('@salesforce/core', 'core', ['inva
|
|
|
36
36
|
* be in a top level property that represents your project or plugin.
|
|
37
37
|
*
|
|
38
38
|
* ```
|
|
39
|
-
* const project = await
|
|
39
|
+
* const project = await SfProject.resolve();
|
|
40
40
|
* const projectJson = await project.resolveProjectConfig();
|
|
41
41
|
* const myPluginProperties = projectJson.get('myplugin') || {};
|
|
42
42
|
* myPluginProperties.myprop = 'someValue';
|
|
@@ -46,12 +46,12 @@ const coreMessages = messages_1.Messages.load('@salesforce/core', 'core', ['inva
|
|
|
46
46
|
*
|
|
47
47
|
* **See** [force:project:create](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_create_new.htm)
|
|
48
48
|
*/
|
|
49
|
-
class
|
|
49
|
+
class SfProjectJson extends configFile_1.ConfigFile {
|
|
50
50
|
static getFileName() {
|
|
51
51
|
return internal_1.SFDX_PROJECT_JSON;
|
|
52
52
|
}
|
|
53
53
|
static getDefaultOptions(isGlobal = false) {
|
|
54
|
-
const options = configFile_1.ConfigFile.getDefaultOptions(isGlobal,
|
|
54
|
+
const options = configFile_1.ConfigFile.getDefaultOptions(isGlobal, SfProjectJson.getFileName());
|
|
55
55
|
options.isState = false;
|
|
56
56
|
return options;
|
|
57
57
|
}
|
|
@@ -229,7 +229,7 @@ class SfdxProjectJson extends configFile_1.ConfigFile {
|
|
|
229
229
|
return uniqueValues;
|
|
230
230
|
}
|
|
231
231
|
/**
|
|
232
|
-
* Get a list of the unique package names from within sfdx-project.json. Use {@link
|
|
232
|
+
* Get a list of the unique package names from within sfdx-project.json. Use {@link SfProject.getUniquePackageDirectories}
|
|
233
233
|
* for data other than the names.
|
|
234
234
|
*/
|
|
235
235
|
getUniquePackageNames() {
|
|
@@ -248,31 +248,31 @@ class SfdxProjectJson 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.
|
|
255
|
-
const upperCaseKey = sfdc_1.sfdc.findUpperCaseKeys(this.toObject(),
|
|
255
|
+
const upperCaseKey = sfdc_1.sfdc.findUpperCaseKeys(this.toObject(), SfProjectJson.BLOCKLIST);
|
|
256
256
|
if (upperCaseKey) {
|
|
257
257
|
throw coreMessages.createError('invalidJsonCasing', [upperCaseKey, this.getPath()]);
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
|
-
exports.
|
|
262
|
-
|
|
261
|
+
exports.SfProjectJson = SfProjectJson;
|
|
262
|
+
SfProjectJson.BLOCKLIST = ['packageAliases'];
|
|
263
263
|
/**
|
|
264
|
-
* Represents an SFDX project directory. This directory contains a {@link
|
|
264
|
+
* Represents an SFDX project directory. This directory contains a {@link SfProjectJson} config file as well as
|
|
265
265
|
* a hidden .sfdx folder that contains all the other local project config files.
|
|
266
266
|
*
|
|
267
267
|
* ```
|
|
268
|
-
* const project = await
|
|
268
|
+
* const project = await SfProject.resolve();
|
|
269
269
|
* const projectJson = await project.resolveProjectConfig();
|
|
270
270
|
* console.log(projectJson.sfdcLoginUrl);
|
|
271
271
|
* ```
|
|
272
272
|
*/
|
|
273
|
-
class
|
|
273
|
+
class SfProject {
|
|
274
274
|
/**
|
|
275
|
-
* Do not directly construct instances of this class -- use {@link
|
|
275
|
+
* Do not directly construct instances of this class -- use {@link SfProject.resolve} instead.
|
|
276
276
|
*
|
|
277
277
|
* @ignore
|
|
278
278
|
*/
|
|
@@ -284,38 +284,38 @@ class SfdxProject {
|
|
|
284
284
|
*
|
|
285
285
|
* @param path The path of the project.
|
|
286
286
|
*
|
|
287
|
-
* **Throws** *{@link
|
|
287
|
+
* **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
|
|
288
288
|
*/
|
|
289
289
|
static async resolve(path) {
|
|
290
290
|
path = await this.resolveProjectPath(path || process.cwd());
|
|
291
|
-
if (!
|
|
292
|
-
const project = new
|
|
293
|
-
|
|
291
|
+
if (!SfProject.instances.has(path)) {
|
|
292
|
+
const project = new SfProject(path);
|
|
293
|
+
SfProject.instances.set(path, project);
|
|
294
294
|
}
|
|
295
|
-
return (0, ts_types_1.ensure)(
|
|
295
|
+
return (0, ts_types_1.ensure)(SfProject.instances.get(path));
|
|
296
296
|
}
|
|
297
297
|
/**
|
|
298
298
|
* Get a Project from a given path or from the working directory.
|
|
299
299
|
*
|
|
300
300
|
* @param path The path of the project.
|
|
301
301
|
*
|
|
302
|
-
* **Throws** *{@link
|
|
302
|
+
* **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
|
|
303
303
|
*/
|
|
304
304
|
static getInstance(path) {
|
|
305
305
|
// Store instance based on the path of the actual project.
|
|
306
306
|
path = this.resolveProjectPathSync(path || process.cwd());
|
|
307
|
-
if (!
|
|
308
|
-
const project = new
|
|
309
|
-
|
|
307
|
+
if (!SfProject.instances.has(path)) {
|
|
308
|
+
const project = new SfProject(path);
|
|
309
|
+
SfProject.instances.set(path, project);
|
|
310
310
|
}
|
|
311
|
-
return (0, ts_types_1.ensure)(
|
|
311
|
+
return (0, ts_types_1.ensure)(SfProject.instances.get(path));
|
|
312
312
|
}
|
|
313
313
|
/**
|
|
314
314
|
* Performs an upward directory search for an sfdx project file. Returns the absolute path to the project.
|
|
315
315
|
*
|
|
316
316
|
* @param dir The directory path to start traversing from.
|
|
317
317
|
*
|
|
318
|
-
* **Throws** *{@link
|
|
318
|
+
* **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
|
|
319
319
|
*
|
|
320
320
|
* **See** {@link traverseForFile}
|
|
321
321
|
*
|
|
@@ -329,7 +329,7 @@ class SfdxProject {
|
|
|
329
329
|
*
|
|
330
330
|
* @param dir The directory path to start traversing from.
|
|
331
331
|
*
|
|
332
|
-
* **Throws** *{@link
|
|
332
|
+
* **Throws** *{@link SfError}{ name: 'InvalidProjectWorkspaceError' }* If the current folder is not located in a workspace.
|
|
333
333
|
*
|
|
334
334
|
* **See** {@link traverseForFileSync}
|
|
335
335
|
*
|
|
@@ -348,54 +348,54 @@ class SfdxProject {
|
|
|
348
348
|
* Get the sfdx-project.json config. The global sfdx-project.json is used for user defaults
|
|
349
349
|
* that are not checked in to the project specific file.
|
|
350
350
|
*
|
|
351
|
-
* *Note:* When reading values from {@link
|
|
352
|
-
* {@link
|
|
351
|
+
* *Note:* When reading values from {@link SfProjectJson}, it is recommended to use
|
|
352
|
+
* {@link SfProject.resolveProjectConfig} instead.
|
|
353
353
|
*
|
|
354
354
|
* @param isGlobal True to get the global project file, otherwise the local project config.
|
|
355
355
|
*/
|
|
356
|
-
async
|
|
357
|
-
const options =
|
|
356
|
+
async retrieveSfProjectJson(isGlobal = false) {
|
|
357
|
+
const options = SfProjectJson.getDefaultOptions(isGlobal);
|
|
358
358
|
if (isGlobal) {
|
|
359
|
-
if (!this.
|
|
360
|
-
this.
|
|
359
|
+
if (!this.sfProjectJsonGlobal) {
|
|
360
|
+
this.sfProjectJsonGlobal = await SfProjectJson.create(options);
|
|
361
361
|
}
|
|
362
|
-
return this.
|
|
362
|
+
return this.sfProjectJsonGlobal;
|
|
363
363
|
}
|
|
364
364
|
else {
|
|
365
365
|
options.rootFolder = this.getPath();
|
|
366
|
-
if (!this.
|
|
367
|
-
this.
|
|
366
|
+
if (!this.sfProjectJson) {
|
|
367
|
+
this.sfProjectJson = await SfProjectJson.create(options);
|
|
368
368
|
}
|
|
369
|
-
return this.
|
|
369
|
+
return this.sfProjectJson;
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
372
|
/**
|
|
373
373
|
* Get the sfdx-project.json config. The global sfdx-project.json is used for user defaults
|
|
374
374
|
* that are not checked in to the project specific file.
|
|
375
375
|
*
|
|
376
|
-
* *Note:* When reading values from {@link
|
|
377
|
-
* {@link
|
|
376
|
+
* *Note:* When reading values from {@link SfProjectJson}, it is recommended to use
|
|
377
|
+
* {@link SfProject.resolveProjectConfig} instead.
|
|
378
378
|
*
|
|
379
|
-
* This is the sync method of {@link
|
|
379
|
+
* This is the sync method of {@link SfProject.resolveSfProjectJson}
|
|
380
380
|
*
|
|
381
381
|
* @param isGlobal True to get the global project file, otherwise the local project config.
|
|
382
382
|
*/
|
|
383
|
-
|
|
384
|
-
const options =
|
|
383
|
+
getSfProjectJson(isGlobal = false) {
|
|
384
|
+
const options = SfProjectJson.getDefaultOptions(isGlobal);
|
|
385
385
|
if (isGlobal) {
|
|
386
|
-
if (!this.
|
|
387
|
-
this.
|
|
388
|
-
this.
|
|
386
|
+
if (!this.sfProjectJsonGlobal) {
|
|
387
|
+
this.sfProjectJsonGlobal = new SfProjectJson(options);
|
|
388
|
+
this.sfProjectJsonGlobal.readSync();
|
|
389
389
|
}
|
|
390
|
-
return this.
|
|
390
|
+
return this.sfProjectJsonGlobal;
|
|
391
391
|
}
|
|
392
392
|
else {
|
|
393
393
|
options.rootFolder = this.getPath();
|
|
394
|
-
if (!this.
|
|
395
|
-
this.
|
|
396
|
-
this.
|
|
394
|
+
if (!this.sfProjectJson) {
|
|
395
|
+
this.sfProjectJson = new SfProjectJson(options);
|
|
396
|
+
this.sfProjectJson.readSync();
|
|
397
397
|
}
|
|
398
|
-
return this.
|
|
398
|
+
return this.sfProjectJson;
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
401
|
/**
|
|
@@ -405,7 +405,7 @@ class SfdxProject {
|
|
|
405
405
|
*/
|
|
406
406
|
getPackageDirectories() {
|
|
407
407
|
if (!this.packageDirectories) {
|
|
408
|
-
this.packageDirectories = this.
|
|
408
|
+
this.packageDirectories = this.getSfProjectJson().getPackageDirectoriesSync();
|
|
409
409
|
}
|
|
410
410
|
return this.packageDirectories;
|
|
411
411
|
}
|
|
@@ -420,14 +420,14 @@ class SfdxProject {
|
|
|
420
420
|
* for packaging operations that want to do something for each package entry.
|
|
421
421
|
*/
|
|
422
422
|
getUniquePackageDirectories() {
|
|
423
|
-
return this.
|
|
423
|
+
return this.getSfProjectJson().getUniquePackageDirectories();
|
|
424
424
|
}
|
|
425
425
|
/**
|
|
426
|
-
* Get a list of the unique package names from within sfdx-project.json. Use {@link
|
|
426
|
+
* Get a list of the unique package names from within sfdx-project.json. Use {@link SfProject.getUniquePackageDirectories}
|
|
427
427
|
* for data other than the names.
|
|
428
428
|
*/
|
|
429
429
|
getUniquePackageNames() {
|
|
430
|
-
return this.
|
|
430
|
+
return this.getSfProjectJson().getUniquePackageNames();
|
|
431
431
|
}
|
|
432
432
|
/**
|
|
433
433
|
* Returns the package from a file path.
|
|
@@ -471,13 +471,13 @@ class SfdxProject {
|
|
|
471
471
|
* Has package directories defined in the project.
|
|
472
472
|
*/
|
|
473
473
|
hasPackages() {
|
|
474
|
-
return this.
|
|
474
|
+
return this.getSfProjectJson().hasPackages();
|
|
475
475
|
}
|
|
476
476
|
/**
|
|
477
477
|
* Has multiple package directories (MPD) defined in the project.
|
|
478
478
|
*/
|
|
479
479
|
hasMultiplePackages() {
|
|
480
|
-
return this.
|
|
480
|
+
return this.getSfProjectJson().hasMultiplePackages();
|
|
481
481
|
}
|
|
482
482
|
/**
|
|
483
483
|
* Get the currently activated package on the project. This has no implication on sfdx-project.json
|
|
@@ -506,17 +506,17 @@ class SfdxProject {
|
|
|
506
506
|
*/
|
|
507
507
|
getDefaultPackage() {
|
|
508
508
|
if (!this.hasPackages()) {
|
|
509
|
-
throw new
|
|
509
|
+
throw new sfError_1.SfError('The sfdx-project.json does not have any packageDirectories defined.');
|
|
510
510
|
}
|
|
511
511
|
const defaultPackage = this.getPackageDirectories().find((packageDir) => packageDir.default === true);
|
|
512
512
|
return defaultPackage || this.getPackageDirectories()[0];
|
|
513
513
|
}
|
|
514
514
|
/**
|
|
515
|
-
* The project config is resolved from local and global {@link
|
|
515
|
+
* The project config is resolved from local and global {@link SfProjectJson},
|
|
516
516
|
* {@link ConfigAggregator}, and a set of defaults. It is recommended to use
|
|
517
|
-
* this when reading values from
|
|
517
|
+
* this when reading values from SfProjectJson.
|
|
518
518
|
*
|
|
519
|
-
* The global {@link
|
|
519
|
+
* The global {@link SfProjectJson} is used to allow the user to provide default values they
|
|
520
520
|
* may not want checked into their project's source.
|
|
521
521
|
*
|
|
522
522
|
* @returns A resolved config object that contains a bunch of different
|
|
@@ -527,8 +527,8 @@ class SfdxProject {
|
|
|
527
527
|
if (!this.projectConfig) {
|
|
528
528
|
// Do fs operations in parallel
|
|
529
529
|
const [global, local, configAggregator] = await Promise.all([
|
|
530
|
-
this.
|
|
531
|
-
this.
|
|
530
|
+
this.retrieveSfProjectJson(true),
|
|
531
|
+
this.retrieveSfProjectJson(),
|
|
532
532
|
configAggregator_1.ConfigAggregator.create(),
|
|
533
533
|
]);
|
|
534
534
|
await Promise.all([global.read(), local.read()]);
|
|
@@ -551,7 +551,19 @@ class SfdxProject {
|
|
|
551
551
|
return this.projectConfig;
|
|
552
552
|
}
|
|
553
553
|
}
|
|
554
|
+
exports.SfProject = SfProject;
|
|
555
|
+
// Cache of SfProject instances per path.
|
|
556
|
+
SfProject.instances = new Map();
|
|
557
|
+
/**
|
|
558
|
+
* @deprecated use SfProject instead
|
|
559
|
+
*/
|
|
560
|
+
class SfdxProject extends SfProject {
|
|
561
|
+
}
|
|
554
562
|
exports.SfdxProject = SfdxProject;
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
563
|
+
/**
|
|
564
|
+
* @deprecated use SfProjectJson instead
|
|
565
|
+
*/
|
|
566
|
+
class SfdxProjectJson extends SfProjectJson {
|
|
567
|
+
}
|
|
568
|
+
exports.SfdxProjectJson = SfdxProjectJson;
|
|
569
|
+
//# sourceMappingURL=sfProject.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AsyncOptionalCreatable, Duration } from '@salesforce/kit';
|
|
2
2
|
import { AnyJson } from '@salesforce/ts-types';
|
|
3
3
|
import { Logger } from '../logger';
|
|
4
|
-
import { StatusResult } from './
|
|
4
|
+
import { StatusResult } from './types';
|
|
5
5
|
/**
|
|
6
6
|
* This is a polling client that can be used to poll the status of long running tasks. It can be used as a replacement
|
|
7
7
|
* for Streaming when streaming topics are not available or when streaming handshakes are failing. Why wouldn't you
|
|
@@ -38,7 +38,7 @@ export declare class PollingClient extends AsyncOptionalCreatable<PollingClient.
|
|
|
38
38
|
* Returns a promise to call the specified polling function using the interval and timeout specified
|
|
39
39
|
* in the polling options.
|
|
40
40
|
*/
|
|
41
|
-
subscribe(): Promise<
|
|
41
|
+
subscribe<T = AnyJson>(): Promise<T>;
|
|
42
42
|
}
|
|
43
43
|
export declare namespace PollingClient {
|
|
44
44
|
/**
|
|
@@ -11,7 +11,8 @@ const kit_1 = require("@salesforce/kit");
|
|
|
11
11
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
12
12
|
const ts_retry_promise_1 = require("ts-retry-promise");
|
|
13
13
|
const logger_1 = require("../logger");
|
|
14
|
-
const
|
|
14
|
+
const sfError_1 = require("../sfError");
|
|
15
|
+
const lifecycleEvents_1 = require("../lifecycleEvents");
|
|
15
16
|
/**
|
|
16
17
|
* This is a polling client that can be used to poll the status of long running tasks. It can be used as a replacement
|
|
17
18
|
* for Streaming when streaming topics are not available or when streaming handshakes are failing. Why wouldn't you
|
|
@@ -60,9 +61,14 @@ class PollingClient extends kit_1.AsyncOptionalCreatable {
|
|
|
60
61
|
result = await this.options.poll();
|
|
61
62
|
}
|
|
62
63
|
catch (error) {
|
|
63
|
-
errorInPollingFunction = error;
|
|
64
|
+
const err = (errorInPollingFunction = error);
|
|
65
|
+
if (['ETIMEDOUT', 'ENOTFOUND', 'ECONNRESET', 'socket hang up'].some((retryableNetworkError) => err.message.includes(retryableNetworkError))) {
|
|
66
|
+
this.logger.debug('Network error on the request', err);
|
|
67
|
+
await lifecycleEvents_1.Lifecycle.getInstance().emitWarning('Network error occurred. Continuing to poll.');
|
|
68
|
+
throw sfError_1.SfError.wrap(err);
|
|
69
|
+
}
|
|
64
70
|
// there was an actual error thrown, so we don't want to keep retrying
|
|
65
|
-
throw new ts_retry_promise_1.NotRetryableError(
|
|
71
|
+
throw new ts_retry_promise_1.NotRetryableError(err.name);
|
|
66
72
|
}
|
|
67
73
|
if (result.completed) {
|
|
68
74
|
return result.payload;
|
|
@@ -82,7 +88,7 @@ class PollingClient extends kit_1.AsyncOptionalCreatable {
|
|
|
82
88
|
throw errorInPollingFunction;
|
|
83
89
|
}
|
|
84
90
|
this.logger.debug('Polling timed out');
|
|
85
|
-
throw new
|
|
91
|
+
throw new sfError_1.SfError('The client has timed out.', (_a = this.options.timeoutErrorName) !== null && _a !== void 0 ? _a : 'PollingClientTimeout');
|
|
86
92
|
}
|
|
87
93
|
}
|
|
88
94
|
}
|
|
@@ -113,7 +113,7 @@ export declare class StreamingClient extends AsyncOptionalCreatable<StreamingCli
|
|
|
113
113
|
* Subscribe to streaming events. When the streaming processor that's set in the options completes execution it
|
|
114
114
|
* returns a payload in the StatusResult object. The payload is just echoed here for convenience.
|
|
115
115
|
*
|
|
116
|
-
* **Throws** *{@link
|
|
116
|
+
* **Throws** *{@link SfError}{ name: '{@link StreamingClient.TimeoutErrorType.SUBSCRIBE}'}* When the subscribe timeout occurs.
|
|
117
117
|
*
|
|
118
118
|
* @param streamInit This function should call the platform apis that result in streaming updates on push topics.
|
|
119
119
|
* {@link StatusResult}
|
|
@@ -13,7 +13,7 @@ const lib_1 = require("@salesforce/kit/lib");
|
|
|
13
13
|
const lib_2 = require("@salesforce/ts-types/lib");
|
|
14
14
|
const Faye = require("faye");
|
|
15
15
|
const logger_1 = require("../logger");
|
|
16
|
-
const
|
|
16
|
+
const sfError_1 = require("../sfError");
|
|
17
17
|
const messages_1 = require("../messages");
|
|
18
18
|
const types_1 = require("./types");
|
|
19
19
|
Object.defineProperty(exports, "CometClient", { enumerable: true, get: function () { return types_1.CometClient; } });
|
|
@@ -151,7 +151,7 @@ class StreamingClient extends lib_1.AsyncOptionalCreatable {
|
|
|
151
151
|
this.cometClient.setHeader('Authorization', `OAuth ${accessToken}`);
|
|
152
152
|
}
|
|
153
153
|
else {
|
|
154
|
-
throw new
|
|
154
|
+
throw new sfError_1.SfError('Missing or invalid access token', 'MissingOrInvalidAccessToken');
|
|
155
155
|
}
|
|
156
156
|
this.log(`Streaming client target url: ${this.targetUrl}`);
|
|
157
157
|
this.log(`options.subscribeTimeout (ms): ${this.options.subscribeTimeout.milliseconds}`);
|
|
@@ -201,7 +201,7 @@ class StreamingClient extends lib_1.AsyncOptionalCreatable {
|
|
|
201
201
|
* Subscribe to streaming events. When the streaming processor that's set in the options completes execution it
|
|
202
202
|
* returns a payload in the StatusResult object. The payload is just echoed here for convenience.
|
|
203
203
|
*
|
|
204
|
-
* **Throws** *{@link
|
|
204
|
+
* **Throws** *{@link SfError}{ name: '{@link StreamingClient.TimeoutErrorType.SUBSCRIBE}'}* When the subscribe timeout occurs.
|
|
205
205
|
*
|
|
206
206
|
* @param streamInit This function should call the platform apis that result in streaming updates on push topics.
|
|
207
207
|
* {@link StatusResult}
|
|
@@ -342,13 +342,13 @@ exports.StreamingClient = StreamingClient;
|
|
|
342
342
|
logger.warn('envDep is deprecated');
|
|
343
343
|
}
|
|
344
344
|
if (!streamProcessor) {
|
|
345
|
-
throw new
|
|
345
|
+
throw new sfError_1.SfError('Missing stream processor', 'MissingArg');
|
|
346
346
|
}
|
|
347
347
|
if (!org) {
|
|
348
|
-
throw new
|
|
348
|
+
throw new sfError_1.SfError('Missing org', 'MissingArg');
|
|
349
349
|
}
|
|
350
350
|
if (!channel) {
|
|
351
|
-
throw new
|
|
351
|
+
throw new sfError_1.SfError('Missing streaming channel', 'MissingArg');
|
|
352
352
|
}
|
|
353
353
|
this.org = org;
|
|
354
354
|
this.apiVersion = org.getConnection().getApiVersion();
|
package/lib/testSetup.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as sinonType from 'sinon';
|
|
|
4
4
|
import { AnyJson, JsonMap, Optional } from '@salesforce/ts-types';
|
|
5
5
|
import { ConfigContents } from './config/configStore';
|
|
6
6
|
import { Logger } from './logger';
|
|
7
|
-
import {
|
|
7
|
+
import { SfError } from './sfError';
|
|
8
8
|
import { CometClient, CometSubscription, Message, StreamingExtension } from './status/streamingClient';
|
|
9
9
|
import { SfOrg } from './globalInfo';
|
|
10
10
|
/**
|
|
@@ -85,7 +85,7 @@ export interface TestContext {
|
|
|
85
85
|
[configName: string]: Optional<ConfigStub>;
|
|
86
86
|
GlobalInfo?: ConfigStub;
|
|
87
87
|
Aliases?: ConfigStub;
|
|
88
|
-
|
|
88
|
+
SfProjectJson?: ConfigStub;
|
|
89
89
|
SfdxConfig?: ConfigStub;
|
|
90
90
|
};
|
|
91
91
|
/**
|
|
@@ -252,7 +252,7 @@ export declare const testSetup: (sinon?: any) => TestContext;
|
|
|
252
252
|
*
|
|
253
253
|
* **See** {@link shouldThrow}
|
|
254
254
|
*/
|
|
255
|
-
export declare const unexpectedResult:
|
|
255
|
+
export declare const unexpectedResult: SfError;
|
|
256
256
|
/**
|
|
257
257
|
* Use for this testing pattern:
|
|
258
258
|
* ```
|
|
@@ -302,7 +302,7 @@ export interface StreamingMockCometSubscriptionOptions {
|
|
|
302
302
|
/**
|
|
303
303
|
* If it's an error that states what that error should be.
|
|
304
304
|
*/
|
|
305
|
-
subscriptionErrbackError?:
|
|
305
|
+
subscriptionErrbackError?: SfError;
|
|
306
306
|
/**
|
|
307
307
|
* A list of messages to playback for the client. One message per process tick.
|
|
308
308
|
*/
|