@fedify/init 2.2.0-dev.664 → 2.2.0-dev.677

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,8 +1,8 @@
1
1
  import { merge, replace } from "../utils.js";
2
2
  import { PACKAGE_VERSION } from "../lib.js";
3
- import { _logtape_logtape } from "../json/deps.js";
3
+ import { _logtape_logtape, _std_dotenv } from "../json/deps.js";
4
4
  import { getPackagesPath } from "./const.js";
5
- import { isDeno } from "./utils.js";
5
+ import { isDeno, needsDenoDotenv } from "./utils.js";
6
6
  import { always, entries, filter, fromEntries, map, pipe, when } from "@fxts/core";
7
7
  import { join as join$1 } from "node:path";
8
8
  //#region src/action/deps.ts
@@ -14,10 +14,14 @@ import { join as join$1 } from "node:path";
14
14
  * message queue descriptions
15
15
  * @returns A record of dependencies with their versions
16
16
  */
17
- const getDependencies = ({ initializer, kv, mq, testMode, packageManager }) => pipe({
17
+ const getDependencies = ({ initializer, kv, mq, env, testMode, packageManager }) => pipe({
18
18
  "@fedify/fedify": PACKAGE_VERSION,
19
19
  "@fedify/vocab": PACKAGE_VERSION,
20
- "@logtape/logtape": _logtape_logtape
20
+ "@logtape/logtape": _logtape_logtape,
21
+ ...needsDenoDotenv({
22
+ packageManager,
23
+ env
24
+ }) && { "@std/dotenv": _std_dotenv }
21
25
  }, merge(initializer.dependencies), merge(kv.dependencies), merge(mq.dependencies), when(always(testMode), isDeno({ packageManager }) ? removeFedifyDeps : addLocalFedifyDeps), normalizePackageNames(packageManager));
22
26
  const removeFedifyDeps = (deps) => pipe(deps, entries, filter(([name]) => !name.includes("@fedify")), fromEntries);
23
27
  const addLocalFedifyDeps = (deps) => pipe(deps, entries, map(when(([name]) => name.includes("@fedify/"), ([name, _version]) => [name, convertFedifyToLocal(name)])), fromEntries);
@@ -20,6 +20,6 @@ const setProjectName = set("projectName", async ({ dir }) => basename(existsSync
20
20
  const setInitializer = set("initializer", (data) => webFrameworks[data.webFramework].init(data));
21
21
  const setKv = set("kv", ({ kvStore }) => kvStores[kvStore]);
22
22
  const setMq = set("mq", ({ messageQueue }) => messageQueues[messageQueue]);
23
- const setEnv = set("env", ({ kv, mq }) => merge(kv.env)(mq.env));
23
+ const setEnv = set("env", ({ initializer, kv, mq }) => merge(initializer.env)(merge(kv.env)(mq.env)));
24
24
  //#endregion
25
25
  export { setData as default };
@@ -1,13 +1,16 @@
1
1
  import { replace } from "../utils.js";
2
2
  import { readTemplate } from "../lib.js";
3
- import { entries, join, map, pipe } from "@fxts/core";
3
+ import { needsDenoDotenv } from "./utils.js";
4
+ import { concat, entries, join, map, pipe, when } from "@fxts/core";
4
5
  import { toMerged } from "es-toolkit";
5
6
  //#region src/action/templates.ts
6
7
  /**
7
8
  * Loads the federation configuration file content from template.
8
- * Reads the default federation template and replaces placeholders with actual configuration values.
9
+ * Reads the default federation template and replaces placeholders with actual
10
+ * configuration values.
9
11
  *
10
- * @param param0 - Configuration object containing imports, project name, KV store, message queue, and package manager
12
+ * @param param0 - Configuration object containing imports, project name,
13
+ * KV store, message queue, and package manager
11
14
  * @returns The complete federation configuration file content as a string
12
15
  */
13
16
  const loadFederation = async ({ imports, projectName, kv, mq, packageManager }) => pipe(await readTemplate("defaults/federation.ts"), replace(/\/\* imports \*\//, imports), replace(/\/\* logger \*\//, JSON.stringify(projectName)), replace(/\/\* kv \*\//, convertEnv(kv.object, packageManager)), replace(/\/\* queue \*\//, convertEnv(mq.object, packageManager)));
@@ -21,19 +24,30 @@ const loadFederation = async ({ imports, projectName, kv, mq, packageManager })
21
24
  const loadLogging = async ({ projectName }) => pipe(await readTemplate("defaults/logging.ts"), replace(/\/\* project name \*\//, JSON.stringify(projectName)));
22
25
  /**
23
26
  * Generates import statements for KV store and message queue dependencies.
24
- * Merges imports from both KV and MQ configurations and creates proper ES module import syntax.
27
+ * Merges imports from both KV and MQ configurations and creates proper
28
+ * ES module import syntax.
25
29
  *
26
- * @param param0 - Destructured object containing kv and mq configurations
30
+ * Destructured parameters:
31
+ * - kv: KV store configuration, including module import mappings
32
+ * - mq: Message queue configuration, including module import mappings
33
+ * - packageManager: Package manager used for environment-specific handling
34
+ * - env: Environment variable setup used to determine loading requirements
35
+ *
36
+ * @param param0 - InitCommandData containing kv, mq, packageManager, and env
27
37
  * @returns A multi-line string containing all necessary import statements
28
38
  */
29
- const getImports = ({ kv, mq }) => pipe(toMerged(kv.imports, mq.imports), entries, map(([module, { "default": defaultImport = "", ...imports }]) => [
39
+ const getImports = ({ kv, mq, packageManager, env }) => pipe(toMerged(kv.imports, mq.imports), entries, map(([module, { "default": defaultImport = "", ...imports }]) => [
30
40
  module,
31
41
  defaultImport,
32
42
  getAlias(imports)
33
- ]), map(([module, defaultImport, namedImports]) => `import ${[defaultImport, namedImports.length > 0 ? `{ ${namedImports} }` : ""].filter((x) => x.length > 0).join(", ")} from ${JSON.stringify(module)};`), join("\n"));
43
+ ]), map(([module, defaultImport, namedImports]) => `import ${[defaultImport, namedImports.length > 0 ? `{ ${namedImports} }` : ""].filter((x) => x.length > 0).join(", ")} from ${JSON.stringify(module)};`), when(() => needsDenoDotenv({
44
+ packageManager,
45
+ env
46
+ }), concat(["import \"@std/dotenv/load\";"])), join("\n"));
34
47
  /**
35
48
  * Converts import mappings to named import string with aliases.
36
- * Creates proper ES module named import syntax, using aliases when the import name differs from the local name.
49
+ * Creates proper ES module named import syntax, using aliases when the import
50
+ * name differs from the local name.
37
51
  *
38
52
  * @param imports - A record mapping import names to their local aliases
39
53
  * @returns A comma-separated string of named imports with aliases where needed
@@ -41,12 +55,16 @@ const getImports = ({ kv, mq }) => pipe(toMerged(kv.imports, mq.imports), entrie
41
55
  const getAlias = (imports) => pipe(imports, entries, map(([name, alias]) => name === alias ? name : `${name} as ${alias}`), join(", "));
42
56
  const ENV_REG_EXP = /process\.env\.(\w+)/g;
43
57
  /**
44
- * Converts Node.js environment variable access to Deno-compatible syntax when needed.
45
- * Transforms `process.env.VAR_NAME` to `Deno.env.get("VAR_NAME")` for Deno projects.
58
+ * Converts Node.js environment variable access to Deno-compatible syntax when
59
+ * needed.
60
+ * Transforms `process.env.VAR_NAME` to `Deno.env.get("VAR_NAME")` for Deno
61
+ * projects.
46
62
  *
47
- * @param obj - The object string containing potential environment variable references
63
+ * @param obj - The object string containing potential environment variable
64
+ * references
48
65
  * @param pm - The package manager (runtime) being used
49
- * @returns The converted object string with appropriate environment variable access syntax
66
+ * @returns The converted object string with appropriate environment variable
67
+ * access syntax
50
68
  */
51
69
  const convertEnv = (obj, pm) => pm === "deno" && ENV_REG_EXP.test(obj) ? obj.replaceAll(ENV_REG_EXP, (_, g1) => `Deno.env.get("${g1}")`) : obj;
52
70
  //#endregion
@@ -8,6 +8,11 @@ const hasCommand = (data) => !!data.initializer.command;
8
8
  /** Returns `true` if the selected package manager is Deno. */
9
9
  const isDeno = ({ packageManager }) => packageManager === "deno";
10
10
  /**
11
+ * Returns `true` when the `@std/dotenv` dependency should be included:
12
+ * the project uses Deno and has at least one environment variable to load.
13
+ */
14
+ const needsDenoDotenv = ({ packageManager, env }) => packageManager === "deno" && Object.keys(env).length > 0;
15
+ /**
11
16
  * Returns a function that prepends the project directory to a
12
17
  * `[filename, content]` tuple, resolving the filename into an absolute path.
13
18
  */
@@ -70,4 +75,4 @@ function* splitOnOperator(command) {
70
75
  if (current.length > 0) yield current;
71
76
  }
72
77
  //#endregion
73
- export { hasCommand, installDependencies, isDeno, isDry, joinDir, runPrecommand, stringifyEnvs };
78
+ export { hasCommand, installDependencies, isDeno, isDry, joinDir, needsDenoDotenv, runPrecommand, stringifyEnvs };
package/dist/deno.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region deno.json
2
- var version = "2.2.0-dev.664+53d88408";
2
+ var version = "2.2.0-dev.677+41046619";
3
3
  //#endregion
4
4
  export { version };
@@ -1,4 +1,3 @@
1
- import "@std/dotenv/load";
2
1
  import { behindProxy } from "@hongminhee/x-forwarded-fetch";
3
2
  import federation from "./federation.ts";
4
3
  import "./logging.ts";
@@ -1,5 +1,4 @@
1
1
  import { behindProxy } from "@hongminhee/x-forwarded-fetch";
2
- import "@std/dotenv/load";
3
2
  import app from "./app.tsx";
4
3
  import "./logging.ts";
5
4
 
package/dist/types.d.ts CHANGED
@@ -15,15 +15,25 @@ interface WebFrameworkInitializer {
15
15
  /** Optional shell command to run before scaffolding (e.g., `create-next-app`). */
16
16
  command?: string[];
17
17
  /** Runtime dependencies to install (package name to version). */
18
- dependencies?: object;
18
+ dependencies?: Record<string, string>;
19
19
  /** Development-only dependencies to install (package name to version). */
20
- devDependencies?: object;
20
+ devDependencies?: Record<string, string>;
21
21
  /** Relative path where the federation configuration file will be created. */
22
22
  federationFile: string;
23
23
  /** Relative path where the logging configuration file will be created. */
24
24
  loggingFile: string;
25
- /** Additional files to create, keyed by relative path to file content. */
26
- files?: Record<string, string>;
25
+ /**
26
+ * Additional files to create, keyed by relative path to file content.
27
+ * Do not use `".env"` as a key — use the {@link env} property instead so
28
+ * that environment variables are properly merged with KV/MQ env vars.
29
+ */
30
+ files?: Record<string, string> & {
31
+ ".env"?: never;
32
+ };
33
+ /** Environment variables required by this framework, keyed by name to
34
+ * default value. Merged together with KV store and message queue env vars
35
+ * into the generated `.env` file. */
36
+ env?: Record<string, string>;
27
37
  /** TypeScript compiler options to include in `tsconfig.json`. */
28
38
  compilerOptions?: Record<string, string | boolean | number | string[] | null>;
29
39
  /** Task scripts keyed by task name (e.g., `"dev"`, `"prod"`, `"lint"`). */
@@ -1,8 +1,8 @@
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__types_node_22, npm_typescript } from "../json/deps.js";
3
+ import { npm__astrojs_node, npm__deno_astro_adapter, npm__dotenvx_dotenvx, npm__types_node_22, npm_typescript } from "../json/deps.js";
4
4
  import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
5
- import { getInstruction } from "./utils.js";
5
+ import { getInstruction, pmToRt } from "./utils.js";
6
6
  //#region src/webframeworks/astro.ts
7
7
  const astroDescription = {
8
8
  label: "Astro",
@@ -16,7 +16,8 @@ const astroDescription = {
16
16
  "@fedify/astro": PACKAGE_VERSION
17
17
  } : {
18
18
  "@astrojs/node": npm__astrojs_node,
19
- "@fedify/astro": PACKAGE_VERSION
19
+ "@fedify/astro": PACKAGE_VERSION,
20
+ ...pm !== "bun" && { "@dotenvx/dotenvx": npm__dotenvx_dotenvx }
20
21
  },
21
22
  devDependencies: {
22
23
  ...defaultDevDependencies,
@@ -28,27 +29,11 @@ const astroDescription = {
28
29
  federationFile: "src/federation.ts",
29
30
  loggingFile: "src/logging.ts",
30
31
  files: {
31
- [`astro.config.ts`]: await readTemplate(`astro/astro.config.${pm === "deno" ? "deno" : "node"}.ts`),
32
+ "astro.config.ts": await readTemplate(`astro/astro.config.${pm === "deno" ? "deno" : "node"}.ts`),
32
33
  "src/middleware.ts": await readTemplate("astro/src/middleware.ts"),
33
- ...pm !== "deno" ? { "eslint.config.ts": await 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 ." } : {}
34
+ ...pm !== "deno" && { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") }
51
35
  },
36
+ tasks: TASKS[pmToRt(pm)],
52
37
  instruction: getInstruction(pm, 4321)
53
38
  })
54
39
  };
@@ -78,5 +63,24 @@ const createAstroAppCommand = (pm) => pm === "deno" ? [
78
63
  "-y",
79
64
  "--npm"
80
65
  ] : [pm, "create"];
66
+ const TASKS = {
67
+ "deno": {
68
+ dev: "deno run -A npm:astro dev",
69
+ build: "deno run -A npm:astro build",
70
+ preview: "deno run -A npm:astro preview"
71
+ },
72
+ "bun": {
73
+ dev: "bunx astro dev",
74
+ build: "bunx astro build",
75
+ preview: "bunx astro preview",
76
+ lint: "eslint ."
77
+ },
78
+ "node": {
79
+ dev: "dotenvx run -- astro dev",
80
+ build: "dotenvx run -- astro build",
81
+ preview: "dotenvx run -- astro preview",
82
+ lint: "eslint ."
83
+ }
84
+ };
81
85
  //#endregion
82
86
  export { astroDescription as default };
@@ -1,24 +1,15 @@
1
1
  import { readTemplate } from "../lib.js";
2
2
  import { PACKAGE_MANAGER } from "../const.js";
3
- import { _hongminhee_x_forwarded_fetch, _std_dotenv, npm__dotenvx_dotenvx, npm__hono_node_server, npm__types_bun, npm__types_node_25, npm_tsx, npm_x_forwarded_fetch } from "../json/deps.js";
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, packageManagerToRuntime } from "./utils.js";
5
+ import { getInstruction, pmToRt } from "./utils.js";
6
6
  //#region src/webframeworks/bare-bones.ts
7
7
  const bareBonesDescription = {
8
8
  label: "Bare-bones",
9
9
  packageManagers: PACKAGE_MANAGER,
10
10
  defaultPort: 8e3,
11
11
  init: async ({ packageManager: pm }) => ({
12
- dependencies: pm === "deno" ? {
13
- ...defaultDenoDependencies,
14
- "@std/dotenv": _std_dotenv,
15
- "@hongminhee/x-forwarded-fetch": _hongminhee_x_forwarded_fetch
16
- } : pm === "bun" ? { "npm:x-forwarded-fetch": npm_x_forwarded_fetch } : {
17
- "npm:@dotenvx/dotenvx": npm__dotenvx_dotenvx,
18
- "npm:@hono/node-server": npm__hono_node_server,
19
- "npm:tsx": npm_tsx,
20
- "npm:x-forwarded-fetch": npm_x_forwarded_fetch
21
- },
12
+ dependencies: getDependencies(pm),
22
13
  devDependencies: {
23
14
  ...defaultDevDependencies,
24
15
  ...pm === "bun" ? { "@types/bun": npm__types_bun } : { "@types/node": npm__types_node_25 }
@@ -26,8 +17,8 @@ const bareBonesDescription = {
26
17
  federationFile: "src/federation.ts",
27
18
  loggingFile: "src/logging.ts",
28
19
  files: {
29
- "src/main.ts": await readTemplate(`bare-bones/main/${packageManagerToRuntime(pm)}.ts`),
30
- ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
20
+ "src/main.ts": await readTemplate(`bare-bones/main/${pmToRt(pm)}.ts`),
21
+ ...pm !== "deno" && { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") }
31
22
  },
32
23
  compilerOptions: pm === "deno" ? {
33
24
  "jsx": "precompile",
@@ -42,12 +33,34 @@ const bareBonesDescription = {
42
33
  "noEmit": true,
43
34
  "strict": true
44
35
  },
45
- tasks: {
46
- "dev": pm === "deno" ? "deno run -A --watch ./src/main.ts" : pm === "bun" ? "bun run --hot ./src/main.ts" : "dotenvx run -- tsx watch ./src/main.ts",
47
- "prod": pm === "deno" ? "deno run -A ./src/main.ts" : pm === "bun" ? "bun run ./src/main.ts" : "dotenvx run -- node --import tsx ./src/main.ts"
48
- },
36
+ tasks: TASKS[pmToRt(pm)],
49
37
  instruction: getInstruction(pm, 8e3)
50
38
  })
51
39
  };
40
+ const getDependencies = (pm) => pm === "deno" ? {
41
+ ...defaultDenoDependencies,
42
+ "@hongminhee/x-forwarded-fetch": _hongminhee_x_forwarded_fetch
43
+ } : pm === "bun" ? { "npm:x-forwarded-fetch": npm_x_forwarded_fetch } : {
44
+ "npm:@dotenvx/dotenvx": npm__dotenvx_dotenvx,
45
+ "npm:@hono/node-server": npm__hono_node_server,
46
+ "npm:tsx": npm_tsx,
47
+ "npm:x-forwarded-fetch": npm_x_forwarded_fetch
48
+ };
49
+ const TASKS = {
50
+ deno: {
51
+ dev: "deno run -A --watch ./src/main.ts",
52
+ prod: "deno run -A ./src/main.ts"
53
+ },
54
+ bun: {
55
+ dev: "bun run --hot ./src/main.ts",
56
+ prod: "bun run ./src/main.ts",
57
+ lint: "eslint ."
58
+ },
59
+ node: {
60
+ dev: "dotenvx run -- tsx watch ./src/main.ts",
61
+ prod: "dotenvx run -- node --import tsx ./src/main.ts",
62
+ lint: "eslint ."
63
+ }
64
+ };
52
65
  //#endregion
53
66
  export { bareBonesDescription as default };
@@ -1,8 +1,8 @@
1
1
  import { PACKAGE_VERSION, readTemplate } from "../lib.js";
2
2
  import { PACKAGE_MANAGER } from "../const.js";
3
- import { 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";
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, packageManagerToRuntime } from "./utils.js";
5
+ import { getInstruction, pmToRt } from "./utils.js";
6
6
  //#region src/webframeworks/elysia.ts
7
7
  const elysiaDescription = {
8
8
  label: "ElysiaJS",
@@ -17,13 +17,14 @@ const elysiaDescription = {
17
17
  elysia: npm_elysia,
18
18
  "@fedify/elysia": PACKAGE_VERSION
19
19
  } : {
20
+ "@dotenvx/dotenvx": npm__dotenvx_dotenvx,
20
21
  elysia: npm_elysia,
21
22
  "@elysiajs/node": npm__elysiajs_node,
22
23
  "@fedify/elysia": PACKAGE_VERSION,
23
- ...pm === "pnpm" ? {
24
+ ...pm === "pnpm" && {
24
25
  "@sinclair/typebox": npm__sinclair_typebox,
25
26
  "openapi-types": npm_openapi_types
26
- } : {}
27
+ }
27
28
  },
28
29
  devDependencies: {
29
30
  ...pm === "bun" ? { "@types/bun": npm__types_bun } : {
@@ -36,8 +37,8 @@ const elysiaDescription = {
36
37
  federationFile: "src/federation.ts",
37
38
  loggingFile: "src/logging.ts",
38
39
  files: {
39
- "src/index.ts": (await readTemplate(`elysia/index/${packageManagerToRuntime(pm)}.ts`)).replace(/\/\* logger \*\//, projectName),
40
- ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
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") }
41
42
  },
42
43
  compilerOptions: pm === "deno" || pm === "bun" ? void 0 : {
43
44
  "lib": ["ESNext", "DOM"],
@@ -49,16 +50,26 @@ const elysiaDescription = {
49
50
  "noEmit": true,
50
51
  "strict": true
51
52
  },
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
- },
53
+ tasks: TASKS[pmToRt(pm)],
60
54
  instruction: getInstruction(pm, 3e3)
61
55
  })
62
56
  };
57
+ const TASKS = {
58
+ deno: {
59
+ dev: "deno serve --allow-read --allow-env --allow-net --watch ./src/index.ts",
60
+ prod: "deno serve --allow-read --allow-env --allow-net ./src/index.ts"
61
+ },
62
+ bun: {
63
+ dev: "bun run --hot ./src/index.ts",
64
+ prod: "bun run ./src/index.ts",
65
+ lint: "eslint ."
66
+ },
67
+ node: {
68
+ dev: "dotenvx run -- tsx watch src/index.ts",
69
+ build: "tsc src/index.ts --outDir dist",
70
+ start: "NODE_ENV=production dotenvx run -- node dist/index.js",
71
+ lint: "eslint ."
72
+ }
73
+ };
63
74
  //#endregion
64
75
  export { elysiaDescription as default };
@@ -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 } from "./utils.js";
5
+ import { getInstruction, pmToRt } from "./utils.js";
6
6
  //#region src/webframeworks/express.ts
7
7
  const expressDescription = {
8
8
  label: "Express",
@@ -12,11 +12,11 @@ const expressDescription = {
12
12
  dependencies: {
13
13
  "npm:express": npm_express,
14
14
  "@fedify/express": PACKAGE_VERSION,
15
- ...pm !== "deno" && pm !== "bun" ? {
15
+ ...pmToRt(pm) === "node" && {
16
16
  "@dotenvx/dotenvx": npm__dotenvx_dotenvx,
17
17
  tsx: npm_tsx
18
- } : {},
19
- ...pm === "deno" ? defaultDenoDependencies : {}
18
+ },
19
+ ...pm === "deno" && defaultDenoDependencies
20
20
  },
21
21
  devDependencies: {
22
22
  "@types/express": npm__types_express,
@@ -40,13 +40,25 @@ const expressDescription = {
40
40
  "noEmit": true,
41
41
  "strict": true
42
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
- },
43
+ tasks: TASKS[pmToRt(pm)],
48
44
  instruction: getInstruction(pm, 8e3)
49
45
  })
50
46
  };
47
+ const TASKS = {
48
+ deno: {
49
+ dev: "deno run --allow-read --allow-net --allow-env --allow-sys --watch ./src/index.ts",
50
+ prod: "deno run --allow-read --allow-net --allow-env --allow-sys ./src/index.ts"
51
+ },
52
+ bun: {
53
+ dev: "bun run --hot ./src/index.ts",
54
+ prod: "bun run ./src/index.ts",
55
+ lint: "eslint ."
56
+ },
57
+ node: {
58
+ dev: "dotenvx run -- tsx watch ./src/index.ts",
59
+ prod: "dotenvx run -- node --import tsx ./src/index.ts",
60
+ lint: "eslint ."
61
+ }
62
+ };
51
63
  //#endregion
52
64
  export { expressDescription as default };
@@ -1,9 +1,9 @@
1
1
  import { replace } from "../utils.js";
2
2
  import { PACKAGE_VERSION, readTemplate } from "../lib.js";
3
3
  import { PACKAGE_MANAGER } from "../const.js";
4
- import { _hongminhee_x_forwarded_fetch, _hono_hono, _std_dotenv, 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, _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, packageManagerToRuntime } from "./utils.js";
6
+ import { getInstruction, pmToRt } from "./utils.js";
7
7
  import { pipe } from "@fxts/core";
8
8
  //#region src/webframeworks/hono.ts
9
9
  const honoDescription = {
@@ -11,24 +11,7 @@ const honoDescription = {
11
11
  packageManagers: PACKAGE_MANAGER,
12
12
  defaultPort: 8e3,
13
13
  init: async ({ projectName, packageManager: pm }) => ({
14
- dependencies: pm === "deno" ? {
15
- ...defaultDenoDependencies,
16
- "@std/dotenv": _std_dotenv,
17
- "@hono/hono": _hono_hono,
18
- "@hongminhee/x-forwarded-fetch": _hongminhee_x_forwarded_fetch,
19
- "@fedify/hono": PACKAGE_VERSION
20
- } : pm === "bun" ? {
21
- hono: npm_hono,
22
- "x-forwarded-fetch": npm_x_forwarded_fetch,
23
- "@fedify/hono": PACKAGE_VERSION
24
- } : {
25
- "@dotenvx/dotenvx": npm__dotenvx_dotenvx,
26
- hono: npm_hono,
27
- "@hono/node-server": npm__hono_node_server,
28
- tsx: npm_tsx,
29
- "x-forwarded-fetch": npm_x_forwarded_fetch,
30
- "@fedify/hono": PACKAGE_VERSION
31
- },
14
+ dependencies: getDependencies(pm),
32
15
  devDependencies: {
33
16
  ...defaultDevDependencies,
34
17
  ...pm === "bun" ? { "@types/bun": npm__types_bun } : {}
@@ -37,7 +20,7 @@ const honoDescription = {
37
20
  loggingFile: "src/logging.ts",
38
21
  files: {
39
22
  "src/app.tsx": pipe(await readTemplate("hono/app.tsx"), replace(/\/\* hono \*\//, pm === "deno" ? "@hono/hono" : "hono"), replace(/\/\* logger \*\//, projectName)),
40
- "src/index.ts": await readTemplate(`hono/index/${packageManagerToRuntime(pm)}.ts`),
23
+ "src/index.ts": await readTemplate(`hono/index/${pmToRt(pm)}.ts`),
41
24
  ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
42
25
  },
43
26
  compilerOptions: pm === "deno" ? void 0 : {
@@ -52,13 +35,42 @@ const honoDescription = {
52
35
  "jsx": "react-jsx",
53
36
  "jsxImportSource": "hono/jsx"
54
37
  },
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
- },
38
+ tasks: TASKS[pmToRt(pm)],
60
39
  instruction: getInstruction(pm, 8e3)
61
40
  })
62
41
  };
42
+ const getDependencies = (pm) => pm === "deno" ? {
43
+ ...defaultDenoDependencies,
44
+ "@hono/hono": _hono_hono,
45
+ "@hongminhee/x-forwarded-fetch": _hongminhee_x_forwarded_fetch,
46
+ "@fedify/hono": PACKAGE_VERSION
47
+ } : pm === "bun" ? {
48
+ hono: npm_hono,
49
+ "x-forwarded-fetch": npm_x_forwarded_fetch,
50
+ "@fedify/hono": PACKAGE_VERSION
51
+ } : {
52
+ "@dotenvx/dotenvx": npm__dotenvx_dotenvx,
53
+ hono: npm_hono,
54
+ "@hono/node-server": npm__hono_node_server,
55
+ tsx: npm_tsx,
56
+ "x-forwarded-fetch": npm_x_forwarded_fetch,
57
+ "@fedify/hono": PACKAGE_VERSION
58
+ };
59
+ const TASKS = {
60
+ deno: {
61
+ dev: "deno run -A --watch ./src/index.ts",
62
+ prod: "deno run -A ./src/index.ts"
63
+ },
64
+ bun: {
65
+ dev: "bun run --hot ./src/index.ts",
66
+ prod: "bun run ./src/index.ts",
67
+ lint: "eslint ."
68
+ },
69
+ node: {
70
+ dev: "dotenvx run -- tsx watch ./src/index.ts",
71
+ prod: "dotenvx run -- node --import tsx ./src/index.ts",
72
+ lint: "eslint ."
73
+ }
74
+ };
63
75
  //#endregion
64
76
  export { honoDescription as default };
@@ -22,9 +22,9 @@ const nextDescription = {
22
22
  loggingFile: "logging.ts",
23
23
  files: {
24
24
  "middleware.ts": await readTemplate("next/middleware.ts"),
25
- ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
25
+ ...pm !== "deno" && { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") }
26
26
  },
27
- tasks: { ...pm !== "deno" ? { "lint": "eslint ." } : {} },
27
+ tasks: pm !== "deno" ? { "lint": "eslint ." } : {},
28
28
  instruction: getInstruction(pm, 3e3)
29
29
  })
30
30
  };
@@ -11,17 +11,17 @@ const nitroDescription = {
11
11
  command: getNitroInitCommand(pm),
12
12
  dependencies: {
13
13
  "@fedify/h3": PACKAGE_VERSION,
14
- ...pm === "deno" ? defaultDenoDependencies : {}
14
+ ...pm === "deno" && defaultDenoDependencies
15
15
  },
16
16
  devDependencies: defaultDevDependencies,
17
17
  federationFile: "server/federation.ts",
18
18
  loggingFile: "server/logging.ts",
19
+ env: testMode ? { HOST: "127.0.0.1" } : {},
19
20
  files: {
20
21
  "server/middleware/federation.ts": await readTemplate("nitro/server/middleware/federation.ts"),
21
22
  "server/error.ts": await readTemplate("nitro/server/error.ts"),
22
23
  "nitro.config.ts": await readTemplate("nitro/nitro.config.ts"),
23
- ...testMode ? { ".env": await readTemplate("nitro/.env.test") } : {},
24
- ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
24
+ ...pm !== "deno" && { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") }
25
25
  },
26
26
  tasks: pm !== "deno" ? { "lint": "eslint ." } : {},
27
27
  instruction: getInstruction(pm, 3e3)
@@ -1,8 +1,8 @@
1
1
  import { PACKAGE_VERSION, readTemplate } from "../lib.js";
2
2
  import { PACKAGE_MANAGER } from "../const.js";
3
- import { npm__solidjs_router, npm__solidjs_start, npm__types_node_22, npm_solid_js, npm_typescript, npm_vinxi } from "../json/deps.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";
4
4
  import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
5
- import { getInstruction } from "./utils.js";
5
+ import { getInstruction, 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 = {
@@ -10,25 +10,7 @@ const solidstartDescription = {
10
10
  packageManagers: PACKAGE_MANAGER,
11
11
  defaultPort: 3e3,
12
12
  init: async ({ packageManager: pm }) => ({
13
- dependencies: pm === "deno" ? {
14
- ...defaultDenoDependencies,
15
- "@solidjs/router": `npm:@solidjs/router@${npm__solidjs_router}`,
16
- "@solidjs/start": `${NPM_SOLIDSTART}`,
17
- "@solidjs/start/client": `${NPM_SOLIDSTART}/client`,
18
- "@solidjs/start/config": `${NPM_SOLIDSTART}/config`,
19
- "@solidjs/start/middleware": `${NPM_SOLIDSTART}/middleware`,
20
- "@solidjs/start/router": `${NPM_SOLIDSTART}/router`,
21
- "@solidjs/start/server": `${NPM_SOLIDSTART}/server`,
22
- "solid-js": `npm:solid-js@${npm_solid_js}`,
23
- vinxi: `npm:vinxi@${npm_vinxi}`,
24
- "@fedify/solidstart": PACKAGE_VERSION
25
- } : {
26
- "@solidjs/router": npm__solidjs_router,
27
- "@solidjs/start": npm__solidjs_start,
28
- "solid-js": npm_solid_js,
29
- vinxi: npm_vinxi,
30
- "@fedify/solidstart": PACKAGE_VERSION
31
- },
13
+ dependencies: getDependencies(pm),
32
14
  devDependencies: {
33
15
  ...defaultDevDependencies,
34
16
  typescript: npm_typescript,
@@ -43,7 +25,7 @@ const solidstartDescription = {
43
25
  "src/entry-server.tsx": await readTemplate("solidstart/src/entry-server.tsx"),
44
26
  "src/routes/index.tsx": await readTemplate("solidstart/src/routes/index.tsx"),
45
27
  "src/middleware/index.ts": await readTemplate("solidstart/src/middleware/index.ts"),
46
- ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
28
+ ...pm !== "deno" && { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") }
47
29
  },
48
30
  compilerOptions: pm === "deno" ? void 0 : {
49
31
  target: "ESNext",
@@ -57,14 +39,51 @@ const solidstartDescription = {
57
39
  noEmit: true,
58
40
  skipLibCheck: true
59
41
  },
60
- tasks: {
61
- dev: pm === "deno" ? "deno run -A npm:vinxi dev" : pm === "bun" ? "bunx vinxi dev" : "vinxi dev",
62
- build: pm === "deno" ? "deno run -A npm:vinxi build" : pm === "bun" ? "bunx vinxi build" : "vinxi build",
63
- start: pm === "deno" ? "deno run -A npm:vinxi start" : pm === "bun" ? "bunx vinxi start" : "vinxi start",
64
- ...pm !== "deno" ? { lint: "eslint ." } : {}
65
- },
42
+ tasks: TASKS[pmToRt(pm)],
66
43
  instruction: getInstruction(pm, 3e3)
67
44
  })
68
45
  };
46
+ const getDependencies = (pm) => pm === "deno" ? {
47
+ ...defaultDenoDependencies,
48
+ "@solidjs/router": `npm:@solidjs/router@${npm__solidjs_router}`,
49
+ "@solidjs/start": NPM_SOLIDSTART,
50
+ ...DENO_SOLIDSTART,
51
+ "solid-js": `npm:solid-js@${npm_solid_js}`,
52
+ vinxi: `npm:vinxi@${npm_vinxi}`,
53
+ "@fedify/solidstart": PACKAGE_VERSION
54
+ } : {
55
+ "@dotenvx/dotenvx": npm__dotenvx_dotenvx,
56
+ "@solidjs/router": npm__solidjs_router,
57
+ "@solidjs/start": npm__solidjs_start,
58
+ "solid-js": npm_solid_js,
59
+ vinxi: npm_vinxi,
60
+ "@fedify/solidstart": PACKAGE_VERSION
61
+ };
62
+ const DENO_SOLIDSTART = Object.fromEntries([
63
+ "client",
64
+ "config",
65
+ "middleware",
66
+ "router",
67
+ "server"
68
+ ].map((pkg) => [`@solidjs/start/${pkg}`, `${NPM_SOLIDSTART}/${pkg}`]));
69
+ const TASKS = {
70
+ deno: {
71
+ dev: "deno run -A npm:vinxi dev",
72
+ build: "deno run -A npm:vinxi build",
73
+ start: "deno run -A npm:vinxi start"
74
+ },
75
+ bun: {
76
+ dev: "bunx vinxi dev",
77
+ build: "bunx vinxi build",
78
+ start: "bunx vinxi start",
79
+ lint: "eslint ."
80
+ },
81
+ node: {
82
+ dev: "vinxi dev",
83
+ build: "vinxi build",
84
+ start: "dotenvx run -- vinxi start",
85
+ lint: "eslint ."
86
+ }
87
+ };
69
88
  //#endregion
70
89
  export { solidstartDescription as default };
@@ -24,6 +24,6 @@ Then, try to look up an actor from your server:
24
24
  * @param pm - The package manager (deno, bun, npm, yarn, pnpm)
25
25
  * @returns The runtime name (deno, bun, or node)
26
26
  */
27
- const packageManagerToRuntime = (pm) => pm === "deno" ? "deno" : pm === "bun" ? "bun" : "node";
27
+ const pmToRt = (pm) => pm !== "deno" && pm !== "bun" ? "node" : pm;
28
28
  //#endregion
29
- export { getInstruction, packageManagerToRuntime };
29
+ export { getInstruction, pmToRt };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/init",
3
- "version": "2.2.0-dev.664+53d88408",
3
+ "version": "2.2.0-dev.677+41046619",
4
4
  "description": "Project initializer for Fedify",
5
5
  "keywords": [
6
6
  "fedify",