@blitzjs/config
Advanced tools
Comparing version 0.34.3 to 0.34.4-danger.f06f4b853.6
@@ -5,2 +5,3 @@ 'use strict'; | ||
var esbuild = require('esbuild'); | ||
var fsExtra = require('fs-extra'); | ||
@@ -36,5 +37,54 @@ var path = require('path'); | ||
function getProjectRoot() { | ||
return path__default['default'].dirname(path__default['default'].resolve(process.cwd(), "blitz.config.js")) || pkgDir__default['default'].sync() || process.cwd(); | ||
return path__default['default'].dirname(getConfigSrcPath()); | ||
} | ||
function getConfigSrcPath() { | ||
var tsPath = path__default['default'].resolve(path__default['default'].join(process.cwd(), "blitz.config.ts")); | ||
if (fsExtra.existsSync(tsPath)) { | ||
return tsPath; | ||
} else { | ||
var jsPath = path__default['default'].resolve(path__default['default'].join(process.cwd(), "blitz.config.js")); | ||
return jsPath; | ||
} | ||
} | ||
function getConfigBuildPath() { | ||
return path__default['default'].join(getProjectRoot(), ".blitz", "blitz.config.js"); | ||
} | ||
async function buildConfig(_temp) { | ||
var _pkg$dependencies, _pkg$devDependencies; | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
watch = _ref.watch; | ||
debug("Starting buildConfig..."); | ||
var pkg = fsExtra.readJSONSync(path__default['default'].join(pkgDir__default['default'].sync(), "package.json")); | ||
debug("src", getConfigSrcPath()); | ||
debug("build", getConfigBuildPath()); | ||
var esbuildOptions = { | ||
entryPoints: [getConfigSrcPath()], | ||
outfile: getConfigBuildPath(), | ||
format: "cjs", | ||
bundle: true, | ||
platform: "node", | ||
external: ["blitz", "next"].concat(Object.keys(require("blitz/package").dependencies), Object.keys((_pkg$dependencies = pkg == null ? void 0 : pkg.dependencies) != null ? _pkg$dependencies : {}), Object.keys((_pkg$devDependencies = pkg == null ? void 0 : pkg.devDependencies) != null ? _pkg$devDependencies : {})) | ||
}; | ||
if (watch) { | ||
esbuildOptions.watch = { | ||
onRebuild: function onRebuild(error) { | ||
if (error) { | ||
console.error("Failed to re-build blitz config"); | ||
} else { | ||
console.log("\n> Blitz config changed - restart for changes to take effect\n"); | ||
} | ||
} | ||
}; | ||
} | ||
debug("Building config..."); | ||
debug("Src: ", getConfigSrcPath()); | ||
debug("Build: ", getConfigBuildPath()); | ||
await esbuild.build(esbuildOptions); | ||
} | ||
/** | ||
@@ -68,3 +118,11 @@ * @param {boolean | undefined} reload - reimport config files to reset global cache | ||
var nextConfigPath = path__default['default'].join(projectRoot, "next.config.js"); | ||
var blitzConfigPath = path__default['default'].join(projectRoot, "blitz.config.js"); | ||
var blitzConfigPath; | ||
if (fsExtra.existsSync(path__default['default'].join(projectRoot, ".blitz"))) { | ||
blitzConfigPath = path__default['default'].join(projectRoot, ".blitz", "blitz.config.js"); | ||
} else { | ||
// projectRoot is inside .blitz/build/ | ||
blitzConfigPath = path__default['default'].join(projectRoot, "..", "blitz.config.js"); | ||
} | ||
debug("nextConfigPath: " + nextConfigPath); | ||
@@ -118,3 +176,6 @@ debug("blitzConfigPath: " + blitzConfigPath); | ||
exports.buildConfig = buildConfig; | ||
exports.getConfig = getConfig; | ||
exports.getConfigBuildPath = getConfigBuildPath; | ||
exports.getConfigSrcPath = getConfigSrcPath; | ||
exports.getProjectRoot = getProjectRoot; |
@@ -5,2 +5,3 @@ 'use strict'; | ||
var esbuild = require('esbuild'); | ||
var fsExtra = require('fs-extra'); | ||
@@ -36,5 +37,54 @@ var path = require('path'); | ||
function getProjectRoot() { | ||
return path__default['default'].dirname(path__default['default'].resolve(process.cwd(), "blitz.config.js")) || pkgDir__default['default'].sync() || process.cwd(); | ||
return path__default['default'].dirname(getConfigSrcPath()); | ||
} | ||
function getConfigSrcPath() { | ||
var tsPath = path__default['default'].resolve(path__default['default'].join(process.cwd(), "blitz.config.ts")); | ||
if (fsExtra.existsSync(tsPath)) { | ||
return tsPath; | ||
} else { | ||
var jsPath = path__default['default'].resolve(path__default['default'].join(process.cwd(), "blitz.config.js")); | ||
return jsPath; | ||
} | ||
} | ||
function getConfigBuildPath() { | ||
return path__default['default'].join(getProjectRoot(), ".blitz", "blitz.config.js"); | ||
} | ||
async function buildConfig(_temp) { | ||
var _pkg$dependencies, _pkg$devDependencies; | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
watch = _ref.watch; | ||
debug("Starting buildConfig..."); | ||
var pkg = fsExtra.readJSONSync(path__default['default'].join(pkgDir__default['default'].sync(), "package.json")); | ||
debug("src", getConfigSrcPath()); | ||
debug("build", getConfigBuildPath()); | ||
var esbuildOptions = { | ||
entryPoints: [getConfigSrcPath()], | ||
outfile: getConfigBuildPath(), | ||
format: "cjs", | ||
bundle: true, | ||
platform: "node", | ||
external: ["blitz", "next"].concat(Object.keys(require("blitz/package").dependencies), Object.keys((_pkg$dependencies = pkg == null ? void 0 : pkg.dependencies) != null ? _pkg$dependencies : {}), Object.keys((_pkg$devDependencies = pkg == null ? void 0 : pkg.devDependencies) != null ? _pkg$devDependencies : {})) | ||
}; | ||
if (watch) { | ||
esbuildOptions.watch = { | ||
onRebuild: function onRebuild(error) { | ||
if (error) { | ||
console.error("Failed to re-build blitz config"); | ||
} else { | ||
console.log("\n> Blitz config changed - restart for changes to take effect\n"); | ||
} | ||
} | ||
}; | ||
} | ||
debug("Building config..."); | ||
debug("Src: ", getConfigSrcPath()); | ||
debug("Build: ", getConfigBuildPath()); | ||
await esbuild.build(esbuildOptions); | ||
} | ||
/** | ||
@@ -68,3 +118,11 @@ * @param {boolean | undefined} reload - reimport config files to reset global cache | ||
var nextConfigPath = path__default['default'].join(projectRoot, "next.config.js"); | ||
var blitzConfigPath = path__default['default'].join(projectRoot, "blitz.config.js"); | ||
var blitzConfigPath; | ||
if (fsExtra.existsSync(path__default['default'].join(projectRoot, ".blitz"))) { | ||
blitzConfigPath = path__default['default'].join(projectRoot, ".blitz", "blitz.config.js"); | ||
} else { | ||
// projectRoot is inside .blitz/build/ | ||
blitzConfigPath = path__default['default'].join(projectRoot, "..", "blitz.config.js"); | ||
} | ||
debug("nextConfigPath: " + nextConfigPath); | ||
@@ -118,3 +176,6 @@ debug("blitzConfigPath: " + blitzConfigPath); | ||
exports.buildConfig = buildConfig; | ||
exports.getConfig = getConfig; | ||
exports.getConfigBuildPath = getConfigBuildPath; | ||
exports.getConfigSrcPath = getConfigSrcPath; | ||
exports.getProjectRoot = getProjectRoot; |
@@ -0,1 +1,2 @@ | ||
import { build } from 'esbuild'; | ||
import { existsSync, readJSONSync } from 'fs-extra'; | ||
@@ -26,5 +27,54 @@ import path, { join } from 'path'; | ||
function getProjectRoot() { | ||
return path.dirname(path.resolve(process.cwd(), "blitz.config.js")) || pkgDir.sync() || process.cwd(); | ||
return path.dirname(getConfigSrcPath()); | ||
} | ||
function getConfigSrcPath() { | ||
var tsPath = path.resolve(path.join(process.cwd(), "blitz.config.ts")); | ||
if (existsSync(tsPath)) { | ||
return tsPath; | ||
} else { | ||
var jsPath = path.resolve(path.join(process.cwd(), "blitz.config.js")); | ||
return jsPath; | ||
} | ||
} | ||
function getConfigBuildPath() { | ||
return path.join(getProjectRoot(), ".blitz", "blitz.config.js"); | ||
} | ||
async function buildConfig(_temp) { | ||
var _pkg$dependencies, _pkg$devDependencies; | ||
var _ref = _temp === void 0 ? {} : _temp, | ||
watch = _ref.watch; | ||
debug("Starting buildConfig..."); | ||
var pkg = readJSONSync(path.join(pkgDir.sync(), "package.json")); | ||
debug("src", getConfigSrcPath()); | ||
debug("build", getConfigBuildPath()); | ||
var esbuildOptions = { | ||
entryPoints: [getConfigSrcPath()], | ||
outfile: getConfigBuildPath(), | ||
format: "cjs", | ||
bundle: true, | ||
platform: "node", | ||
external: ["blitz", "next"].concat(Object.keys(require("blitz/package").dependencies), Object.keys((_pkg$dependencies = pkg == null ? void 0 : pkg.dependencies) != null ? _pkg$dependencies : {}), Object.keys((_pkg$devDependencies = pkg == null ? void 0 : pkg.devDependencies) != null ? _pkg$devDependencies : {})) | ||
}; | ||
if (watch) { | ||
esbuildOptions.watch = { | ||
onRebuild: function onRebuild(error) { | ||
if (error) { | ||
console.error("Failed to re-build blitz config"); | ||
} else { | ||
console.log("\n> Blitz config changed - restart for changes to take effect\n"); | ||
} | ||
} | ||
}; | ||
} | ||
debug("Building config..."); | ||
debug("Src: ", getConfigSrcPath()); | ||
debug("Build: ", getConfigBuildPath()); | ||
await build(esbuildOptions); | ||
} | ||
/** | ||
@@ -58,3 +108,11 @@ * @param {boolean | undefined} reload - reimport config files to reset global cache | ||
var nextConfigPath = path.join(projectRoot, "next.config.js"); | ||
var blitzConfigPath = path.join(projectRoot, "blitz.config.js"); | ||
var blitzConfigPath; | ||
if (existsSync(path.join(projectRoot, ".blitz"))) { | ||
blitzConfigPath = path.join(projectRoot, ".blitz", "blitz.config.js"); | ||
} else { | ||
// projectRoot is inside .blitz/build/ | ||
blitzConfigPath = path.join(projectRoot, "..", "blitz.config.js"); | ||
} | ||
debug("nextConfigPath: " + nextConfigPath); | ||
@@ -108,2 +166,2 @@ debug("blitzConfigPath: " + blitzConfigPath); | ||
export { getConfig, getProjectRoot }; | ||
export { buildConfig, getConfig, getConfigBuildPath, getConfigSrcPath, getProjectRoot }; |
export declare function getProjectRoot(): string; | ||
export declare function getConfigSrcPath(): string; | ||
export declare function getConfigBuildPath(): string; | ||
interface BuildConfigOptions { | ||
watch?: boolean; | ||
} | ||
export declare function buildConfig({ watch }?: BuildConfigOptions): Promise<void>; | ||
export interface BlitzConfig extends Record<string, unknown> { | ||
@@ -10,2 +16,5 @@ target?: string; | ||
clearConsoleOnBlitzDev?: boolean; | ||
httpProxy?: string; | ||
httpsProxy?: string; | ||
noProxy?: string; | ||
}; | ||
@@ -27,1 +36,2 @@ _meta: { | ||
export declare const getConfig: (reload?: boolean | undefined) => BlitzConfig; | ||
export {}; |
{ | ||
"name": "@blitzjs/config", | ||
"version": "0.34.3", | ||
"version": "0.34.4-danger.f06f4b853.6+f06f4b853", | ||
"description": "Loads the blitz app config", | ||
@@ -26,4 +26,5 @@ "license": "MIT", | ||
}, | ||
"gitHead": "ec3f871189878f63965c6d3e0088f2e428c1143a", | ||
"gitHead": "f06f4b85314cc056d9f706d24386af17ac3ced28", | ||
"dependencies": { | ||
"esbuild": "^0.11.12", | ||
"fs-extra": "^9.1.0", | ||
@@ -30,0 +31,0 @@ "pkg-dir": "^5.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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the 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
20331
462
3
7
+ Addedesbuild@^0.11.12
+ Addedesbuild@0.11.23(transitive)