@nera-static/plugin-utils 1.0.0 → 1.0.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.
@@ -0,0 +1,30 @@
1
+ name: 🧪 Run Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ build-and-test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ node-version: [18, 20]
15
+
16
+ steps:
17
+ - name: Checkout repository
18
+ uses: actions/checkout@v4
19
+
20
+ - name: Setup Node.js ${{ matrix.node-version }}
21
+ uses: actions/setup-node@v4
22
+ with:
23
+ node-version: ${{ matrix.node-version }}
24
+ cache: 'npm'
25
+
26
+ - name: Install dependencies
27
+ run: npm install
28
+
29
+ - name: Run tests
30
+ run: npm test
package/package.json CHANGED
@@ -1,35 +1,33 @@
1
1
  {
2
2
  "name": "@nera-static/plugin-utils",
3
- "version": "1.0.0",
4
- "description": "Utility helpers for Nera plugins, e.g., YAML config loading",
3
+ "version": "1.0.1",
4
+ "description": "Shared utility functions for Nera plugins (like config loading)",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
- "exports": {
8
- ".": "./index.js"
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/seebaermichi/nera-plugin-utils.git"
9
10
  },
11
+ "bugs": {
12
+ "url": "https://github.com/seebaermichi/nera-plugin-utils/issues"
13
+ },
14
+ "homepage": "https://github.com/seebaermichi/nera-plugin-utils#readme",
10
15
  "keywords": [
11
16
  "nera",
17
+ "static-site-generator",
12
18
  "plugin",
13
19
  "utils",
14
- "yaml",
15
- "config"
20
+ "yaml"
16
21
  ],
17
22
  "author": "Michael Becker",
18
23
  "license": "MIT",
19
- "files": [
20
- "index.js",
21
- "README.md"
22
- ],
23
- "dependencies": {
24
- "js-yaml": "^4.1.0"
24
+ "publishConfig": {
25
+ "access": "public"
25
26
  },
26
27
  "devDependencies": {
27
- "vitest": "^3.2.4"
28
+ "vitest": "^1.0.0"
28
29
  },
29
30
  "scripts": {
30
- "test": "vitest run"
31
- },
32
- "publishConfig": {
33
- "access": "public"
31
+ "test": "vitest"
34
32
  }
35
33
  }
@@ -0,0 +1,22 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { writeFileSync, unlinkSync } from 'fs';
3
+ import { getConfig } from '../index.js';
4
+
5
+ const tmpFile = './.tmp-config.yaml';
6
+
7
+ describe('getConfig', () => {
8
+ it('returns parsed object when file exists', () => {
9
+ writeFileSync(tmpFile, 'title: Hello\nitems:\n - one\n - two');
10
+ const config = getConfig(tmpFile);
11
+
12
+ expect(config.title).toBe('Hello');
13
+ expect(config.items).toEqual(['one', 'two']);
14
+
15
+ unlinkSync(tmpFile);
16
+ });
17
+
18
+ it('returns empty object when file does not exist', () => {
19
+ const config = getConfig('./nonexistent.yaml');
20
+ expect(config).toEqual({});
21
+ });
22
+ });