Skip to content

Commit 87accd4

Browse files
chore: fixed varargs on user:create, fixed list
1 parent c89dd2d commit 87accd4

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

messages/create.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"description": "create a user for a scratch org",
33
"examples": [
44
"sfdx force:user:create",
5-
"sfdx force:user:create -a testuser1 -f config/project-user-def.json",
5+
"sfdx force:user:create -a testuser1 -f config/project-user-def.json profileName='Chatter Free User'",
66
"sfdx force:user:create username=testuser1@my.org email=me@my.org permsets=DreamHouse",
77
"sfdx force:user:create -f config/project-user-def.json email=me@my.org generatepassword=true"
88
],

src/commands/force/user/create.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,7 @@ export class UserCreateCommand extends SfdxCommand {
168168

169169
if (this.varargs) {
170170
Object.keys(this.varargs).forEach((key) => {
171-
if (defaultFields[key]) {
172-
defaultFields[this.lowerFirstLetter(key)] = this.varargs[key];
173-
}
171+
defaultFields[this.lowerFirstLetter(key)] = this.varargs[key];
174172
});
175173
}
176174

src/commands/force/user/list.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
import * as os from 'os';
88
import { SfdxCommand } from '@salesforce/command';
9-
import { Messages, Connection, Aliases, AuthInfo } from '@salesforce/core';
9+
import { Messages, Connection, Aliases, AuthInfo, ConfigAggregator } from '@salesforce/core';
1010

1111
Messages.importMessagesDirectory(__dirname);
1212
const messages = Messages.loadMessages('@salesforce/plugin-user', 'list');
@@ -38,14 +38,16 @@ export class UserListCommand extends SfdxCommand {
3838
const userInfos: UserInfo = await this.buildUserInfos();
3939
const profileInfos: ProfileInfo = await this.buildProfileInfos();
4040
const userAuthData: AuthInfo[] = await this.org.readUserAuthFiles();
41-
42-
const alias = await Aliases.fetch(this.flags.targetusername);
41+
const aliases = await Aliases.create(Aliases.getDefaultOptions());
4342

4443
const authList: AuthList[] = userAuthData.map((authData) => {
4544
const username = authData.getUsername();
46-
45+
// if they passed in a alias and it maps to something we have an Alias.
46+
const alias = aliases.getKeysByValue(authData.getUsername())[0];
47+
const configAgg = ConfigAggregator.getInstance();
48+
const defaultUser = configAgg.getLocalConfig().get('defaultusername');
4749
return {
48-
defaultMarker: authData.getFields().scratchAdminUsername ? '' : '(A)',
50+
defaultMarker: defaultUser === username ? '(A)' : '',
4951
alias: alias || '',
5052
username,
5153
profileName: profileInfos[userInfos[username].ProfileId],

test/commands/user/list.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('force:user:list', () => {
2828
},
2929
]);
3030
stubMethod($$.SANDBOX, Org.prototype, 'getOrgId').returns('abc123');
31-
stubMethod($$.SANDBOX, Aliases, 'fetch').resolves('testAlias');
31+
stubMethod($$.SANDBOX, Aliases.prototype, 'getKeysByValue').returns(['testAlias']);
3232
stubMethod($$.SANDBOX, Connection.prototype, 'query')
3333
.withArgs('SELECT username, profileid, id FROM User')
3434
.resolves({
@@ -77,7 +77,7 @@ describe('force:user:list', () => {
7777
// testUser1@test.com is aliased to testUser
7878
const expected = [
7979
{
80-
defaultMarker: '(A)',
80+
defaultMarker: '',
8181
alias: 'testAlias',
8282
username: 'testuser@test.com',
8383
profileName: 'Analytics Cloud Integration User',

0 commit comments

Comments
 (0)