@fedify/init 2.3.0-dev.1372 → 2.3.0-dev.1404
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/action/cleanup.js +46 -0
- package/dist/action/configs.js +51 -6
- package/dist/action/deps.js +1 -1
- package/dist/action/mod.js +2 -1
- package/dist/action/patch.js +27 -16
- package/dist/action/templates.js +3 -2
- package/dist/deno.js +1 -1
- package/dist/json/deps.js +15 -13
- package/dist/json/deps.json +17 -15
- package/dist/json/kv.js +3 -3
- package/dist/json/kv.json +3 -3
- package/dist/json/mq.js +3 -3
- package/dist/json/mq.json +3 -3
- package/dist/json/oxfmt.js +16 -0
- package/dist/json/oxfmt.json +13 -0
- package/dist/json/oxlint.js +38 -0
- package/dist/json/oxlint.json +37 -0
- package/dist/json/vscode-settings.js +11 -10
- package/dist/json/vscode-settings.json +11 -10
- package/dist/templates/bare-bones/main/bun.ts.tpl +3 -3
- package/dist/templates/bare-bones/main/node.ts.tpl +7 -8
- package/dist/templates/defaults/federation.oxc.ts.tpl +22 -0
- package/dist/templates/defaults/federation.ts.tpl +1 -0
- package/dist/templates/elysia/index/bun.ts.tpl +1 -1
- package/dist/templates/elysia/index/node.ts.tpl +2 -2
- package/dist/templates/express/app.ts.tpl +0 -3
- package/dist/templates/hono/app.tsx.tpl +0 -3
- package/dist/templates/hono/index/node.ts.tpl +1 -2
- package/dist/templates/next/middleware.ts.tpl +3 -3
- package/dist/templates/nitro/nitro.config.ts.tpl +2 -2
- package/dist/templates/nitro/server/error.ts.tpl +1 -1
- package/dist/templates/nitro/server/middleware/federation.ts.tpl +2 -6
- package/dist/templates/nitro/server/routes/index.ts.tpl +11 -0
- package/dist/test/create.js +30 -1
- package/dist/types.d.ts +13 -0
- package/dist/utils.js +14 -7
- package/dist/webframeworks/astro.js +18 -7
- package/dist/webframeworks/bare-bones.js +4 -7
- package/dist/webframeworks/const.js +3 -3
- package/dist/webframeworks/elysia.js +4 -7
- package/dist/webframeworks/express.js +4 -5
- package/dist/webframeworks/hono.js +4 -5
- package/dist/webframeworks/next.js +9 -4
- package/dist/webframeworks/nitro.js +30 -3
- package/dist/webframeworks/nuxt.js +4 -4
- package/dist/webframeworks/solidstart.js +5 -5
- package/dist/webframeworks/utils.js +7 -1
- package/package.json +3 -2
- package/dist/json/biome.js +0 -16
- package/dist/json/biome.json +0 -19
- package/dist/templates/defaults/eslint.config.ts.tpl +0 -3
|
@@ -3,33 +3,34 @@ var vscode_settings_default = {
|
|
|
3
3
|
"editor.detectIndentation": false,
|
|
4
4
|
"editor.indentSize": 2,
|
|
5
5
|
"editor.insertSpaces": true,
|
|
6
|
+
"oxc.fmt.configPath": ".oxfmtrc.json",
|
|
6
7
|
"[javascript]": {
|
|
7
|
-
"editor.defaultFormatter": "
|
|
8
|
+
"editor.defaultFormatter": "oxc.oxc-vscode",
|
|
8
9
|
"editor.formatOnSave": true,
|
|
9
|
-
"editor.codeActionsOnSave": { "source.
|
|
10
|
+
"editor.codeActionsOnSave": { "source.fixAll.oxc": "always" }
|
|
10
11
|
},
|
|
11
12
|
"[javascriptreact]": {
|
|
12
|
-
"editor.defaultFormatter": "
|
|
13
|
+
"editor.defaultFormatter": "oxc.oxc-vscode",
|
|
13
14
|
"editor.formatOnSave": true,
|
|
14
|
-
"editor.codeActionsOnSave": { "source.
|
|
15
|
+
"editor.codeActionsOnSave": { "source.fixAll.oxc": "always" }
|
|
15
16
|
},
|
|
16
17
|
"[json]": {
|
|
17
|
-
"editor.defaultFormatter": "
|
|
18
|
+
"editor.defaultFormatter": "oxc.oxc-vscode",
|
|
18
19
|
"editor.formatOnSave": true
|
|
19
20
|
},
|
|
20
21
|
"[jsonc]": {
|
|
21
|
-
"editor.defaultFormatter": "
|
|
22
|
+
"editor.defaultFormatter": "oxc.oxc-vscode",
|
|
22
23
|
"editor.formatOnSave": true
|
|
23
24
|
},
|
|
24
25
|
"[typescript]": {
|
|
25
|
-
"editor.defaultFormatter": "
|
|
26
|
+
"editor.defaultFormatter": "oxc.oxc-vscode",
|
|
26
27
|
"editor.formatOnSave": true,
|
|
27
|
-
"editor.codeActionsOnSave": { "source.
|
|
28
|
+
"editor.codeActionsOnSave": { "source.fixAll.oxc": "always" }
|
|
28
29
|
},
|
|
29
30
|
"[typescriptreact]": {
|
|
30
|
-
"editor.defaultFormatter": "
|
|
31
|
+
"editor.defaultFormatter": "oxc.oxc-vscode",
|
|
31
32
|
"editor.formatOnSave": true,
|
|
32
|
-
"editor.codeActionsOnSave": { "source.
|
|
33
|
+
"editor.codeActionsOnSave": { "source.fixAll.oxc": "always" }
|
|
33
34
|
}
|
|
34
35
|
};
|
|
35
36
|
//#endregion
|
|
@@ -2,40 +2,41 @@
|
|
|
2
2
|
"editor.detectIndentation": false,
|
|
3
3
|
"editor.indentSize": 2,
|
|
4
4
|
"editor.insertSpaces": true,
|
|
5
|
+
"oxc.fmt.configPath": ".oxfmtrc.json",
|
|
5
6
|
"[javascript]": {
|
|
6
|
-
"editor.defaultFormatter": "
|
|
7
|
+
"editor.defaultFormatter": "oxc.oxc-vscode",
|
|
7
8
|
"editor.formatOnSave": true,
|
|
8
9
|
"editor.codeActionsOnSave": {
|
|
9
|
-
"source.
|
|
10
|
+
"source.fixAll.oxc": "always"
|
|
10
11
|
}
|
|
11
12
|
},
|
|
12
13
|
"[javascriptreact]": {
|
|
13
|
-
"editor.defaultFormatter": "
|
|
14
|
+
"editor.defaultFormatter": "oxc.oxc-vscode",
|
|
14
15
|
"editor.formatOnSave": true,
|
|
15
16
|
"editor.codeActionsOnSave": {
|
|
16
|
-
"source.
|
|
17
|
+
"source.fixAll.oxc": "always"
|
|
17
18
|
}
|
|
18
19
|
},
|
|
19
20
|
"[json]": {
|
|
20
|
-
"editor.defaultFormatter": "
|
|
21
|
+
"editor.defaultFormatter": "oxc.oxc-vscode",
|
|
21
22
|
"editor.formatOnSave": true
|
|
22
23
|
},
|
|
23
24
|
"[jsonc]": {
|
|
24
|
-
"editor.defaultFormatter": "
|
|
25
|
+
"editor.defaultFormatter": "oxc.oxc-vscode",
|
|
25
26
|
"editor.formatOnSave": true
|
|
26
27
|
},
|
|
27
28
|
"[typescript]": {
|
|
28
|
-
"editor.defaultFormatter": "
|
|
29
|
+
"editor.defaultFormatter": "oxc.oxc-vscode",
|
|
29
30
|
"editor.formatOnSave": true,
|
|
30
31
|
"editor.codeActionsOnSave": {
|
|
31
|
-
"source.
|
|
32
|
+
"source.fixAll.oxc": "always"
|
|
32
33
|
}
|
|
33
34
|
},
|
|
34
35
|
"[typescriptreact]": {
|
|
35
|
-
"editor.defaultFormatter": "
|
|
36
|
+
"editor.defaultFormatter": "oxc.oxc-vscode",
|
|
36
37
|
"editor.formatOnSave": true,
|
|
37
38
|
"editor.codeActionsOnSave": {
|
|
38
|
-
"source.
|
|
39
|
+
"source.fixAll.oxc": "always"
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -7,9 +7,9 @@ const server = Bun.serve({
|
|
|
7
7
|
fetch: behindProxy((req) =>
|
|
8
8
|
new URL(req.url).pathname === "/"
|
|
9
9
|
? new Response("Hello, this is a Fedify server!", {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
: federation.fetch(req, { contextData: undefined })
|
|
10
|
+
headers: { "Content-Type": "text/plain" },
|
|
11
|
+
})
|
|
12
|
+
: federation.fetch(req, { contextData: undefined }),
|
|
13
13
|
),
|
|
14
14
|
});
|
|
15
15
|
|
|
@@ -7,13 +7,12 @@ serve(
|
|
|
7
7
|
{
|
|
8
8
|
port: 8000,
|
|
9
9
|
fetch: behindProxy((req) =>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
new URL(req.url).pathname === "/"
|
|
11
|
+
? new Response("Hello, this is a Fedify server!", {
|
|
12
|
+
headers: { "Content-Type": "text/plain" },
|
|
13
|
+
})
|
|
14
|
+
: federation.fetch(req, { contextData: undefined }),
|
|
15
|
+
),
|
|
16
16
|
},
|
|
17
|
-
(info) =>
|
|
18
|
-
console.log("Server started at http://" + info.address + ":" + info.port)
|
|
17
|
+
(info) => console.log("Server started at http://" + info.address + ":" + info.port),
|
|
19
18
|
);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createFederation } from "@fedify/fedify";
|
|
2
|
+
import { Person } from "@fedify/vocab";
|
|
3
|
+
import { getLogger } from "@logtape/logtape";
|
|
4
|
+
/* imports */
|
|
5
|
+
|
|
6
|
+
const logger = getLogger(/* logger */);
|
|
7
|
+
|
|
8
|
+
const federation = createFederation({
|
|
9
|
+
kv: /* kv */,
|
|
10
|
+
queue: /* queue */,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
federation.setActorDispatcher("/users/{identifier}", async (ctx, identifier) => {
|
|
14
|
+
logger.info("Dispatching actor {identifier}", { identifier });
|
|
15
|
+
return new Person({
|
|
16
|
+
id: ctx.getActorUri(identifier),
|
|
17
|
+
preferredUsername: identifier,
|
|
18
|
+
name: identifier,
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export default federation;
|
|
@@ -13,6 +13,7 @@ const federation = createFederation({
|
|
|
13
13
|
federation.setActorDispatcher(
|
|
14
14
|
"/users/{identifier}",
|
|
15
15
|
async (ctx, identifier) => {
|
|
16
|
+
logger.info("Dispatching actor {identifier}", { identifier });
|
|
16
17
|
return new Person({
|
|
17
18
|
id: ctx.getActorUri(identifier),
|
|
18
19
|
preferredUsername: identifier,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { fedify } from "@fedify/elysia";
|
|
2
|
+
import { node } from "@elysiajs/node";
|
|
2
3
|
import { Elysia } from "elysia";
|
|
3
4
|
import federation from "./federation.ts";
|
|
4
5
|
import "./logging.ts";
|
|
5
|
-
import { node } from '@elysiajs/node'
|
|
6
6
|
|
|
7
7
|
const app = new Elysia({ adapter: node() });
|
|
8
8
|
|
|
@@ -11,4 +11,4 @@ app
|
|
|
11
11
|
.get("/", () => "Hello, Fedify!")
|
|
12
12
|
.listen(3000, () => {
|
|
13
13
|
console.log("Server started at http://localhost:3000");
|
|
14
|
-
})
|
|
14
|
+
});
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { integrateFederation } from "@fedify/express";
|
|
2
|
-
import { getLogger } from "@logtape/logtape";
|
|
3
2
|
import express from "express";
|
|
4
3
|
import federation from "./federation.ts";
|
|
5
4
|
|
|
6
|
-
const logger = getLogger("/* logger */");
|
|
7
|
-
|
|
8
5
|
export const app = express();
|
|
9
6
|
|
|
10
7
|
app.set("trust proxy", true);
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
// @ts-nocheck this file is just a template
|
|
2
2
|
import { Hono } from "/* hono */";
|
|
3
3
|
import { federation } from "@fedify/hono";
|
|
4
|
-
import { getLogger } from "@logtape/logtape";
|
|
5
4
|
import fedi from "./federation.ts";
|
|
6
5
|
|
|
7
|
-
const logger = getLogger("/* logger */");
|
|
8
|
-
|
|
9
6
|
const app = new Hono();
|
|
10
7
|
app.use(federation(fedi, () => undefined));
|
|
11
8
|
|
|
@@ -2,7 +2,7 @@ import { fedifyWith } from "@fedify/next";
|
|
|
2
2
|
import federation from "./federation";
|
|
3
3
|
|
|
4
4
|
export default fedifyWith(federation)(
|
|
5
|
-
/*
|
|
5
|
+
/*
|
|
6
6
|
function (request: Request) {
|
|
7
7
|
// If you need to handle other requests besides federation
|
|
8
8
|
// requests in middleware, you can do it here.
|
|
@@ -11,7 +11,7 @@ export default fedifyWith(federation)(
|
|
|
11
11
|
return NextResponse.next();
|
|
12
12
|
},
|
|
13
13
|
*/
|
|
14
|
-
)
|
|
14
|
+
);
|
|
15
15
|
|
|
16
16
|
// This config needs because middleware process only requests with the
|
|
17
17
|
// "Accept" header matching the federation accept regex.
|
|
@@ -42,4 +42,4 @@ export const config = {
|
|
|
42
42
|
{ source: "/.well-known/nodeinfo" },
|
|
43
43
|
{ source: "/.well-known/x-nodeinfo2" },
|
|
44
44
|
],
|
|
45
|
-
};
|
|
45
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNitroConfig } from "nitropack/config"
|
|
1
|
+
import { defineNitroConfig } from "nitropack/config";
|
|
2
2
|
|
|
3
3
|
// https://nitro.build/config
|
|
4
4
|
export default defineNitroConfig({
|
|
@@ -10,5 +10,5 @@ export default defineNitroConfig({
|
|
|
10
10
|
},
|
|
11
11
|
compatibilityDate: "latest",
|
|
12
12
|
srcDir: "server",
|
|
13
|
-
imports: false
|
|
13
|
+
imports: false,
|
|
14
14
|
});
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
1
|
import { integrateFederation } from "@fedify/h3";
|
|
3
|
-
import federation from "../federation"
|
|
2
|
+
import federation from "../federation";
|
|
4
3
|
|
|
5
|
-
export default integrateFederation(
|
|
6
|
-
federation,
|
|
7
|
-
(event, request) => undefined,
|
|
8
|
-
);
|
|
4
|
+
export default integrateFederation(federation, () => undefined);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { eventHandler } from "h3";
|
|
2
|
+
|
|
3
|
+
// Learn more: https://nitro.build/guide/routing
|
|
4
|
+
export default eventHandler(() => {
|
|
5
|
+
return `
|
|
6
|
+
<meta charset="utf-8">
|
|
7
|
+
<h1>This is your brand new Nitro project</h1>
|
|
8
|
+
<p>Get started by editing the <code>server/routes/index.ts</code> file.</p>
|
|
9
|
+
<p>Learn more from <a href="https://nitro.build/guide" target="_blank">Nitro Documentation</a></p>
|
|
10
|
+
`;
|
|
11
|
+
});
|
package/dist/test/create.js
CHANGED
|
@@ -5,7 +5,7 @@ import webFrameworks from "../webframeworks/mod.js";
|
|
|
5
5
|
import { filter, isEmpty, pipe, toArray } from "@fxts/core";
|
|
6
6
|
import process from "node:process";
|
|
7
7
|
import $ from "@david/dax";
|
|
8
|
-
import { appendFile, mkdir } from "node:fs/promises";
|
|
8
|
+
import { appendFile, mkdir, stat } from "node:fs/promises";
|
|
9
9
|
import { join as join$1, sep } from "node:path";
|
|
10
10
|
import { values } from "@optique/core";
|
|
11
11
|
//#region src/test/create.ts
|
|
@@ -16,6 +16,13 @@ const createTestApp = (testDirPrefix, dry) => async (options) => {
|
|
|
16
16
|
const result = await $`${toArray(genInitCommand(testDir, dry, options))}`.cwd(join$1(import.meta.dirname, "..", "..")).stdin("null").stdout("piped").stderr("piped").noThrow().spawn();
|
|
17
17
|
await saveOutputs(testDir, result);
|
|
18
18
|
if (result.code === 0) {
|
|
19
|
+
if (!dry && !await validateDevToolScripts(testDir, options)) {
|
|
20
|
+
printMessage` Fail: ${vals}`;
|
|
21
|
+
printMessage` Check out these files for more details: \
|
|
22
|
+
${join$1(testDir, "out.txt")} and \
|
|
23
|
+
${join$1(testDir, "err.txt")}\n`;
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
19
26
|
printMessage` Pass: ${vals}`;
|
|
20
27
|
return testDir;
|
|
21
28
|
}
|
|
@@ -66,6 +73,28 @@ const saveOutputs = async (dirPath, { stdout, stderr }) => {
|
|
|
66
73
|
if (stdout) await appendFile(join$1(dirPath, "out.txt"), stdout + "\n", "utf8");
|
|
67
74
|
if (stderr) await appendFile(join$1(dirPath, "err.txt"), stderr + "\n", "utf8");
|
|
68
75
|
};
|
|
76
|
+
async function validateDevToolScripts(dir, options) {
|
|
77
|
+
const [, packageManager] = options;
|
|
78
|
+
if (packageManager === "deno") return true;
|
|
79
|
+
if (!await hasInstalledNodeDependencies(dir)) return true;
|
|
80
|
+
for (const script of ["format:check", "lint"]) {
|
|
81
|
+
const result = await $`${[
|
|
82
|
+
packageManager,
|
|
83
|
+
"run",
|
|
84
|
+
script
|
|
85
|
+
]}`.cwd(dir).stdin("null").stdout("piped").stderr("piped").noThrow().spawn();
|
|
86
|
+
await saveOutputs(dir, result);
|
|
87
|
+
if (result.code !== 0) return false;
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
async function hasInstalledNodeDependencies(dir) {
|
|
92
|
+
try {
|
|
93
|
+
return (await stat(join$1(dir, "node_modules"))).isDirectory();
|
|
94
|
+
} catch {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
69
98
|
function filterOptions(options) {
|
|
70
99
|
const [wf, pm, kv, mq] = options;
|
|
71
100
|
return [
|
package/dist/types.d.ts
CHANGED
|
@@ -14,6 +14,14 @@ type PackageManager = typeof PACKAGE_MANAGER[number];
|
|
|
14
14
|
interface WebFrameworkInitializer {
|
|
15
15
|
/** Optional shell command to run before scaffolding (e.g., `create-next-app`). */
|
|
16
16
|
command?: string[];
|
|
17
|
+
/** Files from a framework scaffolder to remove before Fedify writes files. */
|
|
18
|
+
cleanupFiles?: string[];
|
|
19
|
+
/** package.json entries from a framework scaffolder to remove before merging. */
|
|
20
|
+
cleanupPackageJson?: {
|
|
21
|
+
scripts?: string[];
|
|
22
|
+
dependencies?: string[];
|
|
23
|
+
devDependencies?: string[];
|
|
24
|
+
};
|
|
17
25
|
/** Runtime dependencies to install (package name to version). */
|
|
18
26
|
dependencies?: Record<string, string>;
|
|
19
27
|
/** Development-only dependencies to install (package name to version). */
|
|
@@ -36,6 +44,11 @@ interface WebFrameworkInitializer {
|
|
|
36
44
|
* default value. Merged together with KV store and message queue env vars
|
|
37
45
|
* into the generated `.env` file. */
|
|
38
46
|
env?: Record<string, string>;
|
|
47
|
+
/** Formatter and linter options to merge into generated tool configs. */
|
|
48
|
+
format?: {
|
|
49
|
+
tool?: "oxfmt" | "prettier";
|
|
50
|
+
ignorePatterns?: string[];
|
|
51
|
+
};
|
|
39
52
|
/** TypeScript compiler options to include in `tsconfig.json`. */
|
|
40
53
|
compilerOptions?: Record<string, string | boolean | number | string[] | null>;
|
|
41
54
|
/** Task scripts keyed by task name (e.g., `"dev"`, `"prod"`, `"lint"`). */
|
package/dist/utils.js
CHANGED
|
@@ -42,13 +42,20 @@ const merge$1 = (source = {}) => (target = {}) => toMerged(target, source);
|
|
|
42
42
|
* replacement on the given text.
|
|
43
43
|
*/
|
|
44
44
|
const replace = (pattern, replacement) => (text) => text.replace(pattern, replacement);
|
|
45
|
-
/**
|
|
46
|
-
* Curried `String.prototype.replaceAll`. Returns a function that replaces all
|
|
47
|
-
* occurrences of the pattern in the given text.
|
|
48
|
-
*/
|
|
49
|
-
const replaceAll = (pattern, replacement) => (text) => text.replaceAll(pattern, replacement);
|
|
50
45
|
/** Serializes a value to a pretty-printed JSON string with a trailing newline. */
|
|
51
|
-
const formatJson = (obj) => JSON.stringify(obj,
|
|
46
|
+
const formatJson = (obj) => JSON.stringify(obj, createJsonDepthGuard(), 2) + "\n";
|
|
47
|
+
const MAX_JSON_FORMAT_DEPTH = 100;
|
|
48
|
+
const createJsonDepthGuard = () => {
|
|
49
|
+
const depths = /* @__PURE__ */ new WeakMap();
|
|
50
|
+
return function(_key, value) {
|
|
51
|
+
if (value !== null && typeof value === "object") {
|
|
52
|
+
const depth = (this !== null && typeof this === "object" ? depths.get(this) ?? 0 : 0) + 1;
|
|
53
|
+
if (depth > MAX_JSON_FORMAT_DEPTH) throw new RangeError("Maximum depth exceeded while formatting JSON.");
|
|
54
|
+
depths.set(value, depth);
|
|
55
|
+
}
|
|
56
|
+
return value;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
52
59
|
/** Checks whether a string or array-like value has a length greater than zero. */
|
|
53
60
|
const notEmpty = (s) => s.length > 0;
|
|
54
61
|
/** Type guard that checks whether an error is a "file not found" (`ENOENT`) error. */
|
|
@@ -153,4 +160,4 @@ const printMessage = flow(message, print);
|
|
|
153
160
|
/** Prints a formatted error message to stderr using `@optique/run`'s `printError`. */
|
|
154
161
|
const printErrorMessage = flow(message, printError);
|
|
155
162
|
//#endregion
|
|
156
|
-
export { CommandError, colors, formatJson, getCwd, getOsType, isNotFoundError, merge$1 as merge, notEmpty, printErrorMessage, printMessage, product, replace,
|
|
163
|
+
export { CommandError, colors, formatJson, getCwd, getOsType, isNotFoundError, merge$1 as merge, notEmpty, printErrorMessage, printMessage, product, replace, runSubCommand, set };
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { PACKAGE_VERSION, readTemplate } from "../lib.js";
|
|
2
2
|
import { PACKAGE_MANAGER } from "../const.js";
|
|
3
|
-
import { npm__astrojs_node, npm__deno_astro_adapter, npm__dotenvx_dotenvx, npm__nurodev_astro_bun, npm__types_node_22, npm_typescript } from "../json/deps.js";
|
|
4
|
-
import { defaultDenoDependencies
|
|
3
|
+
import { npm__astrojs_node, npm__deno_astro_adapter, npm__dotenvx_dotenvx, npm__nurodev_astro_bun, npm__types_node_22, npm_oxlint, npm_prettier, npm_prettier_plugin_astro, npm_typescript } from "../json/deps.js";
|
|
4
|
+
import { defaultDenoDependencies } from "./const.js";
|
|
5
5
|
import { getInstruction, pmToRt } from "./utils.js";
|
|
6
6
|
//#region src/webframeworks/astro.ts
|
|
7
|
+
const astroNodeBunDevDependencies = {
|
|
8
|
+
"@fedify/lint": PACKAGE_VERSION,
|
|
9
|
+
"oxlint": npm_oxlint,
|
|
10
|
+
"prettier": npm_prettier,
|
|
11
|
+
"prettier-plugin-astro": npm_prettier_plugin_astro
|
|
12
|
+
};
|
|
13
|
+
const astroNodeBunDevToolTasks = {
|
|
14
|
+
format: "prettier --plugin prettier-plugin-astro --write .",
|
|
15
|
+
"format:check": "prettier --plugin prettier-plugin-astro --check .",
|
|
16
|
+
lint: "oxlint ."
|
|
17
|
+
};
|
|
7
18
|
const astroDescription = {
|
|
8
19
|
label: "Astro",
|
|
9
20
|
packageManagers: PACKAGE_MANAGER,
|
|
@@ -25,7 +36,7 @@ const astroDescription = {
|
|
|
25
36
|
command: Array.from(getAstroInitCommand(pm)),
|
|
26
37
|
dependencies,
|
|
27
38
|
devDependencies: {
|
|
28
|
-
...
|
|
39
|
+
...pm === "deno" ? {} : astroNodeBunDevDependencies,
|
|
29
40
|
...pm !== "deno" ? {
|
|
30
41
|
typescript: npm_typescript,
|
|
31
42
|
"@types/node": npm__types_node_22
|
|
@@ -33,10 +44,10 @@ const astroDescription = {
|
|
|
33
44
|
},
|
|
34
45
|
federationFile: "src/federation.ts",
|
|
35
46
|
loggingFile: "src/logging.ts",
|
|
47
|
+
format: pm === "deno" ? void 0 : { tool: "prettier" },
|
|
36
48
|
files: {
|
|
37
49
|
"astro.config.ts": await readTemplate(`astro/astro.config.${pmToRt(pm)}.ts`),
|
|
38
|
-
"src/middleware.ts": await readTemplate("astro/src/middleware.ts")
|
|
39
|
-
...pm !== "deno" && { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") }
|
|
50
|
+
"src/middleware.ts": await readTemplate("astro/src/middleware.ts")
|
|
40
51
|
},
|
|
41
52
|
tasks: TASKS[pmToRt(pm)],
|
|
42
53
|
instruction: getInstruction(pm, 4321)
|
|
@@ -79,13 +90,13 @@ const TASKS = {
|
|
|
79
90
|
dev: "bunx --bun astro dev",
|
|
80
91
|
build: "bunx --bun astro build",
|
|
81
92
|
preview: "bun ./dist/server/entry.mjs",
|
|
82
|
-
|
|
93
|
+
...astroNodeBunDevToolTasks
|
|
83
94
|
},
|
|
84
95
|
"node": {
|
|
85
96
|
dev: "dotenvx run -- astro dev",
|
|
86
97
|
build: "dotenvx run -- astro build",
|
|
87
98
|
preview: "dotenvx run -- astro preview",
|
|
88
|
-
|
|
99
|
+
...astroNodeBunDevToolTasks
|
|
89
100
|
}
|
|
90
101
|
};
|
|
91
102
|
//#endregion
|
|
@@ -2,7 +2,7 @@ import { readTemplate } from "../lib.js";
|
|
|
2
2
|
import { PACKAGE_MANAGER } from "../const.js";
|
|
3
3
|
import { _hongminhee_x_forwarded_fetch, npm__dotenvx_dotenvx, npm__hono_node_server, npm__types_bun, npm__types_node_25, npm_tsx, npm_x_forwarded_fetch } from "../json/deps.js";
|
|
4
4
|
import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
|
|
5
|
-
import { getInstruction, pmToRt } from "./utils.js";
|
|
5
|
+
import { getInstruction, nodeBunDevToolTasks, pmToRt } from "./utils.js";
|
|
6
6
|
//#region src/webframeworks/bare-bones.ts
|
|
7
7
|
const bareBonesDescription = {
|
|
8
8
|
label: "Bare-bones",
|
|
@@ -16,10 +16,7 @@ const bareBonesDescription = {
|
|
|
16
16
|
},
|
|
17
17
|
federationFile: "src/federation.ts",
|
|
18
18
|
loggingFile: "src/logging.ts",
|
|
19
|
-
files: {
|
|
20
|
-
"src/main.ts": await readTemplate(`bare-bones/main/${pmToRt(pm)}.ts`),
|
|
21
|
-
...pm !== "deno" && { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") }
|
|
22
|
-
},
|
|
19
|
+
files: { "src/main.ts": await readTemplate(`bare-bones/main/${pmToRt(pm)}.ts`) },
|
|
23
20
|
compilerOptions: pm === "deno" ? {
|
|
24
21
|
"jsx": "precompile",
|
|
25
22
|
"jsxImportSource": "hono/jsx"
|
|
@@ -54,12 +51,12 @@ const TASKS = {
|
|
|
54
51
|
bun: {
|
|
55
52
|
dev: "bun run --hot ./src/main.ts",
|
|
56
53
|
prod: "bun run ./src/main.ts",
|
|
57
|
-
|
|
54
|
+
...nodeBunDevToolTasks
|
|
58
55
|
},
|
|
59
56
|
node: {
|
|
60
57
|
dev: "dotenvx run -- tsx watch ./src/main.ts",
|
|
61
58
|
prod: "dotenvx run -- node --import tsx ./src/main.ts",
|
|
62
|
-
|
|
59
|
+
...nodeBunDevToolTasks
|
|
63
60
|
}
|
|
64
61
|
};
|
|
65
62
|
//#endregion
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PACKAGE_VERSION } from "../lib.js";
|
|
2
|
-
import {
|
|
2
|
+
import { npm_oxfmt, npm_oxlint } from "../json/deps.js";
|
|
3
3
|
//#region src/webframeworks/const.ts
|
|
4
4
|
const defaultDevDependencies = {
|
|
5
5
|
"@fedify/lint": PACKAGE_VERSION,
|
|
6
|
-
"
|
|
7
|
-
"
|
|
6
|
+
"oxfmt": npm_oxfmt,
|
|
7
|
+
"oxlint": npm_oxlint
|
|
8
8
|
};
|
|
9
9
|
const defaultDenoDependencies = { "@fedify/lint": PACKAGE_VERSION };
|
|
10
10
|
//#endregion
|
|
@@ -2,7 +2,7 @@ import { PACKAGE_VERSION, readTemplate } from "../lib.js";
|
|
|
2
2
|
import { PACKAGE_MANAGER } from "../const.js";
|
|
3
3
|
import { npm__dotenvx_dotenvx, npm__elysiajs_node, npm__sinclair_typebox, npm__types_bun, npm__types_node_25, npm_elysia, npm_openapi_types, npm_tsx, npm_typescript } from "../json/deps.js";
|
|
4
4
|
import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
|
|
5
|
-
import { getInstruction, pmToRt } from "./utils.js";
|
|
5
|
+
import { getInstruction, nodeBunDevToolTasks, pmToRt } from "./utils.js";
|
|
6
6
|
//#region src/webframeworks/elysia.ts
|
|
7
7
|
const elysiaDescription = {
|
|
8
8
|
label: "ElysiaJS",
|
|
@@ -36,10 +36,7 @@ const elysiaDescription = {
|
|
|
36
36
|
},
|
|
37
37
|
federationFile: "src/federation.ts",
|
|
38
38
|
loggingFile: "src/logging.ts",
|
|
39
|
-
files: {
|
|
40
|
-
"src/index.ts": (await readTemplate(`elysia/index/${pmToRt(pm)}.ts`)).replace(/\/\* logger \*\//, projectName),
|
|
41
|
-
...pm !== "deno" && { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") }
|
|
42
|
-
},
|
|
39
|
+
files: { "src/index.ts": (await readTemplate(`elysia/index/${pmToRt(pm)}.ts`)).replace(/\/\* logger \*\//, projectName) },
|
|
43
40
|
compilerOptions: pm === "deno" || pm === "bun" ? void 0 : {
|
|
44
41
|
"lib": ["ESNext", "DOM"],
|
|
45
42
|
"target": "ESNext",
|
|
@@ -62,13 +59,13 @@ const TASKS = {
|
|
|
62
59
|
bun: {
|
|
63
60
|
dev: "bun run --hot ./src/index.ts",
|
|
64
61
|
prod: "bun run ./src/index.ts",
|
|
65
|
-
|
|
62
|
+
...nodeBunDevToolTasks
|
|
66
63
|
},
|
|
67
64
|
node: {
|
|
68
65
|
dev: "dotenvx run -- tsx watch src/index.ts",
|
|
69
66
|
build: "tsc src/index.ts --outDir dist",
|
|
70
67
|
start: "NODE_ENV=production dotenvx run -- node dist/index.js",
|
|
71
|
-
|
|
68
|
+
...nodeBunDevToolTasks
|
|
72
69
|
}
|
|
73
70
|
};
|
|
74
71
|
//#endregion
|
|
@@ -2,7 +2,7 @@ import { PACKAGE_VERSION, readTemplate } from "../lib.js";
|
|
|
2
2
|
import { PACKAGE_MANAGER } from "../const.js";
|
|
3
3
|
import { npm__dotenvx_dotenvx, npm__types_bun, npm__types_express, npm_express, npm_tsx } from "../json/deps.js";
|
|
4
4
|
import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
|
|
5
|
-
import { getInstruction, pmToRt } from "./utils.js";
|
|
5
|
+
import { getInstruction, nodeBunDevToolTasks, pmToRt } from "./utils.js";
|
|
6
6
|
//#region src/webframeworks/express.ts
|
|
7
7
|
const expressDescription = {
|
|
8
8
|
label: "Express",
|
|
@@ -27,8 +27,7 @@ const expressDescription = {
|
|
|
27
27
|
loggingFile: "src/logging.ts",
|
|
28
28
|
files: {
|
|
29
29
|
"src/app.ts": (await readTemplate("express/app.ts")).replace(/\/\* logger \*\//, projectName),
|
|
30
|
-
"src/index.ts": await readTemplate("express/index.ts")
|
|
31
|
-
...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
|
|
30
|
+
"src/index.ts": await readTemplate("express/index.ts")
|
|
32
31
|
},
|
|
33
32
|
compilerOptions: pm === "deno" ? void 0 : {
|
|
34
33
|
"lib": ["ESNext", "DOM"],
|
|
@@ -52,12 +51,12 @@ const TASKS = {
|
|
|
52
51
|
bun: {
|
|
53
52
|
dev: "bun run --hot ./src/index.ts",
|
|
54
53
|
prod: "bun run ./src/index.ts",
|
|
55
|
-
|
|
54
|
+
...nodeBunDevToolTasks
|
|
56
55
|
},
|
|
57
56
|
node: {
|
|
58
57
|
dev: "dotenvx run -- tsx watch ./src/index.ts",
|
|
59
58
|
prod: "dotenvx run -- node --import tsx ./src/index.ts",
|
|
60
|
-
|
|
59
|
+
...nodeBunDevToolTasks
|
|
61
60
|
}
|
|
62
61
|
};
|
|
63
62
|
//#endregion
|
|
@@ -3,7 +3,7 @@ import { PACKAGE_VERSION, readTemplate } from "../lib.js";
|
|
|
3
3
|
import { PACKAGE_MANAGER } from "../const.js";
|
|
4
4
|
import { _hongminhee_x_forwarded_fetch, _hono_hono, npm__dotenvx_dotenvx, npm__hono_node_server, npm__types_bun, npm_hono, npm_tsx, npm_x_forwarded_fetch } from "../json/deps.js";
|
|
5
5
|
import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
|
|
6
|
-
import { getInstruction, pmToRt } from "./utils.js";
|
|
6
|
+
import { getInstruction, nodeBunDevToolTasks, pmToRt } from "./utils.js";
|
|
7
7
|
import { pipe } from "@fxts/core";
|
|
8
8
|
//#region src/webframeworks/hono.ts
|
|
9
9
|
const honoDescription = {
|
|
@@ -20,8 +20,7 @@ const honoDescription = {
|
|
|
20
20
|
loggingFile: "src/logging.ts",
|
|
21
21
|
files: {
|
|
22
22
|
"src/app.tsx": pipe(await readTemplate("hono/app.tsx"), replace(/\/\* hono \*\//, pm === "deno" ? "@hono/hono" : "hono"), replace(/\/\* logger \*\//, projectName)),
|
|
23
|
-
"src/index.ts": await readTemplate(`hono/index/${pmToRt(pm)}.ts`)
|
|
24
|
-
...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
|
|
23
|
+
"src/index.ts": await readTemplate(`hono/index/${pmToRt(pm)}.ts`)
|
|
25
24
|
},
|
|
26
25
|
compilerOptions: pm === "deno" ? void 0 : {
|
|
27
26
|
"lib": ["ESNext", "DOM"],
|
|
@@ -64,12 +63,12 @@ const TASKS = {
|
|
|
64
63
|
bun: {
|
|
65
64
|
dev: "bun run --hot ./src/index.ts",
|
|
66
65
|
prod: "bun run ./src/index.ts",
|
|
67
|
-
|
|
66
|
+
...nodeBunDevToolTasks
|
|
68
67
|
},
|
|
69
68
|
node: {
|
|
70
69
|
dev: "dotenvx run -- tsx watch ./src/index.ts",
|
|
71
70
|
prod: "dotenvx run -- node --import tsx ./src/index.ts",
|
|
72
|
-
|
|
71
|
+
...nodeBunDevToolTasks
|
|
73
72
|
}
|
|
74
73
|
};
|
|
75
74
|
//#endregion
|