@cosmicdrift/kumiko-dev-server 0.422.0 → 0.424.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.
|
@@ -55,24 +55,26 @@ import { parseJsonOrThrow, parseJsonSafe } from "@cosmicdrift/kumiko-framework/u
|
|
|
55
55
|
const hasBun = typeof Bun !== "undefined";
|
|
56
56
|
// Packages that the bundle still references at runtime (`from "<pkg>"` after
|
|
57
57
|
// tree-shaking). Native bindings (argon2), worker-thread loaders (bullmq,
|
|
58
|
-
// ioredis), and dynamic require (
|
|
59
|
-
//
|
|
60
|
-
//
|
|
58
|
+
// ioredis), and dynamic require (temporal-polyfill) — anything that breaks under Bun
|
|
59
|
+
// bundling. (drizzle-kit/drizzle-orm are excluded: the migration path now uses the
|
|
60
|
+
// framework's runMigrationsFromDir, not drizzle-kit.)
|
|
61
61
|
const RUNTIME_EXTERNALS = [
|
|
62
62
|
"@node-rs/argon2",
|
|
63
63
|
"sharp",
|
|
64
64
|
"bullmq",
|
|
65
65
|
"ioredis",
|
|
66
|
-
"postgres",
|
|
67
66
|
"temporal-polyfill",
|
|
68
67
|
"pino",
|
|
69
|
-
"pino-pretty",
|
|
70
68
|
];
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
|
|
69
|
+
// Must stay external (as BUILD_ONLY_EXTERNALS meilisearch crashed money-horse with
|
|
70
|
+
// "Cannot find package 'meilisearch'"), but apps that do not use them should not install
|
|
71
|
+
// them. postgres is no longer imported by the framework (Bun.SQL) and pino-pretty is only
|
|
72
|
+
// loaded for LOG_FORMAT=pretty; neither is in an app lock unless the app declares it, so
|
|
73
|
+
// listing them unconditionally forced a registry lookup on every build. pino-pretty is only
|
|
74
|
+
// named as a string transport target, which the import scan cannot see; scanning for the
|
|
75
|
+
// string would match every app because the logger is always bundled. So pino-pretty enters
|
|
76
|
+
// only through the app's own declaration.
|
|
77
|
+
const OPTIONAL_RUNTIME_EXTERNALS = ["meilisearch", "postgres", "pino-pretty"];
|
|
76
78
|
// Packages that appear only in the build stack (transitive framework imports),
|
|
77
79
|
// but are not referenced by app code. Without the external marker,
|
|
78
80
|
// bun build fails on dynamic imports. Tree-shaking removes them from the
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="bun-types" preserve="true" />
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
|
+
import { ZOD_JITLESS_BANNER } from "@cosmicdrift/kumiko-server-runtime";
|
|
3
4
|
import { hasBun, logError, logInfo } from "./dev-server-runtime.js";
|
|
4
5
|
// Duplicated in packages/testing/src/e2e/constants.ts: the Playwright config
|
|
5
6
|
// runs under Node and cannot import this module.
|
|
@@ -18,6 +19,7 @@ export async function buildClient(entry) {
|
|
|
18
19
|
minify: !unminified,
|
|
19
20
|
sourcemap: prodShaped ? "none" : "linked",
|
|
20
21
|
splitting: prodShaped,
|
|
22
|
+
banner: ZOD_JITLESS_BANNER,
|
|
21
23
|
...(prodShaped ? { define: { "process.env.NODE_ENV": JSON.stringify("production") } } : {}),
|
|
22
24
|
});
|
|
23
25
|
if (!built.success) {
|
package/dist/run-dev-app.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SeedAdminOptions } from "@cosmicdrift/kumiko-bundled-features/auth-email-password/seeding";
|
|
2
|
-
import type { PostAuthLandingResolver } from "@cosmicdrift/kumiko-framework/api";
|
|
2
|
+
import type { LoginRateLimiter, PostAuthLandingResolver } from "@cosmicdrift/kumiko-framework/api";
|
|
3
3
|
import type { KmsAdapter } from "@cosmicdrift/kumiko-framework/crypto";
|
|
4
4
|
import type { RowLevelSecurityMode } from "@cosmicdrift/kumiko-framework/db";
|
|
5
5
|
import type { SessionUser } from "@cosmicdrift/kumiko-framework/engine";
|
|
@@ -21,6 +21,10 @@ export type RunDevAppAuthOptions = {
|
|
|
21
21
|
/** Optional override of the login error → HTTP status map. Default
|
|
22
22
|
* maps invalidCredentials → 401, noMembership → 403. */
|
|
23
23
|
readonly loginErrorStatusMap?: Readonly<Record<string, number>>;
|
|
24
|
+
/** Symmetric with RunProdAppAuthOptions.sessionExchangeHandlers. */
|
|
25
|
+
readonly sessionExchangeHandlers?: Readonly<Record<string, string>>;
|
|
26
|
+
/** Symmetric with RunProdAppAuthOptions.sessionExchangeRateLimit. */
|
|
27
|
+
readonly sessionExchangeRateLimit?: LoginRateLimiter | null;
|
|
24
28
|
/** Auth-mail convenience, symmetric with RunProdAppAuthOptions.mail.
|
|
25
29
|
* Wires all four mail flows from env-based SMTP settings and the default
|
|
26
30
|
* templates; hmacSecret is the `JWT_SECRET` environment value, with a dev
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
// installs from dist-server/package.json, whose ranges alone resolve to whatever is newest
|
|
3
3
|
// on the registry at image-build time. Seeding the app's bun.lock keeps already-locked
|
|
4
4
|
// packages at their locked versions; packages the app lock does not carry resolve fresh.
|
|
5
|
+
// When the seed carries every runtime dependency, the lock is written without registry access
|
|
6
|
+
// (build pods have no internet).
|
|
5
7
|
import { existsSync } from "node:fs";
|
|
6
|
-
import { copyFile } from "node:fs/promises";
|
|
8
|
+
import { copyFile, readFile, writeFile } from "node:fs/promises";
|
|
7
9
|
import { dirname, join, resolve } from "node:path";
|
|
10
|
+
import { parseJsonOrThrow } from "@cosmicdrift/kumiko-framework/utils";
|
|
11
|
+
import * as z from "zod";
|
|
8
12
|
function findSeedLockfile(startDir) {
|
|
9
13
|
let dir = resolve(startDir);
|
|
10
14
|
for (;;) {
|
|
@@ -17,11 +21,47 @@ function findSeedLockfile(startDir) {
|
|
|
17
21
|
dir = parent;
|
|
18
22
|
}
|
|
19
23
|
}
|
|
24
|
+
const runtimePackageSchema = z
|
|
25
|
+
.object({ name: z.string(), dependencies: z.record(z.string(), z.string()).default({}) })
|
|
26
|
+
.passthrough();
|
|
27
|
+
const lockSchema = z
|
|
28
|
+
.object({
|
|
29
|
+
workspaces: z.record(z.string(), z.unknown()),
|
|
30
|
+
overrides: z.record(z.string(), z.string()).optional(),
|
|
31
|
+
})
|
|
32
|
+
.passthrough();
|
|
33
|
+
// The app lock carries the app's own root workspace, so bun would see the dist-server
|
|
34
|
+
// dependencies as changed and re-resolve them through registry manifests. With the root
|
|
35
|
+
// rewritten to dist-server's own dependencies, every locked package resolves from the lock
|
|
36
|
+
// alone; only packages missing from the app lock still need the registry. The other
|
|
37
|
+
// workspaces stay: their `workspace:` entries remain in `packages`, and dropping them makes a
|
|
38
|
+
// monorepo lock inconsistent so bun re-resolves everything. The lock's overrides stay too
|
|
39
|
+
// (they carry security pins for transitive packages) and move into package.json: bun compares
|
|
40
|
+
// the two, and a mismatch re-resolves through the registry and drops the pins.
|
|
41
|
+
async function rewriteSeedLockForRuntimePackage(lockfile, outDir) {
|
|
42
|
+
const manifestPath = join(outDir, "package.json");
|
|
43
|
+
const manifest = runtimePackageSchema.parse(parseJsonOrThrow(await readFile(manifestPath, "utf8"), manifestPath));
|
|
44
|
+
const lock = lockSchema.parse(Bun.JSONC.parse(await readFile(lockfile, "utf8")));
|
|
45
|
+
const rewritten = {
|
|
46
|
+
...lock,
|
|
47
|
+
workspaces: {
|
|
48
|
+
...lock.workspaces,
|
|
49
|
+
"": { name: manifest.name, dependencies: manifest.dependencies },
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
await writeFile(lockfile, `${JSON.stringify(rewritten, null, 2)}\n`);
|
|
53
|
+
if (lock.overrides !== undefined) {
|
|
54
|
+
await writeFile(manifestPath, `${JSON.stringify({ ...manifest, overrides: lock.overrides }, null, 2)}\n`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
20
57
|
async function runBun(args, cwd) {
|
|
21
58
|
// process.execPath: the lock format has to match the Bun that built the bundle.
|
|
22
59
|
const proc = Bun.spawn({
|
|
23
60
|
cmd: [process.execPath, ...args],
|
|
24
61
|
cwd,
|
|
62
|
+
// Bun.spawn reads the env from process start, so runtime changes to process.env (proxy,
|
|
63
|
+
// cache dir) only reach the child when passed explicitly.
|
|
64
|
+
env: process.env,
|
|
25
65
|
stdout: "pipe",
|
|
26
66
|
stderr: "pipe",
|
|
27
67
|
});
|
|
@@ -36,8 +76,10 @@ export async function writeServerLockfile(options) {
|
|
|
36
76
|
const outDir = resolve(options.outDir);
|
|
37
77
|
const lockfile = join(outDir, "bun.lock");
|
|
38
78
|
const seedLockfile = findSeedLockfile(options.cwd);
|
|
39
|
-
if (seedLockfile !== undefined)
|
|
79
|
+
if (seedLockfile !== undefined) {
|
|
40
80
|
await copyFile(seedLockfile, lockfile);
|
|
81
|
+
await rewriteSeedLockForRuntimePackage(lockfile, outDir);
|
|
82
|
+
}
|
|
41
83
|
const install = await runBun(["install", "--lockfile-only"], outDir);
|
|
42
84
|
if (install.exitCode !== 0) {
|
|
43
85
|
throw new Error(`bun install --lockfile-only failed in ${outDir} (exit ${install.exitCode}); shipping dist-server without a lockfile would leave runtime versions unpinned.\n${install.output}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-dev-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.424.1",
|
|
4
4
|
"description": "Dev-tooling for Kumiko apps: local dev-server bootstrap (runDevApp), scaffolding. Its compose-stacks/env-schema subpaths are consumed at prod boot too — see @cosmicdrift/kumiko-server-runtime for the prod runner itself.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -77,15 +77,15 @@
|
|
|
77
77
|
"kumiko-upgrade": "./bin/kumiko-upgrade.ts"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@cosmicdrift/kumiko-bundled-features": "0.
|
|
81
|
-
"@cosmicdrift/kumiko-feature-ast": "0.
|
|
82
|
-
"@cosmicdrift/kumiko-framework": "0.
|
|
83
|
-
"@cosmicdrift/kumiko-renderer": "0.
|
|
84
|
-
"@cosmicdrift/kumiko-renderer-mail-html": "0.
|
|
85
|
-
"@cosmicdrift/kumiko-guards": "0.
|
|
86
|
-
"@cosmicdrift/kumiko-server-runtime": "0.
|
|
87
|
-
"@cosmicdrift/kumiko-testing": "0.
|
|
88
|
-
"@cosmicdrift/kumiko-types": "0.
|
|
80
|
+
"@cosmicdrift/kumiko-bundled-features": "0.424.1",
|
|
81
|
+
"@cosmicdrift/kumiko-feature-ast": "0.424.1",
|
|
82
|
+
"@cosmicdrift/kumiko-framework": "0.424.1",
|
|
83
|
+
"@cosmicdrift/kumiko-renderer": "0.424.1",
|
|
84
|
+
"@cosmicdrift/kumiko-renderer-mail-html": "0.424.1",
|
|
85
|
+
"@cosmicdrift/kumiko-guards": "0.424.1",
|
|
86
|
+
"@cosmicdrift/kumiko-server-runtime": "0.424.1",
|
|
87
|
+
"@cosmicdrift/kumiko-testing": "0.424.1",
|
|
88
|
+
"@cosmicdrift/kumiko-types": "0.424.1",
|
|
89
89
|
"ts-morph": "^28.0.0",
|
|
90
90
|
"zod": "^4.6.7"
|
|
91
91
|
},
|
package/src/changes.json
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.423.0",
|
|
4
|
+
"type": "fix",
|
|
5
|
+
"title": "kumiko-build writes the server lockfile without network",
|
|
6
|
+
"detail": "The dist-server lockfile is derived from the app lock alone, so builds in environments without internet access no longer hang on registry lookups. Packages missing from the app lock still resolve through the registry.",
|
|
7
|
+
"migration": "Apps that run with LOG_FORMAT=pretty in production must declare pino-pretty as a dependency; dist-server no longer installs it by default."
|
|
8
|
+
},
|
|
2
9
|
{
|
|
3
10
|
"version": "0.420.0",
|
|
4
11
|
"type": "fix",
|