1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /*!
- * @nuxt/cli v2.15.8 (c) 2016-2021
- * Released under the MIT License
- * Repository: https://github.com/nuxt/nuxt.js
- * Website: https://nuxtjs.org
- */
- 'use strict';
- const consola = require('consola');
- const index = require('./cli-index.js');
- const chalk = require('chalk');
- require('@nuxt/utils');
- require('@nuxt/config');
- require('path');
- require('exit');
- require('std-env');
- require('wrap-ansi');
- require('boxen');
- require('minimist');
- require('hable');
- require('defu');
- require('semver');
- require('fs');
- require('execa');
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
- const consola__default = /*#__PURE__*/_interopDefaultLegacy(consola);
- const chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
- async function listCommands () {
- const commandsOrder = ['dev', 'build', 'generate', 'start', 'help'];
- // Load all commands
- const _commands = await Promise.all(
- commandsOrder.map(cmd => index.getCommand(cmd))
- );
- let maxLength = 0;
- const commandsHelp = [];
- for (const command of _commands) {
- commandsHelp.push([command.usage, command.description]);
- maxLength = Math.max(maxLength, command.usage.length);
- }
- const _cmds = commandsHelp.map(([cmd, description]) => {
- const i = index.indent(maxLength + index.optionSpaces - cmd.length);
- return index.foldLines(
- chalk__default['default'].green(cmd) + i + description,
- index.startSpaces + maxLength + index.optionSpaces * 2,
- index.startSpaces + index.optionSpaces
- )
- }).join('\n');
- const usage = index.foldLines('Usage: nuxt <command> [--help|-h]', index.startSpaces);
- const cmds = index.foldLines('Commands:', index.startSpaces) + '\n\n' + _cmds;
- process.stderr.write(index.colorize(`${usage}\n\n${cmds}\n\n`));
- }
- const help = {
- name: 'help',
- description: 'Shows help for <command>',
- usage: 'help <command>',
- options: {
- help: index.common.help,
- version: index.common.version
- },
- async run (cmd) {
- const [name] = cmd._argv;
- if (!name) {
- return listCommands()
- }
- const command = await index.getCommand(name);
- if (!command) {
- consola__default['default'].info(`Unknown command: ${name}`);
- return
- }
- index.NuxtCommand.from(command).showHelp();
- }
- };
- exports.default = help;
|