Skip to content

Commit 9fa1985

Browse files
authored
Merge pull request #973 from salesforcecli/sh/refresh-sandbox
Sh/refresh sandbox
2 parents c6881ac + 20876ec commit 9fa1985

20 files changed

+2816
-1703
lines changed

command-snapshot.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,23 @@
188188
"flags": ["job-id", "json", "name", "target-org", "use-most-recent", "wait"],
189189
"plugin": "@salesforce/plugin-org"
190190
},
191+
{
192+
"command": "org:refresh:sandbox",
193+
"flagAliases": [],
194+
"flagChars": ["i", "f", "n", "o", "w"],
195+
"flags": [
196+
"auto-activate",
197+
"async",
198+
"json",
199+
"name",
200+
"definition-file",
201+
"no-prompt",
202+
"target-org",
203+
"poll-interval",
204+
"wait"
205+
],
206+
"plugin": "@salesforce/plugin-org"
207+
},
191208
{
192209
"alias": ["env:resume:scratch"],
193210
"command": "org:resume:scratch",

messages/create.sandbox.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,22 @@ Create a sandbox org.
66

77
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.
88

9+
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.
10+
911
# examples
1012

1113
- 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".
1214

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

1517
- 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.
1618

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

21+
- 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.
22+
23+
<%= config.bin %> <%= command.id %> --clone ExistingSandbox --name NewClonedSandbox --target-org prodOrg --alias MyDevSandbox --set-default --wait 30
24+
1925
# flags.setDefault.summary
2026

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

4349
# flags.definitionFile.description
4450

45-
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.
51+
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.
4652

4753
# flags.name.summary
4854

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

5965
# flags.clone.description
6066

61-
The value of clone must be an existing sandbox in the same target-org.
67+
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.
6268

6369
# flags.licenseType.summary
6470

messages/refresh.sandbox.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# summary
2+
3+
Refresh a sandbox org using the sandbox name.
4+
5+
# description
6+
7+
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.
8+
9+
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.
10+
11+
# examples
12+
13+
- Refresh the sandbox named "devSbx1". The production org that contains the sandbox license has the alias "prodOrg".
14+
15+
<%= config.bin %> <%= command.id %> --name devSbx1 --target-org prodOrg
16+
17+
- 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.
18+
19+
<%= config.bin %> <%= command.id %> --name devSbx2 --definition-file devSbx2-config.json
20+
21+
- Refresh the sandbox using the name defined in the definition file. The production org that contains the sandbox license has the alias "prodOrg".
22+
23+
<%= config.bin %> <%= command.id %> --definition-file devSbx3-config.json --target-org prodOrg
24+
25+
# flags.auto-activate.summary
26+
27+
Activates the sandbox after a successful refresh.
28+
29+
# flags.targetOrg.summary
30+
31+
Username or alias of the production org that contains the sandbox license.
32+
33+
# flags.definitionFile.summary
34+
35+
Path to a sandbox definition file for overriding its configuration when you refresh it.
36+
37+
# flags.definitionFile.description
38+
39+
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.
40+
41+
# flags.name.summary
42+
43+
Name of the existing sandbox org in your production org that you want to refresh.
44+
45+
# flags.wait.summary
46+
47+
Number of minutes to poll for sandbox refresh status.
48+
49+
# flags.wait.description
50+
51+
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.
52+
53+
# flags.poll-interval.summary
54+
55+
Number of seconds to wait between status polling requests.
56+
57+
# flags.async.summary
58+
59+
Request the sandbox refresh, but don't wait for it to complete.
60+
61+
# flags.async.description
62+
63+
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".
64+
65+
# flags.noPrompt.summary
66+
67+
Don't prompt for confirmation about the sandbox refresh.
68+
69+
# isConfigurationOk
70+
71+
Is the configuration correct?
72+
73+
# error.SandboxNameLength
74+
75+
The sandbox name "%s" must be 10 or fewer characters.
76+
77+
# error.NoSandboxName
78+
79+
Must specify a sandbox name using the `--name` or `--definition-file` flag.
80+
81+
# warning.ConflictingSandboxNames
82+
83+
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.
84+
85+
# error.SandboxNotFound
86+
87+
The sandbox name "%s" could not be found in production org "%s".
88+
89+
# error.SandboxNotFound.actions
90+
91+
Ensure the sandbox name and casing is correct.
92+
Ensure the production org for the sandbox is correct.
93+
94+
# error.UserNotSatisfiedWithSandboxConfig
95+
96+
The sandbox request configuration isn't acceptable.
97+
98+
# error.pollIntervalGreaterThanWait
99+
100+
The poll interval (%d seconds) can't be larger than the wait period (%d in seconds).
101+
102+
# sandboxInfoRefreshFailed
103+
104+
The sandbox org refresh failed with a result of %s.

messages/sandboxbase.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# sandboxSuccess
22

3-
The sandbox org creation was successful.
3+
The sandbox org %s was successful.
44

55
# sandboxSuccess.actions
66

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

15-
# warning.ClientTimeoutWaitingForSandboxCreate
15+
# warning.ClientTimeoutWaitingForSandboxProcess
1616

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

1919
# warning.MultipleMatchingSandboxProcesses
2020

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"bugs": "https://github.com/forcedotcom/cli/issues",
77
"dependencies": {
88
"@oclif/core": "^3.18.1",
9-
"@salesforce/core": "^6.5.1",
9+
"@salesforce/core": "^6.6.0",
1010
"@salesforce/kit": "^3.0.15",
11-
"@salesforce/sf-plugins-core": "^7.1.12",
11+
"@salesforce/sf-plugins-core": "^7.1.14",
1212
"@salesforce/source-deploy-retrieve": "^10.3.8",
1313
"chalk": "^5.3.0",
1414
"change-case": "^5.4.3",

schemas/org-refresh-sandbox.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$ref": "#/definitions/SandboxProcessObject",
4+
"definitions": {
5+
"SandboxProcessObject": {
6+
"type": "object",
7+
"properties": {
8+
"Id": {
9+
"type": "string"
10+
},
11+
"Status": {
12+
"type": "string"
13+
},
14+
"SandboxName": {
15+
"type": "string"
16+
},
17+
"SandboxInfoId": {
18+
"type": "string"
19+
},
20+
"LicenseType": {
21+
"type": "string"
22+
},
23+
"CreatedDate": {
24+
"type": "string"
25+
},
26+
"SandboxOrganization": {
27+
"type": "string"
28+
},
29+
"CopyProgress": {
30+
"type": "number"
31+
},
32+
"SourceId": {
33+
"type": "string"
34+
},
35+
"Description": {
36+
"type": "string"
37+
},
38+
"ApexClassId": {
39+
"type": "string"
40+
},
41+
"EndDate": {
42+
"type": "string"
43+
}
44+
},
45+
"required": ["Id", "Status", "SandboxName", "SandboxInfoId", "LicenseType", "CreatedDate"],
46+
"additionalProperties": false
47+
}
48+
}
49+
}

src/commands/org/create/sandbox.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ export default class CreateSandbox extends SandboxCommandBase<SandboxProcessObje
201201
alias: this.flags.alias,
202202
setDefault: this.flags['set-default'],
203203
prodOrgUsername: this.flags['target-org'].getUsername() as string,
204+
action: 'Create',
204205
sandboxProcessObject: {
205206
SandboxName: sandboxReq.SandboxName,
206207
},

src/commands/org/create/scratch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { ScratchCreateResponse } from '../../../shared/orgTypes.js';
2222
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
2323
const messages = Messages.loadMessages('@salesforce/plugin-org', 'create_scratch');
2424

25-
export const secretTimeout = 60000;
25+
export const secretTimeout = 60_000;
2626

2727
const definitionFileHelpGroupName = 'Definition File Override';
2828
export default class EnvCreateScratch extends SfCommand<ScratchCreateResponse> {

0 commit comments

Comments
 (0)