@fragno-dev/create 0.1.1 → 0.1.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/.turbo/turbo-build.log +9 -6
- package/CHANGELOG.md +19 -0
- package/LICENSE.md +16 -0
- package/dist/index.js +19 -26
- package/dist/index.js.map +1 -1
- package/package.json +19 -14
- package/src/integration.test.ts +8 -5
- package/src/package-json.ts +19 -20
- package/templates/fragment/src/client/react.ts +1 -1
- package/templates/fragment/src/client/solid.ts +1 -1
- package/templates/fragment/src/client/svelte.ts +1 -1
- package/templates/fragment/src/client/vanilla.ts +1 -1
- package/templates/fragment/src/client/vue.ts +1 -1
- package/templates/fragment/src/index.ts +23 -28
- package/templates/optional/agent/AGENTS.md +29 -14
- package/templates/optional/builder/esbuild.config.js +3 -3
- package/templates/optional/builder/rollup.config.js +3 -2
- package/templates/optional/builder/rspack.config.js +3 -2
- package/templates/optional/builder/vite.config.ts +5 -1
- package/templates/optional/builder/webpack.config.js +3 -2
- package/templates/optional/database/index.ts +52 -70
- package/dist/tsconfig.tsbuildinfo +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
|
|
2
|
+
> @fragno-dev/create@0.1.4 build /home/runner/work/fragno/fragno/packages/create
|
|
3
|
+
> tsdown
|
|
4
|
+
|
|
5
|
+
[34mℹ[39m tsdown [2mv0.15.12[22m powered by rolldown [2mv1.0.0-beta.45[22m
|
|
3
6
|
[34mℹ[39m Using tsdown config: [4m/home/runner/work/fragno/fragno/packages/create/tsdown.config.ts[24m
|
|
4
7
|
[34mℹ[39m entry: [34msrc/index.ts[39m
|
|
5
8
|
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
6
9
|
[34mℹ[39m Build start
|
|
7
|
-
[34mℹ[39m [2mdist/[22m[1mindex.js[22m [2m 5.
|
|
8
|
-
[34mℹ[39m [2mdist/[22mindex.js.map [2m11.
|
|
10
|
+
[34mℹ[39m [2mdist/[22m[1mindex.js[22m [2m 5.75 kB[22m [2m│ gzip: 1.93 kB[22m
|
|
11
|
+
[34mℹ[39m [2mdist/[22mindex.js.map [2m11.47 kB[22m [2m│ gzip: 3.49 kB[22m
|
|
9
12
|
[34mℹ[39m [2mdist/[22mindex.d.ts.map [2m 0.58 kB[22m [2m│ gzip: 0.31 kB[22m
|
|
10
13
|
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.ts[22m[39m [2m 1.28 kB[22m [2m│ gzip: 0.48 kB[22m
|
|
11
|
-
[34mℹ[39m 4 files, total: 19.
|
|
12
|
-
[32m✔[39m Build complete in [
|
|
14
|
+
[34mℹ[39m 4 files, total: 19.08 kB
|
|
15
|
+
[32m✔[39m Build complete in [32m3797ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @fragno-dev/create
|
|
2
2
|
|
|
3
|
+
## 0.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bc072dd: feat: update create template for newest Fragno version
|
|
8
|
+
|
|
9
|
+
## 0.1.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- d78940e: fix: make sure @fragno-dev/db is properly tree shaken from browser bundles
|
|
14
|
+
- 46ecc44: create: add moduleSideEffects: false to fragment template
|
|
15
|
+
|
|
16
|
+
## 0.1.2
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- b34e9e8: feat: bring Fragment template to latest versions
|
|
21
|
+
|
|
3
22
|
## 0.1.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Copyright 2025 - present "ReJot Nederland B.V.", and individual contributors.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
4
|
+
associated documentation files (the “Software”), to deal in the Software without restriction,
|
|
5
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
6
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
7
|
+
furnished to do so, subject to the following conditions:
|
|
8
|
+
|
|
9
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
10
|
+
portions of the Software.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
13
|
+
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
14
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
|
|
15
|
+
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
16
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/dist/index.js
CHANGED
|
@@ -47,65 +47,59 @@ function copy(from, to, rename = identity) {
|
|
|
47
47
|
|
|
48
48
|
//#endregion
|
|
49
49
|
//#region src/package-json.ts
|
|
50
|
-
const fragnoCoreVersion = "
|
|
51
|
-
const fragnoDbVersion = "
|
|
52
|
-
const unpluginFragnoVersion = "
|
|
53
|
-
const fragnoCliVersion = "
|
|
50
|
+
const fragnoCoreVersion = "0.1.10";
|
|
51
|
+
const fragnoDbVersion = "0.1.15";
|
|
52
|
+
const unpluginFragnoVersion = "0.0.7";
|
|
53
|
+
const fragnoCliVersion = "0.1.20";
|
|
54
54
|
const basePkg = {
|
|
55
55
|
dependencies: {
|
|
56
56
|
"@fragno-dev/core": fragnoCoreVersion,
|
|
57
|
+
"@standard-schema/spec": "^1.0.0",
|
|
57
58
|
zod: "^4.0.5"
|
|
58
59
|
},
|
|
59
60
|
devDependencies: {
|
|
61
|
+
"@types/node": "^24",
|
|
60
62
|
"@fragno-dev/cli": fragnoCliVersion,
|
|
61
|
-
"@
|
|
63
|
+
"@fragno-dev/unplugin-fragno": unpluginFragnoVersion
|
|
62
64
|
},
|
|
63
65
|
peerDependencies: {
|
|
64
|
-
typescript: "
|
|
66
|
+
typescript: ">=5",
|
|
65
67
|
react: ">=18.0.0",
|
|
66
68
|
svelte: ">=4.0.0",
|
|
67
69
|
"solid-js": ">=1.0.0",
|
|
68
70
|
vue: ">=3.0.0"
|
|
69
71
|
}
|
|
70
72
|
};
|
|
71
|
-
const databasePkg = {
|
|
73
|
+
const databasePkg = {
|
|
74
|
+
devDependencies: { "@fragno-dev/db": fragnoDbVersion },
|
|
75
|
+
peerDependencies: { "@fragno-dev/db": fragnoDbVersion }
|
|
76
|
+
};
|
|
72
77
|
const buildToolPkg = {
|
|
73
78
|
none: {},
|
|
74
79
|
tsdown: {
|
|
75
|
-
devDependencies: {
|
|
76
|
-
"@fragno-dev/unplugin-fragno": unpluginFragnoVersion,
|
|
77
|
-
tsdown: "^0.11.9"
|
|
78
|
-
},
|
|
80
|
+
devDependencies: { tsdown: "^0.12.0" },
|
|
79
81
|
scripts: { build: "tsdown" }
|
|
80
82
|
},
|
|
81
83
|
esbuild: {
|
|
82
|
-
devDependencies: {
|
|
83
|
-
"@fragno-dev/unplugin-fragno": unpluginFragnoVersion,
|
|
84
|
-
esbuild: "^0.25.10"
|
|
85
|
-
},
|
|
84
|
+
devDependencies: { esbuild: "^0.25.12" },
|
|
86
85
|
scripts: { build: "./esbuild.config.js" }
|
|
87
86
|
},
|
|
88
87
|
vite: {
|
|
89
|
-
devDependencies: {
|
|
90
|
-
"@fragno-dev/unplugin-fragno": unpluginFragnoVersion,
|
|
91
|
-
vite: "^6.0.0"
|
|
92
|
-
},
|
|
88
|
+
devDependencies: { vite: "^6.3.5" },
|
|
93
89
|
scripts: { build: "vite build" }
|
|
94
90
|
},
|
|
95
91
|
rollup: {
|
|
96
92
|
devDependencies: {
|
|
97
|
-
"@fragno-dev/unplugin-fragno": unpluginFragnoVersion,
|
|
98
93
|
"@rollup/plugin-node-resolve": "^16.0.2",
|
|
99
94
|
"@rollup/plugin-typescript": "^12.1.4",
|
|
100
95
|
tslib: "^2.8.1",
|
|
101
|
-
rollup: "^4.
|
|
96
|
+
rollup: "^4.41.0"
|
|
102
97
|
},
|
|
103
98
|
scripts: { build: "rollup -c" }
|
|
104
99
|
},
|
|
105
100
|
webpack: {
|
|
106
101
|
devDependencies: {
|
|
107
|
-
"
|
|
108
|
-
webpack: "^5.102.0",
|
|
102
|
+
webpack: "^5.99.9",
|
|
109
103
|
"webpack-cli": "^6.0.1",
|
|
110
104
|
"ts-loader": "^9.5.1"
|
|
111
105
|
},
|
|
@@ -113,9 +107,8 @@ const buildToolPkg = {
|
|
|
113
107
|
},
|
|
114
108
|
rspack: {
|
|
115
109
|
devDependencies: {
|
|
116
|
-
"@
|
|
117
|
-
"@rspack/
|
|
118
|
-
"@rspack/cli": "^1.5.8"
|
|
110
|
+
"@rspack/core": "^1.6.1",
|
|
111
|
+
"@rspack/cli": "^1.6.1"
|
|
119
112
|
},
|
|
120
113
|
scripts: { build: "rspack build" }
|
|
121
114
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["e: unknown","basePkg: Record<string, unknown>","databasePkg: Record<string, unknown>","buildToolPkg: Record<BuildTools, Record<string, unknown>>","pkgOverride: Record<string, unknown>"],"sources":["../src/utils.ts","../src/package-json.ts","../src/index.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\n\nexport function mkdirp(dir: string): void {\n try {\n fs.mkdirSync(dir, { recursive: true });\n } catch (e: unknown) {\n if (e instanceof Error && \"code\" in e && e.code === \"EEXIST\") {\n return;\n }\n throw e;\n }\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return (\n value !== null &&\n typeof value === \"object\" &&\n !Array.isArray(value) &&\n Object.prototype.toString.call(value) === \"[object Object]\"\n );\n}\n\n/**\n * Deep merge plain objects. Arrays and primitives are overwritten, not merged.\n * @param target The target object\n * @param source The source object\n * @returns The merged object\n */\nexport function merge<T extends Record<string, unknown>>(\n target: T,\n source: Record<string, unknown>,\n): T {\n const result = { ...target } as Record<string, unknown>;\n\n for (const key in source) {\n const sourceValue = source[key];\n const targetValue = result[key];\n\n if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {\n result[key] = merge(targetValue, sourceValue);\n } else {\n result[key] = sourceValue;\n }\n }\n\n return result as T;\n}\n\nfunction identity<T>(x: T): T {\n return x;\n}\n\nexport function copy(\n from: string,\n to: string,\n rename: (basename: string) => string = identity,\n): void {\n if (!fs.existsSync(from)) {\n return;\n }\n\n const stats = fs.statSync(from);\n\n if (stats.isDirectory()) {\n fs.readdirSync(from).forEach((file) => {\n copy(path.join(from, file), path.join(to, rename(file)));\n });\n } else {\n mkdirp(path.dirname(to));\n fs.copyFileSync(from, to);\n }\n}\n","import type { BuildTools } from \"./index\";\n\nconst fragnoCoreVersion = \"^0.1.2\";\nconst fragnoDbVersion = \"^0.1.2\";\nconst unpluginFragnoVersion = \"^0.0.2\";\nconst fragnoCliVersion = \"^0.1.3\";\n\nexport const basePkg: Record<string, unknown> = {\n dependencies: {\n \"@fragno-dev/core\": fragnoCoreVersion,\n zod: \"^4.0.5\",\n },\n devDependencies: {\n \"@fragno-dev/cli\": fragnoCliVersion,\n \"@types/node\": \"^22\",\n },\n peerDependencies: {\n typescript: \"^5\",\n react: \">=18.0.0\",\n svelte: \">=4.0.0\",\n \"solid-js\": \">=1.0.0\",\n vue: \">=3.0.0\",\n },\n};\n\nexport const databasePkg: Record<string, unknown> = {\n dependencies: {\n \"@fragno-dev/db\": fragnoDbVersion,\n },\n};\n\nexport const buildToolPkg: Record<BuildTools, Record<string, unknown>> = {\n none: {},\n tsdown: {\n devDependencies: {\n \"@fragno-dev/unplugin-fragno\": unpluginFragnoVersion,\n tsdown: \"^0.11.9\",\n },\n scripts: {\n build: \"tsdown\",\n },\n },\n esbuild: {\n devDependencies: {\n \"@fragno-dev/unplugin-fragno\": unpluginFragnoVersion,\n esbuild: \"^0.25.10\",\n },\n scripts: {\n build: \"./esbuild.config.js\",\n },\n },\n vite: {\n devDependencies: {\n \"@fragno-dev/unplugin-fragno\": unpluginFragnoVersion,\n vite: \"^6.0.0\",\n },\n scripts: {\n build: \"vite build\",\n },\n },\n rollup: {\n devDependencies: {\n \"@fragno-dev/unplugin-fragno\": unpluginFragnoVersion,\n \"@rollup/plugin-node-resolve\": \"^16.0.2\",\n \"@rollup/plugin-typescript\": \"^12.1.4\",\n tslib: \"^2.8.1\",\n rollup: \"^4.52.4\",\n },\n scripts: {\n build: \"rollup -c\",\n },\n },\n webpack: {\n devDependencies: {\n \"@fragno-dev/unplugin-fragno\": unpluginFragnoVersion,\n webpack: \"^5.102.0\",\n \"webpack-cli\": \"^6.0.1\",\n \"ts-loader\": \"^9.5.1\",\n },\n scripts: {\n build: \"webpack\",\n },\n },\n rspack: {\n devDependencies: {\n \"@fragno-dev/unplugin-fragno\": unpluginFragnoVersion,\n \"@rspack/core\": \"^1.5.8\",\n \"@rspack/cli\": \"^1.5.8\",\n },\n scripts: {\n build: \"rspack build\",\n },\n },\n};\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { copy, merge } from \"./utils.ts\";\nimport { basePkg, buildToolPkg, databasePkg } from \"./package-json.ts\";\nimport { z } from \"zod\";\n\nconst templateTypesSchema = z.literal(\"fragment\");\nexport type TemplateTypes = z.infer<typeof templateTypesSchema>;\n\nconst buildToolsSchema = z.enum([\n \"esbuild\",\n \"tsdown\",\n \"vite\",\n \"rollup\",\n \"webpack\",\n \"rspack\",\n \"none\",\n]);\nexport type BuildTools = z.infer<typeof buildToolsSchema>;\n\nconst agentDocsSchema = z.enum([\"AGENTS.md\", \"CLAUDE.md\", \"none\"]);\nexport type AgentDocs = z.infer<typeof agentDocsSchema>;\n\nexport const createOptionsSchema = z.object({\n path: z.string(),\n buildTool: buildToolsSchema,\n name: z.string(),\n template: templateTypesSchema,\n agentDocs: agentDocsSchema,\n withDatabase: z.boolean(),\n});\n\ntype CreateOptions = z.infer<typeof createOptionsSchema>;\n\nexport function create(options: CreateOptions) {\n let pkgOverride: Record<string, unknown> = merge(basePkg, { name: options.name });\n\n // Build tool pkg overrides\n pkgOverride = merge(pkgOverride, buildToolPkg[options.buildTool]);\n\n // Database pkg overrides\n if (options.withDatabase) {\n pkgOverride = merge(pkgOverride, databasePkg);\n }\n\n if (options.template == \"fragment\") {\n writeFragmentTemplate(options.path, pkgOverride);\n } else {\n throw new Error(`Unsupported template type: ${options.template}`);\n }\n\n switch (options.buildTool) {\n case \"esbuild\":\n writeOptionalTemplate(options.path, \"builder/esbuild.config.js\");\n break;\n case \"tsdown\":\n writeOptionalTemplate(options.path, \"builder/tsdown.config.ts\");\n break;\n case \"vite\":\n writeOptionalTemplate(options.path, \"builder/vite.config.ts\");\n break;\n case \"rollup\":\n writeOptionalTemplate(options.path, \"builder/rollup.config.js\");\n break;\n case \"webpack\":\n writeOptionalTemplate(options.path, \"builder/webpack.config.js\");\n break;\n case \"rspack\":\n writeOptionalTemplate(options.path, \"builder/rspack.config.js\");\n break;\n case \"none\":\n break;\n }\n\n switch (options.agentDocs) {\n case \"AGENTS.md\":\n writeOptionalTemplate(options.path, \"agent/AGENTS.md\");\n break;\n case \"CLAUDE.md\":\n writeOptionalTemplate(options.path, \"agent/AGENTS.md\", \"CLAUDE.md\");\n break;\n case \"none\":\n break;\n }\n\n if (options.withDatabase) {\n writeOptionalTemplate(options.path, \"database/index.ts\", \"src/index.ts\");\n writeOptionalTemplate(options.path, \"database/schema.ts\", \"src/schema.ts\");\n }\n}\n\nfunction getTemplateDir(): string {\n const __dirname = path.dirname(fileURLToPath(import.meta.url));\n return path.join(__dirname, \"..\", \"templates\");\n}\n\nfunction writeOptionalTemplate(targetPath: string, template: string, rename?: string) {\n const templatePath = path.join(getTemplateDir(), \"optional\", template);\n const targetFileName = rename ? rename : path.basename(template);\n const targetFile = path.join(targetPath, targetFileName);\n\n copy(templatePath, targetFile);\n}\n\nfunction writeFragmentTemplate(targetPath: string, pkgOverrides: Record<string, unknown>) {\n const templateDir = path.join(getTemplateDir(), \"fragment\");\n\n // Copy template files\n copy(templateDir, targetPath, (basename) => {\n if (basename === \"package.template.json\") {\n return \"package.json\";\n }\n return basename;\n });\n\n // Update package.json based on chosen options\n const packageJsonPath = path.join(targetPath, \"package.json\");\n const basePkg = JSON.parse(fs.readFileSync(packageJsonPath, \"utf-8\"));\n const newPkg = merge(basePkg, pkgOverrides);\n\n // Write to disk\n fs.writeFileSync(packageJsonPath, JSON.stringify(newPkg, null, 2) + \"\\n\");\n}\n"],"mappings":";;;;;;AAGA,SAAgB,OAAO,KAAmB;AACxC,KAAI;AACF,KAAG,UAAU,KAAK,EAAE,WAAW,MAAM,CAAC;UAC/BA,GAAY;AACnB,MAAI,aAAa,SAAS,UAAU,KAAK,EAAE,SAAS,SAClD;AAEF,QAAM;;;AAIV,SAAS,cAAc,OAAkD;AACvE,QACE,UAAU,QACV,OAAO,UAAU,YACjB,CAAC,MAAM,QAAQ,MAAM,IACrB,OAAO,UAAU,SAAS,KAAK,MAAM,KAAK;;;;;;;;AAU9C,SAAgB,MACd,QACA,QACG;CACH,MAAM,SAAS,EAAE,GAAG,QAAQ;AAE5B,MAAK,MAAM,OAAO,QAAQ;EACxB,MAAM,cAAc,OAAO;EAC3B,MAAM,cAAc,OAAO;AAE3B,MAAI,cAAc,YAAY,IAAI,cAAc,YAAY,CAC1D,QAAO,OAAO,MAAM,aAAa,YAAY;MAE7C,QAAO,OAAO;;AAIlB,QAAO;;AAGT,SAAS,SAAY,GAAS;AAC5B,QAAO;;AAGT,SAAgB,KACd,MACA,IACA,SAAuC,UACjC;AACN,KAAI,CAAC,GAAG,WAAW,KAAK,CACtB;AAKF,KAFc,GAAG,SAAS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sBAAsB,gBAAgB;;;AAI9E,SAAS,iBAAyB;CAChC,MAAM,YAAY,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAC9D,QAAO,KAAK,KAAK,WAAW,MAAM,YAAY;;AAGhD,SAAS,sBAAsB,YAAoB,UAAkB,QAAiB;CACpF,MAAM,eAAe,KAAK,KAAK,gBAAgB,EAAE,YAAY,SAAS;CACtE,MAAM,iBAAiB,SAAS,SAAS,KAAK,SAAS,SAAS;AAGhE,MAAK,cAFc,KAAK,KAAK,YAAY,eAAe,CAE1B;;AAGhC,SAAS,sBAAsB,YAAoB,cAAuC;AAIxF,MAHoB,KAAK,KAAK,gBAAgB,EAAE,WAAW,EAGzC,aAAa,aAAa;AAC1C,MAAI,aAAa,wBACf,QAAO;AAET,SAAO;GACP;CAGF,MAAM,kBAAkB,KAAK,KAAK,YAAY,eAAe;CAE7D,MAAM,SAAS,MADC,KAAK,MAAM,GAAG,aAAa,iBAAiB,QAAQ,CAAC,EACvC,aAAa;AAG3C,IAAG,cAAc,iBAAiB,KAAK,UAAU,QAAQ,MAAM,EAAE,GAAG,KAAK"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["e: unknown","basePkg: Record<string, unknown>","databasePkg: Record<string, unknown>","buildToolPkg: Record<BuildTools, Record<string, unknown>>","pkgOverride: Record<string, unknown>"],"sources":["../src/utils.ts","../src/package-json.ts","../src/index.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\n\nexport function mkdirp(dir: string): void {\n try {\n fs.mkdirSync(dir, { recursive: true });\n } catch (e: unknown) {\n if (e instanceof Error && \"code\" in e && e.code === \"EEXIST\") {\n return;\n }\n throw e;\n }\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return (\n value !== null &&\n typeof value === \"object\" &&\n !Array.isArray(value) &&\n Object.prototype.toString.call(value) === \"[object Object]\"\n );\n}\n\n/**\n * Deep merge plain objects. Arrays and primitives are overwritten, not merged.\n * @param target The target object\n * @param source The source object\n * @returns The merged object\n */\nexport function merge<T extends Record<string, unknown>>(\n target: T,\n source: Record<string, unknown>,\n): T {\n const result = { ...target } as Record<string, unknown>;\n\n for (const key in source) {\n const sourceValue = source[key];\n const targetValue = result[key];\n\n if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {\n result[key] = merge(targetValue, sourceValue);\n } else {\n result[key] = sourceValue;\n }\n }\n\n return result as T;\n}\n\nfunction identity<T>(x: T): T {\n return x;\n}\n\nexport function copy(\n from: string,\n to: string,\n rename: (basename: string) => string = identity,\n): void {\n if (!fs.existsSync(from)) {\n return;\n }\n\n const stats = fs.statSync(from);\n\n if (stats.isDirectory()) {\n fs.readdirSync(from).forEach((file) => {\n copy(path.join(from, file), path.join(to, rename(file)));\n });\n } else {\n mkdirp(path.dirname(to));\n fs.copyFileSync(from, to);\n }\n}\n","import type { BuildTools } from \"./index\";\n\nconst fragnoCoreVersion = \"0.1.10\";\nconst fragnoDbVersion = \"0.1.15\";\nconst unpluginFragnoVersion = \"0.0.7\";\nconst fragnoCliVersion = \"0.1.20\";\n\nexport const basePkg: Record<string, unknown> = {\n dependencies: {\n \"@fragno-dev/core\": fragnoCoreVersion,\n \"@standard-schema/spec\": \"^1.0.0\",\n zod: \"^4.0.5\",\n },\n devDependencies: {\n \"@types/node\": \"^24\",\n \"@fragno-dev/cli\": fragnoCliVersion,\n \"@fragno-dev/unplugin-fragno\": unpluginFragnoVersion,\n },\n peerDependencies: {\n typescript: \">=5\",\n react: \">=18.0.0\",\n svelte: \">=4.0.0\",\n \"solid-js\": \">=1.0.0\",\n vue: \">=3.0.0\",\n },\n};\n\nexport const databasePkg: Record<string, unknown> = {\n devDependencies: {\n \"@fragno-dev/db\": fragnoDbVersion,\n },\n peerDependencies: {\n \"@fragno-dev/db\": fragnoDbVersion,\n },\n};\n\nexport const buildToolPkg: Record<BuildTools, Record<string, unknown>> = {\n none: {},\n tsdown: {\n devDependencies: {\n tsdown: \"^0.12.0\",\n },\n scripts: {\n build: \"tsdown\",\n },\n },\n esbuild: {\n devDependencies: {\n esbuild: \"^0.25.12\",\n },\n scripts: {\n build: \"./esbuild.config.js\",\n },\n },\n vite: {\n devDependencies: {\n vite: \"^6.3.5\",\n },\n scripts: {\n build: \"vite build\",\n },\n },\n rollup: {\n devDependencies: {\n \"@rollup/plugin-node-resolve\": \"^16.0.2\",\n \"@rollup/plugin-typescript\": \"^12.1.4\",\n tslib: \"^2.8.1\",\n rollup: \"^4.41.0\",\n },\n scripts: {\n build: \"rollup -c\",\n },\n },\n webpack: {\n devDependencies: {\n webpack: \"^5.99.9\",\n \"webpack-cli\": \"^6.0.1\",\n \"ts-loader\": \"^9.5.1\",\n },\n scripts: {\n build: \"webpack\",\n },\n },\n rspack: {\n devDependencies: {\n \"@rspack/core\": \"^1.6.1\",\n \"@rspack/cli\": \"^1.6.1\",\n },\n scripts: {\n build: \"rspack build\",\n },\n },\n};\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { copy, merge } from \"./utils.ts\";\nimport { basePkg, buildToolPkg, databasePkg } from \"./package-json.ts\";\nimport { z } from \"zod\";\n\nconst templateTypesSchema = z.literal(\"fragment\");\nexport type TemplateTypes = z.infer<typeof templateTypesSchema>;\n\nconst buildToolsSchema = z.enum([\n \"esbuild\",\n \"tsdown\",\n \"vite\",\n \"rollup\",\n \"webpack\",\n \"rspack\",\n \"none\",\n]);\nexport type BuildTools = z.infer<typeof buildToolsSchema>;\n\nconst agentDocsSchema = z.enum([\"AGENTS.md\", \"CLAUDE.md\", \"none\"]);\nexport type AgentDocs = z.infer<typeof agentDocsSchema>;\n\nexport const createOptionsSchema = z.object({\n path: z.string(),\n buildTool: buildToolsSchema,\n name: z.string(),\n template: templateTypesSchema,\n agentDocs: agentDocsSchema,\n withDatabase: z.boolean(),\n});\n\ntype CreateOptions = z.infer<typeof createOptionsSchema>;\n\nexport function create(options: CreateOptions) {\n let pkgOverride: Record<string, unknown> = merge(basePkg, { name: options.name });\n\n // Build tool pkg overrides\n pkgOverride = merge(pkgOverride, buildToolPkg[options.buildTool]);\n\n // Database pkg overrides\n if (options.withDatabase) {\n pkgOverride = merge(pkgOverride, databasePkg);\n }\n\n if (options.template == \"fragment\") {\n writeFragmentTemplate(options.path, pkgOverride);\n } else {\n throw new Error(`Unsupported template type: ${options.template}`);\n }\n\n switch (options.buildTool) {\n case \"esbuild\":\n writeOptionalTemplate(options.path, \"builder/esbuild.config.js\");\n break;\n case \"tsdown\":\n writeOptionalTemplate(options.path, \"builder/tsdown.config.ts\");\n break;\n case \"vite\":\n writeOptionalTemplate(options.path, \"builder/vite.config.ts\");\n break;\n case \"rollup\":\n writeOptionalTemplate(options.path, \"builder/rollup.config.js\");\n break;\n case \"webpack\":\n writeOptionalTemplate(options.path, \"builder/webpack.config.js\");\n break;\n case \"rspack\":\n writeOptionalTemplate(options.path, \"builder/rspack.config.js\");\n break;\n case \"none\":\n break;\n }\n\n switch (options.agentDocs) {\n case \"AGENTS.md\":\n writeOptionalTemplate(options.path, \"agent/AGENTS.md\");\n break;\n case \"CLAUDE.md\":\n writeOptionalTemplate(options.path, \"agent/AGENTS.md\", \"CLAUDE.md\");\n break;\n case \"none\":\n break;\n }\n\n if (options.withDatabase) {\n writeOptionalTemplate(options.path, \"database/index.ts\", \"src/index.ts\");\n writeOptionalTemplate(options.path, \"database/schema.ts\", \"src/schema.ts\");\n }\n}\n\nfunction getTemplateDir(): string {\n const __dirname = path.dirname(fileURLToPath(import.meta.url));\n return path.join(__dirname, \"..\", \"templates\");\n}\n\nfunction writeOptionalTemplate(targetPath: string, template: string, rename?: string) {\n const templatePath = path.join(getTemplateDir(), \"optional\", template);\n const targetFileName = rename ? rename : path.basename(template);\n const targetFile = path.join(targetPath, targetFileName);\n\n copy(templatePath, targetFile);\n}\n\nfunction writeFragmentTemplate(targetPath: string, pkgOverrides: Record<string, unknown>) {\n const templateDir = path.join(getTemplateDir(), \"fragment\");\n\n // Copy template files\n copy(templateDir, targetPath, (basename) => {\n if (basename === \"package.template.json\") {\n return \"package.json\";\n }\n return basename;\n });\n\n // Update package.json based on chosen options\n const packageJsonPath = path.join(targetPath, \"package.json\");\n const basePkg = JSON.parse(fs.readFileSync(packageJsonPath, \"utf-8\"));\n const newPkg = merge(basePkg, pkgOverrides);\n\n // Write to disk\n fs.writeFileSync(packageJsonPath, JSON.stringify(newPkg, null, 2) + \"\\n\");\n}\n"],"mappings":";;;;;;AAGA,SAAgB,OAAO,KAAmB;AACxC,KAAI;AACF,KAAG,UAAU,KAAK,EAAE,WAAW,MAAM,CAAC;UAC/BA,GAAY;AACnB,MAAI,aAAa,SAAS,UAAU,KAAK,EAAE,SAAS,SAClD;AAEF,QAAM;;;AAIV,SAAS,cAAc,OAAkD;AACvE,QACE,UAAU,QACV,OAAO,UAAU,YACjB,CAAC,MAAM,QAAQ,MAAM,IACrB,OAAO,UAAU,SAAS,KAAK,MAAM,KAAK;;;;;;;;AAU9C,SAAgB,MACd,QACA,QACG;CACH,MAAM,SAAS,EAAE,GAAG,QAAQ;AAE5B,MAAK,MAAM,OAAO,QAAQ;EACxB,MAAM,cAAc,OAAO;EAC3B,MAAM,cAAc,OAAO;AAE3B,MAAI,cAAc,YAAY,IAAI,cAAc,YAAY,CAC1D,QAAO,OAAO,MAAM,aAAa,YAAY;MAE7C,QAAO,OAAO;;AAIlB,QAAO;;AAGT,SAAS,SAAY,GAAS;AAC5B,QAAO;;AAGT,SAAgB,KACd,MACA,IACA,SAAuC,UACjC;AACN,KAAI,CAAC,GAAG,WAAW,KAAK,CACtB;AAKF,KAFc,GAAG,SAAS,KAAK,CAErB,aAAa,CACrB,IAAG,YAAY,KAAK,CAAC,SAAS,SAAS;AACrC,OAAK,KAAK,KAAK,MAAM,KAAK,EAAE,KAAK,KAAK,IAAI,OAAO,KAAK,CAAC,CAAC;GACxD;MACG;AACL,SAAO,KAAK,QAAQ,GAAG,CAAC;AACxB,KAAG,aAAa,MAAM,GAAG;;;;;;ACpE7B,MAAM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,SAAS,KAAK,SAAS,SAAS;AAGhE,MAAK,cAFc,KAAK,KAAK,YAAY,eAAe,CAE1B;;AAGhC,SAAS,sBAAsB,YAAoB,cAAuC;AAIxF,MAHoB,KAAK,KAAK,gBAAgB,EAAE,WAAW,EAGzC,aAAa,aAAa;AAC1C,MAAI,aAAa,wBACf,QAAO;AAET,SAAO;GACP;CAGF,MAAM,kBAAkB,KAAK,KAAK,YAAY,eAAe;CAE7D,MAAM,SAAS,MADC,KAAK,MAAM,GAAG,aAAa,iBAAiB,QAAQ,CAAC,EACvC,aAAa;AAG3C,IAAG,cAAc,iBAAiB,KAAK,UAAU,QAAQ,MAAM,EAAE,GAAG,KAAK"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fragno-dev/create",
|
|
3
3
|
"description": "A library for creating Fragno fragments",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
|
-
"bun": "./src/index.ts",
|
|
8
7
|
"development": "./src/index.ts",
|
|
9
8
|
"types": "./dist/index.d.ts",
|
|
10
9
|
"default": "./dist/index.js"
|
|
@@ -13,26 +12,32 @@
|
|
|
13
12
|
"main": "./dist/index.js",
|
|
14
13
|
"module": "./dist/index.js",
|
|
15
14
|
"types": "./dist/index.d.ts",
|
|
16
|
-
"scripts": {
|
|
17
|
-
"test": "vitest run",
|
|
18
|
-
"build": "tsdown",
|
|
19
|
-
"build:watch": "tsdown --watch",
|
|
20
|
-
"types:check": "tsc --noEmit"
|
|
21
|
-
},
|
|
22
15
|
"type": "module",
|
|
23
16
|
"dependencies": {
|
|
24
17
|
"zod": "^4.1.12"
|
|
25
18
|
},
|
|
26
19
|
"devDependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"@fragno-private/vitest-config": "0.0.0",
|
|
29
|
-
"@types/node": "^20",
|
|
30
|
-
"@types/bun": "latest",
|
|
20
|
+
"@types/node": "^22",
|
|
31
21
|
"@vitest/coverage-istanbul": "^3.2.4",
|
|
32
|
-
"vitest": "^3.2.4"
|
|
22
|
+
"vitest": "^3.2.4",
|
|
23
|
+
"@fragno-private/typescript-config": "0.0.1",
|
|
24
|
+
"@fragno-private/vitest-config": "0.0.0"
|
|
33
25
|
},
|
|
34
26
|
"private": false,
|
|
35
27
|
"peerDependencies": {
|
|
36
28
|
"typescript": "^5"
|
|
29
|
+
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/rejot-dev/fragno.git",
|
|
33
|
+
"directory": "packages/create"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://fragno.dev",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"scripts": {
|
|
38
|
+
"test": "vitest run",
|
|
39
|
+
"build": "tsdown",
|
|
40
|
+
"build:watch": "tsdown --watch",
|
|
41
|
+
"types:check": "tsc --noEmit"
|
|
37
42
|
}
|
|
38
|
-
}
|
|
43
|
+
}
|
package/src/integration.test.ts
CHANGED
|
@@ -54,8 +54,8 @@ function createFragmentTestSuite(buildTool: BuildTool, withDatabase: boolean) {
|
|
|
54
54
|
await expect(fs.access(agentFile)).resolves.toBeUndefined();
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
test("installs", { timeout:
|
|
58
|
-
const { stdout } = await execAsync("
|
|
57
|
+
test("installs", { timeout: 30000 }, async () => {
|
|
58
|
+
const { stdout } = await execAsync("pnpm install", {
|
|
59
59
|
cwd: tempDir,
|
|
60
60
|
encoding: "utf8",
|
|
61
61
|
});
|
|
@@ -63,7 +63,7 @@ function createFragmentTestSuite(buildTool: BuildTool, withDatabase: boolean) {
|
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
test("compiles", { timeout: 30000 }, async () => {
|
|
66
|
-
const { stdout } = await execAsync("
|
|
66
|
+
const { stdout } = await execAsync("pnpm run types:check", {
|
|
67
67
|
cwd: tempDir,
|
|
68
68
|
encoding: "utf8",
|
|
69
69
|
});
|
|
@@ -72,12 +72,12 @@ function createFragmentTestSuite(buildTool: BuildTool, withDatabase: boolean) {
|
|
|
72
72
|
});
|
|
73
73
|
/*
|
|
74
74
|
FIXME: Skipping this test for rollup:
|
|
75
|
-
When running rollup directly through
|
|
75
|
+
When running rollup directly through pnpm run build or npm run build the build succeeds,
|
|
76
76
|
but somehow when running through vitest the module resolution mechanism changes causing
|
|
77
77
|
the build to fail.
|
|
78
78
|
*/
|
|
79
79
|
test.skipIf(buildTool === "rollup")("builds", { timeout: 50000 }, async () => {
|
|
80
|
-
const result = await execAsync("
|
|
80
|
+
const result = await execAsync("pnpm run build", {
|
|
81
81
|
cwd: tempDir,
|
|
82
82
|
encoding: "utf8",
|
|
83
83
|
});
|
|
@@ -95,6 +95,9 @@ function createFragmentTestSuite(buildTool: BuildTool, withDatabase: boolean) {
|
|
|
95
95
|
// However, the peerDependencies of @fragno-dev/core must not be included
|
|
96
96
|
expect(reactBundleContent).toMatch(/from\s*['"]react['"]/);
|
|
97
97
|
|
|
98
|
+
// db should also not be included in the frontend
|
|
99
|
+
expect(reactBundleContent).not.toMatch(/import\s+.*?\s+from\s+['"]@fragno-dev\/db/);
|
|
100
|
+
|
|
98
101
|
// Vite builds only the browser bundle
|
|
99
102
|
if (buildTool !== "vite") {
|
|
100
103
|
await expect(fs.access(path.join(tempDir, "dist", "node"))).resolves.toBeUndefined();
|
package/src/package-json.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import type { BuildTools } from "./index";
|
|
2
2
|
|
|
3
|
-
const fragnoCoreVersion = "
|
|
4
|
-
const fragnoDbVersion = "
|
|
5
|
-
const unpluginFragnoVersion = "
|
|
6
|
-
const fragnoCliVersion = "
|
|
3
|
+
const fragnoCoreVersion = "0.1.10";
|
|
4
|
+
const fragnoDbVersion = "0.1.15";
|
|
5
|
+
const unpluginFragnoVersion = "0.0.7";
|
|
6
|
+
const fragnoCliVersion = "0.1.20";
|
|
7
7
|
|
|
8
8
|
export const basePkg: Record<string, unknown> = {
|
|
9
9
|
dependencies: {
|
|
10
10
|
"@fragno-dev/core": fragnoCoreVersion,
|
|
11
|
+
"@standard-schema/spec": "^1.0.0",
|
|
11
12
|
zod: "^4.0.5",
|
|
12
13
|
},
|
|
13
14
|
devDependencies: {
|
|
15
|
+
"@types/node": "^24",
|
|
14
16
|
"@fragno-dev/cli": fragnoCliVersion,
|
|
15
|
-
"@
|
|
17
|
+
"@fragno-dev/unplugin-fragno": unpluginFragnoVersion,
|
|
16
18
|
},
|
|
17
19
|
peerDependencies: {
|
|
18
|
-
typescript: "
|
|
20
|
+
typescript: ">=5",
|
|
19
21
|
react: ">=18.0.0",
|
|
20
22
|
svelte: ">=4.0.0",
|
|
21
23
|
"solid-js": ">=1.0.0",
|
|
@@ -24,7 +26,10 @@ export const basePkg: Record<string, unknown> = {
|
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
export const databasePkg: Record<string, unknown> = {
|
|
27
|
-
|
|
29
|
+
devDependencies: {
|
|
30
|
+
"@fragno-dev/db": fragnoDbVersion,
|
|
31
|
+
},
|
|
32
|
+
peerDependencies: {
|
|
28
33
|
"@fragno-dev/db": fragnoDbVersion,
|
|
29
34
|
},
|
|
30
35
|
};
|
|
@@ -33,8 +38,7 @@ export const buildToolPkg: Record<BuildTools, Record<string, unknown>> = {
|
|
|
33
38
|
none: {},
|
|
34
39
|
tsdown: {
|
|
35
40
|
devDependencies: {
|
|
36
|
-
"
|
|
37
|
-
tsdown: "^0.11.9",
|
|
41
|
+
tsdown: "^0.12.0",
|
|
38
42
|
},
|
|
39
43
|
scripts: {
|
|
40
44
|
build: "tsdown",
|
|
@@ -42,8 +46,7 @@ export const buildToolPkg: Record<BuildTools, Record<string, unknown>> = {
|
|
|
42
46
|
},
|
|
43
47
|
esbuild: {
|
|
44
48
|
devDependencies: {
|
|
45
|
-
"
|
|
46
|
-
esbuild: "^0.25.10",
|
|
49
|
+
esbuild: "^0.25.12",
|
|
47
50
|
},
|
|
48
51
|
scripts: {
|
|
49
52
|
build: "./esbuild.config.js",
|
|
@@ -51,8 +54,7 @@ export const buildToolPkg: Record<BuildTools, Record<string, unknown>> = {
|
|
|
51
54
|
},
|
|
52
55
|
vite: {
|
|
53
56
|
devDependencies: {
|
|
54
|
-
"
|
|
55
|
-
vite: "^6.0.0",
|
|
57
|
+
vite: "^6.3.5",
|
|
56
58
|
},
|
|
57
59
|
scripts: {
|
|
58
60
|
build: "vite build",
|
|
@@ -60,11 +62,10 @@ export const buildToolPkg: Record<BuildTools, Record<string, unknown>> = {
|
|
|
60
62
|
},
|
|
61
63
|
rollup: {
|
|
62
64
|
devDependencies: {
|
|
63
|
-
"@fragno-dev/unplugin-fragno": unpluginFragnoVersion,
|
|
64
65
|
"@rollup/plugin-node-resolve": "^16.0.2",
|
|
65
66
|
"@rollup/plugin-typescript": "^12.1.4",
|
|
66
67
|
tslib: "^2.8.1",
|
|
67
|
-
rollup: "^4.
|
|
68
|
+
rollup: "^4.41.0",
|
|
68
69
|
},
|
|
69
70
|
scripts: {
|
|
70
71
|
build: "rollup -c",
|
|
@@ -72,8 +73,7 @@ export const buildToolPkg: Record<BuildTools, Record<string, unknown>> = {
|
|
|
72
73
|
},
|
|
73
74
|
webpack: {
|
|
74
75
|
devDependencies: {
|
|
75
|
-
"
|
|
76
|
-
webpack: "^5.102.0",
|
|
76
|
+
webpack: "^5.99.9",
|
|
77
77
|
"webpack-cli": "^6.0.1",
|
|
78
78
|
"ts-loader": "^9.5.1",
|
|
79
79
|
},
|
|
@@ -83,9 +83,8 @@ export const buildToolPkg: Record<BuildTools, Record<string, unknown>> = {
|
|
|
83
83
|
},
|
|
84
84
|
rspack: {
|
|
85
85
|
devDependencies: {
|
|
86
|
-
"@
|
|
87
|
-
"@rspack/
|
|
88
|
-
"@rspack/cli": "^1.5.8",
|
|
86
|
+
"@rspack/core": "^1.6.1",
|
|
87
|
+
"@rspack/cli": "^1.6.1",
|
|
89
88
|
},
|
|
90
89
|
scripts: {
|
|
91
90
|
build: "rspack build",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useFragno } from "@fragno-dev/core/react";
|
|
2
2
|
import { createExampleFragmentClients } from "..";
|
|
3
|
-
import type { FragnoPublicClientConfig } from "@fragno-dev/core";
|
|
3
|
+
import type { FragnoPublicClientConfig } from "@fragno-dev/core/client";
|
|
4
4
|
|
|
5
5
|
export function createExampleFragmentClient(config: FragnoPublicClientConfig = {}) {
|
|
6
6
|
return useFragno(createExampleFragmentClients(config));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useFragno } from "@fragno-dev/core/solid";
|
|
2
2
|
import { createExampleFragmentClients } from "..";
|
|
3
|
-
import type { FragnoPublicClientConfig } from "@fragno-dev/core";
|
|
3
|
+
import type { FragnoPublicClientConfig } from "@fragno-dev/core/client";
|
|
4
4
|
|
|
5
5
|
export function createExampleFragmentClient(config: FragnoPublicClientConfig = {}) {
|
|
6
6
|
return useFragno(createExampleFragmentClients(config));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useFragno } from "@fragno-dev/core/svelte";
|
|
2
2
|
import { createExampleFragmentClients } from "..";
|
|
3
|
-
import type { FragnoPublicClientConfig } from "@fragno-dev/core";
|
|
3
|
+
import type { FragnoPublicClientConfig } from "@fragno-dev/core/client";
|
|
4
4
|
|
|
5
5
|
export function createExampleFragmentClient(config: FragnoPublicClientConfig = {}) {
|
|
6
6
|
return useFragno(createExampleFragmentClients(config));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useFragno } from "@fragno-dev/core/vanilla";
|
|
2
2
|
import { createExampleFragmentClients } from "..";
|
|
3
|
-
import type { FragnoPublicClientConfig } from "@fragno-dev/core";
|
|
3
|
+
import type { FragnoPublicClientConfig } from "@fragno-dev/core/client";
|
|
4
4
|
|
|
5
5
|
export function createExampleFragmentClient(config: FragnoPublicClientConfig = {}) {
|
|
6
6
|
return useFragno(createExampleFragmentClients(config));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useFragno } from "@fragno-dev/core/vue";
|
|
2
2
|
import { createExampleFragmentClients } from "..";
|
|
3
|
-
import type { FragnoPublicClientConfig } from "@fragno-dev/core";
|
|
3
|
+
import type { FragnoPublicClientConfig } from "@fragno-dev/core/client";
|
|
4
4
|
|
|
5
5
|
export function createExampleFragmentClient(config: FragnoPublicClientConfig = {}) {
|
|
6
6
|
return useFragno(createExampleFragmentClients(config));
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineFragment,
|
|
3
|
-
defineRoute,
|
|
4
3
|
defineRoutes,
|
|
5
|
-
|
|
6
|
-
type FragnoPublicClientConfig,
|
|
4
|
+
instantiate,
|
|
7
5
|
type FragnoPublicConfig,
|
|
8
6
|
} from "@fragno-dev/core";
|
|
9
|
-
import { createClientBuilder } from "@fragno-dev/core/client";
|
|
7
|
+
import { createClientBuilder, type FragnoPublicClientConfig } from "@fragno-dev/core/client";
|
|
10
8
|
|
|
11
9
|
// NOTE: We use zod here for defining schemas, but any StandardSchema library can be used!
|
|
12
10
|
// For a complete list see:
|
|
@@ -17,16 +15,21 @@ export interface ExampleConfig {
|
|
|
17
15
|
initialData?: string;
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
18
|
+
const exampleFragmentDefinition = defineFragment<ExampleConfig>("example-fragment")
|
|
19
|
+
.withDependencies(({ config }) => {
|
|
20
|
+
return {
|
|
21
|
+
serverSideData: { value: config.initialData ?? "Hello World! This is a server-side data." },
|
|
22
|
+
};
|
|
23
|
+
})
|
|
24
|
+
.providesBaseService(({ deps }) => {
|
|
25
|
+
return {
|
|
26
|
+
getData: () => deps.serverSideData.value,
|
|
27
|
+
};
|
|
28
|
+
})
|
|
29
|
+
.build();
|
|
27
30
|
|
|
28
|
-
const exampleRoutesFactory = defineRoutes
|
|
29
|
-
({ deps }) => {
|
|
31
|
+
const exampleRoutesFactory = defineRoutes(exampleFragmentDefinition).create(
|
|
32
|
+
({ deps, defineRoute }) => {
|
|
30
33
|
const { serverSideData } = deps;
|
|
31
34
|
|
|
32
35
|
return [
|
|
@@ -55,23 +58,15 @@ const exampleRoutesFactory = defineRoutes<ExampleConfig, ExampleDeps, ExampleSer
|
|
|
55
58
|
},
|
|
56
59
|
);
|
|
57
60
|
|
|
58
|
-
const exampleFragmentDefinition = defineFragment<ExampleConfig>("example-fragment")
|
|
59
|
-
.withDependencies(({ config }) => {
|
|
60
|
-
return {
|
|
61
|
-
serverSideData: { value: config.initialData ?? "Hello World! This is a server-side data." },
|
|
62
|
-
};
|
|
63
|
-
})
|
|
64
|
-
.withServices(({ deps }) => {
|
|
65
|
-
return {
|
|
66
|
-
getData: () => deps.serverSideData.value,
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
|
|
70
61
|
export function createExampleFragment(
|
|
71
62
|
config: ExampleConfig = {},
|
|
72
|
-
|
|
63
|
+
options: FragnoPublicConfig = {},
|
|
73
64
|
) {
|
|
74
|
-
return
|
|
65
|
+
return instantiate(exampleFragmentDefinition)
|
|
66
|
+
.withConfig(config)
|
|
67
|
+
.withRoutes([exampleRoutesFactory])
|
|
68
|
+
.withOptions(options)
|
|
69
|
+
.build();
|
|
75
70
|
}
|
|
76
71
|
|
|
77
72
|
export function createExampleFragmentClients(fragnoConfig: FragnoPublicClientConfig) {
|
|
@@ -82,4 +77,4 @@ export function createExampleFragmentClients(fragnoConfig: FragnoPublicClientCon
|
|
|
82
77
|
useHelloMutator: b.createMutator("POST", "/hello"),
|
|
83
78
|
};
|
|
84
79
|
}
|
|
85
|
-
export type { FragnoRouteConfig } from "@fragno-dev/core
|
|
80
|
+
export type { FragnoRouteConfig } from "@fragno-dev/core";
|
|
@@ -40,7 +40,7 @@ export function createMyFragment(
|
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
For complete database documentation, see:
|
|
43
|
-
https://fragno.dev/docs/for-library-authors/database-integration/overview.md
|
|
43
|
+
https://fragno.dev/docs/fragno/for-library-authors/database-integration/overview.md
|
|
44
44
|
|
|
45
45
|
## File Structure & Core Concepts
|
|
46
46
|
|
|
@@ -96,9 +96,9 @@ client builder.
|
|
|
96
96
|
|
|
97
97
|
Each framework requires a separate client file that wraps the generic client builder with the
|
|
98
98
|
framework-specific `useFragno` hook. Check the `src/client/` directory for existing framework
|
|
99
|
-
implementations. Use the frameworks page on https://fragno.dev/docs/frameworks to
|
|
100
|
-
have their stubs defined. Make sure to include new frameworks in the exports
|
|
101
|
-
package.json.
|
|
99
|
+
implementations. Use the frameworks page on https://fragno.dev/docs/fragno/reference/frameworks to
|
|
100
|
+
see if all clients have their stubs defined. Make sure to include new frameworks in the exports
|
|
101
|
+
section of package.json.
|
|
102
102
|
|
|
103
103
|
### `package.json` - Package Configuration
|
|
104
104
|
|
|
@@ -131,17 +131,32 @@ Use `defineFragmentWithDatabase()` when your Fragment needs to:
|
|
|
131
131
|
Database schemas are defined in a separate `schema.ts` file using the Fragno schema builder:
|
|
132
132
|
|
|
133
133
|
```typescript
|
|
134
|
-
import { column, idColumn, schema } from "@fragno-dev/db/schema";
|
|
134
|
+
import { column, idColumn, referenceColumn, schema } from "@fragno-dev/db/schema";
|
|
135
135
|
|
|
136
136
|
export const noteSchema = schema((s) => {
|
|
137
|
-
return s
|
|
138
|
-
|
|
139
|
-
.addColumn("id", idColumn())
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
137
|
+
return s
|
|
138
|
+
.addTable("users", (t) => {
|
|
139
|
+
return t.addColumn("id", idColumn()).addColumn("name", column("string"));
|
|
140
|
+
})
|
|
141
|
+
.addTable("note", (t) => {
|
|
142
|
+
return t
|
|
143
|
+
.addColumn("id", idColumn()) // Auto-generated ID
|
|
144
|
+
.addColumn("content", column("string"))
|
|
145
|
+
.addColumn("userId", referenceColumn())
|
|
146
|
+
.addColumn("createdAt", column("timestamp").defaultTo$("now"))
|
|
147
|
+
.createIndex("idx_note_user", ["userId"]);
|
|
148
|
+
})
|
|
149
|
+
.addReference("author", {
|
|
150
|
+
from: {
|
|
151
|
+
table: "note",
|
|
152
|
+
column: "userId",
|
|
153
|
+
},
|
|
154
|
+
to: {
|
|
155
|
+
table: "user",
|
|
156
|
+
column: "id",
|
|
157
|
+
},
|
|
158
|
+
type: "one",
|
|
159
|
+
});
|
|
145
160
|
});
|
|
146
161
|
```
|
|
147
162
|
|
|
@@ -247,7 +262,7 @@ Fragments require code splitting between client and server bundles using
|
|
|
247
262
|
### Type Checking
|
|
248
263
|
|
|
249
264
|
```bash
|
|
250
|
-
|
|
265
|
+
pnpm run types:check
|
|
251
266
|
```
|
|
252
267
|
|
|
253
268
|
## Common Patterns
|
|
@@ -9,6 +9,7 @@ build({
|
|
|
9
9
|
"./src/client/svelte.ts",
|
|
10
10
|
"./src/client/vanilla.ts",
|
|
11
11
|
"./src/client/vue.ts",
|
|
12
|
+
"./src/client/solid.ts",
|
|
12
13
|
],
|
|
13
14
|
outdir: "./dist/browser",
|
|
14
15
|
bundle: true,
|
|
@@ -18,7 +19,7 @@ build({
|
|
|
18
19
|
splitting: true,
|
|
19
20
|
sourcemap: true,
|
|
20
21
|
plugins: [unpluginFragno({ platform: "browser" })],
|
|
21
|
-
external: ["react", "svelte", "vue", "
|
|
22
|
+
external: ["react", "svelte", "vue", "solid-js", "@fragno-dev/db"],
|
|
22
23
|
});
|
|
23
24
|
|
|
24
25
|
build({
|
|
@@ -27,8 +28,7 @@ build({
|
|
|
27
28
|
bundle: true,
|
|
28
29
|
format: "esm",
|
|
29
30
|
platform: "node",
|
|
30
|
-
target: "
|
|
31
|
+
target: "node22",
|
|
31
32
|
sourcemap: true,
|
|
32
33
|
plugins: [unpluginFragno({ platform: "node" })],
|
|
33
|
-
external: ["zod"],
|
|
34
34
|
});
|