@adpt/cli
Version:
AdaptJS command line interface
82 lines • 3.34 kB
JavaScript
;
/*
* 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");
class StatusCommand extends base_1.DeployOpBase {
async run() {
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("status");
const loggerId = logger.from;
dynamic_task_mgr_1.addDynamicTask(this.tasks, ctx.logger.from, ctx.client, {
id: loggerId,
title: "Fetching status for project deployment",
adoptable: true,
initiate: () => {
if (ctx.project == null) {
throw new Error(`Internal error: project cannot be null`);
}
const statusOptions = {
adaptUrl: ctx.adaptUrl,
client: ctx.client,
deployID,
dryRun: ctx.dryRun,
fileName: ctx.projectFile,
logger,
loggerId,
};
return ctx.project.status(statusOptions);
},
onCompleteRoot: async (_ctx, _task, err, prom) => {
const deployState = await dynamic_task_mgr_1.waitForInitiate(err, prom);
if (!this.isApiSuccess(deployState, { action: "fetching status" }))
return;
this.deployInformation(deployState);
const id = deployState.deployID;
this.appendOutput(`Deployment ${id} status:`);
this.appendOutput(JSON.stringify(deployState.mountedOrigStatus, null, 2));
}
});
await this.tasks.run();
}
}
StatusCommand.description = "Fetch the status of an existing deployment of an Adapt project";
StatusCommand.aliases = ["status"];
StatusCommand.examples = [
`Fetch the status of deployment "myproj-dev-abcd" from the default project ` +
`description file, "index.tsx":
$ adapt deploy:status myproj-dev-abcd\n`,
`Fetch the status of deployment "myproj-dev-abcd" from an alternate ` +
`description file, "somefile.tsx":
$ adapt deploy:status --rootFile somefile.tsx myproj-dev-abcd`,
];
StatusCommand.flags = Object.assign({}, base_1.DeployOpBase.flags);
StatusCommand.args = [
{
name: "deployID",
required: true,
},
];
exports.default = StatusCommand;
//# sourceMappingURL=status.js.map