Skip to content

Commit 4630d43

Browse files
authored
refactor: devScripts update (#362)
* refactor: dev-scripts 3 * chore: remove jsforce types
1 parent 7ece929 commit 4630d43

File tree

12 files changed

+419
-385
lines changed

12 files changed

+419
-385
lines changed

.github/workflows/notify-slack-on-pr-open.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ jobs:
88
build:
99
runs-on: ubuntu-latest
1010
steps:
11-
- name: Notify Slack on PR open
12-
env:
13-
WEBHOOK_URL : ${{ secrets.CLI_TEAM_SLACK_WEBHOOK_URL }}
14-
PULL_REQUEST_AUTHOR_ICON_URL : ${{ github.event.pull_request.user.avatar_url }}
15-
PULL_REQUEST_AUTHOR_NAME : ${{ github.event.pull_request.user.login }}
16-
PULL_REQUEST_AUTHOR_PROFILE_URL: ${{ github.event.pull_request.user.html_url }}
17-
PULL_REQUEST_BASE_BRANCH_NAME : ${{ github.event.pull_request.base.ref }}
18-
PULL_REQUEST_COMPARE_BRANCH_NAME : ${{ github.event.pull_request.head.ref }}
19-
PULL_REQUEST_NUMBER : ${{ github.event.pull_request.number }}
20-
PULL_REQUEST_REPO: ${{ github.event.pull_request.head.repo.name }}
21-
PULL_REQUEST_TITLE : ${{ github.event.pull_request.title }}
22-
PULL_REQUEST_URL : ${{ github.event.pull_request.html_url }}
23-
uses: salesforcecli/github-workflows/.github/actions/prNotification@main
11+
- name: Notify Slack on PR open
12+
env:
13+
WEBHOOK_URL: ${{ secrets.CLI_TEAM_SLACK_WEBHOOK_URL }}
14+
PULL_REQUEST_AUTHOR_ICON_URL: ${{ github.event.pull_request.user.avatar_url }}
15+
PULL_REQUEST_AUTHOR_NAME: ${{ github.event.pull_request.user.login }}
16+
PULL_REQUEST_AUTHOR_PROFILE_URL: ${{ github.event.pull_request.user.html_url }}
17+
PULL_REQUEST_BASE_BRANCH_NAME: ${{ github.event.pull_request.base.ref }}
18+
PULL_REQUEST_COMPARE_BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
19+
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
20+
PULL_REQUEST_REPO: ${{ github.event.pull_request.head.repo.name }}
21+
PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }}
22+
PULL_REQUEST_URL: ${{ github.event.pull_request.html_url }}
23+
uses: salesforcecli/github-workflows/.github/actions/prNotification@main

package.json

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,28 @@
1616
"@oclif/plugin-command-snapshot": "3.2.0",
1717
"@salesforce/cli-plugins-testkit": "^3.0.3",
1818
"@salesforce/dev-config": "^3.0.0",
19-
"@salesforce/dev-scripts": "^2.0.0",
19+
"@salesforce/dev-scripts": "^3.0.0",
2020
"@salesforce/plugin-command-reference": "^1.3.0",
2121
"@salesforce/prettier-config": "^0.0.2",
2222
"@salesforce/ts-sinon": "1.4.0",
23-
"@types/jsforce": "^1.11.0",
24-
"@typescript-eslint/eslint-plugin": "^4.26.0",
25-
"@typescript-eslint/parser": "^4.26.0",
23+
"@typescript-eslint/eslint-plugin": "^5.33.0",
24+
"@typescript-eslint/parser": "^5.33.0",
2625
"chai": "^4.2.0",
2726
"chai-each": "^0.0.1",
2827
"cz-conventional-changelog": "^3.2.0",
29-
"eslint": "^7.27.0",
30-
"eslint-config-prettier": "^8.3.0",
31-
"eslint-config-salesforce": "^0.1.6",
28+
"eslint": "^8.21.0",
29+
"eslint-config-prettier": "^8.5.0",
30+
"eslint-config-salesforce": "^1.1.0",
3231
"eslint-config-salesforce-license": "^0.1.6",
33-
"eslint-config-salesforce-typescript": "^0.2.8",
32+
"eslint-config-salesforce-typescript": "^1.1.1",
3433
"eslint-plugin-header": "^3.0.0",
3534
"eslint-plugin-import": "2.26.0",
36-
"eslint-plugin-jsdoc": "^35.1.2",
37-
"eslint-plugin-prettier": "^3.1.3",
35+
"eslint-plugin-jsdoc": "^39.3.6",
3836
"husky": "^7.0.4",
3937
"mocha": "^9.1.3",
4038
"nyc": "^15.1.0",
4139
"oclif": "^2.6.3",
42-
"prettier": "^2.3.0",
40+
"prettier": "^2.7.1",
4341
"pretty-quick": "^3.1.0",
4442
"shx": "0.3.4",
4543
"sinon": "10.0.0",

src/commands/force/user/create.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,6 @@ export class UserCreateCommand extends SfdxCommand {
180180
}
181181
}
182182

183-
private lowerFirstLetter(word: string): string {
184-
return word[0].toLowerCase() + word.substr(1);
185-
}
186-
187183
private async aggregateFields(defaultFields: UserFields): Promise<UserFields & Dictionary<string>> {
188184
// username can be overridden both in the file or varargs, save it to check if it was changed somewhere
189185
const defaultUsername = defaultFields.username;
@@ -194,7 +190,7 @@ export class UserCreateCommand extends SfdxCommand {
194190
const content = (await fse.readJson(this.flags.definitionfile)) as UserFields;
195191
Object.keys(content).forEach((key) => {
196192
// cast entries to lowercase to standardize
197-
defaultFields[this.lowerFirstLetter(key)] = content[key] as keyof typeof REQUIRED_FIELDS;
193+
defaultFields[lowerFirstLetter(key)] = content[key] as keyof typeof REQUIRED_FIELDS;
198194
});
199195
}
200196

@@ -208,7 +204,7 @@ export class UserCreateCommand extends SfdxCommand {
208204
defaultFields['profileName'] = this.varargs[key];
209205
} else {
210206
// all other varargs are left "as is"
211-
defaultFields[this.lowerFirstLetter(key)] = this.varargs[key];
207+
defaultFields[lowerFirstLetter(key)] = this.varargs[key];
212208
}
213209
});
214210
}
@@ -271,3 +267,5 @@ export interface UserCreateOutput {
271267
permissionSetAssignments: string[];
272268
fields: Record<string, unknown>;
273269
}
270+
271+
const lowerFirstLetter = (word: string): string => word[0].toLowerCase() + word.substr(1);

src/commands/force/user/password/generate.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ export class UserPasswordGenerateCommand extends SfdxCommand {
5656
complexity: asNumber(this.flags.complexity, 5),
5757
};
5858

59+
// sequentially to avoid auth file collisions until configFile if safer
60+
/* eslint-disable no-await-in-loop */
5961
for (const aliasOrUsername of this.usernames) {
6062
try {
6163
// Convert any aliases to usernames
@@ -105,6 +107,7 @@ export class UserPasswordGenerateCommand extends SfdxCommand {
105107
throw SfError.wrap(err);
106108
}
107109
}
110+
/* eslint-enable no-await-in-loop */
108111

109112
this.print();
110113

src/commands/force/user/permset/assign.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export class UserPermsetAssignCommand extends SfdxCommand {
5252
const connection: Connection = this.org.getConnection();
5353
const org = await Org.create({ connection });
5454

55+
// sequentially to avoid auth file collisions until configFile if safer
56+
/* eslint-disable no-await-in-loop */
5557
for (const aliasOrUsername of aliasOrUsernames) {
5658
// Attempt to convert any aliases to usernames. Not found alias will be **assumed** to be a username
5759
const username = (await StateAggregator.getInstance()).aliases.resolveUsername(aliasOrUsername);
@@ -77,6 +79,7 @@ export class UserPermsetAssignCommand extends SfdxCommand {
7779
}
7880
}
7981
}
82+
/* eslint-enable no-await-in-loop */
8083
} catch (e) {
8184
if (e instanceof Error || typeof e === 'string') {
8285
throw SfError.wrap(e);

src/commands/force/user/permsetlicense/assign.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,4 @@ export class UserPermsetLicenseAssignCommand extends SfdxCommand {
162162
}
163163
}
164164

165-
const isSuccess = (input: SuccessMsg | FailureMsg): input is SuccessMsg => {
166-
return (input as SuccessMsg).value !== undefined;
167-
};
165+
const isSuccess = (input: SuccessMsg | FailureMsg): input is SuccessMsg => (input as SuccessMsg).value !== undefined;

test/commands/user/create.test.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,18 @@ describe('force:user:create', () => {
6969
stubMethod($$.SANDBOX, Org, 'create').resolves(Org.prototype);
7070
stubMethod($$.SANDBOX, Org.prototype, 'getConnection').returns(Connection.prototype);
7171
stubMethod($$.SANDBOX, DefaultUserFields, 'create').resolves({
72-
getFields: (): UserFields => {
73-
return {
74-
id: originalUserId,
75-
username: '1605130295132_test-j6asqt5qoprs@example.com',
76-
alias: 'testAlias',
77-
email: username,
78-
emailEncodingKey: 'UTF-8',
79-
languageLocaleKey: 'en_US',
80-
localeSidKey: 'en_US',
81-
profileId: '00e2D000000bNexWWR',
82-
lastName: 'User',
83-
timeZoneSidKey: 'America/Los_Angeles',
84-
};
85-
},
72+
getFields: (): UserFields => ({
73+
id: originalUserId,
74+
username: '1605130295132_test-j6asqt5qoprs@example.com',
75+
alias: 'testAlias',
76+
email: username,
77+
emailEncodingKey: 'UTF-8',
78+
languageLocaleKey: 'en_US',
79+
localeSidKey: 'en_US',
80+
profileId: '00e2D000000bNexWWR',
81+
lastName: 'User',
82+
timeZoneSidKey: 'America/Los_Angeles',
83+
}),
8684
});
8785

8886
stubMethod($$.SANDBOX, User, 'create').callsFake(() => User.prototype);

test/commands/user/display.test.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ describe('force:user:display', () => {
2020
if (queries) {
2121
stubMethod($$.SANDBOX, Org.prototype, 'readUserAuthFiles').returns([
2222
{
23-
getFields: () => {
24-
return {
25-
username: 'defaultusername@test.com',
26-
instanceUrl: 'instanceURL',
27-
loginUrl: 'login.test.com',
28-
};
29-
},
23+
getFields: () => ({
24+
username: 'defaultusername@test.com',
25+
instanceUrl: 'instanceURL',
26+
loginUrl: 'login.test.com',
27+
}),
3028
},
3129
]);
3230
stubMethod($$.SANDBOX, Connection.prototype, 'query')
@@ -39,16 +37,14 @@ describe('force:user:display', () => {
3937
} else {
4038
stubMethod($$.SANDBOX, Org.prototype, 'readUserAuthFiles').returns([
4139
{
42-
getFields: () => {
43-
return {
44-
username: 'defaultusername@test.com',
45-
userProfileName: 'profileName',
46-
userId: '1234567890',
47-
instanceUrl: 'instanceURL',
48-
loginUrl: 'login.test.com',
49-
password: '-a098u234/1!@#',
50-
};
51-
},
40+
getFields: () => ({
41+
username: 'defaultusername@test.com',
42+
userProfileName: 'profileName',
43+
userId: '1234567890',
44+
instanceUrl: 'instanceURL',
45+
loginUrl: 'login.test.com',
46+
password: '-a098u234/1!@#',
47+
}),
5248
},
5349
]);
5450
}

test/commands/user/list.test.ts

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,25 @@ describe('force:user:list', () => {
4343
stubMethod($$.SANDBOX, Org.prototype, 'readUserAuthFiles').returns([
4444
{
4545
getUsername: () => user1,
46-
getFields: () => {
47-
return {
48-
username: user1,
49-
userProfileName: 'profileName',
50-
userId: '1234567890',
51-
instanceUrl: 'instanceURL',
52-
loginUrl: 'login.test.com',
53-
accessToken: 'accessToken',
54-
};
55-
},
46+
getFields: () => ({
47+
username: user1,
48+
userProfileName: 'profileName',
49+
userId: '1234567890',
50+
instanceUrl: 'instanceURL',
51+
loginUrl: 'login.test.com',
52+
accessToken: 'accessToken',
53+
}),
5654
},
5755
{
5856
getUsername: () => user2,
59-
getFields: () => {
60-
return {
61-
username: user2,
62-
userProfileName: 'profileName',
63-
userId: '1234567890',
64-
instanceUrl: 'instanceURL',
65-
loginUrl: 'login.test.com',
66-
accessToken: 'accessToken',
67-
};
68-
},
57+
getFields: () => ({
58+
username: user2,
59+
userProfileName: 'profileName',
60+
userId: '1234567890',
61+
instanceUrl: 'instanceURL',
62+
loginUrl: 'login.test.com',
63+
accessToken: 'accessToken',
64+
}),
6965
},
7066
]);
7167
stubMethod($$.SANDBOX, Org.prototype, 'getOrgId').returns('abc123');

test/commands/user/password/generate.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe('force:user:password:generate', () => {
9292
});
9393

9494
test
95-
.do(async () => await prepareStubs(true))
95+
.do(async () => prepareStubs(true))
9696

9797
.stdout()
9898
.command(['force:user:password:generate', '--json'])

test/commands/user/permsetlicense/assign.test.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,11 @@ describe('force:user:permsetlicense:assign', () => {
4343
.withArgs(`select Id from PermissionSetLicense where DeveloperName = '${badPSL}' or MasterLabel = '${badPSL}'`)
4444
.throws();
4545

46-
stubMethod($$.SANDBOX, Connection.prototype, 'sobject').callsFake(() => {
47-
return {
48-
create() {
49-
return Promise.resolve({ success: true });
50-
},
51-
};
52-
});
46+
stubMethod($$.SANDBOX, Connection.prototype, 'sobject').callsFake(() => ({
47+
create() {
48+
return Promise.resolve({ success: true });
49+
},
50+
}));
5351
}
5452

5553
test

0 commit comments

Comments
 (0)