@salesforce/core 9.1.10 → 9.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config/envVars.d.ts +2 -1
- package/lib/config/envVars.js +6 -1
- package/lib/org/authInfo.js +78 -17
- package/messages/envVars.md +4 -0
- package/package.json +1 -1
package/lib/config/envVars.d.ts
CHANGED
|
@@ -77,7 +77,8 @@ export declare enum EnvironmentVariable {
|
|
|
77
77
|
'SF_UPDATE_INSTRUCTIONS' = "SF_UPDATE_INSTRUCTIONS",
|
|
78
78
|
'SF_INSTALLER' = "SF_INSTALLER",
|
|
79
79
|
'SF_ENV' = "SF_ENV",
|
|
80
|
-
'SF_CAPITALIZE_RECORD_TYPES' = "SF_CAPITALIZE_RECORD_TYPES"
|
|
80
|
+
'SF_CAPITALIZE_RECORD_TYPES' = "SF_CAPITALIZE_RECORD_TYPES",
|
|
81
|
+
'SF_SKIP_SCRATCH_ORG_CHECK' = "SF_SKIP_SCRATCH_ORG_CHECK"
|
|
81
82
|
}
|
|
82
83
|
type EnvMetaData = {
|
|
83
84
|
description: string;
|
package/lib/config/envVars.js
CHANGED
|
@@ -22,7 +22,7 @@ const kit_1 = require("@salesforce/kit");
|
|
|
22
22
|
const messages_1 = require("../messages");
|
|
23
23
|
const lifecycleEvents_1 = require("../lifecycleEvents");
|
|
24
24
|
;
|
|
25
|
-
const messages = new messages_1.Messages('@salesforce/core', 'envVars', new Map([["forceOpenUrl", "Web page that opens in your browser when you connect to an org. For example, to open Lightning Experience, set to \"lightning\"."], ["forceShowSpinner", "Set to true to show a spinner animation on the command line when running asynchronous CLI commands. Default is false."], ["forceSpinnerDelay", "Speed of the spinner in milliseconds. Default is 60."], ["httpProxy", "HTTP URL and port of the proxy server when using Salesforce CLI behind a corporate firewall or web proxy."], ["httpsProxy", "HTTPS URL and port of the proxy server when using Salesforce CLI behind a corporate firewall or web proxy."], ["nodeExtraCaCerts", "Fully qualified path to your self-signed certificate. Will be installed after you run \"sfdx update\"."], ["nodeTlsRejectUnauthorized", "Set to 0 to allow Node.js to use the self-signed certificate in the certificate chain."], ["sfdxAccessToken", "Specifies an access token when using the auth:accesstoken:store command."], ["sfdxApiVersion", "The API version for a specific project or all projects. Default value is the API version of your Dev Hub. Overrides the apiVersion config value."], ["sfdxAudienceUrl", "URL that overrides the aud (audience) field used for JWT authentication so that it matches the expected value of the authorization server URL for the org you\u2019re logging into."], ["sfdxCodeCoverageRequirement", "Code coverage percentages that are displayed in green when you run force:apex:test:\\* with the --codecoverage parameter."], ["sfdxContentType", "Set to JSON so that all CLI commands output results in JSON format."], ["sfdxDefaultdevhubusername", "Username or alias of your default Dev Hub org. Overrides the defaultdevhubusername configuration value."], ["sfdxDefaultusername", "Username or alias of your default org. Overrides the defaultusername configuration value."], ["sfdxDisableAutoupdate", "Set to true to disable the auto-update feature of Salesforce CLI. Default value is false."], ["sfdxAutoupdateDisable", "Set to true to disable the auto-update feature of Salesforce CLI. Default value is false."], ["sfdxDisableSourceMemberPolling", "Set to true to disable polling of your org\u2019s SourceMember object when you run the force:source:push|pull commands. Default value is false."], ["sfdxSourceTrackingBatchSize", "Number of source-tracked file updates to batch after a deploy or retrieve. The default value is 8,000 (Windows) or 15,000 (Linux/macOS)."], ["sfdxDisableTelemetry", "Set to true to disable Salesforce CLI from collecting usage information, user environment information, and crash reports. Default value is false. Overrides the disableTelemetry configration variable."], ["sfdxDnsTimeout", "Number of seconds that the force:org:\\* commands wait for a response when checking whether an org is connected. Default value is 3."], ["sfdxDomainRetry", "Time, in seconds, that Salesforce CLI waits for the Lightning Experience custom domain to resolve and become available in a scratch org. Default value is 240."], ["sfdxImprovedCodeCoverage", "Set to true to scope Apex test results to the classes entered during a test run when running force:apex:test:\\*."], ["sfdxInstanceUrl", "URL of the Salesforce instance that is hosting your org. Default value is https://login.salesforce.com. Overrides the instanceUrl configuration value."], ["sfdxJsonToStdout", "Set to true to send messages resulting from failed Salesforce CLI commands to stdout instead of stderr."], ["sfdxDisableLogFile", "Set to true to disable log file writing"], ["sfdxLogLevel", "Level of messages that the CLI writes to the log file. Valid values are trace, debug, info, warn, error, fatal. Default value is warn."], ["sfdxLogRotationCount", "The default rotation period for logs. Example '1d' will rotate logs daily (at midnight)."], ["sfdxLogRotationPeriod", "The number of backup rotated log files to keep. Example: '3' will have the base sf.log file, and the past 3 (period) log files."], ["sfdxMaxQueryLimit", "Maximum number of Salesforce records returned by a CLI command. Default value is 10,000. Overrides the maxQueryLimit configuration value."], ["sfdxMdapiTempDir", "Directory that contains files (in metadata format) when running certain Salesforce CLI commands, such as force:source:\\*."], ["sfdxNpmRegistry", "URL to a private npm server, where all packages that you publish are private."], ["sfdxPrecompileEnable", "Set to true to enable Apex pre-compile before the tests are run with the force:apex:test:run command. Default is false."], ["sfdxProjectAutoupdateDisableForPackageCreate", "Set to true to disable automatic updates to sfdx-project.json when running force:package:create."], ["sfdxProjectAutoupdateDisableForPackageVersionCreate", "Set to true to disable automatic updates to sfdx-project.json when running force:package:version:create."], ["sfdxRestDeploy", "Set to true to make Salesforce CLI use the Metadata REST API for deployments. By default, the CLI uses SOAP."], ["sfdxSourceMemberPollingTimeout", "Number of seconds you want the force:source:push command to keep polling the SourceMember object before the command times out."], ["sfdxUseGenericUnixKeychain", "(Linux and macOS only) Set to true if you want to use the generic UNIX keychain instead of the Linux libsecret library or macOS keychain."], ["sfdxUseProgressBar", "Set to false to disable the progress bar when running force:mdapi:deploy, force:source:deploy, or force:source:push."], ["sfdxLazyLoadModules", "Set to true to enable lazy loading of sfdx modules"], ["sfdxS3Host", "URL to S3 host"], ["sfdxUpdateInstructions", "Text that describes how to update sfdx"], ["sfdxInstaller", "Boolean indicating that the installer is running"], ["sfdxEnv", "Describes if sfdx is in \"demo\" mode"], ["sfTargetOrg", "Username or alias of your default org. Overrides the target-org configuration variable."], ["sfTargetDevHub", "Username or alias of your default Dev Hub org. Overrides the target-dev-hub configuration variable."], ["sfAccessToken", "Specifies an access token when using a login command that uses access tokens."], ["sfOrgApiVersion", "API version for a specific project or all projects. Default value is the API version of your Dev Hub. Overrides the apiVersion configuration variable."], ["sfAudienceUrl", "URL that overrides the aud (audience) field used for JWT authentication so that it matches the expected value of the authorization server URL for the org you\u2019re logging into."], ["sfCodeCoverageRequirement", "Code coverage percentages that are displayed in green when you run the Apex test CLIcommands with the --code-coverage flag."], ["sfContentType", "Set to JSON so that all CLI commands output results in JSON format."], ["sfDisableAutoupdate", "Set to true to disable the auto-update feature of Salesforce CLI. Default value is false."], ["sfAutoupdateDisable", "Set to true to disable the auto-update feature of Salesforce CLI. Default value is false."], ["sfDisableSourceMemberPolling", "Set to true to disable polling of your org\u2019s SourceMember object when you run the commands to push and pull source. Default value is false."], ["sfDisableTelemetry", "Set to true to disable Salesforce CLI from collecting usage information, user environment information, and crash reports. Default value is false. Overrides the disableTelemetry configration variable."], ["sfDnsTimeout", "Number of seconds that the env commands wait for a response when checking whether an org is connected. Default value is 3."], ["sfDomainRetry", "Time, in seconds, that Salesforce CLI waits for the Lightning Experience custom domain to resolve and become available in a scratch org. Default value is 240."], ["sfImprovedCodeCoverage", "Set to true to scope Apex test results to the classes entered during a test run when running the Apex test commands."], ["sfOrgInstanceUrl", "URL of the Salesforce instance that is hosting your org. Default value is https://login.salesforce.com. Overrides the instanceUrl configuration variable."], ["sfJsonToStdout", "Set to true to send messages resulting from failed Salesforce CLI commands to stdout instead of stderr."], ["sfDisableLogFile", "Set to true to disable log file writing"], ["sfLogLevel", "Level of messages that the CLI writes to the log file. Valid values are trace, debug, info, warn, error, fatal. Default value is warn."], ["sfLogRotationCount", "The default rotation period for logs. Example '1d' will rotate logs daily (at midnight)."], ["sfLogRotationPeriod", "The number of backup rotated log files to keep. Example: '3' will have the base sf.log file, and the past 3 (period) log files."], ["sfOrgMaxQueryLimit", "Maximum number of Salesforce records returned by a CLI command. Default value is 10,000. Overrides the maxQueryLimit configuration variable."], ["sfMdapiTempDir", "Directory that contains files (in metadata format) when running certain Salesforce CLI commands."], ["sfNpmRegistry", "URL to a private npm server, where all packages that you publish are private."], ["sfPrecompileEnable", "Set to true to enable Apex pre-compile before the tests are run with the Apex test run command. Default is false."], ["sfProjectAutoupdateDisableForPackageCreate", "Set to true to disable automatic updates to sfdx-project.json when running the package create command."], ["sfProjectAutoupdateDisableForPackageVersionCreate", "Set to true to disable automatic updates to sfdx-project.json when running the package version create command."], ["sfSourceMemberPollingTimeout", "Number of seconds you want the source push command to keep polling the SourceMember object before the command times out."], ["sfUseGenericUnixKeychain", "(Linux and macOS only) Set to true if you want to use the generic UNIX keychain instead of the Linux libsecret library or macOS keychain."], ["sfUseProgressBar", "Set to false to disable the progress bar when running the metadata deploy command."], ["sfLazyLoadModules", "Set to true to enable lazy loading of sf modules"], ["sfS3Host", "URL to S3 host"], ["sfUpdateInstructions", "Text that describes how to update sf"], ["sfInstaller", "Boolean indicating that the installer is running"], ["sfEnv", "Describes if sf is in \"demo\" mode"], ["deprecatedEnv", "Deprecated environment variable: %s. Please use %s instead."], ["deprecatedEnvDisagreement", "Deprecated environment variable: %s. Please use %s instead.\n\nYour environment has both variables populated, and with different values. The value from %s will be used."], ["sfCapitalizeRecordTypes", "Whether record types are capitalized on scratch org creation."]]));
|
|
25
|
+
const messages = new messages_1.Messages('@salesforce/core', 'envVars', new Map([["forceOpenUrl", "Web page that opens in your browser when you connect to an org. For example, to open Lightning Experience, set to \"lightning\"."], ["forceShowSpinner", "Set to true to show a spinner animation on the command line when running asynchronous CLI commands. Default is false."], ["forceSpinnerDelay", "Speed of the spinner in milliseconds. Default is 60."], ["httpProxy", "HTTP URL and port of the proxy server when using Salesforce CLI behind a corporate firewall or web proxy."], ["httpsProxy", "HTTPS URL and port of the proxy server when using Salesforce CLI behind a corporate firewall or web proxy."], ["nodeExtraCaCerts", "Fully qualified path to your self-signed certificate. Will be installed after you run \"sfdx update\"."], ["nodeTlsRejectUnauthorized", "Set to 0 to allow Node.js to use the self-signed certificate in the certificate chain."], ["sfdxAccessToken", "Specifies an access token when using the auth:accesstoken:store command."], ["sfdxApiVersion", "The API version for a specific project or all projects. Default value is the API version of your Dev Hub. Overrides the apiVersion config value."], ["sfdxAudienceUrl", "URL that overrides the aud (audience) field used for JWT authentication so that it matches the expected value of the authorization server URL for the org you\u2019re logging into."], ["sfdxCodeCoverageRequirement", "Code coverage percentages that are displayed in green when you run force:apex:test:\\* with the --codecoverage parameter."], ["sfdxContentType", "Set to JSON so that all CLI commands output results in JSON format."], ["sfdxDefaultdevhubusername", "Username or alias of your default Dev Hub org. Overrides the defaultdevhubusername configuration value."], ["sfdxDefaultusername", "Username or alias of your default org. Overrides the defaultusername configuration value."], ["sfdxDisableAutoupdate", "Set to true to disable the auto-update feature of Salesforce CLI. Default value is false."], ["sfdxAutoupdateDisable", "Set to true to disable the auto-update feature of Salesforce CLI. Default value is false."], ["sfdxDisableSourceMemberPolling", "Set to true to disable polling of your org\u2019s SourceMember object when you run the force:source:push|pull commands. Default value is false."], ["sfdxSourceTrackingBatchSize", "Number of source-tracked file updates to batch after a deploy or retrieve. The default value is 8,000 (Windows) or 15,000 (Linux/macOS)."], ["sfdxDisableTelemetry", "Set to true to disable Salesforce CLI from collecting usage information, user environment information, and crash reports. Default value is false. Overrides the disableTelemetry configration variable."], ["sfdxDnsTimeout", "Number of seconds that the force:org:\\* commands wait for a response when checking whether an org is connected. Default value is 3."], ["sfdxDomainRetry", "Time, in seconds, that Salesforce CLI waits for the Lightning Experience custom domain to resolve and become available in a scratch org. Default value is 240."], ["sfdxImprovedCodeCoverage", "Set to true to scope Apex test results to the classes entered during a test run when running force:apex:test:\\*."], ["sfdxInstanceUrl", "URL of the Salesforce instance that is hosting your org. Default value is https://login.salesforce.com. Overrides the instanceUrl configuration value."], ["sfdxJsonToStdout", "Set to true to send messages resulting from failed Salesforce CLI commands to stdout instead of stderr."], ["sfdxDisableLogFile", "Set to true to disable log file writing"], ["sfdxLogLevel", "Level of messages that the CLI writes to the log file. Valid values are trace, debug, info, warn, error, fatal. Default value is warn."], ["sfdxLogRotationCount", "The default rotation period for logs. Example '1d' will rotate logs daily (at midnight)."], ["sfdxLogRotationPeriod", "The number of backup rotated log files to keep. Example: '3' will have the base sf.log file, and the past 3 (period) log files."], ["sfdxMaxQueryLimit", "Maximum number of Salesforce records returned by a CLI command. Default value is 10,000. Overrides the maxQueryLimit configuration value."], ["sfdxMdapiTempDir", "Directory that contains files (in metadata format) when running certain Salesforce CLI commands, such as force:source:\\*."], ["sfdxNpmRegistry", "URL to a private npm server, where all packages that you publish are private."], ["sfdxPrecompileEnable", "Set to true to enable Apex pre-compile before the tests are run with the force:apex:test:run command. Default is false."], ["sfdxProjectAutoupdateDisableForPackageCreate", "Set to true to disable automatic updates to sfdx-project.json when running force:package:create."], ["sfdxProjectAutoupdateDisableForPackageVersionCreate", "Set to true to disable automatic updates to sfdx-project.json when running force:package:version:create."], ["sfdxRestDeploy", "Set to true to make Salesforce CLI use the Metadata REST API for deployments. By default, the CLI uses SOAP."], ["sfdxSourceMemberPollingTimeout", "Number of seconds you want the force:source:push command to keep polling the SourceMember object before the command times out."], ["sfdxUseGenericUnixKeychain", "(Linux and macOS only) Set to true if you want to use the generic UNIX keychain instead of the Linux libsecret library or macOS keychain."], ["sfdxUseProgressBar", "Set to false to disable the progress bar when running force:mdapi:deploy, force:source:deploy, or force:source:push."], ["sfdxLazyLoadModules", "Set to true to enable lazy loading of sfdx modules"], ["sfdxS3Host", "URL to S3 host"], ["sfdxUpdateInstructions", "Text that describes how to update sfdx"], ["sfdxInstaller", "Boolean indicating that the installer is running"], ["sfdxEnv", "Describes if sfdx is in \"demo\" mode"], ["sfTargetOrg", "Username or alias of your default org. Overrides the target-org configuration variable."], ["sfTargetDevHub", "Username or alias of your default Dev Hub org. Overrides the target-dev-hub configuration variable."], ["sfAccessToken", "Specifies an access token when using a login command that uses access tokens."], ["sfOrgApiVersion", "API version for a specific project or all projects. Default value is the API version of your Dev Hub. Overrides the apiVersion configuration variable."], ["sfAudienceUrl", "URL that overrides the aud (audience) field used for JWT authentication so that it matches the expected value of the authorization server URL for the org you\u2019re logging into."], ["sfCodeCoverageRequirement", "Code coverage percentages that are displayed in green when you run the Apex test CLIcommands with the --code-coverage flag."], ["sfContentType", "Set to JSON so that all CLI commands output results in JSON format."], ["sfDisableAutoupdate", "Set to true to disable the auto-update feature of Salesforce CLI. Default value is false."], ["sfAutoupdateDisable", "Set to true to disable the auto-update feature of Salesforce CLI. Default value is false."], ["sfDisableSourceMemberPolling", "Set to true to disable polling of your org\u2019s SourceMember object when you run the commands to push and pull source. Default value is false."], ["sfDisableTelemetry", "Set to true to disable Salesforce CLI from collecting usage information, user environment information, and crash reports. Default value is false. Overrides the disableTelemetry configration variable."], ["sfDnsTimeout", "Number of seconds that the env commands wait for a response when checking whether an org is connected. Default value is 3."], ["sfDomainRetry", "Time, in seconds, that Salesforce CLI waits for the Lightning Experience custom domain to resolve and become available in a scratch org. Default value is 240."], ["sfImprovedCodeCoverage", "Set to true to scope Apex test results to the classes entered during a test run when running the Apex test commands."], ["sfOrgInstanceUrl", "URL of the Salesforce instance that is hosting your org. Default value is https://login.salesforce.com. Overrides the instanceUrl configuration variable."], ["sfJsonToStdout", "Set to true to send messages resulting from failed Salesforce CLI commands to stdout instead of stderr."], ["sfDisableLogFile", "Set to true to disable log file writing"], ["sfLogLevel", "Level of messages that the CLI writes to the log file. Valid values are trace, debug, info, warn, error, fatal. Default value is warn."], ["sfLogRotationCount", "The default rotation period for logs. Example '1d' will rotate logs daily (at midnight)."], ["sfLogRotationPeriod", "The number of backup rotated log files to keep. Example: '3' will have the base sf.log file, and the past 3 (period) log files."], ["sfOrgMaxQueryLimit", "Maximum number of Salesforce records returned by a CLI command. Default value is 10,000. Overrides the maxQueryLimit configuration variable."], ["sfMdapiTempDir", "Directory that contains files (in metadata format) when running certain Salesforce CLI commands."], ["sfNpmRegistry", "URL to a private npm server, where all packages that you publish are private."], ["sfPrecompileEnable", "Set to true to enable Apex pre-compile before the tests are run with the Apex test run command. Default is false."], ["sfProjectAutoupdateDisableForPackageCreate", "Set to true to disable automatic updates to sfdx-project.json when running the package create command."], ["sfProjectAutoupdateDisableForPackageVersionCreate", "Set to true to disable automatic updates to sfdx-project.json when running the package version create command."], ["sfSourceMemberPollingTimeout", "Number of seconds you want the source push command to keep polling the SourceMember object before the command times out."], ["sfUseGenericUnixKeychain", "(Linux and macOS only) Set to true if you want to use the generic UNIX keychain instead of the Linux libsecret library or macOS keychain."], ["sfUseProgressBar", "Set to false to disable the progress bar when running the metadata deploy command."], ["sfLazyLoadModules", "Set to true to enable lazy loading of sf modules"], ["sfS3Host", "URL to S3 host"], ["sfUpdateInstructions", "Text that describes how to update sf"], ["sfInstaller", "Boolean indicating that the installer is running"], ["sfEnv", "Describes if sf is in \"demo\" mode"], ["deprecatedEnv", "Deprecated environment variable: %s. Please use %s instead."], ["deprecatedEnvDisagreement", "Deprecated environment variable: %s. Please use %s instead.\n\nYour environment has both variables populated, and with different values. The value from %s will be used."], ["sfCapitalizeRecordTypes", "Whether record types are capitalized on scratch org creation."], ["sfSkipScratchOrgCheck", "Set to \"true\" to skip the scratch org and sandbox identification check that runs after authenticating an org. When enabled, `sf org login jwt` (and other login commands) will not query existing cached orgs to determine whether the newly authenticated org is a scratch org or sandbox. This can significantly speed up authentication in CI/CD environments with many cached org authorizations."]]));
|
|
26
26
|
var EnvironmentVariable;
|
|
27
27
|
(function (EnvironmentVariable) {
|
|
28
28
|
EnvironmentVariable["FORCE_OPEN_URL"] = "FORCE_OPEN_URL";
|
|
@@ -102,6 +102,7 @@ var EnvironmentVariable;
|
|
|
102
102
|
EnvironmentVariable["SF_INSTALLER"] = "SF_INSTALLER";
|
|
103
103
|
EnvironmentVariable["SF_ENV"] = "SF_ENV";
|
|
104
104
|
EnvironmentVariable["SF_CAPITALIZE_RECORD_TYPES"] = "SF_CAPITALIZE_RECORD_TYPES";
|
|
105
|
+
EnvironmentVariable["SF_SKIP_SCRATCH_ORG_CHECK"] = "SF_SKIP_SCRATCH_ORG_CHECK";
|
|
105
106
|
})(EnvironmentVariable || (exports.EnvironmentVariable = EnvironmentVariable = {}));
|
|
106
107
|
const getMessage = (environmentVariable) => messages.getMessage((0, change_case_1.camelCase)(environmentVariable));
|
|
107
108
|
exports.SUPPORTED_ENV_VARS = {
|
|
@@ -416,6 +417,10 @@ exports.SUPPORTED_ENV_VARS = {
|
|
|
416
417
|
description: getMessage(EnvironmentVariable.SF_CAPITALIZE_RECORD_TYPES),
|
|
417
418
|
synonymOf: null,
|
|
418
419
|
},
|
|
420
|
+
[EnvironmentVariable.SF_SKIP_SCRATCH_ORG_CHECK]: {
|
|
421
|
+
description: getMessage(EnvironmentVariable.SF_SKIP_SCRATCH_ORG_CHECK),
|
|
422
|
+
synonymOf: null,
|
|
423
|
+
},
|
|
419
424
|
};
|
|
420
425
|
class EnvVars extends kit_1.Env {
|
|
421
426
|
constructor(env = process.env) {
|
package/lib/org/authInfo.js
CHANGED
|
@@ -185,22 +185,25 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
185
185
|
// prevent ConfigFile collision bug
|
|
186
186
|
// eslint-disable-next-line no-await-in-loop
|
|
187
187
|
const authInfo = await AuthInfo.create({ username });
|
|
188
|
-
const
|
|
188
|
+
const authFields = authInfo.getFields();
|
|
189
|
+
const { orgId, instanceUrl, devHubUsername, expirationDate, isDevHub } = authFields;
|
|
190
|
+
const isScratchOrg = Boolean(devHubUsername) || Boolean(authFields[org_1.Org.Fields.IS_SCRATCH]);
|
|
191
|
+
const expDate = expirationDate ?? authFields[org_1.Org.Fields.TRIAL_EXPIRATION_DATE];
|
|
192
|
+
// eslint-disable-next-line no-await-in-loop
|
|
193
|
+
const hasSandboxFile = await stateAggregator.sandboxes.hasFile(orgId);
|
|
194
|
+
const isSandbox = Boolean(authFields[org_1.Org.Fields.IS_SANDBOX]) || hasSandboxFile;
|
|
189
195
|
final.push({
|
|
190
196
|
aliases,
|
|
191
197
|
configs,
|
|
192
198
|
username,
|
|
193
199
|
instanceUrl,
|
|
194
|
-
isScratchOrg
|
|
200
|
+
isScratchOrg,
|
|
195
201
|
isDevHub: isDevHub ?? false,
|
|
196
|
-
|
|
197
|
-
isSandbox: await stateAggregator.sandboxes.hasFile(orgId),
|
|
202
|
+
isSandbox,
|
|
198
203
|
orgId: orgId,
|
|
199
204
|
accessToken: authInfo.getConnectionOptions().accessToken,
|
|
200
205
|
oauthMethod: authInfo.isJwt() ? 'jwt' : authInfo.isOauth() ? 'web' : 'token',
|
|
201
|
-
isExpired:
|
|
202
|
-
? new Date((0, ts_types_1.ensureString)(expirationDate)).getTime() < new Date().getTime()
|
|
203
|
-
: 'unknown',
|
|
206
|
+
isExpired: isScratchOrg && expDate ? new Date((0, ts_types_1.ensureString)(expDate)).getTime() < new Date().getTime() : 'unknown',
|
|
204
207
|
});
|
|
205
208
|
}
|
|
206
209
|
catch (err) {
|
|
@@ -283,31 +286,83 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
283
286
|
* @param orgAuthInfo
|
|
284
287
|
*/
|
|
285
288
|
static async identifyPossibleScratchOrgs(fields, orgAuthInfo) {
|
|
289
|
+
if (kit_1.env.getBoolean('SF_SKIP_SCRATCH_ORG_CHECK')) {
|
|
290
|
+
(await logger_1.Logger.child('Common', { tag: 'identifyPossibleScratchOrgs' })).debug('Skipping scratch org identification due to SF_SKIP_SCRATCH_ORG_CHECK');
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
286
293
|
// fields property is passed in because the consumers of this method have performed the decrypt.
|
|
287
294
|
// This is so we don't have to call authInfo.getFields(true) and decrypt again OR accidentally save an
|
|
288
295
|
// authInfo before it is necessary.
|
|
289
296
|
const logger = await logger_1.Logger.child('Common', { tag: 'identifyPossibleScratchOrgs' });
|
|
290
297
|
await (0, determineOrg_1.determineOrg)(orgAuthInfo);
|
|
298
|
+
// re-read fields after determineOrg may have updated them
|
|
299
|
+
const updatedFields = orgAuthInfo.getFields();
|
|
291
300
|
// return if we already know the hub org, we know it is a devhub or prod-like, or no orgId present
|
|
292
|
-
if (Boolean(
|
|
301
|
+
if (Boolean(updatedFields.isDevHub) || Boolean(updatedFields.devHubUsername) || !updatedFields.orgId)
|
|
293
302
|
return;
|
|
303
|
+
if (updatedFields.isSandbox) {
|
|
304
|
+
logger.debug('determineOrg already identified org as sandbox, skipping expensive org scan');
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
// for scratch orgs, skip the full listAllAuthorizations + sandbox identification and
|
|
308
|
+
// instead do a lightweight DevHub lookup using raw configs (no AuthInfo creation/decryption)
|
|
309
|
+
if (updatedFields.isScratch) {
|
|
310
|
+
logger.debug('determineOrg identified org as scratch, doing lightweight DevHub lookup');
|
|
311
|
+
const stateAggregator = await stateAggregator_1.StateAggregator.getInstance();
|
|
312
|
+
const allConfigs = await stateAggregator.orgs.readAll();
|
|
313
|
+
const devHubUsernames = allConfigs.filter((c) => c.isDevHub).map((c) => (0, ts_types_1.ensureString)(c.username));
|
|
314
|
+
for (const hubUsername of devHubUsernames) {
|
|
315
|
+
try {
|
|
316
|
+
// eslint-disable-next-line no-await-in-loop
|
|
317
|
+
const soi = await AuthInfo.queryScratchOrg(hubUsername, updatedFields.orgId);
|
|
318
|
+
// eslint-disable-next-line no-await-in-loop
|
|
319
|
+
await orgAuthInfo.save({
|
|
320
|
+
...fields,
|
|
321
|
+
devHubUsername: hubUsername,
|
|
322
|
+
expirationDate: soi.ExpirationDate,
|
|
323
|
+
isScratch: true,
|
|
324
|
+
});
|
|
325
|
+
logger.debug(`set ${hubUsername} as devhub for scratch org ${orgAuthInfo.getUsername()}`);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
catch (error) {
|
|
329
|
+
if (error instanceof Error && error.name === 'NoActiveScratchOrgFound') {
|
|
330
|
+
logger.debug(`devhub ${hubUsername} does not own this scratch org`);
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
logger.debug(`Error connecting to devhub ${hubUsername}`, error);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
294
339
|
logger.debug('getting devHubs and prod orgs to identify scratch orgs and sandboxes');
|
|
295
|
-
// TODO: return if url is not sandbox-like to avoid constantly asking about production orgs
|
|
296
340
|
// TODO: someday we make this easier by asking the org if it is a scratch org
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
341
|
+
const allOrgs = await AuthInfo.listAllAuthorizations();
|
|
342
|
+
const hubAuthInfos = allOrgs.filter((org) => org.isDevHub);
|
|
343
|
+
// skip sandbox identification if the instance URL is not sandbox-like
|
|
344
|
+
// enhanced domains: *.sandbox.my.salesforce.com; pre-enhanced My Domain: company--sbxname.my.salesforce.com
|
|
345
|
+
const isSandboxLikeUrl = fields.instanceUrl != null && (fields.instanceUrl.includes('.sandbox.') || fields.instanceUrl.includes('--'));
|
|
346
|
+
const possibleProdOrgs = isSandboxLikeUrl ? allOrgs.filter((org) => !org.isScratchOrg && !org.isSandbox) : [];
|
|
347
|
+
if (!isSandboxLikeUrl) {
|
|
348
|
+
logger.debug('instance URL is not sandbox-like, skipping sandbox identification');
|
|
349
|
+
}
|
|
300
350
|
logger.debug(`found ${hubAuthInfos.length} DevHubs`);
|
|
301
351
|
logger.debug(`found ${possibleProdOrgs.length} possible prod orgs`);
|
|
302
352
|
if (hubAuthInfos.length === 0 && possibleProdOrgs.length === 0) {
|
|
303
353
|
return;
|
|
304
354
|
}
|
|
305
|
-
|
|
355
|
+
let identified = false;
|
|
356
|
+
// ask all those orgs if they know this orgId, but stop once one claims it
|
|
306
357
|
await Promise.all([
|
|
307
358
|
...hubAuthInfos.map(async (hubAuthInfo) => {
|
|
359
|
+
if (identified)
|
|
360
|
+
return;
|
|
308
361
|
try {
|
|
309
362
|
const soi = await AuthInfo.queryScratchOrg(hubAuthInfo.username, fields.orgId);
|
|
310
|
-
|
|
363
|
+
if (identified)
|
|
364
|
+
return;
|
|
365
|
+
identified = true;
|
|
311
366
|
logger.debug(`found orgId ${fields.orgId ?? '<undefined>'} in devhub ${hubAuthInfo.username}`);
|
|
312
367
|
try {
|
|
313
368
|
await orgAuthInfo.save({
|
|
@@ -332,7 +387,11 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
332
387
|
}
|
|
333
388
|
}),
|
|
334
389
|
...possibleProdOrgs.map(async (pOrgAuthInfo) => {
|
|
335
|
-
|
|
390
|
+
if (identified)
|
|
391
|
+
return;
|
|
392
|
+
const found = await AuthInfo.identifyPossibleSandbox(pOrgAuthInfo, fields, orgAuthInfo, logger);
|
|
393
|
+
if (found)
|
|
394
|
+
identified = true;
|
|
336
395
|
}),
|
|
337
396
|
]);
|
|
338
397
|
}
|
|
@@ -344,13 +403,13 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
344
403
|
}
|
|
345
404
|
static async identifyPossibleSandbox(possibleProdOrg, fields, orgAuthInfo, logger) {
|
|
346
405
|
if (!fields.orgId) {
|
|
347
|
-
return;
|
|
406
|
+
return false;
|
|
348
407
|
}
|
|
349
408
|
try {
|
|
350
409
|
const prodOrg = await org_1.Org.create({ aliasOrUsername: possibleProdOrg.username });
|
|
351
410
|
const sbxProcess = await prodOrg.querySandboxProcessByOrgId(fields.orgId);
|
|
352
411
|
if (!sbxProcess?.SandboxInfoId) {
|
|
353
|
-
return;
|
|
412
|
+
return false;
|
|
354
413
|
}
|
|
355
414
|
logger.debug(`${fields.orgId} is a sandbox of ${possibleProdOrg.username}`);
|
|
356
415
|
try {
|
|
@@ -383,9 +442,11 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
|
|
|
383
442
|
catch (e) {
|
|
384
443
|
logger.debug(`error writing sandbox auth file for: ${orgAuthInfo.getUsername()}`, e);
|
|
385
444
|
}
|
|
445
|
+
return true;
|
|
386
446
|
}
|
|
387
447
|
catch (err) {
|
|
388
448
|
logger.debug(`${fields.orgId} is not a sandbox of ${possibleProdOrg.username}`);
|
|
449
|
+
return false;
|
|
389
450
|
}
|
|
390
451
|
}
|
|
391
452
|
/**
|
package/messages/envVars.md
CHANGED
|
@@ -319,3 +319,7 @@ Your environment has both variables populated, and with different values. The va
|
|
|
319
319
|
# sfCapitalizeRecordTypes
|
|
320
320
|
|
|
321
321
|
Whether record types are capitalized on scratch org creation.
|
|
322
|
+
|
|
323
|
+
# sfSkipScratchOrgCheck
|
|
324
|
+
|
|
325
|
+
Set to "true" to skip the scratch org and sandbox identification check that runs after authenticating an org. When enabled, `sf org login jwt` (and other login commands) will not query existing cached orgs to determine whether the newly authenticated org is a scratch org or sandbox. This can significantly speed up authentication in CI/CD environments with many cached org authorizations.
|