@antelopejs/dms 0.17.0 → 0.18.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/CHANGELOG.md +65 -0
- package/README.md +7 -11
- package/bin/control/backend-records.test.mjs +276 -0
- package/bin/control/backend.mjs +212 -0
- package/bin/control/backend.test.mjs +325 -0
- package/bin/control/base.mjs +3 -7
- package/bin/control/browser-client.mjs +6 -4
- package/bin/control/browser.mjs +173 -36
- package/bin/control/build-cache.mjs +394 -0
- package/bin/control/build-cache.test.mjs +270 -0
- package/bin/control/build-inputs.mjs +172 -0
- package/bin/control/build-key-refusals.test.mjs +138 -0
- package/bin/control/build-key.mjs +479 -0
- package/bin/control/build-key.test.mjs +392 -0
- package/bin/control/build-layout.test.mjs +314 -0
- package/bin/control/commands-stack.mjs +46 -6
- package/bin/control/commands-verify.mjs +9 -2
- package/bin/control/doctor.mjs +87 -16
- package/bin/control/forwarder.mjs +86 -0
- package/bin/control/forwarder.test.mjs +141 -0
- package/bin/control/frontend-check.mjs +54 -0
- package/bin/control/frontend-workspace.mjs +150 -0
- package/bin/control/frontend-workspace.test.mjs +133 -0
- package/bin/control/helpers/env.mjs +21 -0
- package/bin/control/helpers/evidence.mjs +13 -0
- package/bin/control/helpers/fake-run.mjs +290 -0
- package/bin/control/helpers/key-fixture.mjs +82 -0
- package/bin/control/helpers/pids.mjs +27 -0
- package/bin/control/helpers/repo.mjs +13 -0
- package/bin/control/helpers/tree.mjs +40 -0
- package/bin/control/identity.mjs +238 -0
- package/bin/control/identity.test.mjs +166 -0
- package/bin/control/journey.mjs +64 -16
- package/bin/control/journey.test.mjs +60 -2
- package/bin/control/namespaces.test.mjs +211 -0
- package/bin/control/options.mjs +2 -0
- package/bin/control/pid-guard.test.mjs +202 -0
- package/bin/control/prepared-workspace.mjs +20 -0
- package/bin/control/processes.mjs +122 -33
- package/bin/control/processes.test.mjs +255 -0
- package/bin/control/renderer.test.mjs +2 -1
- package/bin/control/run-copy.mjs +77 -0
- package/bin/control/run-state.mjs +142 -16
- package/bin/control/stack.mjs +259 -210
- package/bin/control/tab.mjs +13 -6
- package/bin/control/tab.test.mjs +444 -0
- package/bin/control/timing.mjs +244 -0
- package/bin/control/timing.test.mjs +197 -0
- package/bin/control/verify/decode.mjs +34 -21
- package/bin/control/verify/decode.test.mjs +39 -0
- package/bin/control/verify/doors.test.mjs +2 -0
- package/bin/control/verify/map.mjs +57 -7
- package/bin/control/verify/map.test.mjs +264 -0
- package/bin/control/verify/skill.mjs +12 -3
- package/bin/control/verify/types.mjs +2 -2
- package/bin/control/verify/verdict.mjs +37 -7
- package/bin/dms-control.mjs +14 -6
- package/dist/config/internal/state.d.ts +2 -2
- package/dist/config/internal/state.js.map +1 -1
- package/dist/utils/sign-in-country.d.ts +0 -1
- package/dist/utils/sign-in-country.js +7 -17
- package/dist/utils/sign-in-country.js.map +1 -1
- package/frontend-vue/layers/dms-layout/app/components/layout/DashboardSearch.vue +24 -1
- package/frontend-vue/layers/dms-layout/app/composables/layout/usePageHeaderActions.ts +1 -1
- package/frontend-vue/package.json +1 -1
- package/frontend-vue/scripts/check-autoimport-boundaries.mjs +19 -3
- package/frontend-vue/scripts/test-autoimport-boundaries.mjs +19 -0
- package/package.json +5 -5
- package/skills/dms-project/SKILL.md +6 -3
- package/data/NOTICE.md +0 -12
- package/data/dbip-country-lite.mmdb +0 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import {
|
|
2
|
+
existsSync,
|
|
3
|
+
lstatSync,
|
|
4
|
+
readdirSync,
|
|
5
|
+
realpathSync,
|
|
6
|
+
statSync,
|
|
7
|
+
} from "node:fs";
|
|
8
|
+
import { join, sep } from "node:path";
|
|
9
|
+
|
|
10
|
+
/** @typedef {Pick<import("./run-state.mjs").RunState, "moduleRoot" | "playground" | "runPlayground" | "buildRoots">} Build Where a run's build lives, and the build folders `up` found */
|
|
11
|
+
|
|
12
|
+
/** @param {string} folder */
|
|
13
|
+
function entriesOf(folder) {
|
|
14
|
+
try {
|
|
15
|
+
return readdirSync(folder);
|
|
16
|
+
} catch {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The packages `modules` links from outside any `node_modules`: workspace
|
|
23
|
+
* packages, which a build rewrites, unlike installed ones.
|
|
24
|
+
*
|
|
25
|
+
* @param {string} modules A `node_modules` folder
|
|
26
|
+
* @returns {string[]} Their real folders
|
|
27
|
+
*/
|
|
28
|
+
function workspacePackages(modules) {
|
|
29
|
+
const links = entriesOf(modules).flatMap((name) =>
|
|
30
|
+
name.startsWith("@")
|
|
31
|
+
? entriesOf(join(modules, name)).map((scoped) =>
|
|
32
|
+
join(modules, name, scoped),
|
|
33
|
+
)
|
|
34
|
+
: [join(modules, name)],
|
|
35
|
+
);
|
|
36
|
+
return links.flatMap((link) => {
|
|
37
|
+
try {
|
|
38
|
+
const real = realpathSync(link);
|
|
39
|
+
return real.split(sep).includes("node_modules") ? [] : [real];
|
|
40
|
+
} catch {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The folders a backend of the run loads its code from: the module's
|
|
48
|
+
* `dist`, the `dist` of each workspace package the module or the playground
|
|
49
|
+
* links (`@antelopejs/interface-dms` in this repository), and the run copy's
|
|
50
|
+
* playground `dist` and project build.
|
|
51
|
+
*
|
|
52
|
+
* @param {Build} state The run
|
|
53
|
+
* @returns {string[]} The folders, missing ones included
|
|
54
|
+
*/
|
|
55
|
+
function buildInputs(state) {
|
|
56
|
+
const playground = state.runPlayground ?? state.playground;
|
|
57
|
+
const linked = [state.moduleRoot, state.playground].flatMap((folder) =>
|
|
58
|
+
workspacePackages(join(folder, "node_modules")),
|
|
59
|
+
);
|
|
60
|
+
return [
|
|
61
|
+
...new Set([
|
|
62
|
+
join(state.moduleRoot, "dist"),
|
|
63
|
+
...linked.map((folder) => join(folder, "dist")),
|
|
64
|
+
join(playground, "dist"),
|
|
65
|
+
join(playground, ".antelope", "build"),
|
|
66
|
+
]),
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The build folders of the run that exist now. `up` records them once its
|
|
72
|
+
* build is done.
|
|
73
|
+
*
|
|
74
|
+
* @param {Build} state The run
|
|
75
|
+
* @returns {string[]} The folders
|
|
76
|
+
*/
|
|
77
|
+
export function existingBuildRoots(state) {
|
|
78
|
+
return buildInputs(state).filter((folder) => existsSync(folder));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A build folder `up` found that is missing now, such as a `dist` a build
|
|
83
|
+
* removed before it compiles again, or `null`. A folder the build never
|
|
84
|
+
* had, such as the `dist` of a playground that compiles nothing, is not
|
|
85
|
+
* one.
|
|
86
|
+
*
|
|
87
|
+
* @param {Build} state The run
|
|
88
|
+
* @returns {string | null} The folder
|
|
89
|
+
*/
|
|
90
|
+
export function missingBuildRoot(state) {
|
|
91
|
+
return (state.buildRoots ?? []).find((folder) => !existsSync(folder)) ?? null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* What `path` is, its link followed. A link that leads nowhere, such as one
|
|
96
|
+
* to a removed file, is only itself.
|
|
97
|
+
*
|
|
98
|
+
* @param {string} path
|
|
99
|
+
* @param {import("node:fs").Stats} link Its own status
|
|
100
|
+
* @returns {import("node:fs").Stats}
|
|
101
|
+
*/
|
|
102
|
+
function followed(path, link) {
|
|
103
|
+
if (!link.isSymbolicLink()) return link;
|
|
104
|
+
try {
|
|
105
|
+
return statSync(path);
|
|
106
|
+
} catch {
|
|
107
|
+
return link;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The first path under `path`, links followed, whose modification or
|
|
113
|
+
* status-change time is after `since`; `path` itself when it or anything
|
|
114
|
+
* under it cannot be read, as when it is missing or removed during the
|
|
115
|
+
* walk; or `null`. A link that leads nowhere counts by its own times. A
|
|
116
|
+
* rename, a write and a copy move the status-change time, and no tool sets
|
|
117
|
+
* it back.
|
|
118
|
+
*
|
|
119
|
+
* @param {string} path
|
|
120
|
+
* @param {number} since
|
|
121
|
+
* @param {Set<string>} walked The folders already walked, by device and inode, so a link cycle ends
|
|
122
|
+
* @returns {string | null}
|
|
123
|
+
*/
|
|
124
|
+
function changedUnder(path, since, walked) {
|
|
125
|
+
try {
|
|
126
|
+
const link = lstatSync(path);
|
|
127
|
+
const stats = followed(path, link);
|
|
128
|
+
const times = [link.mtimeMs, link.ctimeMs, stats.mtimeMs, stats.ctimeMs];
|
|
129
|
+
if (Math.max(...times) > since) return path;
|
|
130
|
+
const id = `${stats.dev}:${stats.ino}`;
|
|
131
|
+
if (!stats.isDirectory() || walked.has(id)) return null;
|
|
132
|
+
walked.add(id);
|
|
133
|
+
for (const name of readdirSync(path)) {
|
|
134
|
+
const changed = changedUnder(join(path, name), since, walked);
|
|
135
|
+
if (changed) return changed;
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
} catch {
|
|
139
|
+
return path;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* What of the run's build changed after `startedAt`, or `null` when a
|
|
145
|
+
* process started then loaded the build the run has now. It walks every
|
|
146
|
+
* build folder `up` found and every one that exists now. A file or folder
|
|
147
|
+
* renamed, written or copied since counts, whatever modification time it
|
|
148
|
+
* keeps, and so does a build folder that is missing or a path that could
|
|
149
|
+
* not be read during the walk.
|
|
150
|
+
*
|
|
151
|
+
* @param {Build} state The run
|
|
152
|
+
* @param {string} startedAt When the process started, as an ISO time
|
|
153
|
+
* @returns {string | null} What changed since, as `<path> changed` or `<path> is missing`
|
|
154
|
+
*/
|
|
155
|
+
export function buildChangedSince(state, startedAt) {
|
|
156
|
+
const since = Date.parse(startedAt);
|
|
157
|
+
/** @type {Set<string>} */
|
|
158
|
+
const walked = new Set();
|
|
159
|
+
const roots = new Set([
|
|
160
|
+
...(state.buildRoots ?? []),
|
|
161
|
+
...existingBuildRoots(state),
|
|
162
|
+
]);
|
|
163
|
+
for (const folder of roots) {
|
|
164
|
+
const changed = existsSync(folder)
|
|
165
|
+
? changedUnder(folder, since, walked)
|
|
166
|
+
: folder;
|
|
167
|
+
if (changed) {
|
|
168
|
+
return `${changed} ${existsSync(changed) ? "changed" : "is missing"}`;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdirSync, rmSync, symlinkSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import test from "node:test";
|
|
5
|
+
import { fixture, keyOf } from "./helpers/key-fixture.mjs";
|
|
6
|
+
import { write } from "./helpers/repo.mjs";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The key fixture with a workspace package, `packages/shared-ui`, linked
|
|
10
|
+
* into the playground's `node_modules` as pnpm links a `workspace:`
|
|
11
|
+
* dependency.
|
|
12
|
+
*
|
|
13
|
+
* @param {import("node:test").TestContext} t The test
|
|
14
|
+
*/
|
|
15
|
+
function linkedFixture(t) {
|
|
16
|
+
const keyed = fixture(t);
|
|
17
|
+
const side = keyed.prepare("run", 1001);
|
|
18
|
+
const shared = join(keyed.checkout, "packages", "shared-ui");
|
|
19
|
+
write(join(shared, "index.js"), 'export const label = "SHARED-V1";\n');
|
|
20
|
+
symlinkSync("../../packages/shared-ui", join(keyed.modules, "shared-ui"));
|
|
21
|
+
return { ...keyed, side, shared };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
await test("a .modules.yaml that is not pnpm 10's YAML refuses the key instead of keying none of its layout", (t) => {
|
|
25
|
+
const { frontend, checkout, prepare } = fixture(t);
|
|
26
|
+
const side = prepare("run", 1001);
|
|
27
|
+
const record = join(checkout, "node_modules", ".modules.yaml");
|
|
28
|
+
for (const [text, where] of [
|
|
29
|
+
[
|
|
30
|
+
`${JSON.stringify({ hoistPattern: ["*"], layoutVersion: 5 }, null, 2)}\n`,
|
|
31
|
+
"line 1",
|
|
32
|
+
],
|
|
33
|
+
[`{"hoistPattern":[],"layoutVersion":5}\n`, "line 1"],
|
|
34
|
+
["\"layoutVersion\": 5\nhoistPattern:\n - '*'\n", "line 1"],
|
|
35
|
+
['layoutVersion: 5\n"hoistPattern": []\n', "line 2"],
|
|
36
|
+
["hoistPattern:\n - '*'\n", "no layoutVersion field"],
|
|
37
|
+
]) {
|
|
38
|
+
write(record, text);
|
|
39
|
+
assert.throws(
|
|
40
|
+
() => keyOf(frontend, side),
|
|
41
|
+
new RegExp(
|
|
42
|
+
`\\.modules\\.yaml is not the YAML layout the build cache reads \\(${where}\\)`,
|
|
43
|
+
"u",
|
|
44
|
+
),
|
|
45
|
+
"a line reader keys none of pnpm 12's JSON fields, so toggling hoistPattern there keeps the key and serves a build that resolved otherwise",
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
await test("a package copied into a linked package's node_modules refuses the key", (t) => {
|
|
51
|
+
const { frontend, checkout, side, shared } = linkedFixture(t);
|
|
52
|
+
const store = join(
|
|
53
|
+
"node_modules",
|
|
54
|
+
".pnpm",
|
|
55
|
+
"color-lib@1.0.0",
|
|
56
|
+
"node_modules",
|
|
57
|
+
);
|
|
58
|
+
write(join(checkout, store, "color-lib", "index.js"), "export default 1;\n");
|
|
59
|
+
for (const name of ["color-lib", join("@acme", "color-lib")]) {
|
|
60
|
+
const copied = join(shared, "node_modules", name);
|
|
61
|
+
write(join(copied, "index.js"), 'export default "COLOR-V1";\n');
|
|
62
|
+
assert.throws(
|
|
63
|
+
() => keyOf(frontend, side),
|
|
64
|
+
new RegExp(
|
|
65
|
+
`${name} is a package copied into a linked package's node_modules`,
|
|
66
|
+
"u",
|
|
67
|
+
),
|
|
68
|
+
"a key that skips a linked package's node_modules serves the build of the copy's old files",
|
|
69
|
+
);
|
|
70
|
+
rmSync(copied, { recursive: true });
|
|
71
|
+
symlinkSync(
|
|
72
|
+
join("../".repeat(name.split("/").length + 2), store, "color-lib"),
|
|
73
|
+
copied,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
assert.match(
|
|
77
|
+
keyOf(frontend, side),
|
|
78
|
+
/^[0-9a-f]{64}$/u,
|
|
79
|
+
"a key refusing every package in a linked package's node_modules never hits in this repository, whose packages link their dependencies from pnpm's store",
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
await test("a link the key cannot follow refuses the key; a link into a keyed package or pnpm's store does not", (t) => {
|
|
84
|
+
const { dir, frontend, checkout, modules, side, shared } = linkedFixture(t);
|
|
85
|
+
const inner = join(checkout, "packages", "inner");
|
|
86
|
+
write(join(inner, "index.js"), 'export const inner = "INNER-V1";\n');
|
|
87
|
+
mkdirSync(join(shared, "node_modules"));
|
|
88
|
+
symlinkSync("../../inner", join(shared, "node_modules", "inner"));
|
|
89
|
+
const vue = join("node_modules", ".pnpm", "vue@3.5.0", "node_modules", "vue");
|
|
90
|
+
write(join(checkout, vue, "index.js"), "vue();\n");
|
|
91
|
+
symlinkSync(join("../../..", vue), join(shared, "node_modules", "vue"));
|
|
92
|
+
symlinkSync("index.js", join(shared, "alias.js"));
|
|
93
|
+
symlinkSync("missing.js", join(shared, "dangling.js"));
|
|
94
|
+
assert.throws(
|
|
95
|
+
() => keyOf(frontend, side),
|
|
96
|
+
/node_modules\/inner links to .*packages\/inner, which the build cache does not key/u,
|
|
97
|
+
"a key reading a linked package's node_modules by link text serves a build of the old files of a package linked only from inside it",
|
|
98
|
+
);
|
|
99
|
+
symlinkSync("../../packages/inner", join(modules, "inner"));
|
|
100
|
+
const covered = keyOf(frontend, side);
|
|
101
|
+
write(join(inner, "index.js"), 'export const inner = "INNER-V2";\n');
|
|
102
|
+
assert.notEqual(
|
|
103
|
+
keyOf(frontend, side),
|
|
104
|
+
covered,
|
|
105
|
+
"a nested link to a package the key reads anyway is keyed by that package's files",
|
|
106
|
+
);
|
|
107
|
+
const theme = join(dir, "elsewhere", "theme.css");
|
|
108
|
+
write(theme, "a { color: red; }\n");
|
|
109
|
+
symlinkSync(theme, join(shared, "theme.css"));
|
|
110
|
+
assert.throws(
|
|
111
|
+
() => keyOf(frontend, side),
|
|
112
|
+
/shared-ui\/theme\.css links to .*elsewhere\/theme\.css, which the build cache does not key/u,
|
|
113
|
+
"a key that hashes a link's text serves a build of the old file it reaches",
|
|
114
|
+
);
|
|
115
|
+
rmSync(join(shared, "theme.css"));
|
|
116
|
+
write(join(inner, ".dms-frontend", "dist", "chunk.js"), "built();\n");
|
|
117
|
+
symlinkSync("../inner/.dms-frontend/dist/chunk.js", join(shared, "chunk.js"));
|
|
118
|
+
assert.throws(
|
|
119
|
+
() => keyOf(frontend, side),
|
|
120
|
+
/shared-ui\/chunk\.js links to .*\.dms-frontend\/dist\/chunk\.js, which the build cache does not key/u,
|
|
121
|
+
"a key that counts a keyed package's run outputs as keyed serves a build of the output it reached",
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
await test("a link inside a package copied into node_modules that the key cannot follow refuses the key", (t) => {
|
|
126
|
+
const { dir, frontend, modules, prepare } = fixture(t);
|
|
127
|
+
const side = prepare("run", 1001);
|
|
128
|
+
const color = join(dir, "elsewhere", "color-lib");
|
|
129
|
+
write(join(color, "index.js"), 'export default "COLOR-V1";\n');
|
|
130
|
+
write(join(modules, "ui-kit", "index.js"), 'import "color-lib";\n');
|
|
131
|
+
mkdirSync(join(modules, "ui-kit", "node_modules"));
|
|
132
|
+
symlinkSync(color, join(modules, "ui-kit", "node_modules", "color-lib"));
|
|
133
|
+
assert.throws(
|
|
134
|
+
() => keyOf(frontend, side),
|
|
135
|
+
/ui-kit\/node_modules\/color-lib links to/u,
|
|
136
|
+
"a key that hashes a copied package's links by their text serves a build of the old files they reach",
|
|
137
|
+
);
|
|
138
|
+
});
|