@antelopejs/tooling-configs 0.3.4 → 0.3.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/dist/bin/lease.mjs +1 -50
- package/dist/bin/sync.mjs +3 -2
- package/dist/bin/verify.mjs +712 -77
- package/dist/env-DT0UJNeL.mjs +79 -0
- package/dist/{map-mT2iQzit.mjs → map-s_jKqBQv.mjs} +63 -7
- package/dist/verify/index.d.mts +35 -2
- package/package.json +1 -1
package/dist/bin/lease.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
|
|
3
|
+
import { a as isServerRole, l as unmarked, o as leaseEnv, s as leaseMarker } from "../env-DT0UJNeL.mjs";
|
|
3
4
|
import { a as closeServer, c as LOCK_PORT, d as isRole, f as leaseHome, i as claimPort, l as PORT_ROLES, m as parseRecord, n as bindable, o as listenerPids, p as leaseId, r as chooseBlock, s as listensOn, t as accepting, u as isLeaseId } from "../ports-DGP6bPJy.mjs";
|
|
4
5
|
import { accessSync, closeSync, constants, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, renameSync, rmSync, statSync, utimesSync, writeFileSync } from "node:fs";
|
|
5
6
|
import { delimiter, join } from "node:path";
|
|
@@ -7,56 +8,6 @@ import { execFileSync, spawn } from "node:child_process";
|
|
|
7
8
|
import { homedir } from "node:os";
|
|
8
9
|
import { parseArgs } from "node:util";
|
|
9
10
|
import { setTimeout } from "node:timers/promises";
|
|
10
|
-
//#region src/lease/env.ts
|
|
11
|
-
const LEASE_VARIABLE = "ANTELOPEJS_LEASE";
|
|
12
|
-
/**
|
|
13
|
-
* The `environ` entry that `run` hands its command and every descendant inherits, which marks a
|
|
14
|
-
* process as the work of lease `id`.
|
|
15
|
-
*/
|
|
16
|
-
function leaseMarker(id) {
|
|
17
|
-
return `${LEASE_VARIABLE}=${id}`;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* `env` without the lease marker, for a process that outlives the command that started it and
|
|
21
|
-
* belongs to no lease's `down --stop`, such as a lease's mongod started from inside another lease's
|
|
22
|
-
* `run`.
|
|
23
|
-
*/
|
|
24
|
-
function unmarked(env) {
|
|
25
|
-
const { [LEASE_VARIABLE]: _marker, ...rest } = env;
|
|
26
|
-
return rest;
|
|
27
|
-
}
|
|
28
|
-
function isServerRole(value) {
|
|
29
|
-
return value === "api" || value === "web";
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* The environment `run` hands its command: `parent` without `PORT`, plus the lease's variables.
|
|
33
|
-
* `PORT` comes back only for `as`, because one shell-wide `PORT` makes the backend and the
|
|
34
|
-
* dashboard bind the same port. `DMS_MONGO_URL` in `parent` replaces the lease's own mongod.
|
|
35
|
-
* `DMS_API_BASE_URL` stays unset. A backend whose config hard-codes its port falls back to a free
|
|
36
|
-
* one and records it in `.antelope/dev.json`, and `ajs dms dev` reads that file only without it.
|
|
37
|
-
*/
|
|
38
|
-
function leaseEnv(lease, parent, as) {
|
|
39
|
-
const { record, dir } = lease;
|
|
40
|
-
const { ports } = record;
|
|
41
|
-
const { PORT: _inherited, ...env } = parent;
|
|
42
|
-
Object.assign(env, {
|
|
43
|
-
[LEASE_VARIABLE]: record.id,
|
|
44
|
-
ANTELOPEJS_LEASE_DIR: dir,
|
|
45
|
-
DMS_BACK_PORT: String(ports.api),
|
|
46
|
-
DMS_FRONT_PORT: String(ports.web),
|
|
47
|
-
DMS_INSPECT_PORT: String(ports.inspect),
|
|
48
|
-
DMS_SMTP_PORT: String(ports.smtp),
|
|
49
|
-
DMS_CLIENT_BASE_URL: `http://localhost:${ports.web}`,
|
|
50
|
-
MONGO_URL: parent.DMS_MONGO_URL || `mongodb://127.0.0.1:${ports.mongo}`,
|
|
51
|
-
MONGO_DATABASE: `dms_${record.id}`,
|
|
52
|
-
DMS_BACK_LOG: join(dir, "logs", "back.log"),
|
|
53
|
-
DMS_FRONT_LOG: join(dir, "logs", "front.log"),
|
|
54
|
-
TMPDIR: join(dir, "tmp")
|
|
55
|
-
});
|
|
56
|
-
if (as !== void 0) env.PORT = String(ports[as]);
|
|
57
|
-
return env;
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
60
11
|
//#region src/lease/exec.ts
|
|
61
12
|
const SHELL = "/bin/sh";
|
|
62
13
|
const DEFAULT_PATH = "/bin:/usr/bin";
|
package/dist/bin/sync.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { c as repositoryRoot } from "../files-DJ0TeaTU.mjs";
|
|
|
8
8
|
import { i as recordedRelease, t as measureBaseline } from "../ratchet-Q-JXuZIX.mjs";
|
|
9
9
|
import { a as ciWorkflow, c as ciRenovateSyncCallers, f as renovateArtifacts, l as hasChecksWorkflow, o as MISSING_CHECKS_WORKFLOW, r as CI_PATH, s as ciNodeCallers } from "../ci-workflow-C4mQ8QSp.mjs";
|
|
10
10
|
import { n as SUPPRESSIONS_FILE, r as adoptedBudget } from "../suppression-budget-C0SkPO5R.mjs";
|
|
11
|
-
import { t as DEFAULT_SHARED } from "../map-
|
|
11
|
+
import { t as DEFAULT_SHARED } from "../map-s_jKqBQv.mjs";
|
|
12
12
|
import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, rmdirSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
|
|
13
13
|
import { dirname, join, resolve } from "node:path";
|
|
14
14
|
import { execFileSync } from "node:child_process";
|
|
@@ -820,13 +820,14 @@ Each step writes \`<run>/evidence/<feature>/<journey>/<NN-step>/\` with \`comman
|
|
|
820
820
|
${BIN} clean <run>
|
|
821
821
|
\`\`\`
|
|
822
822
|
|
|
823
|
-
Each journey deletes its scratch folder and \`HOME\`, its install included, when it ends: passed, failed or interrupted. Only its evidence stays. \`clean\` stops what the run started, by recorded PID and container name, and removes everything but \`evidence/\` and \`run.json
|
|
823
|
+
Each journey deletes its scratch folder and \`HOME\`, its install included, when it ends: passed, failed or interrupted. Only its evidence stays. \`clean\` stops what the run started, by recorded PID and container name, and removes everything but \`evidence/\` and \`run.json\`, the folders \`context.prepared\` kept included. Run it after every run, failed ones included.
|
|
824
824
|
|
|
825
825
|
## The repository's own layer
|
|
826
826
|
|
|
827
827
|
- \`verify.config.ts\` default-exports a \`VerifyConfig\` from \`@antelopejs/tooling-configs/verify\`:
|
|
828
828
|
- \`doors\`: one entry per door kind (\`data\`, \`format\`, \`contract\`, \`outbound\`, \`exposure\`, \`publish\`), each \`null\` when it cannot apply or \`{ globs, funnels, why }\`.
|
|
829
829
|
- \`journeys\`: the repository's journeys by id, each \`{ title, entryPoint, run(context) }\`, using the check helpers the same import exports. A check states what the product must do; an environment that went away is never a failing check. When a journey fails, the harness reruns each service's readiness command, up to four times over about 3.5 s, and looks at every \`ajs project dev\` the journey started, its own readiness probe included. The journey ends NOT VERIFIED, not FAIL, when a service still fails every rerun, an app was killed by SIGKILL, SIGTERM, SIGHUP or SIGINT that the harness did not send, or the app the harness started failed to bind the port the harness gave it (\`EADDRINUSE\` naming that port). An app that exits on its own with an exit code, one that crashes by another signal such as SIGABRT or SIGSEGV, and one that logs \`EADDRINUSE\` for any other port are the product's failure. A change that takes its own service down still reads as an outage: the service stays down, so the journey is NOT VERIFIED. For anything else the journey depends on, such as a process it started with \`context.command\` or an outside endpoint, probe it when a check fails and call \`context.notVerified(reason)\` when it no longer answers.
|
|
830
|
+
- \`context.prepared(key, build)\` does the preparation many journeys repeat once per run, such as scaffolding and installing a project, and returns the journey's own copy at \`<work>/<key>\`. The first journey that asks for \`key\` runs \`build(folder)\` on the empty folder with its usual steps, after a step \`prepared <key>\` that marks them as the build and says whether it was kept. A build is kept until \`clean\` only when it returns, records at least one check, passes every check, and leaves only files, directories and symlinks in the folder. Every later journey of the run, also in a later \`journey\` command, gets a fresh copy and one step, \`prepared <key>\`, that names the journey that built it and holds that build's evidence under \`build/\`. A build that is not kept is built again by the next journey, and rerunning the journey that built builds again. An absolute symlink into the folder points into each copy; other symlinks keep their target. \`build\` writes only inside the folder it is given: a write elsewhere, such as a sibling under \`<work>\` or the repository, stays with the journey that built. Two concurrent \`journey\` commands that reach the same key at once both build, and the first to finish is kept. The commands \`build\` runs get a \`HOME\` of their own that is deleted when it ends: redo after \`prepared\` anything a later step needs in \`HOME\`, such as \`ajs config set git\`. Pass the same \`build\` for a key in every journey.
|
|
830
831
|
- \`env\`, \`setup\` (commands replacing the build), \`userFacing\` and \`shared\` (globs replacing the kind's default; \`shared\` lists the files whose change runs every feature), and \`formal\` (formal checks: \`name\`, \`covers\`, \`command\`, \`violation\`, and optionally \`behaviour\` and \`baseCommand\`).
|
|
831
832
|
${text.layer}
|
|
832
833
|
- \`features/README.md\`: the index of the features; \`map\` does not read it as a feature.
|