@fedify/init 2.0.7 → 2.0.9

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.
Files changed (63) hide show
  1. package/dist/action/{configs.js → configs.mjs} +7 -9
  2. package/dist/action/{const.js → const.mjs} +1 -3
  3. package/dist/action/{deps.js → deps.mjs} +6 -10
  4. package/dist/action/{dir.js → dir.mjs} +1 -3
  5. package/dist/action/{env.js → env.mjs} +3 -6
  6. package/dist/action/{install.js → install.mjs} +2 -5
  7. package/dist/action/{mod.d.ts → mod.d.mts} +2 -3
  8. package/dist/action/{mod.js → mod.mjs} +15 -18
  9. package/dist/action/{notice.js → notice.mjs} +4 -6
  10. package/dist/action/{patch.js → patch.mjs} +8 -11
  11. package/dist/action/{precommand.js → precommand.mjs} +2 -5
  12. package/dist/action/{recommend.js → recommend.mjs} +5 -8
  13. package/dist/action/{set.js → set.mjs} +5 -8
  14. package/dist/action/{templates.js → templates.mjs} +4 -6
  15. package/dist/action/{utils.js → utils.mjs} +1 -3
  16. package/dist/ask/{dir.js → dir.mjs} +3 -6
  17. package/dist/ask/{kv.js → kv.mjs} +4 -7
  18. package/dist/ask/mod.mjs +10 -0
  19. package/dist/ask/{mq.js → mq.mjs} +4 -7
  20. package/dist/ask/{pm.js → pm.mjs} +8 -11
  21. package/dist/ask/{wf.js → wf.mjs} +4 -7
  22. package/dist/{command.d.ts → command.d.mts} +9 -9
  23. package/dist/{command.js → command.mjs} +2 -4
  24. package/dist/{const.d.ts → const.d.mts} +0 -1
  25. package/dist/{const.js → const.mjs} +3 -5
  26. package/dist/deno.mjs +4 -0
  27. package/dist/json/biome.mjs +13 -0
  28. package/dist/json/db-to-check.mjs +20 -0
  29. package/dist/json/kv.mjs +58 -0
  30. package/dist/json/mq.mjs +76 -0
  31. package/dist/json/pm.mjs +35 -0
  32. package/dist/json/rt.mjs +30 -0
  33. package/dist/json/vscode-settings-for-deno.mjs +38 -0
  34. package/dist/json/vscode-settings.mjs +36 -0
  35. package/dist/{lib.js → lib.mjs} +9 -12
  36. package/dist/mod.d.mts +3 -0
  37. package/dist/mod.mjs +3 -0
  38. package/dist/test/{action.js → action.mjs} +7 -10
  39. package/dist/test/{create.js → create.mjs} +14 -21
  40. package/dist/test/{db.js → db.mjs} +5 -8
  41. package/dist/test/{fill.js → fill.mjs} +10 -12
  42. package/dist/test/{lookup.js → lookup.mjs} +10 -16
  43. package/dist/test/{mod.js → mod.mjs} +6 -8
  44. package/dist/test/{run.js → run.mjs} +5 -8
  45. package/dist/test/{utils.js → utils.mjs} +2 -4
  46. package/dist/{types.d.ts → types.d.mts} +3 -3
  47. package/dist/{utils.d.ts → utils.d.mts} +0 -1
  48. package/dist/{utils.js → utils.mjs} +15 -19
  49. package/dist/{webframeworks.js → webframeworks.mjs} +4 -7
  50. package/package.json +3 -3
  51. package/dist/ask/mod.js +0 -13
  52. package/dist/deno.js +0 -38
  53. package/dist/json/biome.js +0 -18
  54. package/dist/json/db-to-check.js +0 -24
  55. package/dist/json/kv.js +0 -63
  56. package/dist/json/mq.js +0 -82
  57. package/dist/json/pm.js +0 -41
  58. package/dist/json/rt.js +0 -36
  59. package/dist/json/vscode-settings-for-deno.js +0 -50
  60. package/dist/json/vscode-settings.js +0 -46
  61. package/dist/mod.d.ts +0 -3
  62. package/dist/mod.js +0 -4
  63. /package/dist/test/{mod.d.ts → mod.d.mts} +0 -0
@@ -0,0 +1,13 @@
1
+ //#region src/json/biome.json
2
+ var biome_default = {
3
+ $schema: "https://biomejs.dev/schemas/1.8.3/schema.json",
4
+ organizeImports: { "enabled": true },
5
+ formatter: {
6
+ "enabled": true,
7
+ "indentStyle": "space",
8
+ "indentWidth": 2
9
+ },
10
+ linter: { "enabled": false }
11
+ };
12
+ //#endregion
13
+ export { biome_default as default };
@@ -0,0 +1,20 @@
1
+ //#region src/json/db-to-check.json
2
+ var db_to_check_default = {
3
+ redis: {
4
+ "name": "Redis",
5
+ "defaultPort": 6379,
6
+ "documentation": "https://redis.io/docs/latest/operate/oss_and_stack/install/archive/install-redis/"
7
+ },
8
+ postgres: {
9
+ "name": "PostgreSQL",
10
+ "defaultPort": 5432,
11
+ "documentation": "https://www.postgresql.org/download/"
12
+ },
13
+ amqp: {
14
+ "name": "RabbitMQ",
15
+ "defaultPort": 5672,
16
+ "documentation": "https://www.rabbitmq.com/docs/download"
17
+ }
18
+ };
19
+ //#endregion
20
+ export { db_to_check_default as default };
@@ -0,0 +1,58 @@
1
+ //#region src/json/kv.json
2
+ var kv_default = {
3
+ "in-memory": {
4
+ "label": "In-Memory",
5
+ "packageManagers": [
6
+ "deno",
7
+ "bun",
8
+ "npm",
9
+ "yarn",
10
+ "pnpm"
11
+ ],
12
+ "imports": { "@fedify/fedify": { "MemoryKvStore": "MemoryKvStore" } },
13
+ "object": "new MemoryKvStore()"
14
+ },
15
+ redis: {
16
+ "label": "Redis",
17
+ "packageManagers": [
18
+ "deno",
19
+ "bun",
20
+ "npm",
21
+ "yarn",
22
+ "pnpm"
23
+ ],
24
+ "dependencies": { "npm:ioredis": "^5.4.1" },
25
+ "imports": {
26
+ "@fedify/redis": { "RedisKvStore": "RedisKvStore" },
27
+ "ioredis": { "Redis": "Redis" }
28
+ },
29
+ "object": "new RedisKvStore(new Redis(process.env.REDIS_URL))",
30
+ "env": { "REDIS_URL": "redis://localhost:6379" }
31
+ },
32
+ postgres: {
33
+ "label": "PostgreSQL",
34
+ "packageManagers": [
35
+ "deno",
36
+ "bun",
37
+ "npm",
38
+ "yarn",
39
+ "pnpm"
40
+ ],
41
+ "dependencies": { "npm:postgres": "^3.4.5" },
42
+ "imports": {
43
+ "@fedify/postgres": { "PostgresKvStore": "PostgresKvStore" },
44
+ "postgres": { "default": "postgres" }
45
+ },
46
+ "object": "new PostgresKvStore(postgres(process.env.POSTGRES_URL))",
47
+ "env": { "POSTGRES_URL": "postgres://postgres@localhost:5432/postgres" }
48
+ },
49
+ denokv: {
50
+ "label": "Deno KV",
51
+ "packageManagers": ["deno"],
52
+ "imports": { "@fedify/denokv": { "DenoKvStore": "DenoKvStore" } },
53
+ "object": "new DenoKvStore(await Deno.openKv())",
54
+ "denoUnstable": ["kv"]
55
+ }
56
+ };
57
+ //#endregion
58
+ export { kv_default as default };
@@ -0,0 +1,76 @@
1
+ //#region src/json/mq.json
2
+ var mq_default = {
3
+ "in-process": {
4
+ "label": "In-Process",
5
+ "packageManagers": [
6
+ "deno",
7
+ "bun",
8
+ "npm",
9
+ "yarn",
10
+ "pnpm"
11
+ ],
12
+ "imports": { "@fedify/fedify": { "InProcessMessageQueue": "InProcessMessageQueue" } },
13
+ "object": "new InProcessMessageQueue()"
14
+ },
15
+ redis: {
16
+ "label": "Redis",
17
+ "packageManagers": [
18
+ "deno",
19
+ "bun",
20
+ "npm",
21
+ "yarn",
22
+ "pnpm"
23
+ ],
24
+ "dependencies": { "npm:ioredis": "^5.4.1" },
25
+ "imports": {
26
+ "@fedify/redis": { "RedisMessageQueue": "RedisMessageQueue" },
27
+ "ioredis": { "Redis": "Redis" }
28
+ },
29
+ "object": "new RedisMessageQueue(() => new Redis(process.env.REDIS_URL))",
30
+ "env": { "REDIS_URL": "redis://localhost:6379" }
31
+ },
32
+ postgres: {
33
+ "label": "PostgreSQL",
34
+ "packageManagers": [
35
+ "deno",
36
+ "bun",
37
+ "npm",
38
+ "yarn",
39
+ "pnpm"
40
+ ],
41
+ "dependencies": { "npm:postgres": "^3.4.5" },
42
+ "imports": {
43
+ "@fedify/postgres": { "PostgresMessageQueue": "PostgresMessageQueue" },
44
+ "postgres": { "default": "postgres" }
45
+ },
46
+ "object": "new PostgresMessageQueue(postgres(process.env.POSTGRES_URL))",
47
+ "env": { "POSTGRES_URL": "postgres://postgres@localhost:5432/postgres" }
48
+ },
49
+ amqp: {
50
+ "label": "AMQP (e.g., RabbitMQ)",
51
+ "packageManagers": [
52
+ "deno",
53
+ "bun",
54
+ "npm",
55
+ "yarn",
56
+ "pnpm"
57
+ ],
58
+ "dependencies": { "npm:amqplib": "^0.10.4" },
59
+ "devDependencies": { "npm:@types/amqplib": "^0.10.5" },
60
+ "imports": {
61
+ "@fedify/amqp": { "AmqpMessageQueue": "AmqpMessageQueue" },
62
+ "amqplib": { "connect": "connect" }
63
+ },
64
+ "object": "new AmqpMessageQueue(await connect(process.env.AMQP_URL))",
65
+ "env": { "AMQP_URL": "amqp://localhost" }
66
+ },
67
+ denokv: {
68
+ "label": "Deno KV",
69
+ "packageManagers": ["deno"],
70
+ "imports": { "@fedify/denokv": { "DenoKvMessageQueue": "DenoKvMessageQueue" } },
71
+ "object": "new DenoKvMessageQueue(await Deno.openKv())",
72
+ "denoUnstable": ["kv"]
73
+ }
74
+ };
75
+ //#endregion
76
+ export { mq_default as default };
@@ -0,0 +1,35 @@
1
+ //#region src/json/pm.json
2
+ var pm_default = {
3
+ deno: {
4
+ "label": "deno",
5
+ "checkCommand": ["deno", "--version"],
6
+ "outputPattern": "^deno\\s+\\d+\\.\\d+\\.\\d+\\b",
7
+ "installUrl": "https://docs.deno.com/runtime/getting_started/installation"
8
+ },
9
+ bun: {
10
+ "label": "bun",
11
+ "checkCommand": ["bun", "--version"],
12
+ "outputPattern": "^\\d+\\.\\d+\\.\\d+$",
13
+ "installUrl": "https://bun.sh/docs/installation"
14
+ },
15
+ npm: {
16
+ "label": "npm",
17
+ "checkCommand": ["npm", "--version"],
18
+ "outputPattern": "^\\d+\\.\\d+\\.\\d+$",
19
+ "installUrl": "https://docs.npmjs.com/downloading-and-installing-node-js-and-npm"
20
+ },
21
+ yarn: {
22
+ "label": "Yarn",
23
+ "checkCommand": ["yarn", "--version"],
24
+ "outputPattern": "^\\d+\\.\\d+\\.\\d+$",
25
+ "installUrl": "https://classic.yarnpkg.com/en/docs/install/#windows-stable"
26
+ },
27
+ pnpm: {
28
+ "label": "pnpm",
29
+ "checkCommand": ["pnpm", "--version"],
30
+ "outputPattern": "^\\d+\\.\\d+\\.\\d+$",
31
+ "installUrl": "https://pnpm.io/installation"
32
+ }
33
+ };
34
+ //#endregion
35
+ export { pm_default as default };
@@ -0,0 +1,30 @@
1
+ //#region src/json/rt.json
2
+ var rt_default = {
3
+ deno: {
4
+ "label": "Deno",
5
+ "checkCommand": ["deno", "--version"],
6
+ "outputPattern": "^deno\\s+\\d+\\.\\d+\\.\\d+\\b"
7
+ },
8
+ bun: {
9
+ "label": "Bun",
10
+ "checkCommand": ["bun", "--version"],
11
+ "outputPattern": "^\\d+\\.\\d+\\.\\d+$"
12
+ },
13
+ pnpm: {
14
+ "label": "Node.js",
15
+ "checkCommand": ["node", "--version"],
16
+ "outputPattern": "^v\\d+\\.\\d+\\.\\d+$"
17
+ },
18
+ yarn: {
19
+ "label": "Node.js",
20
+ "checkCommand": ["node", "--version"],
21
+ "outputPattern": "^v\\d+\\.\\d+\\.\\d+$"
22
+ },
23
+ npm: {
24
+ "label": "Node.js",
25
+ "checkCommand": ["node", "--version"],
26
+ "outputPattern": "^v\\d+\\.\\d+\\.\\d+$"
27
+ }
28
+ };
29
+ //#endregion
30
+ export { rt_default as default };
@@ -0,0 +1,38 @@
1
+ //#region src/json/vscode-settings-for-deno.json
2
+ var vscode_settings_for_deno_default = {
3
+ "deno.enable": true,
4
+ "deno.unstable": true,
5
+ "editor.detectIndentation": false,
6
+ "editor.indentSize": 2,
7
+ "editor.insertSpaces": true,
8
+ "[javascript]": {
9
+ "editor.defaultFormatter": "denoland.vscode-deno",
10
+ "editor.formatOnSave": true,
11
+ "editor.codeActionsOnSave": { "source.sortImports": "always" }
12
+ },
13
+ "[javascriptreact]": {
14
+ "editor.defaultFormatter": "denoland.vscode-deno",
15
+ "editor.formatOnSave": true,
16
+ "editor.codeActionsOnSave": { "source.sortImports": "always" }
17
+ },
18
+ "[json]": {
19
+ "editor.defaultFormatter": "vscode.json-language-features",
20
+ "editor.formatOnSave": true
21
+ },
22
+ "[jsonc]": {
23
+ "editor.defaultFormatter": "vscode.json-language-features",
24
+ "editor.formatOnSave": true
25
+ },
26
+ "[typescript]": {
27
+ "editor.defaultFormatter": "denoland.vscode-deno",
28
+ "editor.formatOnSave": true,
29
+ "editor.codeActionsOnSave": { "source.sortImports": "always" }
30
+ },
31
+ "[typescriptreact]": {
32
+ "editor.defaultFormatter": "denoland.vscode-deno",
33
+ "editor.formatOnSave": true,
34
+ "editor.codeActionsOnSave": { "source.sortImports": "always" }
35
+ }
36
+ };
37
+ //#endregion
38
+ export { vscode_settings_for_deno_default as default };
@@ -0,0 +1,36 @@
1
+ //#region src/json/vscode-settings.json
2
+ var vscode_settings_default = {
3
+ "editor.detectIndentation": false,
4
+ "editor.indentSize": 2,
5
+ "editor.insertSpaces": true,
6
+ "[javascript]": {
7
+ "editor.defaultFormatter": "biomejs.biome",
8
+ "editor.formatOnSave": true,
9
+ "editor.codeActionsOnSave": { "source.organizeImports.biome": "always" }
10
+ },
11
+ "[javascriptreact]": {
12
+ "editor.defaultFormatter": "biomejs.biome",
13
+ "editor.formatOnSave": true,
14
+ "editor.codeActionsOnSave": { "source.organizeImports.biome": "always" }
15
+ },
16
+ "[json]": {
17
+ "editor.defaultFormatter": "biomejs.biome",
18
+ "editor.formatOnSave": true
19
+ },
20
+ "[jsonc]": {
21
+ "editor.defaultFormatter": "biomejs.biome",
22
+ "editor.formatOnSave": true
23
+ },
24
+ "[typescript]": {
25
+ "editor.defaultFormatter": "biomejs.biome",
26
+ "editor.formatOnSave": true,
27
+ "editor.codeActionsOnSave": { "source.organizeImports.biome": "always" }
28
+ },
29
+ "[typescriptreact]": {
30
+ "editor.defaultFormatter": "biomejs.biome",
31
+ "editor.formatOnSave": true,
32
+ "editor.codeActionsOnSave": { "source.organizeImports.biome": "always" }
33
+ }
34
+ };
35
+ //#endregion
36
+ export { vscode_settings_default as default };
@@ -1,9 +1,9 @@
1
- import { isNotFoundError, runSubCommand } from "./utils.js";
2
- import deno_default from "./deno.js";
3
- import kv_default from "./json/kv.js";
4
- import mq_default from "./json/mq.js";
5
- import pm_default from "./json/pm.js";
6
- import rt_default from "./json/rt.js";
1
+ import { isNotFoundError, runSubCommand } from "./utils.mjs";
2
+ import { version } from "./deno.mjs";
3
+ import kv_default from "./json/kv.mjs";
4
+ import mq_default from "./json/mq.mjs";
5
+ import pm_default from "./json/pm.mjs";
6
+ import rt_default from "./json/rt.mjs";
7
7
  import { entries, evolve, fromEntries, isObject, map, negate, pipe, throwIf } from "@fxts/core";
8
8
  import process from "node:process";
9
9
  import { commandLine, message } from "@optique/core/message";
@@ -12,9 +12,8 @@ import { getLogger } from "@logtape/logtape";
12
12
  import { readFileSync } from "node:fs";
13
13
  import { mkdir, readdir, writeFile } from "node:fs/promises";
14
14
  import { dirname, join as join$1 } from "node:path";
15
-
16
15
  //#region src/lib.ts
17
- const PACKAGE_VERSION = deno_default.version;
16
+ const PACKAGE_VERSION = version;
18
17
  const logger = getLogger([
19
18
  "fedify",
20
19
  "cli",
@@ -91,8 +90,7 @@ const isNotExistsError = (e) => isObject(e) && "code" in e && e.code === "ENOENT
91
90
  const throwUnlessNotExists = throwIf(negate(isNotExistsError));
92
91
  const isDirectoryEmpty = async (path) => {
93
92
  try {
94
- const files = await readdir(path);
95
- return files.length === 0;
93
+ return (await readdir(path)).length === 0;
96
94
  } catch (e) {
97
95
  throwUnlessNotExists(e);
98
96
  return true;
@@ -137,6 +135,5 @@ const createNitroAppCommand = (pm) => pm === "deno" ? [
137
135
  "-A"
138
136
  ] : pm === "bun" ? ["bunx"] : pm === "npm" ? ["npx"] : [pm, "dlx"];
139
137
  const isTest = ({ testMode }) => testMode;
140
-
141
138
  //#endregion
142
- export { PACKAGE_VERSION, createFile, getDevCommand, getInstallUrl, getInstruction, getNextInitCommand, getNitroInitCommand, isDirectoryEmpty, isPackageManagerAvailable, isTest, kvStores, logger, messageQueues, packageManagerToRuntime, packageManagers, readTemplate, runtimes, throwUnlessNotExists };
139
+ export { PACKAGE_VERSION, createFile, getDevCommand, getInstallUrl, getInstruction, getNextInitCommand, getNitroInitCommand, isDirectoryEmpty, isPackageManagerAvailable, isTest, kvStores, logger, messageQueues, packageManagerToRuntime, packageManagers, readTemplate, runtimes, throwUnlessNotExists };
package/dist/mod.d.mts ADDED
@@ -0,0 +1,3 @@
1
+ import { initCommand, initOptions } from "./command.mjs";
2
+ import { runInit } from "./action/mod.mjs";
3
+ export { initCommand, initOptions, runInit };
package/dist/mod.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import runInit from "./action/mod.mjs";
2
+ import { initCommand, initOptions } from "./command.mjs";
3
+ export { initCommand, initOptions, runInit };
@@ -1,15 +1,12 @@
1
- import { set } from "../utils.js";
2
- import { checkRequiredDbs } from "./db.js";
3
- import { fillEmptyOptions } from "./fill.js";
4
- import run_default from "./run.js";
5
- import { emptyTestDir, genRunId, genTestDirPrefix, logTestDir } from "./utils.js";
1
+ import { set } from "../utils.mjs";
2
+ import { checkRequiredDbs } from "./db.mjs";
3
+ import { fillEmptyOptions } from "./fill.mjs";
4
+ import runTests from "./run.mjs";
5
+ import { emptyTestDir, genRunId, genTestDirPrefix, logTestDir } from "./utils.mjs";
6
6
  import { pipe, tap, when } from "@fxts/core";
7
-
8
7
  //#region src/test/action.ts
9
- const runTestInit = (options) => pipe(options, set("runId", genRunId), set("testDirPrefix", genTestDirPrefix), tap(emptyTestDir), fillEmptyOptions, tap(checkRequiredDbs), tap(logTestDir), tap(when(isDryRun, run_default(true))), tap(when(isHydRun, run_default(false))));
8
+ const runTestInit = (options) => pipe(options, set("runId", genRunId), set("testDirPrefix", genTestDirPrefix), tap(emptyTestDir), fillEmptyOptions, tap(checkRequiredDbs), tap(logTestDir), tap(when(isDryRun, runTests(true))), tap(when(isHydRun, runTests(false))));
10
9
  const isDryRun = ({ dryRun }) => dryRun;
11
10
  const isHydRun = ({ hydRun }) => hydRun;
12
- var action_default = runTestInit;
13
-
14
11
  //#endregion
15
- export { action_default as default };
12
+ export { runTestInit as default };
@@ -1,28 +1,26 @@
1
- import { CommandError, printErrorMessage, printMessage, product, runSubCommand } from "../utils.js";
2
- import pm_default from "../json/pm.js";
3
- import { kvStores, messageQueues } from "../lib.js";
4
- import webframeworks_default from "../webframeworks.js";
1
+ import { CommandError, printErrorMessage, printMessage, product, runSubCommand } from "../utils.mjs";
2
+ import pm_default from "../json/pm.mjs";
3
+ import { kvStores, messageQueues } from "../lib.mjs";
4
+ import webFrameworks from "../webframeworks.mjs";
5
5
  import { filter, isEmpty, pipe, toArray } from "@fxts/core";
6
6
  import process from "node:process";
7
7
  import { values } from "@optique/core";
8
8
  import { appendFile, mkdir } from "node:fs/promises";
9
9
  import { join as join$1, sep } from "node:path";
10
-
11
10
  //#region src/test/create.ts
12
11
  const BANNED_PMS = ["bun", "yarn"];
13
12
  const createTestApp = (testDirPrefix, dry) => async (options) => {
14
13
  const testDir = join$1(testDirPrefix, ...options);
15
14
  const vals = values(testDir.split(sep).slice(-4));
16
15
  try {
17
- const result = await runSubCommand(toArray(genInitCommand(testDir, dry, options)), {
16
+ await saveOutputs(testDir, await runSubCommand(toArray(genInitCommand(testDir, dry, options)), {
18
17
  cwd: join$1(import.meta.dirname, "../.."),
19
18
  stdio: [
20
19
  "ignore",
21
20
  "pipe",
22
21
  "pipe"
23
22
  ]
24
- });
25
- await saveOutputs(testDir, result);
23
+ }));
26
24
  printMessage` Pass: ${vals}`;
27
25
  return testDir;
28
26
  } catch (error) {
@@ -30,18 +28,14 @@ const createTestApp = (testDirPrefix, dry) => async (options) => {
30
28
  stdout: error.stdout,
31
29
  stderr: error.stderr
32
30
  });
33
- else {
34
- const errorMessage = error instanceof Error ? error.message : String(error);
35
- await saveOutputs(testDir, {
36
- stdout: "",
37
- stderr: errorMessage
38
- });
39
- }
31
+ else await saveOutputs(testDir, {
32
+ stdout: "",
33
+ stderr: error instanceof Error ? error.message : String(error)
34
+ });
40
35
  printMessage` Fail: ${vals}`;
41
36
  return "";
42
37
  }
43
38
  };
44
- var create_default = createTestApp;
45
39
  function* genInitCommand(testDir, dry, [webFramework, packageManager, kvStore, messageQueue]) {
46
40
  yield "deno";
47
41
  yield "run";
@@ -69,8 +63,8 @@ const generateTestCases = ({ webFramework, packageManager, kvStore, messageQueue
69
63
  ]);
70
64
  return product(webFramework, pms, kvStore, messageQueue);
71
65
  };
72
- const filterPackageManager = (pm) => pipe(pm, filter((pm$1) => BANNED_PMS.includes(pm$1) ? printErrorMessage`${pm_default[pm$1]["label"]} is not \
73
- supported in test mode yet because ${pm_default[pm$1]["label"]} don't \
66
+ const filterPackageManager = (pm) => pipe(pm, filter((pm) => BANNED_PMS.includes(pm) ? printErrorMessage`${pm_default[pm]["label"]} is not \
67
+ supported in test mode yet because ${pm_default[pm]["label"]} don't \
74
68
  support local file dependencies properly.` : true), toArray);
75
69
  const exitIfCasesEmpty = (cases) => {
76
70
  if (cases.some(isEmpty)) {
@@ -86,11 +80,10 @@ const saveOutputs = async (dirPath, { stdout, stderr }) => {
86
80
  function filterOptions(options) {
87
81
  const [wf, pm, kv, mq] = options;
88
82
  return [
89
- webframeworks_default[wf].packageManagers,
83
+ webFrameworks[wf].packageManagers,
90
84
  kvStores[kv].packageManagers,
91
85
  messageQueues[mq].packageManagers
92
86
  ].every((pms) => pms.includes(pm));
93
87
  }
94
-
95
88
  //#endregion
96
- export { create_default as default, filterOptions, generateTestCases };
89
+ export { createTestApp as default, filterOptions, generateTestCases };
@@ -1,9 +1,8 @@
1
- import { printErrorMessage, printMessage } from "../utils.js";
2
- import { DB_TO_CHECK } from "../const.js";
3
- import db_to_check_default from "../json/db-to-check.js";
1
+ import { printErrorMessage, printMessage } from "../utils.mjs";
2
+ import { DB_TO_CHECK } from "../const.mjs";
3
+ import db_to_check_default from "../json/db-to-check.mjs";
4
4
  import { concat, filter, pipe, toArray, uniq } from "@fxts/core";
5
5
  import { createConnection } from "node:net";
6
-
7
6
  //#region src/test/db.ts
8
7
  /**
9
8
  * Checks if a given port is open by attempting a raw TCP connection to
@@ -42,11 +41,9 @@ async function checkRequiredDbs(options) {
42
41
  for (const db of dbs) {
43
42
  const info = db_to_check_default[db];
44
43
  const port = String(info.defaultPort);
45
- const running = await isPortOpen(info.defaultPort);
46
- if (running) printMessage` ${info.name} is running on port ${port}.`;
44
+ if (await isPortOpen(info.defaultPort)) printMessage` ${info.name} is running on port ${port}.`;
47
45
  else printErrorMessage`${info.name} is not running on port ${port}. Tests requiring ${info.name} may fail. Install: ${info.documentation}`;
48
46
  }
49
47
  }
50
-
51
48
  //#endregion
52
- export { checkRequiredDbs };
49
+ export { checkRequiredDbs };
@@ -1,6 +1,5 @@
1
- import { KV_STORE, MESSAGE_QUEUE, PACKAGE_MANAGER, WEB_FRAMEWORK } from "../const.js";
1
+ import { KV_STORE, MESSAGE_QUEUE, PACKAGE_MANAGER, WEB_FRAMEWORK } from "../const.mjs";
2
2
  import { isEmpty, omit, pipe } from "@fxts/core";
3
-
4
3
  //#region src/test/fill.ts
5
4
  const fillEmptyOptions = (options) => pipe(options, fillWebFramework, fillPackageManager, fillKVStore, fillMessageQueue, fillRunMode);
6
5
  const fillOption = (key, allValues) => (options) => ({
@@ -11,19 +10,18 @@ const fillWebFramework = fillOption("webFramework", WEB_FRAMEWORK);
11
10
  const fillPackageManager = fillOption("packageManager", PACKAGE_MANAGER);
12
11
  const fillKVStore = fillOption("kvStore", KV_STORE);
13
12
  const fillMessageQueue = fillOption("messageQueue", MESSAGE_QUEUE);
14
- const fillRunMode = (options) => pipe(options, (options$1) => "noHydRun" in options$1 ? {
15
- ...omit(["noHydRun"], options$1),
16
- hydRun: !options$1.noHydRun
13
+ const fillRunMode = (options) => pipe(options, (options) => "noHydRun" in options ? {
14
+ ...omit(["noHydRun"], options),
15
+ hydRun: !options.noHydRun
17
16
  } : {
18
- ...options$1,
17
+ ...options,
19
18
  hydRun: true
20
- }, (options$1) => "noDryRun" in options$1 ? {
21
- ...omit(["noDryRun"], options$1),
22
- dryRun: !options$1.noDryRun
19
+ }, (options) => "noDryRun" in options ? {
20
+ ...omit(["noDryRun"], options),
21
+ dryRun: !options.noDryRun
23
22
  } : {
24
- ...options$1,
23
+ ...options,
25
24
  dryRun: true
26
25
  });
27
-
28
26
  //#endregion
29
- export { fillEmptyOptions };
27
+ export { fillEmptyOptions };
@@ -1,13 +1,12 @@
1
- import { printErrorMessage, printMessage, runSubCommand } from "../utils.js";
2
- import { getDevCommand } from "../lib.js";
3
- import webframeworks_default from "../webframeworks.js";
1
+ import { printErrorMessage, printMessage, runSubCommand } from "../utils.mjs";
2
+ import { getDevCommand } from "../lib.mjs";
3
+ import webFrameworks from "../webframeworks.mjs";
4
4
  import process from "node:process";
5
5
  import { values } from "@optique/core";
6
6
  import { spawn } from "node:child_process";
7
7
  import { createWriteStream } from "node:fs";
8
8
  import { join, sep } from "node:path";
9
9
  import { isEmpty } from "@fxts/core/index.js";
10
-
11
10
  //#region src/test/lookup.ts
12
11
  const HANDLE = "john";
13
12
  const STARTUP_TIMEOUT = 3e4;
@@ -38,8 +37,7 @@ function filterWebFrameworks(dirs) {
38
37
  const wfs = new Set(dirs.map((dir) => dir.split(sep).slice(-4, -3)[0]));
39
38
  const hasBanned = BANNED_WFS.filter((wf) => wfs.has(wf));
40
39
  if (isEmpty(hasBanned)) return dirs;
41
- const bannedLabels = hasBanned.map((wf) => webframeworks_default[wf]["label"]);
42
- printErrorMessage`\n${values(bannedLabels)} is not supported in lookup test yet.`;
40
+ printErrorMessage`\n${values(hasBanned.map((wf) => webFrameworks[wf]["label"]))} is not supported in lookup test yet.`;
43
41
  return dirs.filter((dir) => !BANNED_WFS.includes(dir.split(sep).slice(-4, -3)[0]));
44
42
  }
45
43
  /**
@@ -53,7 +51,7 @@ async function testApp(dir) {
53
51
  kv,
54
52
  mq
55
53
  ])}...`;
56
- const result = await serverClosure(dir, getDevCommand(pm), webframeworks_default[wf].defaultPort, sendLookup);
54
+ const result = await serverClosure(dir, getDevCommand(pm), webFrameworks[wf].defaultPort, sendLookup);
57
55
  printMessage` Lookup ${result ? "successful" : "failed"} for ${values([
58
56
  wf,
59
57
  pm,
@@ -70,8 +68,7 @@ const sendLookup = async (port) => {
70
68
  const serverUrl = `http://localhost:${port}`;
71
69
  const lookupTarget = `${serverUrl}/users/${HANDLE}`;
72
70
  printMessage` Waiting for server to start at ${serverUrl}...`;
73
- const isReady = await waitForServer(serverUrl, STARTUP_TIMEOUT);
74
- if (!isReady) {
71
+ if (!await waitForServer(serverUrl, STARTUP_TIMEOUT)) {
75
72
  printErrorMessage`Server did not start within \
76
73
  ${String(STARTUP_TIMEOUT)}ms`;
77
74
  return false;
@@ -98,8 +95,7 @@ async function waitForServer(url, timeout) {
98
95
  const startTime = Date.now();
99
96
  while (Date.now() - startTime < timeout) {
100
97
  try {
101
- const response = await fetch(url, { signal: AbortSignal.timeout(1e3) });
102
- if (response.ok) return true;
98
+ if ((await fetch(url, { signal: AbortSignal.timeout(1e3) })).ok) return true;
103
99
  } catch {}
104
100
  await new Promise((resolve) => setTimeout(resolve, 500));
105
101
  }
@@ -121,12 +117,11 @@ async function serverClosure(dir, cmd, defaultPort, callback) {
121
117
  serverProcess.stdout?.pipe(stdout);
122
118
  serverProcess.stderr?.pipe(stderr);
123
119
  try {
124
- const port = await determinePort(serverProcess).catch((err) => {
120
+ return await callback(await determinePort(serverProcess).catch((err) => {
125
121
  printErrorMessage`Failed to determine server port: ${err.message}`;
126
122
  printErrorMessage`Use default port ${String(defaultPort)} for lookup.`;
127
123
  return defaultPort;
128
- });
129
- return await callback(port);
124
+ }));
130
125
  } finally {
131
126
  try {
132
127
  process.kill(-serverProcess.pid, "SIGKILL");
@@ -186,6 +181,5 @@ function determinePort(server) {
186
181
  });
187
182
  });
188
183
  }
189
-
190
184
  //#endregion
191
- export { runServerAndLookupUser };
185
+ export { runServerAndLookupUser as default };
@@ -1,16 +1,14 @@
1
- import { testInitCommand } from "../command.js";
2
- import action_default from "./action.js";
1
+ import { testInitCommand } from "../command.mjs";
2
+ import runTestInit from "./action.mjs";
3
3
  import { run } from "@optique/run";
4
-
5
4
  //#region src/test/mod.ts
6
5
  async function main() {
7
6
  console.log("Running test-init command...");
8
- const result = run(testInitCommand, {
7
+ await runTestInit(run(testInitCommand, {
9
8
  programName: "fedify-test-init",
10
9
  help: "both"
11
- });
12
- await action_default(result);
10
+ }));
13
11
  }
14
12
  await main();
15
-
16
- //#endregion
13
+ //#endregion
14
+ export {};