tina4-nodejs 3.13.163 → 3.13.165
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/CLAUDE.md +12 -8
- package/package.json +1 -1
- package/packages/cli/dist/bin.js +899 -693
- package/packages/cli/src/bin.ts +13 -5
- package/packages/cli/src/commands/lint.ts +3 -1
- package/packages/core/dist/index.js +789 -613
- package/packages/core/src/batchSpawn.ts +129 -0
- package/packages/core/src/devAdmin.ts +15 -11
- package/packages/core/src/fakeData.ts +4 -1
- package/packages/core/src/mcp.ts +4 -1
- package/packages/core/src/portTakeover.ts +62 -10
- package/packages/core/src/projectIndex.ts +3 -4
- package/packages/core/src/projectIndexStorage.ts +9 -1
- package/packages/core/src/response.ts +4 -1
- package/packages/core/src/routeDiscovery.ts +8 -2
- package/packages/core/src/server.ts +97 -20
- package/packages/core/src/session.ts +5 -0
- package/packages/core/src/sessionHandlers/databaseHandler.ts +16 -0
- package/packages/frond/dist/index.js +66 -19
- package/packages/frond/src/engine.ts +74 -23
- package/packages/orm/dist/index.js +823 -647
- package/packages/orm/src/model.ts +2 -1
- package/types/core/src/batchSpawn.d.ts +28 -0
- package/types/core/src/portTakeover.d.ts +18 -1
- package/types/core/src/projectIndexStorage.d.ts +5 -0
- package/types/core/src/session.d.ts +5 -0
- package/types/core/src/sessionHandlers/databaseHandler.d.ts +8 -0
- package/types/frond/src/engine.d.ts +31 -2
package/packages/cli/src/bin.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { generate, GENERATORS, RESOLUTION_ENVELOPE_VERSION, RESOLUTION_FLAGS } f
|
|
|
19
19
|
import { runSeeds } from "./commands/seed.js";
|
|
20
20
|
import { queueCommand, QUEUE_FLAGS, QUEUE_SUBCOMMAND_NAMES } from "./commands/queue.js";
|
|
21
21
|
import { buildImage } from "./commands/build.js";
|
|
22
|
-
import {
|
|
22
|
+
import { spawnSyncAllowingBatch } from "../../core/src/batchSpawn.js";
|
|
23
23
|
import { existsSync, readFileSync } from "node:fs";
|
|
24
24
|
import { dirname, join } from "node:path";
|
|
25
25
|
import { findOnPath } from "./util.js";
|
|
@@ -68,12 +68,15 @@ function readCliVersion(): string {
|
|
|
68
68
|
* message is printed; takeover is also skipped in a container, outside dev mode,
|
|
69
69
|
* and when opted out (`TINA4_NO_TAKEOVER` / `tina4 serve --no-kill`).
|
|
70
70
|
*
|
|
71
|
+
* `host` is the address serve will bind; a port that binds there is reported
|
|
72
|
+
* as free, not "in use".
|
|
73
|
+
*
|
|
71
74
|
* Returns true only when a Tina4 holder was actually signalled.
|
|
72
75
|
*/
|
|
73
|
-
async function killProcessOnPort(port: number): Promise<boolean> {
|
|
76
|
+
async function killProcessOnPort(port: number, host?: string): Promise<boolean> {
|
|
74
77
|
const { takeOverPort, isDev, noTakeoverOptedOut, TAKEOVER_KILLED, TAKEOVER_REFUSALS } =
|
|
75
78
|
await import("../../core/src/portTakeover.js");
|
|
76
|
-
const result = takeOverPort(port, isDev(), noTakeoverOptedOut());
|
|
79
|
+
const result = takeOverPort(port, isDev(), noTakeoverOptedOut(), undefined, undefined, host);
|
|
77
80
|
if (result.status === TAKEOVER_KILLED) {
|
|
78
81
|
console.log(` ${result.message}`);
|
|
79
82
|
return true;
|
|
@@ -359,7 +362,9 @@ export const COMMANDS: Record<string, CommandSpec> = {
|
|
|
359
362
|
// path here AND the runtime bind-failure fallback both honour it
|
|
360
363
|
// (TAKEOVER-DEC-03).
|
|
361
364
|
if (a.includes("--no-kill")) process.env.TINA4_NO_TAKEOVER = "true";
|
|
362
|
-
|
|
365
|
+
// Probe the host the server will bind, resolved exactly as it resolves it.
|
|
366
|
+
const { resolvePortAndHost } = await import("../../core/src/server.js");
|
|
367
|
+
await killProcessOnPort(port, resolvePortAndHost({ port }).host);
|
|
363
368
|
await serveProject({ port, noBrowser, noReload });
|
|
364
369
|
},
|
|
365
370
|
flags: SERVE_FLAGS,
|
|
@@ -552,7 +557,10 @@ export function delegateToClient(command: string, args: string[]): number {
|
|
|
552
557
|
|
|
553
558
|
// stdio is inherited, so the client's interactive prompts (setup) and colour
|
|
554
559
|
// output work exactly as if it had been invoked directly.
|
|
555
|
-
|
|
560
|
+
// A tina4.cmd / tina4.bat client is accepted above, so it must be startable:
|
|
561
|
+
// Node will not spawn a batch file without a shell, and a plain shell would
|
|
562
|
+
// not escape the user's arguments.
|
|
563
|
+
const result = spawnSyncAllowingBatch(client, [command, ...args], {
|
|
556
564
|
stdio: "inherit",
|
|
557
565
|
env: { ...process.env, [DELEGATION_GUARD_ENV]: command },
|
|
558
566
|
});
|
|
@@ -46,6 +46,7 @@ import { createRequire } from "node:module";
|
|
|
46
46
|
import { dirname, join, relative } from "node:path";
|
|
47
47
|
import { findOnPath } from "../util.js";
|
|
48
48
|
import { spawnSync } from "node:child_process";
|
|
49
|
+
import { spawnSyncAllowingBatch } from "../../../core/src/batchSpawn.js";
|
|
49
50
|
|
|
50
51
|
// Source extensions we count as lintable app code. `.d.ts` declaration files are
|
|
51
52
|
// deliberately excluded — they carry no runnable code for `node --check` and are
|
|
@@ -237,7 +238,8 @@ function bootstrapEslint(cwd: string, noInstall: boolean): EslintSetup {
|
|
|
237
238
|
}
|
|
238
239
|
if (!bin) {
|
|
239
240
|
console.log(" · installing eslint (npm i -D eslint @eslint/js typescript-eslint)...");
|
|
240
|
-
|
|
241
|
+
// On Windows npm is npm.cmd, which Node will not spawn without a shell.
|
|
242
|
+
const rc = spawnSyncAllowingBatch(npm, ["install", "-D", "eslint", "@eslint/js", "typescript-eslint"], { cwd, stdio: "inherit" }).status;
|
|
241
243
|
if (rc === 0) bin = resolveEslintBin(cwd);
|
|
242
244
|
else console.log(" · could not install eslint — using the zero-dependency baseline.");
|
|
243
245
|
}
|