@demiurgejs/core 0.2.0-beta.2 → 0.2.0-beta.4
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/README.md +13 -11
- package/bin/demiurge.mjs +30 -12
- package/dist/adapter/testing.js.map +1 -1
- package/dist/browser/file-router.d.ts +388 -5
- package/dist/browser/file-router.d.ts.map +1 -1
- package/dist/browser/focus.d.ts +20 -0
- package/dist/browser/focus.d.ts.map +1 -0
- package/dist/browser/index.d.ts +7 -1
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/mutation-action.d.ts +81 -0
- package/dist/browser/mutation-action.d.ts.map +1 -0
- package/dist/chunks/document-shell-CpJnFtSC.js +36 -0
- package/dist/chunks/document-shell-CpJnFtSC.js.map +1 -0
- package/dist/chunks/env-startup-DOBYWlZD.js +257 -0
- package/dist/chunks/env-startup-DOBYWlZD.js.map +1 -0
- package/dist/chunks/{image-codec-BGTx_t5K.js → image-codec-BmzWnH6W.js} +2 -2
- package/dist/chunks/{image-codec-BGTx_t5K.js.map → image-codec-BmzWnH6W.js.map} +1 -1
- package/dist/chunks/{images-B9MqcjSA.js → images-BQ80950B.js} +99 -91
- package/dist/chunks/images-BQ80950B.js.map +1 -0
- package/dist/chunks/index-BVk9zWbe.js +832 -0
- package/dist/chunks/index-BVk9zWbe.js.map +1 -0
- package/dist/chunks/manifest-vO6c0G0W.js +19 -0
- package/dist/chunks/manifest-vO6c0G0W.js.map +1 -0
- package/dist/chunks/plugin-BQgMiHxa.js +1827 -0
- package/dist/chunks/plugin-BQgMiHxa.js.map +1 -0
- package/dist/chunks/session-store-ChModVcq.js +92 -0
- package/dist/chunks/session-store-ChModVcq.js.map +1 -0
- package/dist/chunks/static-files-ehaD1kE7.js +51 -0
- package/dist/chunks/static-files-ehaD1kE7.js.map +1 -0
- package/dist/chunks/{streaming-BQ1bykDo.js → streaming-BEbPN7Uk.js} +163 -163
- package/dist/chunks/streaming-BEbPN7Uk.js.map +1 -0
- package/dist/chunks/testing-DueXbMo4.js +4167 -0
- package/dist/chunks/testing-DueXbMo4.js.map +1 -0
- package/dist/chunks/vite-DO70kZA6.js +259 -0
- package/dist/chunks/vite-DO70kZA6.js.map +1 -0
- package/dist/cli.d.ts +17 -25
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +159 -124
- package/dist/cli.js.map +1 -1
- package/dist/config/define.d.ts +3 -0
- package/dist/config/define.d.ts.map +1 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +78 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/load.d.ts +12 -0
- package/dist/config/load.d.ts.map +1 -0
- package/dist/config/types.d.ts +64 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/validate.d.ts +9 -0
- package/dist/config/validate.d.ts.map +1 -0
- package/dist/config/vite.d.ts +12 -0
- package/dist/config/vite.d.ts.map +1 -0
- package/dist/data/cache.d.ts +10 -0
- package/dist/data/cache.d.ts.map +1 -1
- package/dist/data/idempotency.d.ts.map +1 -1
- package/dist/data/index.d.ts +3 -1
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/testing.d.ts.map +1 -1
- package/dist/data/testing.js +94 -72
- package/dist/data/testing.js.map +1 -1
- package/dist/data/tiered.d.ts +7 -0
- package/dist/data/tiered.d.ts.map +1 -0
- package/dist/deployment/testing.d.ts +25 -0
- package/dist/deployment/testing.d.ts.map +1 -0
- package/dist/deployment/testing.js +171 -0
- package/dist/deployment/testing.js.map +1 -0
- package/dist/document/deferred-scripts.d.ts.map +1 -1
- package/dist/document/hydration.d.ts +9 -0
- package/dist/document/hydration.d.ts.map +1 -1
- package/dist/document/index.d.ts +5 -2
- package/dist/document/index.d.ts.map +1 -1
- package/dist/document/metadata.d.ts +8 -0
- package/dist/document/metadata.d.ts.map +1 -1
- package/dist/document/navigation.d.ts +28 -0
- package/dist/document/navigation.d.ts.map +1 -0
- package/dist/document/render.d.ts +3 -1
- package/dist/document/render.d.ts.map +1 -1
- package/dist/document/seo.d.ts.map +1 -1
- package/dist/document/trusted-types.d.ts +10 -0
- package/dist/document/trusted-types.d.ts.map +1 -0
- package/dist/edge/assets.d.ts.map +1 -1
- package/dist/edge/index.js +55 -73
- package/dist/edge/index.js.map +1 -1
- package/dist/index.d.ts +15 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2078 -573
- package/dist/index.js.map +1 -1
- package/dist/internal/testing.js +11 -11
- package/dist/kv/index.d.ts +4 -0
- package/dist/kv/index.d.ts.map +1 -1
- package/dist/kv/index.js +180 -60
- package/dist/kv/index.js.map +1 -1
- package/dist/kv/rate-limit-store.d.ts +8 -0
- package/dist/kv/rate-limit-store.d.ts.map +1 -0
- package/dist/kv/session-store.d.ts +20 -0
- package/dist/kv/session-store.d.ts.map +1 -0
- package/dist/kv/store.d.ts.map +1 -1
- package/dist/manifest.d.ts +10 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/node/http.d.ts.map +1 -1
- package/dist/node/image.d.ts.map +1 -1
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +251 -178
- package/dist/node/index.js.map +1 -1
- package/dist/node/serve.d.ts +47 -0
- package/dist/node/serve.d.ts.map +1 -0
- package/dist/node/static.d.ts.map +1 -1
- package/dist/node/streaming.d.ts.map +1 -1
- package/dist/platform/fonts.d.ts.map +1 -1
- package/dist/platform/image-url.d.ts.map +1 -1
- package/dist/platform/images.d.ts.map +1 -1
- package/dist/platform/index.d.ts +5 -1
- package/dist/platform/index.d.ts.map +1 -1
- package/dist/platform/observability.d.ts +2 -1
- package/dist/platform/observability.d.ts.map +1 -1
- package/dist/platform/url.d.ts +19 -0
- package/dist/platform/url.d.ts.map +1 -0
- package/dist/platform/web-vitals-client.d.ts +32 -0
- package/dist/platform/web-vitals-client.d.ts.map +1 -0
- package/dist/platform/web-vitals.d.ts +78 -0
- package/dist/platform/web-vitals.d.ts.map +1 -0
- package/dist/redis/index.d.ts +4 -0
- package/dist/redis/index.d.ts.map +1 -1
- package/dist/redis/index.js +209 -54
- package/dist/redis/index.js.map +1 -1
- package/dist/redis/rate-limit-store.d.ts +8 -0
- package/dist/redis/rate-limit-store.d.ts.map +1 -0
- package/dist/redis/session-store.d.ts +9 -0
- package/dist/redis/session-store.d.ts.map +1 -0
- package/dist/redis/store.d.ts.map +1 -1
- package/dist/route/index.d.ts +2 -2
- package/dist/route/index.d.ts.map +1 -1
- package/dist/route/middleware.d.ts.map +1 -1
- package/dist/route/mutation.d.ts +97 -0
- package/dist/route/mutation.d.ts.map +1 -0
- package/dist/route/response.d.ts.map +1 -1
- package/dist/route/types.d.ts +6 -1
- package/dist/route/types.d.ts.map +1 -1
- package/dist/router/index.d.ts +1 -1
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/manifest.d.ts +9 -0
- package/dist/router/manifest.d.ts.map +1 -1
- package/dist/router/navigation-data.d.ts +9 -1
- package/dist/router/navigation-data.d.ts.map +1 -1
- package/dist/routing/generate.d.ts +3 -0
- package/dist/routing/generate.d.ts.map +1 -1
- package/dist/routing/index.d.ts +3 -1
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/locale.d.ts +43 -0
- package/dist/routing/locale.d.ts.map +1 -0
- package/dist/routing/types.d.ts +12 -0
- package/dist/routing/types.d.ts.map +1 -1
- package/dist/security/cookie-session.d.ts +43 -0
- package/dist/security/cookie-session.d.ts.map +1 -0
- package/dist/security/cookies.d.ts +26 -0
- package/dist/security/cookies.d.ts.map +1 -0
- package/dist/security/csrf.d.ts +1 -1
- package/dist/security/csrf.d.ts.map +1 -1
- package/dist/security/env-startup.d.ts +15 -0
- package/dist/security/env-startup.d.ts.map +1 -0
- package/dist/security/env.d.ts +25 -6
- package/dist/security/env.d.ts.map +1 -1
- package/dist/security/fetch-metadata.d.ts +29 -0
- package/dist/security/fetch-metadata.d.ts.map +1 -0
- package/dist/security/index.d.ts +14 -2
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/policy.d.ts.map +1 -1
- package/dist/security/rate-limit.d.ts +6 -3
- package/dist/security/rate-limit.d.ts.map +1 -1
- package/dist/security/report.d.ts.map +1 -1
- package/dist/security/request.d.ts.map +1 -1
- package/dist/security/session-manager.d.ts +32 -0
- package/dist/security/session-manager.d.ts.map +1 -0
- package/dist/security/session-store.d.ts +51 -0
- package/dist/security/session-store.d.ts.map +1 -0
- package/dist/security/testing.d.ts +10 -0
- package/dist/security/testing.d.ts.map +1 -0
- package/dist/security/testing.js +145 -0
- package/dist/security/testing.js.map +1 -0
- package/dist/security/types.d.ts +73 -3
- package/dist/security/types.d.ts.map +1 -1
- package/dist/server/document-shell.d.ts.map +1 -1
- package/dist/server/errors.d.ts +1 -0
- package/dist/server/errors.d.ts.map +1 -1
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/not-found.d.ts +1 -0
- package/dist/server/not-found.d.ts.map +1 -1
- package/dist/server/render-tree.d.ts.map +1 -1
- package/dist/server/request-handler.d.ts +10 -2
- package/dist/server/request-handler.d.ts.map +1 -1
- package/dist/server/request-metadata.d.ts +1 -0
- package/dist/server/request-metadata.d.ts.map +1 -1
- package/dist/server/ssr.d.ts +2 -0
- package/dist/server/ssr.d.ts.map +1 -1
- package/dist/static/index.d.ts +2 -0
- package/dist/static/index.d.ts.map +1 -1
- package/dist/static/index.js +380 -363
- package/dist/static/index.js.map +1 -1
- package/dist/static/preview.d.ts.map +1 -1
- package/dist/static/vercel.d.ts +11 -2
- package/dist/static/vercel.d.ts.map +1 -1
- package/dist/static-files.d.ts +12 -0
- package/dist/static-files.d.ts.map +1 -1
- package/dist/type-guards.d.ts +19 -0
- package/dist/type-guards.d.ts.map +1 -0
- package/dist/vite/env-boundary.d.ts +14 -0
- package/dist/vite/env-boundary.d.ts.map +1 -0
- package/dist/vite/index.d.ts +8 -3
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +22 -1196
- package/dist/vite/index.js.map +1 -1
- package/dist/vite/plugin.d.ts +8 -1
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/vite/policy-verification.d.ts.map +1 -1
- package/dist/vite/route-audit.d.ts +50 -0
- package/dist/vite/route-audit.d.ts.map +1 -0
- package/package.json +19 -6
- package/dist/chunks/document-shell-D1xo6cEA.js +0 -35
- package/dist/chunks/document-shell-D1xo6cEA.js.map +0 -1
- package/dist/chunks/images-B9MqcjSA.js.map +0 -1
- package/dist/chunks/request-metadata-D5NrT8ks.js +0 -642
- package/dist/chunks/request-metadata-D5NrT8ks.js.map +0 -1
- package/dist/chunks/static-files-DUjHw-4H.js +0 -11
- package/dist/chunks/static-files-DUjHw-4H.js.map +0 -1
- package/dist/chunks/streaming-BQ1bykDo.js.map +0 -1
- package/dist/chunks/testing-B_iMFYz_.js +0 -3321
- package/dist/chunks/testing-B_iMFYz_.js.map +0 -1
- package/dist/route/action.d.ts +0 -33
- package/dist/route/action.d.ts.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,173 +1,208 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { resolve as
|
|
3
|
-
import { pathToFileURL as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { readdir as g, readFile as b } from "node:fs/promises";
|
|
2
|
+
import { resolve as p, join as D, relative as m, sep as v, isAbsolute as y } from "node:path";
|
|
3
|
+
import { pathToFileURL as R } from "node:url";
|
|
4
|
+
import { c as E } from "./chunks/vite-DO70kZA6.js";
|
|
5
|
+
import { p as S } from "./chunks/manifest-vO6c0G0W.js";
|
|
6
|
+
import { generateStaticOutput as N, generateVercelStaticOutput as T } from "./static/index.js";
|
|
7
|
+
const I = /* @__PURE__ */ new Set(["--host", "--origin", "--out-dir", "--port"]), V = "virtual:demiurge/client-entry", _ = "virtual:demiurge/server-entry", O = "dist", j = "dist/server", U = ".demiurge/server";
|
|
8
|
+
function J(t, e = {}) {
|
|
7
9
|
const r = t[0];
|
|
8
10
|
if (!r || r === "--help" || r === "-h" || r === "help")
|
|
9
11
|
return {
|
|
10
12
|
command: "help",
|
|
11
13
|
host: "localhost",
|
|
12
|
-
outDir: "dist",
|
|
13
14
|
port: 4173
|
|
14
15
|
};
|
|
15
|
-
if (r !== "build" && r !== "preview")
|
|
16
|
+
if (r !== "build" && r !== "dev" && r !== "preview")
|
|
16
17
|
throw new Error(`Unknown command: ${r}`);
|
|
17
|
-
const
|
|
18
|
+
const o = {
|
|
18
19
|
command: r,
|
|
19
20
|
host: "localhost",
|
|
20
21
|
origin: e.SITE_ORIGIN,
|
|
21
|
-
|
|
22
|
-
port: 4173
|
|
22
|
+
port: r === "dev" ? 5173 : 4173
|
|
23
23
|
};
|
|
24
24
|
for (let n = 1; n < t.length; n += 1) {
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
25
|
+
const i = t[n];
|
|
26
|
+
if (i === "--help" || i === "-h")
|
|
27
|
+
return { command: "help", host: "localhost", port: 4173 };
|
|
28
|
+
const [s, c] = i.split("=", 2);
|
|
29
|
+
if (!I.has(s))
|
|
30
|
+
throw new Error(`Unknown option: ${i}`);
|
|
31
|
+
const a = c ?? t[++n];
|
|
32
|
+
if (!a || a.startsWith("--"))
|
|
30
33
|
throw new Error(`Option ${s} requires a value.`);
|
|
31
|
-
if (s === "--host" && (
|
|
32
|
-
const
|
|
33
|
-
if (!Number.isSafeInteger(
|
|
34
|
-
throw new Error("
|
|
35
|
-
|
|
34
|
+
if (s === "--host" && (o.host = a), s === "--origin" && (o.origin = a), s === "--out-dir" && (o.outDir = a), s === "--port") {
|
|
35
|
+
const u = Number(a);
|
|
36
|
+
if (!Number.isSafeInteger(u) || u < 0 || u > 65535)
|
|
37
|
+
throw new Error("The server port must be an integer from 0 through 65535.");
|
|
38
|
+
o.port = u;
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
|
-
return
|
|
41
|
+
return o;
|
|
39
42
|
}
|
|
40
|
-
const
|
|
43
|
+
const G = `Usage: demiurge <command> [options]
|
|
41
44
|
|
|
42
45
|
Commands:
|
|
43
|
-
|
|
46
|
+
dev Start the development server
|
|
47
|
+
build Build production output
|
|
44
48
|
preview Serve static output with its declared headers
|
|
45
49
|
|
|
46
50
|
Options:
|
|
47
|
-
--host <host> Set the
|
|
51
|
+
--host <host> Set the server host (default: localhost)
|
|
48
52
|
--origin <origin> Set the build origin (default: SITE_ORIGIN)
|
|
49
|
-
--out-dir <directory> Set the output directory (default: dist)
|
|
50
|
-
--port <port> Set the
|
|
51
|
-
-h, --help Show this help
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
--out-dir <directory> Set the client output directory (default: dist)
|
|
54
|
+
--port <port> Set the server port (dev: 5173, preview: 4173)
|
|
55
|
+
-h, --help Show this help
|
|
56
|
+
|
|
57
|
+
Demiurge reads demiurge.config.ts from the project root.`;
|
|
58
|
+
async function H(t, e) {
|
|
59
|
+
const { createServer: r } = await import("vite"), o = await r(
|
|
60
|
+
await E({
|
|
61
|
+
config: e,
|
|
62
|
+
overrides: {
|
|
63
|
+
mode: "development",
|
|
64
|
+
server: { host: t.host, port: t.port }
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
return await o.listen(), o;
|
|
69
|
+
}
|
|
70
|
+
async function Y(t, e, r) {
|
|
71
|
+
const o = e.root, n = r?.build ?? (await import("vite")).build, i = r?.createViteConfig ?? ((d) => E({ config: e, overrides: d })), s = p(
|
|
56
72
|
o,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
input:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
t.outDir ?? e.deployment?.outDir ?? O
|
|
74
|
+
), c = p(o, U);
|
|
75
|
+
await F(
|
|
76
|
+
o,
|
|
77
|
+
s,
|
|
78
|
+
D(o, "public"),
|
|
79
|
+
c
|
|
80
|
+
), await n(
|
|
81
|
+
await i({
|
|
82
|
+
define: { "process.env.NODE_ENV": JSON.stringify("production") },
|
|
83
|
+
mode: "production",
|
|
84
|
+
build: {
|
|
85
|
+
emptyOutDir: !0,
|
|
86
|
+
outDir: s,
|
|
87
|
+
rollupOptions: { input: V }
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
const a = e.deployment?.server, u = a ? p(o, a.outDir ?? j) : void 0;
|
|
92
|
+
return a && u && await n(
|
|
93
|
+
await i({
|
|
94
|
+
define: { "process.env.NODE_ENV": JSON.stringify("production") },
|
|
95
|
+
mode: "production",
|
|
96
|
+
build: {
|
|
97
|
+
copyPublicDir: !1,
|
|
98
|
+
emptyOutDir: !0,
|
|
99
|
+
outDir: u,
|
|
100
|
+
rollupOptions: { input: p(o, a.entry) },
|
|
101
|
+
ssr: !0
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
), e.deployment?.static ? { ...await C({
|
|
105
|
+
build: n,
|
|
106
|
+
config: e,
|
|
107
|
+
createViteConfig: i,
|
|
108
|
+
frameworkServerOutDir: c,
|
|
109
|
+
options: t,
|
|
110
|
+
outDir: s,
|
|
111
|
+
root: o,
|
|
112
|
+
runtime: r
|
|
113
|
+
}), outDir: s, serverOutDir: u } : { outDir: s, serverOutDir: u };
|
|
114
|
+
}
|
|
115
|
+
async function C({
|
|
116
|
+
build: t,
|
|
117
|
+
config: e,
|
|
118
|
+
createViteConfig: r,
|
|
119
|
+
frameworkServerOutDir: o,
|
|
120
|
+
options: n,
|
|
121
|
+
outDir: i,
|
|
122
|
+
root: s,
|
|
123
|
+
runtime: c
|
|
124
|
+
}) {
|
|
125
|
+
await t(
|
|
126
|
+
await r({
|
|
127
|
+
define: { "process.env.NODE_ENV": JSON.stringify("production") },
|
|
128
|
+
mode: "production",
|
|
129
|
+
build: {
|
|
130
|
+
copyPublicDir: !1,
|
|
131
|
+
emptyOutDir: !0,
|
|
132
|
+
outDir: o,
|
|
133
|
+
rollupOptions: {
|
|
134
|
+
input: _,
|
|
135
|
+
output: { entryFileNames: "server-entry.js" }
|
|
136
|
+
},
|
|
137
|
+
ssr: !0
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
);
|
|
141
|
+
const a = S(
|
|
142
|
+
c ? await c.readText(p(i, "demiurge-manifest.json")) : await b(p(i, "demiurge-manifest.json"), "utf8")
|
|
143
|
+
), u = `${R(p(o, "server-entry.js")).href}?build=${c?.now() ?? Date.now()}`, l = c ? await c.importModule(u) : await import(u);
|
|
144
|
+
if (!A(l.routes))
|
|
81
145
|
throw new Error("The framework server bundle does not export routes.");
|
|
82
|
-
const
|
|
83
|
-
fonts:
|
|
84
|
-
images:
|
|
85
|
-
origin:
|
|
86
|
-
outDir:
|
|
87
|
-
root:
|
|
88
|
-
routes:
|
|
89
|
-
ssr:
|
|
90
|
-
staticFileHeaders:
|
|
91
|
-
}),
|
|
92
|
-
return { deploymentOutDir:
|
|
93
|
-
deployment:
|
|
94
|
-
manifest:
|
|
95
|
-
outDir:
|
|
96
|
-
projectRoot:
|
|
97
|
-
}) : void 0, manifest:
|
|
146
|
+
const d = await (c?.generate ?? N)({
|
|
147
|
+
fonts: e.assets?.fonts,
|
|
148
|
+
images: e.assets?.images,
|
|
149
|
+
origin: n.origin ?? e.deployment?.static?.origin,
|
|
150
|
+
outDir: i,
|
|
151
|
+
root: s,
|
|
152
|
+
routes: l.routes,
|
|
153
|
+
ssr: a,
|
|
154
|
+
staticFileHeaders: e.security?.staticFileHeaders ?? []
|
|
155
|
+
}), h = e.deployment?.static?.provider;
|
|
156
|
+
return { deploymentOutDir: h ? await T({
|
|
157
|
+
deployment: h,
|
|
158
|
+
manifest: d,
|
|
159
|
+
outDir: i,
|
|
160
|
+
projectRoot: s
|
|
161
|
+
}) : void 0, manifest: d };
|
|
98
162
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return c(r.root, t);
|
|
163
|
+
function q(t, e, r) {
|
|
164
|
+
return p(t, e ?? r ?? O);
|
|
102
165
|
}
|
|
103
|
-
async function
|
|
104
|
-
const n =
|
|
105
|
-
if (!n || n === ".." || n.startsWith(`..${
|
|
166
|
+
async function F(t, e, r, o) {
|
|
167
|
+
const n = m(t, e);
|
|
168
|
+
if (!n || n === ".." || n.startsWith(`..${v}`) || y(n))
|
|
106
169
|
throw new Error("The static output directory must be inside the Vite root.");
|
|
107
|
-
if (r &&
|
|
170
|
+
if (r && f(e, r))
|
|
108
171
|
throw new Error("The static output directory must not overlap the Vite public directory.");
|
|
109
|
-
if (
|
|
172
|
+
if (f(e, o))
|
|
110
173
|
throw new Error("The static output directory must not overlap the framework server directory.");
|
|
111
|
-
let
|
|
174
|
+
let i;
|
|
112
175
|
try {
|
|
113
|
-
|
|
176
|
+
i = await g(e);
|
|
114
177
|
} catch (s) {
|
|
115
178
|
if ($(s)) return;
|
|
116
179
|
throw s;
|
|
117
180
|
}
|
|
118
|
-
if (
|
|
181
|
+
if (i.length && !i.includes("demiurge-manifest.json") && !i.includes("demiurge-static-manifest.json"))
|
|
119
182
|
throw new Error(
|
|
120
183
|
"The static output directory contains files that a Demiurge build did not create."
|
|
121
184
|
);
|
|
122
185
|
}
|
|
123
|
-
function N(t) {
|
|
124
|
-
let e;
|
|
125
|
-
try {
|
|
126
|
-
e = JSON.parse(t);
|
|
127
|
-
} catch {
|
|
128
|
-
throw new Error("The client build manifest is not valid JSON.");
|
|
129
|
-
}
|
|
130
|
-
if (!e || typeof e != "object" || !("clientEntry" in e) || typeof e.clientEntry != "string" || !("styles" in e) || !Array.isArray(e.styles) || !e.styles.every((r) => typeof r == "string"))
|
|
131
|
-
throw new Error("The client build manifest has an unsupported format.");
|
|
132
|
-
return { clientEntry: e.clientEntry, styles: e.styles };
|
|
133
|
-
}
|
|
134
|
-
function I(t) {
|
|
135
|
-
return !t || typeof t != "object" || Array.isArray(t) ? !1 : Object.values(t).every((e) => typeof e == "function");
|
|
136
|
-
}
|
|
137
|
-
function P(t) {
|
|
138
|
-
return p(t)?.staticDeployment;
|
|
139
|
-
}
|
|
140
186
|
function A(t) {
|
|
141
|
-
return
|
|
142
|
-
}
|
|
143
|
-
function F(t) {
|
|
144
|
-
return p(t)?.images;
|
|
145
|
-
}
|
|
146
|
-
function R(t) {
|
|
147
|
-
return p(t)?.staticFileHeaders ?? [];
|
|
148
|
-
}
|
|
149
|
-
function p(t) {
|
|
150
|
-
return t?.filter((e) => e.name === "demiurge").map((e) => e.api).find(C);
|
|
151
|
-
}
|
|
152
|
-
function C(t) {
|
|
153
|
-
return !!t && t !== null && typeof t == "object" && "demiurge" in t && t.demiurge === !0;
|
|
187
|
+
return !t || typeof t != "object" || Array.isArray(t) ? !1 : Object.values(t).every((e) => typeof e == "function");
|
|
154
188
|
}
|
|
155
|
-
function
|
|
156
|
-
const r =
|
|
157
|
-
return
|
|
189
|
+
function f(t, e) {
|
|
190
|
+
const r = m(t, e), o = m(e, t);
|
|
191
|
+
return w(r) || w(o);
|
|
158
192
|
}
|
|
159
|
-
function
|
|
160
|
-
return !t || t !== ".." && !t.startsWith(`..${
|
|
193
|
+
function w(t) {
|
|
194
|
+
return !t || t !== ".." && !t.startsWith(`..${v}`) && !y(t);
|
|
161
195
|
}
|
|
162
196
|
function $(t) {
|
|
163
197
|
return t instanceof Error && "code" in t && t.code === "ENOENT";
|
|
164
198
|
}
|
|
165
199
|
export {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
200
|
+
G as helpText,
|
|
201
|
+
J as parseCliArguments,
|
|
202
|
+
S as parseClientManifest,
|
|
203
|
+
q as resolvePreviewOutputDirectory,
|
|
204
|
+
Y as runBuild,
|
|
205
|
+
H as runDev,
|
|
206
|
+
F as validateBuildOutputDirectory
|
|
172
207
|
};
|
|
173
208
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":["import { readFile, readdir } from \"node:fs/promises\";\nimport { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { InlineConfig } from \"vite\";\nimport type { FontContribution, ImagePolicy } from \"./platform\";\nimport type { RouteImporter } from \"./route\";\nimport {\n generateVercelStaticOutput,\n generateStaticOutput,\n type GenerateStaticOutputOptions,\n type StaticFileHeaderPatternRule,\n type StaticOutputManifest,\n type VercelStaticDeployment,\n} from \"./static\";\n\ntype CliEnvironment = Record<string, string | undefined>;\n\nconst cliOptionNames = new Set([\"--host\", \"--origin\", \"--out-dir\", \"--port\"]);\n\nexport type CliOptions = {\n command: \"build\" | \"help\" | \"preview\";\n host: string;\n origin?: string;\n outDir: string;\n port: number;\n};\n\ntype StaticBuildRuntime = {\n build: (config: InlineConfig) => Promise<unknown>;\n generate: (\n options: GenerateStaticOutputOptions,\n ) => Promise<StaticOutputManifest>;\n importModule: (specifier: string) => Promise<Record<string, unknown>>;\n now: () => number;\n readText: (file: string) => Promise<string>;\n resolveConfig: () => Promise<{\n plugins?: Array<{\n api?: unknown;\n name: string;\n }>;\n publicDir: false | string;\n root: string;\n }>;\n};\n\nexport function parseCliArguments(\n arguments_: string[],\n environment: CliEnvironment = {},\n): CliOptions {\n const command = arguments_[0];\n if (!command || command === \"--help\" || command === \"-h\" || command === \"help\") {\n return {\n command: \"help\",\n host: \"localhost\",\n outDir: \"dist\",\n port: 4173,\n };\n }\n if (command !== \"build\" && command !== \"preview\") {\n throw new Error(`Unknown command: ${command}`);\n }\n\n const options: CliOptions = {\n command,\n host: \"localhost\",\n origin: environment.SITE_ORIGIN,\n outDir: \"dist\",\n port: 4173,\n };\n\n for (let index = 1; index < arguments_.length; index += 1) {\n const argument = arguments_[index]!;\n const [name, inlineValue] = argument.split(\"=\", 2);\n if (!cliOptionNames.has(name!)) {\n throw new Error(`Unknown option: ${argument}`);\n }\n const value = inlineValue ?? arguments_[++index];\n if (!value || value.startsWith(\"--\")) {\n throw new Error(`Option ${name} requires a value.`);\n }\n\n if (name === \"--host\") options.host = value;\n if (name === \"--origin\") options.origin = value;\n if (name === \"--out-dir\") options.outDir = value;\n if (name === \"--port\") {\n const port = Number(value);\n if (!Number.isSafeInteger(port) || port < 0 || port > 65_535) {\n throw new Error(\"Preview port must be an integer from 0 through 65535.\");\n }\n options.port = port;\n }\n }\n\n return options;\n}\n\nexport const helpText = `Usage: demiurge <command> [options]\n\nCommands:\n build Build static production output\n preview Serve static output with its declared headers\n\nOptions:\n --host <host> Set the preview host (default: localhost)\n --origin <origin> Set the build origin (default: SITE_ORIGIN)\n --out-dir <directory> Set the output directory (default: dist)\n --port <port> Set the preview port (default: 4173)\n -h, --help Show this help`;\n\nexport async function buildStaticSite(\n options: CliOptions,\n runtime?: StaticBuildRuntime,\n) {\n const vite = runtime ? undefined : await import(\"vite\");\n const config = runtime\n ? await runtime.resolveConfig()\n : await vite!.resolveConfig({}, \"build\", \"production\");\n const root = config.root;\n const outDir = resolve(root, options.outDir);\n const serverOutDir = resolve(root, \".demiurge/server\");\n const build = runtime?.build ?? vite!.build;\n\n await validateBuildOutputDirectory(\n root,\n outDir,\n config.publicDir,\n serverOutDir,\n );\n\n await build({\n build: {\n emptyOutDir: true,\n outDir,\n rollupOptions: { input: \"virtual:demiurge/client-entry\" },\n },\n });\n await build({\n build: {\n copyPublicDir: false,\n emptyOutDir: true,\n outDir: serverOutDir,\n rollupOptions: {\n input: \"virtual:demiurge/server-entry\",\n output: { entryFileNames: \"server-entry.js\" },\n },\n ssr: true,\n },\n });\n\n const clientManifest = parseClientManifest(\n runtime\n ? await runtime.readText(resolve(outDir, \"demiurge-manifest.json\"))\n : await readFile(resolve(outDir, \"demiurge-manifest.json\"), \"utf8\"),\n );\n const serverEntryUrl = `${\n pathToFileURL(resolve(serverOutDir, \"server-entry.js\")).href\n }?build=${runtime?.now() ?? Date.now()}`;\n const serverEntry = runtime\n ? await runtime.importModule(serverEntryUrl)\n : await import(serverEntryUrl);\n if (!isRouteImporterRecord(serverEntry.routes)) {\n throw new Error(\"The framework server bundle does not export routes.\");\n }\n\n const manifest = await (runtime?.generate ?? generateStaticOutput)({\n fonts: findFontContribution(config.plugins),\n images: findImagePolicy(config.plugins),\n origin: options.origin,\n outDir,\n root,\n routes: serverEntry.routes,\n ssr: clientManifest,\n staticFileHeaders: findStaticFileHeaderPatterns(config.plugins),\n });\n\n const deployment = findVercelStaticDeployment(config.plugins);\n const deploymentOutDir = deployment\n ? await generateVercelStaticOutput({\n deployment,\n manifest,\n outDir,\n projectRoot: process.cwd(),\n })\n : undefined;\n\n return { deploymentOutDir, manifest, outDir };\n}\n\nexport async function resolvePreviewOutputDirectory(\n outDir: string,\n resolveConfig?: () => Promise<{ root: string }>,\n) {\n const config = resolveConfig\n ? await resolveConfig()\n : await (await import(\"vite\")).resolveConfig({}, \"serve\", \"production\");\n return resolve(config.root, outDir);\n}\n\nexport async function validateBuildOutputDirectory(\n root: string,\n outDir: string,\n publicDir: false | string,\n serverOutDir: string,\n) {\n const pathFromRoot = relative(root, outDir);\n if (\n !pathFromRoot ||\n pathFromRoot === \"..\" ||\n pathFromRoot.startsWith(`..${sep}`) ||\n isAbsolute(pathFromRoot)\n ) {\n throw new Error(\"The static output directory must be inside the Vite root.\");\n }\n\n if (publicDir && pathsOverlap(outDir, publicDir)) {\n throw new Error(\"The static output directory must not overlap the Vite public directory.\");\n }\n\n if (pathsOverlap(outDir, serverOutDir)) {\n throw new Error(\"The static output directory must not overlap the framework server directory.\");\n }\n\n let entries: string[];\n try {\n entries = await readdir(outDir);\n } catch (error) {\n if (isMissingPath(error)) return;\n throw error;\n }\n\n if (\n entries.length &&\n !entries.includes(\"demiurge-manifest.json\") &&\n !entries.includes(\"demiurge-static-manifest.json\")\n ) {\n throw new Error(\n \"The static output directory contains files that a Demiurge build did not create.\",\n );\n }\n}\n\nexport function parseClientManifest(source: string) {\n let value: unknown;\n try {\n value = JSON.parse(source);\n } catch {\n throw new Error(\"The client build manifest is not valid JSON.\");\n }\n if (\n !value ||\n typeof value !== \"object\" ||\n !(\"clientEntry\" in value) ||\n typeof value.clientEntry !== \"string\" ||\n !(\"styles\" in value) ||\n !Array.isArray(value.styles) ||\n !value.styles.every((style) => typeof style === \"string\")\n ) {\n throw new Error(\"The client build manifest has an unsupported format.\");\n }\n return { clientEntry: value.clientEntry, styles: value.styles };\n}\n\nfunction isRouteImporterRecord(\n value: unknown,\n): value is Record<string, RouteImporter> {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return false;\n }\n\n return Object.values(value).every((load) => typeof load === \"function\");\n}\n\nfunction findVercelStaticDeployment(\n plugins: ReadonlyArray<{ api?: unknown; name: string }> | undefined,\n): VercelStaticDeployment | undefined {\n return findDemiurgePluginApi(plugins)?.staticDeployment;\n}\n\nfunction findFontContribution(\n plugins: ReadonlyArray<{ api?: unknown; name: string }> | undefined,\n): FontContribution | undefined {\n return findDemiurgePluginApi(plugins)?.fonts;\n}\n\nfunction findImagePolicy(\n plugins: ReadonlyArray<{ api?: unknown; name: string }> | undefined,\n): ImagePolicy | undefined {\n return findDemiurgePluginApi(plugins)?.images;\n}\n\nfunction findStaticFileHeaderPatterns(\n plugins: ReadonlyArray<{ api?: unknown; name: string }> | undefined,\n): readonly StaticFileHeaderPatternRule[] {\n return findDemiurgePluginApi(plugins)?.staticFileHeaders ?? [];\n}\n\nfunction findDemiurgePluginApi(\n plugins: ReadonlyArray<{ api?: unknown; name: string }> | undefined,\n) {\n return plugins\n ?.filter((plugin) => plugin.name === \"demiurge\")\n .map((plugin) => plugin.api)\n .find(isDemiurgePluginApi);\n}\n\nfunction isDemiurgePluginApi(value: unknown): value is {\n demiurge: true;\n fonts?: FontContribution;\n images?: ImagePolicy;\n staticDeployment?: VercelStaticDeployment;\n staticFileHeaders?: readonly StaticFileHeaderPatternRule[];\n} {\n return Boolean(value) &&\n value !== null &&\n typeof value === \"object\" &&\n \"demiurge\" in value &&\n value.demiurge === true;\n}\n\nfunction pathsOverlap(left: string, right: string) {\n const fromLeft = relative(left, right);\n const fromRight = relative(right, left);\n return isSameOrChildPath(fromLeft) || isSameOrChildPath(fromRight);\n}\n\nfunction isSameOrChildPath(pathname: string) {\n return !pathname ||\n (pathname !== \"..\" && !pathname.startsWith(`..${sep}`) &&\n !isAbsolute(pathname));\n}\n\nfunction isMissingPath(error: unknown) {\n return error instanceof Error && \"code\" in error && error.code === \"ENOENT\";\n}\n"],"names":["cliOptionNames","parseCliArguments","arguments_","environment","command","options","index","argument","name","inlineValue","value","port","helpText","buildStaticSite","runtime","vite","config","root","outDir","resolve","serverOutDir","build","validateBuildOutputDirectory","clientManifest","parseClientManifest","readFile","serverEntryUrl","pathToFileURL","serverEntry","isRouteImporterRecord","manifest","generateStaticOutput","findFontContribution","findImagePolicy","findStaticFileHeaderPatterns","deployment","findVercelStaticDeployment","generateVercelStaticOutput","resolvePreviewOutputDirectory","resolveConfig","publicDir","pathFromRoot","relative","sep","isAbsolute","pathsOverlap","entries","readdir","error","isMissingPath","source","style","load","plugins","findDemiurgePluginApi","plugin","isDemiurgePluginApi","left","right","fromLeft","fromRight","isSameOrChildPath","pathname"],"mappings":";;;;AAiBA,MAAMA,wBAAqB,IAAI,CAAC,UAAU,YAAY,aAAa,QAAQ,CAAC;AA4BrE,SAASC,EACdC,GACAC,IAA8B,IAClB;AACZ,QAAMC,IAAUF,EAAW,CAAC;AAC5B,MAAI,CAACE,KAAWA,MAAY,YAAYA,MAAY,QAAQA,MAAY;AACtE,WAAO;AAAA,MACL,SAAS;AAAA,MACT,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,MAAM;AAAA,IAAA;AAGV,MAAIA,MAAY,WAAWA,MAAY;AACrC,UAA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AAC1B;AAEA,SAASb,EAAcD,GAAgB;AACrC,SAAOA,aAAiB,SAAS,UAAUA,KAASA,EAAM,SAAS;AACrE;"}
|
|
1
|
+
{"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":["import { readFile, readdir } from \"node:fs/promises\";\nimport { isAbsolute, join, relative, resolve, sep } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { InlineConfig } from \"vite\";\nimport { createDemiurgeViteConfig } from \"./config/vite\";\nimport type { ResolvedDemiurgeConfig } from \"./config/types\";\nimport { parseClientManifest } from \"./manifest\";\nimport type { RouteImporter } from \"./route\";\nimport {\n generateVercelStaticOutput,\n generateStaticOutput,\n type GenerateStaticOutputOptions,\n type StaticOutputManifest,\n} from \"./static\";\n\nexport { parseClientManifest } from \"./manifest\";\nexport type { ClientBuildManifest } from \"./manifest\";\n\ntype CliEnvironment = Record<string, string | undefined>;\n\nconst cliOptionNames = new Set([\"--host\", \"--origin\", \"--out-dir\", \"--port\"]);\n\nconst CLIENT_ENTRY = \"virtual:demiurge/client-entry\";\nconst SERVER_ENTRY = \"virtual:demiurge/server-entry\";\nconst DEFAULT_CLIENT_OUT_DIR = \"dist\";\nconst DEFAULT_SERVER_OUT_DIR = \"dist/server\";\nconst FRAMEWORK_SERVER_OUT_DIR = \".demiurge/server\";\n\nexport type CliOptions = {\n command: \"build\" | \"dev\" | \"help\" | \"preview\";\n host: string;\n origin?: string;\n outDir?: string;\n port: number;\n};\n\nexport type BuildRuntime = {\n build: (config: InlineConfig) => Promise<unknown>;\n createViteConfig: (overrides: InlineConfig) => Promise<InlineConfig>;\n generate: (\n options: GenerateStaticOutputOptions,\n ) => Promise<StaticOutputManifest>;\n importModule: (specifier: string) => Promise<Record<string, unknown>>;\n now: () => number;\n readText: (file: string) => Promise<string>;\n};\n\nexport type BuildResult = {\n deploymentOutDir?: string;\n manifest?: StaticOutputManifest;\n outDir: string;\n serverOutDir?: string;\n};\n\nexport function parseCliArguments(\n arguments_: string[],\n environment: CliEnvironment = {},\n): CliOptions {\n const command = arguments_[0];\n if (!command || command === \"--help\" || command === \"-h\" || command === \"help\") {\n return {\n command: \"help\",\n host: \"localhost\",\n port: 4173,\n };\n }\n if (command !== \"build\" && command !== \"dev\" && command !== \"preview\") {\n throw new Error(`Unknown command: ${command}`);\n }\n\n const options: CliOptions = {\n command,\n host: \"localhost\",\n origin: environment.SITE_ORIGIN,\n port: command === \"dev\" ? 5173 : 4173,\n };\n\n for (let index = 1; index < arguments_.length; index += 1) {\n const argument = arguments_[index]!;\n if (argument === \"--help\" || argument === \"-h\") {\n return { command: \"help\", host: \"localhost\", port: 4173 };\n }\n const [name, inlineValue] = argument.split(\"=\", 2);\n if (!cliOptionNames.has(name!)) {\n throw new Error(`Unknown option: ${argument}`);\n }\n const value = inlineValue ?? arguments_[++index];\n if (!value || value.startsWith(\"--\")) {\n throw new Error(`Option ${name} requires a value.`);\n }\n\n if (name === \"--host\") options.host = value;\n if (name === \"--origin\") options.origin = value;\n if (name === \"--out-dir\") options.outDir = value;\n if (name === \"--port\") {\n const port = Number(value);\n if (!Number.isSafeInteger(port) || port < 0 || port > 65_535) {\n throw new Error(\"The server port must be an integer from 0 through 65535.\");\n }\n options.port = port;\n }\n }\n\n return options;\n}\n\nexport const helpText = `Usage: demiurge <command> [options]\n\nCommands:\n dev Start the development server\n build Build production output\n preview Serve static output with its declared headers\n\nOptions:\n --host <host> Set the server host (default: localhost)\n --origin <origin> Set the build origin (default: SITE_ORIGIN)\n --out-dir <directory> Set the client output directory (default: dist)\n --port <port> Set the server port (dev: 5173, preview: 4173)\n -h, --help Show this help\n\nDemiurge reads demiurge.config.ts from the project root.`;\n\nexport async function runDev(\n options: CliOptions,\n config: ResolvedDemiurgeConfig,\n) {\n const { createServer } = await import(\"vite\");\n const server = await createServer(\n await createDemiurgeViteConfig({\n config,\n overrides: {\n mode: \"development\",\n server: { host: options.host, port: options.port },\n },\n }),\n );\n await server.listen();\n return server;\n}\n\nexport async function runBuild(\n options: CliOptions,\n config: ResolvedDemiurgeConfig,\n runtime?: BuildRuntime,\n): Promise<BuildResult> {\n const root = config.root;\n const build = runtime?.build ?? (await import(\"vite\")).build;\n const createViteConfig = runtime?.createViteConfig ??\n ((overrides: InlineConfig) => createDemiurgeViteConfig({ config, overrides }));\n\n const outDir = resolve(\n root,\n options.outDir ?? config.deployment?.outDir ?? DEFAULT_CLIENT_OUT_DIR,\n );\n const frameworkServerOutDir = resolve(root, FRAMEWORK_SERVER_OUT_DIR);\n\n await validateBuildOutputDirectory(\n root,\n outDir,\n join(root, \"public\"),\n frameworkServerOutDir,\n );\n\n await build(\n await createViteConfig({\n define: { \"process.env.NODE_ENV\": JSON.stringify(\"production\") },\n mode: \"production\",\n build: {\n emptyOutDir: true,\n outDir,\n rollupOptions: { input: CLIENT_ENTRY },\n },\n }),\n );\n\n const applicationServer = config.deployment?.server;\n const serverOutDir = applicationServer\n ? resolve(root, applicationServer.outDir ?? DEFAULT_SERVER_OUT_DIR)\n : undefined;\n\n if (applicationServer && serverOutDir) {\n await build(\n await createViteConfig({\n define: { \"process.env.NODE_ENV\": JSON.stringify(\"production\") },\n mode: \"production\",\n build: {\n copyPublicDir: false,\n emptyOutDir: true,\n outDir: serverOutDir,\n rollupOptions: { input: resolve(root, applicationServer.entry) },\n ssr: true,\n },\n }),\n );\n }\n\n if (!config.deployment?.static) return { outDir, serverOutDir };\n\n const staticResult = await buildStaticOutput({\n build,\n config,\n createViteConfig,\n frameworkServerOutDir,\n options,\n outDir,\n root,\n runtime,\n });\n\n return { ...staticResult, outDir, serverOutDir };\n}\n\nasync function buildStaticOutput({\n build,\n config,\n createViteConfig,\n frameworkServerOutDir,\n options,\n outDir,\n root,\n runtime,\n}: {\n build: (config: InlineConfig) => Promise<unknown>;\n config: ResolvedDemiurgeConfig;\n createViteConfig: (overrides: InlineConfig) => Promise<InlineConfig>;\n frameworkServerOutDir: string;\n options: CliOptions;\n outDir: string;\n root: string;\n runtime?: BuildRuntime;\n}) {\n await build(\n await createViteConfig({\n define: { \"process.env.NODE_ENV\": JSON.stringify(\"production\") },\n mode: \"production\",\n build: {\n copyPublicDir: false,\n emptyOutDir: true,\n outDir: frameworkServerOutDir,\n rollupOptions: {\n input: SERVER_ENTRY,\n output: { entryFileNames: \"server-entry.js\" },\n },\n ssr: true,\n },\n }),\n );\n\n const clientManifest = parseClientManifest(\n runtime\n ? await runtime.readText(resolve(outDir, \"demiurge-manifest.json\"))\n : await readFile(resolve(outDir, \"demiurge-manifest.json\"), \"utf8\"),\n );\n const serverEntryUrl = `${\n pathToFileURL(resolve(frameworkServerOutDir, \"server-entry.js\")).href\n }?build=${runtime?.now() ?? Date.now()}`;\n const serverEntry = runtime\n ? await runtime.importModule(serverEntryUrl)\n : await import(serverEntryUrl);\n if (!isRouteImporterRecord(serverEntry.routes)) {\n throw new Error(\"The framework server bundle does not export routes.\");\n }\n\n const manifest = await (runtime?.generate ?? generateStaticOutput)({\n fonts: config.assets?.fonts,\n images: config.assets?.images,\n origin: options.origin ?? config.deployment?.static?.origin,\n outDir,\n root,\n routes: serverEntry.routes,\n ssr: clientManifest,\n staticFileHeaders: config.security?.staticFileHeaders ?? [],\n });\n\n const provider = config.deployment?.static?.provider;\n const deploymentOutDir = provider\n ? await generateVercelStaticOutput({\n deployment: provider,\n manifest,\n outDir,\n projectRoot: root,\n })\n : undefined;\n\n return { deploymentOutDir, manifest };\n}\n\nexport function resolvePreviewOutputDirectory(\n root: string,\n outDir: string | undefined,\n configuredOutDir?: string,\n) {\n return resolve(root, outDir ?? configuredOutDir ?? DEFAULT_CLIENT_OUT_DIR);\n}\n\nexport async function validateBuildOutputDirectory(\n root: string,\n outDir: string,\n publicDir: false | string,\n serverOutDir: string,\n) {\n const pathFromRoot = relative(root, outDir);\n if (\n !pathFromRoot ||\n pathFromRoot === \"..\" ||\n pathFromRoot.startsWith(`..${sep}`) ||\n isAbsolute(pathFromRoot)\n ) {\n throw new Error(\"The static output directory must be inside the Vite root.\");\n }\n\n if (publicDir && pathsOverlap(outDir, publicDir)) {\n throw new Error(\"The static output directory must not overlap the Vite public directory.\");\n }\n\n if (pathsOverlap(outDir, serverOutDir)) {\n throw new Error(\"The static output directory must not overlap the framework server directory.\");\n }\n\n let entries: string[];\n try {\n entries = await readdir(outDir);\n } catch (error) {\n if (isMissingPath(error)) return;\n throw error;\n }\n\n if (\n entries.length &&\n !entries.includes(\"demiurge-manifest.json\") &&\n !entries.includes(\"demiurge-static-manifest.json\")\n ) {\n throw new Error(\n \"The static output directory contains files that a Demiurge build did not create.\",\n );\n }\n}\n\nfunction isRouteImporterRecord(\n value: unknown,\n): value is Record<string, RouteImporter> {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return false;\n }\n\n return Object.values(value).every((load) => typeof load === \"function\");\n}\n\nfunction pathsOverlap(left: string, right: string) {\n const fromLeft = relative(left, right);\n const fromRight = relative(right, left);\n return isSameOrChildPath(fromLeft) || isSameOrChildPath(fromRight);\n}\n\nfunction isSameOrChildPath(pathname: string) {\n return !pathname ||\n (pathname !== \"..\" && !pathname.startsWith(`..${sep}`) &&\n !isAbsolute(pathname));\n}\n\nfunction isMissingPath(error: unknown) {\n return error instanceof Error && \"code\" in error && error.code === \"ENOENT\";\n}\n"],"names":["cliOptionNames","CLIENT_ENTRY","SERVER_ENTRY","DEFAULT_CLIENT_OUT_DIR","DEFAULT_SERVER_OUT_DIR","FRAMEWORK_SERVER_OUT_DIR","parseCliArguments","arguments_","environment","command","options","index","argument","name","inlineValue","value","port","helpText","runDev","config","createServer","server","createDemiurgeViteConfig","runBuild","runtime","root","build","createViteConfig","overrides","outDir","resolve","frameworkServerOutDir","validateBuildOutputDirectory","join","applicationServer","serverOutDir","buildStaticOutput","clientManifest","parseClientManifest","readFile","serverEntryUrl","pathToFileURL","serverEntry","isRouteImporterRecord","manifest","generateStaticOutput","provider","generateVercelStaticOutput","resolvePreviewOutputDirectory","configuredOutDir","publicDir","pathFromRoot","relative","sep","isAbsolute","pathsOverlap","entries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E,cAAc,EAAE,MAAM,SAAS,CAAC;AAI9C,wBAAgB,YAAY,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,EACzD,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,GAC7B,cAAc,CAAC,MAAM,CAAC,CAExB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { defineConfig } from "./define";
|
|
2
|
+
export { CONFIG_FILE_NAME, loadDemiurgeConfig, missingConfigMessage, resolveConfigFile, resolveProjectRoot, } from "./load";
|
|
3
|
+
export type { ConfigModuleLoader, LoadDemiurgeConfigOptions, } from "./load";
|
|
4
|
+
export { createDemiurgeViteConfig as unstable_createDemiurgeViteConfig, toPluginOptions as unstable_toPluginOptions, } from "./vite";
|
|
5
|
+
export { DemiurgeConfigError, validateDemiurgeConfig } from "./validate";
|
|
6
|
+
export type { DemiurgeAssetsConfig, DemiurgeConfig, DemiurgeDeploymentConfig, DemiurgeRenderingConfig, DemiurgeRoutingConfig, DemiurgeSecurityConfig, DemiurgeServerDeploymentConfig, DemiurgeStaticDeploymentConfig, DemiurgeViteExtension, ResolvedDemiurgeConfig, } from "./types";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,QAAQ,CAAC;AAChB,YAAY,EACV,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,wBAAwB,IAAI,iCAAiC,EAC7D,eAAe,IAAI,wBAAwB,GAC5C,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACzE,YAAY,EACV,oBAAoB,EACpB,cAAc,EACd,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,8BAA8B,EAC9B,8BAA8B,EAC9B,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { existsSync as f } from "node:fs";
|
|
2
|
+
import { join as u, resolve as a, dirname as s } from "node:path";
|
|
3
|
+
import { D as r, v as d } from "../chunks/vite-DO70kZA6.js";
|
|
4
|
+
import { c as F, t as M } from "../chunks/vite-DO70kZA6.js";
|
|
5
|
+
function x(e) {
|
|
6
|
+
return e;
|
|
7
|
+
}
|
|
8
|
+
const g = "demiurge.config.ts";
|
|
9
|
+
function l(e = process.cwd()) {
|
|
10
|
+
let n = a(e);
|
|
11
|
+
for (; ; ) {
|
|
12
|
+
if (f(u(n, "package.json"))) return n;
|
|
13
|
+
const o = s(n);
|
|
14
|
+
if (o === n) return a(e);
|
|
15
|
+
n = o;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function m(e) {
|
|
19
|
+
return u(e, g);
|
|
20
|
+
}
|
|
21
|
+
async function y(e = {}) {
|
|
22
|
+
const n = e.root ?? l(), o = m(n);
|
|
23
|
+
if (!f(o))
|
|
24
|
+
throw new r(p(o));
|
|
25
|
+
const c = e.loadModule ?? C;
|
|
26
|
+
let t;
|
|
27
|
+
try {
|
|
28
|
+
t = await c(o);
|
|
29
|
+
} catch (i) {
|
|
30
|
+
throw new r(
|
|
31
|
+
[
|
|
32
|
+
`Demiurge failed to load ${o}.`,
|
|
33
|
+
` cause: ${i instanceof Error ? i.message : String(i)}`
|
|
34
|
+
].join(`
|
|
35
|
+
`),
|
|
36
|
+
{ cause: i }
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
if (t == null)
|
|
40
|
+
throw new r(
|
|
41
|
+
[
|
|
42
|
+
`Demiurge did not find a default export in ${o}.`,
|
|
43
|
+
" The file must export a Demiurge configuration as its default export.",
|
|
44
|
+
" Example: export default defineConfig({ routing: { typedRoutes: true } });"
|
|
45
|
+
].join(`
|
|
46
|
+
`)
|
|
47
|
+
);
|
|
48
|
+
return { ...d(t, o), configFile: o, root: n };
|
|
49
|
+
}
|
|
50
|
+
function p(e) {
|
|
51
|
+
return [
|
|
52
|
+
`Demiurge did not find the configuration file ${e}.`,
|
|
53
|
+
" Every Demiurge command needs this file. There is no default configuration.",
|
|
54
|
+
' Create an application with "npm create demiurge" to generate it.'
|
|
55
|
+
].join(`
|
|
56
|
+
`);
|
|
57
|
+
}
|
|
58
|
+
async function C(e) {
|
|
59
|
+
const { loadConfigFromFile: n } = await import("vite");
|
|
60
|
+
return (await n(
|
|
61
|
+
{ command: "serve", mode: "development" },
|
|
62
|
+
e,
|
|
63
|
+
s(e)
|
|
64
|
+
))?.config;
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
g as CONFIG_FILE_NAME,
|
|
68
|
+
r as DemiurgeConfigError,
|
|
69
|
+
x as defineConfig,
|
|
70
|
+
y as loadDemiurgeConfig,
|
|
71
|
+
p as missingConfigMessage,
|
|
72
|
+
m as resolveConfigFile,
|
|
73
|
+
l as resolveProjectRoot,
|
|
74
|
+
F as unstable_createDemiurgeViteConfig,
|
|
75
|
+
M as unstable_toPluginOptions,
|
|
76
|
+
d as validateDemiurgeConfig
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/config/define.ts","../../src/config/load.ts"],"sourcesContent":["import type { DemiurgeConfig } from \"./types\";\n\n// This builder gives editor completion and type checking to the application\n// configuration file. It returns the value without a change.\nexport function defineConfig<Locale extends string = string>(\n config: DemiurgeConfig<Locale>,\n): DemiurgeConfig<Locale> {\n return config;\n}\n","import { existsSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport type { DemiurgeConfig, ResolvedDemiurgeConfig } from \"./types\";\nimport { DemiurgeConfigError, validateDemiurgeConfig } from \"./validate\";\n\n// The framework accepts one configuration file name at one location. It does\n// not search parent directories and it does not accept another extension.\nexport const CONFIG_FILE_NAME = \"demiurge.config.ts\";\n\nexport type ConfigModuleLoader = (file: string) => Promise<unknown>;\n\nexport type LoadDemiurgeConfigOptions = {\n loadModule?: ConfigModuleLoader;\n root?: string;\n};\n\n// The project root is the directory that holds the package manifest of the\n// application. The framework resolves it from the working directory.\nexport function resolveProjectRoot(from: string = process.cwd()) {\n let directory = resolve(from);\n\n for (;;) {\n if (existsSync(join(directory, \"package.json\"))) return directory;\n const parent = dirname(directory);\n if (parent === directory) return resolve(from);\n directory = parent;\n }\n}\n\nexport function resolveConfigFile(root: string) {\n return join(root, CONFIG_FILE_NAME);\n}\n\nexport async function loadDemiurgeConfig(\n options: LoadDemiurgeConfigOptions = {},\n): Promise<ResolvedDemiurgeConfig> {\n const root = options.root ?? resolveProjectRoot();\n const configFile = resolveConfigFile(root);\n\n if (!existsSync(configFile)) {\n throw new DemiurgeConfigError(missingConfigMessage(configFile));\n }\n\n const loadModule = options.loadModule ?? loadConfigModule;\n let exported: unknown;\n\n try {\n exported = await loadModule(configFile);\n } catch (error) {\n throw new DemiurgeConfigError(\n [\n `Demiurge failed to load ${configFile}.`,\n ` cause: ${error instanceof Error ? error.message : String(error)}`,\n ].join(\"\\n\"),\n { cause: error },\n );\n }\n\n if (exported === undefined || exported === null) {\n throw new DemiurgeConfigError(\n [\n `Demiurge did not find a default export in ${configFile}.`,\n \" The file must export a Demiurge configuration as its default export.\",\n ' Example: export default defineConfig({ routing: { typedRoutes: true } });',\n ].join(\"\\n\"),\n );\n }\n\n const config: DemiurgeConfig = validateDemiurgeConfig(exported, configFile);\n return { ...config, configFile, root };\n}\n\nexport function missingConfigMessage(configFile: string) {\n return [\n `Demiurge did not find the configuration file ${configFile}.`,\n \" Every Demiurge command needs this file. There is no default configuration.\",\n ' Create an application with \"npm create demiurge\" to generate it.',\n ].join(\"\\n\");\n}\n\nasync function loadConfigModule(configFile: string) {\n const { loadConfigFromFile } = await import(\"vite\");\n const loaded = await loadConfigFromFile(\n { command: \"serve\", mode: \"development\" },\n configFile,\n dirname(configFile),\n );\n return loaded?.config;\n}\n"],"names":["defineConfig","config","CONFIG_FILE_NAME","resolveProjectRoot","from","directory","resolve","existsSync","join","parent","dirname","resolveConfigFile","root","loadDemiurgeConfig","options","configFile","DemiurgeConfigError","missingConfigMessage","loadModule","loadConfigModule","exported","error","validateDemiurgeConfig","loadConfigFromFile"],"mappings":";;;;AAIO,SAASA,EACdC,GACwB;AACxB,SAAOA;AACT;ACDO,MAAMC,IAAmB;AAWzB,SAASC,EAAmBC,IAAe,QAAQ,OAAO;AAC/D,MAAIC,IAAYC,EAAQF,CAAI;AAE5B,aAAS;AACP,QAAIG,EAAWC,EAAKH,GAAW,cAAc,CAAC,EAAG,QAAOA;AACxD,UAAMI,IAASC,EAAQL,CAAS;AAChC,QAAII,MAAWJ,EAAW,QAAOC,EAAQF,CAAI;AAC7C,IAAAC,IAAYI;AAAA,EACd;AACF;AAEO,SAASE,EAAkBC,GAAc;AAC9C,SAAOJ,EAAKI,GAAMV,CAAgB;AACpC;AAEA,eAAsBW,EACpBC,IAAqC,IACJ;AACjC,QAAMF,IAAOE,EAAQ,QAAQX,EAAA,GACvBY,IAAaJ,EAAkBC,CAAI;AAEzC,MAAI,CAACL,EAAWQ,CAAU;AACxB,UAAM,IAAIC,EAAoBC,EAAqBF,CAAU,CAAC;AAGhE,QAAMG,IAAaJ,EAAQ,cAAcK;AACzC,MAAIC;AAEJ,MAAI;AACF,IAAAA,IAAW,MAAMF,EAAWH,CAAU;AAAA,EACxC,SAASM,GAAO;AACd,UAAM,IAAIL;AAAA,MACR;AAAA,QACE,2BAA2BD,CAAU;AAAA,QACrC,YAAYM,aAAiB,QAAQA,EAAM,UAAU,OAAOA,CAAK,CAAC;AAAA,MAAA,EAClE,KAAK;AAAA,CAAI;AAAA,MACX,EAAE,OAAOA,EAAA;AAAA,IAAM;AAAA,EAEnB;AAEA,MAA8BD,KAAa;AACzC,UAAM,IAAIJ;AAAA,MACR;AAAA,QACE,6CAA6CD,CAAU;AAAA,QACvD;AAAA,QACA;AAAA,MAAA,EACA,KAAK;AAAA,CAAI;AAAA,IAAA;AAKf,SAAO,EAAE,GADsBO,EAAuBF,GAAUL,CAAU,GACtD,YAAAA,GAAY,MAAAH,EAAA;AAClC;AAEO,SAASK,EAAqBF,GAAoB;AACvD,SAAO;AAAA,IACL,gDAAgDA,CAAU;AAAA,IAC1D;AAAA,IACA;AAAA,EAAA,EACA,KAAK;AAAA,CAAI;AACb;AAEA,eAAeI,EAAiBJ,GAAoB;AAClD,QAAM,EAAE,oBAAAQ,EAAA,IAAuB,MAAM,OAAO,MAAM;AAMlD,UALe,MAAMA;AAAA,IACnB,EAAE,SAAS,SAAS,MAAM,cAAA;AAAA,IAC1BR;AAAA,IACAL,EAAQK,CAAU;AAAA,EAAA,IAEL;AACjB;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ResolvedDemiurgeConfig } from "./types";
|
|
2
|
+
export declare const CONFIG_FILE_NAME = "demiurge.config.ts";
|
|
3
|
+
export type ConfigModuleLoader = (file: string) => Promise<unknown>;
|
|
4
|
+
export type LoadDemiurgeConfigOptions = {
|
|
5
|
+
loadModule?: ConfigModuleLoader;
|
|
6
|
+
root?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function resolveProjectRoot(from?: string): string;
|
|
9
|
+
export declare function resolveConfigFile(root: string): string;
|
|
10
|
+
export declare function loadDemiurgeConfig(options?: LoadDemiurgeConfigOptions): Promise<ResolvedDemiurgeConfig>;
|
|
11
|
+
export declare function missingConfigMessage(configFile: string): string;
|
|
12
|
+
//# sourceMappingURL=load.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../src/config/load.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAKtE,eAAO,MAAM,gBAAgB,uBAAuB,CAAC;AAErD,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpE,MAAM,MAAM,yBAAyB,GAAG;IACtC,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAIF,wBAAgB,kBAAkB,CAAC,IAAI,GAAE,MAAsB,UAS9D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,UAE7C;AAED,wBAAsB,kBAAkB,CACtC,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,sBAAsB,CAAC,CAmCjC;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,UAMtD"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { PluginOption, UserConfig as ViteUserConfig } from "vite";
|
|
2
|
+
import type { FontContribution } from "../platform/fonts";
|
|
3
|
+
import type { ImagePolicy } from "../platform/images";
|
|
4
|
+
import type { LocaleConfiguration } from "../routing";
|
|
5
|
+
import type { EnvSchema } from "../security/env";
|
|
6
|
+
import type { StaticFileHeaderPatternRule, VercelStaticDeployment } from "../static";
|
|
7
|
+
export type DemiurgeRoutingConfig<Locale extends string = string> = {
|
|
8
|
+
locales?: LocaleConfiguration<Locale>;
|
|
9
|
+
routesDir?: string;
|
|
10
|
+
typedRoutes?: boolean | {
|
|
11
|
+
outputFile?: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type DemiurgeRenderingConfig = {
|
|
15
|
+
document?: {
|
|
16
|
+
lang?: string;
|
|
17
|
+
title?: string;
|
|
18
|
+
};
|
|
19
|
+
styles?: false | string;
|
|
20
|
+
};
|
|
21
|
+
export type DemiurgeSecurityConfig = {
|
|
22
|
+
staticFileHeaders?: readonly StaticFileHeaderPatternRule[];
|
|
23
|
+
};
|
|
24
|
+
export type DemiurgeAssetsConfig = {
|
|
25
|
+
fonts?: FontContribution;
|
|
26
|
+
images?: ImagePolicy;
|
|
27
|
+
};
|
|
28
|
+
export type DemiurgeServerDeploymentConfig = {
|
|
29
|
+
entry: string;
|
|
30
|
+
outDir?: string;
|
|
31
|
+
};
|
|
32
|
+
export type DemiurgeStaticDeploymentConfig = {
|
|
33
|
+
origin?: string;
|
|
34
|
+
provider?: VercelStaticDeployment;
|
|
35
|
+
};
|
|
36
|
+
export type DemiurgeDeploymentConfig = {
|
|
37
|
+
outDir?: string;
|
|
38
|
+
server?: DemiurgeServerDeploymentConfig;
|
|
39
|
+
static?: DemiurgeStaticDeploymentConfig;
|
|
40
|
+
};
|
|
41
|
+
export type DemiurgeViteExtension = {
|
|
42
|
+
define?: Record<string, unknown>;
|
|
43
|
+
optimizeDeps?: ViteUserConfig["optimizeDeps"];
|
|
44
|
+
plugins?: PluginOption[];
|
|
45
|
+
resolve?: {
|
|
46
|
+
alias?: NonNullable<ViteUserConfig["resolve"]>["alias"];
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export type DemiurgeConfig<Locale extends string = string> = {
|
|
50
|
+
assets?: DemiurgeAssetsConfig;
|
|
51
|
+
deployment?: DemiurgeDeploymentConfig;
|
|
52
|
+
devtools?: boolean;
|
|
53
|
+
env?: EnvSchema;
|
|
54
|
+
rendering?: DemiurgeRenderingConfig;
|
|
55
|
+
routing?: DemiurgeRoutingConfig<Locale>;
|
|
56
|
+
security?: DemiurgeSecurityConfig;
|
|
57
|
+
vite?: DemiurgeViteExtension;
|
|
58
|
+
unstable_viteConfig?: (config: ViteUserConfig) => ViteUserConfig | Promise<ViteUserConfig>;
|
|
59
|
+
};
|
|
60
|
+
export type ResolvedDemiurgeConfig = DemiurgeConfig & {
|
|
61
|
+
configFile: string;
|
|
62
|
+
root: string;
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
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d,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DemiurgeConfig } from "./types";
|
|
2
|
+
export declare class DemiurgeConfigError extends Error {
|
|
3
|
+
constructor(message: string, options?: {
|
|
4
|
+
cause?: unknown;
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
export declare function validateDemiurgeConfig(value: unknown, configFile: string): DemiurgeConfig;
|
|
8
|
+
export declare function describeValue(value: unknown): string;
|
|
9
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/config/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI3D;AA2BD,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,MAAM,GACjB,cAAc,CAoIhB;AA4HD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,UAW3C"}
|