@meddleware/frontend-config 0.0.4 → 0.0.6
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 +12 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/network-status.js +20 -4
- package/src/sync.js +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,18 @@ 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.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.0.6] - 2026-11-07
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- `mw-network-status` and `mw-sync` did nothing when run as an installed bin (they compared the symlink in `node_modules/.bin` with the real path); both now compare real paths, and a test runs each through a symlink.
|
|
13
|
+
|
|
14
|
+
## [0.0.5] - 2026-11-07
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- `mw-network-status --check <file>`: fails when the committed network file differs from the deployment records (for CI).
|
|
19
|
+
|
|
8
20
|
## [0.0.4] - 2026-11-07
|
|
9
21
|
|
|
10
22
|
### Added
|
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ same accessibility and browser-support bar.
|
|
|
23
23
|
| `/tsconfig/vue-app.json` | The compiler options of a Vue app (`"extends": "@meddleware/frontend-config/tsconfig/vue-app.json"`); the repository keeps only its `include`. |
|
|
24
24
|
| `/csp` | `buildCsp(options)`, `cspForProfile(name, current?)`, `PROFILES`, `scriptHashesOf(csp)` — the Content-Security-Policy every app image serves, as six named profiles (`static`, `static-strict`, `console`, `chain`, `chain-wasm`, `docs`), so the policy is written once. |
|
|
25
25
|
| `mw-sync` | `mw-sync --check` / `--write` in a repository root: the files every frontend repository copies (dependabot.yml, .dockerignore, postcss/stylelint configs, the Lighthouse allowlist) equal this package's `templates/`, and the Dockerfile's `ARG CSP` equals its profile. Declared in package.json: `"meddleware": { "kind": "app", "csp": "chain-wasm", "lhci": true }`. |
|
|
26
|
-
| `mw-network-status` | `mw-network-status
|
|
26
|
+
| `mw-network-status` | `mw-network-status --out src/network.json` (or `--check src/network.json` in CI): which networks MeddleWare is deployed on, from the installed clients' deployment records through `networkAvailability` (`@meddleware/web-utils`). The file is committed and CI checks it, so "mainnet is coming" turns into "live" by the records alone. |
|
|
27
27
|
| `mw-audit-gate` | CI dependency gate: `npm audit` at high/critical minus the dated, reasoned entries of `.github/audit-allowlist.json` (an entry with no reason or an expired date fails). |
|
|
28
28
|
| `mw-third-party-licenses` | Writes `dist/THIRD_PARTY_LICENSES` from the lockfile's production packages and their installed licence texts; `--check` fails when none can be written. |
|
|
29
29
|
| `mw-check-csp-inline` | `mw-check-csp-inline <policy or @Dockerfile> [dist]`: every inline script in the built pages is allowed by a `sha256` source in the policy, and the policy never allows `'unsafe-inline'` scripts. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meddleware/frontend-config",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shared frontend tooling for MeddleWare apps: browser support, ESLint, Stylelint, html-validate, PostCSS, Playwright, axe, screenshots, Lighthouse and the Vite target.",
|
|
6
6
|
"license": "0BSD",
|
package/src/network-status.js
CHANGED
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
// site (landing page, docs, developer docs) says "mainnet is coming" until the records have a `mainnet` key and says "live" the moment they do.
|
|
5
5
|
//
|
|
6
6
|
// mw-network-status [--out src/network.json] (default: print to stdout)
|
|
7
|
+
// mw-network-status --check src/network.json fail (exit 1) when the committed file differs from the records
|
|
7
8
|
//
|
|
8
|
-
//
|
|
9
|
+
// The file is committed, so the page and its tests never depend on a hidden build step; CI runs `--check`, and bumping a client package
|
|
10
|
+
// (Dependabot, or a release that adds a mainnet record) fails the check until the file is regenerated with `--out`. The repository needs `@meddleware/web-utils` and the two clients
|
|
9
11
|
// (`@meddleware/access-gate-client`, `@meddleware/sealed-storage-client`) installed; it fails when one is missing rather than guess.
|
|
10
|
-
import { writeFileSync } from 'node:fs'
|
|
12
|
+
import { readFileSync, realpathSync, writeFileSync } from 'node:fs'
|
|
11
13
|
import { createRequire } from 'node:module'
|
|
12
14
|
import { join } from 'node:path'
|
|
13
15
|
import { pathToFileURL } from 'node:url'
|
|
@@ -26,17 +28,31 @@ export function networkStatus(utils, records) {
|
|
|
26
28
|
return utils.networkAvailability(Object.fromEntries(Object.entries(records).map(([name, deployments]) => [name, Object.keys(deployments)])))
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
// `process.argv[1]` is the symlink in node_modules/.bin when run as a bin: compare real paths.
|
|
32
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href) {
|
|
30
33
|
const args = process.argv.slice(2)
|
|
31
34
|
const outIndex = args.indexOf('--out')
|
|
32
35
|
const out = outIndex >= 0 ? args[outIndex + 1] : undefined
|
|
36
|
+
const checkIndex = args.indexOf('--check')
|
|
37
|
+
const check = checkIndex >= 0 ? args[checkIndex + 1] : undefined
|
|
33
38
|
try {
|
|
34
39
|
const utils = await load('@meddleware/web-utils')
|
|
35
40
|
const gate = await load('@meddleware/access-gate-client')
|
|
36
41
|
const sealed = await load('@meddleware/sealed-storage-client')
|
|
37
42
|
const status = networkStatus(utils, { 'access gate': gate.ACCESS_GATE_DEPLOYMENTS, 'sealed storage': sealed.SEAL_POLICIES_DEPLOYMENTS })
|
|
38
43
|
const json = JSON.stringify(status, null, 2) + '\n'
|
|
39
|
-
if (
|
|
44
|
+
if (check) {
|
|
45
|
+
let have = ''
|
|
46
|
+
try {
|
|
47
|
+
have = readFileSync(check, 'utf8')
|
|
48
|
+
} catch {
|
|
49
|
+
// missing counts as different
|
|
50
|
+
}
|
|
51
|
+
if (have !== json) {
|
|
52
|
+
console.error(`mw-network-status: ${check} is out of date with the deployment records; run \`mw-network-status --out ${check}\``)
|
|
53
|
+
process.exit(1)
|
|
54
|
+
}
|
|
55
|
+
} else if (out) writeFileSync(out, json)
|
|
40
56
|
else process.stdout.write(json)
|
|
41
57
|
} catch (err) {
|
|
42
58
|
console.error(`mw-network-status: ${err instanceof Error ? err.message : String(err)}`)
|
package/src/sync.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// kind "app" → .github/dependabot.yml, .dockerignore, postcss.config.js, stylelint.config.js are the templates
|
|
12
12
|
// csp a profile of ./csp.js → the Dockerfile's `ARG CSP="…"` is that profile's policy (`docs` keeps the script hashes already there)
|
|
13
13
|
// lhci true → .github/audit-allowlist.json is the template (the dated allowlist for the Lighthouse CI tool chain; one expiry, reviewed together)
|
|
14
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
14
|
+
import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from 'node:fs'
|
|
15
15
|
import { dirname, join } from 'node:path'
|
|
16
16
|
import { fileURLToPath } from 'node:url'
|
|
17
17
|
import { cspForProfile } from './csp.js'
|
|
@@ -67,7 +67,8 @@ export function sync(root, options = {}) {
|
|
|
67
67
|
return out
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
// `process.argv[1]` is the symlink in node_modules/.bin when run as a bin: compare real paths.
|
|
71
|
+
if (process.argv[1] && fileURLToPath(import.meta.url) === realpathSync(process.argv[1])) {
|
|
71
72
|
const args = process.argv.slice(2)
|
|
72
73
|
const write = args.includes('--write')
|
|
73
74
|
if (!write && !args.includes('--check')) {
|