@fedify/init 2.1.0-dev.543 → 2.1.0-dev.592

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/README.md CHANGED
@@ -25,10 +25,10 @@ Supported options
25
25
 
26
26
  The initializer supports the following project configurations:
27
27
 
28
- - **Web frameworks**: [Hono], [Nitro], [Next.js], [Elysia], [Express]
28
+ - **Web frameworks**: Bare-bones, [Hono], [Nitro], [Next.js], [Elysia], [Express]
29
29
  - **Package managers**: Deno, pnpm, Bun, Yarn, npm
30
- - **Key-value stores**: Deno KV, Redis, PostgreSQL
31
- - **Message queues**: Deno KV, Redis, PostgreSQL, AMQP
30
+ - **Key-value stores**: In-Memory, Deno KV, Redis, PostgreSQL
31
+ - **Message queues**: In-Process, Deno KV, Redis, PostgreSQL, AMQP
32
32
 
33
33
  [Hono]: https://hono.dev/
34
34
  [Nitro]: https://nitro.build/
@@ -2,7 +2,7 @@ import { merge } from "../utils.js";
2
2
  import biome_default from "../json/biome.js";
3
3
  import vscode_settings_for_deno_default from "../json/vscode-settings-for-deno.js";
4
4
  import vscode_settings_default from "../json/vscode-settings.js";
5
- import { PACKAGES_PATH } from "./const.js";
5
+ import { getPackagesPath } from "./const.js";
6
6
  import { getDependencies, getDevDependencies, joinDepsReg } from "./deps.js";
7
7
  import { execFileSync } from "node:child_process";
8
8
  import { getLogger } from "@logtape/logtape";
@@ -60,7 +60,7 @@ const getDenoVersionFromCommand = () => {
60
60
  const getDenoVersionFromRuntime = () => pipe(globalThis, prop("Deno"), prop("version"), prop("deno"));
61
61
  const parseVersion = (deno) => pipe(deno.match(/^(\d+)\.(\d+)\.(\d+)/), unless(isNull, (arr) => arr.map(Number)));
62
62
  const isLaterOrEqualThan = (basis) => (target) => pipe(zip(basis, target), filter(([b, t]) => t !== b), head, (a) => a ? a[0] < a[1] : true);
63
- const getLinks = ({ kv, mq, initializer, dir }) => pipe({ "@fedify/fedify": "" }, merge(initializer.dependencies), merge(kv.dependencies), merge(mq.dependencies), keys, filter((dep) => dep.includes("@fedify/")), map((dep) => dep.replace("@fedify/", "")), map((dep) => join(PACKAGES_PATH, dep)), map(realpathSync), map((realAbsolutePath) => relative(realpathSync(dir), realAbsolutePath)), toArray);
63
+ const getLinks = ({ kv, mq, initializer, dir }) => pipe({ "@fedify/fedify": "" }, merge(initializer.dependencies), merge(kv.dependencies), merge(mq.dependencies), keys, filter((dep) => dep.includes("@fedify/")), map((dep) => dep.replace("@fedify/", "")), map((dep) => join(getPackagesPath(), dep)), map(realpathSync), map((realAbsolutePath) => relative(realpathSync(dir), realAbsolutePath)), toArray);
64
64
  /**
65
65
  * Loads TypeScript configuration object for Node.js/Bun projects.
66
66
  * Uses compiler options from the framework initializer.
@@ -5,7 +5,7 @@ import { join } from "node:path";
5
5
  * Absolute path to the monorepo *packages/* directory.
6
6
  * Used in test mode to resolve local `@fedify/*` package paths.
7
7
  */
8
- const PACKAGES_PATH = join(import.meta.dirname, "..", "..", "..");
8
+ const getPackagesPath = () => join(import.meta.dirname, "..", "..", "..");
9
9
 
10
10
  //#endregion
11
- export { PACKAGES_PATH };
11
+ export { getPackagesPath };
@@ -1,6 +1,6 @@
1
1
  import { merge, replace } from "../utils.js";
2
2
  import { PACKAGE_VERSION } from "../lib.js";
3
- import { PACKAGES_PATH } from "./const.js";
3
+ import { getPackagesPath } from "./const.js";
4
4
  import { isDeno } from "./utils.js";
5
5
  import { always, entries, filter, fromEntries, map, pipe, when } from "@fxts/core";
6
6
  import { join as join$1 } from "node:path";
@@ -21,7 +21,7 @@ const getDependencies = ({ initializer, kv, mq, testMode, packageManager }) => p
21
21
  }, merge(initializer.dependencies), merge(kv.dependencies), merge(mq.dependencies), when(always(testMode), isDeno({ packageManager }) ? removeFedifyDeps : addLocalFedifyDeps), normalizePackageNames(packageManager));
22
22
  const removeFedifyDeps = (deps) => pipe(deps, entries, filter(([name]) => !name.includes("@fedify")), fromEntries);
23
23
  const addLocalFedifyDeps = (deps) => pipe(deps, entries, map(when(([name]) => name.includes("@fedify/"), ([name, _version]) => [name, convertFedifyToLocal(name)])), fromEntries);
24
- const convertFedifyToLocal = (name) => pipe(name, replace("@fedify/", ""), (pkg) => join$1(PACKAGES_PATH, pkg));
24
+ const convertFedifyToLocal = (name) => pipe(name, replace("@fedify/", ""), (pkg) => join$1(getPackagesPath(), pkg));
25
25
  /** Gathers all devDependencies required for the project based on the
26
26
  * initializer, key-value store, and message queue configurations,
27
27
  * including Biome for linting/formatting.
@@ -29,12 +29,12 @@ const recommendPatchFiles = (data) => pipe(data, set("files", getFiles), set("js
29
29
  * @param data - The initialization command data
30
30
  * @returns A record of file paths to their string content
31
31
  */
32
- const getFiles = (data) => ({
33
- [data.initializer.federationFile]: loadFederation({
32
+ const getFiles = async (data) => ({
33
+ [data.initializer.federationFile]: await loadFederation({
34
34
  imports: getImports(data),
35
35
  ...data
36
36
  }),
37
- [data.initializer.loggingFile]: loadLogging(data),
37
+ [data.initializer.loggingFile]: await loadLogging(data),
38
38
  ".env": stringifyEnvs(data.env),
39
39
  ...data.initializer.files
40
40
  });
@@ -11,7 +11,7 @@ import { toMerged } from "es-toolkit";
11
11
  * @param param0 - Configuration object containing imports, project name, KV store, message queue, and package manager
12
12
  * @returns The complete federation configuration file content as a string
13
13
  */
14
- const loadFederation = ({ imports, projectName, kv, mq, packageManager }) => pipe("defaults/federation.ts", readTemplate, replace(/\/\* imports \*\//, imports), replace(/\/\* logger \*\//, JSON.stringify(projectName)), replace(/\/\* kv \*\//, convertEnv(kv.object, packageManager)), replace(/\/\* queue \*\//, convertEnv(mq.object, packageManager)));
14
+ 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)));
15
15
  /**
16
16
  * Loads the logging configuration file content from template.
17
17
  * Reads the default logging template and replaces the project name placeholder.
@@ -19,7 +19,7 @@ const loadFederation = ({ imports, projectName, kv, mq, packageManager }) => pip
19
19
  * @param param0 - Destructured object containing the project name
20
20
  * @returns The complete logging configuration file content as a string
21
21
  */
22
- const loadLogging = ({ projectName }) => pipe("defaults/logging.ts", readTemplate, replace(/\/\* project name \*\//, JSON.stringify(projectName)));
22
+ const loadLogging = async ({ projectName }) => pipe(await readTemplate("defaults/logging.ts"), replace(/\/\* project name \*\//, JSON.stringify(projectName)));
23
23
  /**
24
24
  * Generates import statements for KV store and message queue dependencies.
25
25
  * Merges imports from both KV and MQ configurations and creates proper ES module import syntax.
package/dist/command.d.ts CHANGED
@@ -10,17 +10,17 @@ import { InferValue } from "@optique/core";
10
10
  */
11
11
  declare const initOptions: _optique_core0.Parser<"sync", {
12
12
  readonly dir: string;
13
- readonly webFramework: "hono" | "nitro" | "next" | "elysia" | "astro" | "express";
13
+ readonly webFramework: "bare-bones" | "hono" | "nitro" | "next" | "elysia" | "astro" | "express";
14
14
  readonly packageManager: "deno" | "pnpm" | "bun" | "yarn" | "npm";
15
- readonly kvStore: "denokv" | "redis" | "postgres" | "mysql";
16
- readonly messageQueue: "denokv" | "redis" | "postgres" | "mysql" | "amqp";
15
+ readonly kvStore: "postgres" | "mysql" | "in-memory" | "redis" | "denokv";
16
+ readonly messageQueue: "postgres" | "mysql" | "redis" | "denokv" | "in-process" | "amqp";
17
17
  readonly dryRun: boolean;
18
18
  }, {
19
19
  readonly dir: [_optique_core0.ValueParserResult<string>];
20
- readonly webFramework: [_optique_core0.ValueParserResult<"hono" | "nitro" | "next" | "elysia" | "astro" | "express">];
20
+ readonly webFramework: [_optique_core0.ValueParserResult<"bare-bones" | "hono" | "nitro" | "next" | "elysia" | "astro" | "express">];
21
21
  readonly packageManager: [_optique_core0.ValueParserResult<"deno" | "pnpm" | "bun" | "yarn" | "npm">];
22
- readonly kvStore: [_optique_core0.ValueParserResult<"denokv" | "redis" | "postgres" | "mysql">];
23
- readonly messageQueue: [_optique_core0.ValueParserResult<"denokv" | "redis" | "postgres" | "mysql" | "amqp">];
22
+ readonly kvStore: [_optique_core0.ValueParserResult<"postgres" | "mysql" | "in-memory" | "redis" | "denokv">];
23
+ readonly messageQueue: [_optique_core0.ValueParserResult<"postgres" | "mysql" | "redis" | "denokv" | "in-process" | "amqp">];
24
24
  readonly dryRun: _optique_core0.ValueParserResult<boolean>;
25
25
  }>;
26
26
  /**
@@ -28,10 +28,10 @@ declare const initOptions: _optique_core0.Parser<"sync", {
28
28
  */
29
29
  declare const initCommand: _optique_core0.Parser<"sync", {
30
30
  readonly dir: string;
31
- readonly webFramework: "hono" | "nitro" | "next" | "elysia" | "astro" | "express";
31
+ readonly webFramework: "bare-bones" | "hono" | "nitro" | "next" | "elysia" | "astro" | "express";
32
32
  readonly packageManager: "deno" | "pnpm" | "bun" | "yarn" | "npm";
33
- readonly kvStore: "denokv" | "redis" | "postgres" | "mysql";
34
- readonly messageQueue: "denokv" | "redis" | "postgres" | "mysql" | "amqp";
33
+ readonly kvStore: "postgres" | "mysql" | "in-memory" | "redis" | "denokv";
34
+ readonly messageQueue: "postgres" | "mysql" | "redis" | "denokv" | "in-process" | "amqp";
35
35
  readonly dryRun: boolean;
36
36
  } & {
37
37
  readonly command: "init";
package/dist/const.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  //#region src/const.d.ts
2
+
2
3
  /** All supported package manager identifiers, in display order. */
3
4
  declare const PACKAGE_MANAGER: readonly ["deno", "pnpm", "bun", "yarn", "npm"];
4
5
  /** All supported web framework identifiers, in display order. */
5
-
6
6
  //#endregion
7
7
  export { PACKAGE_MANAGER };
package/dist/const.js CHANGED
@@ -1,3 +1,6 @@
1
+ import kv_default from "./json/kv.js";
2
+ import mq_default from "./json/mq.js";
3
+
1
4
  //#region src/const.ts
2
5
  /** All supported package manager identifiers, in display order. */
3
6
  const PACKAGE_MANAGER = [
@@ -9,6 +12,7 @@ const PACKAGE_MANAGER = [
9
12
  ];
10
13
  /** All supported web framework identifiers, in display order. */
11
14
  const WEB_FRAMEWORK = [
15
+ "bare-bones",
12
16
  "hono",
13
17
  "nitro",
14
18
  "next",
@@ -17,20 +21,9 @@ const WEB_FRAMEWORK = [
17
21
  "express"
18
22
  ];
19
23
  /** All supported message queue backend identifiers. */
20
- const MESSAGE_QUEUE = [
21
- "denokv",
22
- "redis",
23
- "postgres",
24
- "mysql",
25
- "amqp"
26
- ];
24
+ const MESSAGE_QUEUE = Object.keys(mq_default);
27
25
  /** All supported key-value store backend identifiers. */
28
- const KV_STORE = [
29
- "denokv",
30
- "redis",
31
- "postgres",
32
- "mysql"
33
- ];
26
+ const KV_STORE = Object.keys(kv_default);
34
27
  /**
35
28
  * External database services that need to be running for integration tests.
36
29
  * Used by the test suite to check service availability before running tests.
package/dist/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region deno.json
2
2
  var name = "@fedify/init";
3
- var version = "2.1.0-dev.543+e09fd1b4";
3
+ var version = "2.1.0-dev.592+6c1f6e6f";
4
4
  var license = "MIT";
5
5
  var exports = "./src/mod.ts";
6
6
  var imports = {
package/dist/json/kv.js CHANGED
@@ -1,4 +1,16 @@
1
1
  //#region src/json/kv.json
2
+ var in_memory = {
3
+ "label": "In-Memory",
4
+ "packageManagers": [
5
+ "deno",
6
+ "bun",
7
+ "npm",
8
+ "yarn",
9
+ "pnpm"
10
+ ],
11
+ "imports": { "@fedify/fedify": { "MemoryKvStore": "MemoryKvStore" } },
12
+ "object": "new MemoryKvStore()"
13
+ };
2
14
  var redis = {
3
15
  "label": "Redis",
4
16
  "packageManagers": [
@@ -58,6 +70,7 @@ var denokv = {
58
70
  "denoUnstable": ["kv"]
59
71
  };
60
72
  var kv_default = {
73
+ "in-memory": in_memory,
61
74
  redis,
62
75
  postgres,
63
76
  mysql,
package/dist/json/kv.json CHANGED
@@ -1,4 +1,12 @@
1
1
  {
2
+ "in-memory": {
3
+ "label": "In-Memory",
4
+ "packageManagers": ["deno", "bun", "npm", "yarn", "pnpm"],
5
+ "imports": {
6
+ "@fedify/fedify": { "MemoryKvStore": "MemoryKvStore" }
7
+ },
8
+ "object": "new MemoryKvStore()"
9
+ },
2
10
  "redis": {
3
11
  "label": "Redis",
4
12
  "packageManagers": ["deno", "bun", "npm", "yarn", "pnpm"],
package/dist/json/mq.js CHANGED
@@ -1,4 +1,16 @@
1
1
  //#region src/json/mq.json
2
+ var in_process = {
3
+ "label": "In-Process",
4
+ "packageManagers": [
5
+ "deno",
6
+ "bun",
7
+ "npm",
8
+ "yarn",
9
+ "pnpm"
10
+ ],
11
+ "imports": { "@fedify/fedify": { "InProcessMessageQueue": "InProcessMessageQueue" } },
12
+ "object": "new InProcessMessageQueue()"
13
+ };
2
14
  var redis = {
3
15
  "label": "Redis",
4
16
  "packageManagers": [
@@ -76,6 +88,7 @@ var denokv = {
76
88
  "denoUnstable": ["kv"]
77
89
  };
78
90
  var mq_default = {
91
+ "in-process": in_process,
79
92
  redis,
80
93
  postgres,
81
94
  mysql,
package/dist/json/mq.json CHANGED
@@ -1,4 +1,20 @@
1
1
  {
2
+ "in-process": {
3
+ "label": "In-Process",
4
+ "packageManagers": [
5
+ "deno",
6
+ "bun",
7
+ "npm",
8
+ "yarn",
9
+ "pnpm"
10
+ ],
11
+ "imports": {
12
+ "@fedify/fedify": {
13
+ "InProcessMessageQueue": "InProcessMessageQueue"
14
+ }
15
+ },
16
+ "object": "new InProcessMessageQueue()"
17
+ },
2
18
  "redis": {
3
19
  "label": "Redis",
4
20
  "packageManagers": [
package/dist/lib.js CHANGED
@@ -21,7 +21,12 @@ const logger = getLogger([
21
21
  "cli",
22
22
  "init"
23
23
  ]);
24
- const addFedifyDeps = (json) => Object.fromEntries(Object.entries(json).map(([key, value]) => [key, toMerged(value, { dependencies: { [`@fedify/${key}`]: PACKAGE_VERSION } })]));
24
+ const addFedifyDeps = (json) => Object.fromEntries(Object.entries(json).map(([key, value]) => [key, toMerged(value, { dependencies: { ...NO_INTEGRATIONS.includes(key) ? {} : { [`@fedify/${key}`]: PACKAGE_VERSION } } })]));
25
+ const NO_INTEGRATIONS = [
26
+ "in-memory",
27
+ "in-process",
28
+ "bare-bones"
29
+ ];
25
30
  /**
26
31
  * KV store descriptions loaded from *json/kv.json*, enriched with the
27
32
  * appropriate `@fedify/*` dependency at the current package version.
@@ -69,7 +74,14 @@ async function isPackageManagerAvailable(pm) {
69
74
  * (e.g., `"defaults/federation.ts"`)
70
75
  * @returns The template file content as a string
71
76
  */
72
- const readTemplate = (templatePath) => readFileSync(join$1(import.meta.dirname, "templates", ...(templatePath + ".tpl").split("/")), "utf8");
77
+ const readTemplate = async (templatePath) => {
78
+ const segments = (templatePath + ".tpl").split("/");
79
+ if (import.meta.dirname) return readFileSync(join$1(import.meta.dirname, "templates", ...segments), "utf8");
80
+ const url = new URL(["templates", ...segments].join("/"), import.meta.url);
81
+ const resp = await fetch(url);
82
+ if (!resp.ok) throw new Error(`Failed to fetch template: ${url}`);
83
+ return resp.text();
84
+ };
73
85
  /**
74
86
  * Returns the shell command string to start the dev server for the given
75
87
  * package manager (e.g., `"deno task dev"`, `"bun dev"`, `"npm run dev"`).
@@ -0,0 +1,16 @@
1
+ import { behindProxy } from "x-forwarded-fetch";
2
+ import federation from "./federation.ts";
3
+ import "./logging.ts";
4
+
5
+ const server = Bun.serve({
6
+ port: 8000,
7
+ fetch: behindProxy((req) =>
8
+ new URL(req.url).pathname === "/"
9
+ ? new Response("Hello, this is a Fedify server!", {
10
+ headers: { "Content-Type": "text/plain" },
11
+ })
12
+ : federation.fetch(req, { contextData: undefined })
13
+ ),
14
+ });
15
+
16
+ console.log("Server started at", server.url.href);
@@ -0,0 +1,19 @@
1
+ import "@std/dotenv/load";
2
+ import { behindProxy } from "@hongminhee/x-forwarded-fetch";
3
+ import federation from "./federation.ts";
4
+ import "./logging.ts";
5
+
6
+ Deno.serve(
7
+ {
8
+ port: 8000,
9
+ onListen: ({ port, hostname }) =>
10
+ console.log("Server started at http://" + hostname + ":" + port)
11
+ },
12
+ behindProxy((req) =>
13
+ new URL(req.url).pathname === "/"
14
+ ? new Response("Hello, this is a Fedify server!", {
15
+ headers: { "Content-Type": "text/plain" },
16
+ })
17
+ : federation.fetch(req, { contextData: undefined })
18
+ ),
19
+ );
@@ -0,0 +1,19 @@
1
+ import { serve } from "@hono/node-server";
2
+ import { behindProxy } from "x-forwarded-fetch";
3
+ import federation from "./federation.ts";
4
+ import "./logging.ts";
5
+
6
+ serve(
7
+ {
8
+ port: 8000,
9
+ fetch: behindProxy((req) =>
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
+ },
17
+ (info) =>
18
+ console.log("Server started at http://" + info.address + ":" + info.port)
19
+ );
@@ -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).catch(() => false);
56
+ const result = await serverClosure(dir, getDevCommand(pm), webframeworks_default[wf].defaultPort, sendLookup).catch(() => false);
57
57
  printMessage` Lookup ${result ? "successful" : "failed"} for ${values([
58
58
  wf,
59
59
  pm,
@@ -105,7 +105,7 @@ async function waitForServer(url, timeout) {
105
105
  }
106
106
  return false;
107
107
  }
108
- async function serverClosure(dir, cmd, callback) {
108
+ async function serverClosure(dir, cmd, defaultPort, callback) {
109
109
  const devCommand = cmd.split(" ");
110
110
  const serverProcess = spawn(devCommand[0], devCommand.slice(1), {
111
111
  cwd: dir,
@@ -121,7 +121,11 @@ async function serverClosure(dir, cmd, callback) {
121
121
  serverProcess.stdout?.pipe(stdout);
122
122
  serverProcess.stderr?.pipe(stderr);
123
123
  try {
124
- const port = await determinePort(serverProcess);
124
+ const port = await determinePort(serverProcess).catch((err) => {
125
+ printErrorMessage`Failed to determine server port: ${err.message}`;
126
+ printErrorMessage`Use default port ${String(defaultPort)} for lookup.`;
127
+ return defaultPort;
128
+ });
125
129
  return await callback(port);
126
130
  } finally {
127
131
  try {
@@ -8,7 +8,7 @@ const astroDescription = {
8
8
  label: "Astro",
9
9
  packageManagers: PACKAGE_MANAGER,
10
10
  defaultPort: 4321,
11
- init: ({ packageManager: pm }) => ({
11
+ init: async ({ packageManager: pm }) => ({
12
12
  command: Array.from(getAstroInitCommand(pm)),
13
13
  dependencies: pm === "deno" ? {
14
14
  ...defaultDenoDependencies,
@@ -28,9 +28,9 @@ const astroDescription = {
28
28
  federationFile: "src/federation.ts",
29
29
  loggingFile: "src/logging.ts",
30
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") } : {}
31
+ [`astro.config.ts`]: await readTemplate(`astro/astro.config.${pm === "deno" ? "deno" : "node"}.ts`),
32
+ "src/middleware.ts": await readTemplate("astro/src/middleware.ts"),
33
+ ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
34
34
  },
35
35
  compilerOptions: void 0,
36
36
  tasks: {
@@ -0,0 +1,55 @@
1
+ import { 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/bare-bones.ts
7
+ const bareBonesDescription = {
8
+ label: "Bare-bones",
9
+ packageManagers: PACKAGE_MANAGER,
10
+ defaultPort: 8e3,
11
+ init: async ({ packageManager: pm }) => ({
12
+ dependencies: pm === "deno" ? {
13
+ ...defaultDenoDependencies,
14
+ "@std/dotenv": "^0.225.2",
15
+ "@hongminhee/x-forwarded-fetch": "^0.2.0"
16
+ } : pm === "bun" ? { "npm:x-forwarded-fetch": "^0.2.0" } : {
17
+ "npm:@dotenvx/dotenvx": "^1.14.1",
18
+ "npm:@hono/node-server": "^1.12.0",
19
+ "npm:tsx": "^4.17.0",
20
+ "npm:x-forwarded-fetch": "^0.2.0"
21
+ },
22
+ devDependencies: {
23
+ ...defaultDevDependencies,
24
+ ...pm === "bun" ? { "@types/bun": "^1.1.6" } : { "@types/node": "^18.0.0" }
25
+ },
26
+ federationFile: "src/federation.ts",
27
+ loggingFile: "src/logging.ts",
28
+ 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") } : {}
31
+ },
32
+ compilerOptions: pm === "deno" ? {
33
+ "jsx": "precompile",
34
+ "jsxImportSource": "hono/jsx"
35
+ } : {
36
+ "lib": ["ESNext", "DOM"],
37
+ "target": "ESNext",
38
+ "module": "NodeNext",
39
+ "moduleResolution": "NodeNext",
40
+ "allowImportingTsExtensions": true,
41
+ "verbatimModuleSyntax": true,
42
+ "noEmit": true,
43
+ "strict": true
44
+ },
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
+ },
49
+ instruction: getInstruction(pm, 8e3)
50
+ })
51
+ };
52
+ var bare_bones_default = bareBonesDescription;
53
+
54
+ //#endregion
55
+ export { bare_bones_default as default };
@@ -8,7 +8,7 @@ const elysiaDescription = {
8
8
  label: "ElysiaJS",
9
9
  packageManagers: PACKAGE_MANAGER,
10
10
  defaultPort: 3e3,
11
- init: ({ projectName, packageManager: pm }) => ({
11
+ init: async ({ projectName, packageManager: pm }) => ({
12
12
  dependencies: pm === "deno" ? {
13
13
  ...defaultDenoDependencies,
14
14
  elysia: "npm:elysia@^1.3.6",
@@ -36,8 +36,8 @@ const elysiaDescription = {
36
36
  federationFile: "src/federation.ts",
37
37
  loggingFile: "src/logging.ts",
38
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") } : {}
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") } : {}
41
41
  },
42
42
  compilerOptions: pm === "deno" || pm === "bun" ? void 0 : {
43
43
  "lib": ["ESNext", "DOM"],
@@ -8,7 +8,7 @@ const expressDescription = {
8
8
  label: "Express",
9
9
  packageManagers: PACKAGE_MANAGER,
10
10
  defaultPort: 8e3,
11
- init: ({ projectName, packageManager: pm }) => ({
11
+ init: async ({ projectName, packageManager: pm }) => ({
12
12
  dependencies: {
13
13
  "npm:express": "^4.19.2",
14
14
  "@fedify/express": PACKAGE_VERSION,
@@ -26,9 +26,9 @@ const expressDescription = {
26
26
  federationFile: "src/federation.ts",
27
27
  loggingFile: "src/logging.ts",
28
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") } : {}
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") } : {}
32
32
  },
33
33
  compilerOptions: pm === "deno" ? void 0 : {
34
34
  "lib": ["ESNext", "DOM"],
@@ -10,7 +10,7 @@ const honoDescription = {
10
10
  label: "Hono",
11
11
  packageManagers: PACKAGE_MANAGER,
12
12
  defaultPort: 8e3,
13
- init: ({ projectName, packageManager: pm }) => ({
13
+ init: async ({ projectName, packageManager: pm }) => ({
14
14
  dependencies: pm === "deno" ? {
15
15
  ...defaultDenoDependencies,
16
16
  "@std/dotenv": "^0.225.2",
@@ -36,9 +36,9 @@ const honoDescription = {
36
36
  federationFile: "src/federation.ts",
37
37
  loggingFile: "src/logging.ts",
38
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") } : {}
39
+ "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`),
41
+ ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
42
42
  },
43
43
  compilerOptions: pm === "deno" ? void 0 : {
44
44
  "lib": ["ESNext", "DOM"],
@@ -1,4 +1,5 @@
1
1
  import astro_default from "./astro.js";
2
+ import bare_bones_default from "./bare-bones.js";
2
3
  import elysia_default from "./elysia.js";
3
4
  import express_default from "./express.js";
4
5
  import hono_default from "./hono.js";
@@ -14,6 +15,7 @@ import nitro_default from "./nitro.js";
14
15
  * and instructions tailored to the selected package manager.
15
16
  */
16
17
  const webFrameworks = {
18
+ "bare-bones": bare_bones_default,
17
19
  astro: astro_default,
18
20
  elysia: elysia_default,
19
21
  express: express_default,
@@ -8,7 +8,7 @@ const nextDescription = {
8
8
  label: "Next.js",
9
9
  packageManagers: PACKAGE_MANAGER,
10
10
  defaultPort: 3e3,
11
- init: ({ packageManager: pm }) => ({
11
+ init: async ({ packageManager: pm }) => ({
12
12
  command: getNextInitCommand(pm),
13
13
  dependencies: {
14
14
  "@fedify/next": PACKAGE_VERSION,
@@ -21,8 +21,8 @@ const nextDescription = {
21
21
  federationFile: "federation/index.ts",
22
22
  loggingFile: "logging.ts",
23
23
  files: {
24
- "middleware.ts": readTemplate("next/middleware.ts"),
25
- ...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
24
+ "middleware.ts": await readTemplate("next/middleware.ts"),
25
+ ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
26
26
  },
27
27
  tasks: { ...pm !== "deno" ? { "lint": "eslint ." } : {} },
28
28
  instruction: getInstruction(pm, 3e3)
@@ -8,7 +8,7 @@ const nitroDescription = {
8
8
  label: "Nitro",
9
9
  packageManagers: PACKAGE_MANAGER,
10
10
  defaultPort: 3e3,
11
- init: ({ packageManager: pm, testMode }) => ({
11
+ init: async ({ packageManager: pm, testMode }) => ({
12
12
  command: getNitroInitCommand(pm),
13
13
  dependencies: {
14
14
  "@fedify/h3": PACKAGE_VERSION,
@@ -18,11 +18,11 @@ const nitroDescription = {
18
18
  federationFile: "server/federation.ts",
19
19
  loggingFile: "server/logging.ts",
20
20
  files: {
21
- "server/middleware/federation.ts": readTemplate("nitro/server/middleware/federation.ts"),
22
- "server/error.ts": readTemplate("nitro/server/error.ts"),
23
- "nitro.config.ts": readTemplate("nitro/nitro.config.ts"),
24
- ...testMode ? { ".env": readTemplate("nitro/.env.test") } : {},
25
- ...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
21
+ "server/middleware/federation.ts": await readTemplate("nitro/server/middleware/federation.ts"),
22
+ "server/error.ts": await readTemplate("nitro/server/error.ts"),
23
+ "nitro.config.ts": await readTemplate("nitro/nitro.config.ts"),
24
+ ...testMode ? { ".env": await readTemplate("nitro/.env.test") } : {},
25
+ ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
26
26
  },
27
27
  tasks: pm !== "deno" ? { "lint": "eslint ." } : {},
28
28
  instruction: getInstruction(pm, 3e3)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/init",
3
- "version": "2.1.0-dev.543+e09fd1b4",
3
+ "version": "2.1.0-dev.592+6c1f6e6f",
4
4
  "description": "Project initializer for Fedify",
5
5
  "keywords": [
6
6
  "fedify",