@fedify/init 2.0.0-dev.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/LICENSE +20 -0
- package/README.md +93 -0
- package/dist/action/configs.mjs +89 -0
- package/dist/action/const.mjs +7 -0
- package/dist/action/deps.mjs +50 -0
- package/dist/action/dir.mjs +13 -0
- package/dist/action/env.mjs +10 -0
- package/dist/action/install.mjs +17 -0
- package/dist/action/mod.d.mts +23 -0
- package/dist/action/mod.mjs +38 -0
- package/dist/action/notice.mjs +52 -0
- package/dist/action/patch.mjs +143 -0
- package/dist/action/precommand.mjs +25 -0
- package/dist/action/recommend.mjs +21 -0
- package/dist/action/set.mjs +28 -0
- package/dist/action/templates.mjs +55 -0
- package/dist/action/utils.mjs +47 -0
- package/dist/ask/dir.mjs +79 -0
- package/dist/ask/kv.mjs +41 -0
- package/dist/ask/mod.mjs +13 -0
- package/dist/ask/mq.mjs +43 -0
- package/dist/ask/pm.mjs +49 -0
- package/dist/ask/wf.mjs +26 -0
- package/dist/command.d.mts +41 -0
- package/dist/command.mjs +44 -0
- package/dist/const.d.mts +4 -0
- package/dist/const.mjs +34 -0
- package/dist/deno.mjs +5 -0
- package/dist/json/biome.json +14 -0
- package/dist/json/biome.mjs +14 -0
- package/dist/json/db-to-check.json +17 -0
- package/dist/json/db-to-check.mjs +21 -0
- package/dist/json/kv.json +39 -0
- package/dist/json/kv.mjs +47 -0
- package/dist/json/mq.json +95 -0
- package/dist/json/mq.mjs +65 -0
- package/dist/json/pm.json +47 -0
- package/dist/json/pm.mjs +36 -0
- package/dist/json/rt.json +42 -0
- package/dist/json/rt.mjs +31 -0
- package/dist/json/vscode-settings-for-deno.json +43 -0
- package/dist/json/vscode-settings-for-deno.mjs +39 -0
- package/dist/json/vscode-settings.json +41 -0
- package/dist/json/vscode-settings.mjs +37 -0
- package/dist/lib.mjs +129 -0
- package/dist/mod.d.mts +3 -0
- package/dist/mod.mjs +4 -0
- package/dist/templates/defaults/eslint.config.ts.tpl +3 -0
- package/dist/templates/defaults/federation.ts.tpl +24 -0
- package/dist/templates/defaults/logging.ts.tpl +23 -0
- package/dist/templates/elysia/index/bun.ts.tpl +13 -0
- package/dist/templates/elysia/index/deno.ts.tpl +19 -0
- package/dist/templates/elysia/index/node.ts.tpl +14 -0
- package/dist/templates/express/app.ts.tpl +16 -0
- package/dist/templates/express/index.ts.tpl +6 -0
- package/dist/templates/hono/app.tsx.tpl +14 -0
- package/dist/templates/hono/index/bun.ts.tpl +10 -0
- package/dist/templates/hono/index/deno.ts.tpl +13 -0
- package/dist/templates/hono/index/node.ts.tpl +14 -0
- package/dist/templates/next/middleware.ts.tpl +45 -0
- package/dist/templates/nitro/.env.test.tpl +1 -0
- package/dist/templates/nitro/nitro.config.ts.tpl +14 -0
- package/dist/templates/nitro/server/error.ts.tpl +3 -0
- package/dist/templates/nitro/server/middleware/federation.ts.tpl +8 -0
- package/dist/test/action.mjs +15 -0
- package/dist/test/create.mjs +92 -0
- package/dist/test/db.mjs +42 -0
- package/dist/test/fill.mjs +29 -0
- package/dist/test/lookup.mjs +183 -0
- package/dist/test/mod.d.mts +1 -0
- package/dist/test/mod.mjs +16 -0
- package/dist/test/run.mjs +22 -0
- package/dist/test/utils.mjs +15 -0
- package/dist/types.d.mts +50 -0
- package/dist/utils.d.mts +9 -0
- package/dist/utils.mjs +102 -0
- package/dist/webframeworks.mjs +220 -0
- package/package.json +66 -0
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { InitCommand } from "./command.mjs";
|
|
2
|
+
import { PACKAGE_MANAGER } from "./const.mjs";
|
|
3
|
+
import { RequiredNotNull } from "./utils.mjs";
|
|
4
|
+
import { Message } from "@optique/core";
|
|
5
|
+
|
|
6
|
+
//#region src/types.d.ts
|
|
7
|
+
type PackageManager = typeof PACKAGE_MANAGER[number];
|
|
8
|
+
interface WebFrameworkInitializer {
|
|
9
|
+
command?: string[];
|
|
10
|
+
dependencies?: object;
|
|
11
|
+
devDependencies?: object;
|
|
12
|
+
federationFile: string;
|
|
13
|
+
loggingFile: string;
|
|
14
|
+
files?: Record<string, string>;
|
|
15
|
+
compilerOptions?: Record<string, string | boolean | number | string[] | null>;
|
|
16
|
+
tasks?: Record<string, string>;
|
|
17
|
+
instruction: Message;
|
|
18
|
+
}
|
|
19
|
+
interface MessageQueueDescription {
|
|
20
|
+
label: string;
|
|
21
|
+
packageManagers: readonly PackageManager[];
|
|
22
|
+
dependencies?: Record<string, string>;
|
|
23
|
+
devDependencies?: Record<string, string>;
|
|
24
|
+
imports: Record<string, Record<string, string>>;
|
|
25
|
+
object: string;
|
|
26
|
+
denoUnstable?: string[];
|
|
27
|
+
env?: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
interface KvStoreDescription {
|
|
30
|
+
label: string;
|
|
31
|
+
packageManagers: readonly PackageManager[];
|
|
32
|
+
dependencies?: Record<string, string>;
|
|
33
|
+
devDependencies?: Record<string, string>;
|
|
34
|
+
imports: Record<string, Record<string, string>>;
|
|
35
|
+
object: string;
|
|
36
|
+
denoUnstable?: string[];
|
|
37
|
+
env?: Record<string, string>;
|
|
38
|
+
}
|
|
39
|
+
type InitCommandOptions = RequiredNotNull<InitCommand> & {
|
|
40
|
+
readonly testMode: boolean;
|
|
41
|
+
};
|
|
42
|
+
interface InitCommandData extends InitCommandOptions {
|
|
43
|
+
readonly projectName: string;
|
|
44
|
+
readonly initializer: WebFrameworkInitializer;
|
|
45
|
+
readonly kv: KvStoreDescription;
|
|
46
|
+
readonly mq: MessageQueueDescription;
|
|
47
|
+
readonly env: Record<string, string>;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { InitCommandData };
|
package/dist/utils.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { message } from "@optique/core";
|
|
2
|
+
import "chalk";
|
|
3
|
+
import { toMerged } from "es-toolkit";
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
|
|
6
|
+
//#region src/utils.d.ts
|
|
7
|
+
type RequiredNotNull<T> = { [P in keyof T]: NonNullable<T[P]> };
|
|
8
|
+
//#endregion
|
|
9
|
+
export { RequiredNotNull };
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { isObject } from "@fxts/core";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { print, printError } from "@optique/run";
|
|
4
|
+
import { message } from "@optique/core";
|
|
5
|
+
import { Chalk } from "chalk";
|
|
6
|
+
import { flow, toMerged } from "es-toolkit";
|
|
7
|
+
import { spawn } from "node:child_process";
|
|
8
|
+
|
|
9
|
+
//#region src/utils.ts
|
|
10
|
+
const colorEnabled = process.stdout.isTTY && !("NO_COLOR" in process.env && process.env.NO_COLOR !== "");
|
|
11
|
+
const colors = new Chalk(colorEnabled ? {} : { level: 0 });
|
|
12
|
+
const isPromise = (value) => value instanceof Promise;
|
|
13
|
+
function set(key, f) {
|
|
14
|
+
return ((obj) => {
|
|
15
|
+
const result = f(obj);
|
|
16
|
+
if (isPromise(result)) return result.then((value) => ({
|
|
17
|
+
...obj,
|
|
18
|
+
[key]: value
|
|
19
|
+
}));
|
|
20
|
+
return {
|
|
21
|
+
...obj,
|
|
22
|
+
[key]: result
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const merge$1 = (source = {}) => (target = {}) => toMerged(target, source);
|
|
27
|
+
const replace = (pattern, replacement) => (text$1) => text$1.replace(pattern, replacement);
|
|
28
|
+
const replaceAll = (pattern, replacement) => (text$1) => text$1.replaceAll(pattern, replacement);
|
|
29
|
+
const formatJson = (obj) => JSON.stringify(obj, null, 2) + "\n";
|
|
30
|
+
const notEmpty = (s) => s.length > 0;
|
|
31
|
+
const isNotFoundError = (e) => isObject(e) && "code" in e && e.code === "ENOENT";
|
|
32
|
+
var CommandError = class extends Error {
|
|
33
|
+
commandLine;
|
|
34
|
+
constructor(message$1, stdout, stderr, code, command$1) {
|
|
35
|
+
super(message$1);
|
|
36
|
+
this.stdout = stdout;
|
|
37
|
+
this.stderr = stderr;
|
|
38
|
+
this.code = code;
|
|
39
|
+
this.command = command$1;
|
|
40
|
+
this.name = "CommandError";
|
|
41
|
+
this.commandLine = command$1.join(" ");
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const runSubCommand = async (command$1, options) => {
|
|
45
|
+
const commands = command$1.reduce((acc, cur) => {
|
|
46
|
+
if (cur === "&&") acc.push([]);
|
|
47
|
+
else {
|
|
48
|
+
if (acc.length === 0) acc.push([]);
|
|
49
|
+
acc[acc.length - 1].push(cur);
|
|
50
|
+
}
|
|
51
|
+
return acc;
|
|
52
|
+
}, []);
|
|
53
|
+
const results = {
|
|
54
|
+
stdout: "",
|
|
55
|
+
stderr: ""
|
|
56
|
+
};
|
|
57
|
+
for (const cmd of commands) try {
|
|
58
|
+
const result = await runSingularCommand(cmd, options);
|
|
59
|
+
results.stdout += (results.stdout ? "\n" : "") + result.stdout;
|
|
60
|
+
results.stderr += (results.stderr ? "\n" : "") + result.stderr;
|
|
61
|
+
} catch (error) {
|
|
62
|
+
if (error instanceof CommandError) {
|
|
63
|
+
results.stdout += (results.stdout ? "\n" : "") + error.stdout;
|
|
64
|
+
results.stderr += (results.stderr ? "\n" : "") + error.stderr;
|
|
65
|
+
}
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
return results;
|
|
69
|
+
};
|
|
70
|
+
const runSingularCommand = (command$1, options) => new Promise((resolve, reject) => {
|
|
71
|
+
let stdout = "";
|
|
72
|
+
let stderr = "";
|
|
73
|
+
const child = spawn(command$1[0], command$1.slice(1), options);
|
|
74
|
+
child.stdout?.on("data", (data) => {
|
|
75
|
+
stdout += data.toString();
|
|
76
|
+
});
|
|
77
|
+
child.stderr?.on("data", (data) => {
|
|
78
|
+
stderr += data.toString();
|
|
79
|
+
});
|
|
80
|
+
child.on("close", (code) => {
|
|
81
|
+
if (code === 0) resolve({
|
|
82
|
+
stdout: stdout.trim(),
|
|
83
|
+
stderr: stderr.trim()
|
|
84
|
+
});
|
|
85
|
+
else reject(new CommandError(`Command exited with code ${code ?? "unknown"}`, stdout.trim(), stderr.trim(), code ?? -1, command$1));
|
|
86
|
+
});
|
|
87
|
+
child.on("error", (error) => {
|
|
88
|
+
reject(error);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
const getCwd = () => process.cwd();
|
|
92
|
+
const getOsType = () => process.platform;
|
|
93
|
+
const exit = (code) => process.exit(code);
|
|
94
|
+
function* product(...[head, ...tail]) {
|
|
95
|
+
if (!head) yield [];
|
|
96
|
+
else for (const x of head) for (const xs of product(...tail)) yield [x, ...xs];
|
|
97
|
+
}
|
|
98
|
+
const printMessage = flow(message, print);
|
|
99
|
+
const printErrorMessage = flow(message, printError);
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
export { CommandError, colors, exit, formatJson, getCwd, getOsType, isNotFoundError, merge$1 as merge, notEmpty, printErrorMessage, printMessage, product, replace, replaceAll, runSubCommand, set };
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { replace } from "./utils.mjs";
|
|
2
|
+
import { PACKAGE_VERSION, getInstruction, getNextInitCommand, getNitroInitCommand, packageManagerToRuntime, readTemplate } from "./lib.mjs";
|
|
3
|
+
import { PACKAGE_MANAGER } from "./const.mjs";
|
|
4
|
+
import { pipe } from "@fxts/core";
|
|
5
|
+
|
|
6
|
+
//#region src/webframeworks.ts
|
|
7
|
+
const webFrameworks = {
|
|
8
|
+
hono: {
|
|
9
|
+
label: "Hono",
|
|
10
|
+
packageManagers: PACKAGE_MANAGER,
|
|
11
|
+
init: ({ projectName, packageManager: pm }) => ({
|
|
12
|
+
dependencies: pm === "deno" ? {
|
|
13
|
+
...defaultDenoDependencies,
|
|
14
|
+
"@std/dotenv": "^0.225.2",
|
|
15
|
+
"@hono/hono": "^4.5.0",
|
|
16
|
+
"@hongminhee/x-forwarded-fetch": "^0.2.0",
|
|
17
|
+
"@fedify/hono": PACKAGE_VERSION
|
|
18
|
+
} : pm === "bun" ? {
|
|
19
|
+
hono: "^4.5.0",
|
|
20
|
+
"x-forwarded-fetch": "^0.2.0",
|
|
21
|
+
"@fedify/hono": PACKAGE_VERSION
|
|
22
|
+
} : {
|
|
23
|
+
"@dotenvx/dotenvx": "^1.14.1",
|
|
24
|
+
hono: "^4.5.0",
|
|
25
|
+
"@hono/node-server": "^1.12.0",
|
|
26
|
+
tsx: "^4.17.0",
|
|
27
|
+
"x-forwarded-fetch": "^0.2.0",
|
|
28
|
+
"@fedify/hono": PACKAGE_VERSION
|
|
29
|
+
},
|
|
30
|
+
devDependencies: {
|
|
31
|
+
...defaultDevDependencies,
|
|
32
|
+
...pm === "bun" ? { "@types/bun": "^1.1.6" } : {}
|
|
33
|
+
},
|
|
34
|
+
federationFile: "src/federation.ts",
|
|
35
|
+
loggingFile: "src/logging.ts",
|
|
36
|
+
files: {
|
|
37
|
+
"src/app.tsx": pipe("hono/app.tsx", readTemplate, replace(/\/\* hono \*\//, pm === "deno" ? "@hono/hono" : "hono"), replace(/\/\* logger \*\//, projectName)),
|
|
38
|
+
"src/index.ts": readTemplate(`hono/index/${packageManagerToRuntime(pm)}.ts`),
|
|
39
|
+
...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
|
|
40
|
+
},
|
|
41
|
+
compilerOptions: pm === "deno" ? void 0 : {
|
|
42
|
+
"lib": ["ESNext", "DOM"],
|
|
43
|
+
"target": "ESNext",
|
|
44
|
+
"module": "NodeNext",
|
|
45
|
+
"moduleResolution": "NodeNext",
|
|
46
|
+
"allowImportingTsExtensions": true,
|
|
47
|
+
"verbatimModuleSyntax": true,
|
|
48
|
+
"noEmit": true,
|
|
49
|
+
"strict": true,
|
|
50
|
+
"jsx": "react-jsx",
|
|
51
|
+
"jsxImportSource": "hono/jsx"
|
|
52
|
+
},
|
|
53
|
+
tasks: {
|
|
54
|
+
"dev": pm === "deno" ? "deno run -A --watch ./src/index.ts" : pm === "bun" ? "bun run --hot ./src/index.ts" : "dotenvx run -- tsx watch ./src/index.ts",
|
|
55
|
+
"prod": pm === "deno" ? "deno run -A ./src/index.ts" : pm === "bun" ? "bun run ./src/index.ts" : "dotenvx run -- node --import tsx ./src/index.ts",
|
|
56
|
+
...pm !== "deno" ? { "lint": "eslint ." } : {}
|
|
57
|
+
},
|
|
58
|
+
instruction: getInstruction(pm, 8e3)
|
|
59
|
+
}),
|
|
60
|
+
defaultPort: 8e3
|
|
61
|
+
},
|
|
62
|
+
elysia: {
|
|
63
|
+
label: "ElysiaJS",
|
|
64
|
+
packageManagers: PACKAGE_MANAGER,
|
|
65
|
+
init: ({ projectName, packageManager: pm }) => ({
|
|
66
|
+
dependencies: pm === "deno" ? {
|
|
67
|
+
...defaultDenoDependencies,
|
|
68
|
+
elysia: "npm:elysia@^1.3.6",
|
|
69
|
+
"@fedify/elysia": PACKAGE_VERSION
|
|
70
|
+
} : pm === "bun" ? {
|
|
71
|
+
elysia: "^1.3.6",
|
|
72
|
+
"@fedify/elysia": PACKAGE_VERSION
|
|
73
|
+
} : {
|
|
74
|
+
elysia: "^1.3.6",
|
|
75
|
+
"@elysiajs/node": "^1.4.2",
|
|
76
|
+
"@fedify/elysia": PACKAGE_VERSION,
|
|
77
|
+
...pm === "pnpm" ? {
|
|
78
|
+
"@sinclair/typebox": "^0.34.41",
|
|
79
|
+
"openapi-types": "^12.1.3"
|
|
80
|
+
} : {}
|
|
81
|
+
},
|
|
82
|
+
devDependencies: {
|
|
83
|
+
...pm === "bun" ? { "@types/bun": "^1.2.19" } : {
|
|
84
|
+
tsx: "^4.21.0",
|
|
85
|
+
"@types/node": "^25.0.3",
|
|
86
|
+
typescript: "^5.9.3"
|
|
87
|
+
},
|
|
88
|
+
...defaultDevDependencies
|
|
89
|
+
},
|
|
90
|
+
federationFile: "src/federation.ts",
|
|
91
|
+
loggingFile: "src/logging.ts",
|
|
92
|
+
files: {
|
|
93
|
+
"src/index.ts": readTemplate(`elysia/index/${packageManagerToRuntime(pm)}.ts`).replace(/\/\* logger \*\//, projectName),
|
|
94
|
+
...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
|
|
95
|
+
},
|
|
96
|
+
compilerOptions: pm === "deno" || pm === "bun" ? void 0 : {
|
|
97
|
+
"lib": ["ESNext", "DOM"],
|
|
98
|
+
"target": "ESNext",
|
|
99
|
+
"module": "NodeNext",
|
|
100
|
+
"moduleResolution": "NodeNext",
|
|
101
|
+
"allowImportingTsExtensions": true,
|
|
102
|
+
"verbatimModuleSyntax": true,
|
|
103
|
+
"noEmit": true,
|
|
104
|
+
"strict": true
|
|
105
|
+
},
|
|
106
|
+
tasks: {
|
|
107
|
+
"dev": pm === "deno" ? "deno serve --allow-env --allow-net --watch ./src/index.ts" : pm === "bun" ? "bun run --hot ./src/index.ts" : "tsx watch src/index.ts",
|
|
108
|
+
...pm === "deno" ? { "prod": "deno serve --allow-env --allow-net ./src/index.ts" } : pm === "bun" ? { "prod": "bun run ./src/index.ts" } : {
|
|
109
|
+
"build": "tsc src/index.ts --outDir dist",
|
|
110
|
+
"start": "NODE_ENV=production node dist/index.js"
|
|
111
|
+
},
|
|
112
|
+
...pm !== "deno" ? { "lint": "eslint ." } : {}
|
|
113
|
+
},
|
|
114
|
+
instruction: getInstruction(pm, 3e3)
|
|
115
|
+
}),
|
|
116
|
+
defaultPort: 3e3
|
|
117
|
+
},
|
|
118
|
+
express: {
|
|
119
|
+
label: "Express",
|
|
120
|
+
packageManagers: PACKAGE_MANAGER,
|
|
121
|
+
init: ({ projectName, packageManager: pm }) => ({
|
|
122
|
+
dependencies: {
|
|
123
|
+
"npm:express": "^4.19.2",
|
|
124
|
+
"@fedify/express": PACKAGE_VERSION,
|
|
125
|
+
...pm !== "deno" && pm !== "bun" ? {
|
|
126
|
+
"@dotenvx/dotenvx": "^1.14.1",
|
|
127
|
+
tsx: "^4.17.0"
|
|
128
|
+
} : {},
|
|
129
|
+
...pm === "deno" ? defaultDenoDependencies : {}
|
|
130
|
+
},
|
|
131
|
+
devDependencies: {
|
|
132
|
+
"@types/express": "^4.17.21",
|
|
133
|
+
...pm === "bun" ? { "@types/bun": "^1.1.6" } : {},
|
|
134
|
+
...defaultDevDependencies
|
|
135
|
+
},
|
|
136
|
+
federationFile: "src/federation.ts",
|
|
137
|
+
loggingFile: "src/logging.ts",
|
|
138
|
+
files: {
|
|
139
|
+
"src/app.ts": readTemplate("express/app.ts").replace(/\/\* logger \*\//, projectName),
|
|
140
|
+
"src/index.ts": readTemplate("express/index.ts"),
|
|
141
|
+
...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
|
|
142
|
+
},
|
|
143
|
+
compilerOptions: pm === "deno" ? void 0 : {
|
|
144
|
+
"lib": ["ESNext", "DOM"],
|
|
145
|
+
"target": "ESNext",
|
|
146
|
+
"module": "NodeNext",
|
|
147
|
+
"moduleResolution": "NodeNext",
|
|
148
|
+
"allowImportingTsExtensions": true,
|
|
149
|
+
"verbatimModuleSyntax": true,
|
|
150
|
+
"noEmit": true,
|
|
151
|
+
"strict": true
|
|
152
|
+
},
|
|
153
|
+
tasks: {
|
|
154
|
+
"dev": pm === "bun" ? "bun run --hot ./src/index.ts" : pm === "deno" ? "deno run --allow-net --allow-env --allow-sys --watch ./src/index.ts" : "dotenvx run -- tsx watch ./src/index.ts",
|
|
155
|
+
"prod": pm === "bun" ? "bun run ./src/index.ts" : pm === "deno" ? "deno run --allow-net --allow-env --allow-sys ./src/index.ts" : "dotenvx run -- node --import tsx ./src/index.ts",
|
|
156
|
+
...pm !== "deno" ? { "lint": "eslint ." } : {}
|
|
157
|
+
},
|
|
158
|
+
instruction: getInstruction(pm, 8e3)
|
|
159
|
+
}),
|
|
160
|
+
defaultPort: 8e3
|
|
161
|
+
},
|
|
162
|
+
nitro: {
|
|
163
|
+
label: "Nitro",
|
|
164
|
+
packageManagers: PACKAGE_MANAGER,
|
|
165
|
+
init: ({ packageManager: pm, testMode }) => ({
|
|
166
|
+
command: getNitroInitCommand(pm),
|
|
167
|
+
dependencies: {
|
|
168
|
+
"@fedify/h3": PACKAGE_VERSION,
|
|
169
|
+
...pm === "deno" ? defaultDenoDependencies : {}
|
|
170
|
+
},
|
|
171
|
+
devDependencies: defaultDevDependencies,
|
|
172
|
+
federationFile: "server/federation.ts",
|
|
173
|
+
loggingFile: "server/logging.ts",
|
|
174
|
+
files: {
|
|
175
|
+
"server/middleware/federation.ts": readTemplate("nitro/server/middleware/federation.ts"),
|
|
176
|
+
"server/error.ts": readTemplate("nitro/server/error.ts"),
|
|
177
|
+
"nitro.config.ts": readTemplate("nitro/nitro.config.ts"),
|
|
178
|
+
...testMode ? { ".env": readTemplate("nitro/.env.test") } : {},
|
|
179
|
+
...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
|
|
180
|
+
},
|
|
181
|
+
tasks: { ...pm !== "deno" ? { "lint": "eslint ." } : {} },
|
|
182
|
+
instruction: getInstruction(pm, 3e3)
|
|
183
|
+
}),
|
|
184
|
+
defaultPort: 3e3
|
|
185
|
+
},
|
|
186
|
+
next: {
|
|
187
|
+
label: "Next.js",
|
|
188
|
+
packageManagers: PACKAGE_MANAGER,
|
|
189
|
+
init: ({ packageManager: pm }) => ({
|
|
190
|
+
label: "Next.js",
|
|
191
|
+
command: getNextInitCommand(pm),
|
|
192
|
+
dependencies: {
|
|
193
|
+
"@fedify/next": PACKAGE_VERSION,
|
|
194
|
+
...pm === "deno" ? defaultDenoDependencies : {}
|
|
195
|
+
},
|
|
196
|
+
devDependencies: {
|
|
197
|
+
"@types/node": "^20.11.2",
|
|
198
|
+
...defaultDevDependencies
|
|
199
|
+
},
|
|
200
|
+
federationFile: "federation/index.ts",
|
|
201
|
+
loggingFile: "logging.ts",
|
|
202
|
+
files: {
|
|
203
|
+
"middleware.ts": readTemplate("next/middleware.ts"),
|
|
204
|
+
...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
|
|
205
|
+
},
|
|
206
|
+
tasks: { ...pm !== "deno" ? { "lint": "eslint ." } : {} },
|
|
207
|
+
instruction: getInstruction(pm, 3e3)
|
|
208
|
+
}),
|
|
209
|
+
defaultPort: 3e3
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
var webframeworks_default = webFrameworks;
|
|
213
|
+
const defaultDevDependencies = {
|
|
214
|
+
"eslint": "^9.0.0",
|
|
215
|
+
"@fedify/lint": PACKAGE_VERSION
|
|
216
|
+
};
|
|
217
|
+
const defaultDenoDependencies = { "@fedify/lint": PACKAGE_VERSION };
|
|
218
|
+
|
|
219
|
+
//#endregion
|
|
220
|
+
export { webframeworks_default as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fedify/init",
|
|
3
|
+
"version": "2.0.0-dev.0",
|
|
4
|
+
"description": "Project initializer for Fedify",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"fedify",
|
|
7
|
+
"activitypub",
|
|
8
|
+
"cli",
|
|
9
|
+
"init"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://fedify.dev/",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/fedify-dev/fedify/issues"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Hong Minhee",
|
|
18
|
+
"email": "hong@minhee.org",
|
|
19
|
+
"url": "https://hongminhee.org/"
|
|
20
|
+
},
|
|
21
|
+
"funding": [
|
|
22
|
+
"https://opencollective.com/fedify",
|
|
23
|
+
"https://github.com/sponsors/dahlia"
|
|
24
|
+
],
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/fedify-dev/fedify.git",
|
|
28
|
+
"directory": "packages/init"
|
|
29
|
+
},
|
|
30
|
+
"type": "module",
|
|
31
|
+
"main": "./dist/mod.js",
|
|
32
|
+
"types": "./dist/mod.d.ts",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"types": "./dist/mod.d.ts",
|
|
36
|
+
"import": "./dist/mod.js"
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist/",
|
|
42
|
+
"package.json",
|
|
43
|
+
"README.md"
|
|
44
|
+
],
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@fxts/core": "^1.20.0",
|
|
47
|
+
"@inquirer/prompts": "^7.8.4",
|
|
48
|
+
"@logtape/logtape": "^2.0.0",
|
|
49
|
+
"@optique/core": "^0.9.0",
|
|
50
|
+
"@optique/run": "^0.9.0",
|
|
51
|
+
"chalk": "^5.6.2",
|
|
52
|
+
"es-toolkit": "1.43.0",
|
|
53
|
+
"inquirer-toggle": "^1.0.1"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^22.17.0",
|
|
57
|
+
"tsdown": "^0.12.9",
|
|
58
|
+
"typescript": "^5.9.3"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build:self": "tsdown",
|
|
62
|
+
"build": "pnpm --filter @fedify/init... run build:self",
|
|
63
|
+
"prepublish": "pnpm build",
|
|
64
|
+
"test-init": "deno task test-init"
|
|
65
|
+
}
|
|
66
|
+
}
|