@fedify/init 2.0.6-pr.633.9 → 2.0.7-dev.573

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
@@ -4,25 +4,25 @@ import { InferValue } from "@optique/core";
4
4
  //#region src/command.d.ts
5
5
  declare const initOptions: _optique_core0.Parser<"sync", {
6
6
  readonly dir: string;
7
- readonly webFramework: "hono" | "nitro" | "next" | "elysia" | "express";
7
+ readonly webFramework: "bare-bones" | "hono" | "nitro" | "next" | "elysia" | "express";
8
8
  readonly packageManager: "deno" | "pnpm" | "bun" | "yarn" | "npm";
9
- readonly kvStore: "denokv" | "redis" | "postgres";
10
- readonly messageQueue: "denokv" | "redis" | "postgres" | "amqp";
9
+ readonly kvStore: "postgres" | "in-memory" | "redis" | "denokv";
10
+ readonly messageQueue: "postgres" | "redis" | "denokv" | "in-process" | "amqp";
11
11
  readonly dryRun: boolean;
12
12
  }, {
13
13
  readonly dir: [_optique_core0.ValueParserResult<string>];
14
- readonly webFramework: [_optique_core0.ValueParserResult<"hono" | "nitro" | "next" | "elysia" | "express">];
14
+ readonly webFramework: [_optique_core0.ValueParserResult<"bare-bones" | "hono" | "nitro" | "next" | "elysia" | "express">];
15
15
  readonly packageManager: [_optique_core0.ValueParserResult<"deno" | "pnpm" | "bun" | "yarn" | "npm">];
16
- readonly kvStore: [_optique_core0.ValueParserResult<"denokv" | "redis" | "postgres">];
17
- readonly messageQueue: [_optique_core0.ValueParserResult<"denokv" | "redis" | "postgres" | "amqp">];
16
+ readonly kvStore: [_optique_core0.ValueParserResult<"postgres" | "in-memory" | "redis" | "denokv">];
17
+ readonly messageQueue: [_optique_core0.ValueParserResult<"postgres" | "redis" | "denokv" | "in-process" | "amqp">];
18
18
  readonly dryRun: _optique_core0.ValueParserResult<boolean>;
19
19
  }>;
20
20
  declare const initCommand: _optique_core0.Parser<"sync", {
21
21
  readonly dir: string;
22
- readonly webFramework: "hono" | "nitro" | "next" | "elysia" | "express";
22
+ readonly webFramework: "bare-bones" | "hono" | "nitro" | "next" | "elysia" | "express";
23
23
  readonly packageManager: "deno" | "pnpm" | "bun" | "yarn" | "npm";
24
- readonly kvStore: "denokv" | "redis" | "postgres";
25
- readonly messageQueue: "denokv" | "redis" | "postgres" | "amqp";
24
+ readonly kvStore: "postgres" | "in-memory" | "redis" | "denokv";
25
+ readonly messageQueue: "postgres" | "redis" | "denokv" | "in-process" | "amqp";
26
26
  readonly dryRun: boolean;
27
27
  } & {
28
28
  readonly command: "init";
package/dist/const.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  //#region src/const.d.ts
2
+
3
+ /** All supported package manager identifiers, in display order. */
2
4
  declare const PACKAGE_MANAGER: readonly ["deno", "pnpm", "bun", "yarn", "npm"];
3
5
  //#endregion
4
6
  export { PACKAGE_MANAGER };
package/dist/const.js CHANGED
@@ -1,4 +1,8 @@
1
+ import kv_default from "./json/kv.js";
2
+ import mq_default from "./json/mq.js";
3
+
1
4
  //#region src/const.ts
5
+ /** All supported package manager identifiers, in display order. */
2
6
  const PACKAGE_MANAGER = [
3
7
  "deno",
4
8
  "pnpm",
@@ -7,23 +11,17 @@ const PACKAGE_MANAGER = [
7
11
  "npm"
8
12
  ];
9
13
  const WEB_FRAMEWORK = [
14
+ "bare-bones",
10
15
  "hono",
11
16
  "nitro",
12
17
  "next",
13
18
  "elysia",
14
19
  "express"
15
20
  ];
16
- const MESSAGE_QUEUE = [
17
- "denokv",
18
- "redis",
19
- "postgres",
20
- "amqp"
21
- ];
22
- const KV_STORE = [
23
- "denokv",
24
- "redis",
25
- "postgres"
26
- ];
21
+ /** All supported message queue backend identifiers. */
22
+ const MESSAGE_QUEUE = Object.keys(mq_default);
23
+ /** All supported key-value store backend identifiers. */
24
+ const KV_STORE = Object.keys(kv_default);
27
25
  const DB_TO_CHECK = [
28
26
  "redis",
29
27
  "postgres",
package/dist/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region deno.json
2
2
  var name = "@fedify/init";
3
- var version = "2.0.6-pr.633.9+12093e72";
3
+ var version = "2.0.7-dev.573+8bbfb513";
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": [
@@ -41,6 +53,7 @@ var denokv = {
41
53
  "denoUnstable": ["kv"]
42
54
  };
43
55
  var kv_default = {
56
+ "in-memory": in_memory,
44
57
  redis,
45
58
  postgres,
46
59
  denokv
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": [
@@ -59,6 +71,7 @@ var denokv = {
59
71
  "denoUnstable": ["kv"]
60
72
  };
61
73
  var mq_default = {
74
+ "in-process": in_process,
62
75
  redis,
63
76
  postgres,
64
77
  amqp,
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
@@ -20,7 +20,12 @@ const logger = getLogger([
20
20
  "cli",
21
21
  "init"
22
22
  ]);
23
- const addFedifyDeps = (json) => Object.fromEntries(Object.entries(json).map(([key, value]) => [key, toMerged(value, { dependencies: { [`@fedify/${key}`]: PACKAGE_VERSION } })]));
23
+ const addFedifyDeps = (json) => Object.fromEntries(Object.entries(json).map(([key, value]) => [key, toMerged(value, { dependencies: { ...NO_INTEGRATIONS.includes(key) ? {} : { [`@fedify/${key}`]: PACKAGE_VERSION } } })]));
24
+ const NO_INTEGRATIONS = [
25
+ "in-memory",
26
+ "in-process",
27
+ "bare-bones"
28
+ ];
24
29
  const kvStores = addFedifyDeps(kv_default);
25
30
  const messageQueues = addFedifyDeps(mq_default);
26
31
  const toRegExp = (str) => new RegExp(str);
@@ -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);
56
+ const result = await serverClosure(dir, getDevCommand(pm), webframeworks_default[wf].defaultPort, sendLookup);
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 {
@@ -5,6 +5,51 @@ import { pipe } from "@fxts/core";
5
5
 
6
6
  //#region src/webframeworks.ts
7
7
  const webFrameworks = {
8
+ "bare-bones": {
9
+ label: "Bare-bones",
10
+ packageManagers: PACKAGE_MANAGER,
11
+ defaultPort: 8e3,
12
+ init: async ({ packageManager: pm }) => ({
13
+ dependencies: pm === "deno" ? {
14
+ ...defaultDenoDependencies,
15
+ "@std/dotenv": "^0.225.2",
16
+ "@hongminhee/x-forwarded-fetch": "^0.2.0"
17
+ } : pm === "bun" ? { "npm:x-forwarded-fetch": "^0.2.0" } : {
18
+ "npm:@dotenvx/dotenvx": "^1.14.1",
19
+ "npm:@hono/node-server": "^1.12.0",
20
+ "npm:tsx": "^4.17.0",
21
+ "npm:x-forwarded-fetch": "^0.2.0"
22
+ },
23
+ devDependencies: {
24
+ ...defaultDevDependencies,
25
+ ...pm === "bun" ? { "@types/bun": "^1.1.6" } : { "@types/node": "^18.0.0" }
26
+ },
27
+ federationFile: "src/federation.ts",
28
+ loggingFile: "src/logging.ts",
29
+ files: {
30
+ "src/main.ts": await readTemplate(`bare-bones/main/${packageManagerToRuntime(pm)}.ts`),
31
+ ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
32
+ },
33
+ compilerOptions: pm === "deno" ? {
34
+ "jsx": "precompile",
35
+ "jsxImportSource": "hono/jsx"
36
+ } : {
37
+ "lib": ["ESNext", "DOM"],
38
+ "target": "ESNext",
39
+ "module": "NodeNext",
40
+ "moduleResolution": "NodeNext",
41
+ "allowImportingTsExtensions": true,
42
+ "verbatimModuleSyntax": true,
43
+ "noEmit": true,
44
+ "strict": true
45
+ },
46
+ tasks: {
47
+ "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",
48
+ "prod": pm === "deno" ? "deno run -A ./src/main.ts" : pm === "bun" ? "bun run ./src/main.ts" : "dotenvx run -- node --import tsx ./src/main.ts"
49
+ },
50
+ instruction: getInstruction(pm, 8e3)
51
+ })
52
+ },
8
53
  hono: {
9
54
  label: "Hono",
10
55
  packageManagers: PACKAGE_MANAGER,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/init",
3
- "version": "2.0.6-pr.633.9+12093e72",
3
+ "version": "2.0.7-dev.573+8bbfb513",
4
4
  "description": "Project initializer for Fedify",
5
5
  "keywords": [
6
6
  "fedify",