UNPKG

@adpt/cli

Version:
105 lines 3.85 kB
"use strict"; /* * Copyright 2018-2019 Unbounded Systems, LLC * * 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. */ Object.defineProperty(exports, "__esModule", { value: true }); const base_1 = require("../../base"); const dynamic_task_mgr_1 = require("../../ui/dynamic_task_mgr"); function cap(s) { return s.substr(0, 1).toUpperCase() + s.substr(1); } class UpdateBaseCommand extends base_1.DeployOpBase { constructor() { super(...arguments); this.ingverb = "updating"; this.edverb = "updated"; } addUpdateTask() { const deployID = this.args.deployID; if (deployID == null) { throw new Error(`Internal error: deployID cannot be null`); } const ctx = this.ctx; if (ctx == null) { throw new Error(`Internal error: ctx cannot be null`); } const logger = ctx.logger.createChild("update"); const loggerId = logger.from; dynamic_task_mgr_1.addDynamicTask(this.tasks, ctx.logger.from, ctx.client, { id: loggerId, title: `${cap(this.ingverb)} project deployment`, adoptable: true, initiate: () => { if (ctx.project == null) { throw new Error(`Internal error: project cannot be null`); } const updateOptions = { adaptUrl: ctx.adaptUrl, debug: ctx.debug, deployID, client: ctx.client, dryRun: ctx.dryRun, fileName: ctx.projectFile, logger, loggerId, stackName: ctx.stackName, }; return ctx.project.update(updateOptions); }, onCompleteRoot: async (_ctx, _task, err, prom) => { const deployState = await dynamic_task_mgr_1.waitForInitiate(err, prom); if (!this.isDeploySuccess(deployState)) return; this.deployInformation(deployState); const id = deployState.deployID; this.appendOutput(`Deployment ${id} ${this.edverb} successfully.`); } }); } } exports.UpdateBaseCommand = UpdateBaseCommand; class UpdateCommand extends UpdateBaseCommand { constructor() { super(...arguments); this.ingverb = "updating"; this.edverb = "updated"; } async run() { this.addUpdateTask(); await this.tasks.run(); } } UpdateCommand.description = "Update an existing deployment of an Adapt project"; UpdateCommand.aliases = ["update"]; UpdateCommand.examples = [ `Update the deployment "myproj-dev-abcd", from the default project ` + `description file, "index.tsx": $ adapt deploy:update myproj-dev-abcd\n`, `Update the deployment "myproj-dev-abcd", using the stack named "dev" from ` + `an alternate description file, "somefile.tsx": $ adapt deploy:update --rootFile somefile.tsx myproj-dev-abcd dev`, ]; UpdateCommand.flags = Object.assign({}, base_1.DeployOpBase.flags); UpdateCommand.args = [ { name: "deployID", required: true, }, { name: "stackName", }, ]; exports.default = UpdateCommand; //# sourceMappingURL=update.js.map