mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-18 07:58:27 +00:00
Compare commits
3 Commits
fix/servic
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d11a999d6d | ||
|
|
3337f07a59 | ||
|
|
61be54061d |
5
.github/workflows/npm-publish.yml
vendored
5
.github/workflows/npm-publish.yml
vendored
@@ -312,7 +312,10 @@ jobs:
|
||||
# its budget had never been measured against a real run. It then blew the limit
|
||||
# on its debut: `npm pack` alone took 24m37s, leaving 5 minutes for two installs
|
||||
# and two boots. 30 was a guess; 60 is sized to the one measurement we have.
|
||||
timeout-minutes: 60
|
||||
# 120 since the v3.8.54 re-publish (run 44220411903): on the shared .113 runner the
|
||||
# step's own `npm pack` took 23m09s, the clean install 17m31s and the 3.8.53 install
|
||||
# 10m39s, and the upgrade was still installing when the 60-minute limit killed it.
|
||||
timeout-minutes: 120
|
||||
run: npm run check:install-upgrade
|
||||
|
||||
# WS1.3 (D2, v3.8.49 plan): STAGED publishing by default — `npm stage publish`
|
||||
|
||||
@@ -318,6 +318,7 @@ _By commits in `6cc6965075..a9539085bd`, author identities consolidated via `.ma
|
||||
|
||||
### 🐛 Bug Fixes
|
||||
|
||||
- **fix(release):** the npm package no longer ships the translated `/docs` mirrors. They took about 96 MB of the packed tarball, and the registry refused 3.8.54 at 206.1 MB with `E413 Payload Too Large`. npm installs now serve `/docs` in English for every locale; Docker and Electron keep the translated pages. `check:pack-artifact` now fails any `docs/i18n` file in the tarball and any tarball over 190 MB packed, so the next size problem shows up before the publish step
|
||||
- **fix(i18n):** the provider API region picker shows its translated labels again in Finnish, Korean, Polish, Portuguese, Brazilian Portuguese and Simplified and Traditional Chinese, instead of falling back to English. ([#19226](https://github.com/cheaper-inference/OmniRoute/pull/19226))
|
||||
- **test(sse):** Distinguish malformed SSE from valid upstream error frames in the non-streaming regression suites, and verify both initial and fallback errors retain their status, diagnostic and receipt.
|
||||
- **fix(ci):** Audit all five independent lockfiles with explicit incomplete results, reject missing/invalid OSV measurements, align OpenCode CI with supported Node releases, and reproduce plugin installs from their lockfiles.
|
||||
|
||||
@@ -157,14 +157,19 @@ When the `NEXT_LOCALE` cookie names a non-English locale, `/docs/<section>/<PAGE
|
||||
`docs/i18n/<locale>/docs/<section>/<PAGE>.md` (`src/lib/docsI18nRender.ts`). A page or locale
|
||||
without a mirror gets the English page.
|
||||
|
||||
Every install method ships these mirrors: the standalone build, Electron, the npm package (under
|
||||
`dist/docs/i18n/`) and the Docker image. The npm package and the image carry only the mirrors the
|
||||
route can serve: the sections `source.config.ts` compiles, without the operator-internal security
|
||||
pages it excludes. The README, CHANGELOG, agent-guide and `llm.txt` mirrors at each locale root
|
||||
stay out of both.
|
||||
`scripts/build/docsMirrorRuntime.mjs` holds that rule; the npm pack policy and `.dockerignore`
|
||||
follow it, and `tests/unit/docs-mirror-runtime-shipping.test.ts` keeps them in sync. The pages are
|
||||
sanitized through `jsdom`, which is a runtime dependency for that reason.
|
||||
The standalone build, Electron and the Docker image ship these mirrors. The image carries only
|
||||
the mirrors the route can serve: the sections `source.config.ts` compiles, without the
|
||||
operator-internal security pages it excludes. The README, CHANGELOG, agent-guide and `llm.txt`
|
||||
mirrors at each locale root stay out.
|
||||
`scripts/build/docsMirrorRuntime.mjs` holds that rule; `.dockerignore` follows it, and
|
||||
`tests/unit/docs-mirror-runtime-shipping.test.ts` keeps them in sync. The pages are sanitized
|
||||
through `jsdom`, which is a runtime dependency for that reason.
|
||||
|
||||
The npm package ships no mirrors, so an npm install serves `/docs` in English for every locale.
|
||||
The mirrors were about 96 MB of the packed tarball and pushed 3.8.54 to 206.1 MB, over the
|
||||
registry's limit (`E413`). Prepublish drops `docs/i18n` from the staged `dist/`, and
|
||||
`check:pack-artifact` rejects any `docs/i18n` file and any tarball over
|
||||
`PACK_ARTIFACT_MAX_PACKED_BYTES` (`scripts/build/pack-artifact-policy.ts`).
|
||||
|
||||
### Supported Locales
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
* directories out of the staged dist/ tree and out of the final tarball.
|
||||
*/
|
||||
|
||||
import { isRuntimeDocsMirrorPath } from "./docsMirrorRuntime.mjs";
|
||||
|
||||
const STAGING_FORBIDDEN_DIRECTORIES = [
|
||||
"app.__qa_backup",
|
||||
"coverage",
|
||||
@@ -31,6 +29,11 @@ export const APP_STAGING_REMOVAL_PATHS: string[] = [
|
||||
// past the registry 413 limit for npm.org. It's only needed on systems
|
||||
// with a CUDA GPU — users install CUDA providers separately.
|
||||
"node_modules/onnxruntime-node/bin/napi-v6/linux/x64/libonnxruntime_providers_cuda.so",
|
||||
// 2026-11-17 (owner decision): the translated /docs mirrors (~397 MB unpacked, ~96 MB of the
|
||||
// packed tarball) pushed omniroute 3.8.54 to 206.1 MB and the registry answered 413. npm
|
||||
// installs serve /docs in English (docsI18nRender falls back when a mirror is missing);
|
||||
// Docker and Electron keep the mirrors, since they ship the standalone build directly.
|
||||
"docs/i18n",
|
||||
];
|
||||
|
||||
export const APP_STAGING_ALLOWED_EXACT_PATHS: string[] = [
|
||||
@@ -100,15 +103,11 @@ export const APP_STAGING_ALLOWED_PATH_PREFIXES: string[] = [
|
||||
];
|
||||
|
||||
/**
|
||||
* Allowed paths that are neither one exact file nor a whole prefix. 2026-11-03 (owner
|
||||
* decision): npm installs serve the translated /docs pages, so dist/ keeps the docs mirrors
|
||||
* the route can read (`docs/i18n/<locale>/docs/<section>/<PAGE>.md`, see docsMirrorRuntime.mjs)
|
||||
* and nothing else under docs/i18n. A prefix would also admit the README, CHANGELOG and agent
|
||||
* guide mirrors and the operator-internal security pages.
|
||||
* Allowed paths that are neither one exact file nor a whole prefix. Empty since 2026-11-17:
|
||||
* it used to admit the translated docs mirrors (2026-11-03), which now stay out of the npm
|
||||
* package entirely (see the docs/i18n entry in APP_STAGING_REMOVAL_PATHS).
|
||||
*/
|
||||
export const APP_STAGING_ALLOWED_PATH_MATCHERS: Array<(filePath: string) => boolean> = [
|
||||
isRuntimeDocsMirrorPath,
|
||||
];
|
||||
export const APP_STAGING_ALLOWED_PATH_MATCHERS: Array<(filePath: string) => boolean> = [];
|
||||
|
||||
export const PACK_ARTIFACT_ALLOWED_EXACT_PATHS: string[] = APP_STAGING_ALLOWED_EXACT_PATHS.map(
|
||||
(filePath: string) => `dist/${filePath}`
|
||||
@@ -123,6 +122,21 @@ export const PACK_ARTIFACT_ALLOWED_PATH_MATCHERS: Array<(filePath: string) => bo
|
||||
(matches) => (filePath: string) => filePath.startsWith("dist/") && matches(filePath.slice(5))
|
||||
);
|
||||
|
||||
/**
|
||||
* Packed-size ceiling for the npm tarball. The registry rejected omniroute 3.8.54 with E413 at
|
||||
* 206.1 MB packed, after 3.8.53 went through at 193.6 MB, and the package grows ~12 MB per
|
||||
* release. Failing check:pack-artifact below that limit catches the growth before the last
|
||||
* step of a release does.
|
||||
*/
|
||||
export const PACK_ARTIFACT_MAX_PACKED_BYTES = 190_000_000;
|
||||
|
||||
export function exceedsPackedSizeBudget(
|
||||
packedBytes: number,
|
||||
maxBytes: number = PACK_ARTIFACT_MAX_PACKED_BYTES
|
||||
): boolean {
|
||||
return Number.isFinite(packedBytes) && packedBytes > maxBytes;
|
||||
}
|
||||
|
||||
export const PACK_ARTIFACT_ROOT_ALLOWED_EXACT_PATHS: string[] = [
|
||||
".env.example",
|
||||
"LICENSE",
|
||||
@@ -264,10 +278,6 @@ export const PACK_ARTIFACT_REQUIRED_PATHS: string[] = [
|
||||
// Cleartext h2c upgrade guard (dist/server-ws.mjs import) — same boot-crash class as above.
|
||||
"dist/h2c-upgrade-guard.cjs",
|
||||
"dist/webdav-handler.mjs",
|
||||
// 2026-11-03: one translated docs mirror, so a packaging change that drops the mirrors
|
||||
// (they only reach dist/ through the standalone docs copy) fails here instead of silently
|
||||
// serving English to every npm install.
|
||||
"dist/docs/i18n/pt-BR/docs/getting-started/QUICK-START.md",
|
||||
"bin/cli/program.mjs",
|
||||
// Direct imports of bin/omniroute.mjs — bin/cli/ is only an allowlist PREFIX, so a
|
||||
// file vanishing from the tarball never fails the unexpected-paths check; only these
|
||||
|
||||
@@ -683,8 +683,7 @@ for (const relativePath of APP_STAGING_REMOVAL_PATHS) {
|
||||
// tarball gate, the staged dist/ legitimately contains node_modules (the
|
||||
// standalone server's runtime deps, including Turbopack-hashed packages whose
|
||||
// wasm files DB init requires). The allowlist prefixes above are the contract.
|
||||
// The path matchers keep the translated docs mirrors the /docs route reads (they arrive
|
||||
// with the standalone's docs/ copy) and drop every other docs/i18n file.
|
||||
// docs/i18n never reaches this point: Step 10.6 removes the whole tree (2026-11-17, npm 413).
|
||||
const stagedFiles = walkFiles(DIST_DIR);
|
||||
const unexpectedStagedFiles = findUnexpectedArtifactPaths(stagedFiles, {
|
||||
exactPaths: APP_STAGING_ALLOWED_EXACT_PATHS,
|
||||
|
||||
@@ -17,7 +17,9 @@ import {
|
||||
PACK_ARTIFACT_ALLOWED_EXACT_PATHS,
|
||||
PACK_ARTIFACT_ALLOWED_PATH_MATCHERS,
|
||||
PACK_ARTIFACT_ALLOWED_PATH_PREFIXES,
|
||||
PACK_ARTIFACT_MAX_PACKED_BYTES,
|
||||
PACK_ARTIFACT_REQUIRED_PATHS,
|
||||
exceedsPackedSizeBudget,
|
||||
findMissingArtifactPaths,
|
||||
findUnexpectedArtifactPaths,
|
||||
parseJsonValuesOutput,
|
||||
@@ -199,11 +201,19 @@ try {
|
||||
}
|
||||
}
|
||||
|
||||
const overPackedBudget = exceedsPackedSizeBudget(packReport.size);
|
||||
if (overPackedBudget) {
|
||||
console.error(
|
||||
`\n❌ Packed size ${formatBytes(packReport.size)} is over the ${formatBytes(PACK_ARTIFACT_MAX_PACKED_BYTES)} budget (PACK_ARTIFACT_MAX_PACKED_BYTES); npm rejected 3.8.54 with E413 at 206.1 MB.`
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
unexpectedPaths.length > 0 ||
|
||||
missingRequiredPaths.length > 0 ||
|
||||
leakedTestPaths.length > 0 ||
|
||||
missingMcpPaths.length > 0
|
||||
missingMcpPaths.length > 0 ||
|
||||
overPackedBudget
|
||||
) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -43,13 +43,12 @@ export const REQUIRED_MACHINE_TOKEN_RUNTIME_FILES = Object.freeze([
|
||||
"node_modules/node-machine-id/index.js",
|
||||
]);
|
||||
|
||||
// Translated /docs pages (2026-11-03): the tarball carries the docs mirrors under dist/docs, and
|
||||
// the sanitizer that renders them imports jsdom, which npm installs as a declared dependency.
|
||||
// Either one missing and every translated page silently falls back to English.
|
||||
export const REQUIRED_DOCS_I18N_RUNTIME_FILES = Object.freeze([
|
||||
"dist/docs/i18n/pt-BR/docs/getting-started/QUICK-START.md",
|
||||
"node_modules/jsdom/package.json",
|
||||
]);
|
||||
// /docs runtime (2026-11-17): the npm package ships no translated docs mirrors. With them the
|
||||
// 3.8.54 tarball reached 206.1 MB and the registry answered 413, so npm installs serve /docs in
|
||||
// English. jsdom (the sanitizer behind translated pages) stays a declared dependency, and a
|
||||
// dist/docs/i18n tree in the installed package means the mirrors came back into the tarball.
|
||||
export const REQUIRED_DOCS_RUNTIME_FILES = Object.freeze(["node_modules/jsdom/package.json"]);
|
||||
export const FORBIDDEN_DOCS_RUNTIME_PATHS = Object.freeze(["dist/docs/i18n"]);
|
||||
|
||||
/** Parse `npm pack --json` output into the generated tarball filename. */
|
||||
export function pickTarball(packJsonOutput) {
|
||||
@@ -91,12 +90,18 @@ export function findMissingMachineTokenRuntimeFiles(packageRoot, exists = fs.exi
|
||||
);
|
||||
}
|
||||
|
||||
export function findMissingDocsI18nRuntimeFiles(packageRoot, exists = fs.existsSync) {
|
||||
return REQUIRED_DOCS_I18N_RUNTIME_FILES.filter(
|
||||
export function findMissingDocsRuntimeFiles(packageRoot, exists = fs.existsSync) {
|
||||
return REQUIRED_DOCS_RUNTIME_FILES.filter(
|
||||
(relativePath) => !exists(path.join(packageRoot, relativePath))
|
||||
);
|
||||
}
|
||||
|
||||
export function findForbiddenDocsRuntimePaths(packageRoot, exists = fs.existsSync) {
|
||||
return FORBIDDEN_DOCS_RUNTIME_PATHS.filter((relativePath) =>
|
||||
exists(path.join(packageRoot, relativePath))
|
||||
);
|
||||
}
|
||||
|
||||
export function evaluateMachineTokenAuth({
|
||||
cliToken,
|
||||
unauthenticatedStatus,
|
||||
@@ -470,13 +475,19 @@ async function main() {
|
||||
);
|
||||
}
|
||||
log("installed package contains the node-machine-id runtime");
|
||||
const missingDocsI18nFiles = findMissingDocsI18nRuntimeFiles(packageRoot);
|
||||
if (missingDocsI18nFiles.length > 0) {
|
||||
const missingDocsFiles = findMissingDocsRuntimeFiles(packageRoot);
|
||||
if (missingDocsFiles.length > 0) {
|
||||
throw new Error(
|
||||
`installed package is missing the translated-docs runtime contract: ${missingDocsI18nFiles.join(", ")}`
|
||||
`installed package is missing the docs runtime contract: ${missingDocsFiles.join(", ")}`
|
||||
);
|
||||
}
|
||||
log("installed package contains the translated docs mirrors and jsdom");
|
||||
const forbiddenDocsPaths = findForbiddenDocsRuntimePaths(packageRoot);
|
||||
if (forbiddenDocsPaths.length > 0) {
|
||||
throw new Error(
|
||||
`installed package carries translated docs mirrors the npm package must not ship: ${forbiddenDocsPaths.join(", ")}`
|
||||
);
|
||||
}
|
||||
log("installed package contains jsdom and no translated docs mirrors");
|
||||
|
||||
const port = pickPort();
|
||||
const dataDir = path.join(tmp, "data");
|
||||
|
||||
@@ -134,8 +134,9 @@ async function renderMirrorMarkdown(
|
||||
*
|
||||
* Returns `null` whenever the English page should be served instead: default locale, no mirror
|
||||
* for this page or locale, or a mirror that cannot be read or rendered. A bad translation must
|
||||
* never take the docs page down. npm, Docker and Electron builds ship the mirrors this reads
|
||||
* (scripts/build/docsMirrorRuntime.mjs decides which).
|
||||
* never take the docs page down. Docker and Electron builds ship the mirrors this reads
|
||||
* (scripts/build/docsMirrorRuntime.mjs decides which); the npm package ships none, so npm
|
||||
* installs always get the English page.
|
||||
*/
|
||||
export async function loadTranslatedDoc(
|
||||
slug: string[],
|
||||
|
||||
@@ -8,13 +8,15 @@ import { fileURLToPath } from "node:url";
|
||||
import {
|
||||
REQUIRED_SQLJS_RUNTIME_FILES,
|
||||
REQUIRED_MACHINE_TOKEN_RUNTIME_FILES,
|
||||
REQUIRED_DOCS_I18N_RUNTIME_FILES,
|
||||
FORBIDDEN_DOCS_RUNTIME_PATHS,
|
||||
REQUIRED_DOCS_RUNTIME_FILES,
|
||||
pickTarball,
|
||||
evaluateBoot,
|
||||
pickPort,
|
||||
findMissingSqlJsRuntimeFiles,
|
||||
findMissingMachineTokenRuntimeFiles,
|
||||
findMissingDocsI18nRuntimeFiles,
|
||||
findForbiddenDocsRuntimePaths,
|
||||
findMissingDocsRuntimeFiles,
|
||||
evaluateMachineTokenAuth,
|
||||
evaluateSqlJsRoundTrip,
|
||||
evaluateRestartPersistence,
|
||||
@@ -85,19 +87,33 @@ test("installed package contract requires sql.js metadata, entrypoint, and WASM"
|
||||
);
|
||||
});
|
||||
|
||||
test("installed package contract requires the translated docs mirrors and jsdom", () => {
|
||||
const present = new Set(REQUIRED_DOCS_I18N_RUNTIME_FILES.map((file) => path.join("/pkg", file)));
|
||||
test("installed package contract requires jsdom and no translated docs mirrors", () => {
|
||||
// 2026-11-17: the npm package no longer ships docs/i18n (the 3.8.54 tarball hit npm's 413).
|
||||
assert.deepEqual([...REQUIRED_DOCS_RUNTIME_FILES], ["node_modules/jsdom/package.json"]);
|
||||
assert.deepEqual([...FORBIDDEN_DOCS_RUNTIME_PATHS], ["dist/docs/i18n"]);
|
||||
|
||||
// jsdom is a declared dependency, so npm places it at <packageRoot>/node_modules.
|
||||
const present = new Set([path.join("/pkg", "node_modules/jsdom/package.json")]);
|
||||
assert.deepEqual(
|
||||
findMissingDocsI18nRuntimeFiles("/pkg", (file) => present.has(file)),
|
||||
findMissingDocsRuntimeFiles("/pkg", (file) => present.has(file)),
|
||||
[]
|
||||
);
|
||||
assert.deepEqual(
|
||||
findForbiddenDocsRuntimePaths("/pkg", (file) => present.has(file)),
|
||||
[]
|
||||
);
|
||||
|
||||
// jsdom is a declared dependency, so npm places it at <packageRoot>/node_modules.
|
||||
present.delete(path.join("/pkg", "node_modules/jsdom/package.json"));
|
||||
present.delete(path.join("/pkg", "dist/docs/i18n/pt-BR/docs/getting-started/QUICK-START.md"));
|
||||
assert.deepEqual(
|
||||
findMissingDocsI18nRuntimeFiles("/pkg", (file) => present.has(file)),
|
||||
["dist/docs/i18n/pt-BR/docs/getting-started/QUICK-START.md", "node_modules/jsdom/package.json"]
|
||||
findMissingDocsRuntimeFiles("/pkg", (file) => present.has(file)),
|
||||
["node_modules/jsdom/package.json"]
|
||||
);
|
||||
|
||||
// The mirrors coming back into the tarball fails the smoke.
|
||||
present.add(path.join("/pkg", "dist/docs/i18n"));
|
||||
assert.deepEqual(
|
||||
findForbiddenDocsRuntimePaths("/pkg", (file) => present.has(file)),
|
||||
["dist/docs/i18n"]
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
49
tests/unit/docs-i18n-render-missing-mirror.test.ts
Normal file
49
tests/unit/docs-i18n-render-missing-mirror.test.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* npm installs ship no translated docs mirrors since 2026-11-17 (the 3.8.54 tarball hit the
|
||||
* registry's 413 limit). The /docs route must then serve the English page: loadTranslatedDoc
|
||||
* returns null when docs/i18n is absent, instead of throwing or rendering an empty page.
|
||||
*/
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
import { loadTranslatedDoc } from "../../src/lib/docsI18nRender.ts";
|
||||
|
||||
test("loadTranslatedDoc falls back to English when the install has no docs/i18n tree", async (t) => {
|
||||
const docsRoot = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-docs-no-i18n-"));
|
||||
t.after(() => fs.rmSync(docsRoot, { recursive: true, force: true }));
|
||||
fs.mkdirSync(path.join(docsRoot, "getting-started"), { recursive: true });
|
||||
fs.writeFileSync(path.join(docsRoot, "getting-started", "QUICK-START.md"), "# Quick start\n");
|
||||
|
||||
for (const locale of ["pt-BR", "zh-CN", "fa"]) {
|
||||
assert.equal(
|
||||
await loadTranslatedDoc(["getting-started", "quick-start"], locale, [], docsRoot),
|
||||
null,
|
||||
locale
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("loadTranslatedDoc falls back to English when only some locales ship mirrors", async (t) => {
|
||||
const docsRoot = fs.mkdtempSync(path.join(os.tmpdir(), "omniroute-docs-partial-i18n-"));
|
||||
t.after(() => fs.rmSync(docsRoot, { recursive: true, force: true }));
|
||||
const mirrorDir = path.join(docsRoot, "i18n", "pt-BR", "docs", "getting-started");
|
||||
fs.mkdirSync(mirrorDir, { recursive: true });
|
||||
fs.writeFileSync(path.join(mirrorDir, "QUICK-START.md"), "# Início rápido\n\nTexto.\n");
|
||||
|
||||
const translated = await loadTranslatedDoc(
|
||||
["getting-started", "quick-start"],
|
||||
"pt-BR",
|
||||
[],
|
||||
docsRoot
|
||||
);
|
||||
assert.ok(translated, "the pt-BR mirror that exists is still served");
|
||||
assert.match(translated.html, /Texto\./);
|
||||
|
||||
assert.equal(
|
||||
await loadTranslatedDoc(["getting-started", "quick-start"], "es", [], docsRoot),
|
||||
null
|
||||
);
|
||||
});
|
||||
@@ -1,11 +1,13 @@
|
||||
/**
|
||||
* 2026-11-03 (owner decision): npm and Docker installs serve the translated /docs pages
|
||||
* (#18699), so both ship the docs mirrors the route reads and nothing else from docs/i18n.
|
||||
* 2026-11-03 (owner decision): Docker installs serve the translated /docs pages (#18699), so the
|
||||
* image ships the docs mirrors the route reads and nothing else from docs/i18n. npm shipped them
|
||||
* too until 2026-11-17, when they pushed the 3.8.54 tarball to 206.1 MB and the registry
|
||||
* answered 413 (owner decision: npm installs serve /docs in English).
|
||||
*
|
||||
* One rule (scripts/build/docsMirrorRuntime.mjs) decides what that is. This file pins it to
|
||||
* source.config.ts, to the npm pack policy, and to .dockerignore, checked against the real
|
||||
* docs/i18n tree, and checks that jsdom (the sanitizer behind every translated page) is a
|
||||
* runtime dependency an npm install actually gets.
|
||||
* One rule (scripts/build/docsMirrorRuntime.mjs) decides what the runtime mirrors are. This file
|
||||
* pins it to source.config.ts and to .dockerignore, checked against the real docs/i18n tree,
|
||||
* checks that the npm pack policy keeps every docs/i18n file out, and checks that jsdom (the
|
||||
* sanitizer behind every translated page) is a runtime dependency.
|
||||
*/
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
@@ -22,10 +24,13 @@ import {
|
||||
APP_STAGING_ALLOWED_EXACT_PATHS,
|
||||
APP_STAGING_ALLOWED_PATH_MATCHERS,
|
||||
APP_STAGING_ALLOWED_PATH_PREFIXES,
|
||||
APP_STAGING_REMOVAL_PATHS,
|
||||
PACK_ARTIFACT_ALLOWED_EXACT_PATHS,
|
||||
PACK_ARTIFACT_ALLOWED_PATH_MATCHERS,
|
||||
PACK_ARTIFACT_ALLOWED_PATH_PREFIXES,
|
||||
PACK_ARTIFACT_MAX_PACKED_BYTES,
|
||||
PACK_ARTIFACT_REQUIRED_PATHS,
|
||||
exceedsPackedSizeBudget,
|
||||
findUnexpectedArtifactPaths,
|
||||
} from "../../scripts/build/pack-artifact-policy.ts";
|
||||
import { resolveSafeI18nSectionDir } from "../../src/lib/docsI18nPath.ts";
|
||||
@@ -128,7 +133,12 @@ test("every shipped mirror is a file the route's path guard resolves to", () =>
|
||||
}
|
||||
});
|
||||
|
||||
test("the npm pack policy allows the runtime mirrors under dist/ and nothing else in docs/i18n", () => {
|
||||
test("the npm pack policy keeps every docs/i18n file out of dist/", () => {
|
||||
assert.ok(
|
||||
APP_STAGING_REMOVAL_PATHS.includes("docs/i18n"),
|
||||
"prepublish must drop the whole docs/i18n tree from the staged dist/"
|
||||
);
|
||||
|
||||
const stagedI18n = ALL_I18N_FILES;
|
||||
const unexpectedStaged = findUnexpectedArtifactPaths(stagedI18n, {
|
||||
exactPaths: APP_STAGING_ALLOWED_EXACT_PATHS,
|
||||
@@ -138,8 +148,8 @@ test("the npm pack policy allows the runtime mirrors under dist/ and nothing els
|
||||
});
|
||||
assert.deepEqual(
|
||||
stagedI18n.filter((file) => !unexpectedStaged.includes(file)),
|
||||
RUNTIME_MIRRORS,
|
||||
"prepublish's staging prune must keep exactly the runtime mirrors"
|
||||
[],
|
||||
"prepublish's staging prune must keep no docs/i18n file"
|
||||
);
|
||||
|
||||
const packed = ALL_I18N_FILES.map((file) => `dist/${file}`);
|
||||
@@ -150,7 +160,8 @@ test("the npm pack policy allows the runtime mirrors under dist/ and nothing els
|
||||
});
|
||||
assert.deepEqual(
|
||||
packed.filter((file) => !unexpectedPacked.includes(file)),
|
||||
RUNTIME_MIRRORS.map((file) => `dist/${file}`)
|
||||
[],
|
||||
"check:pack-artifact must reject any docs/i18n file in the tarball"
|
||||
);
|
||||
|
||||
// The tarball root never carries mirrors: only dist/ does.
|
||||
@@ -164,10 +175,21 @@ test("the npm pack policy allows the runtime mirrors under dist/ and nothing els
|
||||
);
|
||||
});
|
||||
|
||||
test("the pack gate fails when the mirrors vanish from the tarball", () => {
|
||||
const sample = "dist/docs/i18n/pt-BR/docs/getting-started/QUICK-START.md";
|
||||
assert.ok(PACK_ARTIFACT_REQUIRED_PATHS.includes(sample));
|
||||
assert.ok(RUNTIME_MIRRORS.includes(sample.slice("dist/".length)));
|
||||
test("the pack gate no longer requires a docs mirror in the tarball", () => {
|
||||
assert.deepEqual(
|
||||
PACK_ARTIFACT_REQUIRED_PATHS.filter((required) => required.startsWith("dist/docs/i18n/")),
|
||||
[]
|
||||
);
|
||||
});
|
||||
|
||||
test("the pack gate fails a tarball over the packed-size budget", () => {
|
||||
// npm rejected 3.8.54 (206.1 MB packed) with E413; 3.8.53 (193.6 MB) went through.
|
||||
assert.ok(PACK_ARTIFACT_MAX_PACKED_BYTES < 193_600_000);
|
||||
assert.equal(exceedsPackedSizeBudget(206_100_000), true);
|
||||
assert.equal(exceedsPackedSizeBudget(PACK_ARTIFACT_MAX_PACKED_BYTES + 1), true);
|
||||
assert.equal(exceedsPackedSizeBudget(PACK_ARTIFACT_MAX_PACKED_BYTES), false);
|
||||
assert.equal(exceedsPackedSizeBudget(110_000_000), false);
|
||||
assert.equal(exceedsPackedSizeBudget(Number.NaN), false);
|
||||
});
|
||||
|
||||
test("the .dockerignore helper follows Docker's last-match-wins and parent-directory rules", () => {
|
||||
|
||||
@@ -342,8 +342,6 @@ test("findMissingArtifactPaths flags missing root runtime files in the tarball",
|
||||
"config/release/wreq-js-native-manifest.json",
|
||||
"config/release/wreq-js-rust-license-inventory.json",
|
||||
"config/release/wreq-js-rust-notices.md",
|
||||
// 2026-11-03: one translated docs mirror, so losing the mirrors fails the pack gate.
|
||||
"dist/docs/i18n/pt-BR/docs/getting-started/QUICK-START.md",
|
||||
"dist/h2c-upgrade-guard.cjs",
|
||||
"dist/head-response-guard.cjs",
|
||||
"dist/http-method-guard.cjs",
|
||||
|
||||
Reference in New Issue
Block a user