UNPKG

@salesforce/plugin-org

Version:

Commands to interact with Salesforce orgs

44 lines 1.91 kB
/* * Copyright 2026, Salesforce, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import open from 'open'; import { Logger, Messages, SfError } from '@salesforce/core'; import { Duration } from '@salesforce/kit'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); const messages = Messages.loadMessages('@salesforce/plugin-org', 'open'); export const openUrl = async (url, options) => open(url, options); export const handleDomainError = (err, url, env) => { if (err instanceof Error) { if (err.message.includes('timeout')) { const host = /https?:\/\/([^.]*)/.exec(url)?.[1]; if (!host) { throw new SfError('InvalidUrl', 'InvalidUrl'); } const domain = `https://${host}.lightning.force.com`; const domainRetryTimeout = env.getNumber('SF_DOMAIN_RETRY') ?? env.getNumber('SFDX_DOMAIN_RETRY', 240); const timeout = new Duration(domainRetryTimeout, Duration.Unit.SECONDS); const logger = Logger.childFromRoot('org:open'); logger.debug(`Did not find IP for ${domain} after ${timeout.seconds} seconds`); throw new SfError(messages.getMessage('domainTimeoutError'), 'domainTimeoutError'); } throw SfError.wrap(err); } throw err; }; export default { openUrl, handleDomainError, }; //# sourceMappingURL=orgOpenUtils.js.map