🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

@nuxt/generator

Package Overview
Dependencies
Maintainers
3
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuxt/generator - npm Package Compare versions

Comparing version
2.14.1
to
2.14.2
+56
-50
dist/generator.js
/*!
* @nuxt/generator v2.14.1 (c) 2016-2020
* @nuxt/generator v2.14.2 (c) 2016-2020

@@ -12,12 +12,18 @@ * - All the amazing contributors

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
const path = _interopDefault(require('path'));
const chalk = _interopDefault(require('chalk'));
const consola = _interopDefault(require('consola'));
const fsExtra = _interopDefault(require('fs-extra'));
const htmlMinifier = _interopDefault(require('html-minifier'));
const path = require('path');
const chalk = require('chalk');
const consola = require('consola');
const fsExtra = require('fs-extra');
const htmlMinifier = require('html-minifier');
const nodeHtmlParser = require('node-html-parser');
const utils = require('@nuxt/utils');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
const path__default = /*#__PURE__*/_interopDefaultLegacy(path);
const chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
const consola__default = /*#__PURE__*/_interopDefaultLegacy(consola);
const fsExtra__default = /*#__PURE__*/_interopDefaultLegacy(fsExtra);
const htmlMinifier__default = /*#__PURE__*/_interopDefaultLegacy(htmlMinifier);
function _typeof(obj) {

@@ -93,6 +99,6 @@ "@babel/helpers - typeof";

this.isFullStatic = utils.isFullStatic(this.options);
this.staticRoutes = path.resolve(this.options.srcDir, this.options.dir.static);
this.srcBuiltPath = path.resolve(this.options.buildDir, 'dist', 'client');
this.staticRoutes = path__default['default'].resolve(this.options.srcDir, this.options.dir.static);
this.srcBuiltPath = path__default['default'].resolve(this.options.buildDir, 'dist', 'client');
this.distPath = this.options.generate.dir;
this.distNuxtPath = path.join(
this.distNuxtPath = path__default['default'].join(
this.distPath,

@@ -104,3 +110,3 @@ utils.isUrl(this.options.build.publicPath) ? '' : this.options.build.publicPath

const { staticAssets } = this.options.generate;
this.staticAssetsDir = path.resolve(this.distNuxtPath, staticAssets.dir, staticAssets.version);
this.staticAssetsDir = path__default['default'].resolve(this.distNuxtPath, staticAssets.dir, staticAssets.version);
this.staticAssetsBase = this.options.generate.staticAssets.versionBase;

@@ -117,9 +123,9 @@ }

async generate ({ build = true, init = true } = {}) {
consola.debug('Initializing generator...');
consola__default['default'].debug('Initializing generator...');
await this.initiate({ build, init });
consola.debug('Preparing routes for generate...');
consola__default['default'].debug('Preparing routes for generate...');
const routes = await this.initRoutes();
consola.info('Generating pages' + (this.isFullStatic ? ' with full static mode' : ''));
consola__default['default'].info('Generating pages' + (this.isFullStatic ? ' with full static mode' : ''));
const errors = await this.generateRoutes(routes);

@@ -151,3 +157,3 @@

} else {
const hasBuilt = await fsExtra.exists(path.resolve(this.options.buildDir, 'dist', 'server', 'client.manifest.json'));
const hasBuilt = await fsExtra__default['default'].exists(path__default['default'].resolve(this.options.buildDir, 'dist', 'server', 'client.manifest.json'));
if (!hasBuilt) {

@@ -176,3 +182,3 @@ throw new Error(

} catch (e) {
consola.error('Could not resolve routes');
consola__default['default'].error('Could not resolve routes');
throw e // eslint-disable-line no-unreachable

@@ -209,3 +215,3 @@ }

try {
return require(path.join(this.options.buildDir, 'nuxt/config.json'))
return require(path__default['default'].join(this.options.buildDir, 'nuxt/config.json'))
} catch (err) {

@@ -217,3 +223,3 @@ return null

getAppRoutes () {
return require(path.join(this.options.buildDir, 'routes.json'))
return require(path__default['default'].join(this.options.buildDir, 'routes.json'))
}

@@ -260,8 +266,8 @@

let line = chalk[color](` ${route}\n\n`);
let line = chalk__default['default'][color](` ${route}\n\n`);
if (isHandled) {
line += chalk.grey(JSON.stringify(error, undefined, 2) + '\n');
line += chalk__default['default'].grey(JSON.stringify(error, undefined, 2) + '\n');
} else {
line += chalk.grey(error.stack || error.message || `${error}`);
line += chalk__default['default'].grey(error.stack || error.message || `${error}`);
}

@@ -282,7 +288,7 @@

const fallbackPath = path.join(this.distPath, fallback);
const fallbackPath = path__default['default'].join(this.distPath, fallback);
// Prevent conflicts
if (await fsExtra.exists(fallbackPath)) {
consola.warn(`SPA fallback was configured, but the configured path (${fallbackPath}) already exists.`);
if (await fsExtra__default['default'].exists(fallbackPath)) {
consola__default['default'].warn(`SPA fallback was configured, but the configured path (${fallbackPath}) already exists.`);
return

@@ -300,7 +306,7 @@ }

} catch (error) {
consola.warn('HTML minification failed for SPA fallback');
consola__default['default'].warn('HTML minification failed for SPA fallback');
}
await fsExtra.writeFile(fallbackPath, html, 'utf8');
consola.success('Client-side fallback created: `' + fallback + '`');
await fsExtra__default['default'].writeFile(fallbackPath, html, 'utf8');
consola__default['default'].success('Client-side fallback created: `' + fallback + '`');
}

@@ -310,5 +316,5 @@

// Clean destination folder
await fsExtra.emptyDir(this.distPath);
await fsExtra__default['default'].emptyDir(this.distPath);
consola.info(`Generating output directory: ${path.basename(this.distPath)}/`);
consola__default['default'].info(`Generating output directory: ${path__default['default'].basename(this.distPath)}/`);
await this.nuxt.callHook('generate:distRemoved', this);

@@ -318,10 +324,10 @@ await this.nuxt.callHook('export:distRemoved', this);

// Copy static and built files
if (await fsExtra.exists(this.staticRoutes)) {
await fsExtra.copy(this.staticRoutes, this.distPath);
if (await fsExtra__default['default'].exists(this.staticRoutes)) {
await fsExtra__default['default'].copy(this.staticRoutes, this.distPath);
}
// Copy .nuxt/dist/client/ to dist/_nuxt/
await fsExtra.copy(this.srcBuiltPath, this.distNuxtPath);
await fsExtra__default['default'].copy(this.srcBuiltPath, this.distNuxtPath);
if (this.payloadDir) {
await fsExtra.ensureDir(this.payloadDir);
await fsExtra__default['default'].ensureDir(this.payloadDir);
}

@@ -331,4 +337,4 @@

// https://help.github.com/articles/files-that-start-with-an-underscore-are-missing/
const nojekyllPath = path.resolve(this.distPath, '.nojekyll');
fsExtra.writeFile(nojekyllPath, '');
const nojekyllPath = path__default['default'].resolve(this.distPath, '.nojekyll');
fsExtra__default['default'].writeFile(nojekyllPath, '');

@@ -394,3 +400,3 @@ await this.nuxt.callHook('generate:distCopied', this);

if (route.startsWith('/') && !route.startsWith('//') && !path.extname(route) && this.shouldGenerateRoute(route) && !this.generatedRoutes.has(route)) {
if (route.startsWith('/') && !route.startsWith('//') && !path__default['default'].extname(route) && this.shouldGenerateRoute(route) && !this.generatedRoutes.has(route)) {
this.generatedRoutes.add(route);

@@ -405,5 +411,5 @@ this.routes.push({ route });

for (const asset of renderContext.staticAssets) {
const assetPath = path.join(this.staticAssetsDir, asset.path);
await fsExtra.ensureDir(path.dirname(assetPath));
await fsExtra.writeFile(assetPath, asset.src, 'utf-8');
const assetPath = path__default['default'].join(this.staticAssetsDir, asset.path);
await fsExtra__default['default'].ensureDir(path__default['default'].dirname(assetPath));
await fsExtra__default['default'].writeFile(assetPath, asset.src, 'utf-8');
}

@@ -421,3 +427,3 @@ }

await this.nuxt.callHook('export:routeFailed', { route, errors: pageErrors });
consola.error(this._formatErrors(pageErrors));
consola__default['default'].error(this._formatErrors(pageErrors));

@@ -439,7 +445,7 @@ return false

if (this.options.generate.subFolders) {
fileName = path.join(route, path.sep, 'index.html'); // /about -> /about/index.html
fileName = path__default['default'].join(route, path__default['default'].sep, 'index.html'); // /about -> /about/index.html
fileName = fileName === '/404/index.html' ? '/404.html' : fileName; // /404 -> /404.html
} else {
const normalizedRoute = route.replace(/\/$/, '');
fileName = route.length > 1 ? path.join(path.sep, normalizedRoute + '.html') : path.join(path.sep, 'index.html');
fileName = route.length > 1 ? path__default['default'].join(path__default['default'].sep, normalizedRoute + '.html') : path__default['default'].join(path__default['default'].sep, 'index.html');
}

@@ -461,7 +467,7 @@

}
page.path = path.join(this.distPath, page.path);
page.path = path__default['default'].join(this.distPath, page.path);
// Make sure the sub folders are created
await fsExtra.mkdirp(path.dirname(page.path));
await fsExtra.writeFile(page.path, page.html, 'utf8');
await fsExtra__default['default'].mkdirp(path__default['default'].dirname(page.path));
await fsExtra__default['default'].writeFile(page.path, page.html, 'utf8');

@@ -472,6 +478,6 @@ await this.nuxt.callHook('generate:routeCreated', { route, path: page.path, errors: pageErrors });

if (pageErrors.length) {
consola.error(`Error generating route "${route}": ${pageErrors.map(e => e.error.message).join(', ')}`);
consola__default['default'].error(`Error generating route "${route}": ${pageErrors.map(e => e.error.message).join(', ')}`);
errors.push(...pageErrors);
} else {
consola.success(`Generated route "${route}"`);
consola__default['default'].success(`Generated route "${route}"`);
}

@@ -489,3 +495,3 @@

minificationOptions = this.options.generate.minify;
consola.warn('generate.minify has been deprecated and will be removed in the next major version.' +
consola__default['default'].warn('generate.minify has been deprecated and will be removed in the next major version.' +
' Use build.html.minify instead!');

@@ -498,3 +504,3 @@ }

return htmlMinifier.minify(html, minificationOptions)
return htmlMinifier__default['default'].minify(html, minificationOptions)
}

@@ -501,0 +507,0 @@ }

{
"name": "@nuxt/generator",
"version": "2.14.1",
"version": "2.14.2",
"repository": "nuxt/nuxt.js",

@@ -11,5 +11,5 @@ "license": "MIT",

"dependencies": {
"@nuxt/utils": "2.14.1",
"@nuxt/utils": "2.14.2",
"chalk": "^3.0.0",
"consola": "^2.14.0",
"consola": "^2.15.0",
"fs-extra": "^8.1.0",

@@ -16,0 +16,0 @@ "html-minifier": "^4.0.0",