Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@salesforce/plugin-org

Package Overview
Dependencies
Maintainers
47
Versions
334
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salesforce/plugin-org - npm Package Compare versions

Comparing version 5.1.5-beta.0 to 5.1.5

12

lib/commands/org/delete/scratch.js

@@ -9,2 +9,3 @@ /*

import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
import { ensureString } from '@salesforce/ts-types';
import { orgThatMightBeDeleted } from '../../../shared/flags.js';

@@ -32,3 +33,6 @@ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);

const resolvedUsername = flags['target-org'];
const orgId = (await AuthInfo.create({ username: resolvedUsername })).getFields().orgId;
const { orgId, isScratch } = (await AuthInfo.create({ username: resolvedUsername })).getFields();
if (!isScratch) {
throw messages.createError('error.unknownScratch', [resolvedUsername]);
}
if (flags['no-prompt'] ||

@@ -39,3 +43,2 @@ (await this.confirm({ message: messages.getMessage('prompt.confirm', [resolvedUsername]) }))) {

await org.delete();
this.logSuccess(messages.getMessage('success', [org.getUsername()]));
return { username: org.getUsername(), orgId: org.getOrgId() };

@@ -59,5 +62,8 @@ }

}
return { username: resolvedUsername, orgId };
return {
username: resolvedUsername,
orgId: ensureString(orgId),
};
}
}
//# sourceMappingURL=scratch.js.map

@@ -1,4 +0,4 @@

import { OrgOpenCommandBase } from '../../shared/orgOpenCommandBase.js';
import { type OrgOpenOutput } from '../../shared/orgTypes.js';
export declare class OrgOpenCommand extends OrgOpenCommandBase<OrgOpenOutput> {
import { SfCommand } from '@salesforce/sf-plugins-core';
import { Org } from '@salesforce/core';
export declare class OrgOpenCommand extends SfCommand<OrgOpenOutput> {
static readonly summary: string;

@@ -10,6 +10,6 @@ static readonly description: string;

static readonly flags: {
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
'target-org': import("@oclif/core/interfaces").OptionFlag<Org, import("@oclif/core/interfaces").CustomOptions>;
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
private: import("@oclif/core/interfaces").BooleanFlag<boolean>;
browser: import("@oclif/core/interfaces").OptionFlag<"chrome" | "firefox" | "edge" | undefined, import("@oclif/core/interfaces").CustomOptions>;
browser: import("@oclif/core/interfaces").OptionFlag<"chrome" | "edge" | "firefox" | undefined, import("@oclif/core/interfaces").CustomOptions>;
path: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;

@@ -22,1 +22,6 @@ 'url-only': import("@oclif/core/interfaces").BooleanFlag<boolean>;

}
export type OrgOpenOutput = {
url: string;
username: string;
orgId: string;
};

@@ -8,10 +8,15 @@ /*

import path from 'node:path';
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, requiredOrgFlagWithDeprecations, } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import { platform, tmpdir } from 'node:os';
import fs from 'node:fs';
import { execSync } from 'node:child_process';
import { Flags, loglevel, orgApiVersionFlagWithDeprecations, requiredOrgFlagWithDeprecations, SfCommand, } from '@salesforce/sf-plugins-core';
import isWsl from 'is-wsl';
import { Logger, Messages, Org, SfdcUrl, SfError } from '@salesforce/core';
import { Duration, Env, sleep } from '@salesforce/kit';
import { MetadataResolver } from '@salesforce/source-deploy-retrieve';
import { buildFrontdoorUrl } from '../../shared/orgOpenUtils.js';
import { OrgOpenCommandBase } from '../../shared/orgOpenCommandBase.js';
import { apps } from 'open';
import utils from '../../shared/utils.js';
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-org', 'open');
export class OrgOpenCommand extends OrgOpenCommandBase {
export class OrgOpenCommand extends SfCommand {
static summary = messages.getMessage('summary');

@@ -59,11 +64,76 @@ static description = messages.getMessage('description');

const { flags } = await this.parse(OrgOpenCommand);
this.org = flags['target-org'];
this.connection = this.org.getConnection(flags['api-version']);
const conn = flags['target-org'].getConnection(flags['api-version']);
const env = new Env();
const [frontDoorUrl, retUrl] = await Promise.all([
buildFrontdoorUrl(this.org, this.connection),
flags['source-file'] ? generateFileUrl(flags['source-file'], this.connection) : flags.path,
buildFrontdoorUrl(flags['target-org'], conn),
flags['source-file'] ? generateFileUrl(flags['source-file'], conn) : flags.path,
]);
return this.openOrgUI(flags, frontDoorUrl, retUrl);
const url = `${frontDoorUrl}${retUrl ? `&retURL=${retUrl}` : ''}`;
const orgId = flags['target-org'].getOrgId();
// TODO: better typings in sfdx-core for orgs read from auth files
const username = flags['target-org'].getUsername();
const output = { orgId, url, username };
// NOTE: Deliberate use of `||` here since getBoolean() defaults to false, and we need to consider both env vars.
const containerMode = env.getBoolean('SF_CONTAINER_MODE') || env.getBoolean('SFDX_CONTAINER_MODE');
// security warning only for --json OR --url-only OR containerMode
if (flags['url-only'] || Boolean(flags.json) || containerMode) {
const sharedMessages = Messages.loadMessages('@salesforce/plugin-org', 'messages');
this.warn(sharedMessages.getMessage('SecurityWarning'));
this.log('');
}
if (containerMode) {
// instruct the user that they need to paste the URL into the browser
this.styledHeader('Action Required!');
this.log(messages.getMessage('containerAction', [orgId, url]));
return output;
}
if (flags['url-only']) {
// this includes the URL
this.logSuccess(messages.getMessage('humanSuccess', [orgId, username, url]));
return output;
}
this.logSuccess(messages.getMessage('humanSuccessNoUrl', [orgId, username]));
// we actually need to open the org
try {
this.spinner.start(messages.getMessage('domainWaiting'));
await new SfdcUrl(url).checkLightningDomain();
this.spinner.stop();
}
catch (err) {
handleDomainError(err, url, env);
}
// create a local html file that contains the POST stuff.
const tempFilePath = path.join(tmpdir(), `org-open-${new Date().valueOf()}.html`);
await fs.promises.writeFile(tempFilePath, getFileContents(conn.accessToken, conn.instanceUrl,
// the path flag is URI-encoded in its `parse` func.
// For the form redirect to work we need it decoded.
flags.path ? decodeURIComponent(flags.path) : retUrl));
const filePathUrl = isWsl
? 'file:///' + execSync(`wslpath -m ${tempFilePath}`).toString().trim()
: `file:///${tempFilePath}`;
const cp = await utils.openUrl(filePathUrl, {
...(flags.browser ? { app: { name: apps[flags.browser] } } : {}),
...(flags.private ? { newInstance: platform() === 'darwin', app: { name: apps.browserPrivate } } : {}),
});
cp.on('error', (err) => {
fileCleanup(tempFilePath);
throw SfError.wrap(err);
});
// so we don't delete the file while the browser is still using it
// open returns when the CP is spawned, but there's not way to know if the browser is still using the file
await sleep(platform() === 'win32' || isWsl ? 7000 : 5000);
fileCleanup(tempFilePath);
return output;
}
}
const fileCleanup = (tempFilePath) => fs.rmSync(tempFilePath, { force: true, maxRetries: 3, recursive: true });
const buildFrontdoorUrl = async (org, conn) => {
await org.refreshAuth(); // we need a live accessToken for the frontdoor url
const accessToken = conn.accessToken;
if (!accessToken) {
throw new SfError('NoAccessToken', 'NoAccessToken');
}
const instanceUrlClean = org.getField(Org.Fields.INSTANCE_URL).replace(/\/$/, '');
return `${instanceUrlClean}/secur/frontdoor.jsp?sid=${accessToken}`;
};
const generateFileUrl = async (file, conn) => {

@@ -107,2 +177,32 @@ try {

};
/** builds the html file that does an automatic post to the frontdoor url */
const getFileContents = (authToken, instanceUrl,
// we have to defalt this to get to Setup only on the POST version. GET goes to Setup automatically
retUrl = '/lightning/setup/SetupOneHome/home') => `
<html>
<body onload="document.body.firstElementChild.submit()">
<form method="POST" action="${instanceUrl}/secur/frontdoor.jsp">
<input type="hidden" name="sid" value="${authToken}" />
<input type="hidden" name="retURL" value="${retUrl}" />
</form>
</body>
</html>`;
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;
};
//# sourceMappingURL=open.js.map

@@ -14,7 +14,2 @@ import { AuthFields, ScratchOrgInfo } from '@salesforce/core';

};
export type OrgOpenOutput = {
url: string;
username: string;
orgId: string;
};
/** Convenience type for the fields that are in the auth file

@@ -21,0 +16,0 @@ *

@@ -0,5 +1,9 @@

import { ChildProcess } from 'node:child_process';
import { Options } from 'open';
export declare const getAliasByUsername: (username: string) => Promise<string | undefined>;
export declare const openUrl: (url: string, options: Options) => Promise<ChildProcess>;
export declare const lowerToUpper: (object: Record<string, unknown>) => Record<string, unknown>;
declare const _default: {
getAliasByUsername: (username: string) => Promise<string | undefined>;
openUrl: (url: string, options: Options) => Promise<ChildProcess>;
lowerToUpper: (object: Record<string, unknown>) => Record<string, unknown>;

@@ -6,0 +10,0 @@ };

@@ -1,9 +0,4 @@

/*
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { upperFirst } from '@salesforce/kit';
import { StateAggregator } from '@salesforce/core';
import open from 'open';
export const getAliasByUsername = async (username) => {

@@ -15,2 +10,3 @@ const stateAggregator = await StateAggregator.getInstance();

};
export const openUrl = async (url, options) => open(url, options);
export const lowerToUpper = (object) =>

@@ -22,2 +18,3 @@ // the API has keys defined in capital camel case, while the definition schema has them as lower camel case

getAliasByUsername,
openUrl,
lowerToUpper,

@@ -24,0 +21,0 @@ };

@@ -47,1 +47,5 @@ # summary

Unable to determine the username of the org to delete. Specify the username with the --target-org | -o flag.
# error.unknownScratch
Unable to find a scratch org with username %s.
{
"name": "@salesforce/plugin-org",
"description": "Commands to interact with Salesforce orgs",
"version": "5.1.5-beta.0",
"version": "5.1.5",
"author": "Salesforce",

@@ -12,4 +12,5 @@ "bugs": "https://github.com/forcedotcom/cli/issues",

"@salesforce/kit": "^3.2.3",
"@salesforce/sf-plugins-core": "^12.0.11",
"@salesforce/source-deploy-retrieve": "^12.10.1",
"@salesforce/sf-plugins-core": "^12.0.9",
"@salesforce/source-deploy-retrieve": "^12.8.1",
"@salesforce/ts-types": "^2.0.12",
"ansis": "^3.2.0",

@@ -230,5 +231,5 @@ "change-case": "^5.4.4",

"sfdx": {
"publicKeyUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-org/5.1.5-beta.0.crt",
"signatureUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-org/5.1.5-beta.0.sig"
"publicKeyUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-org/5.1.5.crt",
"signatureUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-org/5.1.5.sig"
}
}

@@ -113,3 +113,2 @@ # plugin-org

- [`sf org open`](#sf-org-open)
- [`sf org open agent`](#sf-org-open-agent)
- [`sf org refresh sandbox`](#sf-org-refresh-sandbox)

@@ -246,3 +245,3 @@ - [`sf org resume sandbox`](#sf-org-resume-sandbox)

_See code: [src/commands/org/create/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/create/sandbox.ts)_
_See code: [src/commands/org/create/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5/src/commands/org/create/sandbox.ts)_

@@ -401,3 +400,3 @@ ## `sf org create scratch`

_See code: [src/commands/org/create/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/create/scratch.ts)_
_See code: [src/commands/org/create/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5/src/commands/org/create/scratch.ts)_

@@ -448,3 +447,3 @@ ## `sf org delete sandbox`

_See code: [src/commands/org/delete/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/delete/sandbox.ts)_
_See code: [src/commands/org/delete/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5/src/commands/org/delete/sandbox.ts)_

@@ -493,3 +492,3 @@ ## `sf org delete scratch`

_See code: [src/commands/org/delete/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/delete/scratch.ts)_
_See code: [src/commands/org/delete/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5/src/commands/org/delete/scratch.ts)_

@@ -533,3 +532,3 @@ ## `sf org disable tracking`

_See code: [src/commands/org/disable/tracking.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/disable/tracking.ts)_
_See code: [src/commands/org/disable/tracking.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5/src/commands/org/disable/tracking.ts)_

@@ -579,3 +578,3 @@ ## `sf org display`

_See code: [src/commands/org/display.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/display.ts)_
_See code: [src/commands/org/display.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5/src/commands/org/display.ts)_

@@ -622,3 +621,3 @@ ## `sf org enable tracking`

_See code: [src/commands/org/enable/tracking.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/enable/tracking.ts)_
_See code: [src/commands/org/enable/tracking.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5/src/commands/org/enable/tracking.ts)_

@@ -662,3 +661,3 @@ ## `sf org list`

_See code: [src/commands/org/list.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/list.ts)_
_See code: [src/commands/org/list.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5/src/commands/org/list.ts)_

@@ -730,3 +729,3 @@ ## `sf org list metadata`

_See code: [src/commands/org/list/metadata.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/list/metadata.ts)_
_See code: [src/commands/org/list/metadata.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5/src/commands/org/list/metadata.ts)_

@@ -786,3 +785,3 @@ ## `sf org list metadata-types`

_See code: [src/commands/org/list/metadata-types.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/list/metadata-types.ts)_
_See code: [src/commands/org/list/metadata-types.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5/src/commands/org/list/metadata-types.ts)_

@@ -863,54 +862,4 @@ ## `sf org open`

_See code: [src/commands/org/open.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/open.ts)_
_See code: [src/commands/org/open.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5/src/commands/org/open.ts)_
## `sf org open agent`
Open an agent in the Agent Builder org UI in a browser.
```
USAGE
$ sf org open agent -o <value> -n <value> [--json] [--flags-dir <value>] [--api-version <value>] [--private | -r |
-b chrome|edge|firefox]
FLAGS
-b, --browser=<option> Browser where the org opens.
<options: chrome|edge|firefox>
-n, --name=<value> (required) The developer name (aka API name) of the agent to open in the Agent Builder org
UI.
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
-r, --url-only Display navigation URL, but don’t launch browser.
--api-version=<value> Override the api version used for api requests made by this command
--private Open the org in the default browser using private (incognito) mode.
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Open an agent in the Agent Builder org UI in a browser.
Use the --name flag to open an agent using the developer name (aka API name) in the Agent Builder Org UI.
To generate a URL but not launch it in your browser, specify --url-only.
To open in a specific browser, use the --browser flag. Supported browsers are "chrome", "edge", and "firefox". If you
don't specify --browser, the org opens in your default browser.
EXAMPLES
Open the agent with developer name "Coral_Cloud_Agent using the default browser:
$ sf org open agent --name Coral_Cloud_Agent
Open the agent in an incognito window of your default browser:
$ sf org open agent --private --name Coral_Cloud_Agent
Open the agent in the org with alias MyTestOrg1 using the Firefox browser:
$ sf org open agent --target-org MyTestOrg1 --browser firefox --name Coral_Cloud_Agent
```
_See code: [src/commands/org/open/agent.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/open/agent.ts)_
## `sf org refresh sandbox`

@@ -991,3 +940,3 @@

_See code: [src/commands/org/refresh/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/refresh/sandbox.ts)_
_See code: [src/commands/org/refresh/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5/src/commands/org/refresh/sandbox.ts)_

@@ -1055,3 +1004,3 @@ ## `sf org resume sandbox`

_See code: [src/commands/org/resume/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/resume/sandbox.ts)_
_See code: [src/commands/org/resume/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5/src/commands/org/resume/sandbox.ts)_

@@ -1103,4 +1052,4 @@ ## `sf org resume scratch`

_See code: [src/commands/org/resume/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5-beta.0/src/commands/org/resume/scratch.ts)_
_See code: [src/commands/org/resume/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.1.5/src/commands/org/resume/scratch.ts)_
<!-- commandsstop -->

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc