@fedify/init 2.1.0-dev.565 → 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/
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.565+b4d238a9";
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.
@@ -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 {
@@ -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 };
@@ -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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/init",
3
- "version": "2.1.0-dev.565+b4d238a9",
3
+ "version": "2.1.0-dev.592+6c1f6e6f",
4
4
  "description": "Project initializer for Fedify",
5
5
  "keywords": [
6
6
  "fedify",