@nera-static/core 4.18.0 → 4.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/package.json +1 -1
- package/src/theme.js +29 -6
package/README.md
CHANGED
|
@@ -124,8 +124,6 @@ Views resolve **layered**: a site's `theme/views/<file>` overrides an installed
|
|
|
124
124
|
|
|
125
125
|
The `NERA_THEME` environment variable overrides `theme:` in `config/app.yaml` for one run, in any of its forms (`NERA_THEME=./themes/classic nera build`), so you can build or preview another design without editing the config. An empty value falls back to `app.yaml`.
|
|
126
126
|
|
|
127
|
-
The design lives in [`ROADMAP-themes.md`](./ROADMAP-themes.md); the consolidation that made this package importable is in [`ROADMAP-core.md`](./ROADMAP-core.md).
|
|
128
|
-
|
|
129
127
|
---
|
|
130
128
|
|
|
131
129
|
## 📁 Deploying to a subdirectory (`base_path`)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nera-static/core",
|
|
3
|
-
"version": "4.18.
|
|
3
|
+
"version": "4.18.2",
|
|
4
4
|
"description": "The Nera static site generator engine — the build pipeline and the layered theme/view resolver, importable by the Nera CLI, @nera-static/validate and tooling",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"exports": {
|
package/src/theme.js
CHANGED
|
@@ -49,7 +49,10 @@ export function resolveTheme({
|
|
|
49
49
|
|
|
50
50
|
if (!fs.existsSync(viewsRoot)) {
|
|
51
51
|
throw new Error(
|
|
52
|
-
`theme: "${spec}" resolved to ${root}, but
|
|
52
|
+
`theme: "${spec}" resolved to ${siteRelative(cwd, root)}, but it ` +
|
|
53
|
+
'has no views/ folder — point `theme:` in config/app.yaml (or ' +
|
|
54
|
+
'NERA_THEME) at a theme folder with views/, or remove it to ' +
|
|
55
|
+
'build without a theme'
|
|
53
56
|
)
|
|
54
57
|
}
|
|
55
58
|
|
|
@@ -65,6 +68,26 @@ export function resolveTheme({
|
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
70
|
|
|
71
|
+
// A theme root as the site sees it, for error messages: relative to cwd, `.`
|
|
72
|
+
// when it is the site itself. A resolved package root is already a realpath, so
|
|
73
|
+
// when the root exists both sides go through realpath — otherwise a macOS temp
|
|
74
|
+
// dir (/var → /private/var) or an `npm link`ed theme reads `../../private/…`. A
|
|
75
|
+
// root that does not exist has no realpath, and its plain path is relative to
|
|
76
|
+
// the plain cwd it was resolved from.
|
|
77
|
+
function siteRelative(cwd, root) {
|
|
78
|
+
const real = (p) => {
|
|
79
|
+
try {
|
|
80
|
+
return fs.realpathSync(p)
|
|
81
|
+
} catch {
|
|
82
|
+
return p
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const exists = fs.existsSync(root)
|
|
86
|
+
const from = exists ? real(cwd) : cwd
|
|
87
|
+
const to = exists ? real(root) : root
|
|
88
|
+
return path.relative(from, to) || '.'
|
|
89
|
+
}
|
|
90
|
+
|
|
68
91
|
// The theme spec in effect: NERA_THEME over `app.theme`. An empty NERA_THEME is
|
|
69
92
|
// treated as unset, so `NERA_THEME= nera build` falls back to app.yaml rather
|
|
70
93
|
// than silently building themeless.
|
|
@@ -148,8 +171,8 @@ function resolvePackageRoot(spec, cwd) {
|
|
|
148
171
|
return path.dirname(requireFromSite.resolve(`${pkg}/package.json`))
|
|
149
172
|
} catch {
|
|
150
173
|
throw new Error(
|
|
151
|
-
`theme: "${spec}" — package ${pkg} is not installed
|
|
152
|
-
`
|
|
174
|
+
`theme: "${spec}" — package ${pkg} is not installed; ` +
|
|
175
|
+
`run \`npm install ${pkg}\``
|
|
153
176
|
)
|
|
154
177
|
}
|
|
155
178
|
}
|
|
@@ -240,9 +263,9 @@ function checkGeneratorCompatibility(theme, themePkg, generatorVersion) {
|
|
|
240
263
|
if (!satisfies(generatorVersion, range)) {
|
|
241
264
|
throw new Error(
|
|
242
265
|
`theme "${theme.name}" requires Nera generator ${range}, but this ` +
|
|
243
|
-
`generator is ${generatorVersion}
|
|
244
|
-
'(nera update) or install a theme version compatible with ' +
|
|
245
|
-
|
|
266
|
+
`generator is ${generatorVersion} — update the generator ` +
|
|
267
|
+
'(`nera update`) or install a theme version compatible with ' +
|
|
268
|
+
generatorVersion
|
|
246
269
|
)
|
|
247
270
|
}
|
|
248
271
|
}
|