@salesforce/plugin-user
Version:
Commands to interact with Users and Permission Sets
59 lines • 2.38 kB
JavaScript
/*
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { Flags } from '@salesforce/sf-plugins-core';
import { Messages } from '@salesforce/core';
import { ensureArray } from '@salesforce/kit';
import { UserPasswordGenerateBaseCommand } from '../../../baseCommands/user/password/generate.js';
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-user', 'password.generate');
export class GenerateUserPasswordCommand extends UserPasswordGenerateBaseCommand {
static summary = messages.getMessage('summary');
static description = messages.getMessage('description');
static examples = messages.getMessages('examples');
static flags = {
'on-behalf-of': Flags.string({
aliases: ['onbehalfof'],
deprecateAliases: true,
char: 'b',
summary: messages.getMessage('flags.onBehalfOf.summary'),
multiple: true,
parse: (input) => {
if (input.includes(',')) {
throw messages.createError('onBehalfOfMultipleError');
}
return Promise.resolve(input);
},
}),
length: Flags.integer({
char: 'l',
summary: messages.getMessage('flags.length.summary'),
min: 8,
max: 1000,
default: 13,
}),
// the higher the value, the stronger the password
complexity: Flags.integer({
char: 'c',
summary: messages.getMessage('flags.complexity.summary'),
min: 0,
max: 5,
default: 5,
}),
'target-org': Flags.requiredOrg({ required: true }),
'api-version': Flags.orgApiVersion(),
};
async run() {
const { flags } = await this.parse(GenerateUserPasswordCommand);
return this.generate({
usernames: ensureArray(flags['on-behalf-of'] ?? flags['target-org'].getUsername()),
length: flags.length,
complexity: flags.complexity,
conn: flags['target-org'].getConnection(flags['api-version']),
});
}
}
//# sourceMappingURL=password.js.map