@v-office/site-checks 0.4.0 → 0.4.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/README.md +9 -2
- package/dist/bin.mjs +1 -1
- package/dist/{cli-632ORKer.mjs → cli-CYG52KHL.mjs} +77 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/instructions/CHANGELOG.md +1 -0
- package/instructions/MIGRATION.md +1 -0
- package/instructions/versions/0.4.1/CHANGELOG.md +9 -0
- package/instructions/versions/0.4.1/MIGRATION.md +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,16 +25,20 @@ pnpm add --save-exact --save-dev @v-office/site-checks
|
|
|
25
25
|
{
|
|
26
26
|
"scripts": {
|
|
27
27
|
"check:src": "site-checks src",
|
|
28
|
-
"check:dist": "site-checks dist"
|
|
28
|
+
"check:dist": "site-checks dist",
|
|
29
|
+
"check:all": "site-checks verify"
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
```
|
|
32
33
|
|
|
34
|
+
A pre-push hook (`.githooks/pre-push`) runs `pnpm exec site-checks verify` on a push to `main`.
|
|
35
|
+
|
|
33
36
|
The scripts are for developers; the build worker never runs the site's installed copy, it runs
|
|
34
37
|
both stages from its own. Nothing goes into `astro.config`.
|
|
35
38
|
|
|
36
39
|
```
|
|
37
40
|
site-checks <src | dist> [--root <dir>] [--dist <dir>] [--site <url>] [--report <file>]
|
|
41
|
+
site-checks verify [--root <dir>] [--site <url>]
|
|
38
42
|
```
|
|
39
43
|
|
|
40
44
|
- `src` runs the source checks over the project. It never reads `dist/`, so it gives the same
|
|
@@ -48,8 +52,11 @@ site-checks <src | dist> [--root <dir>] [--dist <dir>] [--site <url>] [--report
|
|
|
48
52
|
do for a preview host. `trailingSlash` is read from the config file the same way. The checks
|
|
49
53
|
read `src/` and `public/` under the root (Astro's default layout); a config that names `root`,
|
|
50
54
|
`srcDir` or `publicDir` stops the command.
|
|
55
|
+
- `verify` runs what the build worker runs, in its order, and stops at the first failure: `src`,
|
|
56
|
+
`astro check` (skipped without `@astrojs/check`), the `build` script (pnpm or npm) and `dist`.
|
|
51
57
|
|
|
52
|
-
Exit codes: 0 when nothing refused, 1 when a check with severity `error` found something
|
|
58
|
+
Exit codes: 0 when nothing refused, 1 when a check with severity `error` found something (for `verify`,
|
|
59
|
+
also when `astro check` or the build fails), 2 on a
|
|
53
60
|
usage or configuration error (a `site-checks.config.json` that cannot be read stops the command).
|
|
54
61
|
|
|
55
62
|
A refused stage ends with the failing checks and their first findings:
|
package/dist/bin.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { parseHTML } from "linkedom";
|
|
4
4
|
import { brotliCompressSync, constants } from "node:zlib";
|
|
5
5
|
import os from "node:os";
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
6
7
|
import { parseArgs } from "node:util";
|
|
7
8
|
//#region src/jsComments.ts
|
|
8
9
|
/** One pass over JavaScript (or the script parts of a component): its comments, and the code with
|
|
@@ -2986,10 +2987,12 @@ const runStage = async (stage, input) => {
|
|
|
2986
2987
|
};
|
|
2987
2988
|
//#endregion
|
|
2988
2989
|
//#region src/cli.ts
|
|
2989
|
-
const USAGE = `Usage: site-checks <src | dist> [options]
|
|
2990
|
+
const USAGE = `Usage: site-checks <src | dist | verify> [options]
|
|
2990
2991
|
|
|
2991
2992
|
src the source checks, before the build (reads the project, never dist/)
|
|
2992
2993
|
dist the checks over the built output, after the build
|
|
2994
|
+
verify what AI Studio's build runs, stopping at the first failure: src, astro check, the
|
|
2995
|
+
build script, dist (--root and --site only)
|
|
2993
2996
|
|
|
2994
2997
|
Options:
|
|
2995
2998
|
--root <dir> the project (default: the current directory)
|
|
@@ -2998,8 +3001,9 @@ Options:
|
|
|
2998
3001
|
--report <file> write the report as JSON here (default for dist: <dist>/${SITE_CHECKS_FILE})
|
|
2999
3002
|
-h, --help this text
|
|
3000
3003
|
|
|
3001
|
-
Exits 0 when nothing refused, 1 when a check with severity error found something
|
|
3002
|
-
or configuration error. Data for the checks:
|
|
3004
|
+
Exits 0 when nothing refused, 1 when a check with severity error found something or (verify)
|
|
3005
|
+
astro check or the build failed, 2 on a usage or configuration error. Data for the checks:
|
|
3006
|
+
${CONFIG_FILE} at the project root.`;
|
|
3003
3007
|
const STAGES = ["src", "dist"];
|
|
3004
3008
|
const isStage = (value) => value !== void 0 && STAGES.includes(value);
|
|
3005
3009
|
const isUrl = (value) => {
|
|
@@ -3052,6 +3056,7 @@ async function cli(argv, io, cwd = process.cwd()) {
|
|
|
3052
3056
|
return 0;
|
|
3053
3057
|
}
|
|
3054
3058
|
const [stage, ...rest] = positionals;
|
|
3059
|
+
if (stage === "verify" && rest.length === 0 && values.dist === void 0 && values.report === void 0) return verify(path.resolve(cwd, values.root ?? "."), values.site, io, cwd);
|
|
3055
3060
|
if (!isStage(stage) || rest.length > 0) {
|
|
3056
3061
|
io.err(USAGE);
|
|
3057
3062
|
return 2;
|
|
@@ -3099,5 +3104,74 @@ async function cli(argv, io, cwd = process.cwd()) {
|
|
|
3099
3104
|
io.out(`[site-checks] ${stage}: ${report.results.length} checks, nothing refused` + (shown ? ` (report: ${shown})` : ""));
|
|
3100
3105
|
return 0;
|
|
3101
3106
|
}
|
|
3107
|
+
/** Runs a child in the project with its output on ours: 0, 1 when it fails, 2 when it cannot
|
|
3108
|
+
* start. No stdin: a pre-push hook's stdin holds git's refs. */
|
|
3109
|
+
const exec = (command, args, root, env, io) => new Promise((resolve) => {
|
|
3110
|
+
const child = spawn(command, args, {
|
|
3111
|
+
cwd: root,
|
|
3112
|
+
env,
|
|
3113
|
+
stdio: [
|
|
3114
|
+
"ignore",
|
|
3115
|
+
"inherit",
|
|
3116
|
+
"inherit"
|
|
3117
|
+
]
|
|
3118
|
+
});
|
|
3119
|
+
child.on("error", (err) => {
|
|
3120
|
+
io.err(`site-checks: cannot run ${command}: ${err.message}`);
|
|
3121
|
+
resolve(2);
|
|
3122
|
+
});
|
|
3123
|
+
child.on("close", (code) => resolve(code === 0 ? 0 : 1));
|
|
3124
|
+
});
|
|
3125
|
+
/**
|
|
3126
|
+
* `site-checks verify`: the build worker's sequence (services/worker/src/builder.ts), stopping at
|
|
3127
|
+
* the first failure: the src stage, `astro check` (skipped without @astrojs/check, as the worker
|
|
3128
|
+
* reports it), the project's build script, the dist stage. `astro check` and the build share one
|
|
3129
|
+
* CONTENT_SYNC_TOKEN, as the worker's `buildEnv`, so a content loader syncs the PMS once.
|
|
3130
|
+
*/
|
|
3131
|
+
async function verify(root, site, io, cwd) {
|
|
3132
|
+
let pkg;
|
|
3133
|
+
try {
|
|
3134
|
+
pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
3135
|
+
} catch {
|
|
3136
|
+
pkg = void 0;
|
|
3137
|
+
}
|
|
3138
|
+
if (typeof pkg?.scripts?.build !== "string") {
|
|
3139
|
+
io.err(`site-checks: no \`build\` script in ${path.join(root, "package.json")}.`);
|
|
3140
|
+
return 2;
|
|
3141
|
+
}
|
|
3142
|
+
const pm = fs.existsSync(path.join(root, "pnpm-lock.yaml")) || String(pkg.packageManager).startsWith("pnpm@") ? "pnpm" : "npm";
|
|
3143
|
+
const env = {
|
|
3144
|
+
...process.env,
|
|
3145
|
+
CONTENT_SYNC_TOKEN: `${process.pid}-${Date.now()}`
|
|
3146
|
+
};
|
|
3147
|
+
const stageArgs = [
|
|
3148
|
+
"--root",
|
|
3149
|
+
root,
|
|
3150
|
+
...site !== void 0 ? ["--site", site] : []
|
|
3151
|
+
];
|
|
3152
|
+
const steps = [
|
|
3153
|
+
["src", () => cli(["src", ...stageArgs], io, cwd)],
|
|
3154
|
+
["astro check", async () => {
|
|
3155
|
+
if (fs.existsSync(path.join(root, "node_modules/@astrojs/check"))) return exec(path.join(root, "node_modules/.bin/astro"), ["check"], root, env, io);
|
|
3156
|
+
io.out("[site-checks] astro check skipped: @astrojs/check is not installed.");
|
|
3157
|
+
return "skipped";
|
|
3158
|
+
}],
|
|
3159
|
+
["build", () => exec(pm, ["run", "build"], root, env, io)],
|
|
3160
|
+
["dist", () => cli(["dist", ...stageArgs], io, cwd)]
|
|
3161
|
+
];
|
|
3162
|
+
const passed = [];
|
|
3163
|
+
for (const [name, step] of steps) {
|
|
3164
|
+
io.out(`[site-checks] verify: ${name === "build" ? `build (${pm} run build)` : name}`);
|
|
3165
|
+
const code = await step();
|
|
3166
|
+
if (code === "skipped") continue;
|
|
3167
|
+
if (code !== 0) {
|
|
3168
|
+
io.err(`[site-checks] verify stopped at ${name}; passed: ${passed.join(", ") || "none"}`);
|
|
3169
|
+
return code;
|
|
3170
|
+
}
|
|
3171
|
+
passed.push(name);
|
|
3172
|
+
}
|
|
3173
|
+
io.out(`[site-checks] verify passed: ${passed.join(", ")}`);
|
|
3174
|
+
return 0;
|
|
3175
|
+
}
|
|
3102
3176
|
//#endregion
|
|
3103
3177
|
export { loadOptions as _, runDistChecks as a, readAstroConfig as b, refusalMessage as c, MAX_FINDINGS_PER_CHECK as d, MAX_MESSAGE_CHARS as f, CONFIG_FILE as g, runSiteChecks as h, distChecks as i, summarizeBlocking as l, blockingResults as m, cli as n, SITE_CHECKS_FILE as o, MAX_PATH_CHARS as p, runStage as r, findingLine as s, USAGE as t, summaryLines as u, checks as v, checksOf as y };
|
package/dist/index.d.mts
CHANGED
|
@@ -242,7 +242,7 @@ type Io = {
|
|
|
242
242
|
out: (line: string) => void;
|
|
243
243
|
err: (line: string) => void;
|
|
244
244
|
};
|
|
245
|
-
export declare const USAGE = "Usage: site-checks <src | dist> [options]\n\n src the source checks, before the build (reads the project, never dist/)\n dist the checks over the built output, after the build\n\nOptions:\n --root <dir> the project (default: the current directory)\n --dist <dir> the build output, relative to the root (default: dist; dist stage only)\n --site <url> the site's public URL (default: `site` in the Astro config file)\n --report <file> write the report as JSON here (default for dist: <dist>/site-checks.json)\n -h, --help this text\n\nExits 0 when nothing refused, 1 when a check with severity error found something, 2 on a usage
|
|
245
|
+
export declare const USAGE = "Usage: site-checks <src | dist | verify> [options]\n\n src the source checks, before the build (reads the project, never dist/)\n dist the checks over the built output, after the build\n verify what AI Studio's build runs, stopping at the first failure: src, astro check, the\n build script, dist (--root and --site only)\n\nOptions:\n --root <dir> the project (default: the current directory)\n --dist <dir> the build output, relative to the root (default: dist; dist stage only)\n --site <url> the site's public URL (default: `site` in the Astro config file)\n --report <file> write the report as JSON here (default for dist: <dist>/site-checks.json)\n -h, --help this text\n\nExits 0 when nothing refused, 1 when a check with severity error found something or (verify)\nastro check or the build failed, 2 on a usage or configuration error. Data for the checks:\nsite-checks.config.json at the project root.";
|
|
246
246
|
/** The command line. Returns the exit code; prints to `io`. */
|
|
247
247
|
export declare function cli(argv: readonly string[], io: Io, cwd?: string): Promise<number>;
|
|
248
248
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as loadOptions, a as runDistChecks, b as readAstroConfig, c as refusalMessage, d as MAX_FINDINGS_PER_CHECK, f as MAX_MESSAGE_CHARS, g as CONFIG_FILE, h as runSiteChecks, i as distChecks, l as summarizeBlocking, m as blockingResults, n as cli, o as SITE_CHECKS_FILE, p as MAX_PATH_CHARS, r as runStage, s as findingLine, t as USAGE, u as summaryLines, v as checks, y as checksOf } from "./cli-
|
|
1
|
+
import { _ as loadOptions, a as runDistChecks, b as readAstroConfig, c as refusalMessage, d as MAX_FINDINGS_PER_CHECK, f as MAX_MESSAGE_CHARS, g as CONFIG_FILE, h as runSiteChecks, i as distChecks, l as summarizeBlocking, m as blockingResults, n as cli, o as SITE_CHECKS_FILE, p as MAX_PATH_CHARS, r as runStage, s as findingLine, t as USAGE, u as summaryLines, v as checks, y as checksOf } from "./cli-CYG52KHL.mjs";
|
|
2
2
|
export { CONFIG_FILE, MAX_FINDINGS_PER_CHECK, MAX_MESSAGE_CHARS, MAX_PATH_CHARS, SITE_CHECKS_FILE, USAGE, blockingResults, checks, checksOf, cli, distChecks, findingLine, loadOptions, readAstroConfig, refusalMessage, runDistChecks, runSiteChecks, runStage, summarizeBlocking, summaryLines };
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Release notes of `@v-office/site-checks`, newest first. Each version has its own directory.
|
|
6
6
|
|
|
7
|
+
- `versions/0.4.1/CHANGELOG.md`: release notes for 0.4.1
|
|
7
8
|
- `versions/0.4.0/CHANGELOG.md`: release notes for 0.4.0
|
|
8
9
|
- `versions/0.3.3/CHANGELOG.md`: release notes for 0.3.3
|
|
9
10
|
- `versions/0.3.2/CHANGELOG.md`: release notes for 0.3.2
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Migration guides of `@v-office/site-checks`, newest first. Apply them in order when skipping versions.
|
|
6
6
|
|
|
7
|
+
- `versions/0.4.1/MIGRATION.md`: Migration: 0.4.0 to 0.4.1
|
|
7
8
|
- `versions/0.4.0/MIGRATION.md`: Migration: 0.3.3 to 0.4.0
|
|
8
9
|
- `versions/0.3.3/MIGRATION.md`: Migration: 0.3.2 to 0.3.3
|
|
9
10
|
- `versions/0.3.2/MIGRATION.md`: Migration: 0.3.1 to 0.3.2
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changelog: 0.4.1
|
|
2
|
+
|
|
3
|
+
## Added
|
|
4
|
+
|
|
5
|
+
- `site-checks verify [--root <dir>] [--site <url>]` runs what AI Studio's build runs, in its
|
|
6
|
+
order, and stops at the first failure: the `src` stage, `astro check` (skipped without
|
|
7
|
+
`@astrojs/check`), the site's `build` script (pnpm or npm), the `dist` stage.
|
|
8
|
+
- Exit codes: 0 when nothing failed (warnings pass), 1 when `astro check` or the build fails or a
|
|
9
|
+
check with severity `error` finds something, 2 on a usage or configuration error.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-office/site-checks",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "The checks over a v-office website in two stages, `site-checks src` before the build and `site-checks dist` after it, which AI Studio's build worker runs on every build from its own pinned copy; the report has the shape of the build worker's dist-check report, and a site excludes the findings it accepts in site-checks.config.json",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|