"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const command_1 = require("@heroku-cli/command"); const buildpacks_1 = require("../../buildpacks"); class Set extends command_1.Command { async run() { let { args, flags } = this.parse(Set); let buildpackCommand = new buildpacks_1.BuildpackCommand(this.heroku); let buildpacks = await buildpackCommand.fetch(flags.app); await buildpackCommand.validateUrlNotSet(buildpacks, args.buildpack); let spliceIndex; if (flags.index === undefined) { spliceIndex = 0; } else { let foundIndex = buildpackCommand.findIndex(buildpacks, flags.index); spliceIndex = (foundIndex === -1) ? buildpacks.length : foundIndex; } let buildpackUpdates = await buildpackCommand.mutate(flags.app, buildpacks, spliceIndex, args.buildpack, 'set'); buildpackCommand.displayUpdate(flags.app, flags.remote || '', buildpackUpdates, 'set'); } } Set.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 in the list of URLs', char: 'i' }) }; Set.args = [ { name: 'buildpack', required: true, description: 'namespace/name of the buildpack' } ]; exports.default = Set;