@pnp/cli-microsoft365
Version:
Manage Microsoft 365 and SharePoint Framework projects on any platform
51 lines • 1.76 kB
JavaScript
import { z } from 'zod';
import auth from '../../../Auth.js';
import commands from '../commands.js';
import Command, { CommandError, globalOptionsZod } from '../../../Command.js';
import { cli } from '../../../cli/cli.js';
export const options = z.strictObject({
...globalOptionsZod.shape,
name: z.string().alias('n'),
force: z.boolean().optional().alias('f')
});
class ConnectionRemoveCommand extends Command {
get name() {
return commands.REMOVE;
}
get description() {
return 'Removes the specified connection';
}
get schema() {
return options;
}
async commandAction(logger, args) {
const deleteConnection = async () => {
const connection = await auth.getConnection(args.options.name);
if (this.verbose) {
await logger.logToStderr(`Removing connection '${connection.identityName}', appId: ${connection.appId}, tenantId: ${connection.identityTenantId}...`);
}
await auth.removeConnectionInfo(connection, logger, this.debug);
};
if (args.options.force) {
await deleteConnection();
}
else {
const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove the connection?` });
if (result) {
await deleteConnection();
}
}
}
async action(logger, args) {
try {
await auth.restoreAuth();
}
catch (error) {
throw new CommandError(error);
}
await this.initAction(args, logger);
await this.commandAction(logger, args);
}
}
export default new ConnectionRemoveCommand();
//# sourceMappingURL=connection-remove.js.map