UNPKG

@salesforce/plugin-packaging

Version:

SF plugin that support Salesforce Packaging Platform

65 lines 3.04 kB
/* * Copyright 2025, 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 { Flags, loglevel, orgApiVersionFlagWithDeprecations, requiredOrgFlagWithDeprecations, SfCommand, } from '@salesforce/sf-plugins-core'; import { Lifecycle, Messages } from '@salesforce/core'; import { PackageEvents, SubscriberPackageVersion } from '@salesforce/packaging'; import { Duration } from '@salesforce/kit'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_uninstall'); export class PackageUninstallCommand extends SfCommand { static summary = messages.getMessage('summary'); static description = messages.getMessage('description'); static examples = messages.getMessages('examples'); static deprecateAliases = true; static aliases = ['force:package:uninstall']; static flags = { loglevel, 'target-org': requiredOrgFlagWithDeprecations, 'api-version': orgApiVersionFlagWithDeprecations, wait: Flags.duration({ unit: 'minutes', char: 'w', summary: messages.getMessage('flags.wait.summary'), default: Duration.minutes(0), }), package: Flags.string({ char: 'p', summary: messages.getMessage('flags.package.summary'), required: true, }), }; async run() { const { flags } = await this.parse(PackageUninstallCommand); // no awaits in async method // eslint-disable-next-line @typescript-eslint/require-await Lifecycle.getInstance().on(PackageEvents.uninstall, async (data) => { // Request still in progress. Just print a console message and move on. Server will be polled again. this.log(`Waiting for the package uninstall request to get processed. Status = ${data.Status}`); }); const packageVersion = new SubscriberPackageVersion({ aliasOrId: flags.package, connection: flags['target-org'].getConnection(flags['api-version']), password: undefined, }); const result = await packageVersion.uninstall(Duration.seconds(30), flags.wait); const arg = result.Status === 'Success' ? [result.SubscriberPackageVersionId] : [this.config.bin, result.Id, flags['target-org'].getUsername()]; this.log(messages.getMessage(result.Status, arg)); return result; } } //# sourceMappingURL=uninstall.js.map