UNPKG

riof

Version:

Rio framework

89 lines 3.97 kB
#!/usr/bin/env node "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const yargs_1 = __importDefault(require("yargs")); const helpers_1 = require("yargs/helpers"); const compiler_1 = require("./compiler"); const child_process_1 = require("child_process"); const path_1 = __importDefault(require("path")); const fs_extra_1 = __importDefault(require("fs-extra")); (() => __awaiter(void 0, void 0, void 0, function* () { yargs_1.default(helpers_1.hideBin(process.argv)) .usage('Usage: riof <command> [options]') .demandCommand() .command({ command: 'init', description: 'Initialize template project', aliases: ['i'], handler: (args) => __awaiter(void 0, void 0, void 0, function* () { fs_extra_1.default.copySync(path_1.default.join(__dirname, '..', 'sample-project'), '.'); }) }) .command({ command: 'compile', description: 'Compile the project', aliases: ['c'], handler: (args) => __awaiter(void 0, void 0, void 0, function* () { yield compiler_1.compile(); }) }) .command({ command: 'deploy', description: 'Deploy the project', aliases: ['d'], builder: (yargs) => { yargs.options('project-id', { describe: 'Project id', type: 'string', demandOption: true, }); yargs.options('profile', { describe: 'Rio cli Profile', type: 'string', }); yargs.options('secret-id', { describe: 'Rio cli secret id', type: 'string', }); yargs.options('secret-key', { describe: 'Rio cli secret key', type: 'string', }); yargs.options('endpoint', { describe: 'Rio cli endpoint', type: 'string', }); yargs.options('endpoint', { describe: 'Rio cli endpoint', type: 'string', }); return yargs; }, handler: (args) => __awaiter(void 0, void 0, void 0, function* () { process.chdir(path_1.default.join('dist', 'dist')); if (args["profile"]) { child_process_1.execSync(`npm run rio -- deploy --profile ${args["profile"]} --project-id ${args["project-id"]} --skip-diff-check --ignore-approval`, { stdio: 'inherit' }); } else { child_process_1.execSync(`npm run rio -- set-profile --profile-name RIOF --secret-id ${args["secret-id"]} --secret-key --skip-diff-check ${args["secret-key"]} ${args["endpoint"] ? '--endpoint ' + args["endpoint"] : ''}`, { stdio: 'inherit' }); child_process_1.execSync(`npm run rio -- deploy --profile RIOF --project-id ${args["project-id"]} --skip-diff-check --ignore-approval`, { stdio: 'inherit' }); } }) }) .showHelpOnFail(false) .strict() .parse(); }))().then().catch(); //# sourceMappingURL=commands.js.map