UNPKG

@webresto/cli

Version:

Webresto command line interface

112 lines (111 loc) 4.14 kB
#!/usr/bin/env node "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const packgeJSON = __importStar(require("../../package.json")); const commander_1 = __importDefault(require("commander")); const generate_1 = require("./generate"); const upgrade_1 = require("./upgrade"); const update_1 = require("./update"); const install_1 = require("./install"); const publish_1 = require("./publish"); const repl_1 = require("./repl"); const program = new commander_1.default.Command(); program.version(packgeJSON.version); const rc_config_loader_1 = require("rc-config-loader"); let config; try { config = (0, rc_config_loader_1.rcFile)('webresto'); } catch (error) { console.error(`.webrestorc not found`); } if (!config) config = {}; process.env.WEBRESTO_REGISTRY = process.env.WEBRESTO_REGISTRY ?? config.registry ?? 'https://registry-v2.webresto.dev/' ?? 'https://registry.webresto.org/'; process.env.MODULE_STORAGE_URL = process.env.WEBRESTO_REGISTRY; process.env.WEBRESTO_LICENSE = process.env.WEBRESTO_LICENSE ?? config.license; process.env.WEBRESTO_REGISTRY_TOKEN = process.env.WEBRESTO_REGISTRY_TOKEN ?? config.registry_token ?? ''; program.parse(process.argv); const options = program.opts(); program .command('generate [what] [name]') .description('Generate new ecosystem object') .option('-d, --debug', 'Output additional debugging info') // .requiredOption( // '-da, --demoAccount <string>', // 'The demo account that should be cleaned or populated. See settings.ts for valid demo accounts.' // ) .action(async (what, name) => { // console.log('generate here'); (0, generate_1.generate)(what, name); }); program .command('install [module]') .description('install module') .option('-d, --debug', 'Output additional debugging info') .option('-c, --channel <channel_name>', 'channel for donwload') .action(async (module, options) => { (0, install_1.install)(module, options); }); program .command('publish [module]') .description('publish module') .option('-d, --debug', 'Output additional debugging info') .option('-t, --tag <tag_name>', 'optional tag to module') .action(async (module, options) => { (0, publish_1.publish)(module, options); }) .parse(process.argv); program .command('update [module]') .description('update module') .option('-d, --debug', 'Output additional debugging info') .action(async (module) => { // console.log('generate here'); (0, update_1.update)(module); }); program .command('repl [url]') .description('connect to repl-server') .option('-d, --debug', 'Output additional debugging info') .action(async (url) => { // console.log('generate here'); (0, repl_1.repl)(url); }); program .command('upgrade') .description('Hard reinstall') .action(async () => { (0, upgrade_1.upgrade)(); }); program.parse(process.argv);