"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const command_1 = require("@heroku-cli/command"); const cli_ux_1 = require("cli-ux"); const buildpacks_1 = require("../../buildpacks"); class Remove extends command_1.Command { async run() { let { args, flags } = this.parse(Remove); let buildpackCommand = new buildpacks_1.BuildpackCommand(this.heroku); if (flags.index && args.buildpack) { cli_ux_1.cli.error('Please choose either index or Buildpack, but not both.', { exit: 1 }); } if (!flags.index && !args.buildpack) { cli_ux_1.cli.error('Usage: heroku buildpacks:remove [BUILDPACK_URL]. Must specify a buildpack to remove, either by index or URL.'); } let buildpacks = await buildpackCommand.fetch(flags.app); if (buildpacks.length === 0) { cli_ux_1.cli.error(`No buildpacks were found. Next release on ${flags.app} will detect buildpack normally.`, { exit: 1 }); } let spliceIndex; if (flags.index) { buildpackCommand.validateIndexInRange(buildpacks, flags.index); spliceIndex = await buildpackCommand.findIndex(buildpacks, flags.index); } else { spliceIndex = await buildpackCommand.findUrl(buildpacks, args.buildpack); } if (spliceIndex === -1) { cli_ux_1.cli.error('Buildpack not found. Nothing was removed.', { exit: 1 }); } if (buildpacks.length === 1) { await buildpackCommand.clear(flags.app, 'remove', 'removed'); } else { let buildpackUpdates = await buildpackCommand.mutate(flags.app, buildpacks, spliceIndex, args.buildpack, 'remove'); buildpackCommand.displayUpdate(flags.app, flags.remote || '', buildpackUpdates, 'removed'); } } } Remove.description = 'remove a buildpack set on the app'; Remove.flags = { app: command_1.flags.app({ required: true }), remote: command_1.flags.remote(), index: command_1.flags.integer({ description: 'the 1-based index of the URL to remove from the list of URLs', char: 'i' }) }; Remove.args = [ { name: 'buildpack', description: 'namespace/name of the buildpack' } ]; exports.default = Remove;