UNPKG

2.32 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const command_1 = require("@heroku-cli/command");
4const cli_ux_1 = require("cli-ux");
5const buildpacks_1 = require("../../buildpacks");
6class Remove extends command_1.Command {
7 async run() {
8 let { args, flags } = this.parse(Remove);
9 let buildpackCommand = new buildpacks_1.BuildpackCommand(this.heroku);
10 if (flags.index && args.buildpack) {
11 cli_ux_1.cli.error('Please choose either index or Buildpack, but not both.', { exit: 1 });
12 }
13 if (!flags.index && !args.buildpack) {
14 cli_ux_1.cli.error('Usage: heroku buildpacks:remove [BUILDPACK_URL]. Must specify a buildpack to remove, either by index or URL.');
15 }
16 let buildpacks = await buildpackCommand.fetch(flags.app);
17 if (buildpacks.length === 0) {
18 cli_ux_1.cli.error(`No buildpacks were found. Next release on ${flags.app} will detect buildpack normally.`, { exit: 1 });
19 }
20 let spliceIndex;
21 if (flags.index) {
22 buildpackCommand.validateIndexInRange(buildpacks, flags.index);
23 spliceIndex = await buildpackCommand.findIndex(buildpacks, flags.index);
24 }
25 else {
26 spliceIndex = await buildpackCommand.findUrl(buildpacks, args.buildpack);
27 }
28 if (spliceIndex === -1) {
29 cli_ux_1.cli.error('Buildpack not found. Nothing was removed.', { exit: 1 });
30 }
31 if (buildpacks.length === 1) {
32 await buildpackCommand.clear(flags.app, 'remove', 'removed');
33 }
34 else {
35 let buildpackUpdates = await buildpackCommand.mutate(flags.app, buildpacks, spliceIndex, args.buildpack, 'remove');
36 buildpackCommand.displayUpdate(flags.app, flags.remote || '', buildpackUpdates, 'removed');
37 }
38 }
39}
40Remove.description = 'remove a buildpack set on the app';
41Remove.flags = {
42 app: command_1.flags.app({ required: true }),
43 remote: command_1.flags.remote(),
44 index: command_1.flags.integer({
45 description: 'the 1-based index of the URL to remove from the list of URLs',
46 char: 'i'
47 })
48};
49Remove.args = [
50 {
51 name: 'buildpack',
52 description: 'namespace/name of the buildpack'
53 }
54];
55exports.default = Remove;