update
This commit is contained in:
+23
-19
@@ -1,19 +1,23 @@
|
||||
/*!
|
||||
* @nuxt/cli v2.13.3 (c) 2016-2020
|
||||
|
||||
* - All the amazing contributors
|
||||
* Released under the MIT License.
|
||||
* @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';
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
const consola = require('consola');
|
||||
const env = require('std-env');
|
||||
const chalk = require('chalk');
|
||||
const index = require('./cli-index.js');
|
||||
const chalk = _interopDefault(require('chalk'));
|
||||
const env = _interopDefault(require('std-env'));
|
||||
const consola = _interopDefault(require('consola'));
|
||||
const prettyBytes = _interopDefault(require('pretty-bytes'));
|
||||
const prettyBytes = require('pretty-bytes');
|
||||
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
const consola__default = /*#__PURE__*/_interopDefaultLegacy(consola);
|
||||
const env__default = /*#__PURE__*/_interopDefaultLegacy(env);
|
||||
const chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
|
||||
const prettyBytes__default = /*#__PURE__*/_interopDefaultLegacy(prettyBytes);
|
||||
|
||||
function getMemoryUsage () {
|
||||
// https://nodejs.org/api/process.html#process_process_memoryusage
|
||||
@@ -23,21 +27,21 @@ function getMemoryUsage () {
|
||||
|
||||
function getFormattedMemoryUsage () {
|
||||
const { heap, rss } = getMemoryUsage();
|
||||
return `Memory usage: ${chalk.bold(prettyBytes(heap))} (RSS: ${prettyBytes(rss)})`
|
||||
return `Memory usage: ${chalk__default['default'].bold(prettyBytes__default['default'](heap))} (RSS: ${prettyBytes__default['default'](rss)})`
|
||||
}
|
||||
|
||||
function showMemoryUsage () {
|
||||
consola.info(getFormattedMemoryUsage());
|
||||
consola__default['default'].info(getFormattedMemoryUsage());
|
||||
}
|
||||
|
||||
function showBanner (nuxt, showMemoryUsage = true) {
|
||||
if (env.test) {
|
||||
if (env__default['default'].test) {
|
||||
return
|
||||
}
|
||||
|
||||
if (env.minimalCLI) {
|
||||
if (env__default['default'].minimalCLI) {
|
||||
for (const listener of nuxt.server.listeners) {
|
||||
consola.info('Listening on: ' + listener.url);
|
||||
consola__default['default'].info('Listening on: ' + listener.url);
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -47,15 +51,15 @@ function showBanner (nuxt, showMemoryUsage = true) {
|
||||
|
||||
// Name and version
|
||||
const { bannerColor, badgeMessages } = nuxt.options.cli;
|
||||
titleLines.push(`${chalk[bannerColor].bold('Nuxt.js')} @ ${nuxt.constructor.version || 'exotic'}\n`);
|
||||
titleLines.push(`${chalk__default['default'][bannerColor].bold('Nuxt')} @ ${nuxt.constructor.version || 'exotic'}\n`);
|
||||
|
||||
const label = name => chalk.bold.cyan(`▸ ${name}:`);
|
||||
const label = name => chalk__default['default'].bold.cyan(`▸ ${name}:`);
|
||||
|
||||
// Environment
|
||||
const isDev = nuxt.options.dev;
|
||||
let _env = isDev ? 'development' : 'production';
|
||||
if (process.env.NODE_ENV !== _env) {
|
||||
_env += ` (${chalk.cyan(process.env.NODE_ENV)})`;
|
||||
_env += ` (${chalk__default['default'].cyan(process.env.NODE_ENV)})`;
|
||||
}
|
||||
titleLines.push(`${label('Environment')} ${_env}`);
|
||||
|
||||
@@ -74,7 +78,7 @@ function showBanner (nuxt, showMemoryUsage = true) {
|
||||
|
||||
// Listeners
|
||||
for (const listener of nuxt.server.listeners) {
|
||||
messageLines.push(chalk.bold('Listening: ') + chalk.underline.blue(listener.url));
|
||||
messageLines.push(chalk__default['default'].bold('Listening: ') + chalk__default['default'].underline.blue(listener.url));
|
||||
}
|
||||
|
||||
// Add custom badge messages
|
||||
|
||||
+16
-13
@@ -1,29 +1,32 @@
|
||||
/*!
|
||||
* @nuxt/cli v2.13.3 (c) 2016-2020
|
||||
|
||||
* - All the amazing contributors
|
||||
* Released under the MIT License.
|
||||
* @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';
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
const index = require('./cli-index.js');
|
||||
require('path');
|
||||
require('@nuxt/config');
|
||||
require('exit');
|
||||
const consola = require('consola');
|
||||
const utils = require('@nuxt/utils');
|
||||
const index = require('./cli-index.js');
|
||||
require('@nuxt/config');
|
||||
require('path');
|
||||
require('exit');
|
||||
require('chalk');
|
||||
require('std-env');
|
||||
require('wrap-ansi');
|
||||
require('boxen');
|
||||
const consola = _interopDefault(require('consola'));
|
||||
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 build = {
|
||||
name: 'build',
|
||||
description: 'Compiles the application for production deployment',
|
||||
@@ -106,8 +109,8 @@ const build = {
|
||||
const builder = await cmd.getBuilder(nuxt);
|
||||
await builder.build();
|
||||
|
||||
const nextCommand = nuxt.options.target === utils.TARGETS.static ? 'nuxt export' : 'nuxt start';
|
||||
consola.info('Ready to run `' + (nextCommand) + '`');
|
||||
const nextCommand = nuxt.options.target === utils.TARGETS.static ? 'nuxt generate' : 'nuxt start';
|
||||
consola__default['default'].info('Ready to run `' + (nextCommand) + '`');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+26
-21
@@ -1,31 +1,36 @@
|
||||
/*!
|
||||
* @nuxt/cli v2.13.3 (c) 2016-2020
|
||||
|
||||
* - All the amazing contributors
|
||||
* Released under the MIT License.
|
||||
* @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';
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
const consola = require('consola');
|
||||
const chalk = require('chalk');
|
||||
const opener = require('opener');
|
||||
const index = require('./cli-index.js');
|
||||
require('path');
|
||||
require('@nuxt/config');
|
||||
require('exit');
|
||||
const banner = require('./cli-banner.js');
|
||||
require('@nuxt/utils');
|
||||
const chalk = _interopDefault(require('chalk'));
|
||||
require('@nuxt/config');
|
||||
require('path');
|
||||
require('exit');
|
||||
require('std-env');
|
||||
require('wrap-ansi');
|
||||
require('boxen');
|
||||
const consola = _interopDefault(require('consola'));
|
||||
require('minimist');
|
||||
require('hable');
|
||||
require('defu');
|
||||
require('semver');
|
||||
require('fs');
|
||||
require('execa');
|
||||
require('pretty-bytes');
|
||||
const banner = require('./cli-banner.js');
|
||||
const opener = _interopDefault(require('opener'));
|
||||
|
||||
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);
|
||||
const opener__default = /*#__PURE__*/_interopDefaultLegacy(opener);
|
||||
|
||||
const dev = {
|
||||
name: 'dev',
|
||||
@@ -33,7 +38,7 @@ const dev = {
|
||||
usage: 'dev <dir>',
|
||||
options: {
|
||||
...index.common,
|
||||
...index.server,
|
||||
...index.server$1,
|
||||
open: {
|
||||
alias: 'o',
|
||||
type: 'boolean',
|
||||
@@ -52,7 +57,7 @@ const dev = {
|
||||
try {
|
||||
nuxt = await this._listenDev(cmd, argv);
|
||||
} catch (error) {
|
||||
consola.fatal(error);
|
||||
consola__default['default'].fatal(error);
|
||||
return
|
||||
}
|
||||
|
||||
@@ -60,7 +65,7 @@ const dev = {
|
||||
await this._buildDev(cmd, argv, nuxt);
|
||||
} catch (error) {
|
||||
await nuxt.callHook('cli:buildError', error);
|
||||
consola.error(error);
|
||||
consola__default['default'].error(error);
|
||||
}
|
||||
|
||||
return nuxt
|
||||
@@ -86,7 +91,7 @@ const dev = {
|
||||
// Opens the server listeners url in the default browser (only once)
|
||||
if (argv.open) {
|
||||
argv.open = false;
|
||||
const openerPromises = nuxt.server.listeners.map(listener => opener(listener.url));
|
||||
const openerPromises = nuxt.server.listeners.map(listener => opener__default['default'](listener.url));
|
||||
await Promise.all(openerPromises);
|
||||
}
|
||||
|
||||
@@ -106,7 +111,7 @@ const dev = {
|
||||
|
||||
// Display server urls after the build
|
||||
for (const listener of nuxt.server.listeners) {
|
||||
consola.info(chalk.bold('Listening on: ') + listener.url);
|
||||
consola__default['default'].info(chalk__default['default'].bold('Listening on: ') + listener.url);
|
||||
}
|
||||
|
||||
// Return instance
|
||||
@@ -116,10 +121,10 @@ const dev = {
|
||||
logChanged ({ event, path }) {
|
||||
const { icon, color, action } = index.eventsMapping[event] || index.eventsMapping.change;
|
||||
|
||||
consola.log({
|
||||
consola__default['default'].log({
|
||||
type: event,
|
||||
icon: chalk[color].bold(icon),
|
||||
message: `${action} ${chalk.cyan(index.formatPath(path))}`
|
||||
icon: chalk__default['default'][color].bold(icon),
|
||||
message: `${action} ${chalk__default['default'].cyan(index.formatPath(path))}`
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
+23
-52
@@ -1,72 +1,43 @@
|
||||
/*!
|
||||
* @nuxt/cli v2.13.3 (c) 2016-2020
|
||||
|
||||
* - All the amazing contributors
|
||||
* Released under the MIT License.
|
||||
* @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';
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
const index = require('./cli-index.js');
|
||||
const path = require('path');
|
||||
const path__default = _interopDefault(path);
|
||||
const consola = require('consola');
|
||||
const generate = require('./cli-generate.js');
|
||||
require('@nuxt/utils');
|
||||
require('./cli-index.js');
|
||||
require('@nuxt/config');
|
||||
require('path');
|
||||
require('exit');
|
||||
const utils = require('@nuxt/utils');
|
||||
require('chalk');
|
||||
require('std-env');
|
||||
require('wrap-ansi');
|
||||
require('boxen');
|
||||
const consola = _interopDefault(require('consola'));
|
||||
require('minimist');
|
||||
require('hable');
|
||||
require('defu');
|
||||
require('semver');
|
||||
require('fs');
|
||||
require('execa');
|
||||
require('upath');
|
||||
require('fs-extra');
|
||||
require('crc/lib/crc32');
|
||||
require('globby');
|
||||
require('destr');
|
||||
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
const consola__default = /*#__PURE__*/_interopDefaultLegacy(consola);
|
||||
|
||||
const _export = {
|
||||
name: 'export',
|
||||
description: 'Export a static generated web application',
|
||||
usage: 'export <dir>',
|
||||
options: {
|
||||
...index.common,
|
||||
...index.locking,
|
||||
'fail-on-error': {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Exit with non-zero status code if there are errors when exporting pages'
|
||||
}
|
||||
},
|
||||
async run (cmd) {
|
||||
const config = await cmd.getNuxtConfig({
|
||||
dev: false,
|
||||
target: utils.TARGETS.static,
|
||||
_export: true
|
||||
});
|
||||
const nuxt = await cmd.getNuxt(config);
|
||||
|
||||
if (cmd.argv.lock) {
|
||||
await cmd.setLock(await index.createLock({
|
||||
id: 'export',
|
||||
dir: nuxt.options.generate.dir,
|
||||
root: config.rootDir
|
||||
}));
|
||||
}
|
||||
|
||||
const generator = await cmd.getGenerator(nuxt);
|
||||
await nuxt.server.listen(0);
|
||||
|
||||
const { errors } = await generator.generate({
|
||||
init: true,
|
||||
build: false
|
||||
});
|
||||
|
||||
await nuxt.close();
|
||||
if (cmd.argv['fail-on-error'] && errors.length > 0) {
|
||||
throw new Error('Error exporting pages, exiting with non-zero code')
|
||||
}
|
||||
consola.info('Ready to run `nuxt serve` or deploy `' + path__default.basename(nuxt.options.generate.dir) + '/` directory');
|
||||
...generate['default'],
|
||||
run (...args) {
|
||||
consola__default['default'].warn('`nuxt export` has been deprecated! Please use `nuxt generate`.');
|
||||
return generate['default'].run.call(this, ...args)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+221
-19
@@ -1,27 +1,220 @@
|
||||
/*!
|
||||
* @nuxt/cli v2.13.3 (c) 2016-2020
|
||||
|
||||
* - All the amazing contributors
|
||||
* Released under the MIT License.
|
||||
* @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 utils = require('@nuxt/utils');
|
||||
const consola = require('consola');
|
||||
const index = require('./cli-index.js');
|
||||
require('path');
|
||||
const path = require('path');
|
||||
const upath = require('upath');
|
||||
const fs = require('fs-extra');
|
||||
const crc32 = require('crc/lib/crc32');
|
||||
const globby = require('globby');
|
||||
const destr = require('destr');
|
||||
require('@nuxt/config');
|
||||
require('exit');
|
||||
const utils = require('@nuxt/utils');
|
||||
require('chalk');
|
||||
require('std-env');
|
||||
require('wrap-ansi');
|
||||
require('boxen');
|
||||
require('consola');
|
||||
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 path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
||||
const upath__default = /*#__PURE__*/_interopDefaultLegacy(upath);
|
||||
const fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
||||
const crc32__default = /*#__PURE__*/_interopDefaultLegacy(crc32);
|
||||
const globby__default = /*#__PURE__*/_interopDefaultLegacy(globby);
|
||||
const destr__default = /*#__PURE__*/_interopDefaultLegacy(destr);
|
||||
|
||||
async function generate$1 (cmd) {
|
||||
const nuxt = await getNuxt({ server: true }, cmd);
|
||||
const generator = await cmd.getGenerator(nuxt);
|
||||
|
||||
await nuxt.server.listen(0);
|
||||
const { errors } = await generator.generate({ build: false });
|
||||
await nuxt.close();
|
||||
if (cmd.argv['fail-on-error'] && errors.length > 0) {
|
||||
throw new Error('Error generating pages, exiting with non-zero code')
|
||||
}
|
||||
}
|
||||
|
||||
async function ensureBuild (cmd) {
|
||||
const nuxt = await getNuxt({ _build: true, server: false }, cmd);
|
||||
const { options } = nuxt;
|
||||
|
||||
if (options.generate.cache === false || destr__default['default'](process.env.NUXT_BUILD) || cmd.argv['force-build']) {
|
||||
const builder = await cmd.getBuilder(nuxt);
|
||||
await builder.build();
|
||||
await nuxt.close();
|
||||
return
|
||||
}
|
||||
|
||||
// Default build ignore files
|
||||
const ignore = [
|
||||
options.buildDir,
|
||||
options.dir.static,
|
||||
options.generate.dir,
|
||||
'node_modules',
|
||||
'.**/*',
|
||||
'.*',
|
||||
'README.md'
|
||||
];
|
||||
|
||||
// Extend ignore
|
||||
const { generate } = options;
|
||||
if (typeof generate.cache.ignore === 'function') {
|
||||
generate.cache.ignore = generate.cache.ignore(ignore);
|
||||
} else if (Array.isArray(generate.cache.ignore)) {
|
||||
generate.cache.ignore = generate.cache.ignore.concat(ignore);
|
||||
}
|
||||
await nuxt.callHook('generate:cache:ignore', generate.cache.ignore);
|
||||
|
||||
// Take a snapshot of current project
|
||||
const snapshotOptions = {
|
||||
rootDir: options.rootDir,
|
||||
ignore: generate.cache.ignore.map(upath__default['default'].normalize),
|
||||
globbyOptions: generate.cache.globbyOptions
|
||||
};
|
||||
|
||||
const currentBuildSnapshot = await snapshot(snapshotOptions);
|
||||
|
||||
// Detect process.env usage in nuxt.config
|
||||
const processEnv = {};
|
||||
if (nuxt.options._nuxtConfigFile) {
|
||||
const configSrc = await fs__default['default'].readFile(nuxt.options._nuxtConfigFile);
|
||||
const envRegex = /process.env.(\w+)/g;
|
||||
let match;
|
||||
// eslint-disable-next-line no-cond-assign
|
||||
while (match = envRegex.exec(configSrc)) {
|
||||
processEnv[match[1]] = process.env[match[1]];
|
||||
}
|
||||
}
|
||||
|
||||
// Current build meta
|
||||
const currentBuild = {
|
||||
// @ts-ignore
|
||||
nuxtVersion: nuxt.constructor.version,
|
||||
ssr: nuxt.options.ssr,
|
||||
target: nuxt.options.target,
|
||||
snapshot: currentBuildSnapshot,
|
||||
env: nuxt.options.env,
|
||||
'process.env': processEnv
|
||||
};
|
||||
|
||||
// Check if build can be skipped
|
||||
const nuxtBuildFile = path__default['default'].resolve(nuxt.options.buildDir, 'build.json');
|
||||
if (fs__default['default'].existsSync(nuxtBuildFile)) {
|
||||
const previousBuild = destr__default['default'](fs__default['default'].readFileSync(nuxtBuildFile, 'utf-8')) || {};
|
||||
|
||||
// Quick diff
|
||||
let needBuild = false;
|
||||
for (const field of ['nuxtVersion', 'ssr', 'target', 'env', 'process.env']) {
|
||||
if (JSON.stringify(previousBuild[field]) !== JSON.stringify(currentBuild[field])) {
|
||||
needBuild = true;
|
||||
consola__default['default'].info(`Doing webpack rebuild because ${field} changed`);
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Full snapshot diff
|
||||
if (!needBuild) {
|
||||
const changed = compareSnapshots(previousBuild.snapshot, currentBuild.snapshot);
|
||||
if (!changed) {
|
||||
consola__default['default'].success('Skipping webpack build as no changes detected');
|
||||
return
|
||||
} else {
|
||||
consola__default['default'].info(`Doing webpack rebuild because ${changed} modified`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Webpack build
|
||||
const builder = await cmd.getBuilder(nuxt);
|
||||
await builder.build();
|
||||
|
||||
// Write build.json
|
||||
fs__default['default'].writeFileSync(nuxtBuildFile, JSON.stringify(currentBuild, null, 2), 'utf-8');
|
||||
|
||||
await nuxt.close();
|
||||
}
|
||||
|
||||
async function getNuxt (args, cmd) {
|
||||
const config = await cmd.getNuxtConfig({ dev: false, ...args });
|
||||
|
||||
if (config.target === utils.TARGETS.static) {
|
||||
config._export = true;
|
||||
} else {
|
||||
config._legacyGenerate = true;
|
||||
}
|
||||
config.buildDir = (config.static && config.static.cacheDir) || path__default['default'].resolve(config.rootDir, 'node_modules/.cache/nuxt');
|
||||
config.build = config.build || {};
|
||||
// https://github.com/nuxt/nuxt.js/issues/7390
|
||||
config.build.parallel = false;
|
||||
config.build.transpile = config.build.transpile || [];
|
||||
if (!config.static || !config.static.cacheDir) {
|
||||
config.build.transpile.push('.cache/nuxt');
|
||||
}
|
||||
|
||||
const nuxt = await cmd.getNuxt(config);
|
||||
|
||||
return nuxt
|
||||
}
|
||||
|
||||
function compareSnapshots (from, to) {
|
||||
const allKeys = Array.from(new Set([
|
||||
...Object.keys(from).sort(),
|
||||
...Object.keys(to).sort()
|
||||
]));
|
||||
|
||||
for (const key of allKeys) {
|
||||
if (JSON.stringify(from[key]) !== JSON.stringify(to[key])) {
|
||||
return key
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
async function snapshot ({ globbyOptions, ignore, rootDir }) {
|
||||
const snapshot = {};
|
||||
|
||||
const files = await globby__default['default']('**/*.*', {
|
||||
...globbyOptions,
|
||||
ignore,
|
||||
cwd: rootDir,
|
||||
absolute: true
|
||||
});
|
||||
|
||||
await Promise.all(files.map(async (p) => {
|
||||
const key = path.relative(rootDir, p);
|
||||
try {
|
||||
const fileContent = await fs__default['default'].readFile(p);
|
||||
snapshot[key] = {
|
||||
checksum: await crc32__default['default'](fileContent).toString(16)
|
||||
};
|
||||
} catch (e) {
|
||||
// TODO: Check for other errors like permission denied
|
||||
snapshot[key] = {
|
||||
exists: false
|
||||
};
|
||||
}
|
||||
}));
|
||||
|
||||
return snapshot
|
||||
}
|
||||
|
||||
const generate = {
|
||||
name: 'generate',
|
||||
description: 'Generate a static web application (server-rendered)',
|
||||
@@ -67,6 +260,11 @@ const generate = {
|
||||
}
|
||||
}
|
||||
},
|
||||
'force-build': {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Force to build the application with webpack'
|
||||
},
|
||||
'fail-on-error': {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
@@ -74,25 +272,29 @@ const generate = {
|
||||
}
|
||||
},
|
||||
async run (cmd) {
|
||||
const config = await cmd.getNuxtConfig({
|
||||
dev: false,
|
||||
_build: cmd.argv.build,
|
||||
_generate: true
|
||||
});
|
||||
|
||||
if (config.target === utils.TARGETS.static) {
|
||||
throw new Error("Please use `nuxt export` when using `target: 'static'`")
|
||||
}
|
||||
|
||||
// Forcing static target anyway
|
||||
config.target = utils.TARGETS.static;
|
||||
const config = await cmd.getNuxtConfig({ dev: false });
|
||||
|
||||
// Disable analyze if set by the nuxt config
|
||||
config.build = config.build || {};
|
||||
config.build.analyze = false;
|
||||
|
||||
// Full static
|
||||
if (config.target === utils.TARGETS.static) {
|
||||
await ensureBuild(cmd);
|
||||
await generate$1(cmd);
|
||||
return
|
||||
}
|
||||
|
||||
// Forcing static target anyway
|
||||
config.target = utils.TARGETS.static;
|
||||
consola__default['default'].warn(`When using \`nuxt generate\`, you should set \`target: 'static'\` in your \`nuxt.config\`\n 👉 Learn more about it on https://go.nuxtjs.dev/static-target`);
|
||||
|
||||
// Set flag to keep the prerendering behaviour
|
||||
config._legacyGenerate = true;
|
||||
if (config.build) {
|
||||
// https://github.com/nuxt/nuxt.js/issues/7390
|
||||
config.build.parallel = false;
|
||||
}
|
||||
|
||||
const nuxt = await cmd.getNuxt(config);
|
||||
|
||||
|
||||
+17
-13
@@ -1,29 +1,33 @@
|
||||
/*!
|
||||
* @nuxt/cli v2.13.3 (c) 2016-2020
|
||||
|
||||
* - All the amazing contributors
|
||||
* Released under the MIT License.
|
||||
* @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';
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
const consola = require('consola');
|
||||
const index = require('./cli-index.js');
|
||||
require('path');
|
||||
require('@nuxt/config');
|
||||
require('exit');
|
||||
const chalk = require('chalk');
|
||||
require('@nuxt/utils');
|
||||
const chalk = _interopDefault(require('chalk'));
|
||||
require('@nuxt/config');
|
||||
require('path');
|
||||
require('exit');
|
||||
require('std-env');
|
||||
require('wrap-ansi');
|
||||
require('boxen');
|
||||
const consola = _interopDefault(require('consola'));
|
||||
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'];
|
||||
|
||||
@@ -43,7 +47,7 @@ async function listCommands () {
|
||||
const _cmds = commandsHelp.map(([cmd, description]) => {
|
||||
const i = index.indent(maxLength + index.optionSpaces - cmd.length);
|
||||
return index.foldLines(
|
||||
chalk.green(cmd) + i + description,
|
||||
chalk__default['default'].green(cmd) + i + description,
|
||||
index.startSpaces + maxLength + index.optionSpaces * 2,
|
||||
index.startSpaces + index.optionSpaces
|
||||
)
|
||||
@@ -71,7 +75,7 @@ const help = {
|
||||
const command = await index.getCommand(name);
|
||||
|
||||
if (!command) {
|
||||
consola.info(`Unknown command: ${name}`);
|
||||
consola__default['default'].info(`Unknown command: ${name}`);
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+141
-2495
File diff suppressed because it is too large
Load Diff
+24
-88
@@ -1,107 +1,43 @@
|
||||
/*!
|
||||
* @nuxt/cli v2.13.3 (c) 2016-2020
|
||||
|
||||
* - All the amazing contributors
|
||||
* Released under the MIT License.
|
||||
* @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';
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
const index = require('./cli-index.js');
|
||||
const path = require('path');
|
||||
const path__default = _interopDefault(path);
|
||||
const config = require('@nuxt/config');
|
||||
const consola = require('consola');
|
||||
const start = require('./cli-start.js');
|
||||
require('@nuxt/utils');
|
||||
require('./cli-index.js');
|
||||
require('@nuxt/config');
|
||||
require('path');
|
||||
require('exit');
|
||||
const utils = require('@nuxt/utils');
|
||||
require('chalk');
|
||||
require('std-env');
|
||||
require('wrap-ansi');
|
||||
require('boxen');
|
||||
require('consola');
|
||||
require('minimist');
|
||||
require('hable');
|
||||
const fs = require('fs');
|
||||
const fs__default = _interopDefault(fs);
|
||||
require('defu');
|
||||
require('semver');
|
||||
require('fs');
|
||||
require('execa');
|
||||
require('./cli-banner.js');
|
||||
require('pretty-bytes');
|
||||
const banner = require('./cli-banner.js');
|
||||
const connect = _interopDefault(require('connect'));
|
||||
const serveStatic = _interopDefault(require('serve-static'));
|
||||
const compression = _interopDefault(require('compression'));
|
||||
require('connect');
|
||||
require('serve-static');
|
||||
require('compression');
|
||||
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
const consola__default = /*#__PURE__*/_interopDefaultLegacy(consola);
|
||||
|
||||
const serve = {
|
||||
name: 'serve',
|
||||
description: 'Serve the exported static application (should be compiled with `nuxt build` and `nuxt export` first)',
|
||||
usage: 'serve <dir>',
|
||||
options: {
|
||||
'config-file': index.common['config-file'],
|
||||
version: index.common.version,
|
||||
help: index.common.help,
|
||||
...index.server
|
||||
},
|
||||
async run (cmd) {
|
||||
let options = await cmd.getNuxtConfig({ dev: false });
|
||||
// add default options
|
||||
options = config.getNuxtConfig(options);
|
||||
try {
|
||||
// overwrites with build config
|
||||
const buildConfig = require(path.join(options.buildDir, 'nuxt/config.json'));
|
||||
options.target = buildConfig.target;
|
||||
} catch (err) {}
|
||||
|
||||
if (options.target === utils.TARGETS.server) {
|
||||
throw new Error('You cannot use `nuxt serve` with ' + utils.TARGETS.server + ' target, please use `nuxt start`')
|
||||
}
|
||||
const distStat = await fs.promises.stat(options.generate.dir).catch(err => null); // eslint-disable-line handle-callback-err
|
||||
if (!distStat || !distStat.isDirectory()) {
|
||||
throw new Error('Output directory `' + path.basename(options.generate.dir) + '/` does not exists, please run `nuxt export` before `nuxt serve`.')
|
||||
}
|
||||
const app = connect();
|
||||
app.use(compression({ threshold: 0 }));
|
||||
app.use(
|
||||
options.router.base,
|
||||
serveStatic(options.generate.dir, {
|
||||
extensions: ['html']
|
||||
})
|
||||
);
|
||||
if (options.generate.fallback) {
|
||||
const fallbackFile = await fs.promises.readFile(path.join(options.generate.dir, options.generate.fallback), 'utf-8');
|
||||
app.use((req, res, next) => {
|
||||
const ext = path.extname(req.url) || '.html';
|
||||
|
||||
if (ext !== '.html') {
|
||||
return next()
|
||||
}
|
||||
res.writeHeader(200, {
|
||||
'Content-Type': 'text/html'
|
||||
});
|
||||
res.write(fallbackFile);
|
||||
res.end();
|
||||
});
|
||||
}
|
||||
|
||||
const { port, host, socket, https } = options.server;
|
||||
const { Listener } = await index.server$1();
|
||||
const listener = new Listener({
|
||||
port,
|
||||
host,
|
||||
socket,
|
||||
https,
|
||||
app,
|
||||
dev: true, // try another port if taken
|
||||
baseURL: options.router.base
|
||||
});
|
||||
await listener.listen();
|
||||
const { Nuxt } = await index.core();
|
||||
banner.showBanner({
|
||||
constructor: Nuxt,
|
||||
options,
|
||||
server: {
|
||||
listeners: [listener]
|
||||
}
|
||||
}, false);
|
||||
...start['default'],
|
||||
run (...args) {
|
||||
consola__default['default'].warn('`nuxt serve` has been deprecated! Please use `nuxt start`.');
|
||||
return start['default'].run.call(this, ...args)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+94
-13
@@ -1,28 +1,107 @@
|
||||
/*!
|
||||
* @nuxt/cli v2.13.3 (c) 2016-2020
|
||||
|
||||
* - All the amazing contributors
|
||||
* Released under the MIT License.
|
||||
* @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 index = require('./cli-index.js');
|
||||
require('path');
|
||||
require('@nuxt/config');
|
||||
require('exit');
|
||||
const utils = require('@nuxt/utils');
|
||||
const index = require('./cli-index.js');
|
||||
const banner = require('./cli-banner.js');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const consola = require('consola');
|
||||
const connect = require('connect');
|
||||
const serveStatic = require('serve-static');
|
||||
const compression = require('compression');
|
||||
const config = require('@nuxt/config');
|
||||
require('exit');
|
||||
require('chalk');
|
||||
require('std-env');
|
||||
require('wrap-ansi');
|
||||
require('boxen');
|
||||
require('consola');
|
||||
require('minimist');
|
||||
require('hable');
|
||||
require('fs');
|
||||
require('defu');
|
||||
require('semver');
|
||||
require('execa');
|
||||
require('pretty-bytes');
|
||||
const banner = require('./cli-banner.js');
|
||||
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
const consola__default = /*#__PURE__*/_interopDefaultLegacy(consola);
|
||||
const connect__default = /*#__PURE__*/_interopDefaultLegacy(connect);
|
||||
const serveStatic__default = /*#__PURE__*/_interopDefaultLegacy(serveStatic);
|
||||
const compression__default = /*#__PURE__*/_interopDefaultLegacy(compression);
|
||||
|
||||
async function serve (cmd) {
|
||||
const _config = await cmd.getNuxtConfig({ dev: false });
|
||||
|
||||
// add default options
|
||||
const options = config.getNuxtConfig(_config);
|
||||
|
||||
try {
|
||||
// overwrites with build config
|
||||
const buildConfig = utils.requireModule(path.join(options.buildDir, 'nuxt/config.json'));
|
||||
options.target = buildConfig.target;
|
||||
} catch (err) { }
|
||||
|
||||
const distStat = await fs.promises.stat(options.generate.dir).catch(err => null); // eslint-disable-line node/handle-callback-err
|
||||
const distPath = path.join(options.generate.dir.replace(process.cwd() + path.sep, ''), path.sep);
|
||||
if (!distStat || !distStat.isDirectory()) {
|
||||
throw new Error('Output directory `' + distPath + '` does not exist, please use `nuxt generate` before `nuxt start` for static target.')
|
||||
}
|
||||
const app = connect__default['default']();
|
||||
app.use(compression__default['default']({ threshold: 0 }));
|
||||
app.use(
|
||||
options.router.base,
|
||||
serveStatic__default['default'](options.generate.dir, {
|
||||
extensions: ['html']
|
||||
})
|
||||
);
|
||||
if (options.generate.fallback) {
|
||||
const fallbackFile = await fs.promises.readFile(path.join(options.generate.dir, options.generate.fallback), 'utf-8');
|
||||
app.use((req, res, next) => {
|
||||
const ext = path.extname(req.url) || '.html';
|
||||
|
||||
if (ext !== '.html') {
|
||||
return next()
|
||||
}
|
||||
res.writeHeader(200, {
|
||||
'Content-Type': 'text/html'
|
||||
});
|
||||
res.write(fallbackFile);
|
||||
res.end();
|
||||
});
|
||||
}
|
||||
|
||||
const { port, host, socket, https } = options.server;
|
||||
const { Listener } = await index.server();
|
||||
const listener = new Listener({
|
||||
port,
|
||||
host,
|
||||
socket,
|
||||
https,
|
||||
app,
|
||||
dev: true, // try another port if taken
|
||||
baseURL: options.router.base
|
||||
});
|
||||
|
||||
await listener.listen();
|
||||
|
||||
const { Nuxt } = await index.core();
|
||||
|
||||
banner.showBanner({
|
||||
constructor: Nuxt,
|
||||
options,
|
||||
server: {
|
||||
listeners: [listener]
|
||||
}
|
||||
}, false);
|
||||
|
||||
consola__default['default'].info(`Serving static application from \`${distPath}\``);
|
||||
}
|
||||
|
||||
const start = {
|
||||
name: 'start',
|
||||
@@ -30,13 +109,15 @@ const start = {
|
||||
usage: 'start <dir>',
|
||||
options: {
|
||||
...index.common,
|
||||
...index.server
|
||||
...index.server$1
|
||||
},
|
||||
async run (cmd) {
|
||||
const config = await cmd.getNuxtConfig({ dev: false, _start: true });
|
||||
|
||||
if (config.target === utils.TARGETS.static) {
|
||||
throw new Error('You cannot use `nuxt start` with ' + utils.TARGETS.static + ' target, please use `nuxt export` and `nuxt serve`')
|
||||
return serve(cmd)
|
||||
}
|
||||
|
||||
const nuxt = await cmd.getNuxt(config);
|
||||
|
||||
// Listen and show ready banner
|
||||
|
||||
+25
-368
@@ -1,379 +1,34 @@
|
||||
/*!
|
||||
* @nuxt/cli v2.13.3 (c) 2016-2020
|
||||
|
||||
* - All the amazing contributors
|
||||
* Released under the MIT License.
|
||||
* @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';
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
const util = require('util');
|
||||
const consola = require('consola');
|
||||
const lodash = require('lodash');
|
||||
const index = require('./cli-index.js');
|
||||
require('path');
|
||||
require('@nuxt/config');
|
||||
require('exit');
|
||||
require('@nuxt/utils');
|
||||
require('@nuxt/config');
|
||||
require('path');
|
||||
require('exit');
|
||||
require('chalk');
|
||||
require('std-env');
|
||||
require('wrap-ansi');
|
||||
require('boxen');
|
||||
const consola = _interopDefault(require('consola'));
|
||||
require('minimist');
|
||||
require('hable');
|
||||
require('defu');
|
||||
require('semver');
|
||||
require('fs');
|
||||
require('execa');
|
||||
const util = _interopDefault(require('util'));
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var symbolTag = '[object Symbol]';
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
/**
|
||||
* Checks if `value` is classified as a `Symbol` primitive or object.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isSymbol(Symbol.iterator);
|
||||
* // => true
|
||||
*
|
||||
* _.isSymbol('abc');
|
||||
* // => false
|
||||
*/
|
||||
function isSymbol(value) {
|
||||
return typeof value == 'symbol' ||
|
||||
(index.isObjectLike_1(value) && index._baseGetTag(value) == symbolTag);
|
||||
}
|
||||
|
||||
var isSymbol_1 = isSymbol;
|
||||
|
||||
/** Used to match property names within property paths. */
|
||||
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
|
||||
reIsPlainProp = /^\w*$/;
|
||||
|
||||
/**
|
||||
* Checks if `value` is a property name and not a property path.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @param {Object} [object] The object to query keys on.
|
||||
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
|
||||
*/
|
||||
function isKey(value, object) {
|
||||
if (index.isArray_1(value)) {
|
||||
return false;
|
||||
}
|
||||
var type = typeof value;
|
||||
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
|
||||
value == null || isSymbol_1(value)) {
|
||||
return true;
|
||||
}
|
||||
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
|
||||
(object != null && value in Object(object));
|
||||
}
|
||||
|
||||
var _isKey = isKey;
|
||||
|
||||
/** Error message constants. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
/**
|
||||
* Creates a function that memoizes the result of `func`. If `resolver` is
|
||||
* provided, it determines the cache key for storing the result based on the
|
||||
* arguments provided to the memoized function. By default, the first argument
|
||||
* provided to the memoized function is used as the map cache key. The `func`
|
||||
* is invoked with the `this` binding of the memoized function.
|
||||
*
|
||||
* **Note:** The cache is exposed as the `cache` property on the memoized
|
||||
* function. Its creation may be customized by replacing the `_.memoize.Cache`
|
||||
* constructor with one whose instances implement the
|
||||
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
|
||||
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Function
|
||||
* @param {Function} func The function to have its output memoized.
|
||||
* @param {Function} [resolver] The function to resolve the cache key.
|
||||
* @returns {Function} Returns the new memoized function.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': 1, 'b': 2 };
|
||||
* var other = { 'c': 3, 'd': 4 };
|
||||
*
|
||||
* var values = _.memoize(_.values);
|
||||
* values(object);
|
||||
* // => [1, 2]
|
||||
*
|
||||
* values(other);
|
||||
* // => [3, 4]
|
||||
*
|
||||
* object.a = 2;
|
||||
* values(object);
|
||||
* // => [1, 2]
|
||||
*
|
||||
* // Modify the result cache.
|
||||
* values.cache.set(object, ['a', 'b']);
|
||||
* values(object);
|
||||
* // => ['a', 'b']
|
||||
*
|
||||
* // Replace `_.memoize.Cache`.
|
||||
* _.memoize.Cache = WeakMap;
|
||||
*/
|
||||
function memoize(func, resolver) {
|
||||
if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
|
||||
throw new TypeError(FUNC_ERROR_TEXT);
|
||||
}
|
||||
var memoized = function() {
|
||||
var args = arguments,
|
||||
key = resolver ? resolver.apply(this, args) : args[0],
|
||||
cache = memoized.cache;
|
||||
|
||||
if (cache.has(key)) {
|
||||
return cache.get(key);
|
||||
}
|
||||
var result = func.apply(this, args);
|
||||
memoized.cache = cache.set(key, result) || cache;
|
||||
return result;
|
||||
};
|
||||
memoized.cache = new (memoize.Cache || index._MapCache);
|
||||
return memoized;
|
||||
}
|
||||
|
||||
// Expose `MapCache`.
|
||||
memoize.Cache = index._MapCache;
|
||||
|
||||
var memoize_1 = memoize;
|
||||
|
||||
/** Used as the maximum memoize cache size. */
|
||||
var MAX_MEMOIZE_SIZE = 500;
|
||||
|
||||
/**
|
||||
* A specialized version of `_.memoize` which clears the memoized function's
|
||||
* cache when it exceeds `MAX_MEMOIZE_SIZE`.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} func The function to have its output memoized.
|
||||
* @returns {Function} Returns the new memoized function.
|
||||
*/
|
||||
function memoizeCapped(func) {
|
||||
var result = memoize_1(func, function(key) {
|
||||
if (cache.size === MAX_MEMOIZE_SIZE) {
|
||||
cache.clear();
|
||||
}
|
||||
return key;
|
||||
});
|
||||
|
||||
var cache = result.cache;
|
||||
return result;
|
||||
}
|
||||
|
||||
var _memoizeCapped = memoizeCapped;
|
||||
|
||||
/** Used to match property names within property paths. */
|
||||
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
||||
|
||||
/** Used to match backslashes in property paths. */
|
||||
var reEscapeChar = /\\(\\)?/g;
|
||||
|
||||
/**
|
||||
* Converts `string` to a property path array.
|
||||
*
|
||||
* @private
|
||||
* @param {string} string The string to convert.
|
||||
* @returns {Array} Returns the property path array.
|
||||
*/
|
||||
var stringToPath = _memoizeCapped(function(string) {
|
||||
var result = [];
|
||||
if (string.charCodeAt(0) === 46 /* . */) {
|
||||
result.push('');
|
||||
}
|
||||
string.replace(rePropName, function(match, number, quote, subString) {
|
||||
result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
|
||||
});
|
||||
return result;
|
||||
});
|
||||
|
||||
var _stringToPath = stringToPath;
|
||||
|
||||
/**
|
||||
* A specialized version of `_.map` for arrays without support for iteratee
|
||||
* shorthands.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} [array] The array to iterate over.
|
||||
* @param {Function} iteratee The function invoked per iteration.
|
||||
* @returns {Array} Returns the new mapped array.
|
||||
*/
|
||||
function arrayMap(array, iteratee) {
|
||||
var index = -1,
|
||||
length = array == null ? 0 : array.length,
|
||||
result = Array(length);
|
||||
|
||||
while (++index < length) {
|
||||
result[index] = iteratee(array[index], index, array);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
var _arrayMap = arrayMap;
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
var INFINITY = 1 / 0;
|
||||
|
||||
/** Used to convert symbols to primitives and strings. */
|
||||
var symbolProto = index._Symbol ? index._Symbol.prototype : undefined,
|
||||
symbolToString = symbolProto ? symbolProto.toString : undefined;
|
||||
|
||||
/**
|
||||
* The base implementation of `_.toString` which doesn't convert nullish
|
||||
* values to empty strings.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to process.
|
||||
* @returns {string} Returns the string.
|
||||
*/
|
||||
function baseToString(value) {
|
||||
// Exit early for strings to avoid a performance hit in some environments.
|
||||
if (typeof value == 'string') {
|
||||
return value;
|
||||
}
|
||||
if (index.isArray_1(value)) {
|
||||
// Recursively convert values (susceptible to call stack limits).
|
||||
return _arrayMap(value, baseToString) + '';
|
||||
}
|
||||
if (isSymbol_1(value)) {
|
||||
return symbolToString ? symbolToString.call(value) : '';
|
||||
}
|
||||
var result = (value + '');
|
||||
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
|
||||
}
|
||||
|
||||
var _baseToString = baseToString;
|
||||
|
||||
/**
|
||||
* Converts `value` to a string. An empty string is returned for `null`
|
||||
* and `undefined` values. The sign of `-0` is preserved.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to convert.
|
||||
* @returns {string} Returns the converted string.
|
||||
* @example
|
||||
*
|
||||
* _.toString(null);
|
||||
* // => ''
|
||||
*
|
||||
* _.toString(-0);
|
||||
* // => '-0'
|
||||
*
|
||||
* _.toString([1, 2, 3]);
|
||||
* // => '1,2,3'
|
||||
*/
|
||||
function toString(value) {
|
||||
return value == null ? '' : _baseToString(value);
|
||||
}
|
||||
|
||||
var toString_1 = toString;
|
||||
|
||||
/**
|
||||
* Casts `value` to a path array if it's not one.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to inspect.
|
||||
* @param {Object} [object] The object to query keys on.
|
||||
* @returns {Array} Returns the cast property path array.
|
||||
*/
|
||||
function castPath(value, object) {
|
||||
if (index.isArray_1(value)) {
|
||||
return value;
|
||||
}
|
||||
return _isKey(value, object) ? [value] : _stringToPath(toString_1(value));
|
||||
}
|
||||
|
||||
var _castPath = castPath;
|
||||
|
||||
/** Used as references for various `Number` constants. */
|
||||
var INFINITY$1 = 1 / 0;
|
||||
|
||||
/**
|
||||
* Converts `value` to a string key if it's not a string or symbol.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to inspect.
|
||||
* @returns {string|symbol} Returns the key.
|
||||
*/
|
||||
function toKey(value) {
|
||||
if (typeof value == 'string' || isSymbol_1(value)) {
|
||||
return value;
|
||||
}
|
||||
var result = (value + '');
|
||||
return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
|
||||
}
|
||||
|
||||
var _toKey = toKey;
|
||||
|
||||
/**
|
||||
* The base implementation of `_.get` without support for default values.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} object The object to query.
|
||||
* @param {Array|string} path The path of the property to get.
|
||||
* @returns {*} Returns the resolved value.
|
||||
*/
|
||||
function baseGet(object, path) {
|
||||
path = _castPath(path, object);
|
||||
|
||||
var index = 0,
|
||||
length = path.length;
|
||||
|
||||
while (object != null && index < length) {
|
||||
object = object[_toKey(path[index++])];
|
||||
}
|
||||
return (index && index == length) ? object : undefined;
|
||||
}
|
||||
|
||||
var _baseGet = baseGet;
|
||||
|
||||
/**
|
||||
* Gets the value at `path` of `object`. If the resolved value is
|
||||
* `undefined`, the `defaultValue` is returned in its place.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 3.7.0
|
||||
* @category Object
|
||||
* @param {Object} object The object to query.
|
||||
* @param {Array|string} path The path of the property to get.
|
||||
* @param {*} [defaultValue] The value returned for `undefined` resolved values.
|
||||
* @returns {*} Returns the resolved value.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
|
||||
*
|
||||
* _.get(object, 'a[0].b.c');
|
||||
* // => 3
|
||||
*
|
||||
* _.get(object, ['a', '0', 'b', 'c']);
|
||||
* // => 3
|
||||
*
|
||||
* _.get(object, 'a.b.c', 'default');
|
||||
* // => 'default'
|
||||
*/
|
||||
function get(object, path, defaultValue) {
|
||||
var result = object == null ? undefined : _baseGet(object, path);
|
||||
return result === undefined ? defaultValue : result;
|
||||
}
|
||||
|
||||
var get_1 = get;
|
||||
const util__default = /*#__PURE__*/_interopDefaultLegacy(util);
|
||||
const consola__default = /*#__PURE__*/_interopDefaultLegacy(consola);
|
||||
|
||||
const webpack = {
|
||||
name: 'webpack',
|
||||
@@ -429,14 +84,14 @@ const webpack = {
|
||||
colors: cmd.argv.colors
|
||||
});
|
||||
|
||||
consola.log(serialized + '\n');
|
||||
consola__default['default'].log(serialized + '\n');
|
||||
|
||||
if (serialized.includes('[Object]' )) {
|
||||
consola.info('You can use `--depth` or add more queries to inspect `[Object]` and `[Array]` fields.');
|
||||
consola__default['default'].info('You can use `--depth` or add more queries to inspect `[Object]` and `[Array]` fields.');
|
||||
}
|
||||
|
||||
if (queryError) {
|
||||
consola.warn(`No match in webpack config for \`${queryError}\``);
|
||||
consola__default['default'].warn(`No match in webpack config for \`${queryError}\``);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -451,14 +106,14 @@ function advancedGet (obj = {}, query = '') {
|
||||
const [l, r] = query.split('=');
|
||||
|
||||
if (!Array.isArray(result)) {
|
||||
return typeof result === 'object' ? get_1(result, l) : result
|
||||
return typeof result === 'object' ? lodash.get(result, l) : result
|
||||
}
|
||||
|
||||
result = result.filter((i) => {
|
||||
const v = get_1(i, l);
|
||||
const v = lodash.get(i, l);
|
||||
|
||||
if (!v) {
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -469,6 +124,8 @@ function advancedGet (obj = {}, query = '') {
|
||||
) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
});
|
||||
|
||||
if (result.length === 1) {
|
||||
@@ -479,10 +136,10 @@ function advancedGet (obj = {}, query = '') {
|
||||
}
|
||||
|
||||
function formatObj (obj, formatOptions) {
|
||||
if (!util.formatWithOptions) {
|
||||
return util.format(obj)
|
||||
if (!util__default['default'].formatWithOptions) {
|
||||
return util__default['default'].format(obj)
|
||||
}
|
||||
return util.formatWithOptions(formatOptions, obj)
|
||||
return util__default['default'].formatWithOptions(formatOptions, obj)
|
||||
}
|
||||
|
||||
exports.default = webpack;
|
||||
|
||||
+9
-7
@@ -1,8 +1,7 @@
|
||||
/*!
|
||||
* @nuxt/cli v2.13.3 (c) 2016-2020
|
||||
|
||||
* - All the amazing contributors
|
||||
* Released under the MIT License.
|
||||
* @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';
|
||||
@@ -10,10 +9,10 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const index = require('./cli-index.js');
|
||||
require('path');
|
||||
require('@nuxt/config');
|
||||
require('exit');
|
||||
require('@nuxt/utils');
|
||||
require('@nuxt/config');
|
||||
require('path');
|
||||
require('exit');
|
||||
require('chalk');
|
||||
require('std-env');
|
||||
require('wrap-ansi');
|
||||
@@ -21,6 +20,8 @@ require('boxen');
|
||||
require('consola');
|
||||
require('minimist');
|
||||
require('hable');
|
||||
require('defu');
|
||||
require('semver');
|
||||
require('fs');
|
||||
require('execa');
|
||||
|
||||
@@ -30,6 +31,7 @@ exports.NuxtCommand = index.NuxtCommand;
|
||||
exports.commands = index.index;
|
||||
exports.getWebpackConfig = index.getWebpackConfig;
|
||||
exports.imports = index.imports;
|
||||
exports.isNuxtDir = index.isNuxtDir;
|
||||
exports.loadNuxtConfig = index.loadNuxtConfig;
|
||||
exports.options = index.index$1;
|
||||
exports.run = index.run;
|
||||
|
||||
Reference in New Issue
Block a user