@nera-static/test-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.
- package/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/files.js +4 -0
- package/src/publish-template.js +1 -3
- package/src/theme/suite.js +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.1] - 2026-11-27
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- The path check every suite's options share (a path below the repo root: not empty, not absolute, no `..` segment) is defined once, in `src/files.js`, instead of twice. No option is accepted or refused differently; it is not exported.
|
|
13
|
+
|
|
8
14
|
## [1.0.0] - 2026-11-27
|
|
9
15
|
|
|
10
16
|
### Added
|
package/package.json
CHANGED
package/src/files.js
CHANGED
|
@@ -4,6 +4,10 @@ import path from 'node:path'
|
|
|
4
4
|
import { afterAll } from 'vitest'
|
|
5
5
|
import { isPlainObject } from '@nera-static/plugin-utils/values'
|
|
6
6
|
|
|
7
|
+
// A path below a root: not empty, not absolute, no `..` segment. Internal:
|
|
8
|
+
// the option checks of the suites share it; the entry point does not export it.
|
|
9
|
+
export const isRelative = (value) => typeof value === 'string' && value !== '' && !path.isAbsolute(value) && !value.split(/[\\/]/).includes('..')
|
|
10
|
+
|
|
7
11
|
// Every dir `tempDir` creates in this test file, removed once the file is
|
|
8
12
|
// done: after all its tests rather than after each, because suites create
|
|
9
13
|
// their site once in `beforeAll` and read it in several tests.
|
package/src/publish-template.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from 'node:path'
|
|
|
3
3
|
import { spawnSync } from 'node:child_process'
|
|
4
4
|
import { describe, expect, it } from 'vitest'
|
|
5
5
|
import { isPlainObject } from '@nera-static/plugin-utils/values'
|
|
6
|
-
import { listFiles } from './files.js'
|
|
6
|
+
import { isRelative, listFiles } from './files.js'
|
|
7
7
|
import { makeSite } from './site.js'
|
|
8
8
|
|
|
9
9
|
// What a user's edited copy holds before a run: a publish that keeps it
|
|
@@ -19,8 +19,6 @@ const PROJECT_FILES = Object.freeze({ 'pages/index.md': '# Home\n' })
|
|
|
19
19
|
// Nera needs.
|
|
20
20
|
const NOT_A_PROJECT = Object.freeze({ 'config/app.yaml': null, views: null, pages: null })
|
|
21
21
|
|
|
22
|
-
const isRelative = (value) => typeof value === 'string' && value !== '' && !path.isAbsolute(value) && !value.split(/[\\/]/).includes('..')
|
|
23
|
-
|
|
24
22
|
/**
|
|
25
23
|
* Check the options once, so every case can trust them, and resolve the
|
|
26
24
|
* paths the cases need.
|
package/src/theme/suite.js
CHANGED
|
@@ -6,13 +6,12 @@ import path from 'node:path'
|
|
|
6
6
|
import { describe, expect, it } from 'vitest'
|
|
7
7
|
import { escapeRegExp } from '@nera-static/plugin-utils/html'
|
|
8
8
|
import { isPlainObject } from '@nera-static/plugin-utils/values'
|
|
9
|
+
import { isRelative } from '../files.js'
|
|
9
10
|
import { pages } from '../html.js'
|
|
10
11
|
|
|
11
12
|
// Re-exported for the suites, so each imports its helpers from one place.
|
|
12
|
-
export { escapeRegExp, isPlainObject }
|
|
13
|
+
export { escapeRegExp, isPlainObject, isRelative }
|
|
13
14
|
|
|
14
|
-
// A path below a root: not empty, not absolute, no `..` segment.
|
|
15
|
-
export const isRelative = (value) => typeof value === 'string' && value !== '' && !path.isAbsolute(value) && !value.split(/[\\/]/).includes('..')
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
17
|
* Refuse a build output path that is not absolute: it is the `public` of a
|