create-fumapress 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fuma
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ export { };
package/dist/index.mjs ADDED
@@ -0,0 +1,276 @@
1
+ #!/usr/bin/env node
2
+ import { mkdir, readdir, writeFile } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { cancel, confirm, intro, isCancel, log, outro, text } from "@clack/prompts";
5
+ import { Command } from "commander";
6
+ import { x } from "tinyexec";
7
+ //#region ../create-fumapress-versions/package.json
8
+ var dependencies = {
9
+ "fumadocs-core": "^16.8.10",
10
+ "fumadocs-mdx": "^15.0.4",
11
+ "fumadocs-ui": "^16.8.10",
12
+ "fumapress": "^0.2.2",
13
+ "react": "^19.2.6",
14
+ "react-dom": "^19.2.6",
15
+ "react-server-dom-webpack": "^19.2.6",
16
+ "waku": "1.0.0-alpha.10"
17
+ };
18
+ var devDependencies = {
19
+ "@tailwindcss/vite": "^4.3.0",
20
+ "@types/mdx": "^2.0.13",
21
+ "@types/node": "^25.7.0",
22
+ "@types/react": "^19.2.14",
23
+ "@types/react-dom": "^19.2.3",
24
+ "tailwindcss": "^4.3.0",
25
+ "typescript": "^6.0.3"
26
+ };
27
+ //#endregion
28
+ //#region src/index.ts
29
+ const packageManagers = [
30
+ "npm",
31
+ "pnpm",
32
+ "yarn",
33
+ "bun"
34
+ ];
35
+ const program = new Command().name("create-fumapress").description("Initialize a Fumapress app").argument("[directory]", "directory to create the app in").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").option("--no-install", "skip dependency installation").option("--package-manager <name>", "package manager to use: npm, pnpm, yarn, or bun").parse(process.argv);
36
+ const [directory] = program.args;
37
+ const options = program.opts();
38
+ intro("create-fumapress");
39
+ const projectDirectory = options.yes ? directory ?? "my-fumapress-app" : await promptProjectDirectory(directory);
40
+ const packageManager = getPackageManager(options.packageManager);
41
+ const shouldInstall = options.yes ? options.install !== false : options.install ?? await promptInstall(packageManager);
42
+ const root = path.resolve(projectDirectory);
43
+ const name = toPackageName(path.basename(root));
44
+ await assertCanInitialize(root, Boolean(options.force));
45
+ await writeProject(root, name);
46
+ log.success(`Created ${path.relative(process.cwd(), root) || "."}`);
47
+ if (shouldInstall) await installDependencies(root, packageManager);
48
+ printNextSteps(root, packageManager, shouldInstall);
49
+ async function promptProjectDirectory(initialValue) {
50
+ return unwrapPrompt(await text({
51
+ message: "Where should the Fumapress app be created?",
52
+ placeholder: "my-fumapress-app",
53
+ initialValue,
54
+ validate(value) {
55
+ if (!value?.trim()) return "Enter a directory name.";
56
+ }
57
+ }));
58
+ }
59
+ async function promptInstall(packageManager) {
60
+ return unwrapPrompt(await confirm({
61
+ message: `Install dependencies with ${packageManager}?`,
62
+ initialValue: true
63
+ }));
64
+ }
65
+ function unwrapPrompt(value) {
66
+ if (isCancel(value)) {
67
+ cancel("Operation cancelled.");
68
+ process.exit(0);
69
+ }
70
+ return value;
71
+ }
72
+ function getPackageManager(value) {
73
+ if (value) {
74
+ if (isPackageManager(value)) return value;
75
+ cancel(`Unsupported package manager: ${value}`);
76
+ process.exit(1);
77
+ }
78
+ const detected = process.env.npm_config_user_agent?.split("/")[0];
79
+ if (detected && isPackageManager(detected)) return detected;
80
+ return "npm";
81
+ }
82
+ function isPackageManager(value) {
83
+ return packageManagers.includes(value);
84
+ }
85
+ async function assertCanInitialize(root, force) {
86
+ if (force) return;
87
+ let entries;
88
+ try {
89
+ entries = await readdir(root);
90
+ } catch (error) {
91
+ if (isNodeError(error) && error.code === "ENOENT") return;
92
+ throw error;
93
+ }
94
+ if (entries.length > 0) {
95
+ cancel(`Target directory is not empty: ${path.relative(process.cwd(), root) || "."}`);
96
+ process.exit(1);
97
+ }
98
+ }
99
+ async function writeProject(root, name) {
100
+ await Promise.all(Object.entries(getFiles(name)).map(async ([file, content]) => {
101
+ const target = path.join(root, file);
102
+ await mkdir(path.dirname(target), { recursive: true });
103
+ await writeFile(target, content);
104
+ }));
105
+ }
106
+ function getFiles(name) {
107
+ return {
108
+ ".gitignore": `.DS_Store
109
+ /node_modules/
110
+
111
+ dist
112
+ .source
113
+ src/pages.gen.ts
114
+ `,
115
+ "README.md": `# ${name}
116
+
117
+ This is a Fumapress app powered by Waku and Fumadocs.
118
+
119
+ ## Development
120
+
121
+ \`\`\`sh
122
+ npm run dev
123
+ \`\`\`
124
+ `,
125
+ "content/index.mdx": `---
126
+ title: My Page
127
+ description: Hello World
128
+ ---
129
+
130
+ # Overview
131
+
132
+ This is my first document.
133
+ `,
134
+ "package.json": `${JSON.stringify(getPackageJson(name), null, 2)}\n`,
135
+ "press.config.tsx": `import { defineConfig } from "fumapress";
136
+ import { fumadocsMdx } from "fumapress/adapters/mdx";
137
+ import { flexsearchPlugin } from "fumapress/plugins/flexsearch";
138
+ import { llmsPlugin } from "fumapress/plugins/llms.txt";
139
+ import { takumiPlugin } from "fumapress/plugins/takumi";
140
+ import { loader } from "fumadocs-core/source";
141
+ import { docs } from "./.source/server";
142
+
143
+ export default defineConfig({
144
+ loader: loader(docs.toFumadocsSource(), {
145
+ baseUrl: "/",
146
+ }),
147
+ site: {
148
+ name: "Fumapress",
149
+ },
150
+ })
151
+ .usePlugins(flexsearchPlugin(), llmsPlugin(), takumiPlugin())
152
+ .useAdapters(fumadocsMdx());
153
+ `,
154
+ "source.config.ts": `import { defineDocs } from "fumadocs-mdx/config";
155
+ import { metaSchema, pageSchema } from "fumadocs-core/source/schema";
156
+
157
+ export const docs = defineDocs({
158
+ dir: "content",
159
+ docs: {
160
+ async: true,
161
+ schema: pageSchema,
162
+ postprocess: {
163
+ includeProcessedMarkdown: true,
164
+ },
165
+ },
166
+ meta: {
167
+ schema: metaSchema,
168
+ },
169
+ });
170
+ `,
171
+ "src/app.css": `@import "tailwindcss";
172
+ @import "fumadocs-ui/css/neutral.css";
173
+ @import "fumadocs-ui/css/preset.css";
174
+ @import "fumapress/css/preset.css";
175
+ `,
176
+ "tsconfig.json": `${JSON.stringify(getTsConfig(), null, 2)}\n`,
177
+ "waku.config.ts": `import { defineConfig } from "waku/config";
178
+ import tailwindcss from "@tailwindcss/vite";
179
+ import press from "fumapress/vite";
180
+ import mdx from "fumadocs-mdx/vite";
181
+
182
+ export default defineConfig({
183
+ vite: {
184
+ plugins: [press(), mdx(), tailwindcss()],
185
+ },
186
+ });
187
+ `
188
+ };
189
+ }
190
+ function getPackageJson(name) {
191
+ return {
192
+ name,
193
+ private: true,
194
+ type: "module",
195
+ sideEffects: false,
196
+ scripts: {
197
+ dev: "waku dev",
198
+ build: "waku build",
199
+ start: "waku start",
200
+ "types:check": "fumadocs-mdx && tsc --noEmit"
201
+ },
202
+ dependencies,
203
+ devDependencies
204
+ };
205
+ }
206
+ function getTsConfig() {
207
+ return {
208
+ compilerOptions: {
209
+ target: "ES2023",
210
+ lib: [
211
+ "dom",
212
+ "dom.iterable",
213
+ "ES2023"
214
+ ],
215
+ jsx: "react-jsx",
216
+ module: "ESNext",
217
+ moduleResolution: "bundler",
218
+ resolveJsonModule: true,
219
+ allowJs: true,
220
+ checkJs: true,
221
+ esModuleInterop: true,
222
+ forceConsistentCasingInFileNames: true,
223
+ strict: true,
224
+ skipLibCheck: true,
225
+ noUncheckedIndexedAccess: true,
226
+ noEmit: true
227
+ },
228
+ exclude: ["node_modules", "dist"]
229
+ };
230
+ }
231
+ async function installDependencies(root, packageManager) {
232
+ const { command, args } = getInstallCommand(packageManager);
233
+ log.step(`Installing dependencies with ${packageManager}...`);
234
+ await x(command, args, { nodeOptions: { cwd: root } });
235
+ }
236
+ function getInstallCommand(packageManager) {
237
+ switch (packageManager) {
238
+ case "bun": return {
239
+ command: "bun",
240
+ args: ["install"]
241
+ };
242
+ case "pnpm": return {
243
+ command: "pnpm",
244
+ args: ["install"]
245
+ };
246
+ case "yarn": return {
247
+ command: "yarn",
248
+ args: ["install"]
249
+ };
250
+ case "npm": return {
251
+ command: "npm",
252
+ args: ["install"]
253
+ };
254
+ }
255
+ }
256
+ function printNextSteps(root, packageManager, installed) {
257
+ const relativeRoot = path.relative(process.cwd(), root);
258
+ const lines = ["Next steps:"];
259
+ if (relativeRoot) lines.push(` cd ${relativeRoot}`);
260
+ if (!installed) lines.push(` ${packageManager} install`);
261
+ lines.push(` ${getRunCommand(packageManager, "dev")}`);
262
+ outro(lines.join("\n"));
263
+ }
264
+ function getRunCommand(packageManager, script) {
265
+ if (packageManager === "npm") return `npm run ${script}`;
266
+ if (packageManager === "bun") return `bun run ${script}`;
267
+ return `${packageManager} ${script}`;
268
+ }
269
+ function toPackageName(value) {
270
+ return value.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "fumapress-app";
271
+ }
272
+ function isNodeError(error) {
273
+ return error instanceof Error && "code" in error;
274
+ }
275
+ //#endregion
276
+ export {};
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "create-fumapress",
3
+ "version": "0.0.1",
4
+ "description": "Initialize a Fumapress app",
5
+ "keywords": [
6
+ "Docs",
7
+ "Fumadocs"
8
+ ],
9
+ "homepage": "https://press.fumadocs.dev",
10
+ "license": "MIT",
11
+ "author": "Fuma Nama",
12
+ "repository": "github:fuma-nama/fumapress",
13
+ "bin": {
14
+ "create-fumapress": "./dist/index.mjs"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "css"
19
+ ],
20
+ "type": "module",
21
+ "sideEffects": false,
22
+ "exports": {
23
+ ".": "./dist/index.mjs",
24
+ "./package.json": "./package.json"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "dependencies": {
30
+ "@clack/prompts": "^1.4.0",
31
+ "commander": "^14.0.3",
32
+ "tinyexec": "^1.1.2"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^25.7.0",
36
+ "tsdown": "0.22.0",
37
+ "typescript": "^6.0.3"
38
+ },
39
+ "scripts": {
40
+ "dev": "tsdown --watch",
41
+ "build": "tsdown",
42
+ "types:check": "tsc --noEmit"
43
+ }
44
+ }