@stamhoofd/node-dev-tools 0.0.0-stage → 2.160.0-alpha.0

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/LICENSE.md ADDED
@@ -0,0 +1,32 @@
1
+ Free Use License for Non-Profit Organizations
2
+
3
+ Copyright 2020 Codawood BV
4
+
5
+ Permission is hereby granted, free of charge, to any non-profit organization with fewer than 2,000 members (each, a “Licensee”), to use this software and associated documentation files (the “Software”), subject to the following conditions:
6
+
7
+ 1. Eligibility:
8
+ This license applies only if neither the Licensee nor, if applicable, its parent or umbrella organization, is already subject to an existing license for this project. For the purposes of this license, a “parent or umbrella organization” means any organization with which the Licensee is affiliated, coordinated, or represented as part of a larger collective, including but not limited to national associations or federations.
9
+
10
+ 2. Modifications:
11
+ Modifications to the Software are permitted only if they are published publicly under the MIT License, covering only the modifications; the original Software remains under this license and may not be sublicensed without a separate agreement. Any modification made by a Licensee (other than modifications by the original author, its representatives, or the copyright owner) shall be deemed to be distributed under the MIT License. Submission of modifications through publicly accessible channels, including but not limited to pull requests on code repositories such as GitHub, shall be considered an explicit acknowledgment and grant by the Licensee that such modifications are made available under the MIT License. Licensees may not sublicense, transfer, or assign the rights granted under this license except as expressly permitted herein.
12
+
13
+ 3. Precedence of Existing Licenses:
14
+ If the Licensee, or its parent or umbrella organization, is already subject to an existing license for this project, that license shall take precedence, and no additional free license is granted. Nothing in this license shall be construed to override any pre-existing exclusive license agreement.
15
+
16
+ 4. Data Protection / GDPR Responsibility:
17
+ Licensees are solely responsible for ensuring that any processing of personal data using this software complies with applicable data protection laws, including the EU General Data Protection Regulation (GDPR).
18
+
19
+ 5. Termination and Revocation:
20
+ The copyright holders may revoke this license at any time, at their sole discretion.
21
+
22
+ 6. Governing Law:
23
+ This license shall be governed by and construed in accordance with the laws of Belgium, without regard to conflict of law principles.
24
+
25
+ 7. Third-Party Licenses:
26
+ Certain files or components included in the Software may be governed by separate licenses, including open-source licenses, or contributed by third parties under different terms. Such files are not automatically covered by this license. Licensees are responsible for reviewing and complying with any additional license terms that apply to these files.
27
+
28
+ For the purposes of this license, a “non-profit organization” means an entity recognized as non-profit under applicable law in its jurisdiction, which does not distribute profits to its members or owners.
29
+
30
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31
+
32
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
package/README.md CHANGED
@@ -1,3 +1,36 @@
1
- # Temporary Holding Version
1
+ # Development integration
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `@stamhoofd/node-dev-tools` owns the typed Stam development protocol and producer adapters.
4
+ It uses Node built-ins, TypeScript and concurrently; importing an emitter does not load the
5
+ CLI, a telemetry SDK, Vite, or Nuxt. Framework dependencies provide adapter types.
6
+
7
+ The CLI's dependency graph builds this package before starting development
8
+ processes. Its output is independent of the CLI's `dist`, which is cleared during
9
+ CLI rebuilds. `stam dev docs` prepares the docs observability dependency graph too.
10
+ Restart the development session after changing tooling code.
11
+
12
+ Application selection, asset preparation, and watch-command construction belong to
13
+ `shared/cli/src/runtime/dev-commands.ts` and `shared/cli/src/workflows/start-dev.ts`.
14
+ They resolve repository paths from the CLI context; this package owns the executable
15
+ adapters and transport, not application orchestration. Entry-point TSDoc describes
16
+ environment requirements, working directories, and lifecycle cleanup.
17
+
18
+ ## Entry points
19
+
20
+ - `events`: validated versioned messages and bounded, best-effort socket emission.
21
+ - `application`: supervisor-injected bridge from application diagnostics to development events.
22
+ - `vite` and `nuxt`: framework hooks translated into build/readiness transitions.
23
+ - `supervise`: executable wrapper reporting process incarnation and exit.
24
+ - `concurrently`: named process runner preserving application output and errors while shortening exit notices and suppressing expected shutdown notices. Application selection and command construction remain in the CLI.
25
+ - `watch-typescript`: compiler watch callbacks translated into build cycles.
26
+ - `shared-build`: one shared build and its session-ready marker.
27
+ - `turbo`: structured Turbo log forwarding and failed shared-build log replay.
28
+
29
+ Sequence numbers are emitter-local. Supervisor and child share a process identity
30
+ and generation; producer monotonic timestamps order their transitions. Socket
31
+ failure disables delivery without preventing application execution. Close emitters
32
+ to drain final events with a bounded deadline.
33
+
34
+ Integration coverage lives with the CLI consumers. Run `pnpm stam test cli`,
35
+ `pnpm stam check lint --filter @stamhoofd/node-dev-tools`, and
36
+ `pnpm stam check typecheck --filter @stamhoofd/node-dev-tools` from the repository root.
@@ -0,0 +1,32 @@
1
+ import { channel } from 'node:diagnostics_channel';
2
+ import { createDevEmitter } from './events.js';
3
+ /**
4
+ * Node preload injected by supervise.ts through NODE_OPTIONS.
5
+ * @remarks With STAM_DEV_APP and STAM_DEV_SOCKET, subscribes to
6
+ * `stamhoofd.application.lifecycle` for matching service names. Ready is forwarded;
7
+ * failed emits a failed stopped event. Stopped/failed drain the emitter; the
8
+ * supervisor reports the actual process exit. Shares the supervisor's identity
9
+ * via STAM_DEV_* and never throws from the subscriber. No cwd assumptions.
10
+ */
11
+ const app = process.env.STAM_DEV_APP;
12
+ if (app && process.env.STAM_DEV_SOCKET) {
13
+ const emitter = createDevEmitter(app);
14
+ channel('stamhoofd.application.lifecycle').subscribe((message) => {
15
+ if (!message || typeof message !== 'object')
16
+ return;
17
+ const event = message;
18
+ if (event.service !== app)
19
+ return;
20
+ // Subscribers must never throw: diagnostics_channel forwards failures as uncaught errors.
21
+ try {
22
+ if (event.event === 'ready')
23
+ emitter.emit('ready');
24
+ if (event.event === 'failed')
25
+ emitter.emit('stopped', { failed: true });
26
+ if (event.event === 'stopped' || event.event === 'failed')
27
+ void emitter.close().catch(() => { });
28
+ }
29
+ catch { /* Status reporting must not affect application execution. */ }
30
+ });
31
+ }
32
+ //# sourceMappingURL=application.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application.js","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;;;;GAOG;AACH,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,YAAkC,CAAC;AAC3D,IAAI,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,CAAC,iCAAiC,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7D,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ;YAAE,OAAO;QACpD,MAAM,KAAK,GAAG,OAAiD,CAAC;QAChE,IAAI,KAAK,CAAC,OAAO,KAAK,GAAG;YAAE,OAAO;QAClC,0FAA0F;QAC1F,IAAI,CAAC;YACD,IAAI,KAAK,CAAC,KAAK,KAAK,OAAO;gBAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACnD,IAAI,KAAK,CAAC,KAAK,KAAK,QAAQ;gBAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;YACxE,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,QAAQ;gBAAE,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACpG,CAAC;QAAC,MAAM,CAAC,CAAC,6DAA6D,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,43 @@
1
+ import concurrently, { Logger } from 'concurrently';
2
+ /**
3
+ * Runs named development commands independently of the CLI's rebuildable dist.
4
+ * Usage: node concurrently.js <comma-separated names> <command> [...commands].
5
+ * Inherits cwd/environment. Concurrently owns signal forwarding and failure handling;
6
+ * only its orchestration notices are shortened. Child output is never filtered.
7
+ * STAM_DEV_VERBOSE=1 retains the original command and signal diagnostics.
8
+ */
9
+ const [names, ...commands] = process.argv.slice(2);
10
+ const verbose = process.env.STAM_DEV_VERBOSE === '1';
11
+ let stopping = false;
12
+ const onSignal = () => {
13
+ stopping = true;
14
+ };
15
+ process.on('SIGINT', onSignal);
16
+ process.on('SIGTERM', onSignal);
17
+ class DevLogger extends Logger {
18
+ logCommandEvent(text, command) {
19
+ const prefix = `${command.command} exited with code `;
20
+ if (!verbose && text.startsWith(prefix)) {
21
+ const code = text.slice(prefix.length);
22
+ if (stopping && ['0', 'SIGINT', 'SIGTERM'].includes(code))
23
+ return;
24
+ text = `exited with code ${code}`;
25
+ }
26
+ super.logCommandEvent(text, command);
27
+ }
28
+ logGlobalEvent(text) {
29
+ if (!verbose && stopping && text === 'Sending SIGTERM to other processes..')
30
+ return;
31
+ super.logGlobalEvent(text);
32
+ }
33
+ }
34
+ const { result } = concurrently(commands.map((command, index) => ({ command, name: names.split(',')[index] })), {
35
+ logger: new DevLogger({ prefixFormat: '[{name}]' }),
36
+ killOthersOn: ['failure'],
37
+ });
38
+ await result.catch(() => {
39
+ process.exitCode = 1;
40
+ });
41
+ process.off('SIGINT', onSignal);
42
+ process.off('SIGTERM', onSignal);
43
+ //# sourceMappingURL=concurrently.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concurrently.js","sourceRoot":"","sources":["../src/concurrently.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGpD;;;;;;GAMG;A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AE,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE;IAC5G,MAAM,EAAE,IAAI,SAAS,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;IACnD,YAAY,EAAE,CAAC,SAAS,CAAC;CAC5B,CAAC,CAAC;AACH,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;IACpB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAChC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC"}
package/dist/events.js ADDED
@@ -0,0 +1,101 @@
1
+ import net from 'node:net';
2
+ import { randomUUID } from 'node:crypto';
3
+ /** Maximum UTF-8 frame size, including the trailing newline. */
4
+ export const maxEventBytes = 16 * 1024;
5
+ const apps = ['shared', 'dashboard', 'api', 'docs', 'webshop', 'renderer', 'stats'];
6
+ const events = ['build.started', 'build.succeeded', 'build.failed', 'starting', 'ready', 'stopped'];
7
+ /**
8
+ * Validates decoded wire fields before handing events to status/telemetry consumers.
9
+ * @param value - Parsed JSON; frame-size and session checks belong to the receiver.
10
+ * @returns Whether the value satisfies version 1 of the development protocol.
11
+ */
12
+ export function isDevEvent(value) {
13
+ if (value === null || typeof value !== 'object')
14
+ return false;
15
+ const record = value;
16
+ return validateDevEvent(record);
17
+ }
18
+ function validateDevEvent(value) {
19
+ return value !== null && typeof value === 'object'
20
+ && value.version === 1 && typeof value.app === 'string' && apps.includes(value.app)
21
+ && typeof value.event === 'string' && events.includes(value.event)
22
+ && typeof value.session === 'string' && typeof value.processId === 'string'
23
+ && typeof value.generation === 'string' && /^\d{1,30}$/.test(value.generation)
24
+ && typeof value.time === 'string' && /^\d{1,30}$/.test(value.time)
25
+ && typeof value.sequence === 'number' && Number.isSafeInteger(value.sequence) && value.sequence > 0
26
+ && (value.event.startsWith('build.') ? typeof value.cycleId === 'string' : value.cycleId === undefined)
27
+ && (value.errors === undefined || (typeof value.errors === 'number' && Number.isSafeInteger(value.errors) && value.errors >= 0))
28
+ && (value.failed === undefined || typeof value.failed === 'boolean')
29
+ && (value.traceparent === undefined || typeof value.traceparent === 'string')
30
+ && (value.startupOwner === undefined || value.startupOwner === 'application');
31
+ }
32
+ /**
33
+ * Creates a development-only, best-effort NDJSON emitter with a lazy Unix socket.
34
+ * @param app - Owner displayed by the CLI's development status.
35
+ * @param env - Requires STAM_DEV_SOCKET and STAM_DEV_SESSION to deliver events.
36
+ * STAM_DEV_PROCESS_ID and STAM_DEV_GENERATION share a supervisor's identity;
37
+ * otherwise fresh values are generated. STAM_DEV_TRACEPARENT supplies trace context.
38
+ * @returns An emitter whose close method must be awaited during graceful shutdown.
39
+ * @remarks Missing configuration makes emission a no-op. Socket failure or a queued
40
+ * backlog above four frames permanently disables this emitter; oversized frames
41
+ * are dropped. There is no retry or acknowledgement. The socket is unreferenced
42
+ * so telemetry cannot keep an application alive. No working-directory requirement.
43
+ */
44
+ export function createDevEmitter(app, env = process.env) {
45
+ const identity = {
46
+ version: 1, app, session: env.STAM_DEV_SESSION,
47
+ processId: env.STAM_DEV_PROCESS_ID ?? randomUUID(),
48
+ generation: env.STAM_DEV_GENERATION ?? process.hrtime.bigint().toString(),
49
+ traceparent: env.STAM_DEV_TRACEPARENT,
50
+ };
51
+ let sequence = 0;
52
+ let socket;
53
+ let closed = false;
54
+ return {
55
+ /**
56
+ * Queues an event without waiting for delivery.
57
+ * @param event - Lifecycle transition to report.
58
+ * @param fields - Build events must supply cycleId; other events must omit it.
59
+ */
60
+ emit(event, fields = {}) {
61
+ if (closed || !env.STAM_DEV_SOCKET || !env.STAM_DEV_SESSION)
62
+ return;
63
+ const line = JSON.stringify({ ...fields, ...identity, event, time: process.hrtime.bigint().toString(), sequence: ++sequence }) + '\n';
64
+ if (Buffer.byteLength(line) > maxEventBytes)
65
+ return;
66
+ if (!socket) {
67
+ socket = net.createConnection(env.STAM_DEV_SOCKET);
68
+ socket.unref();
69
+ socket.on('error', () => {
70
+ closed = true;
71
+ socket?.destroy();
72
+ });
73
+ socket.on('close', () => {
74
+ closed = true;
75
+ });
76
+ }
77
+ if (socket.writableLength + Buffer.byteLength(line) > maxEventBytes * 4) {
78
+ closed = true;
79
+ socket.destroy();
80
+ return;
81
+ }
82
+ socket.write(line);
83
+ },
84
+ /** Stops further emission and drains the connection, destroying it after 250 ms. */
85
+ async close() {
86
+ closed = true;
87
+ if (!socket || socket.destroyed)
88
+ return;
89
+ const connection = socket;
90
+ await new Promise((resolve) => {
91
+ const timer = setTimeout(() => connection.destroy(), 250);
92
+ connection.once('close', () => {
93
+ clearTimeout(timer);
94
+ resolve();
95
+ });
96
+ connection.end();
97
+ });
98
+ },
99
+ };
100
+ }
101
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA4BzC,gEAAgE;AAChE,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,GAAG,IAAI,CAAC;AACvC,MAAM,IAAI,GAAG,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AACpF,MAAM,MAAM,GAAG,CAAC,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AAEpG;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACrC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,MAAM,GAA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@@ -0,0 +1,73 @@
1
+ import { createDevEmitter } from './events.js';
2
+ /**
3
+ * Registers Nuxt's explicit development build and listener lifecycle callbacks.
4
+ * @param options - Optional application lifecycle owner. When supplied, ready and
5
+ * close are delegated to it; build events still use the development emitter.
6
+ * @param nuxt - Instance owning the hooks and cleanup.
7
+ * @remarks Ready requires build:done, Nitro compilation and listen. This describes server
8
+ * startup, not completion of every on-demand browser transform. No production events.
9
+ * Uses the supervisor's STAM_DEV_* environment through createDevEmitter. Nuxt's
10
+ * close hook drains the emitter; the supervisor reports process exit. No cwd assumptions.
11
+ */
12
+ export const devLifecycleModule = (options, nuxt) => {
13
+ if (!nuxt.options.dev)
14
+ return;
15
+ const emitter = createDevEmitter('docs');
16
+ let listening = false;
17
+ let built = false;
18
+ let serverBuilt = false;
19
+ let cycleId;
20
+ const ready = async () => {
21
+ if (listening && built && serverBuilt) {
22
+ if (options.lifecycle)
23
+ await options.lifecycle.ready();
24
+ else
25
+ emitter.emit('ready');
26
+ }
27
+ };
28
+ emitter.emit('starting');
29
+ nuxt.hook('build:before', () => {
30
+ built = false;
31
+ cycleId = process.hrtime.bigint().toString();
32
+ emitter.emit('build.started', { cycleId });
33
+ });
34
+ nuxt.hook('build:done', async () => {
35
+ built = true;
36
+ if (cycleId)
37
+ emitter.emit('build.succeeded', { cycleId });
38
+ await ready();
39
+ });
40
+ nuxt.hook('build:error', () => {
41
+ built = false;
42
+ if (cycleId)
43
+ emitter.emit('build.failed', { cycleId });
44
+ });
45
+ nuxt.hook('listen', async () => {
46
+ listening = true;
47
+ await ready();
48
+ });
49
+ nuxt.hook('nitro:init', (nitro) => {
50
+ let serverCycle;
51
+ nitro.hooks.hook('dev:start', () => {
52
+ serverBuilt = false;
53
+ serverCycle = process.hrtime.bigint().toString();
54
+ emitter.emit('build.started', { cycleId: serverCycle });
55
+ });
56
+ nitro.hooks.hook('dev:reload', async () => {
57
+ serverBuilt = true;
58
+ if (serverCycle)
59
+ emitter.emit('build.succeeded', { cycleId: serverCycle });
60
+ await ready();
61
+ });
62
+ nitro.hooks.hook('dev:error', () => {
63
+ serverBuilt = false;
64
+ if (serverCycle)
65
+ emitter.emit('build.failed', { cycleId: serverCycle });
66
+ });
67
+ });
68
+ nuxt.hook('close', async () => {
69
+ await options.lifecycle?.close();
70
+ await emitter.close();
71
+ });
72
+ };
73
+ //# sourceMappingURL=nuxt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nuxt.js","sourceRoot":"","sources":["../src/nuxt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAmG,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;IAChJ,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG;QAAE,OAAO;IAC9B,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzC,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,OAA2B,CAAC;IAChC,MAAM,KAAK,GAAG,KAAK,IAAI,EAAE;QACrB,IAAI,SAAS,IAAI,KAAK,IAAI,WAAW,EAAE,CAAC;YACpC,IAAI,OAAO,CAAC,SAAS;gBAAE,MAAM,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;;gBAClD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACzB,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;QAC3B,KAAK,GAAG,KAAK,CAAC;QACd,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;QAC7C,OAAO,CAAC,IAAI,CAAC,eAAe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3E,MAAM,KAAK,EAAE,CAAC;QAClB,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE;YAC/B,WAAW,GAAG,KAAK,CAAC;YACpB,IAAI,WAAW;gBAAE,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;QAC5E,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;QAC1B,MAAM,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,CAAC;QACjC,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { runTurbo } from './turbo.js';
2
+ import fs from 'node:fs/promises';
3
+ import { createDevEmitter } from './events.js';
4
+ /**
5
+ * Executable entry point: `node shared-build.js <marker> [--verbose]` from the repo root.
6
+ * @remarks The marker must be `.development/cli/generated/shared-build-<digits>.ready`.
7
+ * Runs the root build:shared graph once and writes the marker only on uncancelled
8
+ * success. The CLI owns marker removal between sessions. Reports one build cycle
9
+ * through STAM_DEV_*; runTurbo owns output buffering and signal forwarding.
10
+ * Compiler failures deliberately exit zero so the outer nodemon watcher can recover.
11
+ * Importing this module runs the build; it is not a library entry point.
12
+ */
13
+ const emitter = createDevEmitter('shared');
14
+ const cycleId = process.hrtime.bigint().toString();
15
+ const marker = process.argv[2];
16
+ if (!/^\.development\/cli\/generated\/shared-build-\d+\.ready$/.test(marker ?? ''))
17
+ throw new Error('Expected the session shared-build ready marker');
18
+ emitter.emit('build.started', { cycleId });
19
+ const args = ['run', 'build:shared', ...(process.argv.includes('--verbose') ? [] : ['--output-logs=new-only'])];
20
+ let cancelled = false;
21
+ for (const signal of ['SIGTERM', 'SIGINT']) {
22
+ process.on(signal, () => {
23
+ cancelled = true;
24
+ });
25
+ }
26
+ const code = await runTurbo(args, { bufferOutput: true });
27
+ if (!cancelled) {
28
+ emitter.emit(code === 0 ? 'build.succeeded' : 'build.failed', { cycleId });
29
+ if (code === 0) {
30
+ await fs.mkdir('.development/cli/generated', { recursive: true });
31
+ // eslint-disable-next-line node-security/no-arbitrary-file-access -- CLI-owned marker validated against the fixed directory and filename above.
32
+ await fs.writeFile(marker, '');
33
+ }
34
+ }
35
+ await emitter.close();
36
+ // Nodemon must keep watching after a compiler failure, as it did with `|| exit 0`.
37
+ process.exitCode = 0;
38
+ //# sourceMappingURL=shared-build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-build.js","sourceRoot":"","sources":["../src/shared-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,OAAO,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;AAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;AACnD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/B,IAAI,CAAC,0DAA0D,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;IAAE,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;AACtJ,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AAC3C,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC;AAChH,IAAI,SAAS,GAAG,KAAK,CAAC;AACtB,KAAK,MAAM,MAAM,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,CAAC;IACzC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACpB,SAAS,GAAG,IAAI,CAAC;IACrB,CAAC,CAAC,CAAC;AACP,CAAC;AACD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1D,IAAI,CAAC,SAAS,EAAE,CAAC;IACb,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,cAAc,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC3E,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;QACb,MAAM,EAAE,CAAC,KAAK,CAAC,4BAA4B,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAClE,gJAAgJ;QAChJ,MAAM,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACnC,CAAC;AACL,CAAC;AACD,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;AACtB,mFAAmF;AACnF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { randomUUID } from 'node:crypto';
3
+ import { createDevEmitter } from './events.js';
4
+ /**
5
+ * Executable entry point: `node supervise.js <app> <command> [...args]`.
6
+ * @remarks Launches the child in the inherited cwd with inherited stdio and environment.
7
+ * Each invocation assigns a fresh STAM_DEV_PROCESS_ID/STAM_DEV_GENERATION. When
8
+ * STAM_DEV_SOCKET is set, NODE_OPTIONS preloads application.js in Node children.
9
+ * STAM_DEV_<APP>_INSPECT_PORT enables the inspector for directly supervised Node;
10
+ * managed non-verbose sessions publish its address over HTTP only.
11
+ *
12
+ * Emits starting before spawn and stopped after exit; readiness belongs to the
13
+ * application/framework adapter. SIGINT/SIGTERM are forwarded, with SIGKILL after
14
+ * two seconds. Shutdown drains events and returns zero on cancellation, otherwise
15
+ * the child's exit code (or one for spawn failure/signal exit). Do not import this
16
+ * module as a library: evaluation launches the command.
17
+ */
18
+ const [app, command, ...args] = process.argv.slice(2);
19
+ if (!app || !command)
20
+ throw new Error('Expected app and command to supervise');
21
+ if (command === 'node' || command === process.execPath) {
22
+ const inspectorPort = process.env[`STAM_DEV_${app.toUpperCase()}_INSPECT_PORT`];
23
+ if (inspectorPort)
24
+ args.unshift(`--inspect=127.0.0.1:${inspectorPort}`);
25
+ if (process.env.STAM_DEV_SESSION && process.env.STAM_DEV_VERBOSE !== '1') {
26
+ args.unshift('--inspect-publish-uid=http');
27
+ }
28
+ }
29
+ const env = { ...process.env, STAM_DEV_PROCESS_ID: randomUUID(), STAM_DEV_GENERATION: process.hrtime.bigint().toString() };
30
+ if (process.env.STAM_DEV_SOCKET) {
31
+ Object.assign(env, {
32
+ STAM_DEV_APP: app,
33
+ NODE_OPTIONS: `${process.env.NODE_OPTIONS ?? ''} --import=${new URL('./application.js', import.meta.url).href}`,
34
+ });
35
+ }
36
+ const emitter = createDevEmitter(app, env);
37
+ emitter.emit('starting', ['api', 'renderer', 'stats', 'docs'].includes(app) ? { startupOwner: 'application' } : {});
38
+ const child = spawn(command, args, { env, stdio: 'inherit' });
39
+ let cancelled = false;
40
+ let deadline;
41
+ for (const signal of ['SIGTERM', 'SIGINT']) {
42
+ process.on(signal, () => {
43
+ cancelled = true;
44
+ child.kill(signal);
45
+ deadline ??= setTimeout(() => child.kill('SIGKILL'), 2000);
46
+ deadline.unref();
47
+ });
48
+ }
49
+ const code = await new Promise((resolve) => {
50
+ child.once('error', (error) => {
51
+ console.error(error);
52
+ resolve(1);
53
+ });
54
+ child.once('close', code => resolve(code ?? 1));
55
+ });
56
+ if (deadline)
57
+ clearTimeout(deadline);
58
+ emitter.emit('stopped', { failed: !cancelled && code !== 0 });
59
+ await emitter.close();
60
+ process.exitCode = cancelled ? 0 : code;
61
+ //# sourceMappingURL=supervise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supervise.js","sourceRoot":"","sources":["../src/supervise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACtD,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO;IAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;AAC/E,IAAI,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC;IACrD,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAChF,IAAI,aAAa;QAAE,IAAI,CAAC,OAAO,CAAC,uBAAuB,aAAa,EAAE,CAAC,CAAC;IACxE,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,KAAK,GAAG,EAAE,CAAC;QACvE,IAAI,CAAC,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAC/C,CAAC;AACL,CAAC;AACD,MAAM,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,mBAAmB,EAAE,UAAU,EAAE,EAAE,mBAAmB,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC;AAC3H,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC;IAC9B,MAAM,C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AO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,CAAC,CAAC,CAAC,CAAC;IACf,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC,CAAC,CAAC;AACH,IAAI,QAAQ;IAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;AACrC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,SAAS,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC;AAC9D,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;AACtB,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC"}
package/dist/turbo.js ADDED
@@ -0,0 +1,104 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { createInterface } from 'node:readline';
3
+ import { pathToFileURL } from 'node:url';
4
+ import fs from 'node:fs';
5
+ import os from 'node:os';
6
+ import path from 'node:path';
7
+ import { pipeline } from 'node:stream/promises';
8
+ const appNames = new Map([
9
+ ['@stamhoofd/backend#dev', 'api'], ['@stamhoofd/backend-renderer#dev', 'renderer'],
10
+ ['@stamhoofd/backend-statistics-syncer#dev', 'stats'], ['@stamhoofd/web-app#dev', 'dashboard'],
11
+ ['@stamhoofd/webshop#dev', 'webshop'],
12
+ ]);
13
+ /**
14
+ * Presents one Turbo NDJSON record without inspecting rendered message text.
15
+ * @param line - Complete stdout line, excluding its delimiter.
16
+ * @param write - Output destination.
17
+ * @remarks Only Turbo-owned info records are hidden. Task output, unknown records
18
+ * and malformed frames remain visible; stderr retains its original stream.
19
+ */
20
+ export function forwardTurboLine(line, write) {
21
+ let value;
22
+ try {
23
+ value = JSON.parse(line);
24
+ }
25
+ catch {
26
+ write('stdout', line + '\n');
27
+ return;
28
+ }
29
+ const record = value && typeof value === 'object' ? value : undefined;
30
+ if (!record || typeof record.source !== 'string' || typeof record.text !== 'string'
31
+ || typeof record.level !== 'string' || !['info', 'warn', 'error', 'stdout', 'stderr'].includes(record.level)) {
32
+ write('stdout', line + '\n');
33
+ return;
34
+ }
35
+ if (record.source === 'turbo' && record.level === 'info')
36
+ return;
37
+ const stream = ['stderr', 'warn', 'error'].includes(record.level) ? 'stderr' : 'stdout';
38
+ const app = appNames.get(record.source);
39
+ const prefix = app ? `[${app}]` : `${record.source.replace('#', ':')}:`;
40
+ write(stream, `${prefix} ${record.text}\n`);
41
+ }
42
+ /**
43
+ * Runs a pnpm command ending in Turbo, retaining Turbo's graph and exit status.
44
+ * @param args - pnpm arguments; Turbo flags are appended to these.
45
+ * @param options - Buffer finite shared builds in normal mode.
46
+ * @returns Exit code, or 1 for spawn failure/signal termination.
47
+ * @remarks Normal managed sessions consume Turbo's documented NDJSON interface.
48
+ * Verbose/unmanaged sessions inherit native output. Signals are forwarded and
49
+ * handlers removed on close; tooling output is independent of CLI rebuilds.
50
+ * Buffered output is spooled to a private temporary file, replayed to stderr on
51
+ * failure, and removed on completion. Success (including warnings) and cancellation
52
+ * discard it. Verbose/unmanaged output always streams, regardless of this option.
53
+ * Inherits cwd and environment: callers must select the workspace owning the command.
54
+ * STAM_DEV_SESSION enables managed output unless STAM_DEV_VERBOSE=1. No shell is used.
55
+ * Executable usage: `node turbo.js <turbo args>`; importing does not launch a process.
56
+ */
57
+ export async function runTurbo(args, { bufferOutput = false } = {}) {
58
+ const quiet = !!process.env.STAM_DEV_SESSION && process.env.STAM_DEV_VERBOSE !== '1';
59
+ const directory = quiet && bufferOutput ? fs.mkdtempSync(path.join(os.tmpdir(), 'stam-shared-log-')) : undefined;
60
+ const file = directory ? path.join(directory, 'output.log') : undefined;
61
+ const fd = file ? fs.openSync(file, 'wx', 0o600) : undefined;
62
+ const write = (stream, text) => fd === undefined ? process[stream].write(text) : fs.writeSync(fd, text);
63
+ const child = spawn('pnpm', [...args, ...(quiet ? ['--json'] : [])], { stdio: quiet ? ['inherit', 'pipe', fd === undefined ? 'inherit' : 'pipe'] : 'inherit' });
64
+ if (child.stdout) {
65
+ createInterface({ input: child.stdout, crlfDelay: Infinity }).on('line', line => forwardTurboLine(line, write));
66
+ }
67
+ child.stderr?.setEncoding('utf8').on('data', (text) => write('stderr', text));
68
+ let cancelled = false;
69
+ const interrupt = () => {
70
+ cancelled = true;
71
+ child.kill('SIGINT');
72
+ };
73
+ const terminate = () => {
74
+ cancelled = true;
75
+ child.kill('SIGTERM');
76
+ };
77
+ process.on('SIGINT', interrupt);
78
+ process.on('SIGTERM', terminate);
79
+ try {
80
+ const code = await new Promise((resolve) => {
81
+ child.once('error', (error) => {
82
+ console.error(error);
83
+ resolve(1);
84
+ });
85
+ child.once('close', code => resolve(code ?? 1));
86
+ });
87
+ if (file && code !== 0 && !cancelled) {
88
+ await pipeline(fs.createReadStream(file), process.stderr, { end: false });
89
+ }
90
+ return code;
91
+ }
92
+ finally {
93
+ process.off('SIGINT', interrupt);
94
+ process.off('SIGTERM', terminate);
95
+ if (fd !== undefined)
96
+ fs.closeSync(fd);
97
+ if (directory)
98
+ fs.rmSync(directory, { recursive: true, force: true });
99
+ }
100
+ }
101
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
102
+ process.exitCode = await runTurbo(['exec', 'turbo', ...process.argv.slice(2)]);
103
+ }
104
+ //# sourceMappingURL=turbo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turbo.js","sourceRoot":"","sources":["../src/turbo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,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CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7E,OAAO,CAAC,QAAQ,GAAG,MAAM,QAAQ,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnF,CAAC"}
package/dist/vite.js ADDED
@@ -0,0 +1,34 @@
1
+ import { createDevEmitter } from './events.js';
2
+ /**
3
+ * Reports Vite server availability without pretending lazy transforms are a full build.
4
+ * @param app - Owner selected by the calling config.
5
+ * @returns A development-only plugin; no work in production builds.
6
+ * @remarks The supervisor supplies the process identity. A config reload starts
7
+ * another startup phase within that identity; the supervisor reports actual exits.
8
+ * Uses createDevEmitter's STAM_DEV_* environment and has no cwd assumptions.
9
+ * Readiness means the HTTP server is listening; middleware mode without an HTTP
10
+ * server does not emit ready. Server close/closeBundle drain the emitter.
11
+ */
12
+ export function devLifecyclePlugin(app) {
13
+ let emitter;
14
+ return {
15
+ name: 'stam-dev-lifecycle',
16
+ apply: 'serve',
17
+ configureServer(server) {
18
+ emitter = createDevEmitter(app);
19
+ emitter.emit('starting');
20
+ const ready = () => emitter?.emit('ready');
21
+ if (server.httpServer?.listening)
22
+ ready();
23
+ else
24
+ server.httpServer?.once('listening', ready);
25
+ server.httpServer?.once('close', () => {
26
+ void emitter?.close();
27
+ });
28
+ },
29
+ async closeBundle() {
30
+ await emitter?.close();
31
+ },
32
+ };
33
+ }
34
+ //# sourceMappingURL=vite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC1C,IAAI,OAAwD,CAAC;IAC7D,OAAO;QACH,IAAI,EAAE,oBAAoB;QAC1B,KAAK,EAAE,OAAO;QACd,eAAe,CAAC,MAAyC;YACrD,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;YAChC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACzB,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAC3C,IAAI,MAAM,CAAC,UAAU,EAAE,SAAS;gBAAE,KAAK,EAAE,CAAC;;gBACrC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;YACjD,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;gBAClC,KAAK,OAAO,EAAE,KAAK,EAAE,CAAC;YAC1B,CAAC,CAAC,CAAC;QACP,CAAC;QACD,KAAK,CAAC,WAAW;YACb,MAAM,OAAO,EAAE,KAAK,EAAE,CAAC;QAC3B,CAAC;KACa,CAAC;AACvB,CAAC"}
@@ -0,0 +1,63 @@
1
+ import ts from 'typescript';
2
+ import { pathToFileURL } from 'node:url';
3
+ import { createDevEmitter } from './events.js';
4
+ /**
5
+ * Watches one runtime solution through TypeScript's supported builder API.
6
+ * @param app - Development owner for lifecycle events.
7
+ * @param config - Runtime tsconfig path, relative to the package cwd.
8
+ * @returns Watcher owner; close stops file watchers and drains events.
9
+ * @remarks Compiler diagnostics remain on stdout. Numeric status diagnostics are
10
+ * compiler API notifications, not parsed terminal text. The CLI prepares shared
11
+ * dependencies before starting this watcher. Compilation failures emit build.failed
12
+ * and keep watching. STAM_DEV_SESSION suppresses routine status text unless
13
+ * STAM_DEV_VERBOSE=1; diagnostics are always reported. Transport uses createDevEmitter.
14
+ *
15
+ * Executable usage: `node watch-typescript.js <app>` from the application directory.
16
+ * SIGINT/SIGTERM close the watcher and drain events; importing does not start it.
17
+ */
18
+ export function watchTypeScript(app, config = 'tsconfig.build.json') {
19
+ const emitter = createDevEmitter(app);
20
+ let cycleId;
21
+ let errors = 0;
22
+ // The host exposes TypeScript's default reporters through its public API.
23
+ const defaults = ts.createSolutionBuilderWithWatchHost(ts.sys);
24
+ const report = defaults.reportDiagnostic;
25
+ const status = defaults.onWatchStatusChange;
26
+ const host = ts.createSolutionBuilderWithWatchHost(ts.sys, undefined, (diagnostic) => {
27
+ if (diagnostic.category === ts.DiagnosticCategory.Error)
28
+ errors++;
29
+ report(diagnostic);
30
+ }, report, (diagnostic, newline, options) => {
31
+ // TypeScript's public diagnostic codes for initial/incremental watch starts.
32
+ if (diagnostic.code === 6031 || diagnostic.code === 6032) {
33
+ cycleId = process.hrtime.bigint().toString();
34
+ errors = 0;
35
+ emitter.emit('build.started', { cycleId });
36
+ }
37
+ if (!process.env.STAM_DEV_SESSION || process.env.STAM_DEV_VERBOSE === '1') {
38
+ status?.(diagnostic, newline, { ...options, preserveWatchOutput: true });
39
+ }
40
+ // Watch summary: singular/plural errors. Diagnostics were reported above.
41
+ if (cycleId && (diagnostic.code === 6193 || diagnostic.code === 6194)) {
42
+ emitter.emit(errors ? 'build.failed' : 'build.succeeded', { cycleId, errors });
43
+ cycleId = undefined;
44
+ }
45
+ });
46
+ const builder = ts.createSolutionBuilderWithWatch(host, [config], { watch: true, preserveWatchOutput: true });
47
+ builder.build();
48
+ return {
49
+ async close() {
50
+ // TypeScript 6 exposes close at runtime but omits it from SolutionBuilder.
51
+ builder.close();
52
+ await emitter.close();
53
+ },
54
+ };
55
+ }
56
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
57
+ const watcher = watchTypeScript(process.argv[2]);
58
+ for (const signal of ['SIGTERM', 'SIGINT'])
59
+ process.once(signal, () => {
60
+ void watcher.close();
61
+ });
62
+ }
63
+ //# sourceMappingURL=watch-typescript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch-typescript.js","sourceRoot":"","sources":["../src/watch-typescript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,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AC;AACP,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=application.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=concurrently.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concurrently.d.ts","sourceRoot":"","sources":["../src/concurrently.ts"],"names":[],"mappings":""}
@@ -0,0 +1,56 @@
1
+ /** Application owners understood by the development footer. */
2
+ export type DevApp = 'shared' | 'dashboard' | 'api' | 'docs' | 'webshop' | 'renderer' | 'stats';
3
+ export type DevEventName = 'build.started' | 'build.succeeded' | 'build.failed' | 'starting' | 'ready' | 'stopped';
4
+ /**
5
+ * Versioned NDJSON message shared by development producers and the CLI receiver.
6
+ * @remarks `generation` and `time` are decimal monotonic nanoseconds, not wall-clock
7
+ * timestamps. Sequence numbers are emitter-local; supervisor and child share a
8
+ * process identity but have separate sequences. Build events require a cycleId;
9
+ * other events must omit it. `startupOwner` delegates startup reporting to the application.
10
+ */
11
+ export type DevEvent = {
12
+ version: 1;
13
+ app: DevApp;
14
+ event: DevEventName;
15
+ session: string;
16
+ processId: string;
17
+ generation: string;
18
+ time: string;
19
+ sequence: number;
20
+ cycleId?: string;
21
+ errors?: number;
22
+ failed?: boolean;
23
+ traceparent?: string;
24
+ startupOwner?: 'application';
25
+ };
26
+ /** Maximum UTF-8 frame size, including the trailing newline. */
27
+ export declare const maxEventBytes: number;
28
+ /**
29
+ * Validates decoded wire fields before handing events to status/telemetry consumers.
30
+ * @param value - Parsed JSON; frame-size and session checks belong to the receiver.
31
+ * @returns Whether the value satisfies version 1 of the development protocol.
32
+ */
33
+ export declare function isDevEvent(value: unknown): value is DevEvent;
34
+ /**
35
+ * Creates a development-only, best-effort NDJSON emitter with a lazy Unix socket.
36
+ * @param app - Owner displayed by the CLI's development status.
37
+ * @param env - Requires STAM_DEV_SOCKET and STAM_DEV_SESSION to deliver events.
38
+ * STAM_DEV_PROCESS_ID and STAM_DEV_GENERATION share a supervisor's identity;
39
+ * otherwise fresh values are generated. STAM_DEV_TRACEPARENT supplies trace context.
40
+ * @returns An emitter whose close method must be awaited during graceful shutdown.
41
+ * @remarks Missing configuration makes emission a no-op. Socket failure or a queued
42
+ * backlog above four frames permanently disables this emitter; oversized frames
43
+ * are dropped. There is no retry or acknowledgement. The socket is unreferenced
44
+ * so telemetry cannot keep an application alive. No working-directory requirement.
45
+ */
46
+ export declare function createDevEmitter(app: DevApp, env?: NodeJS.ProcessEnv): {
47
+ /**
48
+ * Queues an event without waiting for delivery.
49
+ * @param event - Lifecycle transition to report.
50
+ * @param fields - Build events must supply cycleId; other events must omit it.
51
+ */
52
+ emit(event: DevEventName, fields?: Pick<DevEvent, "cycleId" | "errors" | "failed" | "startupOwner">): void;
53
+ /** Stops further emission and drains the connection, destroying it after 250 ms. */
54
+ close(): Promise<void>;
55
+ };
56
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAGA,+DAA+D;AAC/D,MAAM,MAAM,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,CAAC;AAChG,MAAM,MAAM,YAAY,GAAG,eAAe,GAAG,iBAAiB,GAAG,cAAc,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;AACnH;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG;IACnB,OAAO,EAAE,CAAC,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,aAAa,CAAC;CAChC,CAAC;AAEF,gEAAgE;AAChE,eAAO,MAAM,aAAa,QAAY,CAAC;AAIvC;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAI5D;AAiBD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB;IAW1E;;;;OAIG;gBACS,YAAY,WAAU,IAAI,CAAC,QAAQ,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,cAAc,CAAC;IAsBlG,oFAAoF;;EAe3F"}
@@ -0,0 +1,19 @@
1
+ import type { NuxtModule } from '@nuxt/schema';
2
+ /**
3
+ * Registers Nuxt's explicit development build and listener lifecycle callbacks.
4
+ * @param options - Optional application lifecycle owner. When supplied, ready and
5
+ * close are delegated to it; build events still use the development emitter.
6
+ * @param nuxt - Instance owning the hooks and cleanup.
7
+ * @remarks Ready requires build:done, Nitro compilation and listen. This describes server
8
+ * startup, not completion of every on-demand browser transform. No production events.
9
+ * Uses the supervisor's STAM_DEV_* environment through createDevEmitter. Nuxt's
10
+ * close hook drains the emitter; the supervisor reports process exit. No cwd assumptions.
11
+ */
12
+ export declare const devLifecycleModule: NuxtModule<{
13
+ lifecycle?: {
14
+ ready(): Promise<void>;
15
+ failed(): void;
16
+ close(): Promise<void>;
17
+ };
18
+ }>;
19
+ //# sourceMappingURL=nuxt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nuxt.d.ts","sourceRoot":"","sources":["../src/nuxt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAAU,CAAC;IAAE,SAAS,CAAC,EAAE;QAAE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;QAAC,MAAM,IAAI,IAAI,CAAC;QAAC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAA;CAAE,CAqD7H,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=shared-build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-build.d.ts","sourceRoot":"","sources":["../src/shared-build.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=supervise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supervise.d.ts","sourceRoot":"","sources":["../src/supervise.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Presents one Turbo NDJSON record without inspecting rendered message text.
3
+ * @param line - Complete stdout line, excluding its delimiter.
4
+ * @param write - Output destination.
5
+ * @remarks Only Turbo-owned info records are hidden. Task output, unknown records
6
+ * and malformed frames remain visible; stderr retains its original stream.
7
+ */
8
+ export declare function forwardTurboLine(line: string, write: (stream: 'stdout' | 'stderr', text: string) => void): void;
9
+ /**
10
+ * Runs a pnpm command ending in Turbo, retaining Turbo's graph and exit status.
11
+ * @param args - pnpm arguments; Turbo flags are appended to these.
12
+ * @param options - Buffer finite shared builds in normal mode.
13
+ * @returns Exit code, or 1 for spawn failure/signal termination.
14
+ * @remarks Normal managed sessions consume Turbo's documented NDJSON interface.
15
+ * Verbose/unmanaged sessions inherit native output. Signals are forwarded and
16
+ * handlers removed on close; tooling output is independent of CLI rebuilds.
17
+ * Buffered output is spooled to a private temporary file, replayed to stderr on
18
+ * failure, and removed on completion. Success (including warnings) and cancellation
19
+ * discard it. Verbose/unmanaged output always streams, regardless of this option.
20
+ * Inherits cwd and environment: callers must select the workspace owning the command.
21
+ * STAM_DEV_SESSION enables managed output unless STAM_DEV_VERBOSE=1. No shell is used.
22
+ * Executable usage: `node turbo.js <turbo args>`; importing does not launch a process.
23
+ */
24
+ export declare function runTurbo(args: string[], { bufferOutput }?: {
25
+ bufferOutput?: boolean;
26
+ }): Promise<number>;
27
+ //# sourceMappingURL=turbo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turbo.d.ts","sourceRoot":"","sources":["../src/turbo.ts"],"names":[],"mappings":"AAcA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,QAmBxG;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,YAAoB,EAAE,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAwCzH"}
@@ -0,0 +1,19 @@
1
+ import type { ViteDevServer } from 'vite';
2
+ import type { DevApp } from './events.js';
3
+ /**
4
+ * Reports Vite server availability without pretending lazy transforms are a full build.
5
+ * @param app - Owner selected by the calling config.
6
+ * @returns A development-only plugin; no work in production builds.
7
+ * @remarks The supervisor supplies the process identity. A config reload starts
8
+ * another startup phase within that identity; the supervisor reports actual exits.
9
+ * Uses createDevEmitter's STAM_DEV_* environment and has no cwd assumptions.
10
+ * Readiness means the HTTP server is listening; middleware mode without an HTTP
11
+ * server does not emit ready. Server close/closeBundle drain the emitter.
12
+ */
13
+ export declare function devLifecyclePlugin(app: DevApp): {
14
+ name: string;
15
+ apply: "serve";
16
+ configureServer(server: Pick<ViteDevServer, "httpServer">): void;
17
+ closeBundle(): Promise<void>;
18
+ };
19
+ //# sourceMappingURL=vite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,aAAa,EAAE,MAAM,MAAM,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM;;;4BAKd,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC;;EAchE"}
@@ -0,0 +1,19 @@
1
+ import type { DevApp } from './events.js';
2
+ /**
3
+ * Watches one runtime solution through TypeScript's supported builder API.
4
+ * @param app - Development owner for lifecycle events.
5
+ * @param config - Runtime tsconfig path, relative to the package cwd.
6
+ * @returns Watcher owner; close stops file watchers and drains events.
7
+ * @remarks Compiler diagnostics remain on stdout. Numeric status diagnostics are
8
+ * compiler API notifications, not parsed terminal text. The CLI prepares shared
9
+ * dependencies before starting this watcher. Compilation failures emit build.failed
10
+ * and keep watching. STAM_DEV_SESSION suppresses routine status text unless
11
+ * STAM_DEV_VERBOSE=1; diagnostics are always reported. Transport uses createDevEmitter.
12
+ *
13
+ * Executable usage: `node watch-typescript.js <app>` from the application directory.
14
+ * SIGINT/SIGTERM close the watcher and drain events; importing does not start it.
15
+ */
16
+ export declare function watchTypeScript(app: DevApp, config?: string): {
17
+ close(): Promise<void>;
18
+ };
19
+ //# sourceMappingURL=watch-typescript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch-typescript.d.ts","sourceRoot":"","sources":["../src/watch-typescript.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,SAAwB;;EAoC1E"}
package/package.json CHANGED
@@ -1,6 +1,48 @@
1
1
  {
2
2
  "name": "@stamhoofd/node-dev-tools",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "2.160.0-alpha.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/stamhoofd/stamhoofd.git",
7
+ "directory": "packages/node/dev-tools"
8
+ },
9
+ "type": "module",
10
+ "files": [
11
+ "dist",
12
+ "dist-types"
13
+ ],
14
+ "exports": {
15
+ "./*": {
16
+ "types": "./dist-types/*.d.ts",
17
+ "import": "./dist/*.js"
18
+ }
19
+ },
20
+ "dependencies": {
21
+ "concurrently": "10.0.7",
22
+ "typescript": "6.0.3"
23
+ },
24
+ "devDependencies": {
25
+ "@nuxt/schema": "4.6.4",
26
+ "vite": "8.3.8"
27
+ },
28
+ "peerDependencies": {
29
+ "@nuxt/schema": "^4.0.0",
30
+ "vite": "^8.0.0"
31
+ },
32
+ "peerDependenciesMeta": {
33
+ "@nuxt/schema": {
34
+ "optional": true
35
+ },
36
+ "vite": {
37
+ "optional": true
38
+ }
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "scripts": {
44
+ "build": "tsc --build tsconfig.build.json",
45
+ "build:types": "tsc --project tsconfig.types.json",
46
+ "lint": "eslint . --quiet"
47
+ }
6
48
  }