@fedify/init 2.1.0-dev.421 → 2.1.0-dev.438

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.
@@ -1,7 +1,7 @@
1
1
  import { CommandError, printErrorMessage, printMessage, product, runSubCommand } from "../utils.js";
2
2
  import pm_default from "../json/pm.js";
3
3
  import { kvStores, messageQueues } from "../lib.js";
4
- import webframeworks_default from "../webframeworks.js";
4
+ import webframeworks_default from "../webframeworks/mod.js";
5
5
  import { filter, isEmpty, pipe, toArray } from "@fxts/core";
6
6
  import process from "node:process";
7
7
  import { values } from "@optique/core";
@@ -38,6 +38,9 @@ const createTestApp = (testDirPrefix, dry) => async (options) => {
38
38
  });
39
39
  }
40
40
  printMessage` Fail: ${vals}`;
41
+ printMessage` Check out these files for more details:
42
+ ${join$1(testDir, "out.txt")} and
43
+ ${join$1(testDir, "err.txt")}\n`;
41
44
  return "";
42
45
  }
43
46
  };
@@ -57,7 +60,7 @@ function* genInitCommand(testDir, dry, [webFramework, packageManager, kvStore, m
57
60
  yield kvStore;
58
61
  yield "-m";
59
62
  yield messageQueue;
60
- if (dry) yield "-d";
63
+ if (dry) yield "--dry-run";
61
64
  }
62
65
  const generateTestCases = ({ webFramework, packageManager, kvStore, messageQueue }) => {
63
66
  const pms = filterPackageManager(packageManager);
@@ -1,6 +1,6 @@
1
1
  import { printErrorMessage, printMessage, runSubCommand } from "../utils.js";
2
2
  import { getDevCommand } from "../lib.js";
3
- import webframeworks_default from "../webframeworks.js";
3
+ import webframeworks_default from "../webframeworks/mod.js";
4
4
  import process from "node:process";
5
5
  import { values } from "@optique/core";
6
6
  import { spawn } from "node:child_process";
@@ -53,7 +53,7 @@ async function testApp(dir) {
53
53
  kv,
54
54
  mq
55
55
  ])}...`;
56
- const result = await serverClosure(dir, getDevCommand(pm), sendLookup);
56
+ const result = await serverClosure(dir, getDevCommand(pm), sendLookup).catch(() => false);
57
57
  printMessage` Lookup ${result ? "successful" : "failed"} for ${values([
58
58
  wf,
59
59
  pm,
@@ -7,7 +7,7 @@ import { tmpdir } from "node:os";
7
7
  const genRunId = () => `${Date.now()}-${Math.random().toString(36).slice(2)}`;
8
8
  const genTestDirPrefix = ({ runId }) => join(tmpdir(), "fedify-init", runId);
9
9
  const emptyTestDir = ({ testDirPrefix }) => rm(testDirPrefix, { recursive: true }).catch(() => {});
10
- const logTestDir = ({ runId, testDirPrefix }) => printMessage`Test run completed.
10
+ const logTestDir = ({ runId, testDirPrefix }) => printMessage`Test running with
11
11
  Run ID: ${runId}
12
12
  Path: ${testDirPrefix}`;
13
13
 
package/dist/types.d.ts CHANGED
@@ -4,47 +4,108 @@ import { RequiredNotNull } from "./utils.js";
4
4
  import { Message } from "@optique/core";
5
5
 
6
6
  //#region src/types.d.ts
7
+ /** Supported package manager identifiers: `"deno"`, `"pnpm"`, `"bun"`, `"yarn"`, `"npm"`. */
7
8
  type PackageManager = typeof PACKAGE_MANAGER[number];
9
+ /** Supported web framework identifiers: `"hono"`, `"nitro"`, `"next"`, `"elysia"`, `"astro"`, `"express"`. */
10
+
11
+ /**
12
+ * The result returned by a web framework's `init()` function.
13
+ * Contains all the information needed to scaffold a project for that framework,
14
+ * including dependencies, template files, compiler options, and task scripts.
15
+ */
8
16
  interface WebFrameworkInitializer {
17
+ /** Optional shell command to run before scaffolding (e.g., `create-next-app`). */
9
18
  command?: string[];
19
+ /** Runtime dependencies to install (package name to version). */
10
20
  dependencies?: object;
21
+ /** Development-only dependencies to install (package name to version). */
11
22
  devDependencies?: object;
23
+ /** Relative path where the federation configuration file will be created. */
12
24
  federationFile: string;
25
+ /** Relative path where the logging configuration file will be created. */
13
26
  loggingFile: string;
27
+ /** Additional files to create, keyed by relative path to file content. */
14
28
  files?: Record<string, string>;
29
+ /** TypeScript compiler options to include in `tsconfig.json`. */
15
30
  compilerOptions?: Record<string, string | boolean | number | string[] | null>;
31
+ /** Task scripts keyed by task name (e.g., `"dev"`, `"prod"`, `"lint"`). */
16
32
  tasks?: Record<string, string>;
33
+ /** Instructions shown to the user after project initialization is complete. */
17
34
  instruction: Message;
18
35
  }
36
+ /**
37
+ * Describes a web framework integration (Hono, Express, Nitro, Next.js,
38
+ * ElysiaJS, Astro) and how to initialize a project with it.
39
+ */
40
+
41
+ /**
42
+ * Describes a message queue backend (Deno KV, Redis, PostgreSQL, AMQP) and
43
+ * the dependencies, imports, and environment variables it requires.
44
+ */
19
45
  interface MessageQueueDescription {
46
+ /** Human-readable name of the message queue backend. */
20
47
  label: string;
48
+ /** Package managers that this message queue supports. */
21
49
  packageManagers: readonly PackageManager[];
50
+ /** Runtime dependencies required by this message queue. */
22
51
  dependencies?: Record<string, string>;
52
+ /** Development-only dependencies required by this message queue. */
23
53
  devDependencies?: Record<string, string>;
54
+ /** ES module imports needed, keyed by module specifier to named exports. */
24
55
  imports: Record<string, Record<string, string>>;
56
+ /** TypeScript expression that creates the message queue instance. */
25
57
  object: string;
58
+ /** Deno unstable feature flags required (e.g., `["kv"]`). */
26
59
  denoUnstable?: string[];
60
+ /** Environment variables required, keyed by name to default value. */
27
61
  env?: Record<string, string>;
28
62
  }
63
+ /**
64
+ * Describes a key-value store backend (Deno KV, Redis, PostgreSQL) and
65
+ * the dependencies, imports, and environment variables it requires.
66
+ */
29
67
  interface KvStoreDescription {
68
+ /** Human-readable name of the key-value store backend. */
30
69
  label: string;
70
+ /** Package managers that this KV store supports. */
31
71
  packageManagers: readonly PackageManager[];
72
+ /** Runtime dependencies required by this KV store. */
32
73
  dependencies?: Record<string, string>;
74
+ /** Development-only dependencies required by this KV store. */
33
75
  devDependencies?: Record<string, string>;
76
+ /** ES module imports needed, keyed by module specifier to named exports. */
34
77
  imports: Record<string, Record<string, string>>;
78
+ /** TypeScript expression that creates the KV store instance. */
35
79
  object: string;
80
+ /** Deno unstable feature flags required (e.g., `["kv"]`). */
36
81
  denoUnstable?: string[];
82
+ /** Environment variables required, keyed by name to default value. */
37
83
  env?: Record<string, string>;
38
84
  }
85
+ /**
86
+ * Fully resolved initialization options with all fields guaranteed non-null.
87
+ * Created after the user has answered all interactive prompts.
88
+ */
39
89
  type InitCommandOptions = RequiredNotNull<InitCommand> & {
40
90
  readonly testMode: boolean;
41
91
  };
92
+ /**
93
+ * The complete data object used throughout the initialization process.
94
+ * Extends {@link InitCommandOptions} with derived fields such as the project
95
+ * name, framework initializer, KV/MQ descriptions, and environment variables.
96
+ */
42
97
  interface InitCommandData extends InitCommandOptions {
98
+ /** The project name, derived from the target directory's basename. */
43
99
  readonly projectName: string;
100
+ /** The resolved initializer configuration from the chosen web framework. */
44
101
  readonly initializer: WebFrameworkInitializer;
102
+ /** The resolved key-value store description. */
45
103
  readonly kv: KvStoreDescription;
104
+ /** The resolved message queue description. */
46
105
  readonly mq: MessageQueueDescription;
106
+ /** Combined environment variables from both KV store and message queue. */
47
107
  readonly env: Record<string, string>;
48
108
  }
109
+ /** A synchronous side-effect function that operates on {@link InitCommandData}. */
49
110
  //#endregion
50
111
  export { InitCommandData };
package/dist/utils.d.ts CHANGED
@@ -4,6 +4,9 @@ import { toMerged } from "es-toolkit";
4
4
  import { spawn } from "node:child_process";
5
5
 
6
6
  //#region src/utils.d.ts
7
+
8
+ /** Makes all properties of `T` required and non-nullable. */
7
9
  type RequiredNotNull<T> = { [P in keyof T]: NonNullable<T[P]> };
10
+ /** Type guard that checks whether a value is a `Promise`. */
8
11
  //#endregion
9
12
  export { RequiredNotNull };
package/dist/utils.js CHANGED
@@ -7,9 +7,25 @@ import { flow, toMerged } from "es-toolkit";
7
7
  import { spawn } from "node:child_process";
8
8
 
9
9
  //#region src/utils.ts
10
+ /**
11
+ * Whether terminal color output is enabled.
12
+ * `true` when stdout is a TTY and the `NO_COLOR` environment variable is not set.
13
+ */
10
14
  const colorEnabled = process.stdout.isTTY && !("NO_COLOR" in process.env && process.env.NO_COLOR !== "");
15
+ /** Chalk instance configured based on {@link colorEnabled}. */
11
16
  const colors = new Chalk(colorEnabled ? {} : { level: 0 });
17
+ /** Type guard that checks whether a value is a `Promise`. */
12
18
  const isPromise = (value) => value instanceof Promise;
19
+ /**
20
+ * Functional composition helper that adds a computed property to an object.
21
+ * Returns a function that takes an object, computes a value using `f`, and
22
+ * returns a new object with the additional property `key` set to the result.
23
+ * Handles both synchronous and asynchronous computations.
24
+ *
25
+ * @param key - The property key to add
26
+ * @param f - A function that computes the value from the input object
27
+ * @returns A function that augments the input object with the computed property
28
+ */
13
29
  function set(key, f) {
14
30
  return (obj) => {
15
31
  const result = f(obj);
@@ -23,12 +39,31 @@ function set(key, f) {
23
39
  };
24
40
  };
25
41
  }
42
+ /**
43
+ * Curried deep merge helper. Returns a function that merges `source` into the
44
+ * given `target` object using `es-toolkit`'s `toMerged`.
45
+ */
26
46
  const merge$1 = (source = {}) => (target = {}) => toMerged(target, source);
47
+ /**
48
+ * Curried `String.prototype.replace`. Returns a function that performs the
49
+ * replacement on the given text.
50
+ */
27
51
  const replace = (pattern, replacement) => (text$1) => text$1.replace(pattern, replacement);
52
+ /**
53
+ * Curried `String.prototype.replaceAll`. Returns a function that replaces all
54
+ * occurrences of the pattern in the given text.
55
+ */
28
56
  const replaceAll = (pattern, replacement) => (text$1) => text$1.replaceAll(pattern, replacement);
57
+ /** Serializes a value to a pretty-printed JSON string with a trailing newline. */
29
58
  const formatJson = (obj) => JSON.stringify(obj, null, 2) + "\n";
59
+ /** Checks whether a string or array-like value has a length greater than zero. */
30
60
  const notEmpty = (s) => s.length > 0;
61
+ /** Type guard that checks whether an error is a "file not found" (`ENOENT`) error. */
31
62
  const isNotFoundError = (e) => isObject(e) && "code" in e && e.code === "ENOENT";
63
+ /**
64
+ * Error thrown when a spawned shell command exits with a non-zero code.
65
+ * Captures stdout, stderr, exit code, and the original command array.
66
+ */
32
67
  var CommandError = class extends Error {
33
68
  commandLine;
34
69
  constructor(message$1, stdout, stderr, code, command$1) {
@@ -41,6 +76,16 @@ var CommandError = class extends Error {
41
76
  this.commandLine = command$1.join(" ");
42
77
  }
43
78
  };
79
+ /**
80
+ * Executes a shell command (or a chain of commands joined by `"&&"`) as child
81
+ * processes and returns the combined stdout/stderr output.
82
+ * Throws a {@link CommandError} if any command in the chain exits with a
83
+ * non-zero code.
84
+ *
85
+ * @param command - The command as an array of strings; use `"&&"` to chain
86
+ * @param options - Options forwarded to `node:child_process.spawn`
87
+ * @returns A promise resolving to `{ stdout, stderr }`
88
+ */
44
89
  const runSubCommand = async (command$1, options) => {
45
90
  const commands = command$1.reduce((acc, cur) => {
46
91
  if (cur === "&&") acc.push([]);
@@ -88,14 +133,29 @@ const runSingularCommand = (command$1, options) => new Promise((resolve, reject)
88
133
  reject(error);
89
134
  });
90
135
  });
136
+ /** Returns the current working directory. */
91
137
  const getCwd = () => process.cwd();
138
+ /** Returns the current OS platform (e.g., `"darwin"`, `"win32"`, `"linux"`). */
92
139
  const getOsType = () => process.platform;
140
+ /** Exits the process with the given exit code. */
93
141
  const exit = (code) => process.exit(code);
142
+ /**
143
+ * Generates the cartesian product of multiple iterables.
144
+ * Used by the test suite to enumerate all option combinations.
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * [...product(["a", "b"], [1, 2])]
149
+ * // [["a", 1], ["a", 2], ["b", 1], ["b", 2]]
150
+ * ```
151
+ */
94
152
  function* product(...[head, ...tail]) {
95
153
  if (!head) yield [];
96
154
  else for (const x of head) for (const xs of product(...tail)) yield [x, ...xs];
97
155
  }
156
+ /** Prints a formatted message to stdout using `@optique/run`'s `print`. */
98
157
  const printMessage = flow(message, print);
158
+ /** Prints a formatted error message to stderr using `@optique/run`'s `printError`. */
99
159
  const printErrorMessage = flow(message, printError);
100
160
 
101
161
  //#endregion
@@ -0,0 +1,83 @@
1
+ import { PACKAGE_VERSION, readTemplate } from "../lib.js";
2
+ import { PACKAGE_MANAGER } from "../const.js";
3
+ import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
4
+ import { getInstruction } from "./utils.js";
5
+
6
+ //#region src/webframeworks/astro.ts
7
+ const astroDescription = {
8
+ label: "Astro",
9
+ packageManagers: PACKAGE_MANAGER,
10
+ defaultPort: 4321,
11
+ init: ({ packageManager: pm }) => ({
12
+ command: Array.from(getAstroInitCommand(pm)),
13
+ dependencies: pm === "deno" ? {
14
+ ...defaultDenoDependencies,
15
+ "@deno/astro-adapter": "npm:@deno/astro-adapter@^0.3.2",
16
+ "@fedify/astro": PACKAGE_VERSION
17
+ } : {
18
+ "@astrojs/node": "^9.5.4",
19
+ "@fedify/astro": PACKAGE_VERSION
20
+ },
21
+ devDependencies: {
22
+ ...defaultDevDependencies,
23
+ ...pm !== "deno" ? {
24
+ typescript: "^5.9.3",
25
+ "@types/node": "^22.17.0"
26
+ } : {}
27
+ },
28
+ federationFile: "src/federation.ts",
29
+ loggingFile: "src/logging.ts",
30
+ files: {
31
+ [`astro.config.ts`]: readTemplate(`astro/astro.config.${pm === "deno" ? "deno" : "node"}.ts`),
32
+ "src/middleware.ts": readTemplate("astro/src/middleware.ts"),
33
+ ...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
34
+ },
35
+ compilerOptions: void 0,
36
+ tasks: {
37
+ ...pm === "deno" ? {
38
+ dev: "deno run -A npm:astro dev",
39
+ build: "deno run -A npm:astro build",
40
+ preview: "deno run -A npm:astro preview"
41
+ } : pm === "bun" ? {
42
+ dev: "bunx astro dev",
43
+ build: "bunx astro build",
44
+ preview: "bunx astro preview"
45
+ } : {
46
+ dev: "astro dev",
47
+ build: "astro build",
48
+ preview: "astro preview"
49
+ },
50
+ ...pm !== "deno" ? { lint: "eslint ." } : {}
51
+ },
52
+ instruction: getInstruction(pm, 4321)
53
+ })
54
+ };
55
+ var astro_default = astroDescription;
56
+ /**
57
+ * Returns the shell command array to scaffold a new Astro project
58
+ * in the current directory using the given package manager.
59
+ * Also removes the default `astro.config.mjs` so it can be replaced
60
+ * by a template.
61
+ */
62
+ function* getAstroInitCommand(pm) {
63
+ yield* createAstroAppCommand(pm);
64
+ yield "astro@latest";
65
+ yield ".";
66
+ yield "--";
67
+ yield "--no-git";
68
+ yield "--skip-houston";
69
+ yield "-y";
70
+ yield "&&";
71
+ yield "rm";
72
+ yield "astro.config.mjs";
73
+ if (pm === "deno") yield "package.json";
74
+ }
75
+ const createAstroAppCommand = (pm) => pm === "deno" ? [
76
+ "deno",
77
+ "init",
78
+ "-y",
79
+ "--npm"
80
+ ] : [pm, "create"];
81
+
82
+ //#endregion
83
+ export { astro_default as default };
@@ -0,0 +1,11 @@
1
+ import { PACKAGE_VERSION } from "../lib.js";
2
+
3
+ //#region src/webframeworks/const.ts
4
+ const defaultDevDependencies = {
5
+ "@fedify/lint": PACKAGE_VERSION,
6
+ "eslint": "^9.0.0"
7
+ };
8
+ const defaultDenoDependencies = { "@fedify/lint": PACKAGE_VERSION };
9
+
10
+ //#endregion
11
+ export { defaultDenoDependencies, defaultDevDependencies };
@@ -0,0 +1,66 @@
1
+ import { PACKAGE_VERSION, readTemplate } from "../lib.js";
2
+ import { PACKAGE_MANAGER } from "../const.js";
3
+ import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
4
+ import { getInstruction, packageManagerToRuntime } from "./utils.js";
5
+
6
+ //#region src/webframeworks/elysia.ts
7
+ const elysiaDescription = {
8
+ label: "ElysiaJS",
9
+ packageManagers: PACKAGE_MANAGER,
10
+ defaultPort: 3e3,
11
+ init: ({ projectName, packageManager: pm }) => ({
12
+ dependencies: pm === "deno" ? {
13
+ ...defaultDenoDependencies,
14
+ elysia: "npm:elysia@^1.3.6",
15
+ "@fedify/elysia": PACKAGE_VERSION
16
+ } : pm === "bun" ? {
17
+ elysia: "^1.3.6",
18
+ "@fedify/elysia": PACKAGE_VERSION
19
+ } : {
20
+ elysia: "^1.3.6",
21
+ "@elysiajs/node": "^1.4.2",
22
+ "@fedify/elysia": PACKAGE_VERSION,
23
+ ...pm === "pnpm" ? {
24
+ "@sinclair/typebox": "^0.34.41",
25
+ "openapi-types": "^12.1.3"
26
+ } : {}
27
+ },
28
+ devDependencies: {
29
+ ...pm === "bun" ? { "@types/bun": "^1.2.19" } : {
30
+ tsx: "^4.21.0",
31
+ "@types/node": "^25.0.3",
32
+ typescript: "^5.9.3"
33
+ },
34
+ ...defaultDevDependencies
35
+ },
36
+ federationFile: "src/federation.ts",
37
+ loggingFile: "src/logging.ts",
38
+ files: {
39
+ "src/index.ts": readTemplate(`elysia/index/${packageManagerToRuntime(pm)}.ts`).replace(/\/\* logger \*\//, projectName),
40
+ ...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
41
+ },
42
+ compilerOptions: pm === "deno" || pm === "bun" ? void 0 : {
43
+ "lib": ["ESNext", "DOM"],
44
+ "target": "ESNext",
45
+ "module": "NodeNext",
46
+ "moduleResolution": "NodeNext",
47
+ "allowImportingTsExtensions": true,
48
+ "verbatimModuleSyntax": true,
49
+ "noEmit": true,
50
+ "strict": true
51
+ },
52
+ tasks: {
53
+ "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",
54
+ ...pm === "deno" ? { "prod": "deno serve --allow-env --allow-net ./src/index.ts" } : pm === "bun" ? { "prod": "bun run ./src/index.ts" } : {
55
+ "build": "tsc src/index.ts --outDir dist",
56
+ "start": "NODE_ENV=production node dist/index.js"
57
+ },
58
+ ...pm !== "deno" ? { "lint": "eslint ." } : {}
59
+ },
60
+ instruction: getInstruction(pm, 3e3)
61
+ })
62
+ };
63
+ var elysia_default = elysiaDescription;
64
+
65
+ //#endregion
66
+ export { elysia_default as default };
@@ -0,0 +1,54 @@
1
+ import { PACKAGE_VERSION, readTemplate } from "../lib.js";
2
+ import { PACKAGE_MANAGER } from "../const.js";
3
+ import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
4
+ import { getInstruction } from "./utils.js";
5
+
6
+ //#region src/webframeworks/express.ts
7
+ const expressDescription = {
8
+ label: "Express",
9
+ packageManagers: PACKAGE_MANAGER,
10
+ defaultPort: 8e3,
11
+ init: ({ projectName, packageManager: pm }) => ({
12
+ dependencies: {
13
+ "npm:express": "^4.19.2",
14
+ "@fedify/express": PACKAGE_VERSION,
15
+ ...pm !== "deno" && pm !== "bun" ? {
16
+ "@dotenvx/dotenvx": "^1.14.1",
17
+ tsx: "^4.17.0"
18
+ } : {},
19
+ ...pm === "deno" ? defaultDenoDependencies : {}
20
+ },
21
+ devDependencies: {
22
+ "@types/express": "^4.17.21",
23
+ ...pm === "bun" ? { "@types/bun": "^1.1.6" } : {},
24
+ ...defaultDevDependencies
25
+ },
26
+ federationFile: "src/federation.ts",
27
+ loggingFile: "src/logging.ts",
28
+ files: {
29
+ "src/app.ts": readTemplate("express/app.ts").replace(/\/\* logger \*\//, projectName),
30
+ "src/index.ts": readTemplate("express/index.ts"),
31
+ ...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
32
+ },
33
+ compilerOptions: pm === "deno" ? void 0 : {
34
+ "lib": ["ESNext", "DOM"],
35
+ "target": "ESNext",
36
+ "module": "NodeNext",
37
+ "moduleResolution": "NodeNext",
38
+ "allowImportingTsExtensions": true,
39
+ "verbatimModuleSyntax": true,
40
+ "noEmit": true,
41
+ "strict": true
42
+ },
43
+ tasks: {
44
+ "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",
45
+ "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",
46
+ ...pm !== "deno" ? { "lint": "eslint ." } : {}
47
+ },
48
+ instruction: getInstruction(pm, 8e3)
49
+ })
50
+ };
51
+ var express_default = expressDescription;
52
+
53
+ //#endregion
54
+ export { express_default as default };
@@ -0,0 +1,66 @@
1
+ import { replace } from "../utils.js";
2
+ import { PACKAGE_VERSION, readTemplate } from "../lib.js";
3
+ import { PACKAGE_MANAGER } from "../const.js";
4
+ import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
5
+ import { getInstruction, packageManagerToRuntime } from "./utils.js";
6
+ import { pipe } from "@fxts/core";
7
+
8
+ //#region src/webframeworks/hono.ts
9
+ const honoDescription = {
10
+ label: "Hono",
11
+ packageManagers: PACKAGE_MANAGER,
12
+ defaultPort: 8e3,
13
+ init: ({ projectName, packageManager: pm }) => ({
14
+ dependencies: pm === "deno" ? {
15
+ ...defaultDenoDependencies,
16
+ "@std/dotenv": "^0.225.2",
17
+ "@hono/hono": "^4.5.0",
18
+ "@hongminhee/x-forwarded-fetch": "^0.2.0",
19
+ "@fedify/hono": PACKAGE_VERSION
20
+ } : pm === "bun" ? {
21
+ hono: "^4.5.0",
22
+ "x-forwarded-fetch": "^0.2.0",
23
+ "@fedify/hono": PACKAGE_VERSION
24
+ } : {
25
+ "@dotenvx/dotenvx": "^1.14.1",
26
+ hono: "^4.5.0",
27
+ "@hono/node-server": "^1.12.0",
28
+ tsx: "^4.17.0",
29
+ "x-forwarded-fetch": "^0.2.0",
30
+ "@fedify/hono": PACKAGE_VERSION
31
+ },
32
+ devDependencies: {
33
+ ...defaultDevDependencies,
34
+ ...pm === "bun" ? { "@types/bun": "^1.1.6" } : {}
35
+ },
36
+ federationFile: "src/federation.ts",
37
+ loggingFile: "src/logging.ts",
38
+ files: {
39
+ "src/app.tsx": pipe("hono/app.tsx", readTemplate, replace(/\/\* hono \*\//, pm === "deno" ? "@hono/hono" : "hono"), replace(/\/\* logger \*\//, projectName)),
40
+ "src/index.ts": readTemplate(`hono/index/${packageManagerToRuntime(pm)}.ts`),
41
+ ...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
42
+ },
43
+ compilerOptions: pm === "deno" ? void 0 : {
44
+ "lib": ["ESNext", "DOM"],
45
+ "target": "ESNext",
46
+ "module": "NodeNext",
47
+ "moduleResolution": "NodeNext",
48
+ "allowImportingTsExtensions": true,
49
+ "verbatimModuleSyntax": true,
50
+ "noEmit": true,
51
+ "strict": true,
52
+ "jsx": "react-jsx",
53
+ "jsxImportSource": "hono/jsx"
54
+ },
55
+ tasks: {
56
+ "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",
57
+ "prod": pm === "deno" ? "deno run -A ./src/index.ts" : pm === "bun" ? "bun run ./src/index.ts" : "dotenvx run -- node --import tsx ./src/index.ts",
58
+ ...pm !== "deno" ? { "lint": "eslint ." } : {}
59
+ },
60
+ instruction: getInstruction(pm, 8e3)
61
+ })
62
+ };
63
+ var hono_default = honoDescription;
64
+
65
+ //#endregion
66
+ export { hono_default as default };
@@ -0,0 +1,27 @@
1
+ import astro_default from "./astro.js";
2
+ import elysia_default from "./elysia.js";
3
+ import express_default from "./express.js";
4
+ import hono_default from "./hono.js";
5
+ import next_default from "./next.js";
6
+ import nitro_default from "./nitro.js";
7
+
8
+ //#region src/webframeworks/mod.ts
9
+ /**
10
+ * Registry of all supported web framework configurations.
11
+ * Each entry defines the framework's label, supported package managers,
12
+ * default port, and an `init()` factory that produces a
13
+ * {@link WebFrameworkInitializer} with dependencies, templates, tasks,
14
+ * and instructions tailored to the selected package manager.
15
+ */
16
+ const webFrameworks = {
17
+ astro: astro_default,
18
+ elysia: elysia_default,
19
+ express: express_default,
20
+ hono: hono_default,
21
+ next: next_default,
22
+ nitro: nitro_default
23
+ };
24
+ var webframeworks_default = webFrameworks;
25
+
26
+ //#endregion
27
+ export { webframeworks_default as default };
@@ -0,0 +1,56 @@
1
+ import { PACKAGE_VERSION, readTemplate } from "../lib.js";
2
+ import { PACKAGE_MANAGER } from "../const.js";
3
+ import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
4
+ import { getInstruction } from "./utils.js";
5
+
6
+ //#region src/webframeworks/next.ts
7
+ const nextDescription = {
8
+ label: "Next.js",
9
+ packageManagers: PACKAGE_MANAGER,
10
+ defaultPort: 3e3,
11
+ init: ({ packageManager: pm }) => ({
12
+ command: getNextInitCommand(pm),
13
+ dependencies: {
14
+ "@fedify/next": PACKAGE_VERSION,
15
+ ...pm === "deno" ? defaultDenoDependencies : {}
16
+ },
17
+ devDependencies: {
18
+ "@types/node": "^20.11.2",
19
+ ...defaultDevDependencies
20
+ },
21
+ federationFile: "federation/index.ts",
22
+ loggingFile: "logging.ts",
23
+ files: {
24
+ "middleware.ts": readTemplate("next/middleware.ts"),
25
+ ...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
26
+ },
27
+ tasks: { ...pm !== "deno" ? { "lint": "eslint ." } : {} },
28
+ instruction: getInstruction(pm, 3e3)
29
+ })
30
+ };
31
+ var next_default = nextDescription;
32
+ /**
33
+ * Returns the shell command array to scaffold a new Next.js project
34
+ * in the current directory using the given package manager.
35
+ */
36
+ const getNextInitCommand = (pm) => [
37
+ ...createNextAppCommand(pm),
38
+ ".",
39
+ "--yes"
40
+ ];
41
+ const createNextAppCommand = (pm) => pm === "deno" ? [
42
+ "deno",
43
+ "-Ar",
44
+ "npm:create-next-app@latest"
45
+ ] : pm === "bun" ? [
46
+ "bun",
47
+ "create",
48
+ "next-app"
49
+ ] : pm === "npm" ? ["npx", "create-next-app"] : [
50
+ pm,
51
+ "dlx",
52
+ "create-next-app"
53
+ ];
54
+
55
+ //#endregion
56
+ export { next_default as default };