create-nifra 2.2.0 → 2.4.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/README.md +4 -4
- package/dist/agent-files.d.ts +14 -14
- package/dist/agent-files.js +29 -29
- package/dist/agents.d.ts +4 -4
- package/dist/agents.js +63 -63
- package/dist/auth.d.ts +2 -2
- package/dist/auth.js +8 -8
- package/dist/cli.d.ts +6 -6
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +56 -35
- package/dist/cli.js.map +1 -1
- package/dist/db.d.ts +6 -6
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +138 -41
- package/dist/db.js.map +1 -1
- package/dist/scaffold/features.d.ts +41 -0
- package/dist/scaffold/features.d.ts.map +1 -0
- package/dist/scaffold/features.js +48 -0
- package/dist/scaffold/features.js.map +1 -0
- package/dist/scaffold/frameworks.d.ts +73 -0
- package/dist/scaffold/frameworks.d.ts.map +1 -0
- package/dist/scaffold/frameworks.js +100 -0
- package/dist/scaffold/frameworks.js.map +1 -0
- package/dist/scaffold/site-build.d.ts +60 -0
- package/dist/scaffold/site-build.d.ts.map +1 -0
- package/dist/scaffold/site-build.js +198 -0
- package/dist/scaffold/site-build.js.map +1 -0
- package/dist/scaffold/site-files.d.ts +16 -0
- package/dist/scaffold/site-files.d.ts.map +1 -0
- package/dist/scaffold/site-files.js +112 -0
- package/dist/scaffold/site-files.js.map +1 -0
- package/dist/scaffold/site.d.ts +33 -0
- package/dist/scaffold/site.d.ts.map +1 -0
- package/dist/scaffold/site.js +99 -0
- package/dist/scaffold/site.js.map +1 -0
- package/package.json +4 -3
- package/src/agent-files.ts +29 -29
- package/template/README.md +3 -3
- package/template/nifra.assurance.ts +80 -0
- package/template/package.json +5 -3
- package/template/src/app.ts +10 -11
- package/template/src/routes.ts +13 -0
- package/template-isr/README.md +1 -1
- package/template-isr/backend.ts +11 -15
- package/template-isr/nifra.assurance.ts +81 -0
- package/template-isr/package.json +8 -7
- package/template-isr/page.ts +12 -0
- package/template-isr/routes/_404.tsx +1 -1
- package/template-isr/routes/_layout.tsx +1 -1
- package/template-isr/routes/index.tsx +2 -2
- package/template-isr/server.ts +1 -1
- package/template-isr/worker.ts +2 -2
- package/template-isr/wrangler.toml +2 -2
- package/template-site/Dockerfile +1 -1
- package/template-site/README.md +6 -6
- package/template-site/backend.ts +11 -13
- package/template-site/counter.ts +16 -0
- package/template-site/nifra.assurance.ts +83 -0
- package/template-site/nifra.config.ts +1 -1
- package/template-site/routes/index.tsx +1 -1
- package/template-site/server-node.ts +1 -1
- package/template-site/server-vercel.ts +1 -1
- package/template-site-preact/README.md +7 -7
- package/template-site-preact/nifra.config.ts +1 -1
- package/template-site-preact/routes/index.tsx +1 -1
- package/template-site-solid/README.md +7 -7
- package/template-site-solid/nifra.config.ts +2 -2
- package/template-site-solid/routes/index.tsx +1 -1
- package/template-site-svelte/README.md +7 -7
- package/template-site-svelte/nifra.config.ts +2 -2
- package/template-site-svelte/routes/_layout.svelte +1 -1
- package/template-site-svelte/routes/index.svelte +1 -1
- package/template-site-vue/README.md +7 -7
- package/template-site-vue/nifra.config.ts +2 -2
- package/template-site-vue/routes/_layout.vue +2 -2
- package/template-site-vue/routes/index.vue +3 -3
- package/template-site/build-bun.ts +0 -27
- package/template-site/build-deno.ts +0 -25
- package/template-site/build-node.ts +0 -26
- package/template-site/build-vercel.ts +0 -45
- package/template-site/build.ts +0 -29
- package/template-site/framework.ts +0 -6
- package/template-site/package.json +0 -38
- package/template-site/tsconfig.json +0 -37
- package/template-site-preact/.dockerignore +0 -14
- package/template-site-preact/Dockerfile +0 -20
- package/template-site-preact/_worker.ts +0 -17
- package/template-site-preact/backend.ts +0 -15
- package/template-site-preact/build-bun.ts +0 -27
- package/template-site-preact/build-deno.ts +0 -25
- package/template-site-preact/build-node.ts +0 -26
- package/template-site-preact/build-vercel.ts +0 -45
- package/template-site-preact/build.ts +0 -29
- package/template-site-preact/deno.json +0 -7
- package/template-site-preact/framework.ts +0 -6
- package/template-site-preact/gitignore +0 -16
- package/template-site-preact/package.json +0 -35
- package/template-site-preact/server-bun.ts +0 -35
- package/template-site-preact/server-deno.ts +0 -38
- package/template-site-preact/server-node.ts +0 -40
- package/template-site-preact/server-vercel.ts +0 -17
- package/template-site-preact/tsconfig.json +0 -38
- package/template-site-preact/wrangler.toml +0 -4
- package/template-site-solid/.dockerignore +0 -14
- package/template-site-solid/Dockerfile +0 -20
- package/template-site-solid/_worker.ts +0 -17
- package/template-site-solid/backend.ts +0 -15
- package/template-site-solid/build-bun.ts +0 -33
- package/template-site-solid/build-deno.ts +0 -32
- package/template-site-solid/build-node.ts +0 -33
- package/template-site-solid/build-vercel.ts +0 -47
- package/template-site-solid/build.ts +0 -36
- package/template-site-solid/deno.json +0 -7
- package/template-site-solid/framework.ts +0 -6
- package/template-site-solid/gitignore +0 -16
- package/template-site-solid/package.json +0 -35
- package/template-site-solid/server-bun.ts +0 -35
- package/template-site-solid/server-deno.ts +0 -38
- package/template-site-solid/server-node.ts +0 -40
- package/template-site-solid/server-vercel.ts +0 -17
- package/template-site-solid/tsconfig.json +0 -38
- package/template-site-solid/wrangler.toml +0 -4
- package/template-site-svelte/.dockerignore +0 -14
- package/template-site-svelte/Dockerfile +0 -20
- package/template-site-svelte/_worker.ts +0 -17
- package/template-site-svelte/backend.ts +0 -15
- package/template-site-svelte/build-bun.ts +0 -32
- package/template-site-svelte/build-deno.ts +0 -31
- package/template-site-svelte/build-node.ts +0 -32
- package/template-site-svelte/build-vercel.ts +0 -46
- package/template-site-svelte/build.ts +0 -35
- package/template-site-svelte/deno.json +0 -7
- package/template-site-svelte/framework.ts +0 -6
- package/template-site-svelte/gitignore +0 -16
- package/template-site-svelte/package.json +0 -35
- package/template-site-svelte/server-bun.ts +0 -35
- package/template-site-svelte/server-deno.ts +0 -38
- package/template-site-svelte/server-node.ts +0 -40
- package/template-site-svelte/server-vercel.ts +0 -17
- package/template-site-svelte/tsconfig.json +0 -37
- package/template-site-svelte/wrangler.toml +0 -4
- package/template-site-vue/.dockerignore +0 -14
- package/template-site-vue/Dockerfile +0 -20
- package/template-site-vue/_worker.ts +0 -17
- package/template-site-vue/backend.ts +0 -15
- package/template-site-vue/build-bun.ts +0 -37
- package/template-site-vue/build-deno.ts +0 -36
- package/template-site-vue/build-node.ts +0 -37
- package/template-site-vue/build-vercel.ts +0 -54
- package/template-site-vue/build.ts +0 -40
- package/template-site-vue/deno.json +0 -7
- package/template-site-vue/framework.ts +0 -6
- package/template-site-vue/gitignore +0 -16
- package/template-site-vue/package.json +0 -36
- package/template-site-vue/server-bun.ts +0 -35
- package/template-site-vue/server-deno.ts +0 -38
- package/template-site-vue/server-node.ts +0 -40
- package/template-site-vue/server-vercel.ts +0 -17
- package/template-site-vue/tsconfig.json +0 -37
- package/template-site-vue/wrangler.toml +0 -4
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a frontend framework contributes to a site scaffold.
|
|
3
|
+
*
|
|
4
|
+
* The five site templates were five directories of 26 files each, and 13 of those 26 were
|
|
5
|
+
* byte-identical in all five - the Dockerfile, every server entry, the worker, the assurance config.
|
|
6
|
+
* Editing the runtime story meant editing it five times and hoping. This session made the same
|
|
7
|
+
* one-line `package.json` edit in eight files, which is the whole argument.
|
|
8
|
+
*
|
|
9
|
+
* So the runtime knowledge lives once (see `site.ts`), and a framework contributes only what is
|
|
10
|
+
* genuinely its own: an adapter, a bundler plugin, the resolve conditions and defines its compiler
|
|
11
|
+
* needs, and its dependency set. The prose a framework needs to explain ITSELF - why Solid wants a
|
|
12
|
+
* `"solid"` resolve condition, what `@preact/preset-vite` is - stays in a real file next to it. That
|
|
13
|
+
* is the line: mechanical differences are modelled, explanations are written.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* The `@nifrajs/*` range a scaffolded site installs.
|
|
17
|
+
*
|
|
18
|
+
* One constant, because it used to be a regex sweep over eight `package.json` files in the release
|
|
19
|
+
* script with nothing checking the result - and the script's own comment warns that a missed bump
|
|
20
|
+
* ships templates installing the PREVIOUS release. `scaffold-version.test.ts` now fails when this
|
|
21
|
+
* drifts from what core is publishing, so the footgun is a red test rather than a silent regression.
|
|
22
|
+
*/
|
|
23
|
+
export const NIFRA_DEP_RANGE = "^2.4.0";
|
|
24
|
+
/**
|
|
25
|
+
* React is first because it is the default (`--framework` omitted scaffolds it), and because the
|
|
26
|
+
* other four are most easily read as deltas from it.
|
|
27
|
+
*/
|
|
28
|
+
export const FRAMEWORK_SPECS = {
|
|
29
|
+
react: {
|
|
30
|
+
id: "react",
|
|
31
|
+
adapter: "reactAdapter",
|
|
32
|
+
package: "@nifrajs/web-react",
|
|
33
|
+
runtimeDependencies: { react: "^19.0.0", "react-dom": "^19.0.0" },
|
|
34
|
+
devDependencies: {
|
|
35
|
+
"@types/react": "^19.0.0",
|
|
36
|
+
"@types/react-dom": "^19.0.0",
|
|
37
|
+
"@vitejs/plugin-react": "^4.3.0",
|
|
38
|
+
},
|
|
39
|
+
typescript: { jsx: "react-jsx", types: ["react", "react-dom"] },
|
|
40
|
+
},
|
|
41
|
+
preact: {
|
|
42
|
+
id: "preact",
|
|
43
|
+
adapter: "preactAdapter",
|
|
44
|
+
package: "@nifrajs/web-preact",
|
|
45
|
+
runtimeDependencies: { preact: "^10.25.0" },
|
|
46
|
+
devDependencies: { "@preact/preset-vite": "^2.9.0" },
|
|
47
|
+
typescript: { jsx: "react-jsx", jsxImportSource: "preact" },
|
|
48
|
+
},
|
|
49
|
+
solid: {
|
|
50
|
+
id: "solid",
|
|
51
|
+
adapter: "solidAdapter",
|
|
52
|
+
package: "@nifrajs/web-solid",
|
|
53
|
+
runtimeDependencies: { "solid-js": "^1.9.0" },
|
|
54
|
+
devDependencies: { "vite-plugin-solid": "^2.10.0" },
|
|
55
|
+
typescript: { jsx: "preserve", jsxImportSource: "solid-js" },
|
|
56
|
+
bunPlugin: { specifier: "@nifrajs/web-solid", name: "solidBunPlugin" },
|
|
57
|
+
// Solid publishes a `solid` export condition that routes `solid-js` to its JSX source; without it
|
|
58
|
+
// the bundler takes the pre-compiled build and hydration has nothing to attach to.
|
|
59
|
+
conditions: { client: ["solid"], ssr: ["solid"] },
|
|
60
|
+
},
|
|
61
|
+
svelte: {
|
|
62
|
+
id: "svelte",
|
|
63
|
+
adapter: "svelteAdapter",
|
|
64
|
+
package: "@nifrajs/web-svelte",
|
|
65
|
+
runtimeDependencies: { svelte: "^5.3.0" },
|
|
66
|
+
devDependencies: { "@sveltejs/vite-plugin-svelte": "^5.0.0" },
|
|
67
|
+
typescript: { types: ["svelte"], includeTsx: false },
|
|
68
|
+
bunPlugin: { specifier: "@nifrajs/web-svelte/plugin", name: "svelteBunPlugin" },
|
|
69
|
+
},
|
|
70
|
+
vue: {
|
|
71
|
+
id: "vue",
|
|
72
|
+
adapter: "vueAdapter",
|
|
73
|
+
package: "@nifrajs/web-vue",
|
|
74
|
+
runtimeDependencies: { vue: "^3.5.0" },
|
|
75
|
+
devDependencies: { "@vitejs/plugin-vue": "^5.2.0", "@vue/compiler-sfc": "^3.5.0" },
|
|
76
|
+
typescript: { jsx: "preserve" },
|
|
77
|
+
bunPlugin: {
|
|
78
|
+
specifier: "@nifrajs/web-vue/plugin",
|
|
79
|
+
name: "vueBunPlugin",
|
|
80
|
+
note: { dom: " // compile .vue SFCs → client bundle", ssr: " // compile .vue SFCs → SSR" },
|
|
81
|
+
},
|
|
82
|
+
// Vue reads these at build time to drop dev-only branches; leaving them undefined ships the
|
|
83
|
+
// development runtime and warns about it on every boot.
|
|
84
|
+
defineNote: '// Vue feature flags: silence "feature flag not explicitly defined" warnings + trim dev-only code.',
|
|
85
|
+
define: {
|
|
86
|
+
__VUE_OPTIONS_API__: '"true"',
|
|
87
|
+
__VUE_PROD_DEVTOOLS__: '"false"',
|
|
88
|
+
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: '"false"',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
export const FRAMEWORK_IDS = Object.keys(FRAMEWORK_SPECS);
|
|
93
|
+
export function frameworkSpec(id) {
|
|
94
|
+
const spec = FRAMEWORK_SPECS[id];
|
|
95
|
+
if (spec === undefined) {
|
|
96
|
+
throw new Error(`unknown framework "${id}". options: ${FRAMEWORK_IDS.join(", ")}`);
|
|
97
|
+
}
|
|
98
|
+
return spec;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=frameworks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frameworks.js","sourceRoot":"","sources":["../../src/scaffold/frameworks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAwCH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA;AAEvC;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAA4C;IACtE,KAAK,EAAE;QACL,EAAE,EAAE,OAAO;QACX,OAAO,EAAE,cAAc;QACvB,OAAO,EAAE,oBAAoB;QAC7B,mBAAmB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE;QACjE,eAAe,EAAE;YACf,cAAc,EAAE,SAAS;YACzB,kBAAkB,EAAE,SAAS;YAC7B,sBAAsB,EAAE,QAAQ;SACjC;QACD,UAAU,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,EAAE;KAChE;IACD,MAAM,EAAE;QACN,EAAE,EAAE,QAAQ;QACZ,OAAO,EAAE,eAAe;QACxB,OAAO,EAAE,qBAAqB;QAC9B,mBAAmB,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;QAC3C,eAAe,EAAE,EAAE,qBAAqB,EAAE,QAAQ,EAAE;QACpD,UAAU,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE;KAC5D;IACD,KAAK,EAAE;QACL,EAAE,EAAE,OAAO;QACX,OAAO,EAAE,cAA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QACxD,UAAU,EACR,oGAAoG;QACtG,MAAM,EAAE;YACN,mBAAmB,EAAE,QAAQ;YAC7B,qBAAqB,EAAE,SAAS;YAChC,uCAAuC,EAAE,SAAS;SACnD;KACF;CACF,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;AAEzD,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,MAAM,IAAI,GAAG,eAAe,CAAC,EAAE,CAAC,CAAA;IAChC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,sBAAsB,EAAE,eAAe,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACpF,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The five build entries a site scaffold ships, emitted from one shape.
|
|
3
|
+
*
|
|
4
|
+
* These were 25 files - five deploy targets copied across five framework directories - and the
|
|
5
|
+
* difference between any two of them is mechanical: which runtime it targets, and which compiler
|
|
6
|
+
* plugin, resolve conditions and defines the framework needs. Nothing else. So the target owns its
|
|
7
|
+
* own prose (what it emits, how to run it) and the framework contributes its injections, and the 25
|
|
8
|
+
* files come out of one function.
|
|
9
|
+
*
|
|
10
|
+
* The emitted text is asserted byte-for-byte against the templates that used to be checked in, so
|
|
11
|
+
* this is a refactor whose correctness is decided by a test rather than by reading.
|
|
12
|
+
*/
|
|
13
|
+
import type { FrameworkSpec } from "./frameworks.js";
|
|
14
|
+
/**
|
|
15
|
+
* Where the framework's own resolve conditions sit inside a target's server list.
|
|
16
|
+
*
|
|
17
|
+
* The edge targets end theirs with `browser` (the worker has no Node builtins, so packages must be
|
|
18
|
+
* asked for their browser build); Bun and Node do not. The framework's conditions go in the middle,
|
|
19
|
+
* which is the order every checked-in template used.
|
|
20
|
+
*/
|
|
21
|
+
export interface ServerConditionSlots {
|
|
22
|
+
readonly before: readonly string[];
|
|
23
|
+
readonly after: readonly string[];
|
|
24
|
+
}
|
|
25
|
+
export interface BuildTarget {
|
|
26
|
+
/** File name, e.g. `build-bun.ts`. */
|
|
27
|
+
readonly file: string;
|
|
28
|
+
/** Leading comment block, without the trailing newline. */
|
|
29
|
+
readonly header: string;
|
|
30
|
+
/**
|
|
31
|
+
* Frameworks whose header says something extra here - what their plugin does, or how to run the
|
|
32
|
+
* output once their compiler is in the picture.
|
|
33
|
+
*
|
|
34
|
+
* These are the one genuinely non-mechanical part of a build entry, and they are the reason this
|
|
35
|
+
* table exists rather than a pure `{framework, runtime}` function: the prose a framework needs to
|
|
36
|
+
* explain itself is written, not derived. Keeping them beside the target they belong to is the
|
|
37
|
+
* closest thing to having them in the file without having five copies of the file.
|
|
38
|
+
*/
|
|
39
|
+
readonly headerOverrides?: Readonly<Record<string, string>>;
|
|
40
|
+
/** Runtime conditions this target's SERVER build resolves with. */
|
|
41
|
+
readonly serverConditions: ServerConditionSlots;
|
|
42
|
+
/** Extra `node:fs` named imports beyond `cpSync, mkdirSync, rmSync`. */
|
|
43
|
+
readonly extraFsImports?: readonly string[];
|
|
44
|
+
/** Lines between the imports and the first build call, `dir` already declared. */
|
|
45
|
+
readonly setup: string;
|
|
46
|
+
/** Where `buildClient` writes assets, as a template expression. */
|
|
47
|
+
readonly clientOutDir: string;
|
|
48
|
+
/** The server entry this target boots from. */
|
|
49
|
+
readonly serverEntry: string;
|
|
50
|
+
/** Scratch directory for the server build. */
|
|
51
|
+
readonly serverOutDir: string;
|
|
52
|
+
/** `target:` line for `buildServer`, or empty for the default (workerd). */
|
|
53
|
+
readonly serverTarget: string;
|
|
54
|
+
/** Everything after the `buildServer` call. */
|
|
55
|
+
readonly tail: string;
|
|
56
|
+
}
|
|
57
|
+
export declare const BUILD_TARGETS: readonly BuildTarget[];
|
|
58
|
+
/** Emit one target's build entry for one framework. */
|
|
59
|
+
export declare function renderBuildFile(target: BuildTarget, framework: Framework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vD,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,GAAG,MAAM,CAsBrF"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
const NODE_ENV_DEFINE = `"process.env.NODE_ENV": '"production"'`;
|
|
2
|
+
/**
|
|
3
|
+
* A framework with no compiler plugin keeps the define inline in the client call, exactly as the
|
|
4
|
+
* React and Preact templates had it: nothing is shared, so hoisting it would name a constant used
|
|
5
|
+
* once. A framework WITH a plugin needs the same defines in both calls, so it hoists.
|
|
6
|
+
*/
|
|
7
|
+
function injectionsFor(framework, target) {
|
|
8
|
+
const extraDefines = Object.entries(framework.define ?? {}).map(([k, v]) => `${k}: ${v}`);
|
|
9
|
+
const hoist = framework.bunPlugin !== undefined;
|
|
10
|
+
const defineEntries = [NODE_ENV_DEFINE, ...extraDefines];
|
|
11
|
+
const defineLiteral = defineEntries.length === 1
|
|
12
|
+
? `{ ${defineEntries[0]} }`
|
|
13
|
+
: `{\n${defineEntries.map((e) => ` ${e},`).join("\n")}\n}`;
|
|
14
|
+
const plugin = framework.bunPlugin;
|
|
15
|
+
const call = (mode) => {
|
|
16
|
+
if (plugin === undefined)
|
|
17
|
+
return "";
|
|
18
|
+
return ` plugins: [${plugin.name}("${mode}")],${plugin.note?.[mode] ?? ""}\n`;
|
|
19
|
+
};
|
|
20
|
+
const list = (values) => ` conditions: [${values.map((c) => `"${c}"`).join(", ")}],\n`;
|
|
21
|
+
// The client call always names its conditions (`bun`, then anything the framework adds, then
|
|
22
|
+
// `browser`). The server call names them ONLY when the framework contributes one - otherwise the
|
|
23
|
+
// build's own default is right and spelling it out would be noise.
|
|
24
|
+
const clientConditions = (extra) => list(["bun", ...(extra ?? []), "browser"]);
|
|
25
|
+
const serverConditions = (extra) => extra === undefined || extra.length === 0
|
|
26
|
+
? ""
|
|
27
|
+
: list([...target.serverConditions.before, ...extra, ...target.serverConditions.after]);
|
|
28
|
+
return {
|
|
29
|
+
pluginImport: plugin === undefined ? "" : `import { ${plugin.name} } from "${plugin.specifier}"\n`,
|
|
30
|
+
defineConst: hoist
|
|
31
|
+
? `${framework.defineNote === undefined ? "" : `${framework.defineNote}\n`}const define = ${defineLiteral}\n`
|
|
32
|
+
: "",
|
|
33
|
+
clientPlugins: call("dom"),
|
|
34
|
+
clientConditions: clientConditions(framework.conditions?.client),
|
|
35
|
+
clientDefine: hoist ? " define,\n" : ` define: ${defineLiteral},\n`,
|
|
36
|
+
serverPlugins: call("ssr"),
|
|
37
|
+
serverConditions: serverConditions(framework.conditions?.ssr),
|
|
38
|
+
serverDefine: hoist ? " define,\n" : "",
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export const BUILD_TARGETS = [
|
|
42
|
+
{
|
|
43
|
+
file: "build.ts",
|
|
44
|
+
header: "// Build for Cloudflare Pages → dist/ (_worker.js + _routes.json + client assets). `bun run build`.",
|
|
45
|
+
headerOverrides: {
|
|
46
|
+
solid: `// Build for Cloudflare Pages → dist/ (_worker.js + _routes.json + client assets). \`bun run build\`.
|
|
47
|
+
// Solid: solidBunPlugin("dom") for the client, ("ssr") for the server + the \`solid\` export condition.`,
|
|
48
|
+
svelte: `// Build for Cloudflare Pages → dist/ (_worker.js + _routes.json + client assets). \`bun run build\`.
|
|
49
|
+
// Svelte: svelteBunPlugin("dom") compiles .svelte for the client, ("ssr") for the server bundle.`,
|
|
50
|
+
},
|
|
51
|
+
serverConditions: { before: ["workerd", "edge-light"], after: ["browser"] },
|
|
52
|
+
extraFsImports: ["writeFileSync"],
|
|
53
|
+
setup: "const dist = `${dir}/dist`\n",
|
|
54
|
+
clientOutDir: "`${dist}/assets`",
|
|
55
|
+
serverEntry: "`${dir}/_worker.ts`",
|
|
56
|
+
serverOutDir: "`${dir}/.build`",
|
|
57
|
+
serverTarget: "",
|
|
58
|
+
tail: `cpSync(worker, \`\${dist}/_worker.js\`)
|
|
59
|
+
rmSync(\`\${dir}/.build\`, { recursive: true, force: true })
|
|
60
|
+
writeFileSync(
|
|
61
|
+
\`\${dist}/_routes.json\`,
|
|
62
|
+
\`\${JSON.stringify({ version: 1, include: ["/*"], exclude: ["/assets/*"] }, null, 2)}\\n\`,
|
|
63
|
+
)
|
|
64
|
+
console.log("Cloudflare Pages output → dist (deploy: wrangler pages deploy dist)")
|
|
65
|
+
`,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
file: "build-bun.ts",
|
|
69
|
+
header: `// Build for Bun (nifra's flagship runtime) → dist-bun/ (server-bun.js + client assets).
|
|
70
|
+
// \`bun run build:bun\`. Run: \`bun dist-bun/server-bun.js\`.`,
|
|
71
|
+
serverConditions: { before: ["bun"], after: [] },
|
|
72
|
+
setup: "const dist = `${dir}/dist-bun`\n",
|
|
73
|
+
clientOutDir: "`${dist}/assets`",
|
|
74
|
+
serverEntry: "`${dir}/server-bun.ts`",
|
|
75
|
+
serverOutDir: "`${dir}/.build-bun`",
|
|
76
|
+
serverTarget: ' target: "bun",\n',
|
|
77
|
+
tail: `cpSync(worker, \`\${dist}/server-bun.js\`)
|
|
78
|
+
rmSync(\`\${dir}/.build-bun\`, { recursive: true, force: true })
|
|
79
|
+
console.log("Bun output → dist-bun (run: bun dist-bun/server-bun.js)")
|
|
80
|
+
`,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
file: "build-node.ts",
|
|
84
|
+
header: "// Build for Node → dist-node/ (server-node.js + client assets). `bun run build:node`.",
|
|
85
|
+
headerOverrides: {
|
|
86
|
+
solid: `// Build for Node → dist-node/ (server-node.js + client assets). \`bun run build:node\`.
|
|
87
|
+
// Run: \`node dist-node/server-node.js\` (or the Dockerfile). \`node\`+\`solid\` → solid-js/web's server build.`,
|
|
88
|
+
svelte: `// Build for Node → dist-node/ (server-node.js + client assets). \`bun run build:node\`.
|
|
89
|
+
// Run: \`node dist-node/server-node.js\` (or the Dockerfile).`,
|
|
90
|
+
vue: `// Build for Node → dist-node/ (server-node.js + client assets). \`bun run build:node\`.
|
|
91
|
+
// Run: \`node dist-node/server-node.js\` (or the Dockerfile).`,
|
|
92
|
+
},
|
|
93
|
+
serverConditions: { before: ["node"], after: [] },
|
|
94
|
+
setup: "const dist = `${dir}/dist-node`\n",
|
|
95
|
+
clientOutDir: "`${dist}/assets`",
|
|
96
|
+
serverEntry: "`${dir}/server-node.ts`",
|
|
97
|
+
serverOutDir: "`${dir}/.build-node`",
|
|
98
|
+
serverTarget: ' target: "node",\n',
|
|
99
|
+
tail: `cpSync(worker, \`\${dist}/server-node.js\`)
|
|
100
|
+
rmSync(\`\${dir}/.build-node\`, { recursive: true, force: true })
|
|
101
|
+
console.log("Node output → dist-node (run: node dist-node/server-node.js)")
|
|
102
|
+
`,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
file: "build-deno.ts",
|
|
106
|
+
header: "// Build for Deno → dist-deno/ (server-deno.js + client assets). `bun run build:deno`.",
|
|
107
|
+
headerOverrides: {
|
|
108
|
+
solid: `// Build for Deno → dist-deno/ (server-deno.js + client assets). \`bun run build:deno\`.
|
|
109
|
+
// Run: \`deno task start\` (or deployctl). Deno runs the edge bundle (workerd/edge-light + solid).`,
|
|
110
|
+
svelte: `// Build for Deno → dist-deno/ (server-deno.js + client assets). \`bun run build:deno\`.
|
|
111
|
+
// Run: \`deno task start\` (or deployctl).`,
|
|
112
|
+
vue: `// Build for Deno → dist-deno/ (server-deno.js + client assets). \`bun run build:deno\`.
|
|
113
|
+
// Run: \`deno task start\` (or deployctl for Deno Deploy).`,
|
|
114
|
+
},
|
|
115
|
+
serverConditions: { before: ["workerd", "edge-light"], after: ["browser"] },
|
|
116
|
+
setup: "const dist = `${dir}/dist-deno`\n",
|
|
117
|
+
clientOutDir: "`${dist}/assets`",
|
|
118
|
+
serverEntry: "`${dir}/server-deno.ts`",
|
|
119
|
+
serverOutDir: "`${dir}/.build-deno`",
|
|
120
|
+
serverTarget: "",
|
|
121
|
+
tail: `cpSync(worker, \`\${dist}/server-deno.js\`)
|
|
122
|
+
rmSync(\`\${dir}/.build-deno\`, { recursive: true, force: true })
|
|
123
|
+
console.log("Deno output → dist-deno (run: deno run -A dist-deno/server-deno.js)")
|
|
124
|
+
`,
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
file: "build-vercel.ts",
|
|
128
|
+
header: `// Build for Vercel, emitting Vercel's Build Output API v3 at .vercel/output/ so it deploys with no
|
|
129
|
+
// framework preset: \`vercel deploy --prebuilt\`. Layout:
|
|
130
|
+
// .vercel/output/config.json - serve static files, else SSR via the function
|
|
131
|
+
// .vercel/output/static/assets/<client bundle> - Vercel's CDN serves these directly
|
|
132
|
+
// .vercel/output/functions/index.func/index.js - the Edge SSR function (+ .vc-config.json)`,
|
|
133
|
+
serverConditions: { before: ["workerd", "edge-light"], after: ["browser"] },
|
|
134
|
+
extraFsImports: ["writeFileSync"],
|
|
135
|
+
setup: `const out = \`\${dir}/.vercel/output\`
|
|
136
|
+
const fn = \`\${out}/functions/index.func\`
|
|
137
|
+
`,
|
|
138
|
+
clientOutDir: "`${out}/static/assets`",
|
|
139
|
+
serverEntry: "`${dir}/server-vercel.ts`",
|
|
140
|
+
serverOutDir: "`${dir}/.build-vercel`",
|
|
141
|
+
serverTarget: "",
|
|
142
|
+
tail: `cpSync(worker, \`\${fn}/index.js\`)
|
|
143
|
+
rmSync(\`\${dir}/.build-vercel\`, { recursive: true, force: true })
|
|
144
|
+
|
|
145
|
+
// Build Output API v3: serve real files first (\`handle: filesystem\` → /assets/*), then SSR the rest.
|
|
146
|
+
writeFileSync(
|
|
147
|
+
\`\${fn}/.vc-config.json\`,
|
|
148
|
+
\`\${JSON.stringify({ runtime: "edge", entrypoint: "index.js" }, null, 2)}\\n\`,
|
|
149
|
+
)
|
|
150
|
+
writeFileSync(
|
|
151
|
+
\`\${out}/config.json\`,
|
|
152
|
+
\`\${JSON.stringify(
|
|
153
|
+
{ version: 3, routes: [{ handle: "filesystem" }, { src: "/(.*)", dest: "/index" }] },
|
|
154
|
+
null,
|
|
155
|
+
2,
|
|
156
|
+
)}\\n\`,
|
|
157
|
+
)
|
|
158
|
+
console.log("Vercel output → .vercel/output (deploy: vercel deploy --prebuilt)")
|
|
159
|
+
`,
|
|
160
|
+
},
|
|
161
|
+
];
|
|
162
|
+
/** The `rm`/`mkdir` preamble differs only for Vercel, which builds two trees rather than one. */
|
|
163
|
+
function preambleFor(target) {
|
|
164
|
+
if (target.file !== "build-vercel.ts") {
|
|
165
|
+
return `rmSync(dist, { recursive: true, force: true })
|
|
166
|
+
mkdirSync(\`\${dist}/assets\`, { recursive: true })
|
|
167
|
+
`;
|
|
168
|
+
}
|
|
169
|
+
return `rmSync(\`\${dir}/.vercel\`, { recursive: true, force: true })
|
|
170
|
+
mkdirSync(\`\${out}/static/assets\`, { recursive: true })
|
|
171
|
+
mkdirSync(fn, { recursive: true })
|
|
172
|
+
`;
|
|
173
|
+
}
|
|
174
|
+
/** Emit one target's build entry for one framework. */
|
|
175
|
+
export function renderBuildFile(target, framework) {
|
|
176
|
+
const injections = injectionsFor(framework, target);
|
|
177
|
+
const header = target.headerOverrides?.[framework.id] ?? target.header;
|
|
178
|
+
const fsImports = ["cpSync", "mkdirSync", "rmSync", ...(target.extraFsImports ?? [])].sort();
|
|
179
|
+
return `${header}
|
|
180
|
+
import { ${fsImports.join(", ")} } from "node:fs"
|
|
181
|
+
import { buildClient, buildServer } from "@nifrajs/web/build"
|
|
182
|
+
${injections.pluginImport}
|
|
183
|
+
const dir = import.meta.dir
|
|
184
|
+
${target.setup}${injections.defineConst}${preambleFor(target)}
|
|
185
|
+
const client = await buildClient({
|
|
186
|
+
routesDir: \`\${dir}/routes\`,
|
|
187
|
+
outDir: ${target.clientOutDir},
|
|
188
|
+
clientModule: "${framework.package}/client",
|
|
189
|
+
${injections.clientPlugins}${injections.clientConditions}${injections.clientDefine}})
|
|
190
|
+
const { worker } = await buildServer({
|
|
191
|
+
routesDir: \`\${dir}/routes\`,
|
|
192
|
+
serverEntry: ${target.serverEntry},
|
|
193
|
+
outDir: ${target.serverOutDir},
|
|
194
|
+
${target.serverTarget} clientEntry: client.entry,
|
|
195
|
+
${injections.serverPlugins}${injections.serverConditions}${injections.serverDefine}})
|
|
196
|
+
${target.tail}`;
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=site-build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-build.js","sourceRoot":"","sources":["../../src/scaffold/site-build.ts"],"names":[],"mappings":"AAgBA,MAAM,eAAe,GAAG,wCAAwC,CAAA;AAgBhE;;;;GAIG;AACH,SAAS,aAAa,CAAC,SAAwB,EAAE,MAAmB;IAClE,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACzF,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,KAAK,SAAS,CAAA;IAC/C,MAAM,aAAa,GAAG,CAAC,eAAe,EAAE,GAAG,YAAY,CAAC,CAAA;IACxD,MAAM,aAAa,GACjB,aAAa,CAAC,MAAM,KAAK,CAAC;QACxB,CAAC,CAAC,KAAK,aAAa,CAAC,CAAC,CAAC,IAAI;QAC3B,CAAC,CAAC,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAA;IAE/D,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAA;IAClC,MAAM,IAAI,GAAG,CAAC,IAAmB,EAAU,EAAE;QAC3C,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,EAAE,CAAA;QACnC,OAAO,eAAe,MAAM,CAAC,IAAI,KAAK,IAAI,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAA;I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AC3E,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;IACnD,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,MAAM,CAAA;IACtE,MAAM,SAAS,GAAG,CAAC,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IAC5F,OAAO,GAAG,MAAM;WACP,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;;EAE7B,UAAU,CAAC,YAAY;;EAEvB,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC;;;YAGjD,MAAM,CAAC,YAAY;mBACZ,SAAS,CAAC,OAAO;EAClC,UAAU,CAAC,aAAa,GAAG,UAAU,CAAC,gBAAgB,GAAG,UAAU,CAAC,YAAY;;;iBAGjE,MAAM,CAAC,WAAW;YACvB,MAAM,CAAC,YAAY;EAC7B,MAAM,CAAC,YAAY;EACnB,UAAU,CAAC,aAAa,GAAG,UAAU,CAAC,gBAAgB,GAAG,UAAU,CAAC,YAAY;EAChF,MAAM,CAAC,IAAI,EAAE,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rest of a site scaffold's mechanical files: the adapter re-export, the manifest, the tsconfig.
|
|
3
|
+
*
|
|
4
|
+
* Same argument as `site-build.ts`. These three were five copies each whose only real difference was
|
|
5
|
+
* which framework they name, and keeping five copies is how `.vercel` came to be excluded from four
|
|
6
|
+
* tsconfigs and not the fifth.
|
|
7
|
+
*/
|
|
8
|
+
import { type FrameworkSpec } from "./frameworks.js";
|
|
9
|
+
/**
|
|
10
|
+
* `framework.ts` - the one file every server entry imports the adapter from, which is what keeps the
|
|
11
|
+
* entries themselves framework-agnostic and therefore shareable.
|
|
12
|
+
*/
|
|
13
|
+
export declare function renderFrameworkModule(framework: FrameworkSpec): string;
|
|
14
|
+
export declare function renderPackageJson(framework: FrameworkSpec): string;
|
|
15
|
+
export declare function renderTsconfig(framework: FrameworkSpec): string;
|
|
16
|
+
//# sourceMappingURL=site-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-files.d.ts","sourceRoot":"","sources":["../../src/scaffold/site-files.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,iBAAiB,CAAA;AAKrE;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,aAAa,GAAG,MAAM,CAQtE;AAqBD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,aAAa,GAAG,MAAM,CAoBlE;AAgCD,wBAAgB,cAAc,CAAC,SAAS,EAAE,aAAa,GAAG,MAAM,CAoB/D"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rest of a site scaffold's mechanical files: the adapter re-export, the manifest, the tsconfig.
|
|
3
|
+
*
|
|
4
|
+
* Same argument as `site-build.ts`. These three were five copies each whose only real difference was
|
|
5
|
+
* which framework they name, and keeping five copies is how `.vercel` came to be excluded from four
|
|
6
|
+
* tsconfigs and not the fifth.
|
|
7
|
+
*/
|
|
8
|
+
import { NIFRA_DEP_RANGE } from "./frameworks.js";
|
|
9
|
+
/** JSON as these files are written: two-space indent, trailing newline. */
|
|
10
|
+
const json = (value) => `${JSON.stringify(value, null, 2)}\n`;
|
|
11
|
+
/**
|
|
12
|
+
* `framework.ts` - the one file every server entry imports the adapter from, which is what keeps the
|
|
13
|
+
* entries themselves framework-agnostic and therefore shareable.
|
|
14
|
+
*/
|
|
15
|
+
export function renderFrameworkModule(framework) {
|
|
16
|
+
return `// The frontend adapter for this app. \`create-nifra --framework <react|preact|vue|solid|svelte>\` swaps
|
|
17
|
+
// this one line (and the routes + build config); every server entry imports the adapter from here, so
|
|
18
|
+
// they stay framework-agnostic.
|
|
19
|
+
import { ${framework.adapter} } from "${framework.package}"
|
|
20
|
+
|
|
21
|
+
export const adapter = ${framework.adapter}
|
|
22
|
+
`;
|
|
23
|
+
}
|
|
24
|
+
/** The scripts every site scaffold ships, identical across frameworks. */
|
|
25
|
+
const SCRIPTS = {
|
|
26
|
+
dev: "nifra dev",
|
|
27
|
+
preview: "bunx wrangler pages dev dist",
|
|
28
|
+
build: "bun run build.ts",
|
|
29
|
+
"build:bun": "bun run build-bun.ts",
|
|
30
|
+
"build:node": "bun run build-node.ts",
|
|
31
|
+
"build:deno": "bun run build-deno.ts",
|
|
32
|
+
"build:vercel": "bun run build-vercel.ts",
|
|
33
|
+
start: "bun dist-bun/server-bun.js",
|
|
34
|
+
"start:node": "node dist-node/server-node.js",
|
|
35
|
+
"deploy:cf": "wrangler pages deploy dist",
|
|
36
|
+
"deploy:vercel": "vercel deploy --prebuilt",
|
|
37
|
+
check: "nifra check && nifra assure",
|
|
38
|
+
};
|
|
39
|
+
/** Nifra packages every site depends on, whatever it renders with. */
|
|
40
|
+
const NIFRA_RUNTIME = ["client", "core", "schema", "deno", "node", "web"];
|
|
41
|
+
export function renderPackageJson(framework) {
|
|
42
|
+
const dependencies = {};
|
|
43
|
+
for (const name of NIFRA_RUNTIME)
|
|
44
|
+
dependencies[`@nifrajs/${name}`] = NIFRA_DEP_RANGE;
|
|
45
|
+
dependencies[framework.package] = NIFRA_DEP_RANGE;
|
|
46
|
+
Object.assign(dependencies, framework.runtimeDependencies);
|
|
47
|
+
return json({
|
|
48
|
+
name: "nifra-site",
|
|
49
|
+
version: "0.0.0",
|
|
50
|
+
type: "module",
|
|
51
|
+
private: true,
|
|
52
|
+
scripts: SCRIPTS,
|
|
53
|
+
dependencies,
|
|
54
|
+
devDependencies: {
|
|
55
|
+
"@nifrajs/cli": NIFRA_DEP_RANGE,
|
|
56
|
+
...framework.devDependencies,
|
|
57
|
+
typescript: "^6.0.3",
|
|
58
|
+
vite: "^8.0.0",
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Directories a build writes and a typecheck must not read, plus the entries that are run by Bun
|
|
64
|
+
* rather than typechecked as part of the app.
|
|
65
|
+
*
|
|
66
|
+
* `.vercel` is in here for every framework. It was missing from React's copy alone, which is the shape
|
|
67
|
+
* this whole refactor is about: `build-vercel.ts` writes there in all five, and four tsconfigs knew.
|
|
68
|
+
*/
|
|
69
|
+
const EXCLUDE = [
|
|
70
|
+
"node_modules",
|
|
71
|
+
"dist",
|
|
72
|
+
"dist-bun",
|
|
73
|
+
"dist-node",
|
|
74
|
+
"dist-deno",
|
|
75
|
+
"dist-vercel",
|
|
76
|
+
".nifra",
|
|
77
|
+
".vercel",
|
|
78
|
+
".wrangler",
|
|
79
|
+
"server-manifest.ts",
|
|
80
|
+
"server-bun.ts",
|
|
81
|
+
"server-node.ts",
|
|
82
|
+
"server-deno.ts",
|
|
83
|
+
"server-vercel.ts",
|
|
84
|
+
"_worker.ts",
|
|
85
|
+
"build.ts",
|
|
86
|
+
"build-bun.ts",
|
|
87
|
+
"build-node.ts",
|
|
88
|
+
"build-deno.ts",
|
|
89
|
+
"build-vercel.ts",
|
|
90
|
+
];
|
|
91
|
+
export function renderTsconfig(framework) {
|
|
92
|
+
const ts = framework.typescript;
|
|
93
|
+
return json({
|
|
94
|
+
compilerOptions: {
|
|
95
|
+
target: "ES2022",
|
|
96
|
+
module: "ESNext",
|
|
97
|
+
moduleResolution: "bundler",
|
|
98
|
+
lib: ["ES2022", "DOM", "DOM.Iterable"],
|
|
99
|
+
...(ts.jsx === undefined ? {} : { jsx: ts.jsx }),
|
|
100
|
+
...(ts.jsxImportSource === undefined ? {} : { jsxImportSource: ts.jsxImportSource }),
|
|
101
|
+
strict: true,
|
|
102
|
+
noUncheckedIndexedAccess: true,
|
|
103
|
+
skipLibCheck: true,
|
|
104
|
+
noEmit: true,
|
|
105
|
+
verbatimModuleSyntax: true,
|
|
106
|
+
...(ts.types === undefined ? {} : { types: ts.types }),
|
|
107
|
+
},
|
|
108
|
+
include: ts.includeTsx === false ? ["**/*.ts"] : ["**/*.ts", "**/*.tsx"],
|
|
109
|
+
exclude: EXCLUDE,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=site-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-files.js","sourceRoot":"","sources":["../../src/scaffold/site-files.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAsB,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAErE,2EAA2E;AAC3E,MAAM,IAAI,GAAG,CAAC,KAAc,EAAU,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAA;AAE9E;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAAwB;IAC5D,OAAO;;;WAGE,SAAS,CAAC,OAAO,YAAY,SAAS,CAAC,OAAO;;yBAEhC,SAAS,CAAC,OAAO;CACzC,CAAA;AACD,CAAC;AAED,0EAA0E;AAC1E,MAAM,OAAO,GAAqC;IAChD,GAAG,EAAE,WAAW;IAChB,OAAO,EAAE,8BAA8B;IACvC,KAAK,EAAE,kBAAkB;IACzB,WAAW,EAAE,sBAAsB;IACnC,YAAY,EAAE,uBAAuB;IACrC,YAAY,EAAE,uBAAuB;IACrC,cAAc,EAAE,yBAAyB;IACzC,KAAK,EAAE,4BAA4B;IACnC,YAAY,EAAE,+BAA+B;IAC7C,WAAW,EAAE,4BAA4B;IACzC,eAAe,EAAE,0BAA0B;IAC3C,KAAK,EAAE,6BAA6B;CACrC,CAAA;AAED,sEAAsE;AACtE,MAAM,aAAa,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;AAEzE,MAAM,UAAU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AC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC;YAChD,GAAG,CAAC,EAAE,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,EAAE,CAAC,eAAe,EAAE,CAAC;YACpF,MAAM,EAAE,IAAI;YACZ,wBAAwB,EAAE,IAAI;YAC9B,YAAY,EAAE,IAAI;YAClB,MAAM,EAAE,IAAI;YACZ,oBAAoB,EAAE,IAAI;YAC1B,GAAG,CAAC,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC;SACvD;QACD,OAAO,EAAE,EAAE,CAAC,UAAU,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,UAAU,CAAC;QACxE,OAAO,EAAE,OAAO;KACjB,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type FrameworkSpec } from "./frameworks.js";
|
|
2
|
+
/**
|
|
3
|
+
* Files identical in every site scaffold, taken from the base directory.
|
|
4
|
+
*
|
|
5
|
+
* Listed rather than globbed: a glob would silently absorb a file someone adds to the base for one
|
|
6
|
+
* framework's benefit, which is the failure this is meant to end. Adding a shared file means saying so
|
|
7
|
+
* here, and `site-composition.test.ts` fails if this list and the directory disagree.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SHARED_SITE_FILES: readonly string[];
|
|
10
|
+
/** Files each framework supplies itself, relative to its overlay directory. */
|
|
11
|
+
export declare const FRAMEWORK_SITE_FILES: readonly string[];
|
|
12
|
+
/** Route files, whose extension is the framework's own. */
|
|
13
|
+
export declare const ROUTE_BASENAMES: readonly string[];
|
|
14
|
+
/** Extension the framework's route files carry. */
|
|
15
|
+
export declare function routeExtension(framework: FrameworkSpec): string;
|
|
16
|
+
/** The base directory: the shared files plus React's own, which is also the React overlay. */
|
|
17
|
+
export declare const SITE_BASE_DIR: string;
|
|
18
|
+
export declare function overlayDir(framework: FrameworkSpec): string;
|
|
19
|
+
/** Every file a site scaffold emits, and the text it holds. Generated files only. */
|
|
20
|
+
export declare function generatedSiteFiles(framework: FrameworkSpec): Map<string, string>;
|
|
21
|
+
export interface MaterializeOptions {
|
|
22
|
+
/** Overwrite an existing destination. Default false, which refuses rather than clobbers. */
|
|
23
|
+
readonly force?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Write a complete site scaffold into `target`.
|
|
27
|
+
*
|
|
28
|
+
* Refusing an occupied destination is the default and is preserved deliberately: `cp`'s
|
|
29
|
+
* `errorOnExist` did that before this was generated, and losing it would turn a mistyped path into
|
|
30
|
+
* silent data loss in someone's working directory. `--force` is what `bun create nifra .` needs.
|
|
31
|
+
*/
|
|
32
|
+
export declare function materializeSite(target: string, id: string, options?: MaterializeOptions): Promise<void>;
|
|
33
|
+
//# sourceMappingURL=site.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../../src/scaffold/site.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,iBAAiB,CAAA;AAInE;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAc9C,CAAA;AAED,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAAqC,CAAA;AAEvF,2DAA2D;AAC3D,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAAiC,CAAA;AAE9E,mDAAmD;AACnD,wBAAgB,cAAc,CAAC,SAAS,EAAE,aAAa,GAAG,MAAM,CAI/D;AAGD,8FAA8F;AAC9F,eAAO,MAAM,aAAa,QAA0C,CAAA;AACpE,wBAAgB,UAAU,CAAC,SAAS,EAAE,aAAa,GAAG,MAAM,CAI3D;AAED,qFAAqF;AACrF,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAOhF;AAED,MAAM,WAAW,kBAAkB;IACjC,4FAA4F;IAC5F,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CACzB;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAqBf"}
|