create-fumapress 0.1.22 → 0.1.23
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/dist/index.mjs +212 -62
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { mkdir, readdir, writeFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { cancel, confirm, intro, isCancel, log, outro, text } from "@clack/prompts";
|
|
4
|
+
import { cancel, confirm, intro, isCancel, log, outro, select, text } from "@clack/prompts";
|
|
5
5
|
import { cac } from "cac";
|
|
6
6
|
import { x } from "tinyexec";
|
|
7
|
-
|
|
7
|
+
// ../astro/package.json
|
|
8
|
+
var version$1 = "0.1.0";
|
|
9
|
+
// ../create-fumapress-versions/package.json
|
|
8
10
|
var dependencies = {
|
|
11
|
+
"@astrojs/react": "^7.1.1",
|
|
9
12
|
"@base-ui/react": "^1.8.0",
|
|
10
|
-
"fumadocs
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
+
"@fumadocs/astro": "^0.2.1",
|
|
14
|
+
"@fumapress/astro": "workspace:*",
|
|
15
|
+
"astro": "^7.4.2",
|
|
16
|
+
"fumadocs-core": "^16.18.2",
|
|
17
|
+
"fumadocs-mdx": "^15.5.1",
|
|
18
|
+
"fumadocs-ui": "npm:@fumadocs/base-ui@^16.18.2",
|
|
13
19
|
"fumapress": "workspace:*",
|
|
14
20
|
"react": "^19.3.0",
|
|
15
|
-
"react-dom": "^19.3.0"
|
|
21
|
+
"react-dom": "^19.3.0",
|
|
22
|
+
"takumi-js": "^2.14.0"
|
|
16
23
|
};
|
|
17
24
|
var devDependencies = {
|
|
18
25
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -24,19 +31,81 @@ var devDependencies = {
|
|
|
24
31
|
"typescript": "^7.0.2",
|
|
25
32
|
"vite": "^8.3.0"
|
|
26
33
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/index.ts
|
|
34
|
+
// ../fumapress/package.json
|
|
35
|
+
var version = "2.0.0";
|
|
36
|
+
// src/index.ts
|
|
32
37
|
const packageManagers = [
|
|
33
38
|
"npm",
|
|
34
39
|
"pnpm",
|
|
35
40
|
"yarn",
|
|
36
41
|
"bun"
|
|
37
42
|
];
|
|
43
|
+
const versions = {
|
|
44
|
+
...dependencies,
|
|
45
|
+
...devDependencies,
|
|
46
|
+
fumapress: version,
|
|
47
|
+
"@fumapress/astro": version$1
|
|
48
|
+
};
|
|
49
|
+
const frameworks = {
|
|
50
|
+
waku: {
|
|
51
|
+
label: "Waku",
|
|
52
|
+
scripts: {
|
|
53
|
+
dev: "fumapress dev",
|
|
54
|
+
build: "fumapress build",
|
|
55
|
+
start: "fumapress start",
|
|
56
|
+
"types:check": "tsc --noEmit"
|
|
57
|
+
},
|
|
58
|
+
dependencies: [
|
|
59
|
+
"@base-ui/react",
|
|
60
|
+
"fumadocs-core",
|
|
61
|
+
"fumadocs-mdx",
|
|
62
|
+
"fumadocs-ui",
|
|
63
|
+
"fumapress",
|
|
64
|
+
"react",
|
|
65
|
+
"react-dom"
|
|
66
|
+
],
|
|
67
|
+
devDependencies: [
|
|
68
|
+
"@tailwindcss/vite",
|
|
69
|
+
"@types/mdx",
|
|
70
|
+
"@types/node",
|
|
71
|
+
"@types/react",
|
|
72
|
+
"@types/react-dom",
|
|
73
|
+
"tailwindcss",
|
|
74
|
+
"typescript",
|
|
75
|
+
"vite"
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
astro: {
|
|
79
|
+
label: "Astro",
|
|
80
|
+
scripts: {
|
|
81
|
+
dev: "astro dev",
|
|
82
|
+
build: "astro build",
|
|
83
|
+
preview: "astro preview",
|
|
84
|
+
"types:check": "astro sync && tsc --noEmit"
|
|
85
|
+
},
|
|
86
|
+
dependencies: [
|
|
87
|
+
"@astrojs/react",
|
|
88
|
+
"@fumadocs/astro",
|
|
89
|
+
"@fumapress/astro",
|
|
90
|
+
"astro",
|
|
91
|
+
"fumadocs-core",
|
|
92
|
+
"fumadocs-ui",
|
|
93
|
+
"react",
|
|
94
|
+
"react-dom",
|
|
95
|
+
"takumi-js"
|
|
96
|
+
],
|
|
97
|
+
devDependencies: [
|
|
98
|
+
"@tailwindcss/vite",
|
|
99
|
+
"@types/mdx",
|
|
100
|
+
"@types/react",
|
|
101
|
+
"@types/react-dom",
|
|
102
|
+
"tailwindcss",
|
|
103
|
+
"typescript"
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
};
|
|
38
107
|
const cli = cac("create-fumapress");
|
|
39
|
-
cli.command("[directory]", "Initialize a Fumapress app in the given directory").option("-y, --yes", "use defaults and install dependencies").option("--force", "write files even when the target directory is not empty").option("--install", "install dependencies after scaffolding, or --no-install to skip").option("--package-manager <name>", "package manager to use: npm, pnpm, yarn, or bun").action(create);
|
|
108
|
+
cli.command("[directory]", "Initialize a Fumapress app in the given directory").option("-y, --yes", "use defaults and install dependencies").option("--framework <name>", "framework to use: waku or astro").option("--force", "write files even when the target directory is not empty").option("--install", "install dependencies after scaffolding, or --no-install to skip").option("--package-manager <name>", "package manager to use: npm, pnpm, yarn, or bun").action(create);
|
|
40
109
|
cli.help((sections) => sections.filter((section) => !section.title?.startsWith("For more info")));
|
|
41
110
|
try {
|
|
42
111
|
cli.parse();
|
|
@@ -47,12 +116,13 @@ try {
|
|
|
47
116
|
async function create(directory, options) {
|
|
48
117
|
intro("create-fumapress");
|
|
49
118
|
const projectDirectory = options.yes ? directory ?? "my-fumapress-app" : await promptProjectDirectory(directory);
|
|
119
|
+
const framework = await getFramework(options);
|
|
50
120
|
const packageManager = getPackageManager(options.packageManager);
|
|
51
121
|
const shouldInstall = options.yes ? options.install !== false : options.install ?? await promptInstall(packageManager);
|
|
52
122
|
const root = path.resolve(projectDirectory);
|
|
53
123
|
const name = toPackageName(path.basename(root));
|
|
54
124
|
await assertCanInitialize(root, Boolean(options.force));
|
|
55
|
-
await writeProject(root, name, packageManager);
|
|
125
|
+
await writeProject(root, framework, name, packageManager);
|
|
56
126
|
log.success(`Created ${path.relative(process.cwd(), root) || "."}`);
|
|
57
127
|
if (shouldInstall) await installDependencies(root, packageManager);
|
|
58
128
|
printNextSteps(root, packageManager, shouldInstall);
|
|
@@ -67,6 +137,24 @@ async function promptProjectDirectory(initialValue) {
|
|
|
67
137
|
}
|
|
68
138
|
}));
|
|
69
139
|
}
|
|
140
|
+
async function getFramework({ framework, yes }) {
|
|
141
|
+
if (framework) {
|
|
142
|
+
if (isFramework(framework)) return framework;
|
|
143
|
+
cancel(`Unsupported framework: ${framework}`);
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
if (yes) return "waku";
|
|
147
|
+
return unwrapPrompt(await select({
|
|
148
|
+
message: "Which framework should the app use?",
|
|
149
|
+
options: Object.entries(frameworks).map(([value, { label }]) => ({
|
|
150
|
+
value,
|
|
151
|
+
label
|
|
152
|
+
}))
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
function isFramework(value) {
|
|
156
|
+
return Object.hasOwn(frameworks, value);
|
|
157
|
+
}
|
|
70
158
|
async function promptInstall(packageManager) {
|
|
71
159
|
return unwrapPrompt(await confirm({
|
|
72
160
|
message: `Install dependencies with ${packageManager}?`,
|
|
@@ -107,24 +195,15 @@ async function assertCanInitialize(root, force) {
|
|
|
107
195
|
process.exit(1);
|
|
108
196
|
}
|
|
109
197
|
}
|
|
110
|
-
async function writeProject(root, name, packageManager) {
|
|
111
|
-
await Promise.all(Object.entries(getFiles(name, packageManager)).map(async ([file, content]) => {
|
|
198
|
+
async function writeProject(root, framework, name, packageManager) {
|
|
199
|
+
await Promise.all(Object.entries(getFiles(framework, name, packageManager)).map(async ([file, content]) => {
|
|
112
200
|
const target = path.join(root, file);
|
|
113
201
|
await mkdir(path.dirname(target), { recursive: true });
|
|
114
202
|
await writeFile(target, content);
|
|
115
203
|
}));
|
|
116
204
|
}
|
|
117
|
-
function getFiles(name, packageManager) {
|
|
205
|
+
function getFiles(framework, name, packageManager) {
|
|
118
206
|
const files = {
|
|
119
|
-
".gitignore": `.DS_Store
|
|
120
|
-
/node_modules/
|
|
121
|
-
|
|
122
|
-
.env
|
|
123
|
-
.env.local
|
|
124
|
-
dist
|
|
125
|
-
.source
|
|
126
|
-
src/pages.gen.ts
|
|
127
|
-
`,
|
|
128
207
|
"README.md": `# ${name}
|
|
129
208
|
|
|
130
209
|
This is a Fumapress app powered by Fumadocs.
|
|
@@ -140,14 +219,91 @@ title: My Page
|
|
|
140
219
|
description: Hello World
|
|
141
220
|
---
|
|
142
221
|
|
|
143
|
-
|
|
222
|
+
## Overview
|
|
144
223
|
|
|
145
224
|
This is my first document.
|
|
146
225
|
`,
|
|
147
|
-
"package.json": `${JSON.stringify(getPackageJson(name), null, 2)}\n
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
226
|
+
"package.json": `${JSON.stringify(getPackageJson(framework, name), null, 2)}\n`
|
|
227
|
+
};
|
|
228
|
+
if (framework === "astro") return Object.assign(files, {
|
|
229
|
+
".gitignore": `.DS_Store
|
|
230
|
+
/node_modules/
|
|
231
|
+
|
|
232
|
+
.env
|
|
233
|
+
.env.local
|
|
234
|
+
dist
|
|
235
|
+
.astro
|
|
236
|
+
`,
|
|
237
|
+
"content/meta.json": `{
|
|
238
|
+
"pages": ["..."]
|
|
239
|
+
}
|
|
240
|
+
`,
|
|
241
|
+
"astro.config.mjs": `// @ts-check
|
|
242
|
+
import { defineConfig } from "astro/config";
|
|
243
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
244
|
+
import press from "@fumapress/astro";
|
|
245
|
+
|
|
246
|
+
export default defineConfig({
|
|
247
|
+
// the URL where your site is deployed, needed for SEO features like sitemap:
|
|
248
|
+
// site: "https://example.com",
|
|
249
|
+
integrations: [
|
|
250
|
+
press({
|
|
251
|
+
collections: { docs: { dir: "content" } },
|
|
252
|
+
lastModified: true,
|
|
253
|
+
includeProcessedMarkdown: true,
|
|
254
|
+
}),
|
|
255
|
+
],
|
|
256
|
+
vite: {
|
|
257
|
+
plugins: [tailwindcss()],
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
`,
|
|
261
|
+
"press.config.tsx": `import { getCollection } from "astro:content";
|
|
262
|
+
import { toFumadocsSource } from "@fumadocs/astro/source";
|
|
263
|
+
import { createPress } from "@fumapress/astro/config";
|
|
264
|
+
|
|
265
|
+
export default createPress(
|
|
266
|
+
toFumadocsSource(await getCollection("docs"), await getCollection("meta")),
|
|
267
|
+
).config({
|
|
268
|
+
site: {
|
|
269
|
+
name: ${JSON.stringify(name)},
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
`,
|
|
273
|
+
"src/app.css": `@import "@fumapress/astro/css/default.css";
|
|
274
|
+
`,
|
|
275
|
+
"src/content.config.ts": `import { defineCollection } from "astro:content";
|
|
276
|
+
import { metaLoader, pageLoader } from "@fumadocs/astro/loaders";
|
|
277
|
+
|
|
278
|
+
export const collections = {
|
|
279
|
+
docs: defineCollection({ loader: pageLoader() }),
|
|
280
|
+
meta: defineCollection({ loader: metaLoader() }),
|
|
281
|
+
};
|
|
282
|
+
`,
|
|
283
|
+
"tsconfig.json": `{
|
|
284
|
+
"extends": "astro/tsconfigs/strict",
|
|
285
|
+
"include": [".astro/types.d.ts", "**/*"],
|
|
286
|
+
"exclude": ["dist"],
|
|
287
|
+
"compilerOptions": {
|
|
288
|
+
"jsx": "react-jsx",
|
|
289
|
+
"jsxImportSource": "react",
|
|
290
|
+
"paths": { "@/*": ["./src/*"] }
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
`
|
|
294
|
+
});
|
|
295
|
+
Object.assign(files, {
|
|
296
|
+
".gitignore": `.DS_Store
|
|
297
|
+
/node_modules/
|
|
298
|
+
|
|
299
|
+
.env
|
|
300
|
+
.env.local
|
|
301
|
+
dist
|
|
302
|
+
.source
|
|
303
|
+
src/pages.gen.ts
|
|
304
|
+
`,
|
|
305
|
+
"press.config.tsx": `import { createPress } from "fumapress";
|
|
306
|
+
import { metaSchema, pageSchema } from "fumapress/schema";
|
|
151
307
|
import { defineDocs } from "fumadocs-mdx/macro";
|
|
152
308
|
|
|
153
309
|
const docs = defineDocs({
|
|
@@ -165,29 +321,24 @@ const docs = defineDocs({
|
|
|
165
321
|
},
|
|
166
322
|
});
|
|
167
323
|
|
|
168
|
-
export default
|
|
169
|
-
content: docs.toFumadocsSource(),
|
|
324
|
+
export default createPress(docs.toFumadocsSource()).config({
|
|
170
325
|
site: {
|
|
171
326
|
name: ${JSON.stringify(name)},
|
|
172
327
|
// the URL where your site is deployed, needed for SEO features like sitemap:
|
|
173
328
|
// baseUrl: "https://example.com",
|
|
174
329
|
},
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
/>
|
|
185
|
-
</>
|
|
186
|
-
);
|
|
330
|
+
head: [
|
|
331
|
+
{ tag: "link", attrs: { rel: "preconnect", href: "https://fonts.googleapis.com" } },
|
|
332
|
+
{ tag: "link", attrs: { rel: "preconnect", href: "https://fonts.gstatic.com", crossorigin: "" } },
|
|
333
|
+
{
|
|
334
|
+
tag: "link",
|
|
335
|
+
attrs: {
|
|
336
|
+
rel: "stylesheet",
|
|
337
|
+
href: "https://fonts.googleapis.com/css2?family=Geist:ital,wght@0,100..900;1,100..900&family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap",
|
|
338
|
+
},
|
|
187
339
|
},
|
|
188
|
-
|
|
189
|
-
})
|
|
190
|
-
.adapters(fumadocsMdx());
|
|
340
|
+
],
|
|
341
|
+
});
|
|
191
342
|
`,
|
|
192
343
|
"src/app.css": `@import "tailwindcss";
|
|
193
344
|
@import "fumadocs-ui/css/neutral.css";
|
|
@@ -209,31 +360,29 @@ export default defineConfig({
|
|
|
209
360
|
plugins: [press(), fumadocsMdx(), tailwindcss()],
|
|
210
361
|
});
|
|
211
362
|
`
|
|
212
|
-
};
|
|
363
|
+
});
|
|
213
364
|
if (packageManager === "pnpm") files["pnpm-workspace.yaml"] = `allowBuilds:
|
|
214
365
|
esbuild: false
|
|
215
366
|
`;
|
|
216
367
|
return files;
|
|
217
368
|
}
|
|
218
|
-
function getPackageJson(name) {
|
|
369
|
+
function getPackageJson(framework, name) {
|
|
370
|
+
const { scripts, dependencies, devDependencies } = frameworks[framework];
|
|
219
371
|
return {
|
|
220
372
|
name,
|
|
221
373
|
private: true,
|
|
222
374
|
type: "module",
|
|
223
375
|
sideEffects: false,
|
|
224
|
-
scripts
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
start: "fumapress start",
|
|
228
|
-
"types:check": "tsc --noEmit"
|
|
229
|
-
},
|
|
230
|
-
dependencies: {
|
|
231
|
-
...dependencies,
|
|
232
|
-
fumapress: version
|
|
233
|
-
},
|
|
234
|
-
devDependencies
|
|
376
|
+
scripts,
|
|
377
|
+
dependencies: getVersions(dependencies),
|
|
378
|
+
devDependencies: getVersions(devDependencies)
|
|
235
379
|
};
|
|
236
380
|
}
|
|
381
|
+
function getVersions(names) {
|
|
382
|
+
const out = {};
|
|
383
|
+
for (const name of names) out[name] = versions[name];
|
|
384
|
+
return out;
|
|
385
|
+
}
|
|
237
386
|
function getTsConfig() {
|
|
238
387
|
return {
|
|
239
388
|
compilerOptions: {
|
|
@@ -254,7 +403,9 @@ function getTsConfig() {
|
|
|
254
403
|
strict: true,
|
|
255
404
|
skipLibCheck: true,
|
|
256
405
|
noUncheckedIndexedAccess: true,
|
|
257
|
-
noEmit: true
|
|
406
|
+
noEmit: true,
|
|
407
|
+
types: ["node", "vite/client"],
|
|
408
|
+
paths: { "@/*": ["./src/*"] }
|
|
258
409
|
},
|
|
259
410
|
exclude: ["node_modules", "dist"]
|
|
260
411
|
};
|
|
@@ -303,5 +454,4 @@ function toPackageName(value) {
|
|
|
303
454
|
function isNodeError(error) {
|
|
304
455
|
return error instanceof Error && "code" in error;
|
|
305
456
|
}
|
|
306
|
-
//#endregion
|
|
307
457
|
export {};
|