@salesforce/core 3.31.7 → 3.31.9
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/LICENSE.txt +11 -11
- package/README.md +222 -222
- package/lib/config/aliasesConfig.d.ts +12 -12
- package/lib/config/aliasesConfig.js +27 -27
- package/lib/config/authInfoConfig.d.ts +19 -19
- package/lib/config/authInfoConfig.js +34 -34
- package/lib/config/config.d.ts +311 -311
- package/lib/config/config.js +574 -574
- package/lib/config/configAggregator.d.ts +232 -232
- package/lib/config/configAggregator.js +379 -379
- package/lib/config/configFile.d.ts +199 -199
- package/lib/config/configFile.js +340 -340
- package/lib/config/configGroup.d.ts +141 -141
- package/lib/config/configGroup.js +224 -224
- package/lib/config/configStore.d.ts +241 -241
- package/lib/config/configStore.js +352 -352
- package/lib/config/envVars.d.ts +101 -101
- package/lib/config/envVars.js +456 -456
- package/lib/config/orgUsersConfig.d.ts +31 -31
- package/lib/config/orgUsersConfig.js +41 -41
- package/lib/config/sandboxOrgConfig.d.ts +37 -37
- package/lib/config/sandboxOrgConfig.js +50 -50
- package/lib/config/sandboxProcessCache.d.ts +16 -16
- package/lib/config/sandboxProcessCache.js +37 -37
- package/lib/config/tokensConfig.d.ts +10 -10
- package/lib/config/tokensConfig.js +28 -28
- package/lib/config/ttlConfig.d.ts +34 -34
- package/lib/config/ttlConfig.js +54 -54
- package/lib/crypto/crypto.d.ts +54 -54
- package/lib/crypto/crypto.js +220 -220
- package/lib/crypto/keyChain.d.ts +8 -8
- package/lib/crypto/keyChain.js +61 -61
- package/lib/crypto/keyChainImpl.d.ts +116 -116
- package/lib/crypto/keyChainImpl.js +486 -486
- package/lib/crypto/secureBuffer.d.ts +46 -46
- package/lib/crypto/secureBuffer.js +82 -82
- package/lib/deviceOauthService.d.ts +71 -71
- package/lib/deviceOauthService.js +191 -191
- package/lib/exported.d.ts +38 -38
- package/lib/exported.js +118 -118
- package/lib/global.d.ts +70 -70
- package/lib/global.js +109 -109
- package/lib/lifecycleEvents.d.ts +93 -93
- package/lib/lifecycleEvents.js +188 -188
- package/lib/logger.d.ts +381 -381
- package/lib/logger.js +734 -734
- package/lib/messages.d.ts +291 -291
- package/lib/messages.js +543 -543
- package/lib/org/authInfo.d.ts +344 -344
- package/lib/org/authInfo.js +892 -892
- package/lib/org/authRemover.d.ts +88 -88
- package/lib/org/authRemover.js +182 -182
- package/lib/org/connection.d.ts +197 -197
- package/lib/org/connection.js +395 -395
- package/lib/org/index.d.ts +6 -6
- package/lib/org/index.js +28 -28
- package/lib/org/org.d.ts +558 -558
- package/lib/org/org.js +1267 -1267
- package/lib/org/orgConfigProperties.d.ts +69 -69
- package/lib/org/orgConfigProperties.js +136 -136
- package/lib/org/permissionSetAssignment.d.ts +35 -35
- package/lib/org/permissionSetAssignment.js +125 -125
- package/lib/org/scratchOrgCache.d.ts +20 -20
- package/lib/org/scratchOrgCache.js +32 -32
- package/lib/org/scratchOrgCreate.d.ts +54 -54
- package/lib/org/scratchOrgCreate.js +216 -216
- package/lib/org/scratchOrgErrorCodes.d.ts +10 -10
- package/lib/org/scratchOrgErrorCodes.js +88 -88
- package/lib/org/scratchOrgFeatureDeprecation.d.ts +26 -26
- package/lib/org/scratchOrgFeatureDeprecation.js +109 -109
- package/lib/org/scratchOrgInfoApi.d.ts +68 -68
- package/lib/org/scratchOrgInfoApi.js +416 -413
- package/lib/org/scratchOrgInfoGenerator.d.ts +64 -64
- package/lib/org/scratchOrgInfoGenerator.js +241 -241
- package/lib/org/scratchOrgLifecycleEvents.d.ts +10 -10
- package/lib/org/scratchOrgLifecycleEvents.js +40 -40
- package/lib/org/scratchOrgSettingsGenerator.d.ts +78 -78
- package/lib/org/scratchOrgSettingsGenerator.js +276 -276
- package/lib/org/scratchOrgTypes.d.ts +43 -43
- package/lib/org/scratchOrgTypes.js +8 -8
- package/lib/org/user.d.ts +187 -187
- package/lib/org/user.js +448 -448
- package/lib/schema/printer.d.ts +79 -79
- package/lib/schema/printer.js +260 -260
- package/lib/schema/validator.d.ts +70 -70
- package/lib/schema/validator.js +169 -169
- package/lib/sfError.d.ts +73 -73
- package/lib/sfError.js +136 -136
- package/lib/sfProject.d.ts +357 -357
- package/lib/sfProject.js +671 -671
- package/lib/stateAggregator/accessors/aliasAccessor.d.ts +98 -98
- package/lib/stateAggregator/accessors/aliasAccessor.js +145 -145
- package/lib/stateAggregator/accessors/orgAccessor.d.ts +101 -101
- package/lib/stateAggregator/accessors/orgAccessor.js +240 -240
- package/lib/stateAggregator/accessors/sandboxAccessor.d.ts +8 -8
- package/lib/stateAggregator/accessors/sandboxAccessor.js +27 -27
- package/lib/stateAggregator/accessors/tokenAccessor.d.ts +63 -63
- package/lib/stateAggregator/accessors/tokenAccessor.js +79 -79
- package/lib/stateAggregator/index.d.ts +4 -4
- package/lib/stateAggregator/index.js +26 -26
- package/lib/stateAggregator/stateAggregator.d.ts +25 -25
- package/lib/stateAggregator/stateAggregator.js +45 -45
- package/lib/status/myDomainResolver.d.ts +66 -66
- package/lib/status/myDomainResolver.js +124 -124
- package/lib/status/pollingClient.d.ts +85 -85
- package/lib/status/pollingClient.js +115 -115
- package/lib/status/streamingClient.d.ts +244 -244
- package/lib/status/streamingClient.js +436 -436
- package/lib/status/types.d.ts +89 -89
- package/lib/status/types.js +17 -17
- package/lib/testSetup.d.ts +553 -553
- package/lib/testSetup.js +871 -871
- package/lib/util/cache.d.ts +11 -11
- package/lib/util/cache.js +69 -69
- package/lib/util/checkLightningDomain.d.ts +1 -1
- package/lib/util/checkLightningDomain.js +28 -28
- package/lib/util/directoryWriter.d.ts +12 -12
- package/lib/util/directoryWriter.js +53 -53
- package/lib/util/getJwtAudienceUrl.d.ts +4 -4
- package/lib/util/getJwtAudienceUrl.js +18 -18
- package/lib/util/internal.d.ts +58 -58
- package/lib/util/internal.js +118 -118
- package/lib/util/jsonXmlTools.d.ts +14 -14
- package/lib/util/jsonXmlTools.js +38 -38
- package/lib/util/mapKeys.d.ts +14 -14
- package/lib/util/mapKeys.js +51 -51
- package/lib/util/sfdc.d.ts +52 -52
- package/lib/util/sfdc.js +85 -85
- package/lib/util/sfdcUrl.d.ts +72 -72
- package/lib/util/sfdcUrl.js +215 -215
- package/lib/util/structuredWriter.d.ts +9 -9
- package/lib/util/structuredWriter.js +2 -2
- package/lib/util/zipWriter.d.ts +16 -16
- package/lib/util/zipWriter.js +67 -67
- package/lib/webOAuthServer.d.ts +156 -156
- package/lib/webOAuthServer.js +388 -388
- package/messages/auth.md +37 -37
- package/messages/config.md +156 -156
- package/messages/connection.md +30 -30
- package/messages/core.json +20 -20
- package/messages/core.md +67 -67
- package/messages/encryption.md +85 -85
- package/messages/envVars.md +303 -303
- package/messages/org.md +63 -63
- package/messages/permissionSetAssignment.md +31 -31
- package/messages/scratchOrgCreate.md +23 -23
- package/messages/scratchOrgErrorCodes.md +115 -115
- package/messages/scratchOrgFeatureDeprecation.md +11 -11
- package/messages/scratchOrgInfoApi.md +19 -15
- package/messages/scratchOrgInfoGenerator.md +23 -23
- package/messages/streaming.md +23 -23
- package/messages/user.md +35 -35
- package/package.json +97 -97
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import { SfProjectJson } from '../sfProject';
|
|
2
|
-
import { Org } from './org';
|
|
3
|
-
import { ScratchOrgInfo } from './scratchOrgTypes';
|
|
4
|
-
declare type PartialScratchOrgInfo = Pick<ScratchOrgInfo, 'ConnectedAppConsumerKey' | 'AuthCode' | 'Snapshot' | 'Status' | 'LoginUrl' | 'SignupEmail' | 'SignupUsername' | 'SignupInstance' | 'Username'>;
|
|
5
|
-
export interface ScratchOrgInfoPayload extends PartialScratchOrgInfo {
|
|
6
|
-
orgName: string;
|
|
7
|
-
package2AncestorIds: string;
|
|
8
|
-
features: string | string[];
|
|
9
|
-
connectedAppConsumerKey: string;
|
|
10
|
-
namespace: string;
|
|
11
|
-
connectedAppCallbackUrl: string;
|
|
12
|
-
durationDays: number;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Generates the package2AncestorIds scratch org property
|
|
16
|
-
*
|
|
17
|
-
* @param scratchOrgInfo - the scratchOrgInfo passed in by the user
|
|
18
|
-
* @param projectJson - sfProjectJson
|
|
19
|
-
* @param hubOrg - the hub org, in case we need to do queries
|
|
20
|
-
*/
|
|
21
|
-
export declare const getAncestorIds: (scratchOrgInfo: ScratchOrgInfoPayload, projectJson: SfProjectJson, hubOrg: Org) => Promise<string>;
|
|
22
|
-
/**
|
|
23
|
-
* Takes in a scratchOrgInfo and fills in the missing fields
|
|
24
|
-
*
|
|
25
|
-
* @param hubOrg the environment hub org
|
|
26
|
-
* @param scratchOrgInfoPayload - the scratchOrgInfo passed in by the user
|
|
27
|
-
* @param nonamespace create the scratch org with no namespace
|
|
28
|
-
* @param ignoreAncestorIds true if the sfdx-project.json ancestorId keys should be ignored
|
|
29
|
-
*/
|
|
30
|
-
export declare const generateScratchOrgInfo: ({ hubOrg, scratchOrgInfoPayload, nonamespace, ignoreAncestorIds, }: {
|
|
31
|
-
hubOrg: Org;
|
|
32
|
-
scratchOrgInfoPayload: ScratchOrgInfoPayload;
|
|
33
|
-
nonamespace?: boolean | undefined;
|
|
34
|
-
ignoreAncestorIds?: boolean | undefined;
|
|
35
|
-
}) => Promise<ScratchOrgInfoPayload>;
|
|
36
|
-
/**
|
|
37
|
-
* Returns a valid signup json
|
|
38
|
-
*
|
|
39
|
-
* definitionjson org definition in JSON format
|
|
40
|
-
* definitionfile path to an org definition file
|
|
41
|
-
* connectedAppConsumerKey The connected app consumer key. May be null for JWT OAuth flow.
|
|
42
|
-
* durationdays duration of the scratch org (in days) (default:1, min:1, max:30)
|
|
43
|
-
* nonamespace create the scratch org with no namespace
|
|
44
|
-
* noancestors do not include second-generation package ancestors in the scratch org
|
|
45
|
-
* orgConfig overrides definitionjson
|
|
46
|
-
*
|
|
47
|
-
* @returns scratchOrgInfoPayload: ScratchOrgInfoPayload;
|
|
48
|
-
ignoreAncestorIds: boolean;
|
|
49
|
-
warnings: string[];
|
|
50
|
-
*/
|
|
51
|
-
export declare const getScratchOrgInfoPayload: (options: {
|
|
52
|
-
durationDays: number;
|
|
53
|
-
definitionjson?: string;
|
|
54
|
-
definitionfile?: string;
|
|
55
|
-
connectedAppConsumerKey?: string;
|
|
56
|
-
nonamespace?: boolean;
|
|
57
|
-
noancestors?: boolean;
|
|
58
|
-
orgConfig?: Record<string, unknown>;
|
|
59
|
-
}) => Promise<{
|
|
60
|
-
scratchOrgInfoPayload: ScratchOrgInfoPayload;
|
|
61
|
-
ignoreAncestorIds: boolean;
|
|
62
|
-
warnings: string[];
|
|
63
|
-
}>;
|
|
64
|
-
export {};
|
|
1
|
+
import { SfProjectJson } from '../sfProject';
|
|
2
|
+
import { Org } from './org';
|
|
3
|
+
import { ScratchOrgInfo } from './scratchOrgTypes';
|
|
4
|
+
declare type PartialScratchOrgInfo = Pick<ScratchOrgInfo, 'ConnectedAppConsumerKey' | 'AuthCode' | 'Snapshot' | 'Status' | 'LoginUrl' | 'SignupEmail' | 'SignupUsername' | 'SignupInstance' | 'Username'>;
|
|
5
|
+
export interface ScratchOrgInfoPayload extends PartialScratchOrgInfo {
|
|
6
|
+
orgName: string;
|
|
7
|
+
package2AncestorIds: string;
|
|
8
|
+
features: string | string[];
|
|
9
|
+
connectedAppConsumerKey: string;
|
|
10
|
+
namespace: string;
|
|
11
|
+
connectedAppCallbackUrl: string;
|
|
12
|
+
durationDays: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Generates the package2AncestorIds scratch org property
|
|
16
|
+
*
|
|
17
|
+
* @param scratchOrgInfo - the scratchOrgInfo passed in by the user
|
|
18
|
+
* @param projectJson - sfProjectJson
|
|
19
|
+
* @param hubOrg - the hub org, in case we need to do queries
|
|
20
|
+
*/
|
|
21
|
+
export declare const getAncestorIds: (scratchOrgInfo: ScratchOrgInfoPayload, projectJson: SfProjectJson, hubOrg: Org) => Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Takes in a scratchOrgInfo and fills in the missing fields
|
|
24
|
+
*
|
|
25
|
+
* @param hubOrg the environment hub org
|
|
26
|
+
* @param scratchOrgInfoPayload - the scratchOrgInfo passed in by the user
|
|
27
|
+
* @param nonamespace create the scratch org with no namespace
|
|
28
|
+
* @param ignoreAncestorIds true if the sfdx-project.json ancestorId keys should be ignored
|
|
29
|
+
*/
|
|
30
|
+
export declare const generateScratchOrgInfo: ({ hubOrg, scratchOrgInfoPayload, nonamespace, ignoreAncestorIds, }: {
|
|
31
|
+
hubOrg: Org;
|
|
32
|
+
scratchOrgInfoPayload: ScratchOrgInfoPayload;
|
|
33
|
+
nonamespace?: boolean | undefined;
|
|
34
|
+
ignoreAncestorIds?: boolean | undefined;
|
|
35
|
+
}) => Promise<ScratchOrgInfoPayload>;
|
|
36
|
+
/**
|
|
37
|
+
* Returns a valid signup json
|
|
38
|
+
*
|
|
39
|
+
* definitionjson org definition in JSON format
|
|
40
|
+
* definitionfile path to an org definition file
|
|
41
|
+
* connectedAppConsumerKey The connected app consumer key. May be null for JWT OAuth flow.
|
|
42
|
+
* durationdays duration of the scratch org (in days) (default:1, min:1, max:30)
|
|
43
|
+
* nonamespace create the scratch org with no namespace
|
|
44
|
+
* noancestors do not include second-generation package ancestors in the scratch org
|
|
45
|
+
* orgConfig overrides definitionjson
|
|
46
|
+
*
|
|
47
|
+
* @returns scratchOrgInfoPayload: ScratchOrgInfoPayload;
|
|
48
|
+
ignoreAncestorIds: boolean;
|
|
49
|
+
warnings: string[];
|
|
50
|
+
*/
|
|
51
|
+
export declare const getScratchOrgInfoPayload: (options: {
|
|
52
|
+
durationDays: number;
|
|
53
|
+
definitionjson?: string;
|
|
54
|
+
definitionfile?: string;
|
|
55
|
+
connectedAppConsumerKey?: string;
|
|
56
|
+
nonamespace?: boolean;
|
|
57
|
+
noancestors?: boolean;
|
|
58
|
+
orgConfig?: Record<string, unknown>;
|
|
59
|
+
}) => Promise<{
|
|
60
|
+
scratchOrgInfoPayload: ScratchOrgInfoPayload;
|
|
61
|
+
ignoreAncestorIds: boolean;
|
|
62
|
+
warnings: string[];
|
|
63
|
+
}>;
|
|
64
|
+
export {};
|
|
@@ -1,242 +1,242 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getScratchOrgInfoPayload = exports.generateScratchOrgInfo = exports.getAncestorIds = void 0;
|
|
4
|
-
/*
|
|
5
|
-
* Copyright (c) 2021, salesforce.com, inc.
|
|
6
|
-
* All rights reserved.
|
|
7
|
-
* Licensed under the BSD 3-Clause license.
|
|
8
|
-
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
|
-
*/
|
|
10
|
-
const fs_1 = require("fs");
|
|
11
|
-
const kit_1 = require("@salesforce/kit");
|
|
12
|
-
const ts_types_1 = require("@salesforce/ts-types");
|
|
13
|
-
const sfProject_1 = require("../sfProject");
|
|
14
|
-
const webOAuthServer_1 = require("../webOAuthServer");
|
|
15
|
-
const messages_1 = require("../messages");
|
|
16
|
-
const sfError_1 = require("../sfError");
|
|
17
|
-
const scratchOrgFeatureDeprecation_1 = require("./scratchOrgFeatureDeprecation");
|
|
18
|
-
const defaultConnectedAppInfo = {
|
|
19
|
-
clientId: 'PlatformCLI',
|
|
20
|
-
legacyClientId: 'SalesforceDevelopmentExperience',
|
|
21
|
-
legacyClientSecret: '1384510088588713504',
|
|
22
|
-
};
|
|
23
|
-
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
24
|
-
const messages = messages_1.Messages.loadMessages('@salesforce/core', 'scratchOrgInfoGenerator');
|
|
25
|
-
const SNAPSHOT_UNSUPPORTED_OPTIONS = [
|
|
26
|
-
'features',
|
|
27
|
-
'orgPreferences',
|
|
28
|
-
'edition',
|
|
29
|
-
'sourceOrg',
|
|
30
|
-
'settingsPath',
|
|
31
|
-
'releaseVersion',
|
|
32
|
-
'language',
|
|
33
|
-
];
|
|
34
|
-
// A validator function to ensure any options parameters entered by the user adhere
|
|
35
|
-
// to a allowlist of valid option settings. Because org:create allows options to be
|
|
36
|
-
// input either key=value pairs or within the definition file, this validator is
|
|
37
|
-
// executed within the ctor and also after parsing/normalization of the definition file.
|
|
38
|
-
const optionsValidator = (key, scratchOrgInfoPayload) => {
|
|
39
|
-
if (key.toLowerCase() === 'durationdays') {
|
|
40
|
-
throw new sfError_1.SfError('unrecognizedScratchOrgOption', 'durationDays');
|
|
41
|
-
}
|
|
42
|
-
if (key.toLowerCase() === 'snapshot') {
|
|
43
|
-
const foundInvalidFields = SNAPSHOT_UNSUPPORTED_OPTIONS.filter((invalidField) => invalidField in scratchOrgInfoPayload);
|
|
44
|
-
if (foundInvalidFields.length > 0) {
|
|
45
|
-
throw new sfError_1.SfError(messages.getMessage('unsupportedSnapshotOrgCreateOptions', [foundInvalidFields.join(', ')]), 'orgSnapshot');
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Generates the package2AncestorIds scratch org property
|
|
51
|
-
*
|
|
52
|
-
* @param scratchOrgInfo - the scratchOrgInfo passed in by the user
|
|
53
|
-
* @param projectJson - sfProjectJson
|
|
54
|
-
* @param hubOrg - the hub org, in case we need to do queries
|
|
55
|
-
*/
|
|
56
|
-
const getAncestorIds = async (scratchOrgInfo, projectJson, hubOrg) => {
|
|
57
|
-
if (Reflect.has(scratchOrgInfo, 'package2AncestorIds')) {
|
|
58
|
-
throw new sfError_1.SfError(messages.getMessage('Package2AncestorsIdsKeyNotSupportedError'), 'DeprecationError');
|
|
59
|
-
}
|
|
60
|
-
const packagesWithAncestors = (await projectJson.getPackageDirectories())
|
|
61
|
-
// check that the package has any ancestor types (id or version)
|
|
62
|
-
.filter((packageDir) => packageDir.ancestorId ?? packageDir.ancestorVersion);
|
|
63
|
-
if (packagesWithAncestors.length === 0) {
|
|
64
|
-
return '';
|
|
65
|
-
}
|
|
66
|
-
const ancestorIds = await Promise.all(packagesWithAncestors.map(async (packageDir) => {
|
|
67
|
-
// ancestorID can be 05i, or 04t, alias; OR "ancestorVersion": "4.6.0.1"
|
|
68
|
-
// according to docs, 05i is not ok: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev2gp_config_file.htm
|
|
69
|
-
// package can be an ID, but not according to docs
|
|
70
|
-
const packageAliases = projectJson.get('packageAliases');
|
|
71
|
-
const packageId = packageAliases[(0, ts_types_1.ensureString)(packageDir.package)] ?? packageDir.package;
|
|
72
|
-
// Handle HIGHEST and NONE in ancestor(Version|Id).
|
|
73
|
-
// Precedence chain: NONE -> HIGHEST -> ancestorVersion & ancestoryId
|
|
74
|
-
if (packageDir.ancestorVersion === 'NONE' || packageDir.ancestorId === 'NONE') {
|
|
75
|
-
return '';
|
|
76
|
-
}
|
|
77
|
-
else if (packageDir.ancestorVersion === 'HIGHEST' || packageDir.ancestorId === 'HIGHEST') {
|
|
78
|
-
const query = 'SELECT Id FROM Package2Version ' +
|
|
79
|
-
`WHERE Package2Id = '${packageId}' AND IsReleased = True AND IsDeprecated = False AND PatchVersion = 0 ` +
|
|
80
|
-
'ORDER BY MajorVersion Desc, MinorVersion Desc, PatchVersion Desc, BuildNumber Desc LIMIT 1';
|
|
81
|
-
try {
|
|
82
|
-
return (await hubOrg.getConnection().singleRecordQuery(query, { tooling: true })).Id;
|
|
83
|
-
}
|
|
84
|
-
catch (err) {
|
|
85
|
-
if (packageDir.ancestorVersion === 'HIGHEST') {
|
|
86
|
-
throw new sfError_1.SfError(messages.getMessage('NoMatchingAncestorError', [packageDir.ancestorVersion, packageDir.package]), 'NoMatchingAncestorError', [messages.getMessage('AncestorNotReleasedError', [packageDir.ancestorVersion])]);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
throw new sfError_1.SfError(messages.getMessage('NoMatchingAncestorIdError', [packageDir.ancestorId, packageDir.package]), 'NoMatchingAncestorIdError', [messages.getMessage('AncestorNotReleasedError', [packageDir.ancestorId])]);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
if (packageDir.ancestorVersion) {
|
|
94
|
-
if (!/^[0-9]+.[0-9]+.[0-9]+(.[0-9]+)?$/.test(packageDir.ancestorVersion)) {
|
|
95
|
-
throw messages.createError('InvalidAncestorVersionFormatError', [packageDir.ancestorVersion]);
|
|
96
|
-
}
|
|
97
|
-
const [major, minor, patch] = packageDir.ancestorVersion.split('.');
|
|
98
|
-
let releasedAncestor;
|
|
99
|
-
try {
|
|
100
|
-
releasedAncestor = await hubOrg
|
|
101
|
-
.getConnection()
|
|
102
|
-
.singleRecordQuery(`SELECT Id, IsReleased FROM Package2Version WHERE Package2Id = '${packageId}' AND MajorVersion = ${major} AND MinorVersion = ${minor} AND PatchVersion = ${patch} and IsReleased = true`, { tooling: true });
|
|
103
|
-
}
|
|
104
|
-
catch (err) {
|
|
105
|
-
throw new sfError_1.SfError(messages.getMessage('NoMatchingAncestorError', [packageDir.ancestorVersion, packageDir.package]), 'NoMatchingAncestorError', [messages.getMessage('AncestorNotReleasedError', [packageDir.ancestorVersion])]);
|
|
106
|
-
}
|
|
107
|
-
if (packageDir.ancestorId && packageDir.ancestorId !== releasedAncestor.Id) {
|
|
108
|
-
throw messages.createError('AncestorIdVersionMismatchError', [
|
|
109
|
-
packageDir.ancestorVersion,
|
|
110
|
-
packageDir.ancestorId,
|
|
111
|
-
]);
|
|
112
|
-
}
|
|
113
|
-
return releasedAncestor.Id;
|
|
114
|
-
}
|
|
115
|
-
if (packageDir?.ancestorId?.startsWith('05i')) {
|
|
116
|
-
// if it's already a 05i return it, otherwise query for it
|
|
117
|
-
return packageDir.ancestorId;
|
|
118
|
-
}
|
|
119
|
-
if (packageDir?.ancestorId?.startsWith('04t')) {
|
|
120
|
-
// query for the Id
|
|
121
|
-
return (await hubOrg
|
|
122
|
-
.getConnection()
|
|
123
|
-
.singleRecordQuery(`SELECT Id FROM Package2Version WHERE SubscriberPackageVersionId = '${packageDir.ancestorId}'`, { tooling: true })).Id;
|
|
124
|
-
}
|
|
125
|
-
// ancestorID can be an alias; get it from projectJson
|
|
126
|
-
if (packageDir.ancestorId && packageAliases?.[packageDir.ancestorId]) {
|
|
127
|
-
return packageAliases[packageDir.ancestorId];
|
|
128
|
-
}
|
|
129
|
-
throw new sfError_1.SfError(`Invalid ancestorId ${packageDir.ancestorId}`, 'InvalidAncestorId');
|
|
130
|
-
}));
|
|
131
|
-
// strip out '' due to NONE
|
|
132
|
-
return Array.from(new Set(ancestorIds.filter((id) => id !== ''))).join(';');
|
|
133
|
-
};
|
|
134
|
-
exports.getAncestorIds = getAncestorIds;
|
|
135
|
-
/**
|
|
136
|
-
* Takes in a scratchOrgInfo and fills in the missing fields
|
|
137
|
-
*
|
|
138
|
-
* @param hubOrg the environment hub org
|
|
139
|
-
* @param scratchOrgInfoPayload - the scratchOrgInfo passed in by the user
|
|
140
|
-
* @param nonamespace create the scratch org with no namespace
|
|
141
|
-
* @param ignoreAncestorIds true if the sfdx-project.json ancestorId keys should be ignored
|
|
142
|
-
*/
|
|
143
|
-
const generateScratchOrgInfo = async ({ hubOrg, scratchOrgInfoPayload, nonamespace, ignoreAncestorIds, }) => {
|
|
144
|
-
let sfProject;
|
|
145
|
-
try {
|
|
146
|
-
sfProject = await sfProject_1.SfProjectJson.create({});
|
|
147
|
-
}
|
|
148
|
-
catch (e) {
|
|
149
|
-
// project is not required
|
|
150
|
-
}
|
|
151
|
-
scratchOrgInfoPayload.orgName = scratchOrgInfoPayload.orgName ?? 'Company';
|
|
152
|
-
scratchOrgInfoPayload.package2AncestorIds =
|
|
153
|
-
!ignoreAncestorIds && sfProject?.hasPackages()
|
|
154
|
-
? await (0, exports.getAncestorIds)(scratchOrgInfoPayload, sfProject, hubOrg)
|
|
155
|
-
: '';
|
|
156
|
-
// Use the Hub org's client ID value, if one wasn't provided to us, or the default
|
|
157
|
-
if (!scratchOrgInfoPayload.connectedAppConsumerKey) {
|
|
158
|
-
scratchOrgInfoPayload.connectedAppConsumerKey =
|
|
159
|
-
hubOrg.getConnection().getAuthInfoFields().clientId ?? defaultConnectedAppInfo.clientId;
|
|
160
|
-
}
|
|
161
|
-
if (!nonamespace && sfProject?.get('namespace')) {
|
|
162
|
-
scratchOrgInfoPayload.namespace = sfProject.get('namespace');
|
|
163
|
-
}
|
|
164
|
-
// we already have the info, and want to get rid of configApi, so this doesn't use that
|
|
165
|
-
scratchOrgInfoPayload.connectedAppCallbackUrl = `http://localhost:${await webOAuthServer_1.WebOAuthServer.determineOauthPort()}/OauthRedirect`;
|
|
166
|
-
return scratchOrgInfoPayload;
|
|
167
|
-
};
|
|
168
|
-
exports.generateScratchOrgInfo = generateScratchOrgInfo;
|
|
169
|
-
/**
|
|
170
|
-
* Returns a valid signup json
|
|
171
|
-
*
|
|
172
|
-
* definitionjson org definition in JSON format
|
|
173
|
-
* definitionfile path to an org definition file
|
|
174
|
-
* connectedAppConsumerKey The connected app consumer key. May be null for JWT OAuth flow.
|
|
175
|
-
* durationdays duration of the scratch org (in days) (default:1, min:1, max:30)
|
|
176
|
-
* nonamespace create the scratch org with no namespace
|
|
177
|
-
* noancestors do not include second-generation package ancestors in the scratch org
|
|
178
|
-
* orgConfig overrides definitionjson
|
|
179
|
-
*
|
|
180
|
-
* @returns scratchOrgInfoPayload: ScratchOrgInfoPayload;
|
|
181
|
-
ignoreAncestorIds: boolean;
|
|
182
|
-
warnings: string[];
|
|
183
|
-
*/
|
|
184
|
-
const getScratchOrgInfoPayload = async (options) => {
|
|
185
|
-
let warnings = [];
|
|
186
|
-
// orgConfig input overrides definitionjson (-j option; hidden/deprecated) overrides definitionfile (-f option)
|
|
187
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
188
|
-
const scratchOrgInfoPayload = {
|
|
189
|
-
...(options.definitionfile ? await parseDefinitionFile(options.definitionfile) : {}),
|
|
190
|
-
...(options.definitionjson ? JSON.parse(options.definitionjson) : {}),
|
|
191
|
-
...(options.orgConfig ?? {}),
|
|
192
|
-
};
|
|
193
|
-
// scratchOrgInfoPayload must be heads down camelcase.
|
|
194
|
-
Object.keys(scratchOrgInfoPayload).forEach((key) => {
|
|
195
|
-
if (key[0].toUpperCase() === key[0]) {
|
|
196
|
-
throw new sfError_1.SfError('InvalidJsonCasing', key);
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
// Now run the fully resolved user input against the validator
|
|
200
|
-
Object.keys(scratchOrgInfoPayload).forEach((key) => {
|
|
201
|
-
optionsValidator(key, scratchOrgInfoPayload);
|
|
202
|
-
});
|
|
203
|
-
if (options.connectedAppConsumerKey) {
|
|
204
|
-
scratchOrgInfoPayload.connectedAppConsumerKey = options.connectedAppConsumerKey;
|
|
205
|
-
}
|
|
206
|
-
scratchOrgInfoPayload.durationDays = options.durationDays;
|
|
207
|
-
// Throw warnings for deprecated scratch org features.
|
|
208
|
-
const scratchOrgFeatureDeprecation = new scratchOrgFeatureDeprecation_1.ScratchOrgFeatureDeprecation();
|
|
209
|
-
// convert various supported array and string formats to a semi-colon-delimited string
|
|
210
|
-
if (scratchOrgInfoPayload.features) {
|
|
211
|
-
if (typeof scratchOrgInfoPayload.features === 'string') {
|
|
212
|
-
scratchOrgInfoPayload.features = scratchOrgInfoPayload.features.split(/[;,]/);
|
|
213
|
-
}
|
|
214
|
-
warnings = scratchOrgFeatureDeprecation.getFeatureWarnings(scratchOrgInfoPayload.features);
|
|
215
|
-
scratchOrgInfoPayload.features = scratchOrgInfoPayload.features.map((feature) => feature.trim());
|
|
216
|
-
scratchOrgInfoPayload.features = scratchOrgFeatureDeprecation
|
|
217
|
-
.filterDeprecatedFeatures(scratchOrgInfoPayload.features)
|
|
218
|
-
.join(';');
|
|
219
|
-
}
|
|
220
|
-
return {
|
|
221
|
-
scratchOrgInfoPayload,
|
|
222
|
-
// Ignore ancestor ids only when 'nonamespace' or 'noancestors' options are specified
|
|
223
|
-
ignoreAncestorIds: options.nonamespace ?? options.noancestors ?? false,
|
|
224
|
-
warnings,
|
|
225
|
-
};
|
|
226
|
-
};
|
|
227
|
-
exports.getScratchOrgInfoPayload = getScratchOrgInfoPayload;
|
|
228
|
-
const parseDefinitionFile = async (definitionFile) => {
|
|
229
|
-
try {
|
|
230
|
-
const fileData = await fs_1.promises.readFile(definitionFile, 'utf8');
|
|
231
|
-
const defFileContents = (0, kit_1.parseJson)(fileData);
|
|
232
|
-
return defFileContents;
|
|
233
|
-
}
|
|
234
|
-
catch (err) {
|
|
235
|
-
const error = err;
|
|
236
|
-
if (error.name === 'JsonParseError') {
|
|
237
|
-
throw new sfError_1.SfError(`An error occurred parsing ${definitionFile}`);
|
|
238
|
-
}
|
|
239
|
-
throw sfError_1.SfError.wrap(error);
|
|
240
|
-
}
|
|
241
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getScratchOrgInfoPayload = exports.generateScratchOrgInfo = exports.getAncestorIds = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2021, salesforce.com, inc.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
* Licensed under the BSD 3-Clause license.
|
|
8
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
|
+
*/
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const kit_1 = require("@salesforce/kit");
|
|
12
|
+
const ts_types_1 = require("@salesforce/ts-types");
|
|
13
|
+
const sfProject_1 = require("../sfProject");
|
|
14
|
+
const webOAuthServer_1 = require("../webOAuthServer");
|
|
15
|
+
const messages_1 = require("../messages");
|
|
16
|
+
const sfError_1 = require("../sfError");
|
|
17
|
+
const scratchOrgFeatureDeprecation_1 = require("./scratchOrgFeatureDeprecation");
|
|
18
|
+
const defaultConnectedAppInfo = {
|
|
19
|
+
clientId: 'PlatformCLI',
|
|
20
|
+
legacyClientId: 'SalesforceDevelopmentExperience',
|
|
21
|
+
legacyClientSecret: '1384510088588713504',
|
|
22
|
+
};
|
|
23
|
+
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
24
|
+
const messages = messages_1.Messages.loadMessages('@salesforce/core', 'scratchOrgInfoGenerator');
|
|
25
|
+
const SNAPSHOT_UNSUPPORTED_OPTIONS = [
|
|
26
|
+
'features',
|
|
27
|
+
'orgPreferences',
|
|
28
|
+
'edition',
|
|
29
|
+
'sourceOrg',
|
|
30
|
+
'settingsPath',
|
|
31
|
+
'releaseVersion',
|
|
32
|
+
'language',
|
|
33
|
+
];
|
|
34
|
+
// A validator function to ensure any options parameters entered by the user adhere
|
|
35
|
+
// to a allowlist of valid option settings. Because org:create allows options to be
|
|
36
|
+
// input either key=value pairs or within the definition file, this validator is
|
|
37
|
+
// executed within the ctor and also after parsing/normalization of the definition file.
|
|
38
|
+
const optionsValidator = (key, scratchOrgInfoPayload) => {
|
|
39
|
+
if (key.toLowerCase() === 'durationdays') {
|
|
40
|
+
throw new sfError_1.SfError('unrecognizedScratchOrgOption', 'durationDays');
|
|
41
|
+
}
|
|
42
|
+
if (key.toLowerCase() === 'snapshot') {
|
|
43
|
+
const foundInvalidFields = SNAPSHOT_UNSUPPORTED_OPTIONS.filter((invalidField) => invalidField in scratchOrgInfoPayload);
|
|
44
|
+
if (foundInvalidFields.length > 0) {
|
|
45
|
+
throw new sfError_1.SfError(messages.getMessage('unsupportedSnapshotOrgCreateOptions', [foundInvalidFields.join(', ')]), 'orgSnapshot');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Generates the package2AncestorIds scratch org property
|
|
51
|
+
*
|
|
52
|
+
* @param scratchOrgInfo - the scratchOrgInfo passed in by the user
|
|
53
|
+
* @param projectJson - sfProjectJson
|
|
54
|
+
* @param hubOrg - the hub org, in case we need to do queries
|
|
55
|
+
*/
|
|
56
|
+
const getAncestorIds = async (scratchOrgInfo, projectJson, hubOrg) => {
|
|
57
|
+
if (Reflect.has(scratchOrgInfo, 'package2AncestorIds')) {
|
|
58
|
+
throw new sfError_1.SfError(messages.getMessage('Package2AncestorsIdsKeyNotSupportedError'), 'DeprecationError');
|
|
59
|
+
}
|
|
60
|
+
const packagesWithAncestors = (await projectJson.getPackageDirectories())
|
|
61
|
+
// check that the package has any ancestor types (id or version)
|
|
62
|
+
.filter((packageDir) => packageDir.ancestorId ?? packageDir.ancestorVersion);
|
|
63
|
+
if (packagesWithAncestors.length === 0) {
|
|
64
|
+
return '';
|
|
65
|
+
}
|
|
66
|
+
const ancestorIds = await Promise.all(packagesWithAncestors.map(async (packageDir) => {
|
|
67
|
+
// ancestorID can be 05i, or 04t, alias; OR "ancestorVersion": "4.6.0.1"
|
|
68
|
+
// according to docs, 05i is not ok: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev2gp_config_file.htm
|
|
69
|
+
// package can be an ID, but not according to docs
|
|
70
|
+
const packageAliases = projectJson.get('packageAliases');
|
|
71
|
+
const packageId = packageAliases[(0, ts_types_1.ensureString)(packageDir.package)] ?? packageDir.package;
|
|
72
|
+
// Handle HIGHEST and NONE in ancestor(Version|Id).
|
|
73
|
+
// Precedence chain: NONE -> HIGHEST -> ancestorVersion & ancestoryId
|
|
74
|
+
if (packageDir.ancestorVersion === 'NONE' || packageDir.ancestorId === 'NONE') {
|
|
75
|
+
return '';
|
|
76
|
+
}
|
|
77
|
+
else if (packageDir.ancestorVersion === 'HIGHEST' || packageDir.ancestorId === 'HIGHEST') {
|
|
78
|
+
const query = 'SELECT Id FROM Package2Version ' +
|
|
79
|
+
`WHERE Package2Id = '${packageId}' AND IsReleased = True AND IsDeprecated = False AND PatchVersion = 0 ` +
|
|
80
|
+
'ORDER BY MajorVersion Desc, MinorVersion Desc, PatchVersion Desc, BuildNumber Desc LIMIT 1';
|
|
81
|
+
try {
|
|
82
|
+
return (await hubOrg.getConnection().singleRecordQuery(query, { tooling: true })).Id;
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
if (packageDir.ancestorVersion === 'HIGHEST') {
|
|
86
|
+
throw new sfError_1.SfError(messages.getMessage('NoMatchingAncestorError', [packageDir.ancestorVersion, packageDir.package]), 'NoMatchingAncestorError', [messages.getMessage('AncestorNotReleasedError', [packageDir.ancestorVersion])]);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
throw new sfError_1.SfError(messages.getMessage('NoMatchingAncestorIdError', [packageDir.ancestorId, packageDir.package]), 'NoMatchingAncestorIdError', [messages.getMessage('AncestorNotReleasedError', [packageDir.ancestorId])]);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (packageDir.ancestorVersion) {
|
|
94
|
+
if (!/^[0-9]+.[0-9]+.[0-9]+(.[0-9]+)?$/.test(packageDir.ancestorVersion)) {
|
|
95
|
+
throw messages.createError('InvalidAncestorVersionFormatError', [packageDir.ancestorVersion]);
|
|
96
|
+
}
|
|
97
|
+
const [major, minor, patch] = packageDir.ancestorVersion.split('.');
|
|
98
|
+
let releasedAncestor;
|
|
99
|
+
try {
|
|
100
|
+
releasedAncestor = await hubOrg
|
|
101
|
+
.getConnection()
|
|
102
|
+
.singleRecordQuery(`SELECT Id, IsReleased FROM Package2Version WHERE Package2Id = '${packageId}' AND MajorVersion = ${major} AND MinorVersion = ${minor} AND PatchVersion = ${patch} and IsReleased = true`, { tooling: true });
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
throw new sfError_1.SfError(messages.getMessage('NoMatchingAncestorError', [packageDir.ancestorVersion, packageDir.package]), 'NoMatchingAncestorError', [messages.getMessage('AncestorNotReleasedError', [packageDir.ancestorVersion])]);
|
|
106
|
+
}
|
|
107
|
+
if (packageDir.ancestorId && packageDir.ancestorId !== releasedAncestor.Id) {
|
|
108
|
+
throw messages.createError('AncestorIdVersionMismatchError', [
|
|
109
|
+
packageDir.ancestorVersion,
|
|
110
|
+
packageDir.ancestorId,
|
|
111
|
+
]);
|
|
112
|
+
}
|
|
113
|
+
return releasedAncestor.Id;
|
|
114
|
+
}
|
|
115
|
+
if (packageDir?.ancestorId?.startsWith('05i')) {
|
|
116
|
+
// if it's already a 05i return it, otherwise query for it
|
|
117
|
+
return packageDir.ancestorId;
|
|
118
|
+
}
|
|
119
|
+
if (packageDir?.ancestorId?.startsWith('04t')) {
|
|
120
|
+
// query for the Id
|
|
121
|
+
return (await hubOrg
|
|
122
|
+
.getConnection()
|
|
123
|
+
.singleRecordQuery(`SELECT Id FROM Package2Version WHERE SubscriberPackageVersionId = '${packageDir.ancestorId}'`, { tooling: true })).Id;
|
|
124
|
+
}
|
|
125
|
+
// ancestorID can be an alias; get it from projectJson
|
|
126
|
+
if (packageDir.ancestorId && packageAliases?.[packageDir.ancestorId]) {
|
|
127
|
+
return packageAliases[packageDir.ancestorId];
|
|
128
|
+
}
|
|
129
|
+
throw new sfError_1.SfError(`Invalid ancestorId ${packageDir.ancestorId}`, 'InvalidAncestorId');
|
|
130
|
+
}));
|
|
131
|
+
// strip out '' due to NONE
|
|
132
|
+
return Array.from(new Set(ancestorIds.filter((id) => id !== ''))).join(';');
|
|
133
|
+
};
|
|
134
|
+
exports.getAncestorIds = getAncestorIds;
|
|
135
|
+
/**
|
|
136
|
+
* Takes in a scratchOrgInfo and fills in the missing fields
|
|
137
|
+
*
|
|
138
|
+
* @param hubOrg the environment hub org
|
|
139
|
+
* @param scratchOrgInfoPayload - the scratchOrgInfo passed in by the user
|
|
140
|
+
* @param nonamespace create the scratch org with no namespace
|
|
141
|
+
* @param ignoreAncestorIds true if the sfdx-project.json ancestorId keys should be ignored
|
|
142
|
+
*/
|
|
143
|
+
const generateScratchOrgInfo = async ({ hubOrg, scratchOrgInfoPayload, nonamespace, ignoreAncestorIds, }) => {
|
|
144
|
+
let sfProject;
|
|
145
|
+
try {
|
|
146
|
+
sfProject = await sfProject_1.SfProjectJson.create({});
|
|
147
|
+
}
|
|
148
|
+
catch (e) {
|
|
149
|
+
// project is not required
|
|
150
|
+
}
|
|
151
|
+
scratchOrgInfoPayload.orgName = scratchOrgInfoPayload.orgName ?? 'Company';
|
|
152
|
+
scratchOrgInfoPayload.package2AncestorIds =
|
|
153
|
+
!ignoreAncestorIds && sfProject?.hasPackages()
|
|
154
|
+
? await (0, exports.getAncestorIds)(scratchOrgInfoPayload, sfProject, hubOrg)
|
|
155
|
+
: '';
|
|
156
|
+
// Use the Hub org's client ID value, if one wasn't provided to us, or the default
|
|
157
|
+
if (!scratchOrgInfoPayload.connectedAppConsumerKey) {
|
|
158
|
+
scratchOrgInfoPayload.connectedAppConsumerKey =
|
|
159
|
+
hubOrg.getConnection().getAuthInfoFields().clientId ?? defaultConnectedAppInfo.clientId;
|
|
160
|
+
}
|
|
161
|
+
if (!nonamespace && sfProject?.get('namespace')) {
|
|
162
|
+
scratchOrgInfoPayload.namespace = sfProject.get('namespace');
|
|
163
|
+
}
|
|
164
|
+
// we already have the info, and want to get rid of configApi, so this doesn't use that
|
|
165
|
+
scratchOrgInfoPayload.connectedAppCallbackUrl = `http://localhost:${await webOAuthServer_1.WebOAuthServer.determineOauthPort()}/OauthRedirect`;
|
|
166
|
+
return scratchOrgInfoPayload;
|
|
167
|
+
};
|
|
168
|
+
exports.generateScratchOrgInfo = generateScratchOrgInfo;
|
|
169
|
+
/**
|
|
170
|
+
* Returns a valid signup json
|
|
171
|
+
*
|
|
172
|
+
* definitionjson org definition in JSON format
|
|
173
|
+
* definitionfile path to an org definition file
|
|
174
|
+
* connectedAppConsumerKey The connected app consumer key. May be null for JWT OAuth flow.
|
|
175
|
+
* durationdays duration of the scratch org (in days) (default:1, min:1, max:30)
|
|
176
|
+
* nonamespace create the scratch org with no namespace
|
|
177
|
+
* noancestors do not include second-generation package ancestors in the scratch org
|
|
178
|
+
* orgConfig overrides definitionjson
|
|
179
|
+
*
|
|
180
|
+
* @returns scratchOrgInfoPayload: ScratchOrgInfoPayload;
|
|
181
|
+
ignoreAncestorIds: boolean;
|
|
182
|
+
warnings: string[];
|
|
183
|
+
*/
|
|
184
|
+
const getScratchOrgInfoPayload = async (options) => {
|
|
185
|
+
let warnings = [];
|
|
186
|
+
// orgConfig input overrides definitionjson (-j option; hidden/deprecated) overrides definitionfile (-f option)
|
|
187
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
188
|
+
const scratchOrgInfoPayload = {
|
|
189
|
+
...(options.definitionfile ? await parseDefinitionFile(options.definitionfile) : {}),
|
|
190
|
+
...(options.definitionjson ? JSON.parse(options.definitionjson) : {}),
|
|
191
|
+
...(options.orgConfig ?? {}),
|
|
192
|
+
};
|
|
193
|
+
// scratchOrgInfoPayload must be heads down camelcase.
|
|
194
|
+
Object.keys(scratchOrgInfoPayload).forEach((key) => {
|
|
195
|
+
if (key[0].toUpperCase() === key[0]) {
|
|
196
|
+
throw new sfError_1.SfError('InvalidJsonCasing', key);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
// Now run the fully resolved user input against the validator
|
|
200
|
+
Object.keys(scratchOrgInfoPayload).forEach((key) => {
|
|
201
|
+
optionsValidator(key, scratchOrgInfoPayload);
|
|
202
|
+
});
|
|
203
|
+
if (options.connectedAppConsumerKey) {
|
|
204
|
+
scratchOrgInfoPayload.connectedAppConsumerKey = options.connectedAppConsumerKey;
|
|
205
|
+
}
|
|
206
|
+
scratchOrgInfoPayload.durationDays = options.durationDays;
|
|
207
|
+
// Throw warnings for deprecated scratch org features.
|
|
208
|
+
const scratchOrgFeatureDeprecation = new scratchOrgFeatureDeprecation_1.ScratchOrgFeatureDeprecation();
|
|
209
|
+
// convert various supported array and string formats to a semi-colon-delimited string
|
|
210
|
+
if (scratchOrgInfoPayload.features) {
|
|
211
|
+
if (typeof scratchOrgInfoPayload.features === 'string') {
|
|
212
|
+
scratchOrgInfoPayload.features = scratchOrgInfoPayload.features.split(/[;,]/);
|
|
213
|
+
}
|
|
214
|
+
warnings = scratchOrgFeatureDeprecation.getFeatureWarnings(scratchOrgInfoPayload.features);
|
|
215
|
+
scratchOrgInfoPayload.features = scratchOrgInfoPayload.features.map((feature) => feature.trim());
|
|
216
|
+
scratchOrgInfoPayload.features = scratchOrgFeatureDeprecation
|
|
217
|
+
.filterDeprecatedFeatures(scratchOrgInfoPayload.features)
|
|
218
|
+
.join(';');
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
scratchOrgInfoPayload,
|
|
222
|
+
// Ignore ancestor ids only when 'nonamespace' or 'noancestors' options are specified
|
|
223
|
+
ignoreAncestorIds: options.nonamespace ?? options.noancestors ?? false,
|
|
224
|
+
warnings,
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
exports.getScratchOrgInfoPayload = getScratchOrgInfoPayload;
|
|
228
|
+
const parseDefinitionFile = async (definitionFile) => {
|
|
229
|
+
try {
|
|
230
|
+
const fileData = await fs_1.promises.readFile(definitionFile, 'utf8');
|
|
231
|
+
const defFileContents = (0, kit_1.parseJson)(fileData);
|
|
232
|
+
return defFileContents;
|
|
233
|
+
}
|
|
234
|
+
catch (err) {
|
|
235
|
+
const error = err;
|
|
236
|
+
if (error.name === 'JsonParseError') {
|
|
237
|
+
throw new sfError_1.SfError(`An error occurred parsing ${definitionFile}`);
|
|
238
|
+
}
|
|
239
|
+
throw sfError_1.SfError.wrap(error);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
242
|
//# sourceMappingURL=scratchOrgInfoGenerator.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { AuthFields } from './authInfo';
|
|
2
|
-
import { ScratchOrgInfo } from './scratchOrgTypes';
|
|
3
|
-
export declare const scratchOrgLifecycleEventName = "scratchOrgLifecycleEvent";
|
|
4
|
-
export declare const scratchOrgLifecycleStages: readonly ["prepare request", "send request", "wait for org", "available", "authenticate", "deploy settings", "done"];
|
|
5
|
-
export interface ScratchOrgLifecycleEvent {
|
|
6
|
-
stage: typeof scratchOrgLifecycleStages[number];
|
|
7
|
-
scratchOrgInfo?: ScratchOrgInfo;
|
|
8
|
-
}
|
|
9
|
-
export declare const emit: (event: ScratchOrgLifecycleEvent) => Promise<void>;
|
|
10
|
-
export declare const emitPostOrgCreate: (authFields: AuthFields) => Promise<void>;
|
|
1
|
+
import { AuthFields } from './authInfo';
|
|
2
|
+
import { ScratchOrgInfo } from './scratchOrgTypes';
|
|
3
|
+
export declare const scratchOrgLifecycleEventName = "scratchOrgLifecycleEvent";
|
|
4
|
+
export declare const scratchOrgLifecycleStages: readonly ["prepare request", "send request", "wait for org", "available", "authenticate", "deploy settings", "done"];
|
|
5
|
+
export interface ScratchOrgLifecycleEvent {
|
|
6
|
+
stage: typeof scratchOrgLifecycleStages[number];
|
|
7
|
+
scratchOrgInfo?: ScratchOrgInfo;
|
|
8
|
+
}
|
|
9
|
+
export declare const emit: (event: ScratchOrgLifecycleEvent) => Promise<void>;
|
|
10
|
+
export declare const emitPostOrgCreate: (authFields: AuthFields) => Promise<void>;
|