Skip to content

Commit 2a47f14

Browse files
authored
Merge branch 'main' into cd/org-create-duration-default
2 parents ee1a3b4 + 8374fdc commit 2a47f14

File tree

6 files changed

+74
-98
lines changed

6 files changed

+74
-98
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
### [2.0.4](https://github.com/salesforcecli/plugin-org/compare/v2.0.3...v2.0.4) (2022-07-15)
6+
7+
### Bug Fixes
8+
9+
- bump version of @salesforce/core ([b435562](https://github.com/salesforcecli/plugin-org/commit/b435562e3dc8a2e1b92c61b4dc4f7711440aaed9))
10+
- use newer core scratchOrgCreate ([6694302](https://github.com/salesforcecli/plugin-org/commit/6694302a74192d4eedc4e4f5541a423c1c0f965f))
11+
512
### [2.0.3](https://github.com/salesforcecli/plugin-org/compare/v2.0.2...v2.0.3) (2022-07-13)
613

714
### Bug Fixes

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ EXAMPLES
142142
$ sfdx force:org:create -t sandbox -f config/dev-sandbox-def.json -a MyDevSandbox -u prodOrg
143143
```
144144

145-
_See code: [src/commands/force/org/beta/create.ts](https://github.com/salesforcecli/plugin-org/blob/v2.0.2/src/commands/force/org/beta/create.ts)_
145+
_See code: [src/commands/force/org/beta/create.ts](https://github.com/salesforcecli/plugin-org/blob/v2.0.3/src/commands/force/org/beta/create.ts)_
146146

147147
## `sfdx force:org:clone [name=value...] -t sandbox [-f <filepath>] [-s] [-a <string>] [-w <minutes>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
148148

@@ -186,7 +186,7 @@ EXAMPLES
186186
$ sfdx force:org:clone -t sandbox SandboxName=NewClonedSandbox SourceSandboxName=ExistingSandbox -u prodOrg -a MyDevSandbox
187187
```
188188

189-
_See code: [src/commands/force/org/clone.ts](https://github.com/salesforcecli/plugin-org/blob/v2.0.2/src/commands/force/org/clone.ts)_
189+
_See code: [src/commands/force/org/clone.ts](https://github.com/salesforcecli/plugin-org/blob/v2.0.3/src/commands/force/org/clone.ts)_
190190

191191
## `sfdx force:org:delete [-p] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
192192

@@ -220,7 +220,7 @@ EXAMPLES
220220
$ sfdx force:org:delete -u MyOrgAlias -p
221221
```
222222

223-
_See code: [src/commands/force/org/delete.ts](https://github.com/salesforcecli/plugin-org/blob/v2.0.2/src/commands/force/org/delete.ts)_
223+
_See code: [src/commands/force/org/delete.ts](https://github.com/salesforcecli/plugin-org/blob/v2.0.3/src/commands/force/org/delete.ts)_
224224

225225
## `sfdx force:org:display [-u <string>] [--apiversion <string>] [--verbose] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
226226

@@ -264,7 +264,7 @@ EXAMPLES
264264
$ sfdx force:org:display -u TestOrg1 --json > tmp/MyOrgDesc.json
265265
```
266266

267-
_See code: [src/commands/force/org/display.ts](https://github.com/salesforcecli/plugin-org/blob/v2.0.2/src/commands/force/org/display.ts)_
267+
_See code: [src/commands/force/org/display.ts](https://github.com/salesforcecli/plugin-org/blob/v2.0.3/src/commands/force/org/display.ts)_
268268

269269
## `sfdx force:org:list [--all] [-p --clean] [--skipconnectionstatus] [--verbose] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
270270

@@ -301,7 +301,7 @@ EXAMPLES
301301
$ sfdx force:org:list --verbose --json > tmp/MyOrgList.json
302302
```
303303

304-
_See code: [src/commands/force/org/list.ts](https://github.com/salesforcecli/plugin-org/blob/v2.0.2/src/commands/force/org/list.ts)_
304+
_See code: [src/commands/force/org/list.ts](https://github.com/salesforcecli/plugin-org/blob/v2.0.3/src/commands/force/org/list.ts)_
305305

306306
## `sfdx force:org:open [-b <string> | -r] [-p <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
307307

@@ -351,7 +351,7 @@ EXAMPLES
351351
$ sfdx force:org:open -u [email protected] -b firefox
352352
```
353353

354-
_See code: [src/commands/force/org/open.ts](https://github.com/salesforcecli/plugin-org/blob/v2.0.2/src/commands/force/org/open.ts)_
354+
_See code: [src/commands/force/org/open.ts](https://github.com/salesforcecli/plugin-org/blob/v2.0.3/src/commands/force/org/open.ts)_
355355

356356
## `sfdx force:org:status -n <string> [-s] [-a <string>] [-w <minutes>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`
357357

@@ -397,6 +397,6 @@ EXAMPLES
397397
$ sfdx force:org:status --sandboxname DevSbx1 --wait 45 --setdefaultusername -u prodOrg
398398
```
399399

400-
_See code: [src/commands/force/org/status.ts](https://github.com/salesforcecli/plugin-org/blob/v2.0.2/src/commands/force/org/status.ts)_
400+
_See code: [src/commands/force/org/status.ts](https://github.com/salesforcecli/plugin-org/blob/v2.0.3/src/commands/force/org/status.ts)_
401401

402402
<!-- commandsstop -->

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "@salesforce/plugin-org",
33
"description": "Commands to interact with Salesforce orgs",
4-
"version": "2.0.3",
4+
"version": "2.0.4",
55
"author": "Salesforce",
66
"main": "lib/index.js",
77
"bugs": "https://github.com/forcedotcom/cli/issues",
88
"dependencies": {
99
"@oclif/core": "^1.7.0",
1010
"@salesforce/command": "^5.2.0",
11-
"@salesforce/core": "^3.23.8",
11+
"@salesforce/core": "^3.24.0",
1212
"@salesforce/kit": "^1.5.17",
1313
"open": "8.4.0",
1414
"tslib": "^2"

src/commands/force/org/beta/create.ts

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import {
2525
SandboxUserAuthResponse,
2626
SfError,
2727
StatusEvent,
28-
ScratchOrgRequest,
2928
ScratchOrgInfo,
29+
ScratchOrgRequest,
3030
} from '@salesforce/core';
3131
import { OrgCreateResult } from '../../../../shared/orgHooks';
3232
import { SandboxReporter } from '../../../../shared/sandboxReporter';
@@ -261,25 +261,6 @@ export class Create extends SfdxCommand {
261261
}
262262
}
263263

264-
private async setAliasAndDefaultUsername(username: string): Promise<void> {
265-
const stateAggregator = await StateAggregator.getInstance();
266-
if (this.flags.setalias) {
267-
stateAggregator.aliases.set(this.flags.setalias, username);
268-
this.logger.debug('Set Alias: %s result: %s', this.flags.setalias);
269-
}
270-
if (this.flags.setdefaultusername) {
271-
let config: Config;
272-
try {
273-
config = await Config.create({ isGlobal: false });
274-
} catch {
275-
config = await Config.create({ isGlobal: true });
276-
}
277-
const value = stateAggregator.aliases.get(username) || username;
278-
const result = config.set(OrgConfigProperties.TARGET_ORG, value);
279-
await config.write();
280-
this.logger.debug('Set defaultUsername: %s result: %s', this.flags.setdefaultusername, result);
281-
}
282-
}
283264
private async createScratchOrg(): Promise<ScratchOrgProcessObject> {
284265
this.logger.debug('OK, will do scratch org creation');
285266
if (!this.hubOrg) {
@@ -292,15 +273,14 @@ export class Create extends SfdxCommand {
292273

293274
this.logger.debug('validation complete');
294275

295-
let secret: string;
296-
if (this.flags.clientid) {
297-
// If the user supplied a specific client ID, we have no way of knowing if it's
298-
// a certificate-based Connected App or not. Therefore, we have to assume that
299-
// we'll need the client secret, so prompt the user for it.
300-
secret = await this.ux.prompt(messages.getMessage('secretPrompt'), {
301-
type: 'mask',
302-
});
303-
}
276+
// If the user supplied a specific client ID, we have no way of knowing if it's
277+
// a certificate-based Connected App or not. Therefore, we have to assume that
278+
// we'll need the client secret, so prompt the user for it.
279+
const secret = this.flags.clientid
280+
? await this.ux.prompt(messages.getMessage('secretPrompt'), {
281+
type: 'mask',
282+
})
283+
: undefined;
304284

305285
const createCommandOptions: ScratchOrgRequest = {
306286
connectedAppConsumerKey: this.flags.clientid as string,
@@ -313,14 +293,15 @@ export class Create extends SfdxCommand {
313293
definitionfile: this.flags.definitionfile as string,
314294
orgConfig: this.varargs,
315295
clientSecret: secret,
296+
setDefault: (this.flags.setdefaultusername as boolean) === true,
297+
alias: this.flags.setalias as string | undefined,
298+
tracksSource: true,
316299
};
317300

318301
const { username, scratchOrgInfo, authFields, warnings } = await this.hubOrg.scratchOrgCreate(createCommandOptions);
319302

320303
await Lifecycle.getInstance().emit('scratchOrgInfo', scratchOrgInfo);
321304

322-
await this.setAliasAndDefaultUsername(username);
323-
324305
// emit postorgcreate event for hook
325306
const postOrgCreateHookInfo: OrgCreateResult = [authFields].map((element) => ({
326307
accessToken: element.accessToken,

test/commands/force/org/scratchOrgCreate.test.ts

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Licensed under the BSD 3-Clause license.
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
7-
import { Config, StateAggregator, SfError, Messages, Org, SfProject } from '@salesforce/core';
7+
import { SfError, Messages, Org, SfProject } from '@salesforce/core';
88
import { fromStub, stubInterface, stubMethod } from '@salesforce/ts-sinon';
99
import * as sinon from 'sinon';
1010
import { expect } from '@salesforce/command/lib/test';
@@ -44,8 +44,6 @@ describe('org:create', () => {
4444
let uxLogStub: sinon.SinonStub;
4545
let uxWarnStub: sinon.SinonStub;
4646
let promptStub: sinon.SinonStub;
47-
let aliasGetStub: sinon.SinonStub;
48-
let aliasSetStub: sinon.SinonSpy;
4947
let cmd: TestCreate;
5048

5149
class TestCreate extends Create {
@@ -109,6 +107,7 @@ describe('org:create', () => {
109107
const prodOrg = stubMethod(sandbox, Org.prototype, 'scratchOrgCreate').resolves(CREATE_RESULT);
110108
await command.runIt();
111109
expect(prodOrg.firstCall.args[0]).to.deep.equal({
110+
alias: undefined,
112111
apiversion: undefined,
113112
clientSecret: undefined,
114113
connectedAppConsumerKey: undefined,
@@ -120,6 +119,8 @@ describe('org:create', () => {
120119
unit: 0,
121120
},
122121
retry: 0,
122+
setDefault: false,
123+
tracksSource: true,
123124
definitionfile: 'myScratchDef.json',
124125
orgConfig: {
125126
licenseType: 'LicenseFromVarargs',
@@ -161,6 +162,7 @@ describe('org:create', () => {
161162
const prodOrg = stubMethod(sandbox, Org.prototype, 'scratchOrgCreate').resolves(CREATE_RESULT);
162163
await command.runIt();
163164
expect(prodOrg.firstCall.args[0]).to.deep.equal({
165+
alias: undefined,
164166
apiversion: undefined,
165167
clientSecret,
166168
connectedAppConsumerKey,
@@ -173,6 +175,8 @@ describe('org:create', () => {
173175
unit: 0,
174176
},
175177
retry: 0,
178+
setDefault: false,
179+
tracksSource: true,
176180
orgConfig: {},
177181
});
178182
expect(promptStub.callCount).to.equal(1);
@@ -201,17 +205,9 @@ describe('org:create', () => {
201205
...CREATE_RESULT,
202206
username: 'newScratchUsername',
203207
});
204-
aliasGetStub = sinon.stub().returns('');
205-
aliasSetStub = sinon.spy();
206-
stubMethod(sandbox, StateAggregator, 'getInstance').returns({
207-
aliases: {
208-
get: aliasGetStub,
209-
set: aliasSetStub,
210-
},
211-
});
212-
const configStub = stubMethod(sandbox, Config.prototype, 'set');
213208
await command.runIt();
214209
expect(prodOrg.firstCall.args[0]).to.deep.equal({
210+
alias: 'scratchOrgAlias',
215211
apiversion: undefined,
216212
clientSecret: undefined,
217213
connectedAppConsumerKey: undefined,
@@ -224,11 +220,10 @@ describe('org:create', () => {
224220
unit: 0,
225221
},
226222
retry: 0,
223+
setDefault: true,
224+
tracksSource: true,
227225
orgConfig: {},
228226
});
229-
expect(aliasSetStub.firstCall.args).to.deep.equal(['scratchOrgAlias', 'newScratchUsername']);
230-
expect(aliasGetStub.firstCall.args).to.deep.equal(['newScratchUsername']);
231-
expect(configStub.firstCall.args).to.deep.equal(['target-org', 'newScratchUsername']);
232227
});
233228

234229
it('will set alias as default', async () => {
@@ -252,18 +247,9 @@ describe('org:create', () => {
252247
username: 'newScratchUsername',
253248
});
254249

255-
aliasGetStub = sinon.stub().returns('scratchOrgAlias');
256-
aliasSetStub = sinon.spy();
257-
stubMethod(sandbox, StateAggregator, 'getInstance').returns({
258-
aliases: {
259-
get: aliasGetStub,
260-
set: aliasSetStub,
261-
},
262-
});
263-
264-
const configStub = stubMethod(sandbox, Config.prototype, 'set');
265250
await command.runIt();
266251
expect(prodOrg.firstCall.args[0]).to.deep.equal({
252+
alias: 'scratchOrgAlias',
267253
apiversion: undefined,
268254
clientSecret: undefined,
269255
connectedAppConsumerKey: undefined,
@@ -277,10 +263,9 @@ describe('org:create', () => {
277263
},
278264
retry: 0,
279265
orgConfig: {},
266+
setDefault: true,
267+
tracksSource: true,
280268
});
281-
expect(aliasSetStub.firstCall.args).to.deep.equal(['scratchOrgAlias', 'newScratchUsername']);
282-
expect(aliasGetStub.firstCall.args).to.deep.equal(['newScratchUsername']);
283-
expect(configStub.firstCall.args).to.deep.equal(['target-org', 'scratchOrgAlias']);
284269
});
285270

286271
it('will test json output', async () => {
@@ -295,6 +280,7 @@ describe('org:create', () => {
295280
});
296281
const result = await command.runIt();
297282
expect(prodOrg.firstCall.args[0]).to.deep.equal({
283+
alias: undefined,
298284
apiversion: undefined,
299285
clientSecret: undefined,
300286
connectedAppConsumerKey: undefined,
@@ -307,6 +293,8 @@ describe('org:create', () => {
307293
unit: 0,
308294
},
309295
retry: 0,
296+
tracksSource: true,
297+
setDefault: false,
310298
orgConfig: {},
311299
});
312300
expect(result).to.have.keys(['username', 'authFields', 'scratchOrgInfo', 'warnings', 'orgId']);

yarn.lock

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,10 +1104,10 @@
11041104
semver "^7.3.5"
11051105
ts-retry-promise "^0.6.0"
11061106

1107-
"@salesforce/core@^3.20.1", "@salesforce/core@^3.23.8":
1108-
version "3.23.8"
1109-
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-3.23.8.tgz#de175ef8e9bce757adb1d515f43ce942b1427e2c"
1110-
integrity sha512-xE0yar5cDL0+PZbvJqRgzekY3ZKeFpZqhVQlsFMWMUH0jBo+sao8sS6U6aTnCJfISnDw08CMW90Kp8rgkYyvHA==
1107+
"@salesforce/core@^3.20.1", "@salesforce/core@^3.24.0":
1108+
version "3.24.0"
1109+
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-3.24.0.tgz#ecfa4ae3c23dab37b7431e5d8e7b623db2ba4f12"
1110+
integrity sha512-PiiJAfCIw0Gj9CUm0Y9C211JXgyJASoywHPmWKe6RY4Ul+WuHkFBDGmdRkuxHLA23P0PVZaclT0Av3CbWwmPSg==
11111111
dependencies:
11121112
"@salesforce/bunyan" "^2.0.0"
11131113
"@salesforce/kit" "^1.5.41"
@@ -1124,7 +1124,7 @@
11241124
form-data "^4.0.0"
11251125
graceful-fs "^4.2.9"
11261126
js2xmlparser "^4.0.1"
1127-
jsforce "2.0.0-beta.14"
1127+
jsforce beta
11281128
jsonwebtoken "8.5.1"
11291129
mkdirp "1.0.4"
11301130
ts-retry-promise "^0.6.0"
@@ -4814,10 +4814,31 @@ jsesc@^2.5.1:
48144814
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4"
48154815
integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==
48164816

4817-
4818-
version "2.0.0-beta.14"
4819-
resolved "https://registry.yarnpkg.com/jsforce/-/jsforce-2.0.0-beta.14.tgz#237753bdabb7e80447b5b266eaefc4abf8b6c951"
4820-
integrity sha512-j66PaKroshB4VZbfKBAx9+lJy8etFfGG1hGFsI7ufwxvacXxLTAxZwOEZPkYPMigiHrPlEMtIwh5NqwBsIn9HA==
4817+
jsforce@^1.11.0:
4818+
version "1.11.0"
4819+
resolved "https://registry.yarnpkg.com/jsforce/-/jsforce-1.11.0.tgz#7e853b82c534f1fe8e18f432a344bae81881a133"
4820+
integrity sha512-vYNXJXXdz9ZQNdfRqq/MCJ/zU7JGA7iEduwafQDzChR9FeqXgTNfHTppLVbw9mIniKkQZemmxSOtl7N04lj/5Q==
4821+
dependencies:
4822+
base64-url "^2.2.0"
4823+
co-prompt "^1.0.0"
4824+
coffeescript "^1.10.0"
4825+
commander "^2.9.0"
4826+
csv-parse "^4.10.1"
4827+
csv-stringify "^1.0.4"
4828+
faye "^1.4.0"
4829+
inherits "^2.0.1"
4830+
lodash "^4.17.19"
4831+
multistream "^2.0.5"
4832+
opn "^5.3.0"
4833+
promise "^7.1.1"
4834+
readable-stream "^2.1.0"
4835+
request "^2.72.0"
4836+
xml2js "^0.4.16"
4837+
4838+
jsforce@beta:
4839+
version "2.0.0-beta.15"
4840+
resolved "https://registry.yarnpkg.com/jsforce/-/jsforce-2.0.0-beta.15.tgz#05255f3b54a001421c973b1a7b4dbb4468ded2a3"
4841+
integrity sha512-AfwIxG+y+WOsqSGKlezyL3G+4ItmR/zfcvg38x4CDa3eizDD0wWZBAOnJbOQ8U76zAQqrMsyWs+s3ozJzSLtZA==
48214842
dependencies:
48224843
"@babel/runtime" "^7.12.5"
48234844
"@babel/runtime-corejs3" "^7.12.5"
@@ -4840,27 +4861,6 @@ [email protected]:
48404861
strip-ansi "^6.0.0"
48414862
xml2js "^0.4.22"
48424863

4843-
jsforce@^1.11.0:
4844-
version "1.11.0"
4845-
resolved "https://registry.yarnpkg.com/jsforce/-/jsforce-1.11.0.tgz#7e853b82c534f1fe8e18f432a344bae81881a133"
4846-
integrity sha512-vYNXJXXdz9ZQNdfRqq/MCJ/zU7JGA7iEduwafQDzChR9FeqXgTNfHTppLVbw9mIniKkQZemmxSOtl7N04lj/5Q==
4847-
dependencies:
4848-
base64-url "^2.2.0"
4849-
co-prompt "^1.0.0"
4850-
coffeescript "^1.10.0"
4851-
commander "^2.9.0"
4852-
csv-parse "^4.10.1"
4853-
csv-stringify "^1.0.4"
4854-
faye "^1.4.0"
4855-
inherits "^2.0.1"
4856-
lodash "^4.17.19"
4857-
multistream "^2.0.5"
4858-
opn "^5.3.0"
4859-
promise "^7.1.1"
4860-
readable-stream "^2.1.0"
4861-
request "^2.72.0"
4862-
xml2js "^0.4.16"
4863-
48644864
json-parse-better-errors@^1.0.1:
48654865
version "1.0.2"
48664866
resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9"

0 commit comments

Comments
 (0)