@salesforce/plugin-user
Version:
Commands to interact with Users and Permission Sets
68 lines • 2.81 kB
JavaScript
/*
* Copyright 2026, Salesforce, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Messages } from '@salesforce/core';
import { arrayWithDeprecation, Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand, } from '@salesforce/sf-plugins-core';
import { ensureArray } from '@salesforce/kit';
import { assignPSL, print, resultsToExitCode } from '../../../../baseCommands/user/permsetlicense/assign.js';
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-user', 'permsetlicense.assign');
export class ForceUserPermSetLicenseAssignCommand extends SfCommand {
static hidden = true;
static summary = messages.getMessage('summary');
static description = messages.getMessage('description');
static examples = messages.getMessages('examples');
static state = 'deprecated';
static deprecationOptions = {
to: 'org assign permsetlicense',
};
static flags = {
name: Flags.string({
char: 'n',
summary: messages.getMessage('flags.name.summary'),
required: true,
aliases: ['perm-set-license', 'psl'],
}),
'on-behalf-of': arrayWithDeprecation({
char: 'b',
summary: messages.getMessage('flags.onBehalfOf.summary'),
aliases: ['onbehalfof'],
deprecateAliases: true,
}),
'target-org': Flags.requiredOrg({
char: 'u',
summary: messages.getMessage('flags.target-org.summary'),
aliases: ['targetusername'],
deprecateAliases: true,
required: true,
}),
'api-version': orgApiVersionFlagWithDeprecations,
loglevel,
};
async run() {
const { flags } = await this.parse(ForceUserPermSetLicenseAssignCommand);
const result = await assignPSL({
conn: flags['target-org'].getConnection(flags['api-version']),
pslName: flags.name,
usernamesOrAliases: ensureArray(flags['on-behalf-of'] ?? flags['target-org'].getUsername()),
});
process.exitCode = resultsToExitCode(result);
if (!this.jsonEnabled()) {
print(result);
}
return result;
}
}
//# sourceMappingURL=assign.js.map