@meddleware/frontend-config 0.0.3 → 0.0.5
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 -0
- package/dist/network-status.d.ts +8 -0
- package/package.json +3 -2
- package/src/network-status.js +60 -0
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.5] - 2026-11-07
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `mw-network-status --check <file>`: fails when the committed network file differs from the deployment records (for CI).
|
|
13
|
+
|
|
14
|
+
## [0.0.4] - 2026-11-07
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- `mw-network-status`: writes the networks the platform is deployed on from the clients' deployment records, for the landing page, docs and developer docs.
|
|
19
|
+
|
|
8
20
|
## [0.0.3] - 2026-11-07
|
|
9
21
|
|
|
10
22
|
### Added
|
package/README.md
CHANGED
|
@@ -23,6 +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 --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. |
|
|
26
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). |
|
|
27
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. |
|
|
28
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. |
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @param {{ networkAvailability: Function }} utils
|
|
4
|
+
* @param {Record<string, Record<string, unknown>>} records product name → its deployments object
|
|
5
|
+
*/
|
|
6
|
+
export function networkStatus(utils: {
|
|
7
|
+
networkAvailability: Function;
|
|
8
|
+
}, records: Record<string, Record<string, unknown>>): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meddleware/frontend-config",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
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",
|
|
@@ -175,6 +175,7 @@
|
|
|
175
175
|
"mw-audit-gate": "./src/audit-gate.js",
|
|
176
176
|
"mw-third-party-licenses": "./src/third-party-licenses.js",
|
|
177
177
|
"mw-check-csp-inline": "./src/check-csp-inline.js",
|
|
178
|
-
"mw-sync": "./src/sync.js"
|
|
178
|
+
"mw-sync": "./src/sync.js",
|
|
179
|
+
"mw-network-status": "./src/network-status.js"
|
|
179
180
|
}
|
|
180
181
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @ts-check
|
|
3
|
+
// mw-network-status — write which networks MeddleWare is deployed on, from the deployment records of the installed client packages, so a static
|
|
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
|
+
//
|
|
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
|
|
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
|
|
11
|
+
// (`@meddleware/access-gate-client`, `@meddleware/sealed-storage-client`) installed; it fails when one is missing rather than guess.
|
|
12
|
+
import { readFileSync, writeFileSync } from 'node:fs'
|
|
13
|
+
import { createRequire } from 'node:module'
|
|
14
|
+
import { join } from 'node:path'
|
|
15
|
+
import { pathToFileURL } from 'node:url'
|
|
16
|
+
|
|
17
|
+
/** @param {string} name */
|
|
18
|
+
async function load(name) {
|
|
19
|
+
const require = createRequire(join(process.cwd(), 'noop.js'))
|
|
20
|
+
return import(pathToFileURL(require.resolve(name)).href)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {{ networkAvailability: Function }} utils
|
|
25
|
+
* @param {Record<string, Record<string, unknown>>} records product name → its deployments object
|
|
26
|
+
*/
|
|
27
|
+
export function networkStatus(utils, records) {
|
|
28
|
+
return utils.networkAvailability(Object.fromEntries(Object.entries(records).map(([name, deployments]) => [name, Object.keys(deployments)])))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
32
|
+
const args = process.argv.slice(2)
|
|
33
|
+
const outIndex = args.indexOf('--out')
|
|
34
|
+
const out = outIndex >= 0 ? args[outIndex + 1] : undefined
|
|
35
|
+
const checkIndex = args.indexOf('--check')
|
|
36
|
+
const check = checkIndex >= 0 ? args[checkIndex + 1] : undefined
|
|
37
|
+
try {
|
|
38
|
+
const utils = await load('@meddleware/web-utils')
|
|
39
|
+
const gate = await load('@meddleware/access-gate-client')
|
|
40
|
+
const sealed = await load('@meddleware/sealed-storage-client')
|
|
41
|
+
const status = networkStatus(utils, { 'access gate': gate.ACCESS_GATE_DEPLOYMENTS, 'sealed storage': sealed.SEAL_POLICIES_DEPLOYMENTS })
|
|
42
|
+
const json = JSON.stringify(status, null, 2) + '\n'
|
|
43
|
+
if (check) {
|
|
44
|
+
let have = ''
|
|
45
|
+
try {
|
|
46
|
+
have = readFileSync(check, 'utf8')
|
|
47
|
+
} catch {
|
|
48
|
+
// missing counts as different
|
|
49
|
+
}
|
|
50
|
+
if (have !== json) {
|
|
51
|
+
console.error(`mw-network-status: ${check} is out of date with the deployment records; run \`mw-network-status --out ${check}\``)
|
|
52
|
+
process.exit(1)
|
|
53
|
+
}
|
|
54
|
+
} else if (out) writeFileSync(out, json)
|
|
55
|
+
else process.stdout.write(json)
|
|
56
|
+
} catch (err) {
|
|
57
|
+
console.error(`mw-network-status: ${err instanceof Error ? err.message : String(err)}`)
|
|
58
|
+
process.exit(1)
|
|
59
|
+
}
|
|
60
|
+
}
|