Comparing version 2.15.8 to 2.16.0
/*! | ||
* @nuxt/cli v2.15.8 (c) 2016-2021 | ||
* @nuxt/cli v2.16.0 (c) 2016-2023 | ||
* Released under the MIT License | ||
@@ -10,3 +10,3 @@ * Repository: https://github.com/nuxt/nuxt.js | ||
const consola = require('consola'); | ||
const env = require('std-env'); | ||
const stdEnv = require('std-env'); | ||
const chalk = require('chalk'); | ||
@@ -16,77 +16,51 @@ const index = require('./cli-index.js'); | ||
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 | ||
function getMemoryUsage() { | ||
const { heapUsed, rss } = process.memoryUsage(); | ||
return { heap: heapUsed, rss } | ||
return { heap: heapUsed, rss }; | ||
} | ||
function getFormattedMemoryUsage () { | ||
function getFormattedMemoryUsage() { | ||
const { heap, rss } = getMemoryUsage(); | ||
return `Memory usage: ${chalk__default['default'].bold(prettyBytes__default['default'](heap))} (RSS: ${prettyBytes__default['default'](rss)})` | ||
return `Memory usage: ${chalk.bold(prettyBytes(heap))} (RSS: ${prettyBytes(rss)})`; | ||
} | ||
function showMemoryUsage () { | ||
consola__default['default'].info(getFormattedMemoryUsage()); | ||
function showMemoryUsage() { | ||
consola.info(getFormattedMemoryUsage()); | ||
} | ||
function showBanner (nuxt, showMemoryUsage = true) { | ||
if (env__default['default'].test) { | ||
return | ||
function showBanner(nuxt, showMemoryUsage = true) { | ||
if (stdEnv.isTest) { | ||
return; | ||
} | ||
if (env__default['default'].minimalCLI) { | ||
if (stdEnv.isMinimal) { | ||
for (const listener of nuxt.server.listeners) { | ||
consola__default['default'].info('Listening on: ' + listener.url); | ||
consola.info("Listening on: " + listener.url); | ||
} | ||
return | ||
return; | ||
} | ||
const titleLines = []; | ||
const messageLines = []; | ||
// Name and version | ||
const { bannerColor, badgeMessages } = nuxt.options.cli; | ||
titleLines.push(`${chalk__default['default'][bannerColor].bold('Nuxt')} @ ${nuxt.constructor.version || 'exotic'}\n`); | ||
const label = name => chalk__default['default'].bold.cyan(`▸ ${name}:`); | ||
// Environment | ||
titleLines.push(`${chalk[bannerColor].bold("Nuxt")} @ ${nuxt.constructor.version || "exotic"} | ||
`); | ||
const label = (name) => chalk.bold.cyan(`\u25B8 ${name}:`); | ||
const isDev = nuxt.options.dev; | ||
let _env = isDev ? 'development' : 'production'; | ||
let _env = isDev ? "development" : "production"; | ||
if (process.env.NODE_ENV !== _env) { | ||
_env += ` (${chalk__default['default'].cyan(process.env.NODE_ENV)})`; | ||
_env += ` (${chalk.cyan(process.env.NODE_ENV)})`; | ||
} | ||
titleLines.push(`${label('Environment')} ${_env}`); | ||
// Rendering | ||
titleLines.push(`${label("Environment")} ${_env}`); | ||
const isSSR = nuxt.options.render.ssr; | ||
const rendering = isSSR ? 'server-side' : 'client-side'; | ||
titleLines.push(`${label('Rendering')} ${rendering}`); | ||
// Target | ||
const target = nuxt.options.target || 'server'; | ||
titleLines.push(`${label('Target')} ${target}`); | ||
const rendering = isSSR ? "server-side" : "client-side"; | ||
titleLines.push(`${label("Rendering")} ${rendering}`); | ||
const target = nuxt.options.target || "server"; | ||
titleLines.push(`${label("Target")} ${target}`); | ||
if (showMemoryUsage) { | ||
titleLines.push('\n' + getFormattedMemoryUsage()); | ||
titleLines.push("\n" + getFormattedMemoryUsage()); | ||
} | ||
// Listeners | ||
for (const listener of nuxt.server.listeners) { | ||
messageLines.push(chalk__default['default'].bold('Listening: ') + chalk__default['default'].underline.blue(listener.url)); | ||
messageLines.push(chalk.bold("Listening: ") + chalk.underline.blue(listener.url)); | ||
} | ||
// Add custom badge messages | ||
if (badgeMessages.length) { | ||
messageLines.push('', ...badgeMessages); | ||
messageLines.push("", ...badgeMessages); | ||
} | ||
process.stdout.write(index.successBox(messageLines.join('\n'), titleLines.join('\n'))); | ||
process.stdout.write(index.successBox(messageLines.join("\n"), titleLines.join("\n"))); | ||
} | ||
@@ -93,0 +67,0 @@ |
/*! | ||
* @nuxt/cli v2.15.8 (c) 2016-2021 | ||
* @nuxt/cli v2.16.0 (c) 2016-2023 | ||
* Released under the MIT License | ||
@@ -26,10 +26,6 @@ * Repository: https://github.com/nuxt/nuxt.js | ||
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', | ||
usage: 'build <dir>', | ||
name: "build", | ||
description: "Compiles the application for production deployment", | ||
usage: "build <dir>", | ||
options: { | ||
@@ -39,9 +35,8 @@ ...index.common, | ||
analyze: { | ||
alias: 'a', | ||
type: 'boolean', | ||
description: 'Launch webpack-bundle-analyzer to optimize your bundles', | ||
prepare (cmd, options, argv) { | ||
// Analyze option | ||
alias: "a", | ||
type: "boolean", | ||
description: "Launch webpack-bundle-analyzer to optimize your bundles", | ||
prepare(cmd, options, argv) { | ||
options.build = options.build || {}; | ||
if (argv.analyze && typeof options.build.analyze !== 'object') { | ||
if (argv.analyze && typeof options.build.analyze !== "object") { | ||
options.build.analyze = true; | ||
@@ -52,6 +47,6 @@ } | ||
devtools: { | ||
type: 'boolean', | ||
type: "boolean", | ||
default: false, | ||
description: 'Enable Vue devtools', | ||
prepare (cmd, options, argv) { | ||
description: "Enable Vue devtools", | ||
prepare(cmd, options, argv) { | ||
options.vue = options.vue || {}; | ||
@@ -65,12 +60,11 @@ options.vue.config = options.vue.config || {}; | ||
generate: { | ||
type: 'boolean', | ||
type: "boolean", | ||
default: true, | ||
description: 'Don\'t generate static version for SPA mode (useful for nuxt start)' | ||
description: "Don't generate static version for SPA mode (useful for nuxt start)" | ||
}, | ||
quiet: { | ||
alias: 'q', | ||
type: 'boolean', | ||
description: 'Disable output except for errors', | ||
prepare (cmd, options, argv) { | ||
// Silence output when using --quiet | ||
alias: "q", | ||
type: "boolean", | ||
description: "Disable output except for errors", | ||
prepare(cmd, options, argv) { | ||
options.build = options.build || {}; | ||
@@ -83,6 +77,6 @@ if (argv.quiet) { | ||
standalone: { | ||
type: 'boolean', | ||
type: "boolean", | ||
default: false, | ||
description: 'Bundle all server dependencies (useful for nuxt-start)', | ||
prepare (cmd, options, argv) { | ||
description: "Bundle all server dependencies (useful for nuxt-start)", | ||
prepare(cmd, options, argv) { | ||
if (argv.standalone) { | ||
@@ -94,10 +88,9 @@ options.build.standalone = true; | ||
}, | ||
async run (cmd) { | ||
async run(cmd) { | ||
const config = await cmd.getNuxtConfig({ dev: false, server: false, _build: true }); | ||
config.server = (config.mode === utils.MODES.spa || config.ssr === false) && cmd.argv.generate !== false; | ||
const nuxt = await cmd.getNuxt(config); | ||
if (cmd.argv.lock) { | ||
await cmd.setLock(await index.createLock({ | ||
id: 'build', | ||
id: "build", | ||
dir: nuxt.options.buildDir, | ||
@@ -107,15 +100,10 @@ root: config.rootDir | ||
} | ||
// TODO: remove if in Nuxt 3 | ||
if (nuxt.options.mode === utils.MODES.spa && nuxt.options.target === utils.TARGETS.server && cmd.argv.generate !== false) { | ||
// Build + Generate for static deployment | ||
const generator = await cmd.getGenerator(nuxt); | ||
await generator.generate({ build: true }); | ||
} else { | ||
// Build only | ||
const builder = await cmd.getBuilder(nuxt); | ||
await builder.build(); | ||
const nextCommand = nuxt.options.target === utils.TARGETS.static ? 'nuxt generate' : 'nuxt start'; | ||
consola__default['default'].info('Ready to run `' + (nextCommand) + '`'); | ||
const nextCommand = nuxt.options.target === utils.TARGETS.static ? "nuxt generate" : "nuxt start"; | ||
consola.info("Ready to run `" + nextCommand + "`"); | ||
} | ||
@@ -122,0 +110,0 @@ } |
/*! | ||
* @nuxt/cli v2.15.8 (c) 2016-2021 | ||
* @nuxt/cli v2.16.0 (c) 2016-2023 | ||
* Released under the MIT License | ||
@@ -29,12 +29,6 @@ * Repository: https://github.com/nuxt/nuxt.js | ||
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', | ||
description: 'Start the application in development mode (e.g. hot-code reloading, error reporting)', | ||
usage: 'dev <dir>', | ||
name: "dev", | ||
description: "Start the application in development mode (e.g. hot-code reloading, error reporting)", | ||
usage: "dev <dir>", | ||
options: { | ||
@@ -44,15 +38,12 @@ ...index.common, | ||
open: { | ||
alias: 'o', | ||
type: 'boolean', | ||
description: 'Opens the server listeners url in the default browser' | ||
alias: "o", | ||
type: "boolean", | ||
description: "Opens the server listeners url in the default browser" | ||
} | ||
}, | ||
async run (cmd) { | ||
async run(cmd) { | ||
const { argv } = cmd; | ||
await this.startDev(cmd, argv, argv.open); | ||
}, | ||
async startDev (cmd, argv) { | ||
async startDev(cmd, argv) { | ||
let nuxt; | ||
@@ -62,83 +53,52 @@ try { | ||
} catch (error) { | ||
consola__default['default'].fatal(error); | ||
return | ||
consola.fatal(error); | ||
return; | ||
} | ||
try { | ||
await this._buildDev(cmd, argv, nuxt); | ||
} catch (error) { | ||
await nuxt.callHook('cli:buildError', error); | ||
consola__default['default'].error(error); | ||
await nuxt.callHook("cli:buildError", error); | ||
consola.error(error); | ||
} | ||
return nuxt | ||
return nuxt; | ||
}, | ||
async _listenDev (cmd, argv) { | ||
async _listenDev(cmd, argv) { | ||
const config = await cmd.getNuxtConfig({ dev: true, _build: true }); | ||
const nuxt = await cmd.getNuxt(config); | ||
// Setup hooks | ||
nuxt.hook('watch:restart', payload => this.onWatchRestart(payload, { nuxt, cmd, argv })); | ||
nuxt.hook('bundler:change', changedFileName => this.onBundlerChange(changedFileName)); | ||
// Wait for nuxt to be ready | ||
nuxt.hook("watch:restart", (payload) => this.onWatchRestart(payload, { nuxt, cmd, argv })); | ||
nuxt.hook("bundler:change", (changedFileName) => this.onBundlerChange(changedFileName)); | ||
await nuxt.ready(); | ||
// Start listening | ||
await nuxt.server.listen(); | ||
// Show banner when listening | ||
banner.showBanner(nuxt, false); | ||
// 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__default['default'](listener.url)); | ||
const openerPromises = nuxt.server.listeners.map((listener) => opener(listener.url)); | ||
await Promise.all(openerPromises); | ||
} | ||
// Return instance | ||
return nuxt | ||
return nuxt; | ||
}, | ||
async _buildDev (cmd, argv, nuxt) { | ||
// Create builder instance | ||
async _buildDev(cmd, argv, nuxt) { | ||
const builder = await cmd.getBuilder(nuxt); | ||
// Start Build | ||
await builder.build(); | ||
// Print memory usage | ||
banner.showMemoryUsage(); | ||
// Display server urls after the build | ||
for (const listener of nuxt.server.listeners) { | ||
consola__default['default'].info(chalk__default['default'].bold('Listening on: ') + listener.url); | ||
consola.info(chalk.bold("Listening on: ") + listener.url); | ||
} | ||
// Return instance | ||
return nuxt | ||
return nuxt; | ||
}, | ||
logChanged ({ event, path }) { | ||
logChanged({ event, path }) { | ||
const { icon, color, action } = index.eventsMapping[event] || index.eventsMapping.change; | ||
consola__default['default'].log({ | ||
consola.log({ | ||
type: event, | ||
icon: chalk__default['default'][color].bold(icon), | ||
message: `${action} ${chalk__default['default'].cyan(index.formatPath(path))}` | ||
icon: chalk[color].bold(icon), | ||
message: `${action} ${chalk.cyan(index.formatPath(path))}` | ||
}); | ||
}, | ||
async onWatchRestart ({ event, path }, { nuxt, cmd, argv }) { | ||
async onWatchRestart({ event, path }, { nuxt, cmd, argv }) { | ||
this.logChanged({ event, path }); | ||
await nuxt.close(); | ||
await this.startDev(cmd, argv); | ||
}, | ||
onBundlerChange (path) { | ||
this.logChanged({ event: 'change', path }); | ||
onBundlerChange(path) { | ||
this.logChanged({ event: "change", path }); | ||
} | ||
@@ -145,0 +105,0 @@ }; |
/*! | ||
* @nuxt/cli v2.15.8 (c) 2016-2021 | ||
* @nuxt/cli v2.16.0 (c) 2016-2023 | ||
* Released under the MIT License | ||
@@ -28,15 +28,11 @@ * Repository: https://github.com/nuxt/nuxt.js | ||
require('fs-extra'); | ||
require('crc/lib/crc32'); | ||
require('crc/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 = { | ||
...generate['default'], | ||
run (...args) { | ||
consola__default['default'].warn('`nuxt export` has been deprecated! Please use `nuxt generate`.'); | ||
return generate['default'].run.call(this, ...args) | ||
...generate.default, | ||
run(...args) { | ||
consola.warn("`nuxt export` has been deprecated! Please use `nuxt generate`."); | ||
return generate.default.run.call(this, ...args); | ||
} | ||
@@ -43,0 +39,0 @@ }; |
/*! | ||
* @nuxt/cli v2.15.8 (c) 2016-2021 | ||
* @nuxt/cli v2.16.0 (c) 2016-2023 | ||
* Released under the MIT License | ||
@@ -15,3 +15,3 @@ * Repository: https://github.com/nuxt/nuxt.js | ||
const fs = require('fs-extra'); | ||
const crc32 = require('crc/lib/crc32'); | ||
const crc32 = require('crc/crc32'); | ||
const globby = require('globby'); | ||
@@ -32,36 +32,21 @@ const destr = require('destr'); | ||
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) { | ||
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') | ||
if (cmd.argv["fail-on-error"] && errors.length > 0) { | ||
throw new Error("Error generating pages, exiting with non-zero code"); | ||
} | ||
} | ||
async function ensureBuild (cmd) { | ||
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(); | ||
if (options.generate.cache === false || destr(process.env.NUXT_BUILD) || cmd.argv["force-build"]) { | ||
const builder2 = await cmd.getBuilder(nuxt); | ||
await builder2.build(); | ||
await nuxt.close(); | ||
return | ||
return; | ||
} | ||
// Default build ignore files | ||
const ignore = [ | ||
@@ -71,33 +56,25 @@ options.buildDir, | ||
options.generate.dir, | ||
'node_modules', | ||
'.**/*', | ||
'.*', | ||
'README.md' | ||
"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); | ||
const { generate: generate2 } = options; | ||
if (typeof generate2.cache.ignore === "function") { | ||
generate2.cache.ignore = generate2.cache.ignore(ignore); | ||
} else if (Array.isArray(generate2.cache.ignore)) { | ||
generate2.cache.ignore = generate2.cache.ignore.concat(ignore); | ||
} | ||
await nuxt.callHook('generate:cache:ignore', generate.cache.ignore); | ||
// Take a snapshot of current project | ||
await nuxt.callHook("generate:cache:ignore", generate2.cache.ignore); | ||
const snapshotOptions = { | ||
rootDir: options.rootDir, | ||
ignore: generate.cache.ignore.map(upath__default['default'].normalize), | ||
globbyOptions: generate.cache.globbyOptions | ||
ignore: generate2.cache.ignore.map(upath.normalize), | ||
globbyOptions: generate2.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 configSrc = await fs.readFile(nuxt.options._nuxtConfigFile); | ||
const envRegex = /process.env.(\w+)/g; | ||
let match; | ||
// eslint-disable-next-line no-cond-assign | ||
while (match = envRegex.exec(configSrc)) { | ||
@@ -107,4 +84,2 @@ processEnv[match[1]] = process.env[match[1]]; | ||
} | ||
// Current build meta | ||
const currentBuild = { | ||
@@ -117,45 +92,37 @@ // @ts-ignore | ||
env: nuxt.options.env, | ||
'process.env': processEnv | ||
"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 | ||
const nuxtBuildFile = path.resolve(nuxt.options.buildDir, "build.json"); | ||
if (fs.existsSync(nuxtBuildFile)) { | ||
const previousBuild = destr(fs.readFileSync(nuxtBuildFile, "utf-8")) || {}; | ||
let needBuild = false; | ||
for (const field of ['nuxtVersion', 'ssr', 'target', 'env', 'process.env']) { | ||
const fields = ["nuxtVersion", "ssr", "target"]; | ||
if (nuxt.options.generate.ignoreEnv !== true) { | ||
fields.push("env", "process.env"); | ||
} | ||
for (const field of fields) { | ||
if (JSON.stringify(previousBuild[field]) !== JSON.stringify(currentBuild[field])) { | ||
needBuild = true; | ||
consola__default['default'].info(`Doing webpack rebuild because ${field} changed`); | ||
break | ||
consola.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 | ||
consola.success("Skipping webpack build as no changes detected"); | ||
await nuxt.close(); | ||
return; | ||
} else { | ||
consola__default['default'].info(`Doing webpack rebuild because ${changed} modified`); | ||
consola.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'); | ||
fs.writeFileSync(nuxtBuildFile, JSON.stringify(currentBuild, null, 2), "utf-8"); | ||
await nuxt.close(); | ||
} | ||
async function getNuxt (args, cmd) { | ||
async function getNuxt(args, cmd) { | ||
const config = await cmd.getNuxtConfig({ dev: false, ...args }); | ||
if (config.target === utils.TARGETS.static) { | ||
@@ -166,35 +133,27 @@ config._export = true; | ||
} | ||
config.buildDir = (config.static && config.static.cacheDir) || path__default['default'].resolve(config.rootDir, 'node_modules/.cache/nuxt'); | ||
config.buildDir = config.static && config.static.cacheDir || path.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'); | ||
config.build.transpile.push(".cache/nuxt"); | ||
} | ||
const nuxt = await cmd.getNuxt(config); | ||
return nuxt | ||
return nuxt; | ||
} | ||
function compareSnapshots (from, to) { | ||
const allKeys = Array.from(new Set([ | ||
function compareSnapshots(from, to) { | ||
const allKeys = Array.from(/* @__PURE__ */ 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 key; | ||
} | ||
} | ||
return false | ||
return false; | ||
} | ||
async function snapshot ({ globbyOptions, ignore, rootDir }) { | ||
const snapshot = {}; | ||
const files = await globby__default['default']('**/*.*', { | ||
async function snapshot({ globbyOptions, ignore, rootDir }) { | ||
const snapshot2 = {}; | ||
const files = await globby("**/*.*", { | ||
...globbyOptions, | ||
@@ -205,13 +164,11 @@ ignore, | ||
}); | ||
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) | ||
const fileContent = await fs.readFile(p); | ||
snapshot2[key] = { | ||
checksum: await crc32(fileContent).toString(16) | ||
}; | ||
} catch (e) { | ||
// TODO: Check for other errors like permission denied | ||
snapshot[key] = { | ||
snapshot2[key] = { | ||
exists: false | ||
@@ -221,10 +178,9 @@ }; | ||
})); | ||
return snapshot | ||
return snapshot2; | ||
} | ||
const generate = { | ||
name: 'generate', | ||
description: 'Generate a static web application (server-rendered)', | ||
usage: 'generate <dir>', | ||
name: "generate", | ||
description: "Generate a static web application (server-rendered)", | ||
usage: "generate <dir>", | ||
options: { | ||
@@ -234,11 +190,11 @@ ...index.common, | ||
build: { | ||
type: 'boolean', | ||
type: "boolean", | ||
default: true, | ||
description: 'Only generate pages for dynamic routes, used for incremental builds. Generate has to be run once without this option before using it' | ||
description: "Only generate pages for dynamic routes, used for incremental builds. Generate has to be run once without this option before using it" | ||
}, | ||
devtools: { | ||
type: 'boolean', | ||
type: "boolean", | ||
default: false, | ||
description: 'Enable Vue devtools', | ||
prepare (cmd, options, argv) { | ||
description: "Enable Vue devtools", | ||
prepare(cmd, options, argv) { | ||
options.vue = options.vue || {}; | ||
@@ -252,7 +208,6 @@ options.vue.config = options.vue.config || {}; | ||
quiet: { | ||
alias: 'q', | ||
type: 'boolean', | ||
description: 'Disable output except for errors', | ||
prepare (cmd, options, argv) { | ||
// Silence output when using --quiet | ||
alias: "q", | ||
type: "boolean", | ||
description: "Disable output except for errors", | ||
prepare(cmd, options, argv) { | ||
options.build = options.build || {}; | ||
@@ -266,59 +221,47 @@ if (argv.quiet) { | ||
...index.common.modern, | ||
description: 'Generate app in modern build (modern mode can be only client)', | ||
prepare (cmd, options, argv) { | ||
description: "Generate app in modern build (modern mode can be only client)", | ||
prepare(cmd, options, argv) { | ||
if (index.normalizeArg(argv.modern)) { | ||
options.modern = 'client'; | ||
options.modern = "client"; | ||
} | ||
} | ||
}, | ||
'force-build': { | ||
type: 'boolean', | ||
"force-build": { | ||
type: "boolean", | ||
default: false, | ||
description: 'Force to build the application with webpack' | ||
description: "Force to build the application with webpack" | ||
}, | ||
'fail-on-error': { | ||
type: 'boolean', | ||
"fail-on-error": { | ||
type: "boolean", | ||
default: false, | ||
description: 'Exit with non-zero status code if there are errors when generating pages' | ||
description: "Exit with non-zero status code if there are errors when generating pages" | ||
} | ||
}, | ||
async run (cmd) { | ||
async run(cmd) { | ||
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 | ||
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 | ||
consola.warn(`When using \`nuxt generate\`, you should set \`target: 'static'\` in your \`nuxt.config\` | ||
\u{1F449} Learn more about it on https://go.nuxtjs.dev/static-target`); | ||
config._legacyGenerate = true; | ||
if (config.build) { | ||
// https://github.com/nuxt/nuxt.js/issues/7390 | ||
config.build.parallel = false; | ||
} | ||
const nuxt = await cmd.getNuxt(config); | ||
if (cmd.argv.lock) { | ||
await cmd.setLock(await index.createLock({ | ||
id: 'build', | ||
id: "build", | ||
dir: nuxt.options.buildDir, | ||
root: config.rootDir | ||
})); | ||
nuxt.hook('build:done', async () => { | ||
nuxt.hook("build:done", async () => { | ||
await cmd.releaseLock(); | ||
await cmd.setLock(await index.createLock({ | ||
id: 'generate', | ||
id: "generate", | ||
dir: nuxt.options.generate.dir, | ||
@@ -329,6 +272,4 @@ root: config.rootDir | ||
} | ||
const generator = await cmd.getGenerator(nuxt); | ||
await nuxt.server.listen(0); | ||
const { errors } = await generator.generate({ | ||
@@ -338,6 +279,5 @@ init: true, | ||
}); | ||
await nuxt.close(); | ||
if (cmd.argv['fail-on-error'] && errors.length > 0) { | ||
throw new Error('Error generating pages, exiting with non-zero code') | ||
if (cmd.argv["fail-on-error"] && errors.length > 0) { | ||
throw new Error("Error generating pages, exiting with non-zero code"); | ||
} | ||
@@ -344,0 +284,0 @@ } |
/*! | ||
* @nuxt/cli v2.15.8 (c) 2016-2021 | ||
* @nuxt/cli v2.16.0 (c) 2016-2023 | ||
* Released under the MIT License | ||
@@ -26,18 +26,9 @@ * Repository: https://github.com/nuxt/nuxt.js | ||
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 | ||
async function listCommands() { | ||
const commandsOrder = ["dev", "build", "generate", "start", "help"]; | ||
const _commands = await Promise.all( | ||
commandsOrder.map(cmd => index.getCommand(cmd)) | ||
commandsOrder.map((cmd) => index.getCommand(cmd)) | ||
); | ||
let maxLength = 0; | ||
const commandsHelp = []; | ||
for (const command of _commands) { | ||
@@ -47,22 +38,23 @@ commandsHelp.push([command.usage, command.description]); | ||
} | ||
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, | ||
chalk.green(cmd) + i + description, | ||
index.startSpaces + maxLength + index.optionSpaces * 2, | ||
index.startSpaces + index.optionSpaces | ||
) | ||
}).join('\n'); | ||
); | ||
}).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} | ||
const usage = index.foldLines('Usage: nuxt <command> [--help|-h]', index.startSpaces); | ||
const cmds = index.foldLines('Commands:', index.startSpaces) + '\n\n' + _cmds; | ||
${cmds} | ||
process.stderr.write(index.colorize(`${usage}\n\n${cmds}\n\n`)); | ||
`)); | ||
} | ||
const help = { | ||
name: 'help', | ||
description: 'Shows help for <command>', | ||
usage: 'help <command>', | ||
name: "help", | ||
description: "Shows help for <command>", | ||
usage: "help <command>", | ||
options: { | ||
@@ -72,14 +64,12 @@ help: index.common.help, | ||
}, | ||
async run (cmd) { | ||
async run(cmd) { | ||
const [name] = cmd._argv; | ||
if (!name) { | ||
return listCommands() | ||
return listCommands(); | ||
} | ||
const command = await index.getCommand(name); | ||
if (!command) { | ||
consola__default['default'].info(`Unknown command: ${name}`); | ||
return | ||
consola.info(`Unknown command: ${name}`); | ||
return; | ||
} | ||
index.NuxtCommand.from(command).showHelp(); | ||
@@ -86,0 +76,0 @@ } |
/*! | ||
* @nuxt/cli v2.15.8 (c) 2016-2021 | ||
* @nuxt/cli v2.16.0 (c) 2016-2023 | ||
* Released under the MIT License | ||
@@ -14,3 +14,3 @@ * Repository: https://github.com/nuxt/nuxt.js | ||
const chalk = require('chalk'); | ||
const env = require('std-env'); | ||
const stdEnv = require('std-env'); | ||
const wrapAnsi = require('wrap-ansi'); | ||
@@ -26,17 +26,2 @@ const boxen = require('boxen'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
const path__default = /*#__PURE__*/_interopDefaultLegacy(path); | ||
const exit__default = /*#__PURE__*/_interopDefaultLegacy(exit); | ||
const chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk); | ||
const env__default = /*#__PURE__*/_interopDefaultLegacy(env); | ||
const wrapAnsi__default = /*#__PURE__*/_interopDefaultLegacy(wrapAnsi); | ||
const boxen__default = /*#__PURE__*/_interopDefaultLegacy(boxen); | ||
const consola__default = /*#__PURE__*/_interopDefaultLegacy(consola); | ||
const minimist__default = /*#__PURE__*/_interopDefaultLegacy(minimist); | ||
const Hookable__default = /*#__PURE__*/_interopDefaultLegacy(Hookable); | ||
const defu__default = /*#__PURE__*/_interopDefaultLegacy(defu); | ||
const fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); | ||
const execa__default = /*#__PURE__*/_interopDefaultLegacy(execa); | ||
const commands = { | ||
@@ -52,8 +37,7 @@ start: () => Promise.resolve().then(function () { return require('./cli-start.js'); }), | ||
}; | ||
function getCommand (name) { | ||
function getCommand(name) { | ||
if (!commands[name]) { | ||
return Promise.resolve(null) | ||
return Promise.resolve(null); | ||
} | ||
return commands[name]().then(m => m.default) | ||
return commands[name]().then((m) => m.default); | ||
} | ||
@@ -63,3 +47,3 @@ | ||
__proto__: null, | ||
'default': getCommand | ||
default: getCommand | ||
}); | ||
@@ -69,45 +53,39 @@ | ||
try { | ||
return Promise.resolve(utils.requireModule(id)) | ||
return Promise.resolve(utils.requireModule(id)); | ||
} catch (err) { | ||
if (err.code === 'MODULE_NOT_FOUND') { | ||
if (err.code === "MODULE_NOT_FOUND") { | ||
err.message = `Cannot import module '${id}'`; | ||
} | ||
return Promise.reject(err) | ||
return Promise.reject(err); | ||
} | ||
}; | ||
const builder = () => importModule("@nuxt/builder"); | ||
const webpack = () => importModule("@nuxt/webpack"); | ||
const generator = () => importModule("@nuxt/generator"); | ||
const core = () => importModule("@nuxt/core"); | ||
const server$1 = () => importModule("@nuxt/server"); | ||
const builder = () => importModule('@nuxt/builder'); | ||
const webpack = () => importModule('@nuxt/webpack'); | ||
const generator = () => importModule('@nuxt/generator'); | ||
const core = () => importModule('@nuxt/core'); | ||
const server$1 = () => importModule('@nuxt/server'); | ||
const imports = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
importModule: importModule, | ||
builder: builder, | ||
webpack: webpack, | ||
core: core, | ||
generator: generator, | ||
core: core, | ||
server: server$1 | ||
importModule: importModule, | ||
server: server$1, | ||
webpack: webpack | ||
}); | ||
const forceExitTimeout = 5; | ||
const startSpaces = 2; | ||
const optionSpaces = 2; | ||
// 80% of terminal column width | ||
// this is a fn because console width can have changed since startup | ||
const maxCharsPerLine = () => (process.stdout.columns || 100) * 80 / 100; | ||
function indent (count, chr = ' ') { | ||
return chr.repeat(count) | ||
function indent(count, chr = " ") { | ||
return chr.repeat(count); | ||
} | ||
function indentLines (string, spaces, firstLineSpaces) { | ||
const lines = Array.isArray(string) ? string : string.split('\n'); | ||
let s = ''; | ||
function indentLines(string, spaces, firstLineSpaces) { | ||
const lines = Array.isArray(string) ? string : string.split("\n"); | ||
let s = ""; | ||
if (lines.length) { | ||
const i0 = indent(firstLineSpaces === undefined ? spaces : firstLineSpaces); | ||
const i0 = indent(firstLineSpaces === void 0 ? spaces : firstLineSpaces); | ||
s = i0 + lines.shift(); | ||
@@ -117,86 +95,72 @@ } | ||
const i = indent(spaces); | ||
s += '\n' + lines.map(l => i + l).join('\n'); | ||
s += "\n" + lines.map((l) => i + l).join("\n"); | ||
} | ||
return s | ||
return s; | ||
} | ||
function foldLines (string, spaces, firstLineSpaces, charsPerLine = maxCharsPerLine()) { | ||
return indentLines(wrapAnsi__default['default'](string, charsPerLine), spaces, firstLineSpaces) | ||
function foldLines(string, spaces, firstLineSpaces, charsPerLine = maxCharsPerLine()) { | ||
return indentLines(wrapAnsi(string, charsPerLine), spaces, firstLineSpaces); | ||
} | ||
function colorize (text) { | ||
return text | ||
.replace(/\[[^ ]+]/g, m => chalk__default['default'].grey(m)) | ||
.replace(/<[^ ]+>/g, m => chalk__default['default'].green(m)) | ||
.replace(/ (-[-\w,]+)/g, m => chalk__default['default'].bold(m)) | ||
.replace(/`([^`]+)`/g, (_, m) => chalk__default['default'].bold.cyan(m)) | ||
function colorize(text) { | ||
return text.replace(/\[[^ ]+]/g, (m) => chalk.grey(m)).replace(/<[^ ]+>/g, (m) => chalk.green(m)).replace(/ (-[-\w,]+)/g, (m) => chalk.bold(m)).replace(/`([^`]+)`/g, (_, m) => chalk.bold.cyan(m)); | ||
} | ||
function box (message, title, options) { | ||
return boxen__default['default']([ | ||
title || chalk__default['default'].white('Nuxt Message'), | ||
'', | ||
chalk__default['default'].white(foldLines(message, 0, 0, maxCharsPerLine())) | ||
].join('\n'), Object.assign({ | ||
borderColor: 'white', | ||
borderStyle: 'round', | ||
function box(message, title, options) { | ||
return boxen([ | ||
title || chalk.white("Nuxt Message"), | ||
"", | ||
chalk.white(foldLines(message, 0, 0, maxCharsPerLine())) | ||
].join("\n"), Object.assign({ | ||
borderColor: "white", | ||
borderStyle: "round", | ||
padding: 1, | ||
margin: 1 | ||
}, options)) + '\n' | ||
}, options)) + "\n"; | ||
} | ||
function successBox (message, title) { | ||
return box(message, title || chalk__default['default'].green('✔ Nuxt Success'), { | ||
borderColor: 'green' | ||
}) | ||
function successBox(message, title) { | ||
return box(message, title || chalk.green("\u2714 Nuxt Success"), { | ||
borderColor: "green" | ||
}); | ||
} | ||
function warningBox (message, title) { | ||
return box(message, title || chalk__default['default'].yellow('⚠ Nuxt Warning'), { | ||
borderColor: 'yellow' | ||
}) | ||
function warningBox(message, title) { | ||
return box(message, title || chalk.yellow("\u26A0 Nuxt Warning"), { | ||
borderColor: "yellow" | ||
}); | ||
} | ||
function errorBox (message, title) { | ||
return box(message, title || chalk__default['default'].red('✖ Nuxt Error'), { | ||
borderColor: 'red' | ||
}) | ||
function errorBox(message, title) { | ||
return box(message, title || chalk.red("\u2716 Nuxt Error"), { | ||
borderColor: "red" | ||
}); | ||
} | ||
function fatalBox (message, title) { | ||
return errorBox(message, title || chalk__default['default'].red('✖ Nuxt Fatal Error')) | ||
function fatalBox(message, title) { | ||
return errorBox(message, title || chalk.red("\u2716 Nuxt Fatal Error")); | ||
} | ||
const eventsMapping = { | ||
add: { icon: '+', color: 'green', action: 'Created' }, | ||
change: { icon: env__default['default'].windows ? '»' : '↻', color: 'blue', action: 'Updated' }, | ||
unlink: { icon: '-', color: 'red', action: 'Removed' } | ||
add: { icon: "+", color: "green", action: "Created" }, | ||
change: { icon: stdEnv.isWindows ? "\xBB" : "\u21BB", color: "blue", action: "Updated" }, | ||
unlink: { icon: "-", color: "red", action: "Removed" } | ||
}; | ||
function formatPath (filePath) { | ||
function formatPath(filePath) { | ||
if (!filePath) { | ||
return | ||
return; | ||
} | ||
return filePath.replace(process.cwd() + path__default['default'].sep, '') | ||
return filePath.replace(process.cwd() + path.sep, ""); | ||
} | ||
/** | ||
* Normalize string argument in command | ||
* | ||
* @export | ||
* @param {String} argument | ||
* @param {*} defaultValue | ||
* @returns formatted argument | ||
*/ | ||
function normalizeArg (arg, defaultValue) { | ||
function normalizeArg(arg, defaultValue) { | ||
switch (arg) { | ||
case 'true': arg = true; break | ||
case '': arg = true; break | ||
case 'false': arg = false; break | ||
case undefined: arg = defaultValue; break | ||
case "true": | ||
arg = true; | ||
break; | ||
case "": | ||
arg = true; | ||
break; | ||
case "false": | ||
arg = false; | ||
break; | ||
case void 0: | ||
arg = defaultValue; | ||
break; | ||
} | ||
return arg | ||
return arg; | ||
} | ||
function forceExit (cmdName, timeout) { | ||
function forceExit(cmdName, timeout) { | ||
if (timeout !== false) { | ||
@@ -209,18 +173,13 @@ const exitTimeout = setTimeout(() => { | ||
${chalk__default['default'].bold('DeprecationWarning: Starting with Nuxt version 3 this will be a fatal error')}`; | ||
// TODO: Change this to a fatal error in v3 | ||
${chalk.bold("DeprecationWarning: Starting with Nuxt version 3 this will be a fatal error")}`; | ||
process.stderr.write(warningBox(msg)); | ||
exit__default['default'](0); | ||
}, timeout * 1000); | ||
exit(0); | ||
}, timeout * 1e3); | ||
exitTimeout.unref(); | ||
} else { | ||
exit__default['default'](0); | ||
exit(0); | ||
} | ||
} | ||
// An immediate export throws an error when mocking with jest | ||
// TypeError: Cannot set property createLock of #<Object> which has only a getter | ||
function createLock (...args) { | ||
return utils.lock(...args) | ||
function createLock(...args) { | ||
return utils.lock(...args); | ||
} | ||
@@ -230,14 +189,14 @@ | ||
spa: { | ||
alias: 's', | ||
type: 'boolean', | ||
description: 'Launch in SPA mode' | ||
alias: "s", | ||
type: "boolean", | ||
description: "Launch in SPA mode" | ||
}, | ||
universal: { | ||
alias: 'u', | ||
type: 'boolean', | ||
description: 'Launch in Universal mode (default)' | ||
alias: "u", | ||
type: "boolean", | ||
description: "Launch in Universal mode (default)" | ||
}, | ||
'config-file': { | ||
alias: 'c', | ||
type: 'string', | ||
"config-file": { | ||
alias: "c", | ||
type: "string", | ||
default: config.defaultNuxtConfigFile, | ||
@@ -247,7 +206,7 @@ description: `Path to Nuxt config file (default: \`${config.defaultNuxtConfigFile}\`)` | ||
modern: { | ||
alias: 'm', | ||
type: 'string', | ||
description: 'Build/Start app for modern browsers, e.g. server, client and false', | ||
prepare (cmd, options, argv) { | ||
if (argv.modern !== undefined) { | ||
alias: "m", | ||
type: "string", | ||
description: "Build/Start app for modern browsers, e.g. server, client and false", | ||
prepare(cmd, options, argv) { | ||
if (argv.modern !== void 0) { | ||
options.modern = normalizeArg(argv.modern); | ||
@@ -258,6 +217,6 @@ } | ||
target: { | ||
alias: 't', | ||
type: 'string', | ||
description: 'Build/start app for a different target, e.g. server, serverless and static', | ||
prepare (cmd, options, argv) { | ||
alias: "t", | ||
type: "string", | ||
description: "Build/start app for a different target, e.g. server, serverless and static", | ||
prepare(cmd, options, argv) { | ||
if (argv.target) { | ||
@@ -268,28 +227,28 @@ options.target = argv.target; | ||
}, | ||
'force-exit': { | ||
type: 'boolean', | ||
default (cmd) { | ||
return ['build', 'generate', 'export'].includes(cmd.name) | ||
"force-exit": { | ||
type: "boolean", | ||
default(cmd) { | ||
return ["build", "generate", "export"].includes(cmd.name); | ||
}, | ||
description: 'Whether Nuxt should force exit after the command has finished' | ||
description: "Whether Nuxt should force exit after the command has finished" | ||
}, | ||
version: { | ||
alias: 'v', | ||
type: 'boolean', | ||
description: 'Display the Nuxt version' | ||
alias: "v", | ||
type: "boolean", | ||
description: "Display the Nuxt version" | ||
}, | ||
help: { | ||
alias: 'h', | ||
type: 'boolean', | ||
description: 'Display this message' | ||
alias: "h", | ||
type: "boolean", | ||
description: "Display this message" | ||
}, | ||
processenv: { | ||
type: 'boolean', | ||
type: "boolean", | ||
default: true, | ||
description: 'Disable reading from `process.env` and updating it with dotenv' | ||
description: "Disable reading from `process.env` and updating it with dotenv" | ||
}, | ||
dotenv: { | ||
type: 'string', | ||
default: '.env', | ||
description: 'Specify path to dotenv file (default: `.env`). Use `false` to disable' | ||
type: "string", | ||
default: ".env", | ||
description: "Specify path to dotenv file (default: `.env`). Use `false` to disable" | ||
} | ||
@@ -300,6 +259,6 @@ }; | ||
port: { | ||
alias: 'p', | ||
type: 'string', | ||
description: 'Port number on which to start the application', | ||
prepare (cmd, options, argv) { | ||
alias: "p", | ||
type: "string", | ||
description: "Port number on which to start the application", | ||
prepare(cmd, options, argv) { | ||
if (argv.port) { | ||
@@ -311,15 +270,15 @@ options.server.port = +argv.port; | ||
hostname: { | ||
alias: 'H', | ||
type: 'string', | ||
description: 'Hostname on which to start the application', | ||
prepare (cmd, options, argv) { | ||
if (argv.hostname === '') { | ||
consola__default['default'].fatal('Provided hostname argument has no value'); | ||
alias: "H", | ||
type: "string", | ||
description: "Hostname on which to start the application", | ||
prepare(cmd, options, argv) { | ||
if (argv.hostname === "") { | ||
consola.fatal("Provided hostname argument has no value"); | ||
} | ||
} | ||
}, | ||
'unix-socket': { | ||
alias: 'n', | ||
type: 'string', | ||
description: 'Path to a UNIX socket' | ||
"unix-socket": { | ||
alias: "n", | ||
type: "string", | ||
description: "Path to a UNIX socket" | ||
} | ||
@@ -330,5 +289,5 @@ }; | ||
lock: { | ||
type: 'boolean', | ||
type: "boolean", | ||
default: true, | ||
description: 'Do not set a lock on the project when building' | ||
description: "Do not set a lock on the project when building" | ||
} | ||
@@ -340,14 +299,12 @@ }; | ||
common: common, | ||
server: server, | ||
locking: locking | ||
locking: locking, | ||
server: server | ||
}); | ||
var name = "@nuxt/cli"; | ||
var version = "2.15.8"; | ||
var version = "2.16.0"; | ||
async function loadNuxtConfig (argv, configContext) { | ||
const rootDir = path__default['default'].resolve(argv._[0] || '.'); | ||
const configFile = argv['config-file']; | ||
// Load config | ||
async function loadNuxtConfig(argv, configContext) { | ||
const rootDir = path.resolve(argv._[0] || "."); | ||
const configFile = argv["config-file"]; | ||
const options = await config.loadNuxtConfig({ | ||
@@ -358,7 +315,6 @@ rootDir, | ||
envConfig: { | ||
dotenv: argv.dotenv === 'false' ? false : argv.dotenv, | ||
dotenv: argv.dotenv === "false" ? false : argv.dotenv, | ||
env: argv.processenv ? process.env : {} | ||
} | ||
}); | ||
if (argv.spa === true) { | ||
@@ -369,18 +325,14 @@ options.ssr = false; | ||
} | ||
// Server options | ||
options.server = defu__default['default']({ | ||
options.server = defu.defu({ | ||
port: argv.port || null, | ||
host: argv.hostname || null, | ||
socket: argv['unix-socket'] || null | ||
socket: argv["unix-socket"] || null | ||
}, options.server || {}, config.getDefaultNuxtConfig().server); | ||
return options | ||
return options; | ||
} | ||
class NuxtCommand extends Hookable__default['default'] { | ||
constructor (cmd = { name: '', usage: '', description: '' }, argv = process.argv.slice(2), hooks = {}) { | ||
super(consola__default['default']); | ||
class NuxtCommand extends Hookable { | ||
constructor(cmd = { name: "", usage: "", description: "" }, argv = process.argv.slice(2), hooks = {}) { | ||
super(consola); | ||
this.addHooks(hooks); | ||
if (!cmd.options) { | ||
@@ -390,41 +342,32 @@ cmd.options = {}; | ||
this.cmd = cmd; | ||
this._argv = Array.from(argv); | ||
this._parsedArgv = null; // Lazy evaluate | ||
this._parsedArgv = null; | ||
} | ||
static run (cmd, argv, hooks) { | ||
return NuxtCommand.from(cmd, argv, hooks).run() | ||
static run(cmd, argv, hooks) { | ||
return NuxtCommand.from(cmd, argv, hooks).run(); | ||
} | ||
static from (cmd, argv, hooks) { | ||
static from(cmd, argv, hooks) { | ||
if (cmd instanceof NuxtCommand) { | ||
return cmd | ||
return cmd; | ||
} | ||
return new NuxtCommand(cmd, argv, hooks) | ||
return new NuxtCommand(cmd, argv, hooks); | ||
} | ||
async run () { | ||
await this.callHook('run:before', { | ||
async run() { | ||
await this.callHook("run:before", { | ||
argv: this._argv, | ||
cmd: this.cmd, | ||
rootDir: path__default['default'].resolve(this.argv._[0] || '.') | ||
rootDir: path.resolve(this.argv._[0] || ".") | ||
}); | ||
if (this.argv.help) { | ||
this.showHelp(); | ||
return | ||
return; | ||
} | ||
if (this.argv.version) { | ||
this.showVersion(); | ||
return | ||
return; | ||
} | ||
if (typeof this.cmd.run !== 'function') { | ||
throw new TypeError('Invalid command! Commands should at least implement run() function.') | ||
if (typeof this.cmd.run !== "function") { | ||
throw new TypeError("Invalid command! Commands should at least implement run() function."); | ||
} | ||
let cmdError; | ||
try { | ||
@@ -435,43 +378,35 @@ await this.cmd.run(this); | ||
} | ||
if (this.argv.lock) { | ||
await this.releaseLock(); | ||
} | ||
if (this.argv['force-exit']) { | ||
const forceExitByUser = this.isUserSuppliedArg('force-exit'); | ||
if (this.argv["force-exit"]) { | ||
const forceExitByUser = this.isUserSuppliedArg("force-exit"); | ||
if (cmdError) { | ||
consola__default['default'].fatal(cmdError); | ||
consola.fatal(cmdError); | ||
} | ||
forceExit(this.cmd.name, forceExitByUser ? false : forceExitTimeout); | ||
if (forceExitByUser) { | ||
return | ||
return; | ||
} | ||
} | ||
if (cmdError) { | ||
throw cmdError | ||
throw cmdError; | ||
} | ||
} | ||
showVersion () { | ||
process.stdout.write(`${name} v${version}\n`); | ||
showVersion() { | ||
process.stdout.write(`${name} v${version} | ||
`); | ||
} | ||
showHelp () { | ||
showHelp() { | ||
process.stdout.write(this._getHelp()); | ||
} | ||
get argv () { | ||
get argv() { | ||
if (!this._parsedArgv) { | ||
const minimistOptions = this._getMinimistOptions(); | ||
this._parsedArgv = minimist__default['default'](this._argv, minimistOptions); | ||
this._parsedArgv = minimist(this._argv, minimistOptions); | ||
} | ||
return this._parsedArgv | ||
return this._parsedArgv; | ||
} | ||
async getNuxtConfig (extraOptions = {}) { | ||
// Flag to indicate nuxt is running with CLI (not programmatic) | ||
async getNuxtConfig(extraOptions = {}) { | ||
extraOptions._cli = true; | ||
const context = { | ||
@@ -481,41 +416,30 @@ command: this.cmd.name, | ||
}; | ||
const config = await loadNuxtConfig(this.argv, context); | ||
const options = Object.assign(config, extraOptions); | ||
for (const name of Object.keys(this.cmd.options)) { | ||
this.cmd.options[name].prepare && this.cmd.options[name].prepare(this, options, this.argv); | ||
for (const name2 of Object.keys(this.cmd.options)) { | ||
this.cmd.options[name2].prepare && this.cmd.options[name2].prepare(this, options, this.argv); | ||
} | ||
await this.callHook('config', options); | ||
return options | ||
await this.callHook("config", options); | ||
return options; | ||
} | ||
async getNuxt (options) { | ||
async getNuxt(options) { | ||
const { Nuxt } = await core(); | ||
const nuxt = new Nuxt(options); | ||
await nuxt.ready(); | ||
return nuxt | ||
return nuxt; | ||
} | ||
async getBuilder (nuxt) { | ||
async getBuilder(nuxt) { | ||
const { Builder } = await builder(); | ||
const { BundleBuilder } = await webpack(); | ||
return new Builder(nuxt, BundleBuilder) | ||
return new Builder(nuxt, BundleBuilder); | ||
} | ||
async getGenerator (nuxt) { | ||
async getGenerator(nuxt) { | ||
const { Generator } = await generator(); | ||
const builder = await this.getBuilder(nuxt); | ||
return new Generator(nuxt, builder) | ||
return new Generator(nuxt, builder); | ||
} | ||
async setLock (lockRelease) { | ||
async setLock(lockRelease) { | ||
if (lockRelease) { | ||
if (this._lockRelease) { | ||
consola__default['default'].warn(`A previous unreleased lock was found, this shouldn't happen and is probably an error in 'nuxt ${this.cmd.name}' command. The lock will be removed but be aware of potential strange results`); | ||
consola.warn(`A previous unreleased lock was found, this shouldn't happen and is probably an error in 'nuxt ${this.cmd.name}' command. The lock will be removed but be aware of potential strange results`); | ||
await this.releaseLock(); | ||
@@ -528,19 +452,15 @@ this._lockRelease = lockRelease; | ||
} | ||
async releaseLock () { | ||
async releaseLock() { | ||
if (this._lockRelease) { | ||
await this._lockRelease(); | ||
this._lockRelease = undefined; | ||
this._lockRelease = void 0; | ||
} | ||
} | ||
isUserSuppliedArg (option) { | ||
return this._argv.includes(`--${option}`) || this._argv.includes(`--no-${option}`) | ||
isUserSuppliedArg(option) { | ||
return this._argv.includes(`--${option}`) || this._argv.includes(`--no-${option}`); | ||
} | ||
_getDefaultOptionValue (option) { | ||
return typeof option.default === 'function' ? option.default(this.cmd) : option.default | ||
_getDefaultOptionValue(option) { | ||
return typeof option.default === "function" ? option.default(this.cmd) : option.default; | ||
} | ||
_getMinimistOptions () { | ||
_getMinimistOptions() { | ||
const minimistOptions = { | ||
@@ -552,60 +472,55 @@ alias: {}, | ||
}; | ||
for (const name of Object.keys(this.cmd.options)) { | ||
const option = this.cmd.options[name]; | ||
for (const name2 of Object.keys(this.cmd.options)) { | ||
const option = this.cmd.options[name2]; | ||
if (option.alias) { | ||
minimistOptions.alias[option.alias] = name; | ||
minimistOptions.alias[option.alias] = name2; | ||
} | ||
if (option.type) { | ||
minimistOptions[option.type].push(option.alias || name); | ||
minimistOptions[option.type].push(option.alias || name2); | ||
} | ||
if (option.default) { | ||
minimistOptions.default[option.alias || name] = this._getDefaultOptionValue(option); | ||
minimistOptions.default[option.alias || name2] = this._getDefaultOptionValue(option); | ||
} | ||
} | ||
return minimistOptions | ||
return minimistOptions; | ||
} | ||
_getHelp () { | ||
_getHelp() { | ||
const options = []; | ||
let maxOptionLength = 0; | ||
for (const name in this.cmd.options) { | ||
const option = this.cmd.options[name]; | ||
let optionHelp = '--'; | ||
optionHelp += option.type === 'boolean' && this._getDefaultOptionValue(option) ? 'no-' : ''; | ||
optionHelp += name; | ||
for (const name2 in this.cmd.options) { | ||
const option = this.cmd.options[name2]; | ||
let optionHelp = "--"; | ||
optionHelp += option.type === "boolean" && this._getDefaultOptionValue(option) ? "no-" : ""; | ||
optionHelp += name2; | ||
if (option.alias) { | ||
optionHelp += `, -${option.alias}`; | ||
} | ||
maxOptionLength = Math.max(maxOptionLength, optionHelp.length); | ||
options.push([optionHelp, option.description]); | ||
} | ||
const _opts = options.map(([option, description]) => { | ||
const _opts = options.map(([option, description2]) => { | ||
const i = indent(maxOptionLength + optionSpaces - option.length); | ||
return foldLines( | ||
option + i + description, | ||
option + i + description2, | ||
startSpaces + maxOptionLength + optionSpaces * 2, | ||
startSpaces + optionSpaces | ||
) | ||
}).join('\n'); | ||
); | ||
}).join("\n"); | ||
const usage = foldLines(`Usage: nuxt ${this.cmd.usage} [options]`, startSpaces); | ||
const description = foldLines(this.cmd.description, startSpaces); | ||
const opts = foldLines('Options:', startSpaces) + '\n\n' + _opts; | ||
const opts = foldLines("Options:", startSpaces) + "\n\n" + _opts; | ||
let helpText = colorize(`${usage} | ||
let helpText = colorize(`${usage}\n\n`); | ||
`); | ||
if (this.cmd.description) { | ||
helpText += colorize(`${description}\n\n`); | ||
helpText += colorize(`${description} | ||
`); | ||
} | ||
if (options.length) { | ||
helpText += colorize(`${opts}\n\n`); | ||
helpText += colorize(`${opts} | ||
`); | ||
} | ||
return helpText | ||
return helpText; | ||
} | ||
@@ -615,30 +530,26 @@ } | ||
const dependencies = { | ||
webpack: '^4.46.0', | ||
'css-loader': '>=4.2.0', | ||
'sass-loader': '^10.1.1' | ||
webpack: "^4.46.0", | ||
"css-loader": ">=4.2.0", | ||
"sass-loader": "^10.1.1" | ||
}; | ||
const nodeVersion = '>=12.0.0'; | ||
function getInstalledVersion (name) { | ||
const nodeVersion = ">=12.0.0"; | ||
function getInstalledVersion(name) { | ||
try { | ||
return utils.getPKG(name).version | ||
} catch { } | ||
return utils.getPKG(name).version; | ||
} catch { | ||
} | ||
} | ||
function checkDependencies () { | ||
function checkDependencies() { | ||
for (const name in dependencies) { | ||
const installedVersion = getInstalledVersion(name); | ||
if (!installedVersion) { | ||
continue // Ignore to avoid false-positive warnings | ||
continue; | ||
} | ||
const expectedRange = dependencies[name]; | ||
if (!semver.satisfies(installedVersion, expectedRange)) { | ||
consola__default['default'].warn(`${name}@${installedVersion} is installed but ${expectedRange} is expected`); | ||
consola.warn(`${name}@${installedVersion} is installed but ${expectedRange} is expected`); | ||
} | ||
} | ||
// Check Node versions | ||
if (!semver.satisfies(process.version, nodeVersion)) { | ||
consola__default['default'].warn(`You are using an unsupported version of Node.js (${process.version}). It is recommended to use the latest LTS version (https://nodejs.org/en/about/releases)`); | ||
consola.warn(`You are using an unsupported version of Node.js (${process.version}). It is recommended to use the latest LTS version (https://nodejs.org/en/about/releases)`); | ||
} | ||
@@ -648,81 +559,52 @@ } | ||
let _setup = false; | ||
function setup ({ dev }) { | ||
// Apply default NODE_ENV if not provided | ||
function setup({ dev }) { | ||
if (!process.env.NODE_ENV) { | ||
process.env.NODE_ENV = dev ? 'development' : 'production'; | ||
process.env.NODE_ENV = dev ? "development" : "production"; | ||
} | ||
if (_setup) { | ||
return | ||
return; | ||
} | ||
_setup = true; | ||
checkDependencies(); | ||
// Global error handler | ||
/* istanbul ignore next */ | ||
process.on('unhandledRejection', (err) => { | ||
consola__default['default'].error(err); | ||
process.on("unhandledRejection", (err) => { | ||
consola.error(err); | ||
}); | ||
// Exit process on fatal errors | ||
/* istanbul ignore next */ | ||
consola__default['default'].addReporter({ | ||
log (logObj) { | ||
if (logObj.type === 'fatal') { | ||
consola.addReporter({ | ||
log(logObj) { | ||
if (logObj.type === "fatal") { | ||
const errorMessage = String(logObj.args[0]); | ||
process.stderr.write(fatalBox(errorMessage)); | ||
exit__default['default'](1); | ||
exit(1); | ||
} | ||
} | ||
}); | ||
// Wrap all console logs with consola for better DX | ||
consola__default['default'].wrapConsole(); | ||
consola.wrapConsole(); | ||
} | ||
function isNuxtDir (rootDir) { | ||
if (fs__default['default'].existsSync(path__default['default'].join(rootDir, 'nuxt.config.js')) || | ||
fs__default['default'].existsSync(path__default['default'].join(rootDir, 'pages')) || | ||
fs__default['default'].existsSync(path__default['default'].join(rootDir, 'nuxt.config.ts'))) { | ||
return true | ||
function isNuxtDir(rootDir) { | ||
if (fs.existsSync(path.join(rootDir, "nuxt.config.js")) || fs.existsSync(path.join(rootDir, "pages")) || fs.existsSync(path.join(rootDir, "nuxt.config.ts"))) { | ||
return true; | ||
} | ||
return false | ||
return false; | ||
} | ||
async function run (_argv, hooks = {}) { | ||
// Check for not installing both nuxt and nuxt-edge | ||
const dupPkg = 'cli-edge'; | ||
const dupPkgJSON = path.resolve(__dirname, '../..' /* dist/../.. */, dupPkg, 'package.json'); | ||
if (fs.existsSync(dupPkgJSON) && utils.requireModule(dupPkgJSON).name !== '@nuxt/' + dupPkg) { | ||
consola__default['default'].warn('Both `nuxt` and `nuxt-edge` dependencies are installed! Please choose one and remove the other one from dependencies.'); | ||
async function run(_argv, hooks = {}) { | ||
const dupPkg = "cli-edge"; | ||
const dupPkgJSON = path.resolve(__dirname, "../..", dupPkg, "package.json"); | ||
if (fs.existsSync(dupPkgJSON) && utils.requireModule(dupPkgJSON).name !== "@nuxt/" + dupPkg) { | ||
consola.warn("Both `nuxt` and `nuxt-edge` dependencies are installed! Please choose one and remove the other one from dependencies."); | ||
} | ||
// Read from process.argv | ||
const argv = _argv ? Array.from(_argv) : process.argv.slice(2); | ||
// Check for internal command | ||
let cmd = await getCommand(argv[0]); | ||
// Matching `nuxt` or `nuxt [dir]` or `nuxt -*` for `nuxt dev` shortcut | ||
if (!cmd && (!argv[0] || argv[0][0] === '-' || isNuxtDir(argv[0]))) { | ||
argv.unshift('dev'); | ||
cmd = await getCommand('dev'); | ||
if (!cmd && (!argv[0] || argv[0][0] === "-" || isNuxtDir(argv[0]))) { | ||
argv.unshift("dev"); | ||
cmd = await getCommand("dev"); | ||
} | ||
// Check for dev | ||
const dev = argv[0] === 'dev'; | ||
// Setup env | ||
const dev = argv[0] === "dev"; | ||
setup({ dev }); | ||
// Try internal command | ||
if (cmd) { | ||
return NuxtCommand.run(cmd, argv.slice(1), hooks) | ||
return NuxtCommand.run(cmd, argv.slice(1), hooks); | ||
} | ||
// Try external command | ||
try { | ||
await execa__default['default'](`nuxt-${argv[0]}`, argv.slice(1), { | ||
await execa(`nuxt-${argv[0]}`, argv.slice(1), { | ||
stdout: process.stdout, | ||
@@ -734,16 +616,16 @@ stderr: process.stderr, | ||
if (error.exitCode === 2) { | ||
throw String(`Command not found: nuxt-${argv[0]}`) | ||
throw String(`Command not found: nuxt-${argv[0]}`); | ||
} | ||
throw String(`Failed to run command \`nuxt-${argv[0]}\`:\n${error}`) | ||
throw String(`Failed to run command \`nuxt-${argv[0]}\`: | ||
${error}`); | ||
} | ||
} | ||
async function getWebpackConfig (name = 'client', loadOptions = {}) { | ||
async function getWebpackConfig(name = "client", loadOptions = {}) { | ||
const { loadNuxt } = await core(); | ||
const { getBuilder } = await builder(); | ||
const nuxt = await loadNuxt(loadOptions); | ||
const builder$1 = await getBuilder(nuxt); | ||
const { bundleBuilder } = builder$1; | ||
return bundleBuilder.getWebpackConfig(name) | ||
return bundleBuilder.getWebpackConfig(name); | ||
} | ||
@@ -750,0 +632,0 @@ |
/*! | ||
* @nuxt/cli v2.15.8 (c) 2016-2021 | ||
* @nuxt/cli v2.16.0 (c) 2016-2023 | ||
* Released under the MIT License | ||
@@ -32,11 +32,7 @@ * Repository: https://github.com/nuxt/nuxt.js | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
const consola__default = /*#__PURE__*/_interopDefaultLegacy(consola); | ||
const serve = { | ||
...start['default'], | ||
run (...args) { | ||
consola__default['default'].warn('`nuxt serve` has been deprecated! Please use `nuxt start`.'); | ||
return start['default'].run.call(this, ...args) | ||
...start.default, | ||
run(...args) { | ||
consola.warn("`nuxt serve` has been deprecated! Please use `nuxt start`."); | ||
return start.default.run.call(this, ...args); | ||
} | ||
@@ -43,0 +39,0 @@ }; |
/*! | ||
* @nuxt/cli v2.15.8 (c) 2016-2021 | ||
* @nuxt/cli v2.16.0 (c) 2016-2023 | ||
* Released under the MIT License | ||
@@ -31,44 +31,33 @@ * Repository: https://github.com/nuxt/nuxt.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) { | ||
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')); | ||
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); | ||
} catch (err) { | ||
} | ||
const distStat = await fs.promises.stat(options.generate.dir).catch(() => { | ||
}); | ||
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.') | ||
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 })); | ||
const app = connect(); | ||
app.use(compression({ threshold: 0 })); | ||
app.use( | ||
options.router.base, | ||
serveStatic__default['default'](options.generate.dir, { | ||
extensions: ['html'] | ||
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'); | ||
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() | ||
const ext = path.extname(req.url) || ".html"; | ||
if (ext !== ".html") { | ||
return next(); | ||
} | ||
res.writeHeader(200, { | ||
'Content-Type': 'text/html' | ||
"Content-Type": "text/html" | ||
}); | ||
@@ -79,3 +68,2 @@ res.write(fallbackFile); | ||
} | ||
const { port, host, socket, https } = options.server; | ||
@@ -89,10 +77,8 @@ const { Listener } = await index.server(); | ||
app, | ||
dev: true, // try another port if taken | ||
dev: true, | ||
// try another port if taken | ||
baseURL: options.router.base | ||
}); | ||
await listener.listen(); | ||
const { Nuxt } = await index.core(); | ||
banner.showBanner({ | ||
@@ -105,10 +91,9 @@ constructor: Nuxt, | ||
}, false); | ||
consola__default['default'].info(`Serving static application from \`${distPath}\``); | ||
consola.info(`Serving static application from \`${distPath}\``); | ||
} | ||
const start = { | ||
name: 'start', | ||
description: 'Start the application in production mode (the application should be compiled with `nuxt build` first)', | ||
usage: 'start <dir>', | ||
name: "start", | ||
description: "Start the application in production mode (the application should be compiled with `nuxt build` first)", | ||
usage: "start <dir>", | ||
options: { | ||
@@ -118,12 +103,8 @@ ...index.common, | ||
}, | ||
async run (cmd) { | ||
async run(cmd) { | ||
const config = await cmd.getNuxtConfig({ dev: false, _start: true }); | ||
if (config.target === utils.TARGETS.static) { | ||
return serve(cmd) | ||
return serve(cmd); | ||
} | ||
const nuxt = await cmd.getNuxt(config); | ||
// Listen and show ready banner | ||
await nuxt.server.listen(); | ||
@@ -130,0 +111,0 @@ banner.showBanner(nuxt); |
/*! | ||
* @nuxt/cli v2.15.8 (c) 2016-2021 | ||
* @nuxt/cli v2.16.0 (c) 2016-2023 | ||
* Released under the MIT License | ||
@@ -28,40 +28,34 @@ * Repository: https://github.com/nuxt/nuxt.js | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
const util__default = /*#__PURE__*/_interopDefaultLegacy(util); | ||
const consola__default = /*#__PURE__*/_interopDefaultLegacy(consola); | ||
const webpack = { | ||
name: 'webpack', | ||
description: 'Inspect Nuxt webpack config', | ||
usage: 'webpack [query...]', | ||
name: "webpack", | ||
description: "Inspect Nuxt webpack config", | ||
usage: "webpack [query...]", | ||
options: { | ||
...index.common, | ||
name: { | ||
alias: 'n', | ||
type: 'string', | ||
default: 'client', | ||
description: 'Webpack bundle name: server, client, modern' | ||
alias: "n", | ||
type: "string", | ||
default: "client", | ||
description: "Webpack bundle name: server, client, modern" | ||
}, | ||
depth: { | ||
alias: 'd', | ||
type: 'string', | ||
alias: "d", | ||
type: "string", | ||
default: 2, | ||
description: 'Inspection depth' | ||
description: "Inspection depth" | ||
}, | ||
colors: { | ||
type: 'boolean', | ||
type: "boolean", | ||
default: process.stdout.isTTY, | ||
description: 'Output with ANSI colors' | ||
description: "Output with ANSI colors" | ||
}, | ||
dev: { | ||
type: 'boolean', | ||
type: "boolean", | ||
default: false, | ||
description: 'Inspect development mode webpack config' | ||
description: "Inspect development mode webpack config" | ||
} | ||
}, | ||
async run (cmd) { | ||
async run(cmd) { | ||
const { name } = cmd.argv; | ||
const queries = [...cmd.argv._]; | ||
const config = await cmd.getNuxtConfig({ dev: cmd.argv.dev, server: false }); | ||
@@ -72,13 +66,11 @@ const nuxt = await cmd.getNuxt(config); | ||
const webpackConfig = bundleBuilder.getWebpackConfig(name); | ||
let queryError; | ||
const match = queries.reduce((result, query) => { | ||
const m = advancedGet(result, query); | ||
if (m === undefined) { | ||
if (m === void 0) { | ||
queryError = query; | ||
return result | ||
return result; | ||
} | ||
return m | ||
return m; | ||
}, webpackConfig); | ||
const serialized = formatObj(match, { | ||
@@ -88,61 +80,42 @@ depth: parseInt(cmd.argv.depth), | ||
}); | ||
consola__default['default'].log(serialized + '\n'); | ||
if (serialized.includes('[Object]' )) { | ||
consola__default['default'].info('You can use `--depth` or add more queries to inspect `[Object]` and `[Array]` fields.'); | ||
consola.log(serialized + "\n"); | ||
if (serialized.includes("[Object]")) { | ||
consola.info("You can use `--depth` or add more queries to inspect `[Object]` and `[Array]` fields."); | ||
} | ||
if (queryError) { | ||
consola__default['default'].warn(`No match in webpack config for \`${queryError}\``); | ||
consola.warn(`No match in webpack config for \`${queryError}\``); | ||
} | ||
} | ||
}; | ||
function advancedGet (obj = {}, query = '') { | ||
function advancedGet(obj = {}, query = "") { | ||
let result = obj; | ||
if (!query || !result) { | ||
return result | ||
return result; | ||
} | ||
const [l, r] = query.split('='); | ||
const [l, r] = query.split("="); | ||
if (!Array.isArray(result)) { | ||
return typeof result === 'object' ? lodash.get(result, l) : result | ||
return typeof result === "object" ? lodash.get(result, l) : result; | ||
} | ||
result = result.filter((i) => { | ||
const v = lodash.get(i, l); | ||
if (!v) { | ||
return false | ||
return false; | ||
} | ||
if ( | ||
(v === r) || | ||
(typeof v.test === 'function' && v.test(r)) || | ||
(typeof v.match === 'function' && v.match(r)) || | ||
(r && r.match(v)) | ||
) { | ||
return true | ||
if (v === r || typeof v.test === "function" && v.test(r) || typeof v.match === "function" && v.match(r) || r && r.match(v)) { | ||
return true; | ||
} | ||
return false | ||
return false; | ||
}); | ||
if (result.length === 1) { | ||
return result[0] | ||
return result[0]; | ||
} | ||
return result.length ? result : undefined | ||
return result.length ? result : void 0; | ||
} | ||
function formatObj (obj, formatOptions) { | ||
if (!util__default['default'].formatWithOptions) { | ||
return util__default['default'].format(obj) | ||
function formatObj(obj, formatOptions) { | ||
if (!util.formatWithOptions) { | ||
return util.format(obj); | ||
} | ||
return util__default['default'].formatWithOptions(formatOptions, obj) | ||
return util.formatWithOptions(formatOptions, obj); | ||
} | ||
exports.default = webpack; |
/*! | ||
* @nuxt/cli v2.15.8 (c) 2016-2021 | ||
* @nuxt/cli v2.16.0 (c) 2016-2023 | ||
* Released under the MIT License | ||
@@ -9,4 +9,2 @@ * Repository: https://github.com/nuxt/nuxt.js | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
const index = require('./cli-index.js'); | ||
@@ -13,0 +11,0 @@ require('@nuxt/utils'); |
{ | ||
"name": "@nuxt/cli", | ||
"version": "2.15.8", | ||
"version": "2.16.0", | ||
"repository": "nuxt/nuxt.js", | ||
@@ -15,24 +15,24 @@ "license": "MIT", | ||
"dependencies": { | ||
"@nuxt/config": "2.15.8", | ||
"@nuxt/utils": "2.15.8", | ||
"boxen": "^5.0.1", | ||
"chalk": "^4.1.1", | ||
"@nuxt/config": "2.16.0", | ||
"@nuxt/utils": "2.16.0", | ||
"boxen": "^5.1.2", | ||
"chalk": "^4.1.2", | ||
"compression": "^1.7.4", | ||
"connect": "^3.7.0", | ||
"consola": "^2.15.3", | ||
"crc": "^3.8.0", | ||
"defu": "^4.0.1", | ||
"destr": "^1.1.0", | ||
"execa": "^5.0.0", | ||
"crc": "^4.3.2", | ||
"defu": "^6.1.2", | ||
"destr": "^1.2.2", | ||
"execa": "^5.1.1", | ||
"exit": "^0.1.2", | ||
"fs-extra": "^9.1.0", | ||
"globby": "^11.0.3", | ||
"fs-extra": "^10.1.0", | ||
"globby": "^11.0.4", | ||
"hable": "^3.0.0", | ||
"lodash": "^4.17.21", | ||
"minimist": "^1.2.5", | ||
"minimist": "^1.2.7", | ||
"opener": "1.5.2", | ||
"pretty-bytes": "^5.6.0", | ||
"semver": "^7.3.5", | ||
"serve-static": "^1.14.1", | ||
"std-env": "^2.3.0", | ||
"semver": "^7.3.8", | ||
"serve-static": "^1.15.0", | ||
"std-env": "^3.3.2", | ||
"upath": "^2.0.1", | ||
@@ -39,0 +39,0 @@ "wrap-ansi": "^7.0.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46757
13
1547
1
+ Added@nuxt/config@2.16.0(transitive)
+ Added@nuxt/utils@2.16.0(transitive)
+ Addedcrc@4.3.2(transitive)
+ Addeddestr@2.0.3(transitive)
+ Addeddotenv@16.4.5(transitive)
+ Addedfs-extra@10.1.0(transitive)
+ Addedrc9@2.1.2(transitive)
+ Addedserialize-javascript@6.0.2(transitive)
+ Addedstd-env@3.8.0(transitive)
+ Addedua-parser-js@1.0.39(transitive)
+ Addedufo@1.5.4(transitive)
- Removed@nuxt/config@2.15.8(transitive)
- Removed@nuxt/utils@2.15.8(transitive)
- Removedat-least-node@1.0.0(transitive)
- Removedbase64-js@1.5.1(transitive)
- Removedbuffer@5.7.1(transitive)
- Removedci-info@3.9.0(transitive)
- Removedcrc@3.8.0(transitive)
- Removeddefu@4.0.1(transitive)
- Removeddotenv@9.0.2(transitive)
- Removedflat@5.0.2(transitive)
- Removedfs-extra@9.1.0(transitive)
- Removedieee754@1.2.1(transitive)
- Removedrc9@1.2.4(transitive)
- Removedserialize-javascript@5.0.1(transitive)
- Removedstd-env@2.3.1(transitive)
- Removedua-parser-js@0.7.39(transitive)
- Removedufo@0.7.11(transitive)
Updated@nuxt/config@2.16.0
Updated@nuxt/utils@2.16.0
Updatedboxen@^5.1.2
Updatedchalk@^4.1.2
Updatedcrc@^4.3.2
Updateddefu@^6.1.2
Updateddestr@^1.2.2
Updatedexeca@^5.1.1
Updatedfs-extra@^10.1.0
Updatedglobby@^11.0.4
Updatedminimist@^1.2.7
Updatedsemver@^7.3.8
Updatedserve-static@^1.15.0
Updatedstd-env@^3.3.2