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

feat: add env commands for create/resume scratch/sandbox orgs #272

Merged
merged 73 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
d2e1fac
feat: add env create sandbox command
peternhale Mar 7, 2022
170de24
chore: create sandbox cresate schema
peternhale Mar 7, 2022
3003a1e
chore: fix target-org summary message
peternhale Mar 7, 2022
6bcbe07
chore: fix misalign message file load
peternhale Mar 7, 2022
706ac26
chore: more message corrections
peternhale Mar 7, 2022
46ecb00
chore: get nut tests running - almost
peternhale Mar 8, 2022
b8aaecb
chore: fixup stub to ux styled header
peternhale Mar 8, 2022
e31d0cb
chore: gen snapshot.json
peternhale Mar 8, 2022
7658baf
chore: revert functions to 1.5.0
peternhale Mar 8, 2022
f662ef4
Update sandbox.ts
peternhale Mar 8, 2022
3b0b7b3
chore: move message to markdown
peternhale Mar 8, 2022
38368f0
Update src/commands/env/create/sandbox.ts
peternhale Mar 9, 2022
dc7e3fb
chore: apply requested review comments
peternhale Mar 9, 2022
3920051
chore: cleaning up and tests
peternhale Mar 15, 2022
91907a0
chore: fix failing test update snapshot
peternhale Mar 15, 2022
10ee5f3
Update src/commands/env/create/sandbox.ts
peternhale Mar 18, 2022
dd467c9
feat: commands to delete scratch orgs and sandboxes
peternhale Mar 18, 2022
f8fc01d
chore: apply review suggestions
peternhale Mar 18, 2022
874adf6
Merge branch 'main' of github.com:salesforcecli/plugin-env into phale…
peternhale Mar 18, 2022
3e976bd
reenable nuts
peternhale Mar 18, 2022
2205ced
chore: get nuts ready to run
peternhale Mar 18, 2022
65657e1
Update sandboxCreate.nut.ts
peternhale Mar 18, 2022
0e64bf5
chore: isolate sandbox nuts from others
peternhale Mar 18, 2022
07b8d80
chore: fix circle config
peternhale Mar 18, 2022
f4c014f
chore: run sandbox nuts [sb-nuts]
peternhale Mar 18, 2022
be7606f
Revert "chore: run sandbox nuts [sb-nuts]"
peternhale Mar 18, 2022
b193148
Updated config.yml
peternhale Mar 21, 2022
98bc277
chore: force [sb-nuts]
peternhale Mar 21, 2022
f8afe7a
chore: force [sb-nuts]
peternhale Mar 21, 2022
9cf1447
chore: run [sb-nuts]
peternhale Mar 21, 2022
88a6144
chore: [sb-nuts]
peternhale Mar 21, 2022
bb7cfbc
chore: revert temp orb reference [skip ci]
peternhale Mar 21, 2022
b39b46e
Review messages for "env create sandbox" (#254)
jshackell-sfdc Mar 22, 2022
4a6c9b4
feat: add sandbox create [skip ci]
peternhale Apr 1, 2022
bf7e26a
chore: remove unneeded artifacts
peternhale Apr 4, 2022
6500ab7
chore: provide better messaging on timeout
peternhale Apr 5, 2022
06dec62
chore: mark command as beta
peternhale Apr 5, 2022
8540797
feat: scratch org async/resume
mshanemc Apr 6, 2022
1e75913
test: nut for scratch async/resume
mshanemc Apr 6, 2022
8430194
feat: use orgConfig, not definitionJson
mshanemc Apr 7, 2022
4f25919
Merge branch 'main' into sm/scratch-create-resume
mshanemc Apr 7, 2022
b933097
chore: standardColors
mshanemc Apr 11, 2022
8c80ebc
chore: resume sandbox and tweaks from testing
peternhale Apr 12, 2022
930f0a5
refactor: pr feedback
mshanemc Apr 12, 2022
9f9493a
chore: better handle exceptions
peternhale Apr 13, 2022
01d1548
Merge branch 'main' of github.com:salesforcecli/plugin-env into phale…
peternhale Apr 13, 2022
684e93c
chore: aync-wait 0 exist with exit code 68 with latest progress
peternhale Apr 13, 2022
08b6962
Merge branch 'main' into sm/scratch-create-resume
mshanemc Apr 13, 2022
6b4b9dc
fix: remove duplicate identified
mshanemc Apr 13, 2022
4f84b0b
chore: add clone option
peternhale Apr 14, 2022
2d4ee02
chore: add type to flags
peternhale Apr 18, 2022
246bede
chore: fix stuff
peternhale Apr 18, 2022
349f217
chore: apply review suggestions
peternhale Apr 18, 2022
fe70a8d
chore: fix duplicate output
peternhale Apr 18, 2022
a2ec83b
chore: apply review comments
peternhale Apr 18, 2022
3303e40
chore: tweaks
peternhale Apr 19, 2022
1c59d98
chore: remove alias and set-default from resume
peternhale Apr 19, 2022
9f80097
chore: fix char for clone and make license and clone exclusive
peternhale Apr 19, 2022
cc20eba
chore: fix retention of alias and set default username
peternhale Apr 21, 2022
ddc37e8
chore: improve flags
peternhale Apr 22, 2022
d7b7fa0
Merge branch 'main' of github.com:salesforcecli/plugin-env into phale…
peternhale Apr 22, 2022
c6065a4
chore: fix job dependency
peternhale Apr 22, 2022
ba95185
Update messages for new sandbox resume command (#271)
jshackell-sfdc Apr 22, 2022
3422d92
chore: check
peternhale Apr 22, 2022
a0f2add
edit messages for resume scratch (#270)
jshackell-sfdc Apr 22, 2022
5e659d5
Merge branch 'sm/scratch-create-resume' of github.com:salesforcecli/p…
peternhale Apr 22, 2022
d9b722d
chore: correct schma and snapshot
peternhale Apr 22, 2022
2508af7
Merge branch 'phale/W-10657688' of github.com:salesforcecli/plugin-en…
peternhale Apr 22, 2022
4934eb5
chore: update sfdx-core version and some others
peternhale Apr 26, 2022
dba2289
chore: improve type usage
peternhale Apr 26, 2022
08a56b9
chore: fix imports
peternhale Apr 26, 2022
34e28bd
chore: eat after all errors when trying to delete session.dir
peternhale Apr 27, 2022
223faa3
chore: fix sandbox nuts [sb-nuts]
peternhale Apr 27, 2022
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
10 changes: 10 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ workflows:
context:
- na40-auth-url
- na40-jwt
- release-management/run-command-keyword:
name: sandbox-nuts
git_key_word: '[sb-nuts]'
timeout: 1.5h
command: test:nuts:sandbox
requires:
- release-management/test-nut
context:
- na40-auth-url
- na40-jwt
- release-management/release-package:
context:
- AWS
Expand Down
32 changes: 32 additions & 0 deletions command-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
[
{
"command": "env:create:sandbox",
"plugin": "@salesforce/plugin-env",
"flags": [
"alias",
"async",
"clone",
"definition-file",
"json",
"license-type",
"name",
"no-prompt",
"poll-interval",
"set-default",
"target-org",
"wait"
],
"alias": []
},
{
"command": "env:create:scratch",
"plugin": "@salesforce/plugin-env",
"flags": [
"alias",
"api-version",
"async",
"client-id",
"definition-file",
"duration-days",
Expand Down Expand Up @@ -47,5 +67,17 @@
"plugin": "@salesforce/plugin-env",
"flags": ["browser", "json", "path", "target-env", "url-only"],
"alias": []
},
{
"command": "env:resume:sandbox",
"plugin": "@salesforce/plugin-env",
"flags": ["job-id", "json", "name", "target-org", "use-most-recent", "wait"],
"alias": []
},
{
"command": "env:resume:scratch",
"plugin": "@salesforce/plugin-env",
"flags": ["job-id", "json", "use-most-recent"],
"alias": []
}
]
129 changes: 129 additions & 0 deletions messages/create.sandbox.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# summary

Create a sandbox org.

# description

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.

# 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

- 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

# flags.setDefault.summary

Set the sandbox org as your default org.

# flags.alias.summary

Alias for the sandbox org.

# flags.alias.description

When you create a sandbox, the generated usernames are based on the usernames present in the production org. To ensure uniqueness, the new usernames are appended with the name of the sandbox. For example, the username "[email protected]" in the production org results in the username "[email protected]" in a sandbox named "mysandbox". When you set an alias for a sandbox org, it's assigned to the resulting username of the user running this command.

# flags.targetOrg.summary

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

# flags.targetOrg.description

When it creates the sandbox org, Salesforce copies the metadata, and optionally data, from your production org to the new sandbox org.

# flags.definitionFile.summary

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.

# flags.name.summary

Name of the sandbox org.

# flags.name.description

The name must be a unique alphanumeric string (10 or fewer characters) to identify the sandbox. You can’t reuse a name while a sandbox is in the process of being deleted.

# flags.clone.summary

Name of the sandbox org to clone.

# flags.clone.description

The value of clone must be an existing sandbox in the same target-org.

# flags.licenseType.summary

Type of sandbox license.

# flags.wait.summary

Number of minutes to wait for the sandbox org to be ready.

# 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 "sf env resume sandbox" command you run to check the status of the create. The displayed command includes the job ID for the running sandbox creation.

# flags.poll-interval.summary

Number of seconds to wait between retries.

# flags.async.summary

Request the sandbox creation, 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 creation, run "sf env resume sandbox".

# flags.noPrompt.summary

Don't prompt for confirmation about the sandbox configuration.

# isConfigurationOk

Is the configuration correct?

# warning.NoSandboxNameDefined

No SandboxName defined, generating new SandboxName: %s.

# error.RequiresTargetOrg

This command requires a target-org. Specify it with the --target-org flag or by running the "sf config set target-org=<username>" command.

# error.MissingLicenseType

The sandbox license type is required, but you didn't provide a value. Specify the license type in the sandbox definition file with the "licenseType" option, or specify the --license-type and --name flags at the command-line. See https://developer.salesforce.com/docs/atlas.en-us.sf_dev.meta/sf_dev/sf_dev_sandbox_definition.htm for more information.

# error.NoConfig

Specify either a sandbox definition file or the --name and --license-type flags together.

# error.SandboxNameLength

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

# error.UserNotSatisfiedWithSandboxConfig

The sandbox request configuration isn't acceptable.

# error.pollIntervalGreaterThanWait

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

# error.CreateTimeout

The wait timeout (%d minutes) has expired. Check command results for more information.

# error.noCloneSource

Could not find the clone sandbox name "%s" in the target org.
16 changes: 16 additions & 0 deletions messages/create_scratch.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ Don't include second-generation managed package (2GP) ancestors in the scratch o

Salesforce edition of the scratch org.

# flags.async.summary

Request the org, 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 resume the scratch org creation, run "sf env resume scratch".

# flags.edition.description

The editions that begin with "partner-" are available only if the Dev Hub org is a Partner Business Org.
Expand All @@ -66,6 +74,10 @@ Consumer key of the Dev Hub connected app.

Number of minutes to wait for the scratch org to be ready.

# 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 job ID. To resume the scratch org creation, run the env resume scratch command and pass it the job ID.

# flags.track-source.description

We recommend you enable source tracking in scratch orgs, which is why it's the default behavior. Source tracking allows you to track the changes you make to your metadata, both in your local project and in the scratch org, and to detect any conflicts between the two.
Expand All @@ -87,3 +99,7 @@ OAuth client secret of your personal connected app
# success

Your scratch org is ready.

# action.resume

Resume scratch org creation by running sf env resume scratch --job-id %s
4 changes: 4 additions & 0 deletions messages/delete_sandbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ Are you sure you want to delete the sandbox with name: %s?
# success

Successfully marked sandbox %s for deletion.

# error.isNotSandbox

The target org, %s, is not a sandbox.
87 changes: 87 additions & 0 deletions messages/resume.sandbox.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# summary

Check the status of a sandbox creation, and log in to it if it's ready.

# description

Sandbox creation can take a long time. If the original "sf env create sandbox" command either times out, or you specified the --async flag, the command displays a job ID. Use this job ID to check whether the sandbox creation is complete, and if it is, the command then logs into it.

You can also use the sandbox name to check the status or the --use-most-recent flag to use the job ID of the most recent sandbox creation.

# examples

- Check the status of a sandbox creation using its name and specify a production org with alias "prodOrg":

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

- Check the status using the job ID:

<%= config.bin %> <%= command.id %> --job-id 0GRxxxxxxxx

- Check the status of the most recent sandbox create request:

<%= config.bin %> <%= command.id %> --use-most-recent

# flags.setDefault.summary

Set the sandbox org as your default org.

# flags.id.summary

Job ID of the incomplete sandbox creation that you want to check the status of.

# flags.id.description

The job ID is valid for 24 hours after you start the sandbox creation.

# flags.alias.summary

Alias for the sandbox org.

# flags.alias.description

When you create a sandbox, the generated usernames are based on the usernames present in the production org. To ensure uniqueness, the new usernames are appended with the name of the sandbox. For example, the username "[email protected]" in the production org results in the username "[email protected]" in a sandbox named "mysandbox". When you set an alias for a sandbox org, it's assigned to the resulting username of the user running this command.

# flags.targetOrg.summary

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

# flags.targetOrg.description

When it creates the sandbox org, Salesforce copies the metadata, and optionally data, from your production org to the new sandbox org.

# flags.name.summary

Name of the sandbox org.

# flags.wait.summary

Number of minutes to wait for the sandbox org to be ready.

# flags.wait.description

If the command continues to run after the wait period, the CLI returns control of the terminal window to you and returns the job ID. To resume checking the sandbox creation, rerun this command.

# flags.use-most-recent.summary

Use the most recent sandbox create request.

# error.pollIntervalGreaterThanWait

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

# error.NoSandboxNameOrJobId

No sandbox name or job ID were provided.

# error.LatestSandboxRequestNotFound

Retry the command using either the --name or --job-id flags.

#error.NoSandboxRequestFound

Couldn't find a sandbox creation request using the provided sandbox name or job ID.

# error.ResumeTimeout

The wait timeout (%d minutes) has expired. Check command results for more information.
41 changes: 41 additions & 0 deletions messages/resume_scratch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# summary

Resume the creation of an incomplete scratch org.

# description

When the original "sf env create scratch" command either times out or is run with the --async flag, it displays a job ID.

Run this command by either passing it a job ID or using the --use-most-recent flag to specify the most recent incomplete scratch org.

# examples

- Resume a scratch org create with a job ID:

<%= config.bin %> <%= command.id %> --job-id 2SR3u0000008fBDGAY

- Resume your most recent incomplete scratch org:

<%= config.bin %> <%= command.id %> --use-most-recent

# flags.job-id.summary

Job ID of the incomplete scratch org create that you want to resume.

# flags.job-id.description

The job ID is the same as the record ID of the incomplete scratch org in the ScratchOrgInfo object of the Dev Hub.

The job ID is valid for 24 hours after you start the scratch org creation.

# flags.use-most-recent.summary

Use the job ID of the most recent incomplete scratch org.

# error.NoRecentJobId

There are no recent job IDs (ScratchOrgInfo requests) in your cache. Maybe it completed or already resumed?

# success

Your scratch org is ready.
Loading