@nera-static/plugin-utils 1.5.0 → 1.6.1

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.
Files changed (3) hide show
  1. package/README.md +5 -3
  2. package/index.js +19 -2
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -5,6 +5,8 @@
5
5
 
6
6
  🛠 Utility helpers for developing plugins for the [Nera](https://github.com/seebaermichi/nera) static site generator.
7
7
 
8
+ 📖 **Documentation:** [nera.js.org](https://nera.js.org)
9
+
8
10
  ---
9
11
 
10
12
  ## 📦 Installation
@@ -89,7 +91,7 @@ if (validateNeraProject()) {
89
91
 
90
92
  Publishes specific template files from a plugin to a Nera project.
91
93
 
92
- The destination is **theme-aware**, resolved exactly as the generator resolves its views folder (see `resolveViewsDir` below): `theme/views/vendor/<pluginName>/` on a themed site, the deprecated root `views/vendor/<pluginName>/` otherwise. If it already exists, publishing is **skipped** and the function returns `true` — this protects the customizations you have made to previously published templates. Pass `force: true` to overwrite them.
94
+ The destination is **theme-aware**, resolved exactly as the generator resolves its views folder (see `resolveViewsDir` below): `theme/views/vendor/<pluginName>/` on a themed site (one with a local `theme/` folder — what `nera new` scaffolds), the deprecated root `views/vendor/<pluginName>/` otherwise. If it already exists, publishing is **skipped** and the function returns `true` — this protects the customizations you have made to previously published templates. Pass `force: true` to overwrite them.
93
95
 
94
96
  ```js
95
97
  import { publishTemplates } from '@nera-static/plugin-utils'
@@ -207,8 +209,8 @@ A plugin exports `getAppData` and/or `getMetaData`. Both receive a single object
207
209
  See the [Nera contributing guide](https://github.com/seebaermichi/nera/blob/main/CONTRIBUTING.md) for the full plugin contract.
208
210
 
209
211
  ```js
210
- // bin/publish-template.js - Template publishing script
211
212
  #!/usr/bin/env node
213
+ // bin/publish-template.js - Template publishing script
212
214
 
213
215
  import path from 'path'
214
216
  import { fileURLToPath } from 'url'
@@ -260,7 +262,7 @@ Created and maintained by [@seebaermichi](https://github.com/seebaermichi)
260
262
  ## 🧩 Compatibility
261
263
 
262
264
  - **Node.js**: >= 20.0.0
263
- - **Runtime dependency**: `js-yaml ^4.1.0` only
265
+ - **Runtime dependency**: `js-yaml ^5.2.2` only
264
266
  - **Nera**: no direct dependency on the generator — this package is used by
265
267
  plugins, not by the generator itself
266
268
 
package/index.js CHANGED
@@ -1,11 +1,28 @@
1
1
  import fs from 'fs'
2
2
  import path from 'path'
3
- import yaml from 'js-yaml'
3
+ // js-yaml 5 dropped the default export; `load` is a named export now.
4
+ import { load } from 'js-yaml'
5
+
6
+ // js-yaml 5 throws on a document with no content, where 4 returned undefined.
7
+ // A packaged config whose every key is commented out is the normal case here —
8
+ // that is how plugins ship their defaults — so it has to keep behaving like an
9
+ // absent config instead of crashing the build. Real syntax errors still throw.
10
+ function hasNoDocument(content) {
11
+ return content
12
+ .split('\n')
13
+ .every((line) => {
14
+ const trimmed = line.trim()
15
+ return trimmed === '' || trimmed.startsWith('#')
16
+ })
17
+ }
4
18
 
5
19
  export function getConfig(filePath) {
6
20
  if (fs.existsSync(filePath)) {
7
21
  const content = fs.readFileSync(filePath, 'utf-8')
8
- return yaml.load(content) || {}
22
+ if (hasNoDocument(content)) {
23
+ return {}
24
+ }
25
+ return load(content) || {}
9
26
  }
10
27
  return {}
11
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nera-static/plugin-utils",
3
- "version": "1.5.0",
3
+ "version": "1.6.1",
4
4
  "description": "Shared utility functions for Nera plugins (config loading, template publishing)",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,12 +26,12 @@
26
26
  "access": "public"
27
27
  },
28
28
  "dependencies": {
29
- "js-yaml": "^4.1.0"
29
+ "js-yaml": "^5.2.2"
30
30
  },
31
31
  "devDependencies": {
32
- "eslint": "^9.17.0",
32
+ "eslint": "^10.8.0",
33
33
  "husky": "^9.1.7",
34
- "vitest": "^3.2.4"
34
+ "vitest": "^5.0.0"
35
35
  },
36
36
  "scripts": {
37
37
  "test": "vitest",