UNPKG

a2r

Version:
70 lines (69 loc) 2.71 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.globalHelp = exports.parseARgs = exports.mergeArguments = exports.globalArguments = void 0; const chalk_1 = __importDefault(require("chalk")); const colors_1 = require("./colors"); // eslint-disable-next-line import/no-cycle const commands_1 = require("./commands"); exports.globalArguments = [ { name: 'settings', description: `Set a specific settings ${chalk_1.default.italic('json')} file to use (must be inside ${(0, colors_1.fileName)('.a2r')} folder). Default: ${(0, colors_1.fileName)('settings.json')}`, type: String, typeLabel: '{underline fileName}', }, ]; const mergeArguments = (argumentsLists) => { const argsMap = new Map(); for (let i = 0, l = argumentsLists.length; i < l; i++) { const list = argumentsLists[i]; for (let j = 0, k = list.length; j < k; j++) { const command = list[j]; argsMap.set(command.name, Object.assign(Object.assign({}, (argsMap.get(command.name) || {})), command)); } } return Array.from(argsMap.values()); }; exports.mergeArguments = mergeArguments; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types // eslint-disable-next-line @typescript-eslint/no-explicit-any const parseARgs = (commandOptions) => (Object.assign({}, ((commandOptions && commandOptions._all) || {}))); exports.parseARgs = parseARgs; const commandNamesReplacements = { 'npm': 'npm install', }; /** * Command line help containing information about available command options */ exports.globalHelp = [ { header: colors_1.framework, content: `The isomorphic, reactive ${chalk_1.default.italic('framework')} that scales.`, }, { content: colors_1.logo, raw: true, }, { header: 'Commands commands', content: Array.from(new Set(commands_1.commandsMap.values())).map((command) => ({ name: chalk_1.default.bold(commandNamesReplacements[command.name] || command.name), summary: command.description, })), }, { header: 'Global options', optionList: exports.globalArguments, }, { header: 'Synopsis', content: '$ npx a2r <command> [options]\n$ npx a2r help\n$ npx a2r add --type next --dest www\n$ npx a2r add --type electron --dest desktop --base www\n$ npx a2r dev --project www', }, { content: 'Run `npx a2r help <command>` for help with a specific command.', raw: true, }, ];