@fedify/init 2.4.0-pr.936.41 → 2.4.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.
Files changed (46) hide show
  1. package/README.md +9 -5
  2. package/dist/action/configs.js +1 -1
  3. package/dist/action/deps.js +1 -1
  4. package/dist/action/mod.d.ts +1 -1
  5. package/dist/action/patch.js +4 -2
  6. package/dist/action/templates.js +14 -2
  7. package/dist/ask/dir.js +51 -19
  8. package/dist/ask/kv.js +1 -1
  9. package/dist/ask/mq.js +1 -1
  10. package/dist/ask/pm.js +44 -26
  11. package/dist/command.d.ts +5 -5
  12. package/dist/const.js +6 -2
  13. package/dist/deno.js +1 -1
  14. package/dist/json/deps.js +13 -13
  15. package/dist/json/deps.json +15 -15
  16. package/dist/json/kv.js +1 -1
  17. package/dist/json/kv.json +1 -1
  18. package/dist/json/mq.js +1 -1
  19. package/dist/json/mq.json +1 -1
  20. package/dist/json/rt.js +7 -14
  21. package/dist/json/rt.json +7 -20
  22. package/dist/lib.js +78 -2
  23. package/dist/mod.d.ts +1 -1
  24. package/dist/templates/defaults/smoke.test.ts.tpl +170 -0
  25. package/dist/templates/next/middleware.ts.tpl +7 -2
  26. package/dist/templates/sveltekit/hooks.server.ts.tpl +7 -0
  27. package/dist/test/create.js +7 -12
  28. package/dist/test/db.js +1 -1
  29. package/dist/test/lookup.js +3 -2
  30. package/dist/test/port.js +4 -4
  31. package/dist/types.d.ts +3 -1
  32. package/dist/utils.js +9 -3
  33. package/dist/webframeworks/astro.js +11 -5
  34. package/dist/webframeworks/bare-bones.js +8 -4
  35. package/dist/webframeworks/const.js +1 -1
  36. package/dist/webframeworks/elysia.js +9 -5
  37. package/dist/webframeworks/express.js +8 -4
  38. package/dist/webframeworks/hono.js +8 -4
  39. package/dist/webframeworks/mod.js +3 -1
  40. package/dist/webframeworks/next.js +10 -5
  41. package/dist/webframeworks/nitro.js +11 -4
  42. package/dist/webframeworks/nuxt.js +10 -5
  43. package/dist/webframeworks/solidstart.js +10 -5
  44. package/dist/webframeworks/sveltekit.js +82 -0
  45. package/dist/webframeworks/utils.js +15 -1
  46. package/package.json +6 -5
@@ -1,9 +1,9 @@
1
+ import { PACKAGE_MANAGER } from "../const.js";
1
2
  import { replace } from "../utils.js";
2
3
  import { PACKAGE_VERSION, readTemplate } from "../lib.js";
3
- import { PACKAGE_MANAGER } from "../const.js";
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";
4
+ import { "@hongminhee/x-forwarded-fetch" as _hongminhee_x_forwarded_fetch, "@hono/hono" as _hono_hono, "npm:@dotenvx/dotenvx" as npm__dotenvx_dotenvx, "npm:@hono/node-server" as npm__hono_node_server, "npm:@types/bun" as npm__types_bun, "npm:hono" as npm_hono, "npm:tsx" as npm_tsx, "npm:x-forwarded-fetch" as npm_x_forwarded_fetch } from "../json/deps.js";
5
5
  import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
6
- import { getInstruction, nodeBunDevToolTasks, pmToRt } from "./utils.js";
6
+ import { getInstruction, getTestTask, nodeBunDevToolTasks, pmToRt } from "./utils.js";
7
7
  import { pipe } from "@fxts/core";
8
8
  //#region src/webframeworks/hono.ts
9
9
  const honoDescription = {
@@ -18,6 +18,7 @@ const honoDescription = {
18
18
  },
19
19
  federationFile: "src/federation.ts",
20
20
  loggingFile: "src/logging.ts",
21
+ testFile: "scripts/smoke.test.ts",
21
22
  files: {
22
23
  "src/app.tsx": pipe(await readTemplate("hono/app.tsx"), replace(/\/\* hono \*\//, pm === "deno" ? "@hono/hono" : "hono"), replace(/\/\* logger \*\//, projectName)),
23
24
  "src/index.ts": await readTemplate(`hono/index/${pmToRt(pm)}.ts`)
@@ -58,16 +59,19 @@ const getDependencies = (pm) => pm === "deno" ? {
58
59
  const TASKS = {
59
60
  deno: {
60
61
  dev: "deno run -A --watch ./src/index.ts",
61
- prod: "deno run -A ./src/index.ts"
62
+ prod: "deno run -A ./src/index.ts",
63
+ test: getTestTask("deno")
62
64
  },
63
65
  bun: {
64
66
  dev: "bun run --hot ./src/index.ts",
65
67
  prod: "bun run ./src/index.ts",
68
+ test: getTestTask("bun"),
66
69
  ...nodeBunDevToolTasks
67
70
  },
68
71
  node: {
69
72
  dev: "dotenvx run -- tsx watch ./src/index.ts",
70
73
  prod: "dotenvx run -- node --import tsx ./src/index.ts",
74
+ test: getTestTask("npm"),
71
75
  ...nodeBunDevToolTasks
72
76
  }
73
77
  };
@@ -7,6 +7,7 @@ import nextDescription from "./next.js";
7
7
  import nitroDescription from "./nitro.js";
8
8
  import nuxtDescription from "./nuxt.js";
9
9
  import solidstartDescription from "./solidstart.js";
10
+ import sveltekitDescription from "./sveltekit.js";
10
11
  //#region src/webframeworks/mod.ts
11
12
  /**
12
13
  * Registry of all supported web framework configurations.
@@ -24,7 +25,8 @@ const webFrameworks = {
24
25
  next: nextDescription,
25
26
  nitro: nitroDescription,
26
27
  nuxt: nuxtDescription,
27
- solidstart: solidstartDescription
28
+ solidstart: solidstartDescription,
29
+ sveltekit: sveltekitDescription
28
30
  };
29
31
  //#endregion
30
32
  export { webFrameworks as default };
@@ -1,8 +1,8 @@
1
- import { PACKAGE_VERSION, readTemplate } from "../lib.js";
2
1
  import { PACKAGE_MANAGER } from "../const.js";
3
- import { npm__types_node_20 } from "../json/deps.js";
2
+ import { PACKAGE_VERSION, readTemplate } from "../lib.js";
3
+ import { "npm:@types/node@20" as npm__types_node_20 } from "../json/deps.js";
4
4
  import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
5
- import { getInstruction, getNodeBunDevToolTasks } from "./utils.js";
5
+ import { getInstruction, getNodeBunDevToolTasks, getTestDependencies, getTestTask } from "./utils.js";
6
6
  //#region src/webframeworks/next.ts
7
7
  const nextDescription = {
8
8
  label: "Next.js",
@@ -21,16 +21,21 @@ const nextDescription = {
21
21
  },
22
22
  devDependencies: {
23
23
  "@types/node": npm__types_node_20,
24
- ...defaultDevDependencies
24
+ ...defaultDevDependencies,
25
+ ...getTestDependencies(pm)
25
26
  },
26
27
  federationFile: "federation/index.ts",
27
28
  loggingFile: "logging.ts",
29
+ testFile: "scripts/smoke.test.ts",
28
30
  format: { ignorePatterns: [".next/**"] },
29
31
  files: {
30
32
  "instrumentation.ts": await readTemplate("next/instrumentation.ts"),
31
33
  "middleware.ts": await readTemplate("next/middleware.ts")
32
34
  },
33
- tasks: getNodeBunDevToolTasks(pm),
35
+ tasks: {
36
+ ...getNodeBunDevToolTasks(pm),
37
+ test: getTestTask(pm)
38
+ },
34
39
  instruction: getInstruction(pm, 3e3)
35
40
  })
36
41
  };
@@ -1,7 +1,7 @@
1
- import { PACKAGE_VERSION, readTemplate } from "../lib.js";
2
1
  import { PACKAGE_MANAGER } from "../const.js";
2
+ import { PACKAGE_VERSION, readTemplate } from "../lib.js";
3
3
  import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
4
- import { getInstruction, getNodeBunDevToolTasks } from "./utils.js";
4
+ import { getInstruction, getNodeBunDevToolTasks, getTestDependencies, getTestTask } from "./utils.js";
5
5
  //#region src/webframeworks/nitro.ts
6
6
  const nitroDescription = {
7
7
  label: "Nitro",
@@ -19,9 +19,13 @@ const nitroDescription = {
19
19
  "@fedify/h3": PACKAGE_VERSION,
20
20
  ...pm === "deno" && defaultDenoDependencies
21
21
  },
22
- devDependencies: defaultDevDependencies,
22
+ devDependencies: {
23
+ ...defaultDevDependencies,
24
+ ...getTestDependencies(pm)
25
+ },
23
26
  federationFile: "server/federation.ts",
24
27
  loggingFile: "server/logging.ts",
28
+ testFile: "scripts/smoke.test.ts",
25
29
  format: { ignorePatterns: [".output/**"] },
26
30
  env: testMode ? { HOST: "127.0.0.1" } : {},
27
31
  files: {
@@ -51,7 +55,10 @@ const nitroDescription = {
51
55
  lib: ["ESNext", "DOM"],
52
56
  baseUrl: "."
53
57
  },
54
- tasks: getNodeBunDevToolTasks(pm),
58
+ tasks: {
59
+ ...getNodeBunDevToolTasks(pm),
60
+ test: getTestTask(pm)
61
+ },
55
62
  instruction: getInstruction(pm, 3e3)
56
63
  })
57
64
  };
@@ -1,8 +1,8 @@
1
- import { PACKAGE_VERSION, readTemplate } from "../lib.js";
2
1
  import { PACKAGE_MANAGER } from "../const.js";
3
- import { npm__types_node_25, npm_typescript } from "../json/deps.js";
2
+ import { PACKAGE_VERSION, readTemplate } from "../lib.js";
3
+ import { "npm:@types/node@25" as npm__types_node_25, "npm:typescript" as npm_typescript } from "../json/deps.js";
4
4
  import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
5
- import { getInstruction, getNodeBunDevToolTasks } from "./utils.js";
5
+ import { getInstruction, getNodeBunDevToolTasks, getTestDependencies, getTestTask } from "./utils.js";
6
6
  //#region src/webframeworks/nuxt.ts
7
7
  const nuxtDescription = {
8
8
  label: "Nuxt",
@@ -14,18 +14,23 @@ const nuxtDescription = {
14
14
  devDependencies: {
15
15
  ...defaultDevDependencies,
16
16
  "typescript": npm_typescript,
17
- "@types/node": npm__types_node_25
17
+ "@types/node": npm__types_node_25,
18
+ ...getTestDependencies(pm)
18
19
  },
19
20
  federationFile: "server/federation.ts",
20
21
  loggingFile: "server/logging.ts",
21
22
  loggingTemplate: "nuxt/server/logging.ts",
23
+ testFile: "scripts/smoke.test.ts",
22
24
  format: { ignorePatterns: [".output/**"] },
23
25
  env: testMode ? { HOST: "127.0.0.1" } : {},
24
26
  files: {
25
27
  "nuxt.config.ts": await readTemplate("nuxt/nuxt.config.ts"),
26
28
  "server/plugins/logging.ts": await readTemplate("nuxt/server/plugins/logging.ts")
27
29
  },
28
- tasks: getNodeBunDevToolTasks(pm),
30
+ tasks: {
31
+ ...getNodeBunDevToolTasks(pm),
32
+ test: getTestTask(pm)
33
+ },
29
34
  instruction: getInstruction(pm, 3e3)
30
35
  })
31
36
  };
@@ -1,8 +1,8 @@
1
- import { PACKAGE_VERSION, readTemplate } from "../lib.js";
2
1
  import { PACKAGE_MANAGER } from "../const.js";
3
- import { npm__dotenvx_dotenvx, npm__solidjs_router, npm__solidjs_start, npm__types_node_22, npm_solid_js, npm_typescript, npm_vinxi } from "../json/deps.js";
2
+ import { PACKAGE_VERSION, readTemplate } from "../lib.js";
3
+ import { "npm:@dotenvx/dotenvx" as npm__dotenvx_dotenvx, "npm:@solidjs/router" as npm__solidjs_router, "npm:@solidjs/start" as npm__solidjs_start, "npm:@types/node@22" as npm__types_node_22, "npm:solid-js" as npm_solid_js, "npm:typescript" as npm_typescript, "npm:vinxi" as npm_vinxi } from "../json/deps.js";
4
4
  import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
5
- import { getInstruction, nodeBunDevToolTasks, pmToRt } from "./utils.js";
5
+ import { getInstruction, getTestDependencies, getTestTask, nodeBunDevToolTasks, pmToRt } from "./utils.js";
6
6
  //#region src/webframeworks/solidstart.ts
7
7
  const NPM_SOLIDSTART = `npm:@solidjs/start@${npm__solidjs_start}`;
8
8
  const solidstartDescription = {
@@ -14,10 +14,12 @@ const solidstartDescription = {
14
14
  devDependencies: {
15
15
  ...defaultDevDependencies,
16
16
  typescript: npm_typescript,
17
- "@types/node": npm__types_node_22
17
+ "@types/node": npm__types_node_22,
18
+ ...getTestDependencies(pm)
18
19
  },
19
20
  federationFile: "src/federation.ts",
20
21
  loggingFile: "src/logging.ts",
22
+ testFile: "scripts/smoke.test.ts",
21
23
  format: { ignorePatterns: [".solid/**", ".vinxi/**"] },
22
24
  files: {
23
25
  "app.config.ts": (await readTemplate("solidstart/app.config.ts")).replace(/\/\* preset \*\//, pm === "deno" ? "deno-server" : "node-server"),
@@ -70,18 +72,21 @@ const TASKS = {
70
72
  deno: {
71
73
  dev: "deno run -A npm:vinxi dev",
72
74
  build: "deno run -A npm:vinxi build",
73
- start: "deno run -A npm:vinxi start"
75
+ start: "deno run -A npm:vinxi start",
76
+ test: getTestTask("deno")
74
77
  },
75
78
  bun: {
76
79
  dev: "bunx vinxi dev",
77
80
  build: "bunx vinxi build",
78
81
  start: "bunx vinxi start",
82
+ test: getTestTask("bun"),
79
83
  ...nodeBunDevToolTasks
80
84
  },
81
85
  node: {
82
86
  dev: "vinxi dev",
83
87
  build: "vinxi build",
84
88
  start: "dotenvx run -- vinxi start",
89
+ test: getTestTask("npm"),
85
90
  ...nodeBunDevToolTasks
86
91
  }
87
92
  };
@@ -0,0 +1,82 @@
1
+ import { PACKAGE_MANAGER } from "../const.js";
2
+ import { PACKAGE_VERSION, readTemplate } from "../lib.js";
3
+ import { "npm:@dotenvx/dotenvx" as npm__dotenvx_dotenvx, "npm:@types/node@25" as npm__types_node_25, "npm:typescript" as npm_typescript } from "../json/deps.js";
4
+ import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
5
+ import { getInstruction, getTestDependencies, getTestTask, nodeBunDevToolTasks, pmToRt } from "./utils.js";
6
+ //#region src/webframeworks/sveltekit.ts
7
+ const sveltekitDescription = {
8
+ label: "SvelteKit",
9
+ packageManagers: PACKAGE_MANAGER,
10
+ defaultPort: 5173,
11
+ init: async ({ packageManager: pm, testMode }) => ({
12
+ command: Array.from(getInitCommand(pm)),
13
+ dependencies: {
14
+ "@fedify/sveltekit": PACKAGE_VERSION,
15
+ ...pm === "deno" ? defaultDenoDependencies : {}
16
+ },
17
+ devDependencies: {
18
+ ...defaultDevDependencies,
19
+ "typescript": npm_typescript,
20
+ "@types/node": npm__types_node_25,
21
+ ...pmToRt(pm) === "deno" ? {} : { "@dotenvx/dotenvx": npm__dotenvx_dotenvx },
22
+ ...getTestDependencies(pm)
23
+ },
24
+ federationFile: "src/lib/federation.ts",
25
+ loggingFile: "src/lib/logging.ts",
26
+ testFile: "scripts/smoke.test.ts",
27
+ env: testMode ? { HOST: "127.0.0.1" } : {},
28
+ files: { "src/hooks.server.ts": await readTemplate("sveltekit/hooks.server.ts") },
29
+ tasks: pmToRt(pm) === "deno" ? { test: getTestTask("deno") } : {
30
+ ...TASKS,
31
+ test: getTestTask(pm)
32
+ },
33
+ instruction: getInstruction(pm, 5173)
34
+ })
35
+ };
36
+ /**
37
+ * Returns the shell command array to scaffold a new SvelteKit project
38
+ * in the current directory using the given package manager.
39
+ */
40
+ function* getInitCommand(pm) {
41
+ yield* getSvelteKitInitCommand(pm);
42
+ yield* [
43
+ ".",
44
+ "--template",
45
+ "minimal",
46
+ "--types",
47
+ "ts",
48
+ "--no-add-ons",
49
+ "--no-dir-check",
50
+ "--no-download-check",
51
+ "--install",
52
+ pm
53
+ ];
54
+ }
55
+ const getSvelteKitInitCommand = (pm) => pm === "bun" ? [
56
+ "bunx",
57
+ "sv",
58
+ "create"
59
+ ] : pm === "deno" ? [
60
+ "deno",
61
+ "run",
62
+ "-A",
63
+ "npm:sv",
64
+ "create"
65
+ ] : pm === "npm" ? [
66
+ "npx",
67
+ "sv",
68
+ "create"
69
+ ] : [
70
+ pm,
71
+ "dlx",
72
+ "sv",
73
+ "create"
74
+ ];
75
+ const TASKS = {
76
+ "dev": "dotenvx run -- vite dev",
77
+ "build": "dotenvx run -- vite build",
78
+ "preview": "dotenvx run -- vite preview",
79
+ ...nodeBunDevToolTasks
80
+ };
81
+ //#endregion
82
+ export { sveltekitDescription as default };
@@ -1,4 +1,5 @@
1
1
  import { getDevCommand } from "../lib.js";
2
+ import { "npm:tsx" as npm_tsx } from "../json/deps.js";
2
3
  import { commandLine, message } from "@optique/core/message";
3
4
  //#region src/webframeworks/utils.ts
4
5
  const nodeBunDevToolTasks = {
@@ -7,6 +8,19 @@ const nodeBunDevToolTasks = {
7
8
  lint: "oxlint ."
8
9
  };
9
10
  const getNodeBunDevToolTasks = (pm) => pm === "deno" ? {} : nodeBunDevToolTasks;
11
+ const SMOKE_TEST_FILE = "scripts/smoke.test.ts";
12
+ /**
13
+ * Returns the `test` task command that runs the generated smoke-test
14
+ * script (`WebFrameworkInitializer.testFile`) with the runtime matching the
15
+ * given package manager.
16
+ */
17
+ const getTestTask = (pm) => pmToRt(pm) === "deno" ? `deno run -A ${SMOKE_TEST_FILE}` : pmToRt(pm) === "bun" ? `bun run ${SMOKE_TEST_FILE}` : `tsx ${SMOKE_TEST_FILE}`;
18
+ /**
19
+ * Returns the dev dependencies the `test` task needs beyond what the
20
+ * framework already declares. Node.js runs the smoke-test script through
21
+ * `tsx`; Deno and Bun execute TypeScript natively.
22
+ */
23
+ const getTestDependencies = (pm) => pmToRt(pm) === "node" ? { tsx: npm_tsx } : {};
10
24
  /**
11
25
  * Generates the post-initialization instruction message that shows
12
26
  * the user how to start the dev server and look up an actor.
@@ -32,4 +46,4 @@ Then, try to look up an actor from your server:
32
46
  */
33
47
  const pmToRt = (pm) => pm !== "deno" && pm !== "bun" ? "node" : pm;
34
48
  //#endregion
35
- export { getInstruction, getNodeBunDevToolTasks, nodeBunDevToolTasks, pmToRt };
49
+ export { getInstruction, getNodeBunDevToolTasks, getTestDependencies, getTestTask, nodeBunDevToolTasks, pmToRt };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/init",
3
- "version": "2.4.0-pr.936.41+59c7432c",
3
+ "version": "2.4.0",
4
4
  "description": "Project initializer for Fedify",
5
5
  "keywords": [
6
6
  "fedify",
@@ -46,18 +46,19 @@
46
46
  ],
47
47
  "dependencies": {
48
48
  "@david/dax": "npm:dax@^0.46.1",
49
- "@fxts/core": "^1.20.0",
49
+ "@fxts/core": "^1.21.1",
50
50
  "@inquirer/prompts": "^7.8.4",
51
51
  "@logtape/logtape": "^2.2.0",
52
- "@optique/core": "^1.1.0",
53
- "@optique/run": "^1.1.0",
52
+ "@optique/core": "^1.3.2",
53
+ "@optique/run": "^1.3.2",
54
54
  "chalk": "^5.6.2",
55
55
  "es-toolkit": "1.46.1",
56
56
  "inquirer-toggle": "^1.0.1",
57
57
  "jsonc-parser": "^3.3.1"
58
58
  },
59
59
  "devDependencies": {
60
- "@types/node": "^22.17.0",
60
+ "@std/assert": "npm:@jsr/std__assert@^1.0.13",
61
+ "@types/node": "^24.12.2",
61
62
  "tsdown": "^0.22.0",
62
63
  "typescript": "^6.0.0"
63
64
  },