@hublo/sentinel 1.7.0-alpha.22 → 1.7.0-alpha.23
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 +0 -2
- package/dist/bin/sentinel.js +44 -17
- package/dist/{chunk-VSUHHETH.js → chunk-426EFSK7.js} +4191 -5134
- package/dist/{chunk-PMRL4MH6.js → chunk-4YQXLPJ5.js} +2 -2
- package/dist/{chunk-F3Q3JQJ6.js → chunk-7JTCUK77.js} +3 -5
- package/dist/{chunk-LX7EG6PJ.js → chunk-CSZW7OMC.js} +8 -6
- package/dist/chunk-CSZW7OMC.js.map +1 -0
- package/dist/chunk-F5WISUN3.js +17 -0
- package/dist/chunk-F5WISUN3.js.map +1 -0
- package/dist/chunk-FY3P5QPH.js +15 -0
- package/dist/chunk-FY3P5QPH.js.map +1 -0
- package/dist/chunk-NE3IEJBN.js +59 -0
- package/dist/chunk-NE3IEJBN.js.map +1 -0
- package/dist/chunk-VWASE6NN.js +34 -0
- package/dist/chunk-VWASE6NN.js.map +1 -0
- package/dist/{chunk-JT7ZMH44.js → chunk-ZNANJEMK.js} +16 -30
- package/dist/chunk-ZNANJEMK.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -6
- package/dist/roles/runtime-analysis/config.d.ts +92 -0
- package/dist/roles/runtime-analysis/config.js +10 -0
- package/dist/roles/runtime-analysis/gateway.d.ts +2 -0
- package/dist/roles/runtime-analysis/gateway.js +82 -0
- package/dist/roles/runtime-analysis/gateway.js.map +1 -0
- package/dist/roles/runtime-analysis/mock-api.d.ts +2 -0
- package/dist/roles/runtime-analysis/mock-api.js +43 -0
- package/dist/roles/runtime-analysis/mock-api.js.map +1 -0
- package/dist/roles/static-analysis/config.js +1 -2
- package/dist/roles/test/setup/jest-parity.js +2 -2
- package/dist/roles/test/setup/workspace-entry.js +2 -2
- package/dist/{validate-IES226NX.js → validate-GD63SP6M.js} +2 -2
- package/docs/typescript-traces.md +2 -218
- package/docs/using-sentinel.md +1 -2
- package/package.json +9 -6
- package/runtime-analysis-deps/load.mjs +6 -0
- package/runtime-analysis-deps/package-lock.json +1766 -0
- package/runtime-analysis-deps/package.json +11 -0
- package/dist/chunk-JT7ZMH44.js.map +0 -1
- package/dist/chunk-LX7EG6PJ.js.map +0 -1
- package/dist/chunk-NGLEGAEN.js +0 -190
- package/dist/chunk-NGLEGAEN.js.map +0 -1
- package/dist/chunk-PXTU5MPW.js +0 -9
- package/dist/chunk-PXTU5MPW.js.map +0 -1
- package/dist/roles/sql/config.d.ts +0 -68
- package/dist/roles/sql/config.js +0 -8
- package/docs/sql-adoption.md +0 -573
- /package/dist/{chunk-PMRL4MH6.js.map → chunk-4YQXLPJ5.js.map} +0 -0
- /package/dist/roles/{sql → runtime-analysis}/config.js.map +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
declare const METHODS: readonly ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
2
|
+
type Method = (typeof METHODS)[number];
|
|
3
|
+
/** One entry of a front's `api` list, as written. */
|
|
4
|
+
interface ApiEntry {
|
|
5
|
+
method?: Method;
|
|
6
|
+
path: string;
|
|
7
|
+
status?: number;
|
|
8
|
+
/** The JSON answered, relative to the module. */
|
|
9
|
+
file: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** The one interaction a screen's flow performs, timed for INP. */
|
|
13
|
+
type Interaction = {
|
|
14
|
+
click: string;
|
|
15
|
+
} | {
|
|
16
|
+
clickText: string;
|
|
17
|
+
} | {
|
|
18
|
+
type: {
|
|
19
|
+
selector: string;
|
|
20
|
+
text: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/** A screen measured: the route that renders it, the path opened, and what proves it opened. */
|
|
24
|
+
interface Screen {
|
|
25
|
+
id: string;
|
|
26
|
+
/** The route file, relative to `router.routes`: a change to what it loads measures it. */
|
|
27
|
+
route: string;
|
|
28
|
+
/** The path opened, starting with `/`. */
|
|
29
|
+
path: string;
|
|
30
|
+
/** Texts the screen shows once opened: each must be visible before the figures count. */
|
|
31
|
+
expectText: string[];
|
|
32
|
+
interact: Interaction;
|
|
33
|
+
/** Rows the screen must list once opened, by count or at least a minimum. */
|
|
34
|
+
rows?: {
|
|
35
|
+
selector: string;
|
|
36
|
+
count?: number;
|
|
37
|
+
min?: number;
|
|
38
|
+
};
|
|
39
|
+
/** An element that must be there once opened. */
|
|
40
|
+
expectSelector?: string;
|
|
41
|
+
}
|
|
42
|
+
/** What a front's config file passes to `defineRuntimeAnalysis`. */
|
|
43
|
+
interface RuntimeAnalysisInput {
|
|
44
|
+
/** The front's own directory, normally `import.meta.dirname`. */
|
|
45
|
+
root?: string;
|
|
46
|
+
/** The path the app is served under: the rest goes to the mocks. Or `mockPrefixes`, not both. */
|
|
47
|
+
basePath?: string;
|
|
48
|
+
/** The paths sent to the mocks, for an app served at the root. Or `basePath`, not both. */
|
|
49
|
+
mockPrefixes?: string[];
|
|
50
|
+
/** The app's health path, answered once it is up. */
|
|
51
|
+
health: string;
|
|
52
|
+
/** The call that tells the app is ready (a session): answered by the mocks, with 200. */
|
|
53
|
+
ready: string;
|
|
54
|
+
build: {
|
|
55
|
+
/** The build output, relative to the front. */
|
|
56
|
+
output: string;
|
|
57
|
+
/** The server the output starts with (`node <server>`, `HOST` and `PORT` set). */
|
|
58
|
+
server: string;
|
|
59
|
+
/** The build variables; `{origin}` is the gateway the build is served behind. */
|
|
60
|
+
env: Record<string, string>;
|
|
61
|
+
};
|
|
62
|
+
/** The answers of the calls the screens make. */
|
|
63
|
+
api: ApiEntry[];
|
|
64
|
+
router: {
|
|
65
|
+
/** The tsconfig the route imports are resolved with. */
|
|
66
|
+
tsconfig: string;
|
|
67
|
+
/** The app shell files every screen loads. */
|
|
68
|
+
shell: string[];
|
|
69
|
+
/** The file routes directory (TanStack Router), holding `__root.tsx`. */
|
|
70
|
+
routes: string;
|
|
71
|
+
};
|
|
72
|
+
screens: Screen[];
|
|
73
|
+
/**
|
|
74
|
+
* The translations folder, relative to the front, holding `<lang>/<namespace>.json`: a change
|
|
75
|
+
* to one measures the screens whose code names its namespace, not every screen.
|
|
76
|
+
*/
|
|
77
|
+
translations?: string;
|
|
78
|
+
/**
|
|
79
|
+
* The browser's language, as the screens' expected texts are written (`fr-FR`): a front that
|
|
80
|
+
* picks its language from the browser otherwise renders the runner's. `en-US` when left out.
|
|
81
|
+
*/
|
|
82
|
+
locale?: string;
|
|
83
|
+
}
|
|
84
|
+
/** The browser language when a config names none. */
|
|
85
|
+
declare const DEFAULT_LOCALE: string;
|
|
86
|
+
/** The config as sentinel reads it: what the module passed, marked as defined here. */
|
|
87
|
+
type RuntimeAnalysisConfig = RuntimeAnalysisInput & {
|
|
88
|
+
readonly defined: true;
|
|
89
|
+
};
|
|
90
|
+
declare function defineRuntimeAnalysis(input: RuntimeAnalysisInput): RuntimeAnalysisConfig;
|
|
91
|
+
|
|
92
|
+
export { DEFAULT_LOCALE, type Interaction, type RuntimeAnalysisConfig, type RuntimeAnalysisInput, type Screen, defineRuntimeAnalysis };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadRuntimeConfig
|
|
3
|
+
} from "../../chunk-VWASE6NN.js";
|
|
4
|
+
import "../../chunk-F5WISUN3.js";
|
|
5
|
+
|
|
6
|
+
// src/roles/runtime-analysis/serve/gateway-main.ts
|
|
7
|
+
import { resolve } from "node:path";
|
|
8
|
+
import { parseArgs } from "node:util";
|
|
9
|
+
|
|
10
|
+
// src/roles/runtime-analysis/serve/gateway.ts
|
|
11
|
+
import { appendFileSync, writeFileSync } from "node:fs";
|
|
12
|
+
import http from "node:http";
|
|
13
|
+
var under = (pathname, prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`);
|
|
14
|
+
function isAppPath(pathname, options) {
|
|
15
|
+
const base = (options.basePath ?? "").replace(/\/$/, "");
|
|
16
|
+
return options.mockPrefixes ? !options.mockPrefixes.some((prefix) => under(pathname, prefix)) : under(pathname, base);
|
|
17
|
+
}
|
|
18
|
+
function createGateway(options) {
|
|
19
|
+
writeFileSync(options.log, "");
|
|
20
|
+
const agent = new http.Agent({ keepAlive: true });
|
|
21
|
+
return http.createServer((request, response) => {
|
|
22
|
+
const startedAt = Date.now();
|
|
23
|
+
const { pathname } = new URL(request.url ?? "/", "http://gateway");
|
|
24
|
+
const toApp = isAppPath(pathname, options);
|
|
25
|
+
const port = toApp ? options.appPort : options.mockPort;
|
|
26
|
+
const log = (status, mock, error) => appendFileSync(
|
|
27
|
+
options.log,
|
|
28
|
+
`${JSON.stringify({ at: new Date(startedAt).toISOString(), method: request.method, path: request.url, to: toApp ? "app" : "mock", status, mock, ms: Date.now() - startedAt, ...error ? { error } : {} })}
|
|
29
|
+
`
|
|
30
|
+
);
|
|
31
|
+
const upstream = http.request(
|
|
32
|
+
{
|
|
33
|
+
hostname: "127.0.0.1",
|
|
34
|
+
port,
|
|
35
|
+
path: request.url,
|
|
36
|
+
method: request.method,
|
|
37
|
+
headers: { ...request.headers, host: `127.0.0.1:${port}` },
|
|
38
|
+
agent
|
|
39
|
+
},
|
|
40
|
+
(answer) => {
|
|
41
|
+
response.writeHead(answer.statusCode ?? 502, answer.headers);
|
|
42
|
+
answer.pipe(response);
|
|
43
|
+
answer.on("end", () => log(answer.statusCode, answer.headers["x-cwv-mock"] ?? null));
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
upstream.on("error", (error) => {
|
|
47
|
+
log(502, null, error.code ?? String(error));
|
|
48
|
+
response.writeHead(502, { "content-type": "text/plain" });
|
|
49
|
+
response.end("upstream unreachable");
|
|
50
|
+
});
|
|
51
|
+
request.pipe(upstream);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/roles/runtime-analysis/serve/gateway-main.ts
|
|
56
|
+
var { values: args } = parseArgs({
|
|
57
|
+
options: Object.fromEntries(
|
|
58
|
+
["module", "port", "app-port", "mock-port", "log"].map((key) => [
|
|
59
|
+
key,
|
|
60
|
+
{ type: "string" }
|
|
61
|
+
])
|
|
62
|
+
)
|
|
63
|
+
});
|
|
64
|
+
var loaded = await loadRuntimeConfig(resolve(String(args.module)));
|
|
65
|
+
if (!("config" in loaded)) {
|
|
66
|
+
console.error(`no runtime-analysis config in ${args.module}`);
|
|
67
|
+
process.exit(2);
|
|
68
|
+
}
|
|
69
|
+
createGateway({
|
|
70
|
+
...loaded.config.basePath === void 0 ? {} : { basePath: loaded.config.basePath },
|
|
71
|
+
...loaded.config.mockPrefixes === void 0 ? {} : { mockPrefixes: loaded.config.mockPrefixes },
|
|
72
|
+
appPort: Number(args["app-port"]),
|
|
73
|
+
mockPort: Number(args["mock-port"]),
|
|
74
|
+
log: resolve(String(args.log))
|
|
75
|
+
}).listen(
|
|
76
|
+
Number(args.port),
|
|
77
|
+
"127.0.0.1",
|
|
78
|
+
() => console.log(
|
|
79
|
+
`gateway on http://127.0.0.1:${args.port}, app ${args["app-port"]}, mocks ${args["mock-port"]}`
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
//# sourceMappingURL=gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/roles/runtime-analysis/serve/gateway-main.ts","../../../src/roles/runtime-analysis/serve/gateway.ts"],"sourcesContent":["/**\n * The gateway as its own process: `node gateway.js --module <dir> --port 4101 --app-port 4111\n * --mock-port 4199 --log requests-base.jsonl`. The front's routing is read from its config.\n */\nimport { resolve } from 'node:path'\nimport { parseArgs } from 'node:util'\n\nimport { loadRuntimeConfig } from '../config/resolve.js'\n\nimport { createGateway } from './gateway.js'\n\nconst { values: args } = parseArgs({\n options: Object.fromEntries(\n ['module', 'port', 'app-port', 'mock-port', 'log'].map((key) => [\n key,\n { type: 'string' as const },\n ]),\n ),\n})\nconst loaded = await loadRuntimeConfig(resolve(String(args.module)))\nif (!('config' in loaded)) {\n console.error(`no runtime-analysis config in ${args.module}`)\n process.exit(2)\n}\ncreateGateway({\n ...(loaded.config.basePath === undefined ? {} : { basePath: loaded.config.basePath }),\n ...(loaded.config.mockPrefixes === undefined ? {} : { mockPrefixes: loaded.config.mockPrefixes }),\n appPort: Number(args['app-port']),\n mockPort: Number(args['mock-port']),\n log: resolve(String(args.log)),\n}).listen(Number(args.port), '127.0.0.1', () =>\n console.log(\n `gateway on http://127.0.0.1:${args.port}, app ${args['app-port']}, mocks ${args['mock-port']}`,\n ),\n)\n","/**\n * The gateway, one per build, like an environment's: the front's own paths go to that build's\n * server, every other path to the mock API. A plain proxy, no interception. Every request is logged\n * as one JSON line with its status and whether the mock API handled it, which is how a flow later\n * proves its screen was fed by the mocks and nothing else.\n *\n * Moved from the monorepo's harness (`engine/serve/gateway.mjs`, hublo/monorepo#23672), unchanged\n * in behaviour. It runs in its OWN process (`gateway-main.ts`): proxying from the process that runs\n * Lighthouse would delay the very responses being measured.\n */\nimport { appendFileSync, writeFileSync } from 'node:fs'\nimport http from 'node:http'\n\nexport interface GatewayOptions {\n /** The path the app is served under; the rest is mocked. Or `mockPrefixes`. */\n basePath?: string\n /** The paths mocked, for an app at the root; the rest goes to the app. */\n mockPrefixes?: string[]\n appPort: number\n mockPort: number\n /** The request log, one JSON line per request, emptied at start. */\n log: string\n}\n\nconst under = (pathname: string, prefix: string): boolean =>\n pathname === prefix || pathname.startsWith(`${prefix}/`)\n\n/** Whether a request's path is the app's, by the front's base path or its mocked prefixes. */\nexport function isAppPath(\n pathname: string,\n options: Pick<GatewayOptions, 'basePath' | 'mockPrefixes'>,\n): boolean {\n const base = (options.basePath ?? '').replace(/\\/$/, '')\n return options.mockPrefixes\n ? !options.mockPrefixes.some((prefix) => under(pathname, prefix))\n : under(pathname, base)\n}\n\nexport function createGateway(options: GatewayOptions): http.Server {\n writeFileSync(options.log, '')\n const agent = new http.Agent({ keepAlive: true })\n return http.createServer((request, response) => {\n const startedAt = Date.now()\n const { pathname } = new URL(request.url ?? '/', 'http://gateway')\n const toApp = isAppPath(pathname, options)\n const port = toApp ? options.appPort : options.mockPort\n const log = (\n status: number | undefined,\n mock: string | string[] | null,\n error?: string,\n ): void =>\n appendFileSync(\n options.log,\n `${JSON.stringify({ at: new Date(startedAt).toISOString(), method: request.method, path: request.url, to: toApp ? 'app' : 'mock', status, mock, ms: Date.now() - startedAt, ...(error ? { error } : {}) })}\\n`,\n )\n const upstream = http.request(\n {\n hostname: '127.0.0.1',\n port,\n path: request.url,\n method: request.method,\n headers: { ...request.headers, host: `127.0.0.1:${port}` },\n agent,\n },\n (answer) => {\n response.writeHead(answer.statusCode ?? 502, answer.headers)\n answer.pipe(response)\n answer.on('end', () => log(answer.statusCode, answer.headers['x-cwv-mock'] ?? null))\n },\n )\n upstream.on('error', (error: NodeJS.ErrnoException) => {\n log(502, null, error.code ?? String(error))\n response.writeHead(502, { 'content-type': 'text/plain' })\n response.end('upstream unreachable')\n })\n request.pipe(upstream)\n })\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
answer,
|
|
3
|
+
loadApi
|
|
4
|
+
} from "../../chunk-NE3IEJBN.js";
|
|
5
|
+
import {
|
|
6
|
+
loadRuntimeConfig
|
|
7
|
+
} from "../../chunk-VWASE6NN.js";
|
|
8
|
+
import "../../chunk-F5WISUN3.js";
|
|
9
|
+
|
|
10
|
+
// src/roles/runtime-analysis/serve/mock-api-main.ts
|
|
11
|
+
import { resolve } from "node:path";
|
|
12
|
+
import { parseArgs } from "node:util";
|
|
13
|
+
|
|
14
|
+
// src/roles/runtime-analysis/serve/mock-api.ts
|
|
15
|
+
import http from "node:http";
|
|
16
|
+
function createMockApi(api) {
|
|
17
|
+
return http.createServer((request, response) => {
|
|
18
|
+
request.resume();
|
|
19
|
+
const { status, body, mock } = answer(api, request.method ?? "GET", request.url ?? "/");
|
|
20
|
+
response.writeHead(status, {
|
|
21
|
+
"content-type": mock === "handled" ? "application/json" : "text/plain",
|
|
22
|
+
"x-cwv-mock": mock
|
|
23
|
+
});
|
|
24
|
+
response.end(body);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/roles/runtime-analysis/serve/mock-api-main.ts
|
|
29
|
+
var { values: args } = parseArgs({
|
|
30
|
+
options: { module: { type: "string" }, port: { type: "string" } }
|
|
31
|
+
});
|
|
32
|
+
var moduleDir = resolve(String(args.module));
|
|
33
|
+
var loaded = await loadRuntimeConfig(moduleDir);
|
|
34
|
+
if (!("config" in loaded)) {
|
|
35
|
+
console.error(`no runtime-analysis config in ${args.module}`);
|
|
36
|
+
process.exit(2);
|
|
37
|
+
}
|
|
38
|
+
createMockApi(loadApi(loaded.config.api, moduleDir)).listen(
|
|
39
|
+
Number(args.port),
|
|
40
|
+
"127.0.0.1",
|
|
41
|
+
() => console.log(`mock API on http://127.0.0.1:${args.port}`)
|
|
42
|
+
);
|
|
43
|
+
//# sourceMappingURL=mock-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/roles/runtime-analysis/serve/mock-api-main.ts","../../../src/roles/runtime-analysis/serve/mock-api.ts"],"sourcesContent":["/** The mock API as its own process: `node mock-api.js --module <dir> --port 4199`. */\nimport { resolve } from 'node:path'\nimport { parseArgs } from 'node:util'\n\nimport { loadApi } from '../config/api.js'\nimport { loadRuntimeConfig } from '../config/resolve.js'\n\nimport { createMockApi } from './mock-api.js'\n\nconst { values: args } = parseArgs({\n options: { module: { type: 'string' }, port: { type: 'string' } },\n})\nconst moduleDir = resolve(String(args.module))\nconst loaded = await loadRuntimeConfig(moduleDir)\nif (!('config' in loaded)) {\n console.error(`no runtime-analysis config in ${args.module}`)\n process.exit(2)\n}\ncreateMockApi(loadApi(loaded.config.api, moduleDir)).listen(Number(args.port), '127.0.0.1', () =>\n console.log(`mock API on http://127.0.0.1:${args.port}`),\n)\n","/**\n * The mock API: answers a front's API calls from the `api` list of its config, nothing else. A\n * request no entry matches is answered 501, which fails the flow's \"no unhandled request\" proof.\n * Moved from the monorepo's harness (`engine/serve/mock-api.mjs`), unchanged in behaviour; its own\n * process (`mock-api-main.ts`), like the gateway.\n */\nimport http from 'node:http'\n\nimport { answer, type LoadedAnswer } from '../config/api.js'\n\nexport function createMockApi(api: readonly LoadedAnswer[]): http.Server {\n return http.createServer((request, response) => {\n // The body is not read: an entry answers by method and path only.\n request.resume()\n const { status, body, mock } = answer(api, request.method ?? 'GET', request.url ?? '/')\n response.writeHead(status, {\n 'content-type': mock === 'handled' ? 'application/json' : 'text/plain',\n 'x-cwv-mock': mock,\n })\n response.end(body)\n })\n}\n"],"mappings":";;;;;;;;;;AACA,SAAS,eAAe;AACxB,SAAS,iBAAiB;;;ACI1B,OAAO,UAAU;AAIV,SAAS,cAAc,KAA2C;AACvE,SAAO,KAAK,aAAa,CAAC,SAAS,aAAa;AAE9C,YAAQ,OAAO;AACf,UAAM,EAAE,QAAQ,MAAM,KAAK,IAAI,OAAO,KAAK,QAAQ,UAAU,OAAO,QAAQ,OAAO,GAAG;AACtF,aAAS,UAAU,QAAQ;AAAA,MACzB,gBAAgB,SAAS,YAAY,qBAAqB;AAAA,MAC1D,cAAc;AAAA,IAChB,CAAC;AACD,aAAS,IAAI,IAAI;AAAA,EACnB,CAAC;AACH;;;ADZA,IAAM,EAAE,QAAQ,KAAK,IAAI,UAAU;AAAA,EACjC,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,GAAG,MAAM,EAAE,MAAM,SAAS,EAAE;AAClE,CAAC;AACD,IAAM,YAAY,QAAQ,OAAO,KAAK,MAAM,CAAC;AAC7C,IAAM,SAAS,MAAM,kBAAkB,SAAS;AAChD,IAAI,EAAE,YAAY,SAAS;AACzB,UAAQ,MAAM,iCAAiC,KAAK,MAAM,EAAE;AAC5D,UAAQ,KAAK,CAAC;AAChB;AACA,cAAc,QAAQ,OAAO,OAAO,KAAK,SAAS,CAAC,EAAE;AAAA,EAAO,OAAO,KAAK,IAAI;AAAA,EAAG;AAAA,EAAa,MAC1F,QAAQ,IAAI,gCAAgC,KAAK,IAAI,EAAE;AACzD;","names":[]}
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
} from "../../../chunk-NUOQXAYR.js";
|
|
8
8
|
import {
|
|
9
9
|
installWorkspaceSetup
|
|
10
|
-
} from "../../../chunk-
|
|
10
|
+
} from "../../../chunk-4YQXLPJ5.js";
|
|
11
11
|
import "../../../chunk-ELZHIN6E.js";
|
|
12
|
-
import "../../../chunk-
|
|
12
|
+
import "../../../chunk-ZNANJEMK.js";
|
|
13
13
|
|
|
14
14
|
// src/roles/test/setup/jest-parity.ts
|
|
15
15
|
import { expect, vi } from "vitest";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pinWorkspaceTimezone
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-4YQXLPJ5.js";
|
|
4
4
|
import "../../../chunk-ELZHIN6E.js";
|
|
5
|
-
import "../../../chunk-
|
|
5
|
+
import "../../../chunk-ZNANJEMK.js";
|
|
6
6
|
|
|
7
7
|
// src/roles/test/setup/workspace-entry.ts
|
|
8
8
|
await pinWorkspaceTimezone();
|
|
@@ -236,11 +236,9 @@ $ sentinel --report --json 2>/dev/null
|
|
|
236
236
|
"typescript",
|
|
237
237
|
"build",
|
|
238
238
|
"test",
|
|
239
|
-
"static-analysis"
|
|
240
|
-
"sql"
|
|
239
|
+
"static-analysis"
|
|
241
240
|
],
|
|
242
241
|
"skipped": [
|
|
243
|
-
"runtime-analysis",
|
|
244
242
|
"arch"
|
|
245
243
|
],
|
|
246
244
|
"results": [
|
|
@@ -320,32 +318,6 @@ $ sentinel --report --json 2>/dev/null
|
|
|
320
318
|
"preset": null,
|
|
321
319
|
"conformant": false
|
|
322
320
|
},
|
|
323
|
-
{
|
|
324
|
-
"project": "svelte-app",
|
|
325
|
-
"target": "sql",
|
|
326
|
-
"flavour": "svelte",
|
|
327
|
-
"ok": true,
|
|
328
|
-
"status": "ok",
|
|
329
|
-
"migrations": 0,
|
|
330
|
-
"codeFiles": 1,
|
|
331
|
-
"unsafeFiles": 0,
|
|
332
|
-
"base": null,
|
|
333
|
-
"migrationsRead": 0,
|
|
334
|
-
"migrationsUnchanged": 0,
|
|
335
|
-
"migrationsUnread": 0,
|
|
336
|
-
"unsafeFilesRead": 0,
|
|
337
|
-
"unsafeCalls": 0,
|
|
338
|
-
"rawFragmentCalls": 0,
|
|
339
|
-
"unsafeUnparsed": 0,
|
|
340
|
-
"findings": 0,
|
|
341
|
-
"errors": 0,
|
|
342
|
-
"rulesOff": [],
|
|
343
|
-
"syntaxErrors": 0,
|
|
344
|
-
"findingsByRule": {},
|
|
345
|
-
"adopted": false,
|
|
346
|
-
"preset": null,
|
|
347
|
-
"conformant": false
|
|
348
|
-
},
|
|
349
321
|
{
|
|
350
322
|
"project": "bff-admin",
|
|
351
323
|
"target": "lint",
|
|
@@ -422,32 +394,6 @@ $ sentinel --report --json 2>/dev/null
|
|
|
422
394
|
"preset": null,
|
|
423
395
|
"conformant": false
|
|
424
396
|
},
|
|
425
|
-
{
|
|
426
|
-
"project": "bff-admin",
|
|
427
|
-
"target": "sql",
|
|
428
|
-
"flavour": "nest",
|
|
429
|
-
"ok": true,
|
|
430
|
-
"status": "ok",
|
|
431
|
-
"migrations": 0,
|
|
432
|
-
"codeFiles": 1,
|
|
433
|
-
"unsafeFiles": 0,
|
|
434
|
-
"base": null,
|
|
435
|
-
"migrationsRead": 0,
|
|
436
|
-
"migrationsUnchanged": 0,
|
|
437
|
-
"migrationsUnread": 0,
|
|
438
|
-
"unsafeFilesRead": 0,
|
|
439
|
-
"unsafeCalls": 0,
|
|
440
|
-
"rawFragmentCalls": 0,
|
|
441
|
-
"unsafeUnparsed": 0,
|
|
442
|
-
"findings": 0,
|
|
443
|
-
"errors": 0,
|
|
444
|
-
"rulesOff": [],
|
|
445
|
-
"syntaxErrors": 0,
|
|
446
|
-
"findingsByRule": {},
|
|
447
|
-
"adopted": false,
|
|
448
|
-
"preset": null,
|
|
449
|
-
"conformant": false
|
|
450
|
-
},
|
|
451
397
|
{
|
|
452
398
|
"project": "react-app",
|
|
453
399
|
"target": "lint",
|
|
@@ -524,32 +470,6 @@ $ sentinel --report --json 2>/dev/null
|
|
|
524
470
|
"preset": null,
|
|
525
471
|
"conformant": false
|
|
526
472
|
},
|
|
527
|
-
{
|
|
528
|
-
"project": "react-app",
|
|
529
|
-
"target": "sql",
|
|
530
|
-
"flavour": "react",
|
|
531
|
-
"ok": true,
|
|
532
|
-
"status": "ok",
|
|
533
|
-
"migrations": 0,
|
|
534
|
-
"codeFiles": 1,
|
|
535
|
-
"unsafeFiles": 0,
|
|
536
|
-
"base": null,
|
|
537
|
-
"migrationsRead": 0,
|
|
538
|
-
"migrationsUnchanged": 0,
|
|
539
|
-
"migrationsUnread": 0,
|
|
540
|
-
"unsafeFilesRead": 0,
|
|
541
|
-
"unsafeCalls": 0,
|
|
542
|
-
"rawFragmentCalls": 0,
|
|
543
|
-
"unsafeUnparsed": 0,
|
|
544
|
-
"findings": 0,
|
|
545
|
-
"errors": 0,
|
|
546
|
-
"rulesOff": [],
|
|
547
|
-
"syntaxErrors": 0,
|
|
548
|
-
"findingsByRule": {},
|
|
549
|
-
"adopted": false,
|
|
550
|
-
"preset": null,
|
|
551
|
-
"conformant": false
|
|
552
|
-
},
|
|
553
473
|
{
|
|
554
474
|
"project": "utils",
|
|
555
475
|
"target": "lint",
|
|
@@ -613,32 +533,6 @@ $ sentinel --report --json 2>/dev/null
|
|
|
613
533
|
"adopted": false,
|
|
614
534
|
"preset": null,
|
|
615
535
|
"conformant": false
|
|
616
|
-
},
|
|
617
|
-
{
|
|
618
|
-
"project": "utils",
|
|
619
|
-
"target": "sql",
|
|
620
|
-
"flavour": "node",
|
|
621
|
-
"ok": true,
|
|
622
|
-
"status": "ok",
|
|
623
|
-
"migrations": 0,
|
|
624
|
-
"codeFiles": 1,
|
|
625
|
-
"unsafeFiles": 0,
|
|
626
|
-
"base": null,
|
|
627
|
-
"migrationsRead": 0,
|
|
628
|
-
"migrationsUnchanged": 0,
|
|
629
|
-
"migrationsUnread": 0,
|
|
630
|
-
"unsafeFilesRead": 0,
|
|
631
|
-
"unsafeCalls": 0,
|
|
632
|
-
"rawFragmentCalls": 0,
|
|
633
|
-
"unsafeUnparsed": 0,
|
|
634
|
-
"findings": 0,
|
|
635
|
-
"errors": 0,
|
|
636
|
-
"rulesOff": [],
|
|
637
|
-
"syntaxErrors": 0,
|
|
638
|
-
"findingsByRule": {},
|
|
639
|
-
"adopted": false,
|
|
640
|
-
"preset": null,
|
|
641
|
-
"conformant": false
|
|
642
536
|
}
|
|
643
537
|
]
|
|
644
538
|
}
|
|
@@ -671,11 +565,9 @@ $ sentinel --report --all --json 2>/dev/null
|
|
|
671
565
|
"typescript",
|
|
672
566
|
"build",
|
|
673
567
|
"test",
|
|
674
|
-
"static-analysis"
|
|
675
|
-
"sql"
|
|
568
|
+
"static-analysis"
|
|
676
569
|
],
|
|
677
570
|
"skipped": [
|
|
678
|
-
"runtime-analysis",
|
|
679
571
|
"arch"
|
|
680
572
|
],
|
|
681
573
|
"results": [
|
|
@@ -755,32 +647,6 @@ $ sentinel --report --all --json 2>/dev/null
|
|
|
755
647
|
"preset": null,
|
|
756
648
|
"conformant": false
|
|
757
649
|
},
|
|
758
|
-
{
|
|
759
|
-
"project": "svelte-app",
|
|
760
|
-
"target": "sql",
|
|
761
|
-
"flavour": "svelte",
|
|
762
|
-
"ok": true,
|
|
763
|
-
"status": "ok",
|
|
764
|
-
"migrations": 0,
|
|
765
|
-
"codeFiles": 1,
|
|
766
|
-
"unsafeFiles": 0,
|
|
767
|
-
"base": null,
|
|
768
|
-
"migrationsRead": 0,
|
|
769
|
-
"migrationsUnchanged": 0,
|
|
770
|
-
"migrationsUnread": 0,
|
|
771
|
-
"unsafeFilesRead": 0,
|
|
772
|
-
"unsafeCalls": 0,
|
|
773
|
-
"rawFragmentCalls": 0,
|
|
774
|
-
"unsafeUnparsed": 0,
|
|
775
|
-
"findings": 0,
|
|
776
|
-
"errors": 0,
|
|
777
|
-
"rulesOff": [],
|
|
778
|
-
"syntaxErrors": 0,
|
|
779
|
-
"findingsByRule": {},
|
|
780
|
-
"adopted": false,
|
|
781
|
-
"preset": null,
|
|
782
|
-
"conformant": false
|
|
783
|
-
},
|
|
784
650
|
{
|
|
785
651
|
"project": "bff-admin",
|
|
786
652
|
"target": "lint",
|
|
@@ -857,32 +723,6 @@ $ sentinel --report --all --json 2>/dev/null
|
|
|
857
723
|
"preset": null,
|
|
858
724
|
"conformant": false
|
|
859
725
|
},
|
|
860
|
-
{
|
|
861
|
-
"project": "bff-admin",
|
|
862
|
-
"target": "sql",
|
|
863
|
-
"flavour": "nest",
|
|
864
|
-
"ok": true,
|
|
865
|
-
"status": "ok",
|
|
866
|
-
"migrations": 0,
|
|
867
|
-
"codeFiles": 1,
|
|
868
|
-
"unsafeFiles": 0,
|
|
869
|
-
"base": null,
|
|
870
|
-
"migrationsRead": 0,
|
|
871
|
-
"migrationsUnchanged": 0,
|
|
872
|
-
"migrationsUnread": 0,
|
|
873
|
-
"unsafeFilesRead": 0,
|
|
874
|
-
"unsafeCalls": 0,
|
|
875
|
-
"rawFragmentCalls": 0,
|
|
876
|
-
"unsafeUnparsed": 0,
|
|
877
|
-
"findings": 0,
|
|
878
|
-
"errors": 0,
|
|
879
|
-
"rulesOff": [],
|
|
880
|
-
"syntaxErrors": 0,
|
|
881
|
-
"findingsByRule": {},
|
|
882
|
-
"adopted": false,
|
|
883
|
-
"preset": null,
|
|
884
|
-
"conformant": false
|
|
885
|
-
},
|
|
886
726
|
{
|
|
887
727
|
"project": "react-app",
|
|
888
728
|
"target": "lint",
|
|
@@ -959,32 +799,6 @@ $ sentinel --report --all --json 2>/dev/null
|
|
|
959
799
|
"preset": null,
|
|
960
800
|
"conformant": false
|
|
961
801
|
},
|
|
962
|
-
{
|
|
963
|
-
"project": "react-app",
|
|
964
|
-
"target": "sql",
|
|
965
|
-
"flavour": "react",
|
|
966
|
-
"ok": true,
|
|
967
|
-
"status": "ok",
|
|
968
|
-
"migrations": 0,
|
|
969
|
-
"codeFiles": 1,
|
|
970
|
-
"unsafeFiles": 0,
|
|
971
|
-
"base": null,
|
|
972
|
-
"migrationsRead": 0,
|
|
973
|
-
"migrationsUnchanged": 0,
|
|
974
|
-
"migrationsUnread": 0,
|
|
975
|
-
"unsafeFilesRead": 0,
|
|
976
|
-
"unsafeCalls": 0,
|
|
977
|
-
"rawFragmentCalls": 0,
|
|
978
|
-
"unsafeUnparsed": 0,
|
|
979
|
-
"findings": 0,
|
|
980
|
-
"errors": 0,
|
|
981
|
-
"rulesOff": [],
|
|
982
|
-
"syntaxErrors": 0,
|
|
983
|
-
"findingsByRule": {},
|
|
984
|
-
"adopted": false,
|
|
985
|
-
"preset": null,
|
|
986
|
-
"conformant": false
|
|
987
|
-
},
|
|
988
802
|
{
|
|
989
803
|
"project": "utils",
|
|
990
804
|
"target": "lint",
|
|
@@ -1048,32 +862,6 @@ $ sentinel --report --all --json 2>/dev/null
|
|
|
1048
862
|
"adopted": false,
|
|
1049
863
|
"preset": null,
|
|
1050
864
|
"conformant": false
|
|
1051
|
-
},
|
|
1052
|
-
{
|
|
1053
|
-
"project": "utils",
|
|
1054
|
-
"target": "sql",
|
|
1055
|
-
"flavour": "node",
|
|
1056
|
-
"ok": true,
|
|
1057
|
-
"status": "ok",
|
|
1058
|
-
"migrations": 0,
|
|
1059
|
-
"codeFiles": 1,
|
|
1060
|
-
"unsafeFiles": 0,
|
|
1061
|
-
"base": null,
|
|
1062
|
-
"migrationsRead": 0,
|
|
1063
|
-
"migrationsUnchanged": 0,
|
|
1064
|
-
"migrationsUnread": 0,
|
|
1065
|
-
"unsafeFilesRead": 0,
|
|
1066
|
-
"unsafeCalls": 0,
|
|
1067
|
-
"rawFragmentCalls": 0,
|
|
1068
|
-
"unsafeUnparsed": 0,
|
|
1069
|
-
"findings": 0,
|
|
1070
|
-
"errors": 0,
|
|
1071
|
-
"rulesOff": [],
|
|
1072
|
-
"syntaxErrors": 0,
|
|
1073
|
-
"findingsByRule": {},
|
|
1074
|
-
"adopted": false,
|
|
1075
|
-
"preset": null,
|
|
1076
|
-
"conformant": false
|
|
1077
865
|
}
|
|
1078
866
|
]
|
|
1079
867
|
}
|
|
@@ -1433,7 +1221,6 @@ $ sentinel --init --dry-run
|
|
|
1433
1221
|
+ }
|
|
1434
1222
|
+ }
|
|
1435
1223
|
+ }
|
|
1436
|
-
sql: no migration (**/migrations/*/migration.sql) and no raw SQL call in this module: nothing for the sql role to read.
|
|
1437
1224
|
dry run: no files written
|
|
1438
1225
|
materialized the nest format preset into .oxfmtrc.json (@hublo/sentinel@<version>). oxfmt has no `extends`, so the values live here; `sentinel --status --format` reports modules left behind by a preset change
|
|
1439
1226
|
|
|
@@ -1512,7 +1299,6 @@ $ sentinel --init --dry-run
|
|
|
1512
1299
|
dry run: the lint autofix runs on adoption and can rewrite source, as moving to another linter does; add --rehearse to name the files (it runs the pass in a throwaway copy, as long as the real one)
|
|
1513
1300
|
dry run: the format autofix runs on adoption and can rewrite source, as moving to another formatter does; add --rehearse to name the files (it runs the pass in a throwaway copy, as long as the real one)
|
|
1514
1301
|
dry run: would ignore static-analysis-report/ in the root .gitignore
|
|
1515
|
-
dry run: would ignore sql-report/ in the root .gitignore
|
|
1516
1302
|
# exit: 0
|
|
1517
1303
|
```
|
|
1518
1304
|
|
|
@@ -1673,7 +1459,6 @@ $ sentinel --init --dry-run --rehearse
|
|
|
1673
1459
|
+ }
|
|
1674
1460
|
+ }
|
|
1675
1461
|
+ }
|
|
1676
|
-
sql: no migration (**/migrations/*/migration.sql) and no raw SQL call in this module: nothing for the sql role to read.
|
|
1677
1462
|
dry run: no files written
|
|
1678
1463
|
materialized the nest format preset into .oxfmtrc.json (@hublo/sentinel@<version>). oxfmt has no `extends`, so the values live here; `sentinel --status --format` reports modules left behind by a preset change
|
|
1679
1464
|
|
|
@@ -1752,7 +1537,6 @@ $ sentinel --init --dry-run --rehearse
|
|
|
1752
1537
|
dry run: the lint autofix cannot be rehearsed yet: its preset is not installed in this module, which is expected before the first `pnpm install`. After it, this dry-run names what it rewrites
|
|
1753
1538
|
dry run: the format autofix would rewrite 1 file beyond the ones above: project.json
|
|
1754
1539
|
dry run: would ignore static-analysis-report/ in the root .gitignore
|
|
1755
|
-
dry run: would ignore sql-report/ in the root .gitignore
|
|
1756
1540
|
# exit: 0
|
|
1757
1541
|
```
|
|
1758
1542
|
|
package/docs/using-sentinel.md
CHANGED
|
@@ -6,8 +6,7 @@ migrating a module see [`lint-adoption.md`](lint-adoption.md),
|
|
|
6
6
|
[`typescript-adoption.md`](typescript-adoption.md),
|
|
7
7
|
[`build-adoption.md`](build-adoption.md),
|
|
8
8
|
[`test-adoption.md`](test-adoption.md) and
|
|
9
|
-
[`static-analysis-adoption.md`](static-analysis-adoption.md)
|
|
10
|
-
[`sql-adoption.md`](sql-adoption.md). The reference gate `--test` runs a
|
|
9
|
+
[`static-analysis-adoption.md`](static-analysis-adoption.md). The reference gate `--test` runs a
|
|
11
10
|
migration against is in `test-adoption.md`, not the static-analysis page.
|
|
12
11
|
|
|
13
12
|
## The grid
|