jovo-cli
Version:
jovo command line tool (beta)
111 lines • 4.5 kB
JavaScript
;
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = require("@oclif/command");
const jovo_cli_core_1 = require("jovo-cli-core");
const Listr = require("listr");
const _ = __importStar(require("lodash"));
const utils_1 = require("../utils");
const Tasks_1 = require("../utils/Tasks");
const chalk_1 = __importDefault(require("chalk"));
class Deploy extends command_1.Command {
async run() {
try {
utils_1.platforms.addCliOptions('deploy', Deploy.flags);
utils_1.addBaseCliOptions(Deploy.flags);
const { flags } = this.parse(Deploy);
if (!utils_1.platforms.validateCliOptions('deploy', flags)) {
return;
}
this.log(`\n jovo deploy: ${Deploy.description}`);
this.log(chalk_1.default.grey(' >> Learn more: https://jovo.tech/docs/cli/deploy\n'));
const project = jovo_cli_core_1.getProject();
await project.init();
const tasks = new Listr([], {
renderer: new utils_1.JovoCliRenderer(),
collapse: false,
});
const config = {
locales: project.getLocales(flags.locale),
types: utils_1.platforms.getAll(flags.platform, flags.stage),
targets: project.getTargets('deploy', flags.target, flags.stage),
src: flags.src ||
project.jovoConfigReader.getConfigParameter('src', flags.stage) ||
project.getProjectPath(),
stage: project.getStage(flags.stage),
debug: flags.debug,
frameworkVersion: project.frameworkVersion,
};
if (config.types.length === 0 &&
(!config.targets ||
config.targets.length === 0 ||
!utils_1.deployTargets.getAllPluginTargets().some((el) => config.targets.includes(el)))) {
throw new jovo_cli_core_1.JovoCliError("Couldn't find a platform folder.", 'jovo-cli', 'Please use the "jovo build" command to create platform-specific files.');
}
for (const type of config.types) {
const platform = utils_1.platforms.get(type, config.stage);
_.merge(config, platform.getPlatformConfigIds(project, flags));
_.merge(config, platform.getPlatformConfigValues(project, flags));
}
for (const task of Tasks_1.deployTask(config)) {
tasks.add(task);
}
await tasks.run(config);
this.log();
this.log('Deployment completed.');
this.log();
}
catch (err) {
this.error(`There was a problem:\n${err}`);
}
}
}
exports.Deploy = Deploy;
Deploy.description = 'Deploys the project to the voice platform.';
Deploy.examples = [
'jovo deploy --locale en-US --platform alexaSkill --stage dev',
'jovo deploy --target zip',
];
Deploy.flags = {
locale: command_1.flags.string({
char: 'l',
description: 'Locale of the language model.\n<en-US|de-DE|etc>',
}),
platform: command_1.flags.string({
char: 'p',
description: 'Specifies a build platform.',
options: utils_1.platforms.getAllAvailable(),
}),
target: command_1.flags.string({
char: 't',
description: 'Target of build.',
options: [
jovo_cli_core_1.TARGET_ALL,
jovo_cli_core_1.TARGET_INFO,
jovo_cli_core_1.TARGET_MODEL,
jovo_cli_core_1.TARGET_ZIP,
...utils_1.deployTargets.getAllPluginTargets(),
],
}),
stage: command_1.flags.string({
description: 'Takes configuration from specified stage.',
}),
src: command_1.flags.string({
char: 's',
description: 'Path to source files.\n Default: <project directory>',
}),
debug: command_1.flags.boolean({
hidden: true,
default: false,
}),
};
//# sourceMappingURL=deploy.js.map