Comparing version 0.6.0 to 0.6.1
@@ -17,6 +17,6 @@ 'use strict'; | ||
const unctx = require('unctx'); | ||
const hash = require('hash-sum'); | ||
const consola = require('consola'); | ||
const upath = require('upath'); | ||
const globby = require('globby'); | ||
const hash = require('hash-sum'); | ||
const consola = require('consola'); | ||
@@ -45,5 +45,5 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; } | ||
const dotenv__default = /*#__PURE__*/_interopDefaultLegacy(dotenv); | ||
const globby__default = /*#__PURE__*/_interopDefaultLegacy(globby); | ||
const hash__default = /*#__PURE__*/_interopDefaultLegacy(hash); | ||
const consola__default = /*#__PURE__*/_interopDefaultLegacy(consola); | ||
const globby__default = /*#__PURE__*/_interopDefaultLegacy(globby); | ||
@@ -898,2 +898,84 @@ const _require = jiti__default(process.cwd()); | ||
function chainFn(base, fn) { | ||
if (typeof fn !== "function") { | ||
return base; | ||
} | ||
return function(...args) { | ||
if (typeof base !== "function") { | ||
return fn.apply(this, args); | ||
} | ||
let baseResult = base.apply(this, args); | ||
if (baseResult === void 0) { | ||
[baseResult] = args; | ||
} | ||
const fnResult = fn.call(this, baseResult, ...Array.prototype.slice.call(args, 1)); | ||
if (fnResult === void 0) { | ||
return baseResult; | ||
} | ||
return fnResult; | ||
}; | ||
} | ||
function addTemplate(tmpl) { | ||
const nuxt = useNuxt(); | ||
if (!tmpl) { | ||
throw new Error("Invalid tmpl: " + JSON.stringify(tmpl)); | ||
} | ||
const src = typeof tmpl === "string" ? tmpl : tmpl.src; | ||
const srcPath = path.parse(src); | ||
if (typeof src !== "string" || !fs__default.existsSync(src)) { | ||
throw new Error("tmpl src not found: " + src); | ||
} | ||
const fileName = typeof tmpl === "string" ? "" : tmpl.fileName || tmpl.filename; | ||
const dst = fileName || `${path.basename(srcPath.dir)}.${srcPath.name}.${hash__default(src)}${srcPath.ext}`; | ||
const tmplObj = { | ||
src, | ||
dst, | ||
options: typeof tmpl === "string" ? void 0 : tmpl.options | ||
}; | ||
nuxt.options.build.templates.push(tmplObj); | ||
return tmplObj; | ||
} | ||
function addPlugin(tmpl) { | ||
const nuxt = useNuxt(); | ||
const {dst} = addTemplate(tmpl); | ||
if (!tmpl.mode && typeof tmpl.ssr === "boolean") { | ||
tmpl.mode = tmpl.ssr ? "server" : "client"; | ||
} | ||
nuxt.options.plugins.unshift({ | ||
src: path__default.join(nuxt.options.buildDir, dst), | ||
mode: tmpl.mode | ||
}); | ||
} | ||
function addLayout(tmpl, name) { | ||
const nuxt = useNuxt(); | ||
const {dst, src} = addTemplate(tmpl); | ||
const layoutName = name || path__default.parse(src).name; | ||
const layout = nuxt.options.layouts[layoutName]; | ||
if (layout) { | ||
consola__default.warn(`Duplicate layout registration, "${layoutName}" has been registered as "${layout}"`); | ||
} | ||
nuxt.options.layouts[layoutName] = `./${dst}`; | ||
if (name === "error") { | ||
addErrorLayout(dst); | ||
} | ||
} | ||
function addErrorLayout(dst) { | ||
const nuxt = useNuxt(); | ||
const relativeBuildDir = path__default.relative(nuxt.options.rootDir, nuxt.options.buildDir); | ||
nuxt.options.ErrorPage = `~/${relativeBuildDir}/${dst}`; | ||
} | ||
function addServerMiddleware(middleware) { | ||
const nuxt = useNuxt(); | ||
nuxt.options.serverMiddleware.push(middleware); | ||
} | ||
function extendBuild(fn) { | ||
const nuxt = useNuxt(); | ||
nuxt.options.build.extend = chainFn(nuxt.options.build.extend, fn); | ||
} | ||
function extendRoutes(fn) { | ||
const nuxt = useNuxt(); | ||
nuxt.options.router.extendRoutes = chainFn(nuxt.options.router.extendRoutes, fn); | ||
} | ||
function resolvePath(path, opts = {}) { | ||
@@ -1022,84 +1104,2 @@ if (fs.existsSync(path)) { | ||
function chainFn(base, fn) { | ||
if (typeof fn !== "function") { | ||
return base; | ||
} | ||
return function(...args) { | ||
if (typeof base !== "function") { | ||
return fn.apply(this, args); | ||
} | ||
let baseResult = base.apply(this, args); | ||
if (baseResult === void 0) { | ||
[baseResult] = args; | ||
} | ||
const fnResult = fn.call(this, baseResult, ...Array.prototype.slice.call(args, 1)); | ||
if (fnResult === void 0) { | ||
return baseResult; | ||
} | ||
return fnResult; | ||
}; | ||
} | ||
function addTemplate(tmpl) { | ||
const nuxt = useNuxt(); | ||
if (!tmpl) { | ||
throw new Error("Invalid tmpl: " + JSON.stringify(tmpl)); | ||
} | ||
const src = typeof tmpl === "string" ? tmpl : tmpl.src; | ||
const srcPath = path.parse(src); | ||
if (typeof src !== "string" || !fs__default.existsSync(src)) { | ||
throw new Error("tmpl src not found: " + src); | ||
} | ||
const fileName = typeof tmpl === "string" ? "" : tmpl.fileName || tmpl.filename; | ||
const dst = fileName || `${path.basename(srcPath.dir)}.${srcPath.name}.${hash__default(src)}${srcPath.ext}`; | ||
const tmplObj = { | ||
src, | ||
dst, | ||
options: typeof tmpl === "string" ? void 0 : tmpl.options | ||
}; | ||
nuxt.options.build.templates.push(tmplObj); | ||
return tmplObj; | ||
} | ||
function addPlugin(tmpl) { | ||
const nuxt = useNuxt(); | ||
const {dst} = addTemplate(tmpl); | ||
if (!tmpl.mode && typeof tmpl.ssr === "boolean") { | ||
tmpl.mode = tmpl.ssr ? "server" : "client"; | ||
} | ||
nuxt.options.plugins.unshift({ | ||
src: path__default.join(nuxt.options.buildDir, dst), | ||
mode: tmpl.mode | ||
}); | ||
} | ||
function addLayout(tmpl, name) { | ||
const nuxt = useNuxt(); | ||
const {dst, src} = addTemplate(tmpl); | ||
const layoutName = name || path__default.parse(src).name; | ||
const layout = nuxt.options.layouts[layoutName]; | ||
if (layout) { | ||
consola__default.warn(`Duplicate layout registration, "${layoutName}" has been registered as "${layout}"`); | ||
} | ||
nuxt.options.layouts[layoutName] = `./${dst}`; | ||
if (name === "error") { | ||
addErrorLayout(dst); | ||
} | ||
} | ||
function addErrorLayout(dst) { | ||
const nuxt = useNuxt(); | ||
const relativeBuildDir = path__default.relative(nuxt.options.rootDir, nuxt.options.buildDir); | ||
nuxt.options.ErrorPage = `~/${relativeBuildDir}/${dst}`; | ||
} | ||
function addServerMiddleware(middleware) { | ||
const nuxt = useNuxt(); | ||
nuxt.options.serverMiddleware.push(middleware); | ||
} | ||
function extendBuild(fn) { | ||
const nuxt = useNuxt(); | ||
nuxt.options.build.extend = chainFn(nuxt.options.build.extend, fn); | ||
} | ||
function extendRoutes(fn) { | ||
const nuxt = useNuxt(); | ||
nuxt.options.router.extendRoutes = chainFn(nuxt.options.router.extendRoutes, fn); | ||
} | ||
class ModuleContainer { | ||
@@ -1106,0 +1106,0 @@ constructor(nuxt) { |
{ | ||
"name": "@nuxt/kit", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"repository": "nuxt/framework", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"devDependencies": { | ||
"unbuild": "^0.2.3" | ||
"unbuild": "^0.3.0" | ||
}, | ||
@@ -23,3 +23,3 @@ "dependencies": { | ||
"defu": "^5.0.0", | ||
"dotenv": "^9.0.2", | ||
"dotenv": "^10.0.0", | ||
"globby": "^11.0.3", | ||
@@ -36,3 +36,3 @@ "hash-sum": "^2.0.0", | ||
}, | ||
"gitHead": "2f2e818e325048a3f619f8eb11de2e9cdd3aea7c" | ||
"gitHead": "6bde9032736a81fa98326ec03730fefc3792e3b1" | ||
} |
@@ -407,5 +407,5 @@ { | ||
"versionBase": "", | ||
"version": "1621517976" | ||
"version": "1621855826" | ||
} | ||
} | ||
} |
@@ -2019,4 +2019,4 @@ | ||
- **Type**: `string` | ||
- **Default**: `"1621517976"` | ||
- **Default**: `"1621855826"` | ||
> A unique string to uniquely identify payload versions (defaults to the current timestamp). |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
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
388796
+ Addeddotenv@10.0.0(transitive)
- Removeddotenv@9.0.2(transitive)
Updateddotenv@^10.0.0