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

refactor: devScripts update #646

Merged
merged 6 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"require": "ts-node/register,source-map-support/register",
"watch-extensions": "ts",
"watch-files": ["src", "test"],
"recursive": true,
"reporter": "spec",
"timeout": 5000
Expand Down
44 changes: 35 additions & 9 deletions command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,41 @@
"target-dev-hub",
"target-org"
],
"alias": []
"alias": [],
"flagChars": ["c", "l", "o", "u", "v"],
"flagAliases": ["apiversion", "onbehalfof", "targetdevhubusername", "targetusername"]
},
{
"command": "force:user:permset:assign",
"plugin": "@salesforce/plugin-user",
"flags": ["api-version", "json", "loglevel", "on-behalf-of", "perm-set-name", "target-org"],
"alias": []
"alias": [],
"flagChars": ["n", "o", "u"],
"flagAliases": ["apiversion", "onbehalfof", "permsetname", "targetusername"]
},
{
"command": "force:user:permsetlicense:assign",
"plugin": "@salesforce/plugin-user",
"flags": ["api-version", "json", "loglevel", "name", "on-behalf-of", "target-org"],
"alias": []
"alias": [],
"flagChars": ["b", "n", "u"],
"flagAliases": ["apiversion", "onbehalfof", "perm-set-license", "psl", "targetusername"]
},
{
"command": "org:assign:permset",
"plugin": "@salesforce/plugin-user",
"flags": ["api-version", "json", "name", "on-behalf-of", "target-org"],
"alias": []
"alias": [],
"flagChars": ["b", "n", "o"],
"flagAliases": ["onbehalfof", "permsetname"]
},
{
"command": "org:assign:permsetlicense",
"plugin": "@salesforce/plugin-user",
"flags": ["api-version", "json", "name", "on-behalf-of", "target-org"],
"alias": []
"alias": [],
"flagChars": ["b", "n", "o"],
"flagAliases": ["onbehalfof", "perm-set-license", "psl"]
},
{
"command": "org:create:user",
Expand All @@ -51,24 +61,40 @@
"target-dev-hub",
"target-org"
],
"alias": ["force:user:create"]
"alias": ["force:user:create"],
"flagChars": ["a", "f", "o", "s", "v"],
"flagAliases": [
"apiversion",
"definitionfile",
"setalias",
"setuniqueusername",
"targetdevhubusername",
"targetusername",
"u"
]
},
{
"command": "org:display:user",
"plugin": "@salesforce/plugin-user",
"flags": ["api-version", "json", "loglevel", "target-dev-hub", "target-org"],
"alias": ["force:user:display"]
"alias": ["force:user:display"],
"flagChars": ["o", "v"],
"flagAliases": ["apiversion", "targetdevhubusername", "targetusername", "u"]
},
{
"command": "org:generate:password",
"plugin": "@salesforce/plugin-user",
"flags": ["api-version", "complexity", "json", "length", "on-behalf-of", "target-org"],
"alias": []
"alias": [],
"flagChars": ["b", "c", "l", "o"],
"flagAliases": ["onbehalfof"]
},
{
"command": "org:list:users",
"plugin": "@salesforce/plugin-user",
"flags": ["api-version", "json", "loglevel", "target-dev-hub", "target-org"],
"alias": ["force:user:list"]
"alias": ["force:user:list"],
"flagChars": ["o", "v"],
"flagAliases": ["apiversion", "targetusername", "u"]
}
]
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/core": "^2.8.2",
"@salesforce/core": "^4.0.1",
"@salesforce/core": "^4.1.0",
"@salesforce/kit": "^3.0.2",
"@salesforce/sf-plugins-core": "^3.0.2",
"@salesforce/ts-types": "^2.0.2",
"tslib": "^2"
},
"devDependencies": {
"@oclif/plugin-command-snapshot": "^3.3.15",
"@salesforce/cli-plugins-testkit": "^3.4.0",
"@oclif/plugin-command-snapshot": "^4.0.2",
"@salesforce/cli-plugins-testkit": "^4.0.1",
"@salesforce/dev-config": "^4.0.1",
"@salesforce/dev-scripts": "^5.3.0",
"@salesforce/plugin-command-reference": "^2.4.4",
"@salesforce/dev-scripts": "^5.4.2",
"@salesforce/plugin-command-reference": "^3.0.2",
"@salesforce/plugin-source": "^2.10.12",
"@salesforce/prettier-config": "^0.0.3",
"@salesforce/ts-sinon": "^1.4.7",
Expand All @@ -33,18 +33,18 @@
"eslint-config-salesforce": "^2.0.1",
"eslint-config-salesforce-license": "^0.2.0",
"eslint-config-salesforce-typescript": "^1.1.1",
"eslint-plugin-header": "^3.0.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsdoc": "^43.0.5",
"eslint-plugin-sf-plugin": "^1.15.5",
"eslint-plugin-sf-plugin": "^1.15.6",
"husky": "^7.0.4",
"mocha": "^9.1.3",
"nyc": "^15.1.0",
"oclif": "^3.9.0",
"prettier": "^2.8.8",
"pretty-quick": "^3.1.0",
"shx": "0.3.4",
"sinon": "10.0.0",
"sinon": "^15.1.0",
"ts-node": "^10.0.0",
"typescript": "^4.9.5",
"wireit": "^0.9.5"
Expand Down Expand Up @@ -244,4 +244,4 @@
"output": []
}
}
}
}
46 changes: 29 additions & 17 deletions test/commands/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,23 @@ describe('org:create:user', () => {

it('will properly merge fields regardless of capitalization', async () => {
// notice the varied capitalization
$$.SANDBOX.stub(fs.promises, 'readFile').resolves(
JSON.stringify({
id: originalUserId,
Username: '[email protected]',
Alias: 'testAlias',
Email: username,
EmailEncodingKey: 'UTF-8',
LanguageLocaleKey: 'en_US',
localeSidKey: 'en_US',
ProfileId: '00e2D000000bNexWWR',
LastName: 'User',
timeZoneSidKey: 'America/Los_Angeles',
permsets: ['permset1', 'permset2'],
})
);
$$.SANDBOX.stub(fs.promises, 'readFile')
.withArgs('testing')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only change readFile for the file you care about

.resolves(
JSON.stringify({
id: originalUserId,
Username: '[email protected]',
Alias: 'testAlias',
Email: username,
EmailEncodingKey: 'UTF-8',
LanguageLocaleKey: 'en_US',
localeSidKey: 'en_US',
ProfileId: '00e2D000000bNexWWR',
LastName: 'User',
timeZoneSidKey: 'America/Los_Angeles',
permsets: ['permset1', 'permset2'],
})
);

const createCommand = new CreateUserCommand(['-f', 'userConfig.json'], {} as Config);

Expand Down Expand Up @@ -131,7 +133,15 @@ describe('org:create:user', () => {
if (readsFile) {
$$.SANDBOXES.CONNECTION.stub(Connection.prototype, 'singleRecordQuery').resolves({ Id: '12345678' });
$$.SANDBOX.stub(Logger.prototype, 'debug');
$$.SANDBOX.stub(fs.promises, 'readFile').resolves(JSON.stringify(readsFile));
if (typeof readsFile !== 'boolean') {
const fsStub = $$.SANDBOX.stub(fs.promises, 'readFile');
fsStub.withArgs('parent/child/file.json').resolves(JSON.stringify(readsFile));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only changes readFile for the file it needs to stub. callThrough lets the original implementation work in other cases.

fsStub.callThrough();
// $$.SANDBOX.stub(fs.promises, 'readFile')
// .withArgs('parent/child/file.json')
// .resolves(JSON.stringify(readsFile))
// .callThrough();
}
}
}

Expand All @@ -151,7 +161,7 @@ describe('org:create:user', () => {
localesidkey: 'en_US',
generatepassword: true,
profileid: '12345678',
profilename: 'profileFromArgs',
profilename: 'profileFromFile',
timezonesidkey: 'America/Los_Angeles',
username: '[email protected]',
},
Expand All @@ -163,6 +173,8 @@ describe('org:create:user', () => {
testOrg.username,
'--target-dev-hub',
'[email protected]',
'--definition-file',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test says it's testing override of file, but wasn't using the file contents.

'parent/child/file.json',
"permsets='permCLI, permCLI2'",
'generatepassword=true',
],
Expand Down
Loading