Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sh/refresh sandbox #973

Merged
merged 8 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,23 @@
"flags": ["job-id", "json", "name", "target-org", "use-most-recent", "wait"],
"plugin": "@salesforce/plugin-org"
},
{
"command": "org:refresh:sandbox",
"flagAliases": [],
"flagChars": ["i", "f", "n", "o", "w"],
"flags": [
"auto-activate",
"async",
"json",
"name",
"definition-file",
"no-prompt",
"target-org",
"poll-interval",
"wait"
],
"plugin": "@salesforce/plugin-org"
},
{
"alias": ["env:resume:scratch"],
"command": "org:resume:scratch",
Expand Down
12 changes: 9 additions & 3 deletions messages/create.sandbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@ Create a sandbox org.

There are two ways to create a sandbox org: specify a definition file that contains the sandbox options or use the --name and --license-type flags to specify the two required options. If you want to set an option other than name or license type, such as apexClassId, you must use a definition file.

You can also use this command to clone an existing sandbox. Use the --clone flag to specify the existing sandbox name and the --name flag to the name of the new sandbox.

# examples

- Create a sandbox org using a definition file and give it the alias "MyDevSandbox". The production org that contains the sandbox license has the alias "prodOrg".

<%= config.bin %> <%= command.id %> -f config/dev-sandbox-def.json --alias MyDevSandbox --target-org prodOrg
<%= config.bin %> <%= command.id %> --definition-file config/dev-sandbox-def.json --alias MyDevSandbox --target-org prodOrg

- Create a sandbox org by directly specifying its name and type of license (Developer) instead of using a definition file. Set the sandbox org as your default.

<%= config.bin %> <%= command.id %> --name mysandbox --license-type Developer --alias MyDevSandbox --target-org prodOrg --set-default

- Clone the existing sandbox with name "ExistingSandbox" and name the new sandbox "NewClonedSandbox". Set the new sandbox as your default org. Wait for 30 minutes for the sandbox creation to complete.

<%= config.bin %> <%= command.id %> --clone ExistingSandbox --name NewClonedSandbox --target-org prodOrg --alias MyDevSandbox --set-default --wait 30

# flags.setDefault.summary

Set the sandbox org as your default org.
Expand All @@ -42,7 +48,7 @@ Path to a sandbox definition file.

# flags.definitionFile.description

The sandbox definition file is a blueprint for the sandbox. You can create different definition files for each sandbox type that you use in the development process. See <https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_sandbox_definition.htm> for all the options you can specify in the defintion file.
The sandbox definition file is a blueprint for the sandbox. You can create different definition files for each sandbox type that you use in the development process. See <https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_sandbox_definition.htm> for all the options you can specify in the definition file.

# flags.name.summary

Expand All @@ -58,7 +64,7 @@ Name of the sandbox org to clone.

# flags.clone.description

The value of clone must be an existing sandbox in the same target-org.
The value of --clone must be an existing sandbox. The existing sandbox, and the new sandbox specified with the --name flag, must both be associated with the production org (--target-org) that contains the sandbox licenses.

# flags.licenseType.summary

Expand Down
104 changes: 104 additions & 0 deletions messages/refresh.sandbox.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# summary

Refresh a sandbox org using the sandbox name.

# description

Refreshing a sandbox copies the metadata, and optionally data, from your production org to the refreshed sandbox org. You can optionally specify a definition file if you want to change the configuration of the refreshed sandbox, such as its license type or template ID.

You're not allowed to change the sandbox name when you refresh it with this command. If you want to change the sandbox name, first delete it with the "org delete sandbox" command. And then recreate it with the "org create sandbox" command and give it a new name.

# examples

- Refresh the sandbox named "devSbx1". The production org that contains the sandbox license has the alias "prodOrg".

<%= config.bin %> <%= command.id %> --name devSbx1 --target-org prodOrg

- Refresh the sandbox named "devSbx2", and override the configuration of the refreshed sandbox with the properties in the specified defintion file. The default target org is the production org, so you don't need to specify the `--target-org` flag in this case.

<%= config.bin %> <%= command.id %> --name devSbx2 --definition-file devSbx2-config.json

- Refresh the sandbox using the name defined in the definition file. The production org that contains the sandbox license has the alias "prodOrg".

<%= config.bin %> <%= command.id %> --definition-file devSbx3-config.json --target-org prodOrg

# flags.auto-activate.summary

Activates the sandbox after a successful refresh.

# flags.targetOrg.summary

Username or alias of the production org that contains the sandbox license.

# flags.definitionFile.summary

Path to a sandbox definition file for overriding its configuration when you refresh it.

# flags.definitionFile.description

The sandbox definition file is a blueprint for the sandbox; use the file to change the sandbox configuration during a refresh. If you don't want to change the sandbox configuration when you refresh it, then simply use the --name flag to specify the sandbox and don't use this flag. See <https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_sandbox_definition.htm> for all the options you can specify in the definition file.

# flags.name.summary

Name of the existing sandbox org in your production org that you want to refresh.

# flags.wait.summary

Number of minutes to poll for sandbox refresh status.

# flags.wait.description

If the command continues to run after the wait period, the CLI returns control of the terminal to you and displays the "<%= config.bin %> org resume sandbox" command for you run to check the status of the refresh. The displayed command includes the job ID for the running sandbox refresh.

# flags.poll-interval.summary

Number of seconds to wait between status polling requests.

# flags.async.summary

Request the sandbox refresh, but don't wait for it to complete.

# flags.async.description

The command immediately displays the job ID and returns control of the terminal to you. This way, you can continue to use the CLI. To check the status of the sandbox refresh, run "<%= config.bin %> org resume sandbox".

# flags.noPrompt.summary

Don't prompt for confirmation about the sandbox refresh.

# isConfigurationOk

Is the configuration correct?

# error.SandboxNameLength

The sandbox name "%s" must be 10 or fewer characters.

# error.NoSandboxName

Must specify a sandbox name using the `--name` or `--definition-file` flag.

# warning.ConflictingSandboxNames

Different sandbox names were provided with the `--name` ('%s') and `--definition-file` flags ('%s'). Using the value provided by the `--name` flag. If you want to change the name of the sandbox, first delete it and then create it again using the new name.

# error.SandboxNotFound

The sandbox name "%s" could not be found in production org "%s".

# error.SandboxNotFound.actions

Ensure the sandbox name and casing is correct.
Ensure the production org for the sandbox is correct.

# error.UserNotSatisfiedWithSandboxConfig

The sandbox request configuration isn't acceptable.

# error.pollIntervalGreaterThanWait

The poll interval (%d seconds) can't be larger than the wait period (%d in seconds).

# sandboxInfoRefreshFailed

The sandbox org refresh failed with a result of %s.
6 changes: 3 additions & 3 deletions messages/sandboxbase.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# sandboxSuccess

The sandbox org creation was successful.
The sandbox org %s was successful.

# sandboxSuccess.actions

Expand All @@ -12,9 +12,9 @@ You can open the org by running "%s org open -o %s"
Run "%s org resume sandbox --job-id %s -o %s" to check for status.
If the org is ready, checking the status also authorizes the org for use with Salesforce CLI.

# warning.ClientTimeoutWaitingForSandboxCreate
# warning.ClientTimeoutWaitingForSandboxProcess

The wait time for the sandbox creation has been exhausted. See the results below for more information.
The wait time for the sandbox %s has been exhausted. See the results below for more information.

# warning.MultipleMatchingSandboxProcesses

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/core": "^3.18.1",
"@salesforce/core": "^6.5.1",
"@salesforce/core": "^6.6.0",
"@salesforce/kit": "^3.0.15",
"@salesforce/sf-plugins-core": "^7.1.12",
"@salesforce/sf-plugins-core": "^7.1.14",
"@salesforce/source-deploy-retrieve": "^10.3.8",
"chalk": "^5.3.0",
"change-case": "^5.4.3",
Expand Down
49 changes: 49 additions & 0 deletions schemas/org-refresh-sandbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/SandboxProcessObject",
"definitions": {
"SandboxProcessObject": {
"type": "object",
"properties": {
"Id": {
"type": "string"
},
"Status": {
"type": "string"
},
"SandboxName": {
"type": "string"
},
"SandboxInfoId": {
"type": "string"
},
"LicenseType": {
"type": "string"
},
"CreatedDate": {
"type": "string"
},
"SandboxOrganization": {
"type": "string"
},
"CopyProgress": {
"type": "number"
},
"SourceId": {
"type": "string"
},
"Description": {
"type": "string"
},
"ApexClassId": {
"type": "string"
},
"EndDate": {
"type": "string"
}
},
"required": ["Id", "Status", "SandboxName", "SandboxInfoId", "LicenseType", "CreatedDate"],
"additionalProperties": false
}
}
}
1 change: 1 addition & 0 deletions src/commands/org/create/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export default class CreateSandbox extends SandboxCommandBase<SandboxProcessObje
alias: this.flags.alias,
setDefault: this.flags['set-default'],
prodOrgUsername: this.flags['target-org'].getUsername() as string,
action: 'Create',
sandboxProcessObject: {
SandboxName: sandboxReq.SandboxName,
},
Expand Down
2 changes: 1 addition & 1 deletion src/commands/org/create/scratch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { ScratchCreateResponse } from '../../../shared/orgTypes.js';
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-org', 'create_scratch');

export const secretTimeout = 60000;
export const secretTimeout = 60_000;

const definitionFileHelpGroupName = 'Definition File Override';
export default class EnvCreateScratch extends SfCommand<ScratchCreateResponse> {
Expand Down
Loading
Loading