@antelopejs/dms 0.25.1 → 0.25.2

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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.25.2
4
+
5
+ [compare changes](https://github.com/AntelopeJS/dms/compare/v0.25.1...v0.25.2)
6
+
7
+ ### 🔥 Performance
8
+
9
+ - **dms:** Start the e2e kit's runs together ([#1306](https://github.com/AntelopeJS/dms/pull/1306))
10
+
11
+ ### 🩹 Fixes
12
+
13
+ - **dms:** Key a symlinked scope folder of the e2e build key entry by entry ([#1307](https://github.com/AntelopeJS/dms/pull/1307))
14
+
15
+ ### 🏡 Chore
16
+
17
+ - **deps:** Update @antelopejs/tooling-configs to 0.10.14 and sync ([#1305](https://github.com/AntelopeJS/dms/pull/1305))
18
+
19
+ ### ❤️ Contributors
20
+
21
+ - Antony Rizzitelli
22
+
3
23
  ## v0.25.1
4
24
 
5
25
  [compare changes](https://github.com/AntelopeJS/dms/compare/v0.25.0...v0.25.1)
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Asks the kernel for a free loopback port outside `exclude`.
2
+ * Asks the kernel for a free loopback port outside `exclude` that this
3
+ * process has not given before.
3
4
  *
4
5
  * @param {Iterable<number>} [exclude] Skipped ports
5
6
  * @returns {Promise<number>} The port
@@ -14,11 +15,11 @@ export function freePort(exclude?: Iterable<number>): Promise<number>;
14
15
  */
15
16
  export function isRestartablePort(port: number): port is RestartablePort;
16
17
  /**
17
- * A free loopback port outside the ephemeral range and `exclude` for a server
18
- * that must listen on the same port again after it restarts. No outgoing
19
- * connection takes such a port as its source port, so none can hold it in
20
- * TIME_WAIT and make that listen fail with `EADDRINUSE`, as a port from
21
- * {@link freePort} can be held.
18
+ * A free loopback port outside the ephemeral range and `exclude`, which this
19
+ * process has not given before, for a server that must listen on the same
20
+ * port again after it restarts. No outgoing connection takes such a port as
21
+ * its source port, so none can hold it in TIME_WAIT and make that listen
22
+ * fail with `EADDRINUSE`, as a port from {@link freePort} can be held.
22
23
  *
23
24
  * @param {Iterable<number>} [exclude] Skipped ports
24
25
  * @returns {Promise<RestartablePort>} The port
@@ -24,28 +24,28 @@ export function targetOf(options: Pick<StartOptions, "playground" | "renderer" |
24
24
  renderer: string | undefined;
25
25
  }>;
26
26
  /**
27
- * Starts the stack of a run: with `prepare`, the journeys config's install
28
- * and build commands first, then the stack on its playground and renderer.
27
+ * Starts the stack of a run on its playground and renderer, the journeys
28
+ * config's commands already run.
29
29
  *
30
30
  * @param {StartOptions} options How to start it
31
+ * @param {import("./timing.mjs").TimingEntry[]} prepared The timings of the commands, which the run records
31
32
  * @param {string} cwd Where the run starts from, which finds the journeys config
32
33
  * @returns {Promise<import("./run-state.mjs").RunState>} The ready run
33
34
  */
34
- export function startStack(options: StartOptions, cwd: string): Promise<import("./run-state.mjs").RunState>;
35
+ export function startStack(options: StartOptions, prepared: import("./timing.mjs").TimingEntry[], cwd: string): Promise<import("./run-state.mjs").RunState>;
35
36
  /**
36
37
  * Starts `count` runs of the checkout's playground, each with its own
37
38
  * playground copy, ports, MongoDB, mail sink, backends and dashboard, for
38
- * the workers of one suite to drive one each. The first runs the journeys
39
- * config's prepare commands as `options` asks; the others start once it is
40
- * ready, together, without them, so their dashboards come from the build
41
- * cache the first one filled. `stop` stops them all, and from the moment
42
- * the first is ready a SIGINT or SIGTERM to this process stops every run
43
- * started so far, then ends the process by that signal.
39
+ * the workers of one suite to drive one each. The journeys config's prepare
40
+ * commands run first, once, as `options` asks; then every run starts at the
41
+ * same time. `stop` stops them all, and from the moment the runs start a
42
+ * SIGINT or SIGTERM to this process stops every run ready so far, then
43
+ * ends the process by that signal.
44
44
  *
45
45
  * @param {RunOptions} options How to start them
46
46
  * @param {number} count How many, at least 1
47
- * @returns {Promise<{ runs: import("./run-state.mjs").RunState[], stop: () => Promise<void> }>} The ready runs, and what stops them
48
- * @throws When a run fails to start; every run it started is stopped first
47
+ * @returns {Promise<{ runs: import("./run-state.mjs").RunState[], stop: () => Promise<void> }>} The ready runs, one per worker, and what stops them
48
+ * @throws When a run fails to start; every run that started is stopped first
49
49
  */
50
50
  export function startRuns(options: RunOptions, count: number): Promise<{
51
51
  runs: import("./run-state.mjs").RunState[];
package/e2e/build-key.mjs CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  readFileSync,
7
7
  readlinkSync,
8
8
  realpathSync,
9
+ statSync,
9
10
  } from "node:fs";
10
11
  import { basename, dirname, isAbsolute, join, relative, sep } from "node:path";
11
12
  import { isRecord } from "./json.mjs";
@@ -168,12 +169,12 @@ function hashFolder(folder, names, walk = SOURCES) {
168
169
 
169
170
  /**
170
171
  * Keys an entry at the top of a `node_modules` above the workspace, or in a
171
- * scope folder there. A scope folder is keyed entry by entry. A link is keyed
172
- * by its target, and, when the target is not a package of pnpm's virtual
173
- * store (a `link:` or `workspace:` package), by the content hash of the
174
- * folder it resolves to, its installs left out, read once however many links
175
- * reach it. A package copied in is keyed by its files, its own
176
- * `node_modules` included.
172
+ * scope folder there. A scope folder, or a link to one, is keyed entry by
173
+ * entry. Any other link is keyed by its target, and, when the target is not
174
+ * a package of pnpm's virtual store (a `link:` or `workspace:` package), by
175
+ * the content hash of the folder it resolves to, its installs left out,
176
+ * read once however many links reach it. A package copied in is keyed by
177
+ * its files, its own `node_modules` included.
177
178
  *
178
179
  * @param {import("node:crypto").Hash} hash
179
180
  * @param {string} path The entry
@@ -181,7 +182,7 @@ function hashFolder(folder, names, walk = SOURCES) {
181
182
  */
182
183
  function hashInstalled(hash, path, outside) {
183
184
  const stat = lstatSync(path, { throwIfNoEntry: false });
184
- if (stat?.isDirectory() && basename(path).startsWith("@")) {
185
+ if (isScope(path)) {
185
186
  hash.update("scope\0");
186
187
  for (const name of readdirSync(path).sort()) {
187
188
  hash.update(`${name}\0`);
@@ -208,6 +209,19 @@ function hashInstalled(hash, path, outside) {
208
209
  hash.update(`linked ${digest}\0`);
209
210
  }
210
211
 
212
+ /**
213
+ * @param {string} path An entry of a `node_modules`
214
+ * @returns {boolean} Whether it is a scope folder, or a link to one
215
+ */
216
+ function isScope(path) {
217
+ if (!basename(path).startsWith("@")) return false;
218
+ try {
219
+ return statSync(path).isDirectory();
220
+ } catch {
221
+ return false;
222
+ }
223
+ }
224
+
211
225
  /**
212
226
  * @param {string} path A real path
213
227
  * @returns {boolean}
@@ -228,7 +242,7 @@ function packagesIn(modules) {
228
242
  .filter((name) => !name.startsWith("."))
229
243
  .flatMap((name) => {
230
244
  const path = join(modules, name);
231
- return name.startsWith("@") && lstatSync(path).isDirectory()
245
+ return isScope(path)
232
246
  ? readdirSync(path).map((scoped) => join(path, scoped))
233
247
  : [path];
234
248
  });
package/e2e/processes.mjs CHANGED
@@ -41,8 +41,22 @@ function isTcpAddress(address) {
41
41
  return typeof address === "object" && address !== null;
42
42
  }
43
43
 
44
+ /** Every port {@link freePort} or {@link restartablePort} gave in this process, which neither gives again: runs that start at the same time each pick a port before any of them listens on it. */
45
+ const handedOut = new Set();
46
+
47
+ /**
48
+ * @template {number} P
49
+ * @param {P} port A port to give
50
+ * @returns {P} The port, never to be given again in this process
51
+ */
52
+ function handOut(port) {
53
+ handedOut.add(port);
54
+ return port;
55
+ }
56
+
44
57
  /**
45
- * Asks the kernel for a free loopback port outside `exclude`.
58
+ * Asks the kernel for a free loopback port outside `exclude` that this
59
+ * process has not given before.
46
60
  *
47
61
  * @param {Iterable<number>} [exclude] Skipped ports
48
62
  * @returns {Promise<number>} The port
@@ -51,7 +65,7 @@ export async function freePort(exclude = []) {
51
65
  const skip = new Set(exclude);
52
66
  for (let n = 0; n < RESTARTABLE_PORT_ATTEMPTS; n += 1) {
53
67
  const port = await kernelPort();
54
- if (!skip.has(port)) return port;
68
+ if (!skip.has(port) && !handedOut.has(port)) return handOut(port);
55
69
  }
56
70
  throw new Error("no free port");
57
71
  }
@@ -115,11 +129,11 @@ export function isRestartablePort(port) {
115
129
  }
116
130
 
117
131
  /**
118
- * A free loopback port outside the ephemeral range and `exclude` for a server
119
- * that must listen on the same port again after it restarts. No outgoing
120
- * connection takes such a port as its source port, so none can hold it in
121
- * TIME_WAIT and make that listen fail with `EADDRINUSE`, as a port from
122
- * {@link freePort} can be held.
132
+ * A free loopback port outside the ephemeral range and `exclude`, which this
133
+ * process has not given before, for a server that must listen on the same
134
+ * port again after it restarts. No outgoing connection takes such a port as
135
+ * its source port, so none can hold it in TIME_WAIT and make that listen
136
+ * fail with `EADDRINUSE`, as a port from {@link freePort} can be held.
123
137
  *
124
138
  * @param {Iterable<number>} [exclude] Skipped ports
125
139
  * @returns {Promise<RestartablePort>} The port
@@ -141,9 +155,10 @@ export async function restartablePort(exclude = []) {
141
155
  if (
142
156
  isRestartablePort(port) &&
143
157
  !excluded.has(port) &&
144
- (await canListen(port))
158
+ (await canListen(port)) &&
159
+ !handedOut.has(port)
145
160
  )
146
- return port;
161
+ return handOut(port);
147
162
  }
148
163
  throw new Error("no loopback port outside the ephemeral range is free");
149
164
  }
package/e2e/start.mjs CHANGED
@@ -49,21 +49,30 @@ export async function targetOf(options, cwd) {
49
49
  }
50
50
 
51
51
  /**
52
- * Starts the stack of a run: with `prepare`, the journeys config's install
53
- * and build commands first, then the stack on its playground and renderer.
52
+ * Runs the journeys config's install and build commands when `options`
53
+ * asks for them.
54
+ *
55
+ * @param {StartOptions} options How the runs start
56
+ * @param {string} cwd Where the runs start from, which finds the journeys config
57
+ * @returns {Promise<import("./timing.mjs").TimingEntry[]>} The timings of the commands, none when it ran nothing
58
+ */
59
+ async function prepareRuns(options, cwd) {
60
+ if (!options.prepare) return [];
61
+ const config = await loadSuiteConfig(cwd, options.config);
62
+ return runPrepare(config, config.repo);
63
+ }
64
+
65
+ /**
66
+ * Starts the stack of a run on its playground and renderer, the journeys
67
+ * config's commands already run.
54
68
  *
55
69
  * @param {StartOptions} options How to start it
70
+ * @param {import("./timing.mjs").TimingEntry[]} prepared The timings of the commands, which the run records
56
71
  * @param {string} cwd Where the run starts from, which finds the journeys config
57
72
  * @returns {Promise<import("./run-state.mjs").RunState>} The ready run
58
73
  */
59
- export async function startStack(options, cwd) {
60
- const { prepare, config: journeysConfig, ...upOptions } = options;
61
- /** @type {import("./timing.mjs").TimingEntry[]} */
62
- let prepared = [];
63
- if (prepare) {
64
- const config = await loadSuiteConfig(cwd, journeysConfig);
65
- prepared = runPrepare(config, config.repo);
66
- }
74
+ export async function startStack(options, prepared, cwd) {
75
+ const { prepare: _prepare, config: _journeysConfig, ...upOptions } = options;
67
76
  const state = await up({
68
77
  ...upOptions,
69
78
  ...(await targetOf(options, cwd)),
@@ -110,22 +119,23 @@ async function stopRuns(dirs) {
110
119
  /**
111
120
  * Starts `count` runs of the checkout's playground, each with its own
112
121
  * playground copy, ports, MongoDB, mail sink, backends and dashboard, for
113
- * the workers of one suite to drive one each. The first runs the journeys
114
- * config's prepare commands as `options` asks; the others start once it is
115
- * ready, together, without them, so their dashboards come from the build
116
- * cache the first one filled. `stop` stops them all, and from the moment
117
- * the first is ready a SIGINT or SIGTERM to this process stops every run
118
- * started so far, then ends the process by that signal.
122
+ * the workers of one suite to drive one each. The journeys config's prepare
123
+ * commands run first, once, as `options` asks; then every run starts at the
124
+ * same time. `stop` stops them all, and from the moment the runs start a
125
+ * SIGINT or SIGTERM to this process stops every run ready so far, then
126
+ * ends the process by that signal.
119
127
  *
120
128
  * @param {RunOptions} options How to start them
121
129
  * @param {number} count How many, at least 1
122
- * @returns {Promise<{ runs: import("./run-state.mjs").RunState[], stop: () => Promise<void> }>} The ready runs, and what stops them
123
- * @throws When a run fails to start; every run it started is stopped first
130
+ * @returns {Promise<{ runs: import("./run-state.mjs").RunState[], stop: () => Promise<void> }>} The ready runs, one per worker, and what stops them
131
+ * @throws When a run fails to start; every run that started is stopped first
124
132
  */
125
133
  export async function startRuns(options, count) {
126
134
  const cwd = process.cwd();
127
- const first = await startStack(startOptions(options, cwd), cwd);
128
- const dirs = [first.dir];
135
+ const start = startOptions(options, cwd);
136
+ const prepared = await prepareRuns(start, cwd);
137
+ /** @type {string[]} */
138
+ const dirs = [];
129
139
  const onSignal = (/** @type {NodeJS.Signals} */ signal) => {
130
140
  release();
131
141
  const reraise = () => process.kill(process.pid, signal);
@@ -135,29 +145,23 @@ export async function startRuns(options, count) {
135
145
  for (const signal of STOP_SIGNALS) process.off(signal, onSignal);
136
146
  };
137
147
  for (const signal of STOP_SIGNALS) process.on(signal, onSignal);
138
- const others = await Promise.allSettled(
139
- Array.from({ length: count - 1 }, async () => {
140
- const run = await startStack(
141
- startOptions({ ...options, prepare: false }, cwd),
142
- cwd,
143
- );
148
+ const started = await Promise.allSettled(
149
+ Array.from({ length: count }, async (_, index) => {
150
+ const run = await startStack(start, index === 0 ? prepared : [], cwd);
144
151
  dirs.push(run.dir);
145
152
  return run;
146
153
  }),
147
154
  );
148
- const failed = others.find((other) => other.status === "rejected");
155
+ const failed = started.find((run) => run.status === "rejected");
149
156
  if (failed) {
150
157
  release();
151
158
  await stopRuns(dirs);
152
159
  throw failed.reason;
153
160
  }
154
161
  return {
155
- runs: [
156
- first,
157
- ...others.flatMap((other) =>
158
- other.status === "fulfilled" ? [other.value] : [],
159
- ),
160
- ],
162
+ runs: started.flatMap((run) =>
163
+ run.status === "fulfilled" ? [run.value] : [],
164
+ ),
161
165
  stop: () => {
162
166
  release();
163
167
  return stopRuns(dirs);
@@ -80,7 +80,7 @@
80
80
  "devDependencies": {
81
81
  "@antelopejs/core": "~1.24.5",
82
82
  "@antelopejs/dms-frontend": ">=0.11.11 <0.12.0",
83
- "@antelopejs/tooling-configs": ">=0.10.12 <0.11.0",
83
+ "@antelopejs/tooling-configs": ">=0.10.14 <0.11.0",
84
84
  "@inertiajs/vue3": "^3.7.0",
85
85
  "@nuxt/eslint-config": "^1.17.0",
86
86
  "@nuxt/ui": "4.10.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/dms",
3
- "version": "0.25.1",
3
+ "version": "0.25.2",
4
4
  "description": "AntelopeJS DMS. Plug in your PostgreSQL, MySQL, MariaDB, MongoDB or RethinkDB database and your coding agent builds a back office and analytics dashboard as typed TypeScript. Real-time updates on the data the DMS manages.",
5
5
  "keywords": [
6
6
  "antelopejs",
@@ -120,7 +120,7 @@
120
120
  "@antelopejs/mysql": ">=0.2.7 <0.3.0",
121
121
  "@antelopejs/postgres": ">=0.4.3 <0.5.0",
122
122
  "@antelopejs/rethinkdb": "~1.10.6",
123
- "@antelopejs/tooling-configs": ">=0.10.12 <0.11.0",
123
+ "@antelopejs/tooling-configs": ">=0.10.14 <0.11.0",
124
124
  "@playwright/test": "~1.65.0",
125
125
  "@types/archiver": "^6.0.4",
126
126
  "@types/chai": "^5.0.0",
@@ -211,7 +211,7 @@
211
211
  "optional": true
212
212
  }
213
213
  },
214
- "gitHead": "995c8f94cd4a82bbe533267ff8c0df690ffcfef0",
214
+ "gitHead": "120b32596b6e0a703e8b7297fbc4be04ace4a0da",
215
215
  "scripts": {
216
216
  "build": "pnpm --filter @antelopejs/interface-dms --filter @antelopejs/interface-dms-builder build && rimraf dist && antelopejs-tsc && tsc-alias && tsc -p e2e/tsconfig.types.json",
217
217
  "dev": "ajs project run --inspect -w -p playground",