@fedify/init 2.1.1 → 2.1.3

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 (58) hide show
  1. package/dist/action/configs.js +1 -3
  2. package/dist/action/const.js +1 -3
  3. package/dist/action/deps.js +2 -6
  4. package/dist/action/dir.js +1 -3
  5. package/dist/action/env.js +1 -4
  6. package/dist/action/install.js +1 -4
  7. package/dist/action/mod.d.ts +0 -1
  8. package/dist/action/mod.js +10 -13
  9. package/dist/action/notice.js +3 -5
  10. package/dist/action/patch.js +2 -5
  11. package/dist/action/precommand.js +1 -4
  12. package/dist/action/recommend.js +1 -4
  13. package/dist/action/set.js +3 -6
  14. package/dist/action/templates.js +2 -4
  15. package/dist/action/utils.js +1 -3
  16. package/dist/ask/dir.js +1 -4
  17. package/dist/ask/kv.js +1 -4
  18. package/dist/ask/mod.js +7 -10
  19. package/dist/ask/mq.js +1 -4
  20. package/dist/ask/pm.js +6 -9
  21. package/dist/ask/wf.js +3 -6
  22. package/dist/command.d.ts +9 -13
  23. package/dist/command.js +1 -3
  24. package/dist/const.d.ts +0 -2
  25. package/dist/const.js +1 -3
  26. package/dist/deno.js +2 -36
  27. package/dist/json/biome.js +9 -14
  28. package/dist/json/db-to-check.js +21 -26
  29. package/dist/json/kv.js +69 -75
  30. package/dist/json/mq.js +86 -93
  31. package/dist/json/pm.js +31 -37
  32. package/dist/json/rt.js +26 -32
  33. package/dist/json/vscode-settings-for-deno.js +34 -46
  34. package/dist/json/vscode-settings.js +32 -42
  35. package/dist/lib.js +4 -7
  36. package/dist/mod.js +2 -3
  37. package/dist/test/action.js +3 -6
  38. package/dist/test/create.js +11 -18
  39. package/dist/test/db.js +2 -5
  40. package/dist/test/fill.js +9 -11
  41. package/dist/test/lookup.js +8 -14
  42. package/dist/test/mod.js +5 -7
  43. package/dist/test/run.js +4 -7
  44. package/dist/test/utils.js +1 -3
  45. package/dist/types.d.ts +0 -8
  46. package/dist/utils.d.ts +0 -3
  47. package/dist/utils.js +15 -23
  48. package/dist/webframeworks/astro.js +1 -4
  49. package/dist/webframeworks/bare-bones.js +1 -4
  50. package/dist/webframeworks/const.js +1 -3
  51. package/dist/webframeworks/elysia.js +1 -4
  52. package/dist/webframeworks/express.js +1 -4
  53. package/dist/webframeworks/hono.js +1 -4
  54. package/dist/webframeworks/mod.js +15 -18
  55. package/dist/webframeworks/next.js +1 -4
  56. package/dist/webframeworks/nitro.js +1 -4
  57. package/dist/webframeworks/utils.js +1 -3
  58. package/package.json +5 -3
@@ -1,46 +1,36 @@
1
1
  //#region src/json/vscode-settings.json
2
- var editor_detectIndentation = false;
3
- var editor_indentSize = 2;
4
- var editor_insertSpaces = true;
5
- var __javascript_ = {
6
- "editor.defaultFormatter": "biomejs.biome",
7
- "editor.formatOnSave": true,
8
- "editor.codeActionsOnSave": { "source.organizeImports.biome": "always" }
9
- };
10
- var __javascriptreact_ = {
11
- "editor.defaultFormatter": "biomejs.biome",
12
- "editor.formatOnSave": true,
13
- "editor.codeActionsOnSave": { "source.organizeImports.biome": "always" }
14
- };
15
- var __json_ = {
16
- "editor.defaultFormatter": "biomejs.biome",
17
- "editor.formatOnSave": true
18
- };
19
- var __jsonc_ = {
20
- "editor.defaultFormatter": "biomejs.biome",
21
- "editor.formatOnSave": true
22
- };
23
- var __typescript_ = {
24
- "editor.defaultFormatter": "biomejs.biome",
25
- "editor.formatOnSave": true,
26
- "editor.codeActionsOnSave": { "source.organizeImports.biome": "always" }
27
- };
28
- var __typescriptreact_ = {
29
- "editor.defaultFormatter": "biomejs.biome",
30
- "editor.formatOnSave": true,
31
- "editor.codeActionsOnSave": { "source.organizeImports.biome": "always" }
32
- };
33
2
  var vscode_settings_default = {
34
- "editor.detectIndentation": editor_detectIndentation,
35
- "editor.indentSize": editor_indentSize,
36
- "editor.insertSpaces": editor_insertSpaces,
37
- "[javascript]": __javascript_,
38
- "[javascriptreact]": __javascriptreact_,
39
- "[json]": __json_,
40
- "[jsonc]": __jsonc_,
41
- "[typescript]": __typescript_,
42
- "[typescriptreact]": __typescriptreact_
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
+ }
43
34
  };
44
-
45
35
  //#endregion
46
- export { vscode_settings_default as default };
36
+ export { vscode_settings_default as default };
package/dist/lib.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { isNotFoundError, runSubCommand } from "./utils.js";
2
- import deno_default from "./deno.js";
2
+ import { version } from "./deno.js";
3
3
  import kv_default from "./json/kv.js";
4
4
  import mq_default from "./json/mq.js";
5
5
  import pm_default from "./json/pm.js";
@@ -11,10 +11,9 @@ import { getLogger } from "@logtape/logtape";
11
11
  import { readFileSync } from "node:fs";
12
12
  import { mkdir, readdir, writeFile } from "node:fs/promises";
13
13
  import { dirname, join as join$1 } from "node:path";
14
-
15
14
  //#region src/lib.ts
16
15
  /** The current `@fedify/init` package version, read from *deno.json*. */
17
- const PACKAGE_VERSION = deno_default.version;
16
+ const PACKAGE_VERSION = version;
18
17
  /** Logger instance for the `fedify init` command, scoped to `["fedify", "cli", "init"]`. */
19
18
  const logger = getLogger([
20
19
  "fedify",
@@ -128,8 +127,7 @@ const throwUnlessNotExists = throwIf(negate(isNotExistsError));
128
127
  */
129
128
  const isDirectoryEmpty = async (path) => {
130
129
  try {
131
- const files = await readdir(path);
132
- return files.length === 0;
130
+ return (await readdir(path)).length === 0;
133
131
  } catch (e) {
134
132
  throwUnlessNotExists(e);
135
133
  return true;
@@ -137,6 +135,5 @@ const isDirectoryEmpty = async (path) => {
137
135
  };
138
136
  /** Returns `true` if the current run is in test mode. */
139
137
  const isTest = ({ testMode }) => testMode;
140
-
141
138
  //#endregion
142
- export { PACKAGE_VERSION, createFile, getDevCommand, getInstallUrl, isDirectoryEmpty, isPackageManagerAvailable, isTest, kvStores, logger, messageQueues, packageManagers, readTemplate, runtimes, throwUnlessNotExists };
139
+ export { PACKAGE_VERSION, createFile, getDevCommand, getInstallUrl, isDirectoryEmpty, isPackageManagerAvailable, isTest, kvStores, logger, messageQueues, packageManagers, readTemplate, runtimes, throwUnlessNotExists };
package/dist/mod.js CHANGED
@@ -1,4 +1,3 @@
1
- import action_default from "./action/mod.js";
1
+ import runInit from "./action/mod.js";
2
2
  import { initCommand, initOptions } from "./command.js";
3
-
4
- export { initCommand, initOptions, action_default as runInit };
3
+ export { initCommand, initOptions, runInit };
@@ -1,15 +1,12 @@
1
1
  import { set } from "../utils.js";
2
2
  import { checkRequiredDbs } from "./db.js";
3
3
  import { fillEmptyOptions } from "./fill.js";
4
- import run_default from "./run.js";
4
+ import runTests from "./run.js";
5
5
  import { emptyTestDir, genRunId, genTestDirPrefix, logTestDir } from "./utils.js";
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
1
  import { CommandError, printErrorMessage, printMessage, product, runSubCommand } from "../utils.js";
2
2
  import pm_default from "../json/pm.js";
3
3
  import { kvStores, messageQueues } from "../lib.js";
4
- import webframeworks_default from "../webframeworks/mod.js";
4
+ import webFrameworks from "../webframeworks/mod.js";
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,13 +28,10 @@ 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
  printMessage` Check out these files for more details:
42
37
  ${join$1(testDir, "out.txt")} and
@@ -44,7 +39,6 @@ const createTestApp = (testDirPrefix, dry) => async (options) => {
44
39
  return "";
45
40
  }
46
41
  };
47
- var create_default = createTestApp;
48
42
  function* genInitCommand(testDir, dry, [webFramework, packageManager, kvStore, messageQueue]) {
49
43
  yield "deno";
50
44
  yield "run";
@@ -72,8 +66,8 @@ const generateTestCases = ({ webFramework, packageManager, kvStore, messageQueue
72
66
  ]);
73
67
  return product(webFramework, pms, kvStore, messageQueue);
74
68
  };
75
- const filterPackageManager = (pm) => pipe(pm, filter((pm$1) => BANNED_PMS.includes(pm$1) ? printErrorMessage`${pm_default[pm$1]["label"]} is not \
76
- supported in test mode yet because ${pm_default[pm$1]["label"]} don't \
69
+ const filterPackageManager = (pm) => pipe(pm, filter((pm) => BANNED_PMS.includes(pm) ? printErrorMessage`${pm_default[pm]["label"]} is not \
70
+ supported in test mode yet because ${pm_default[pm]["label"]} don't \
77
71
  support local file dependencies properly.` : true), toArray);
78
72
  const exitIfCasesEmpty = (cases) => {
79
73
  if (cases.some(isEmpty)) {
@@ -89,11 +83,10 @@ const saveOutputs = async (dirPath, { stdout, stderr }) => {
89
83
  function filterOptions(options) {
90
84
  const [wf, pm, kv, mq] = options;
91
85
  return [
92
- webframeworks_default[wf].packageManagers,
86
+ webFrameworks[wf].packageManagers,
93
87
  kvStores[kv].packageManagers,
94
88
  messageQueues[mq].packageManagers
95
89
  ].every((pms) => pms.includes(pm));
96
90
  }
97
-
98
91
  //#endregion
99
- export { create_default as default, filterOptions, generateTestCases };
92
+ export { createTestApp as default, filterOptions, generateTestCases };
package/dist/test/db.js CHANGED
@@ -3,7 +3,6 @@ import { DB_TO_CHECK } from "../const.js";
3
3
  import db_to_check_default from "../json/db-to-check.js";
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 };
package/dist/test/fill.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { KV_STORE, MESSAGE_QUEUE, PACKAGE_MANAGER, WEB_FRAMEWORK } from "../const.js";
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
1
  import { printErrorMessage, printMessage, runSubCommand } from "../utils.js";
2
2
  import { getDevCommand } from "../lib.js";
3
- import webframeworks_default from "../webframeworks/mod.js";
3
+ import webFrameworks from "../webframeworks/mod.js";
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).catch(() => false);
54
+ const result = await serverClosure(dir, getDevCommand(pm), webFrameworks[wf].defaultPort, sendLookup).catch(() => false);
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 };
package/dist/test/mod.js CHANGED
@@ -1,16 +1,14 @@
1
1
  import { testInitCommand } from "../command.js";
2
- import action_default from "./action.js";
2
+ import runTestInit from "./action.js";
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 {};
package/dist/test/run.js CHANGED
@@ -1,13 +1,11 @@
1
1
  import { printMessage } from "../utils.js";
2
- import create_default, { filterOptions, generateTestCases } from "./create.js";
3
- import { runServerAndLookupUser } from "./lookup.js";
2
+ import createTestApp, { filterOptions, generateTestCases } from "./create.js";
3
+ import runServerAndLookupUser from "./lookup.js";
4
4
  import { always, filter, map, pipe, tap, unless } from "@fxts/core";
5
5
  import { optionNames } from "@optique/core";
6
6
  import { join as join$1 } from "node:path";
7
-
8
7
  //#region src/test/run.ts
9
- const runTests = (dry) => ({ testDirPrefix, dryRun, hydRun,...options }) => pipe(options, printStartMessage(dry), generateTestCases, filter(filterOptions), map(create_default(join$1(testDirPrefix, getMid(dryRun, hydRun, dry)), dry)), Array.fromAsync, unless(always(dry), runServerAndLookupUser));
10
- var run_default = runTests;
8
+ const runTests = (dry) => ({ testDirPrefix, dryRun, hydRun, ...options }) => pipe(options, printStartMessage(dry), generateTestCases, filter(filterOptions), map(createTestApp(join$1(testDirPrefix, getMid(dryRun, hydRun, dry)), dry)), Array.fromAsync, unless(always(dry), runServerAndLookupUser));
11
9
  const printStartMessage = (dry) => tap(() => printMessage`\n
12
10
  Init ${dry ? "Dry" : "Hyd"} Test start!
13
11
  Options: ${optionNames([
@@ -17,6 +15,5 @@ Options: ${optionNames([
17
15
  "Message Queue"
18
16
  ])}`);
19
17
  const getMid = (dryRun, hydRun, dry) => dryRun === hydRun ? dry ? "dry" : "hyd" : "";
20
-
21
18
  //#endregion
22
- export { run_default as default };
19
+ export { runTests as default };
@@ -2,7 +2,6 @@ import { printMessage } from "../utils.js";
2
2
  import { rm } from "node:fs/promises";
3
3
  import { join } from "node:path";
4
4
  import { tmpdir } from "node:os";
5
-
6
5
  //#region src/test/utils.ts
7
6
  const genRunId = () => `${Date.now()}-${Math.random().toString(36).slice(2)}`;
8
7
  const genTestDirPrefix = ({ runId }) => join(tmpdir(), "fedify-init", runId);
@@ -10,6 +9,5 @@ const emptyTestDir = ({ testDirPrefix }) => rm(testDirPrefix, { recursive: true
10
9
  const logTestDir = ({ runId, testDirPrefix }) => printMessage`Test running with
11
10
  Run ID: ${runId}
12
11
  Path: ${testDirPrefix}`;
13
-
14
12
  //#endregion
15
- export { emptyTestDir, genRunId, genTestDirPrefix, logTestDir };
13
+ export { emptyTestDir, genRunId, genTestDirPrefix, logTestDir };
package/dist/types.d.ts CHANGED
@@ -6,8 +6,6 @@ import { Message } from "@optique/core";
6
6
  //#region src/types.d.ts
7
7
  /** Supported package manager identifiers: `"deno"`, `"pnpm"`, `"bun"`, `"yarn"`, `"npm"`. */
8
8
  type PackageManager = typeof PACKAGE_MANAGER[number];
9
- /** Supported web framework identifiers: `"hono"`, `"nitro"`, `"next"`, `"elysia"`, `"astro"`, `"express"`. */
10
-
11
9
  /**
12
10
  * The result returned by a web framework's `init()` function.
13
11
  * Contains all the information needed to scaffold a project for that framework,
@@ -33,11 +31,6 @@ interface WebFrameworkInitializer {
33
31
  /** Instructions shown to the user after project initialization is complete. */
34
32
  instruction: Message;
35
33
  }
36
- /**
37
- * Describes a web framework integration (Hono, Express, Nitro, Next.js,
38
- * ElysiaJS, Astro) and how to initialize a project with it.
39
- */
40
-
41
34
  /**
42
35
  * Describes a message queue backend (Deno KV, Redis, PostgreSQL, AMQP) and
43
36
  * the dependencies, imports, and environment variables it requires.
@@ -106,6 +99,5 @@ interface InitCommandData extends InitCommandOptions {
106
99
  /** Combined environment variables from both KV store and message queue. */
107
100
  readonly env: Record<string, string>;
108
101
  }
109
- /** A synchronous side-effect function that operates on {@link InitCommandData}. */
110
102
  //#endregion
111
103
  export { InitCommandData };
package/dist/utils.d.ts CHANGED
@@ -1,12 +1,9 @@
1
1
  import { message } from "@optique/core";
2
- import "chalk";
3
2
  import { toMerged } from "es-toolkit";
4
3
  import { spawn } from "node:child_process";
5
4
 
6
5
  //#region src/utils.d.ts
7
-
8
6
  /** Makes all properties of `T` required and non-nullable. */
9
7
  type RequiredNotNull<T> = { [P in keyof T]: NonNullable<T[P]> };
10
- /** Type guard that checks whether a value is a `Promise`. */
11
8
  //#endregion
12
9
  export { RequiredNotNull };
package/dist/utils.js CHANGED
@@ -5,15 +5,8 @@ import { message } from "@optique/core";
5
5
  import { Chalk } from "chalk";
6
6
  import { flow, toMerged } from "es-toolkit";
7
7
  import { spawn } from "node:child_process";
8
-
9
- //#region src/utils.ts
10
- /**
11
- * Whether terminal color output is enabled.
12
- * `true` when stdout is a TTY and the `NO_COLOR` environment variable is not set.
13
- */
14
- const colorEnabled = process.stdout.isTTY && !("NO_COLOR" in process.env && process.env.NO_COLOR !== "");
15
8
  /** Chalk instance configured based on {@link colorEnabled}. */
16
- const colors = new Chalk(colorEnabled ? {} : { level: 0 });
9
+ const colors = new Chalk(process.stdout.isTTY && !("NO_COLOR" in process.env && process.env.NO_COLOR !== "") ? {} : { level: 0 });
17
10
  /** Type guard that checks whether a value is a `Promise`. */
18
11
  const isPromise = (value) => value instanceof Promise;
19
12
  /**
@@ -27,7 +20,7 @@ const isPromise = (value) => value instanceof Promise;
27
20
  * @returns A function that augments the input object with the computed property
28
21
  */
29
22
  function set(key, f) {
30
- return (obj) => {
23
+ return ((obj) => {
31
24
  const result = f(obj);
32
25
  if (isPromise(result)) return result.then((value) => ({
33
26
  ...obj,
@@ -37,7 +30,7 @@ function set(key, f) {
37
30
  ...obj,
38
31
  [key]: result
39
32
  };
40
- };
33
+ });
41
34
  }
42
35
  /**
43
36
  * Curried deep merge helper. Returns a function that merges `source` into the
@@ -48,12 +41,12 @@ const merge$1 = (source = {}) => (target = {}) => toMerged(target, source);
48
41
  * Curried `String.prototype.replace`. Returns a function that performs the
49
42
  * replacement on the given text.
50
43
  */
51
- const replace = (pattern, replacement) => (text$1) => text$1.replace(pattern, replacement);
44
+ const replace = (pattern, replacement) => (text) => text.replace(pattern, replacement);
52
45
  /**
53
46
  * Curried `String.prototype.replaceAll`. Returns a function that replaces all
54
47
  * occurrences of the pattern in the given text.
55
48
  */
56
- const replaceAll = (pattern, replacement) => (text$1) => text$1.replaceAll(pattern, replacement);
49
+ const replaceAll = (pattern, replacement) => (text) => text.replaceAll(pattern, replacement);
57
50
  /** Serializes a value to a pretty-printed JSON string with a trailing newline. */
58
51
  const formatJson = (obj) => JSON.stringify(obj, null, 2) + "\n";
59
52
  /** Checks whether a string or array-like value has a length greater than zero. */
@@ -66,14 +59,14 @@ const isNotFoundError = (e) => isObject(e) && "code" in e && e.code === "ENOENT"
66
59
  */
67
60
  var CommandError = class extends Error {
68
61
  commandLine;
69
- constructor(message$1, stdout, stderr, code, command$1) {
70
- super(message$1);
62
+ constructor(message, stdout, stderr, code, command) {
63
+ super(message);
71
64
  this.stdout = stdout;
72
65
  this.stderr = stderr;
73
66
  this.code = code;
74
- this.command = command$1;
67
+ this.command = command;
75
68
  this.name = "CommandError";
76
- this.commandLine = command$1.join(" ");
69
+ this.commandLine = command.join(" ");
77
70
  }
78
71
  };
79
72
  /**
@@ -86,8 +79,8 @@ var CommandError = class extends Error {
86
79
  * @param options - Options forwarded to `node:child_process.spawn`
87
80
  * @returns A promise resolving to `{ stdout, stderr }`
88
81
  */
89
- const runSubCommand = async (command$1, options) => {
90
- const commands = command$1.reduce((acc, cur) => {
82
+ const runSubCommand = async (command, options) => {
83
+ const commands = command.reduce((acc, cur) => {
91
84
  if (cur === "&&") acc.push([]);
92
85
  else {
93
86
  if (acc.length === 0) acc.push([]);
@@ -112,10 +105,10 @@ const runSubCommand = async (command$1, options) => {
112
105
  }
113
106
  return results;
114
107
  };
115
- const runSingularCommand = (command$1, options) => new Promise((resolve, reject) => {
108
+ const runSingularCommand = (command, options) => new Promise((resolve, reject) => {
116
109
  let stdout = "";
117
110
  let stderr = "";
118
- const child = spawn(command$1[0], command$1.slice(1), options);
111
+ const child = spawn(command[0], command.slice(1), options);
119
112
  child.stdout?.on("data", (data) => {
120
113
  stdout += data.toString();
121
114
  });
@@ -127,7 +120,7 @@ const runSingularCommand = (command$1, options) => new Promise((resolve, reject)
127
120
  stdout: stdout.trim(),
128
121
  stderr: stderr.trim()
129
122
  });
130
- else reject(new CommandError(`Command exited with code ${code ?? "unknown"}`, stdout.trim(), stderr.trim(), code ?? -1, command$1));
123
+ else reject(new CommandError(`Command exited with code ${code ?? "unknown"}`, stdout.trim(), stderr.trim(), code ?? -1, command));
131
124
  });
132
125
  child.on("error", (error) => {
133
126
  reject(error);
@@ -157,6 +150,5 @@ function* product(...[head, ...tail]) {
157
150
  const printMessage = flow(message, print);
158
151
  /** Prints a formatted error message to stderr using `@optique/run`'s `printError`. */
159
152
  const printErrorMessage = flow(message, printError);
160
-
161
153
  //#endregion
162
- export { CommandError, colors, exit, formatJson, getCwd, getOsType, isNotFoundError, merge$1 as merge, notEmpty, printErrorMessage, printMessage, product, replace, replaceAll, runSubCommand, set };
154
+ export { CommandError, colors, exit, formatJson, getCwd, getOsType, isNotFoundError, merge$1 as merge, notEmpty, printErrorMessage, printMessage, product, replace, replaceAll, runSubCommand, set };
@@ -2,7 +2,6 @@ import { PACKAGE_VERSION, readTemplate } from "../lib.js";
2
2
  import { PACKAGE_MANAGER } from "../const.js";
3
3
  import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
4
4
  import { getInstruction } from "./utils.js";
5
-
6
5
  //#region src/webframeworks/astro.ts
7
6
  const astroDescription = {
8
7
  label: "Astro",
@@ -52,7 +51,6 @@ const astroDescription = {
52
51
  instruction: getInstruction(pm, 4321)
53
52
  })
54
53
  };
55
- var astro_default = astroDescription;
56
54
  /**
57
55
  * Returns the shell command array to scaffold a new Astro project
58
56
  * in the current directory using the given package manager.
@@ -78,6 +76,5 @@ const createAstroAppCommand = (pm) => pm === "deno" ? [
78
76
  "-y",
79
77
  "--npm"
80
78
  ] : [pm, "create"];
81
-
82
79
  //#endregion
83
- export { astro_default as default };
80
+ export { astroDescription as default };
@@ -2,7 +2,6 @@ import { readTemplate } from "../lib.js";
2
2
  import { PACKAGE_MANAGER } from "../const.js";
3
3
  import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
4
4
  import { getInstruction, packageManagerToRuntime } from "./utils.js";
5
-
6
5
  //#region src/webframeworks/bare-bones.ts
7
6
  const bareBonesDescription = {
8
7
  label: "Bare-bones",
@@ -49,7 +48,5 @@ const bareBonesDescription = {
49
48
  instruction: getInstruction(pm, 8e3)
50
49
  })
51
50
  };
52
- var bare_bones_default = bareBonesDescription;
53
-
54
51
  //#endregion
55
- export { bare_bones_default as default };
52
+ export { bareBonesDescription as default };
@@ -1,11 +1,9 @@
1
1
  import { PACKAGE_VERSION } from "../lib.js";
2
-
3
2
  //#region src/webframeworks/const.ts
4
3
  const defaultDevDependencies = {
5
4
  "@fedify/lint": PACKAGE_VERSION,
6
5
  "eslint": "^9.0.0"
7
6
  };
8
7
  const defaultDenoDependencies = { "@fedify/lint": PACKAGE_VERSION };
9
-
10
8
  //#endregion
11
- export { defaultDenoDependencies, defaultDevDependencies };
9
+ export { defaultDenoDependencies, defaultDevDependencies };
@@ -2,7 +2,6 @@ import { PACKAGE_VERSION, readTemplate } from "../lib.js";
2
2
  import { PACKAGE_MANAGER } from "../const.js";
3
3
  import { defaultDenoDependencies, defaultDevDependencies } from "./const.js";
4
4
  import { getInstruction, packageManagerToRuntime } from "./utils.js";
5
-
6
5
  //#region src/webframeworks/elysia.ts
7
6
  const elysiaDescription = {
8
7
  label: "ElysiaJS",
@@ -60,7 +59,5 @@ const elysiaDescription = {
60
59
  instruction: getInstruction(pm, 3e3)
61
60
  })
62
61
  };
63
- var elysia_default = elysiaDescription;
64
-
65
62
  //#endregion
66
- export { elysia_default as default };
63
+ export { elysiaDescription as default };