@antelopejs/dms 0.20.0 → 0.20.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.
Files changed (144) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +19 -12
  3. package/bin/control/backend-mode.test.mjs +41 -1
  4. package/bin/control/backend-records.test.mjs +154 -100
  5. package/bin/control/backend.mjs +1 -1
  6. package/bin/control/backend.test.mjs +4 -1
  7. package/bin/control/base.mjs +6 -1
  8. package/bin/control/build-key-refusals.test.mjs +8 -8
  9. package/bin/control/build-key.mjs +8 -6
  10. package/bin/control/build-key.test.mjs +3 -2
  11. package/bin/control/build-layout.test.mjs +5 -4
  12. package/bin/control/forwarder.test.mjs +19 -11
  13. package/bin/control/helpers/fake-run.mjs +59 -60
  14. package/bin/control/helpers/key-fixture.mjs +1 -1
  15. package/bin/control/helpers/pids.mjs +10 -0
  16. package/bin/control/helpers/tree.mjs +4 -4
  17. package/bin/control/journey.test.mjs +32 -32
  18. package/bin/control/mongo-server.test.mjs +64 -19
  19. package/bin/control/mongo.mjs +12 -3
  20. package/bin/control/namespaces.test.mjs +50 -31
  21. package/bin/control/processes.mjs +13 -1
  22. package/bin/control/processes.test.mjs +98 -64
  23. package/bin/control/renderer.test.mjs +2 -2
  24. package/bin/control/run-ports.test.mjs +24 -9
  25. package/bin/control/stack.mjs +16 -3
  26. package/bin/control/tab.test.mjs +1 -1
  27. package/bin/control/verify/formal.test.mjs +2 -2
  28. package/checks/dms-components.d.mts +38 -0
  29. package/data/mockup-spec.schema.json +4 -2
  30. package/data/module-store/catalog.json +1 -7
  31. package/dist/builder.js +2 -1
  32. package/dist/builder.js.map +1 -1
  33. package/dist/crons/cleanup-user-invites.js +7 -1
  34. package/dist/crons/cleanup-user-invites.js.map +1 -1
  35. package/dist/dev/module-update-notifications.js +2 -4
  36. package/dist/dev/module-update-notifications.js.map +1 -1
  37. package/dist/implementations/dms/dev-handshake.js +2 -5
  38. package/dist/implementations/dms/dev-handshake.js.map +1 -1
  39. package/dist/implementations/dms-auth/index.d.ts +3 -4
  40. package/dist/implementations/dms-auth/index.js +20 -4
  41. package/dist/implementations/dms-auth/index.js.map +1 -1
  42. package/dist/implementations/dms-auth/token-session.d.ts +2 -2
  43. package/dist/implementations/dms-auth/token-session.js +1 -4
  44. package/dist/implementations/dms-auth/token-session.js.map +1 -1
  45. package/dist/implementations/dms-builder/engine/connection-access-config.js +2 -7
  46. package/dist/implementations/dms-builder/engine/connection-access-config.js.map +1 -1
  47. package/dist/implementations/dms-builder/engine/driver-packages.js +4 -1
  48. package/dist/implementations/dms-builder/engine/driver-packages.js.map +1 -1
  49. package/dist/implementations/dms-builder/engine/file-paths.d.ts +3 -0
  50. package/dist/implementations/dms-builder/engine/file-paths.js +18 -0
  51. package/dist/implementations/dms-builder/engine/file-paths.js.map +1 -0
  52. package/dist/implementations/dms-builder/engine/index.d.ts +2 -0
  53. package/dist/implementations/dms-builder/engine/index.js +2 -0
  54. package/dist/implementations/dms-builder/engine/index.js.map +1 -1
  55. package/dist/implementations/dms-builder/engine/inherited-variables.d.ts +2 -0
  56. package/dist/implementations/dms-builder/engine/inherited-variables.js +19 -0
  57. package/dist/implementations/dms-builder/engine/inherited-variables.js.map +1 -0
  58. package/dist/implementations/dms-builder/engine/map-resources.js +1 -1
  59. package/dist/implementations/dms-builder/engine/map-resources.js.map +1 -1
  60. package/dist/implementations/dms-builder/engine/modules.js +3 -5
  61. package/dist/implementations/dms-builder/engine/modules.js.map +1 -1
  62. package/dist/implementations/dms-builder/engine/placement.js +2 -1
  63. package/dist/implementations/dms-builder/engine/placement.js.map +1 -1
  64. package/dist/implementations/dms-builder/engine/project-config-ops.js +2 -1
  65. package/dist/implementations/dms-builder/engine/project-config-ops.js.map +1 -1
  66. package/dist/implementations/dms-builder/engine/project-env.js +5 -0
  67. package/dist/implementations/dms-builder/engine/project-env.js.map +1 -1
  68. package/dist/implementations/dms-builder/engine/project-scaffold.js +18 -8
  69. package/dist/implementations/dms-builder/engine/project-scaffold.js.map +1 -1
  70. package/dist/implementations/dms-builder/engine/theme-app-config.d.ts +1 -1
  71. package/dist/implementations/dms-builder/engine/theme-app-config.js +96 -22
  72. package/dist/implementations/dms-builder/engine/theme-app-config.js.map +1 -1
  73. package/dist/mcp/project-files.js +2 -8
  74. package/dist/mcp/project-files.js.map +1 -1
  75. package/dist/mcp/tools/preview-blocks.js +8 -24
  76. package/dist/mcp/tools/preview-blocks.js.map +1 -1
  77. package/dist/mcp/tools/typecheck.js +2 -5
  78. package/dist/mcp/tools/typecheck.js.map +1 -1
  79. package/dist/mockup/json-schema.js +2 -2
  80. package/dist/mockup/json-schema.js.map +1 -1
  81. package/dist/mockup/sketch-allowlist.d.ts +11 -0
  82. package/dist/mockup/sketch-allowlist.js +368 -0
  83. package/dist/mockup/sketch-allowlist.js.map +1 -0
  84. package/dist/mockup/sketch-css.d.ts +3 -0
  85. package/dist/mockup/sketch-css.js +306 -0
  86. package/dist/mockup/sketch-css.js.map +1 -0
  87. package/dist/mockup/sketch-html.d.ts +7 -0
  88. package/dist/mockup/sketch-html.js +243 -0
  89. package/dist/mockup/sketch-html.js.map +1 -0
  90. package/dist/mockup/sketch-limits.d.ts +1 -0
  91. package/dist/mockup/sketch-limits.js +5 -0
  92. package/dist/mockup/sketch-limits.js.map +1 -0
  93. package/dist/mockup/sketch-scan.d.ts +1 -0
  94. package/dist/mockup/sketch-scan.js +136 -0
  95. package/dist/mockup/sketch-scan.js.map +1 -0
  96. package/dist/mockup/sketch-tokens.d.ts +22 -0
  97. package/dist/mockup/sketch-tokens.js +42 -0
  98. package/dist/mockup/sketch-tokens.js.map +1 -0
  99. package/dist/mockup/sketch.d.ts +19 -1
  100. package/dist/mockup/sketch.js +78 -94
  101. package/dist/mockup/sketch.js.map +1 -1
  102. package/dist/routes/auth/logout.d.ts +2 -2
  103. package/dist/routes/auth/logout.js +3 -9
  104. package/dist/routes/auth/logout.js.map +1 -1
  105. package/dist/routes/auth/refresh.js +6 -8
  106. package/dist/routes/auth/refresh.js.map +1 -1
  107. package/dist/routes/auth/switch-tenant.js +8 -11
  108. package/dist/routes/auth/switch-tenant.js.map +1 -1
  109. package/dist/routes/auth.js +1 -1
  110. package/dist/routes/auth.js.map +1 -1
  111. package/dist/store/registry.js +2 -4
  112. package/dist/store/registry.js.map +1 -1
  113. package/dist/store/tarball.js +12 -6
  114. package/dist/store/tarball.js.map +1 -1
  115. package/dist/utils/index.d.ts +1 -0
  116. package/dist/utils/index.js +1 -0
  117. package/dist/utils/index.js.map +1 -1
  118. package/dist/utils/owner-only-file.d.ts +1 -0
  119. package/dist/utils/owner-only-file.js +60 -0
  120. package/dist/utils/owner-only-file.js.map +1 -0
  121. package/dist/utils/package-manager/index.d.ts +1 -0
  122. package/dist/utils/package-manager/index.js +18 -0
  123. package/dist/utils/package-manager/index.js.map +1 -0
  124. package/dist/utils/package-manager.d.ts +12 -0
  125. package/dist/utils/package-manager.js +28 -0
  126. package/dist/utils/package-manager.js.map +1 -0
  127. package/frontend-vue/layers/dms-auth/app/middleware/auth.ts +11 -7
  128. package/frontend-vue/layers/dms-layout/app/composables/useHeaderActions.ts +4 -4
  129. package/frontend-vue/layers/dms-layout/i18n/locales/layout-en-GB.json +0 -4
  130. package/frontend-vue/layers/dms-layout/i18n/locales/layout-fr-FR.json +0 -4
  131. package/frontend-vue/layers/dms-ui/app/build/utils/sketch.ts +9 -0
  132. package/frontend-vue/package.json +1 -1
  133. package/frontend-vue/scripts/check-autoimport-boundaries.mjs +12 -7
  134. package/frontend-vue/scripts/check-dms-components.mjs +519 -0
  135. package/frontend-vue/scripts/check-invariants.mjs +7 -1
  136. package/frontend-vue/scripts/dms-components-dependencies.mjs +89 -0
  137. package/frontend-vue/scripts/test-dms-components.mjs +255 -0
  138. package/package.json +29 -16
  139. package/skills/dms/REFERENCE.md +1 -1
  140. package/skills/dms/SKILL.md +1 -1
  141. package/skills/dms-module/SKILL.md +1 -1
  142. package/skills/dms-module/cases.json +3 -3
  143. package/skills/dms-project/SKILL.md +1 -1
  144. package/skills/dms-project/scripts/dms-dev.sh +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,66 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.20.1
4
+
5
+ [compare changes](https://github.com/AntelopeJS/dms/compare/v0.20.0...v0.20.1)
6
+
7
+ ### 🚀 Enhancements
8
+
9
+ - **dms:** Fail a layer's lint on a Dms component nothing installed registers ([#1033](https://github.com/AntelopeJS/dms/pull/1033))
10
+
11
+ ### 🩹 Fixes
12
+
13
+ - **dms:** Restrict credential files to their owner on Windows ([#1008](https://github.com/AntelopeJS/dms/pull/1008))
14
+ - **dms:** Keep a logo file the app config builds with +, concat or join ([#1024](https://github.com/AntelopeJS/dms/pull/1024))
15
+ - **interface-dms:** Keep one pending invite when a cancel, accept or expiry lands during a fresh invite's withdrawal ([#1021](https://github.com/AntelopeJS/dms/pull/1021))
16
+ - **dms:** Install a scaffolded module outside the project's pnpm workspace ([#1022](https://github.com/AntelopeJS/dms/pull/1022))
17
+ - **dms:** Check preview_blocks sketches with the mockup compiler's sanitizer and publish it as @antelopejs/dms/sketch ([#1009](https://github.com/AntelopeJS/dms/pull/1009))
18
+ - **dms:** Offer the MySQL driver on interface-database 0.4 ([#1029](https://github.com/AntelopeJS/dms/pull/1029))
19
+ - **dms:** Capture the auth middleware's toast before its first await ([#1031](https://github.com/AntelopeJS/dms/pull/1031))
20
+ - **dms:** Finish a dms-control watch restart of the playground ([#1035](https://github.com/AntelopeJS/dms/pull/1035))
21
+ - **dms:** Keep a logo the app config names in a query, a fragment or a literal-only join ([#1036](https://github.com/AntelopeJS/dms/pull/1036))
22
+ - **interface-dms:** Let a resend through a withdrawn fresh invite left by a failed delete, and name the invite that blocks it ([#1037](https://github.com/AntelopeJS/dms/pull/1037))
23
+ - **deps:** Require zod 3.25 in interface-dms and dms so a reused lock drops zod 3.24 ([#1039](https://github.com/AntelopeJS/dms/pull/1039))
24
+ - **interface-dms:** Hand a fresh invite whose rival retires during its withdrawal a pending invitation ([#1038](https://github.com/AntelopeJS/dms/pull/1038))
25
+ - **dms:** Refuse access and refresh tokens that carry no session ([#1042](https://github.com/AntelopeJS/dms/pull/1042))
26
+ - **dms:** Keep a logo the app config names in a percent-encoded optimizer URL ([#1041](https://github.com/AntelopeJS/dms/pull/1041))
27
+ - **interface-dms:** Keep a new invitation's re-read when its stray-removal retry finds the read invite cancelled ([#1045](https://github.com/AntelopeJS/dms/pull/1045))
28
+ - **dms:** Run the DMS component check without @antelopejs/dms-frontend, and name what a layer must install ([#1044](https://github.com/AntelopeJS/dms/pull/1044))
29
+ - **interface-dms:** Settle a fresh invite once as kept or withdrawn, so no caller yields to one that then withdraws ([#1046](https://github.com/AntelopeJS/dms/pull/1046))
30
+ - **dms:** Report a connection variable the starting environment shadows instead of writing it to .env ([#1049](https://github.com/AntelopeJS/dms/pull/1049))
31
+ - **dms:** Let a restart load a .env value after a builder call loaded the configuration ([#1050](https://github.com/AntelopeJS/dms/pull/1050))
32
+ - **deps:** Cap every @antelopejs range below the next minor ([#1051](https://github.com/AntelopeJS/dms/pull/1051))
33
+
34
+ ### 📖 Documentation
35
+
36
+ - **interface-dms-builder:** Say when a second catalog provider needs exportPriority or a pin ([#1026](https://github.com/AntelopeJS/dms/pull/1026))
37
+ - **dms:** Replace dms-ai and dms-builder with dms-assistant ([#894](https://github.com/AntelopeJS/dms/pull/894))
38
+ - Name the assistant dms-assistant where dms-ai was left ([#1048](https://github.com/AntelopeJS/dms/pull/1048))
39
+
40
+ ### 🏡 Chore
41
+
42
+ - **release:** @antelopejs/interface-dms v0.14.1 ([a53e6e9b](https://github.com/AntelopeJS/dms/commit/a53e6e9b))
43
+ - **release:** @antelopejs/interface-dms v0.14.2 ([82a1a90e](https://github.com/AntelopeJS/dms/commit/82a1a90e))
44
+
45
+ ### ✅ Tests
46
+
47
+ - **dms:** Let the invite host take any zod 3.x and spawn npm through its Windows shim ([#1023](https://github.com/AntelopeJS/dms/pull/1023))
48
+ - **dms:** Load TableView in the table runtime setup, not the first test ([#1025](https://github.com/AntelopeJS/dms/pull/1025))
49
+ - **dms:** Acknowledge test MongoDB writes on apply so Windows integration runs stop stalling ([#1027](https://github.com/AntelopeJS/dms/pull/1027))
50
+ - **dms:** Restore the mail renderer and sender after each suite that captures emails ([#1030](https://github.com/AntelopeJS/dms/pull/1030))
51
+ - **dms:** Give the menu-access-events setup hook a timeout sized to its sign-ups ([#1032](https://github.com/AntelopeJS/dms/pull/1032))
52
+ - **dms:** Size the sketch rebuild test's timeout to its seventeen checks ([#1040](https://github.com/AntelopeJS/dms/pull/1040))
53
+ - **dms:** Keep the integration file storage off the test mongod's disk ([#1028](https://github.com/AntelopeJS/dms/pull/1028))
54
+ - **dms:** Move cold module and Intl setup out of two frontend-vue test bodies ([#1047](https://github.com/AntelopeJS/dms/pull/1047))
55
+
56
+ ### 🤖 CI
57
+
58
+ - Run the CI on Windows in parallel with Linux ([#906](https://github.com/AntelopeJS/dms/pull/906))
59
+
60
+ ### ❤️ Contributors
61
+
62
+ - Antony Rizzitelli ([@Upd4ting](http://github.com/Upd4ting))
63
+
3
64
  ## v0.20.0
4
65
 
5
66
  [compare changes](https://github.com/AntelopeJS/dms/compare/v0.19.6...v0.20.0)
package/README.md CHANGED
@@ -79,20 +79,20 @@ export class SalesPage extends PageController("sales", {
79
79
 
80
80
  | Package | Supported | Tested with |
81
81
  | ------------------------------------------- | ------------------ | ----------- |
82
- | `@antelopejs/core` | `>=1.23.0 <2` | `1.23.0` |
83
- | `@antelopejs/interface-api` | `>=0.3.2 <1.0.0` | `0.3.2` |
84
- | `@antelopejs/interface-api-util` | `>=0.3.0 <1.0.0` | `0.3.0` |
85
- | `@antelopejs/interface-core` | `>=0.5.1 <1.0.0` | `0.5.1` |
86
- | `@antelopejs/interface-data-api` | `>=0.8.0 <1.0.0` | `0.8.0` |
87
- | `@antelopejs/interface-database` | `>=0.4.0 <1.0.0` | `0.4.0` |
88
- | `@antelopejs/interface-database-catalog` | `>=0.0.3 <1.0.0` | `0.0.3` |
89
- | `@antelopejs/interface-database-decorators` | `>=0.5.2 <1.0.0` | `0.5.2` |
82
+ | `@antelopejs/core` | `~1.23.0` | `1.23.0` |
83
+ | `@antelopejs/interface-api` | `>=0.3.2 <0.4.0` | `0.3.2` |
84
+ | `@antelopejs/interface-api-util` | `>=0.3.0 <0.4.0` | `0.3.0` |
85
+ | `@antelopejs/interface-core` | `>=0.5.1 <0.6.0` | `0.5.1` |
86
+ | `@antelopejs/interface-data-api` | `>=0.8.0 <0.9.0` | `0.8.0` |
87
+ | `@antelopejs/interface-database` | `>=0.4.0 <0.5.0` | `0.4.0` |
88
+ | `@antelopejs/interface-database-catalog` | `>=0.0.3 <0.1.0` | `0.0.3` |
89
+ | `@antelopejs/interface-database-decorators` | `>=0.5.2 <0.6.0` | `0.5.2` |
90
90
  | `@antelopejs/interface-dms` | `>=0.14.0 <0.15.0` | `workspace` |
91
- | `@antelopejs/interface-dms-automation` | `>=0.6.0 <1.0.0` | `0.6.1` |
91
+ | `@antelopejs/interface-dms-automation` | `>=0.7.0 <0.8.0` | `0.7.0` |
92
92
  | `@antelopejs/interface-dms-builder` | `>=0.5.0 <0.6.0` | `workspace` |
93
- | `@antelopejs/interface-email` | `>=0.0.6 <1.0.0` | `0.0.6` |
94
- | `@antelopejs/interface-file-storage` | `>=0.1.4 <1.0.0` | `0.1.4` |
95
- | `@antelopejs/interface-redis` | `>=0.0.9 <1.0.0` | `0.0.9` |
93
+ | `@antelopejs/interface-email` | `>=0.2.1 <0.3.0` | `0.2.1` |
94
+ | `@antelopejs/interface-file-storage` | `>=0.1.4 <0.2.0` | `0.1.4` |
95
+ | `@antelopejs/interface-redis` | `>=0.0.9 <0.1.0` | `0.0.9` |
96
96
 
97
97
  <!-- antelopejs-docs-compat:end -->
98
98
 
@@ -119,3 +119,10 @@ This package lives in the [`AntelopeJS/dms`](https://github.com/AntelopeJS/dms)
119
119
  ## License
120
120
 
121
121
  [Apache-2.0](./LICENSE)
122
+
123
+ ## Requirements
124
+
125
+ <!-- antelopejs-docs-node:start -->
126
+
127
+ This package requires Node.js `^20.19.0 || >=22.12.0`.
128
+ <!-- antelopejs-docs-node:end -->
@@ -1,7 +1,14 @@
1
1
  import assert from "node:assert/strict";
2
+ import { join } from "node:path";
2
3
  import test from "node:test";
3
4
  import { freshDatabase, restartBackend } from "./backend.mjs";
4
- import { commandOf, newRun, served, startedOn } from "./helpers/fake-run.mjs";
5
+ import {
6
+ commandOf,
7
+ moduleRootOfBackend,
8
+ newRun,
9
+ served,
10
+ startedOn,
11
+ } from "./helpers/fake-run.mjs";
5
12
  import { isRunning } from "./identity.mjs";
6
13
  import { loadRun, saveRun } from "./run-state.mjs";
7
14
 
@@ -63,6 +70,39 @@ await test("a journey that pins watch gets ajs project dev -w, not the dev stand
63
70
  );
64
71
  });
65
72
 
73
+ await test("a watch backend loads the module from the checkout's module folder, which the run's copy only links to, and a production or dev backend from the copy", async (t) => {
74
+ const state = await newRun(t);
75
+ await freshDatabase(state, "j001", { backend: "watch" });
76
+ const watching = await served(state);
77
+ await restartBackend(state);
78
+ const restarted = await served(state);
79
+ await freshDatabase(state, "j002");
80
+ const production = await served(state);
81
+ await freshDatabase(state, "j003", { backend: "dev" });
82
+ const dev = await served(state);
83
+ assert.deepEqual(
84
+ await Promise.all(
85
+ [watching, restarted, production, dev].map(({ pid }) =>
86
+ moduleRootOfBackend(pid),
87
+ ),
88
+ ),
89
+ [state.moduleRoot, state.moduleRoot, null, null],
90
+ );
91
+ });
92
+
93
+ await test("a watch backend restarted on another build, as the base version's, loads that build's module folder", async (t) => {
94
+ const state = await newRun(t);
95
+ await freshDatabase(state, "j001", { backend: "watch" });
96
+ const baseModuleRoot = join(state.dir, "base-module");
97
+ await restartBackend(state, {
98
+ playground: state.playground,
99
+ cwd: state.runPlayground ?? state.playground,
100
+ moduleRoot: baseModuleRoot,
101
+ });
102
+ const base = await served(state);
103
+ assert.equal(await moduleRootOfBackend(base.pid), baseModuleRoot);
104
+ });
105
+
66
106
  await test("a restart inside a journey that pins production in a dev run keeps production", async (t) => {
67
107
  const state = await newRun(t);
68
108
  state.backendMode = "dev";
@@ -15,7 +15,7 @@ import {
15
15
  withoutStartTimes,
16
16
  } from "./helpers/fake-run.mjs";
17
17
  import { canChoosePid, chooseNextPid } from "./helpers/pids.mjs";
18
- import { isRunning } from "./identity.mjs";
18
+ import { hasProc, isRunning } from "./identity.mjs";
19
19
  import { startDetached } from "./processes.mjs";
20
20
  import { backendsFolder, recordBackend } from "./run-state.mjs";
21
21
  import { down, liveBackends } from "./stack.mjs";
@@ -34,45 +34,61 @@ function stderrOf(t) {
34
34
  write.mock.calls.map((call) => String(call.arguments[0])).join("");
35
35
  }
36
36
 
37
- await test("a process that took the pid of a backend the run recorded is not stopped, even with that backend's database in its environment", async (t) => {
38
- const state = await newRun(t);
39
- await freshDatabase(state, "j001");
40
- const database = `${state.databasePrefix}_j002`;
41
- const standby = await startedOn(database);
42
- const record = liveBackends(state).find(
43
- (backend) => backend.pid === standby.pid,
44
- );
45
- assert.ok(record, "the standby is recorded");
46
- const other = bystander(t, { ...process.env, MONGO_DATABASE: database });
47
- recordBackend(state.dir, { ...record, pid: other });
48
- await freshDatabase(state, "r1");
49
- assert.equal(isRunning(other), true);
50
- await down(state);
51
- assert.equal(isRunning(other), true);
52
- assert.deepEqual(running(), []);
53
- });
37
+ await test(
38
+ "a process that took the pid of a backend the run recorded is not stopped, even with that backend's database in its environment",
39
+ {
40
+ skip:
41
+ !hasProc() &&
42
+ "a start time tells a process from another that took its pid, and only /proc gives one",
43
+ },
44
+ async (t) => {
45
+ const state = await newRun(t);
46
+ await freshDatabase(state, "j001");
47
+ const database = `${state.databasePrefix}_j002`;
48
+ const standby = await startedOn(database);
49
+ const record = liveBackends(state).find(
50
+ (backend) => backend.pid === standby.pid,
51
+ );
52
+ assert.ok(record, "the standby is recorded");
53
+ const other = bystander(t, { ...process.env, MONGO_DATABASE: database });
54
+ recordBackend(state.dir, { ...record, pid: other });
55
+ await freshDatabase(state, "r1");
56
+ assert.equal(isRunning(other), true);
57
+ await down(state);
58
+ assert.equal(isRunning(other), true);
59
+ assert.deepEqual(running(), []);
60
+ },
61
+ );
54
62
 
55
- await test("a process that took the pid of a process run.json records is not stopped by a restart or by down", async (t) => {
56
- const state = await newRun(t);
57
- await freshDatabase(state, "j001");
58
- const serving = state.processes.find((entry) => entry.name === "backend");
59
- assert.ok(serving, "run.json records the backend");
60
- const other = bystander(t, {
61
- ...process.env,
62
- MONGO_DATABASE: state.database,
63
- });
64
- const reused = { ...serving, pid: other };
65
- state.processes = state.processes.map((entry) =>
66
- entry === serving ? reused : entry,
67
- );
68
- await restartBackend(state);
69
- assert.equal(isRunning(other), true);
70
- assert.equal((await served(state)).database, state.database);
71
- state.processes = [...state.processes, { ...reused, name: "frontend" }];
72
- await down(state);
73
- assert.equal(isRunning(other), true);
74
- assert.deepEqual(running(), []);
75
- });
63
+ await test(
64
+ "a process that took the pid of a process run.json records is not stopped by a restart or by down",
65
+ {
66
+ skip:
67
+ !hasProc() &&
68
+ "a start time tells a process from another that took its pid, and only /proc gives one",
69
+ },
70
+ async (t) => {
71
+ const state = await newRun(t);
72
+ await freshDatabase(state, "j001");
73
+ const serving = state.processes.find((entry) => entry.name === "backend");
74
+ assert.ok(serving, "run.json records the backend");
75
+ const other = bystander(t, {
76
+ ...process.env,
77
+ MONGO_DATABASE: state.database,
78
+ });
79
+ const reused = { ...serving, pid: other };
80
+ state.processes = state.processes.map((entry) =>
81
+ entry === serving ? reused : entry,
82
+ );
83
+ await restartBackend(state);
84
+ assert.equal(isRunning(other), true);
85
+ assert.equal((await served(state)).database, state.database);
86
+ state.processes = [...state.processes, { ...reused, name: "frontend" }];
87
+ await down(state);
88
+ assert.equal(isRunning(other), true);
89
+ assert.deepEqual(running(), []);
90
+ },
91
+ );
76
92
 
77
93
  await test("a backend record removed while the records are read counts as gone", async (t) => {
78
94
  const state = await newRun(t);
@@ -165,42 +181,58 @@ function forwarderOf(state) {
165
181
  return api;
166
182
  }
167
183
 
168
- await test("a run.json record without a start time, as an earlier dms-control wrote, is stopped by down only while its pid runs a process started when the record says; a version that trusts the pid alone stops a process started days later", async (t) => {
169
- const state = await newRun(t);
170
- const later = bystander(t);
171
- const own = bystander(t);
172
- const now = new Date();
173
- /**
174
- * @param {string} name
175
- * @param {number} pid
176
- * @param {Date} at
177
- */
178
- const recorded = (name, pid, at) => ({
179
- name,
180
- pid,
181
- command: "a process an earlier dms-control started",
182
- cwd: state.dir,
183
- log: join(state.logs, `${name}.log`),
184
- startedAt: at.toISOString(),
185
- });
186
- state.processes = [
187
- recorded("frontend", later, new Date(now.getTime() - SIX_DAYS_MS)),
188
- recorded("mail", own, now),
189
- ];
190
- await down(state);
191
- assert.equal(isRunning(later), true);
192
- assert.equal(isRunning(own), false);
193
- });
184
+ await test(
185
+ "a run.json record without a start time, as an earlier dms-control wrote, is stopped by down only while its pid runs a process started when the record says; a version that trusts the pid alone stops a process started days later",
186
+ {
187
+ skip:
188
+ !hasProc() &&
189
+ "a start time tells a process from another that took its pid, and only /proc gives one",
190
+ },
191
+ async (t) => {
192
+ const state = await newRun(t);
193
+ const later = bystander(t);
194
+ const own = bystander(t);
195
+ const now = new Date();
196
+ /**
197
+ * @param {string} name
198
+ * @param {number} pid
199
+ * @param {Date} at
200
+ */
201
+ const recorded = (name, pid, at) => ({
202
+ name,
203
+ pid,
204
+ command: "a process an earlier dms-control started",
205
+ cwd: state.dir,
206
+ log: join(state.logs, `${name}.log`),
207
+ startedAt: at.toISOString(),
208
+ });
209
+ state.processes = [
210
+ recorded("frontend", later, new Date(now.getTime() - SIX_DAYS_MS)),
211
+ recorded("mail", own, now),
212
+ ];
213
+ await down(state);
214
+ assert.equal(isRunning(later), true);
215
+ assert.equal(isRunning(own), false);
216
+ },
217
+ );
194
218
 
195
- await test("a backend record without a start time, as this branch wrote before, is stopped by down; a version that skips such a record leaves the standby running", async (t) => {
196
- const state = await newRun(t);
197
- await freshDatabase(state, "j001");
198
- await startedOn(`${state.databasePrefix}_j002`);
199
- assert.equal(withoutStartTimes(state), 2);
200
- assert.equal(liveBackends(state).length, 2);
201
- await down(state);
202
- assert.deepEqual(running(), []);
203
- });
219
+ await test(
220
+ "a backend record without a start time, as this branch wrote before, is stopped by down; a version that skips such a record leaves the standby running",
221
+ {
222
+ skip:
223
+ !hasProc() &&
224
+ "only /proc gives a start time, so no record holds one to leave out",
225
+ },
226
+ async (t) => {
227
+ const state = await newRun(t);
228
+ await freshDatabase(state, "j001");
229
+ await startedOn(`${state.databasePrefix}_j002`);
230
+ assert.equal(withoutStartTimes(state), 2);
231
+ assert.equal(liveBackends(state).length, 2);
232
+ await down(state);
233
+ assert.deepEqual(running(), []);
234
+ },
235
+ );
204
236
 
205
237
  await test(
206
238
  "a recorded backend that exits while a fresh database waits for the standby, and whose pid another process takes, is not signalled; a version that kills from the list it read before the wait kills that process",
@@ -247,30 +279,52 @@ await test(
247
279
  },
248
280
  );
249
281
 
250
- await test("a forwarder that exited, whose pid another process holds, is started again and the API answers; a version that trusts a live pid leaves the API port closed", async (t) => {
251
- const state = await newRun(t);
252
- await freshDatabase(state, "j001");
253
- const api = forwarderOf(state);
254
- process.kill(api.pid, "SIGKILL");
255
- while (isRunning(api.pid)) await sleep(20);
256
- const other = bystander(t);
257
- state.processes = state.processes.map((entry) =>
258
- entry === api ? { ...api, pid: other } : entry,
259
- );
260
- await freshDatabase(state, "j002");
261
- assert.equal((await served(state)).database, `${state.databasePrefix}_j002`);
262
- assert.equal(isRunning(other), true);
263
- });
282
+ await test(
283
+ "a forwarder that exited, whose pid another process holds, is started again and the API answers; a version that trusts a live pid leaves the API port closed",
284
+ {
285
+ skip:
286
+ !hasProc() &&
287
+ "a start time tells a process from another that took its pid, and only /proc gives one",
288
+ },
289
+ async (t) => {
290
+ const state = await newRun(t);
291
+ await freshDatabase(state, "j001");
292
+ const api = forwarderOf(state);
293
+ process.kill(api.pid, "SIGKILL");
294
+ while (isRunning(api.pid)) await sleep(20);
295
+ const other = bystander(t);
296
+ state.processes = state.processes.map((entry) =>
297
+ entry === api ? { ...api, pid: other } : entry,
298
+ );
299
+ await freshDatabase(state, "j002");
300
+ assert.equal(
301
+ (await served(state)).database,
302
+ `${state.databasePrefix}_j002`,
303
+ );
304
+ assert.equal(isRunning(other), true);
305
+ },
306
+ );
264
307
 
265
- await test("doctor fails a recorded process whose pid another process holds; a version that checks only that the pid is alive passes it", async (t) => {
266
- const state = await newRun(t);
267
- await freshDatabase(state, "j001");
268
- const api = forwarderOf(state);
269
- const other = bystander(t);
270
- state.processes = [...state.processes, { ...api, name: "mail", pid: other }];
271
- const lines = await doctor(state);
272
- const okOf = (/** @type {string} */ check) =>
273
- lines.find((line) => line.check === check)?.ok;
274
- assert.equal(okOf(`api pid ${api.pid} alive`), true);
275
- assert.equal(okOf(`mail pid ${other} alive`), false);
276
- });
308
+ await test(
309
+ "doctor fails a recorded process whose pid another process holds; a version that checks only that the pid is alive passes it",
310
+ {
311
+ skip:
312
+ !hasProc() &&
313
+ "a start time tells a process from another that took its pid, and only /proc gives one",
314
+ },
315
+ async (t) => {
316
+ const state = await newRun(t);
317
+ await freshDatabase(state, "j001");
318
+ const api = forwarderOf(state);
319
+ const other = bystander(t);
320
+ state.processes = [
321
+ ...state.processes,
322
+ { ...api, name: "mail", pid: other },
323
+ ];
324
+ const lines = await doctor(state);
325
+ const okOf = (/** @type {string} */ check) =>
326
+ lines.find((line) => line.check === check)?.ok;
327
+ assert.equal(okOf(`api pid ${api.pid} alive`), true);
328
+ assert.equal(okOf(`mail pid ${other} alive`), false);
329
+ },
330
+ );
@@ -47,7 +47,7 @@ export function assertForwardedRun(state) {
47
47
  * so a restart inside a journey keeps the mode the journey asked for.
48
48
  *
49
49
  * @param {RunState} state The run
50
- * @param {{ playground: string, cwd: string }} [build] Another build to start
50
+ * @param {{ playground: string, cwd: string, moduleRoot: string }} [build] Another build to start
51
51
  * @returns {Promise<void>} Resolves once the backend answers again
52
52
  */
53
53
  export async function restartBackend(state, build) {
@@ -11,6 +11,7 @@ import {
11
11
  utimesSync,
12
12
  writeFileSync,
13
13
  } from "node:fs";
14
+ import { platform } from "node:os";
14
15
  import { dirname, join } from "node:path";
15
16
  import test from "node:test";
16
17
  import { freshDatabase, restartBackend } from "./backend.mjs";
@@ -190,7 +191,9 @@ await test("while a build folder is missing, a fresh database refuses before it
190
191
  await test(
191
192
  "a build folder that cannot be read keeps a standby from being used; a version that counts what it cannot read as unchanged uses it",
192
193
  {
193
- skip: process.getuid?.() === 0 && "root reads a folder whatever its mode",
194
+ skip:
195
+ (process.getuid?.() === 0 && "root reads a folder whatever its mode") ||
196
+ (platform() === "win32" && "Windows reads a folder whatever its mode"),
194
197
  },
195
198
  async (t) => {
196
199
  const state = await newRun(t);
@@ -8,6 +8,7 @@ import { runPrepare } from "./verify/skill.mjs";
8
8
  import { COPY_SKIPPED, layOutCopy } from "./run-copy.mjs";
9
9
  import { cliPaths, ENVIRONMENT, spec } from "./launch.mjs";
10
10
  import { restartBackend } from "./backend.mjs";
11
+ import { moduleRootOf } from "./module-root.mjs";
11
12
 
12
13
  const READY_MARK = ".dms-control-ready";
13
14
 
@@ -84,7 +85,11 @@ export async function withBaseBackend(state, skill, action) {
84
85
  cwd,
85
86
  ),
86
87
  );
87
- await restartBackend(state, { playground, cwd });
88
+ await restartBackend(state, {
89
+ playground,
90
+ cwd,
91
+ moduleRoot: moduleRootOf(playground, base.dir),
92
+ });
88
93
  try {
89
94
  await action(base.sha);
90
95
  } finally {
@@ -56,20 +56,20 @@ await test("a package copied into a linked package's node_modules refuses the ke
56
56
  "node_modules",
57
57
  );
58
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);
59
+ for (const name of [["color-lib"], ["@acme", "color-lib"]]) {
60
+ const copied = join(shared, "node_modules", ...name);
61
61
  write(join(copied, "index.js"), 'export default "COLOR-V1";\n');
62
62
  assert.throws(
63
63
  () => keyOf(frontend, side),
64
64
  new RegExp(
65
- `${name} is a package copied into a linked package's node_modules`,
65
+ `${name.join("[\\\\/]")} is a package copied into a linked package's node_modules`,
66
66
  "u",
67
67
  ),
68
68
  "a key that skips a linked package's node_modules serves the build of the copy's old files",
69
69
  );
70
70
  rmSync(copied, { recursive: true });
71
71
  symlinkSync(
72
- join("../".repeat(name.split("/").length + 2), store, "color-lib"),
72
+ join("../".repeat(name.length + 2), store, "color-lib"),
73
73
  copied,
74
74
  );
75
75
  }
@@ -93,7 +93,7 @@ await test("a link the key cannot follow refuses the key; a link into a keyed pa
93
93
  symlinkSync("missing.js", join(shared, "dangling.js"));
94
94
  assert.throws(
95
95
  () => keyOf(frontend, side),
96
- /node_modules\/inner links to .*packages\/inner, which the build cache does not key/u,
96
+ /node_modules[\\/]inner links to .*packages[\\/]inner, which the build cache does not key/u,
97
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
98
  );
99
99
  symlinkSync("../../packages/inner", join(modules, "inner"));
@@ -109,7 +109,7 @@ await test("a link the key cannot follow refuses the key; a link into a keyed pa
109
109
  symlinkSync(theme, join(shared, "theme.css"));
110
110
  assert.throws(
111
111
  () => keyOf(frontend, side),
112
- /shared-ui\/theme\.css links to .*elsewhere\/theme\.css, which the build cache does not key/u,
112
+ /shared-ui[\\/]theme\.css links to .*elsewhere[\\/]theme\.css, which the build cache does not key/u,
113
113
  "a key that hashes a link's text serves a build of the old file it reaches",
114
114
  );
115
115
  rmSync(join(shared, "theme.css"));
@@ -117,7 +117,7 @@ await test("a link the key cannot follow refuses the key; a link into a keyed pa
117
117
  symlinkSync("../inner/.dms-frontend/dist/chunk.js", join(shared, "chunk.js"));
118
118
  assert.throws(
119
119
  () => keyOf(frontend, side),
120
- /shared-ui\/chunk\.js links to .*\.dms-frontend\/dist\/chunk\.js, which the build cache does not key/u,
120
+ /shared-ui[\\/]chunk\.js links to .*\.dms-frontend[\\/]dist[\\/]chunk\.js, which the build cache does not key/u,
121
121
  "a key that counts a keyed package's run outputs as keyed serves a build of the output it reached",
122
122
  );
123
123
  });
@@ -132,7 +132,7 @@ await test("a link inside a package copied into node_modules that the key cannot
132
132
  symlinkSync(color, join(modules, "ui-kit", "node_modules", "color-lib"));
133
133
  assert.throws(
134
134
  () => keyOf(frontend, side),
135
- /ui-kit\/node_modules\/color-lib links to/u,
135
+ /ui-kit[\\/]node_modules[\\/]color-lib links to/u,
136
136
  "a key that hashes a copied package's links by their text serves a build of the old files they reach",
137
137
  );
138
138
  });
@@ -78,8 +78,9 @@ function escaped(text) {
78
78
  /**
79
79
  * Replaces the run's web URL, where a file holds it as a whole
80
80
  * double-quoted value, and the workspace folder, where a file holds it or a
81
- * path under it as one, with placeholders. `%` is escaped first, so no text
82
- * of the file reads as a placeholder.
81
+ * path under it as one, joined by `/` or by the system's separator, with
82
+ * placeholders. `%` is escaped first, so no text of the file reads as a
83
+ * placeholder.
83
84
  *
84
85
  * @param {string} webUrl The run's web URL
85
86
  * @param {string[]} folders The workspace folder, as given and resolved
@@ -92,10 +93,11 @@ function leavingOutRunValues(webUrl, folders) {
92
93
  ...folders.flatMap((folder) => {
93
94
  const quoted = JSON.stringify(folder);
94
95
  /** @type {Array<[string, string]>} */
95
- const forms = [
96
- [quoted, `"${ESCAPE}P"`],
97
- [`${quoted.slice(0, -1)}/`, `"${ESCAPE}P/`],
98
- ];
96
+ const forms = [[quoted, `"${ESCAPE}P"`]];
97
+ for (const separator of new Set(["/", sep])) {
98
+ const under = JSON.stringify(separator).slice(1, -1);
99
+ forms.push([`${quoted.slice(0, -1)}${under}`, `"${ESCAPE}P/`]);
100
+ }
99
101
  return forms;
100
102
  }),
101
103
  ];
@@ -394,13 +394,14 @@ await test("links of one name and one link text in two node_modules are keyed by
394
394
  });
395
395
 
396
396
  await test("an install record above TMPDIR that the key cannot read leaves the fixture's keys unchanged", (t) => {
397
- const outer = realpathSync(
397
+ const outer = realpathSync.native(
398
398
  mkdtempSync(join(tmpdir(), "dms-control-build-key-outer-")),
399
399
  );
400
400
  t.after(() => rmSync(outer, { recursive: true, force: true }));
401
401
  write(join(outer, "node_modules", ".modules.yaml"), '{"layoutVersion":5}\n');
402
402
  write(join(outer, "tmp", ".keep"), "");
403
- setEnv(t, { TMPDIR: join(outer, "tmp") });
403
+ const temp = join(outer, "tmp");
404
+ setEnv(t, { TMPDIR: temp, TEMP: temp, TMP: temp });
404
405
  const { frontend, prepare } = fixture(t);
405
406
  const side = prepare("run-a", 1001);
406
407
  assert.throws(