@fedify/init 2.2.0-dev.613 → 2.2.0-dev.628
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/dist/action/{configs.js → configs.mjs} +7 -9
- package/dist/action/{const.js → const.mjs} +1 -3
- package/dist/action/{deps.js → deps.mjs} +6 -10
- package/dist/action/{dir.js → dir.mjs} +1 -3
- package/dist/action/{env.js → env.mjs} +3 -6
- package/dist/action/{install.js → install.mjs} +2 -5
- package/dist/action/{mod.d.ts → mod.d.mts} +2 -3
- package/dist/action/{mod.js → mod.mjs} +15 -18
- package/dist/action/{notice.js → notice.mjs} +4 -6
- package/dist/action/{patch.js → patch.mjs} +8 -11
- package/dist/action/{precommand.js → precommand.mjs} +2 -5
- package/dist/action/{recommend.js → recommend.mjs} +5 -8
- package/dist/action/{set.js → set.mjs} +5 -8
- package/dist/action/{templates.js → templates.mjs} +4 -6
- package/dist/action/{utils.js → utils.mjs} +1 -3
- package/dist/ask/{dir.js → dir.mjs} +3 -6
- package/dist/ask/{kv.js → kv.mjs} +4 -7
- package/dist/ask/{mod.js → mod.mjs} +7 -10
- package/dist/ask/{mq.js → mq.mjs} +4 -7
- package/dist/ask/{pm.js → pm.mjs} +8 -11
- package/dist/ask/{wf.js → wf.mjs} +4 -7
- package/dist/{command.d.ts → command.d.mts} +9 -13
- package/dist/{command.js → command.mjs} +2 -4
- package/dist/{const.d.ts → const.d.mts} +0 -2
- package/dist/{const.js → const.mjs} +3 -5
- package/dist/deno.mjs +4 -0
- package/dist/json/biome.mjs +13 -0
- package/dist/json/db-to-check.mjs +25 -0
- package/dist/json/kv.mjs +75 -0
- package/dist/json/mq.mjs +93 -0
- package/dist/json/pm.mjs +35 -0
- package/dist/json/rt.mjs +30 -0
- package/dist/json/vscode-settings-for-deno.mjs +38 -0
- package/dist/json/vscode-settings.mjs +36 -0
- package/dist/{lib.js → lib.mjs} +9 -12
- package/dist/mod.d.mts +3 -0
- package/dist/mod.mjs +3 -0
- package/dist/test/{action.js → action.mjs} +7 -10
- package/dist/test/{create.js → create.mjs} +14 -21
- package/dist/test/{db.js → db.mjs} +5 -8
- package/dist/test/{fill.js → fill.mjs} +10 -12
- package/dist/test/{lookup.js → lookup.mjs} +10 -16
- package/dist/test/{mod.js → mod.mjs} +6 -8
- package/dist/test/{run.js → run.mjs} +5 -8
- package/dist/test/{utils.js → utils.mjs} +2 -4
- package/dist/{types.d.ts → types.d.mts} +3 -11
- package/dist/{utils.d.ts → utils.d.mts} +0 -3
- package/dist/{utils.js → utils.mjs} +15 -23
- package/dist/webframeworks/{astro.js → astro.mjs} +5 -8
- package/dist/webframeworks/{bare-bones.js → bare-bones.mjs} +5 -8
- package/dist/webframeworks/{const.js → const.mjs} +2 -4
- package/dist/webframeworks/{elysia.js → elysia.mjs} +5 -8
- package/dist/webframeworks/{express.js → express.mjs} +5 -8
- package/dist/webframeworks/{hono.js → hono.mjs} +6 -9
- package/dist/webframeworks/mod.mjs +26 -0
- package/dist/webframeworks/{next.js → next.mjs} +5 -8
- package/dist/webframeworks/{nitro.js → nitro.mjs} +5 -8
- package/dist/webframeworks/{utils.js → utils.mjs} +2 -4
- package/package.json +3 -3
- package/dist/deno.js +0 -38
- package/dist/json/biome.js +0 -18
- package/dist/json/db-to-check.js +0 -30
- package/dist/json/kv.js +0 -81
- package/dist/json/mq.js +0 -100
- package/dist/json/pm.js +0 -41
- package/dist/json/rt.js +0 -36
- package/dist/json/vscode-settings-for-deno.js +0 -50
- package/dist/json/vscode-settings.js +0 -46
- package/dist/mod.d.ts +0 -3
- package/dist/mod.js +0 -4
- package/dist/webframeworks/mod.js +0 -29
- /package/dist/test/{mod.d.ts → mod.d.mts} +0 -0
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { merge } from "../utils.
|
|
2
|
-
import biome_default from "../json/biome.
|
|
3
|
-
import vscode_settings_for_deno_default from "../json/vscode-settings-for-deno.
|
|
4
|
-
import vscode_settings_default from "../json/vscode-settings.
|
|
5
|
-
import { getPackagesPath } from "./const.
|
|
6
|
-
import { getDependencies, getDevDependencies, joinDepsReg } from "./deps.
|
|
1
|
+
import { merge } from "../utils.mjs";
|
|
2
|
+
import biome_default from "../json/biome.mjs";
|
|
3
|
+
import vscode_settings_for_deno_default from "../json/vscode-settings-for-deno.mjs";
|
|
4
|
+
import vscode_settings_default from "../json/vscode-settings.mjs";
|
|
5
|
+
import { getPackagesPath } from "./const.mjs";
|
|
6
|
+
import { getDependencies, getDevDependencies, joinDepsReg } from "./deps.mjs";
|
|
7
7
|
import { execFileSync } from "node:child_process";
|
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
|
9
9
|
import { realpathSync } from "node:fs";
|
|
10
10
|
import { join, relative } from "node:path";
|
|
11
11
|
import { always, cases, concat, filter, head, isArray, isEmpty, isNull, isString, keys, map, pick, pipe, prop, toArray, uniq, unless, when, zip } from "@fxts/core/index.js";
|
|
12
|
-
|
|
13
12
|
//#region src/action/configs.ts
|
|
14
13
|
const logger = getLogger([
|
|
15
14
|
"fedify",
|
|
@@ -115,6 +114,5 @@ const devToolConfigs = {
|
|
|
115
114
|
data: { recommendations: ["denoland.vscode-deno"] }
|
|
116
115
|
}
|
|
117
116
|
};
|
|
118
|
-
|
|
119
117
|
//#endregion
|
|
120
|
-
export { devToolConfigs, loadDenoConfig, loadPackageJson, loadTsConfig };
|
|
118
|
+
export { devToolConfigs, loadDenoConfig, loadPackageJson, loadTsConfig };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
|
|
3
2
|
//#region src/action/const.ts
|
|
4
3
|
/**
|
|
5
4
|
* Absolute path to the monorepo *packages/* directory.
|
|
6
5
|
* Used in test mode to resolve local `@fedify/*` package paths.
|
|
7
6
|
*/
|
|
8
7
|
const getPackagesPath = () => join(import.meta.dirname, "..", "..", "..");
|
|
9
|
-
|
|
10
8
|
//#endregion
|
|
11
|
-
export { getPackagesPath };
|
|
9
|
+
export { getPackagesPath };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { merge, replace } from "../utils.
|
|
2
|
-
import { PACKAGE_VERSION } from "../lib.
|
|
3
|
-
import { getPackagesPath } from "./const.
|
|
4
|
-
import { isDeno } from "./utils.
|
|
1
|
+
import { merge, replace } from "../utils.mjs";
|
|
2
|
+
import { PACKAGE_VERSION } from "../lib.mjs";
|
|
3
|
+
import { getPackagesPath } from "./const.mjs";
|
|
4
|
+
import { isDeno } from "./utils.mjs";
|
|
5
5
|
import { always, entries, filter, fromEntries, map, pipe, when } from "@fxts/core";
|
|
6
6
|
import { join as join$1 } from "node:path";
|
|
7
|
-
|
|
8
7
|
//#region src/action/deps.ts
|
|
9
8
|
/**
|
|
10
9
|
* Gathers all dependencies required for the project based on the initializer,
|
|
@@ -40,13 +39,10 @@ const getDevDependencies = ({ initializer, kv, mq, packageManager, testMode }) =
|
|
|
40
39
|
* @returns \{ name: `${registry}:${package}@${version}` } for deno
|
|
41
40
|
*/
|
|
42
41
|
const joinDepsReg = (pm) => (dependencies) => pipe(dependencies, entries, map(([name, version]) => {
|
|
43
|
-
|
|
44
|
-
const fullSpec = version.startsWith("npm:") || version.startsWith("jsr:") ? version : `${name}@${getPackageVersion(pm, version)}`;
|
|
45
|
-
return [cleanName, fullSpec];
|
|
42
|
+
return [name.substring(4), version.startsWith("npm:") || version.startsWith("jsr:") ? version : `${name}@${getPackageVersion(pm, version)}`];
|
|
46
43
|
}), fromEntries);
|
|
47
44
|
const getPackageVersion = (pm, version) => pm !== "deno" && version.includes("+") ? version.substring(0, version.indexOf("+")) : version;
|
|
48
45
|
const normalizePackageNames = (pm) => (deps) => pipe(deps, entries, map(([name, version]) => [getPackageName(pm, name), version]), fromEntries);
|
|
49
46
|
const getPackageName = (pm, name) => pm !== "deno" ? name.startsWith("npm:") ? name.replace("npm:", "") : name : name.startsWith("npm:") ? name : `jsr:${name}`;
|
|
50
|
-
|
|
51
47
|
//#endregion
|
|
52
|
-
export { getDependencies, getDevDependencies, joinDepsReg };
|
|
48
|
+
export { getDependencies, getDevDependencies, joinDepsReg };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { mkdir } from "node:fs/promises";
|
|
2
|
-
|
|
3
2
|
//#region src/action/dir.ts
|
|
4
3
|
/**
|
|
5
4
|
* Creates the target directory if it does not exist.
|
|
@@ -8,6 +7,5 @@ import { mkdir } from "node:fs/promises";
|
|
|
8
7
|
* @returns A promise that resolves when the directory is created
|
|
9
8
|
*/
|
|
10
9
|
const makeDirIfHyd = ({ dir }) => mkdir(dir, { recursive: true });
|
|
11
|
-
|
|
12
10
|
//#endregion
|
|
13
|
-
export { makeDirIfHyd };
|
|
11
|
+
export { makeDirIfHyd };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { notEmpty } from "../utils.
|
|
2
|
-
import { noticeConfigEnv, noticeEnvKeyValue } from "./notice.
|
|
1
|
+
import { notEmpty } from "../utils.mjs";
|
|
2
|
+
import { noticeConfigEnv, noticeEnvKeyValue } from "./notice.mjs";
|
|
3
3
|
import { entries, forEach, pipeLazy, tap, toArray, when } from "@fxts/core";
|
|
4
|
-
|
|
5
4
|
//#region src/action/env.ts
|
|
6
5
|
/**
|
|
7
6
|
* Displays environment variable recommendations to the user.
|
|
@@ -9,7 +8,5 @@ import { entries, forEach, pipeLazy, tap, toArray, when } from "@fxts/core";
|
|
|
9
8
|
* queue configurations, so the user knows what to configure.
|
|
10
9
|
*/
|
|
11
10
|
const recommendConfigEnv = pipeLazy((data) => data.env, entries, toArray, when(notEmpty, tap(noticeConfigEnv)), forEach(noticeEnvKeyValue));
|
|
12
|
-
var env_default = recommendConfigEnv;
|
|
13
|
-
|
|
14
11
|
//#endregion
|
|
15
|
-
export {
|
|
12
|
+
export { recommendConfigEnv as default };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { CommandError, runSubCommand } from "../utils.
|
|
1
|
+
import { CommandError, runSubCommand } from "../utils.mjs";
|
|
2
2
|
import { apply, pipe } from "@fxts/core";
|
|
3
|
-
|
|
4
3
|
//#region src/action/install.ts
|
|
5
4
|
/**
|
|
6
5
|
* Runs `<packageManager> install` in the project directory to install all
|
|
@@ -15,7 +14,5 @@ const installDependencies = (data) => pipe(data, ({ packageManager, dir }) => [[
|
|
|
15
14
|
}
|
|
16
15
|
throw e;
|
|
17
16
|
});
|
|
18
|
-
var install_default = installDependencies;
|
|
19
|
-
|
|
20
17
|
//#endregion
|
|
21
|
-
export {
|
|
18
|
+
export { installDependencies as default };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { InitCommand } from "../command.
|
|
2
|
-
import { InitCommandData } from "../types.
|
|
1
|
+
import { InitCommand } from "../command.mjs";
|
|
2
|
+
import { InitCommandData } from "../types.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/action/mod.d.ts
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* Execution flow of the `runInit` function:
|
|
8
7
|
*
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { set } from "../utils.
|
|
2
|
-
import
|
|
3
|
-
import { makeDirIfHyd } from "./dir.
|
|
4
|
-
import { drawDinosaur, noticeHowToRun, noticeOptions, noticePrecommand } from "./notice.
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { hasCommand, isDry } from "./utils.
|
|
8
|
-
import { patchFiles, recommendPatchFiles } from "./patch.
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
1
|
+
import { set } from "../utils.mjs";
|
|
2
|
+
import askOptions from "../ask/mod.mjs";
|
|
3
|
+
import { makeDirIfHyd } from "./dir.mjs";
|
|
4
|
+
import { drawDinosaur, noticeHowToRun, noticeOptions, noticePrecommand } from "./notice.mjs";
|
|
5
|
+
import recommendConfigEnv from "./env.mjs";
|
|
6
|
+
import installDependencies from "./install.mjs";
|
|
7
|
+
import { hasCommand, isDry } from "./utils.mjs";
|
|
8
|
+
import { patchFiles, recommendPatchFiles } from "./patch.mjs";
|
|
9
|
+
import runPrecommand from "./precommand.mjs";
|
|
10
|
+
import recommendDependencies from "./recommend.mjs";
|
|
11
|
+
import setData from "./set.mjs";
|
|
12
12
|
import { pipe, tap, unless, when } from "@fxts/core";
|
|
13
13
|
import process from "node:process";
|
|
14
|
-
|
|
15
14
|
//#region src/action/mod.ts
|
|
16
15
|
/**
|
|
17
16
|
* Execution flow of the `runInit` function:
|
|
@@ -28,11 +27,9 @@ import process from "node:process";
|
|
|
28
27
|
* 7. Recommends configuration environment via `recommendConfigEnv`.
|
|
29
28
|
* 8. Shows how to run the project via `noticeHowToRun`.
|
|
30
29
|
*/
|
|
31
|
-
const runInit = (options) => pipe(options, tap(drawDinosaur), setTestMode,
|
|
32
|
-
var action_default = runInit;
|
|
30
|
+
const runInit = (options) => pipe(options, tap(drawDinosaur), setTestMode, askOptions, tap(noticeOptions), setData, when(isDry, handleDryRun), unless(isDry, handleHydRun), tap(recommendConfigEnv), tap(noticeHowToRun));
|
|
33
31
|
const setTestMode = set("testMode", () => Boolean(process.env["FEDIFY_TEST_MODE"]));
|
|
34
|
-
const handleDryRun = (data) => pipe(data, tap(when(hasCommand, noticePrecommand)), tap(recommendPatchFiles), tap(
|
|
35
|
-
const handleHydRun = (data) => pipe(data, tap(makeDirIfHyd), tap(when(hasCommand,
|
|
36
|
-
|
|
32
|
+
const handleDryRun = (data) => pipe(data, tap(when(hasCommand, noticePrecommand)), tap(recommendPatchFiles), tap(recommendDependencies));
|
|
33
|
+
const handleHydRun = (data) => pipe(data, tap(makeDirIfHyd), tap(when(hasCommand, runPrecommand)), tap(patchFiles), tap(installDependencies));
|
|
37
34
|
//#endregion
|
|
38
|
-
export {
|
|
35
|
+
export { runInit as default };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { colors, printMessage } from "../utils.
|
|
1
|
+
import { colors, printMessage } from "../utils.mjs";
|
|
2
2
|
import { text } from "@optique/core";
|
|
3
3
|
import { flow } from "es-toolkit";
|
|
4
|
-
|
|
5
4
|
//#region src/action/notice.ts
|
|
6
5
|
/** Prints the Feddy ASCII art banner to stderr. */
|
|
7
6
|
function drawDinosaur() {
|
|
@@ -27,10 +26,10 @@ const noticeOptions = ({ packageManager, webFramework, kvStore, messageQueue })
|
|
|
27
26
|
* Prints the precommand that would be run in dry-run mode,
|
|
28
27
|
* showing the directory and command to execute.
|
|
29
28
|
*/
|
|
30
|
-
function noticePrecommand({ initializer: { command
|
|
29
|
+
function noticePrecommand({ initializer: { command }, dir }) {
|
|
31
30
|
printMessage`📦 Would run command:`;
|
|
32
31
|
printMessage` cd ${dir}`;
|
|
33
|
-
printMessage` ${command
|
|
32
|
+
printMessage` ${command.join(" ")}\n`;
|
|
34
33
|
}
|
|
35
34
|
/** Prints a header indicating that text files would be created. */
|
|
36
35
|
const noticeFilesToCreate = () => printMessage`📄 Would create files:\n`;
|
|
@@ -68,6 +67,5 @@ ${instruction}
|
|
|
68
67
|
|
|
69
68
|
Start by editing the ${text(federationFile)} file to define your federation!
|
|
70
69
|
`;
|
|
71
|
-
|
|
72
70
|
//#endregion
|
|
73
|
-
export { displayFile, drawDinosaur, noticeConfigEnv, noticeDeps, noticeDepsIfExist, noticeDevDepsIfExist, noticeEnvKeyValue, noticeFilesToCreate, noticeFilesToInsert, noticeHowToRun, noticeOptions, noticePrecommand };
|
|
71
|
+
export { displayFile, drawDinosaur, noticeConfigEnv, noticeDeps, noticeDepsIfExist, noticeDevDepsIfExist, noticeEnvKeyValue, noticeFilesToCreate, noticeFilesToInsert, noticeHowToRun, noticeOptions, noticePrecommand };
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { formatJson, merge, replaceAll, set } from "../utils.
|
|
2
|
-
import { createFile, throwUnlessNotExists } from "../lib.
|
|
3
|
-
import { displayFile, noticeFilesToCreate, noticeFilesToInsert } from "./notice.
|
|
4
|
-
import { joinDir, stringifyEnvs } from "./utils.
|
|
5
|
-
import { devToolConfigs, loadDenoConfig, loadPackageJson, loadTsConfig } from "./configs.
|
|
6
|
-
import { getImports, loadFederation, loadLogging } from "./templates.
|
|
1
|
+
import { formatJson, merge, replaceAll, set } from "../utils.mjs";
|
|
2
|
+
import { createFile, throwUnlessNotExists } from "../lib.mjs";
|
|
3
|
+
import { displayFile, noticeFilesToCreate, noticeFilesToInsert } from "./notice.mjs";
|
|
4
|
+
import { joinDir, stringifyEnvs } from "./utils.mjs";
|
|
5
|
+
import { devToolConfigs, loadDenoConfig, loadPackageJson, loadTsConfig } from "./configs.mjs";
|
|
6
|
+
import { getImports, loadFederation, loadLogging } from "./templates.mjs";
|
|
7
7
|
import { always, apply, entries, map, pipe, pipeLazy, tap } from "@fxts/core";
|
|
8
8
|
import { toMerged } from "es-toolkit";
|
|
9
9
|
import { readFile } from "node:fs/promises";
|
|
10
|
-
|
|
11
10
|
//#region src/action/patch.ts
|
|
12
11
|
/**
|
|
13
12
|
* Main function that initializes the project by creating necessary files and configurations.
|
|
@@ -97,8 +96,7 @@ const processAllFiles = (process) => ({ dir, files }) => pipe(files, entries, ma
|
|
|
97
96
|
*/
|
|
98
97
|
async function patchContent(path, content) {
|
|
99
98
|
const prev = await readFileIfExists(path);
|
|
100
|
-
|
|
101
|
-
return [path, data];
|
|
99
|
+
return [path, typeof content === "object" ? mergeJson(prev, content) : appendText(prev, content)];
|
|
102
100
|
}
|
|
103
101
|
/**
|
|
104
102
|
* Merges new JSON data with existing JSON content and formats the result.
|
|
@@ -139,6 +137,5 @@ const appendText = (prev, data) => prev ? `${prev}\n${data}` : data;
|
|
|
139
137
|
* @throws Error if file access fails for reasons other than file not existing
|
|
140
138
|
*/
|
|
141
139
|
const readFileIfExists = (path) => readFile(path, "utf8").catch(pipeLazy(tap(throwUnlessNotExists), always("")));
|
|
142
|
-
|
|
143
140
|
//#endregion
|
|
144
|
-
export { patchFiles, recommendPatchFiles };
|
|
141
|
+
export { patchFiles, recommendPatchFiles };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { CommandError, exit, runSubCommand } from "../utils.
|
|
2
|
-
|
|
1
|
+
import { CommandError, exit, runSubCommand } from "../utils.mjs";
|
|
3
2
|
//#region src/action/precommand.ts
|
|
4
3
|
/**
|
|
5
4
|
* Runs the precommand specified in the initializer to set up the project.
|
|
@@ -19,7 +18,5 @@ const runPrecommand = ({ initializer: { command }, dir }) => runSubCommand(comma
|
|
|
19
18
|
} else console.error("Failed to run the precommand:", e);
|
|
20
19
|
exit(1);
|
|
21
20
|
});
|
|
22
|
-
var precommand_default = runPrecommand;
|
|
23
|
-
|
|
24
21
|
//#endregion
|
|
25
|
-
export {
|
|
22
|
+
export { runPrecommand as default };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { notEmpty } from "../utils.
|
|
2
|
-
import { noticeDeps, noticeDepsIfExist, noticeDevDepsIfExist } from "./notice.
|
|
3
|
-
import { isDeno } from "./utils.
|
|
4
|
-
import { getDependencies, getDevDependencies } from "./deps.
|
|
1
|
+
import { notEmpty } from "../utils.mjs";
|
|
2
|
+
import { noticeDeps, noticeDepsIfExist, noticeDevDepsIfExist } from "./notice.mjs";
|
|
3
|
+
import { isDeno } from "./utils.mjs";
|
|
4
|
+
import { getDependencies, getDevDependencies } from "./deps.mjs";
|
|
5
5
|
import { map, peek, pipeLazy, tap, unless, when } from "@fxts/core";
|
|
6
|
-
|
|
7
6
|
//#region src/action/recommend.ts
|
|
8
7
|
const recommendDeps = pipeLazy(getDependencies, Object.entries, when(notEmpty, tap(noticeDepsIfExist)), peek(noticeDeps));
|
|
9
8
|
const recommendDevDeps = pipeLazy(getDevDependencies, Object.entries, when(notEmpty, tap(noticeDevDepsIfExist)), map(noticeDeps));
|
|
@@ -15,7 +14,5 @@ const recommendDevDeps = pipeLazy(getDevDependencies, Object.entries, when(notEm
|
|
|
15
14
|
* @returns An InitCommandIo function that performs the recommendation
|
|
16
15
|
*/
|
|
17
16
|
const recommendDependencies = pipeLazy(tap(recommendDeps), unless(isDeno, tap(recommendDevDeps)));
|
|
18
|
-
var recommend_default = recommendDependencies;
|
|
19
|
-
|
|
20
17
|
//#endregion
|
|
21
|
-
export {
|
|
18
|
+
export { recommendDependencies as default };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { merge, set } from "../utils.
|
|
2
|
-
import { kvStores, messageQueues } from "../lib.
|
|
3
|
-
import
|
|
1
|
+
import { merge, set } from "../utils.mjs";
|
|
2
|
+
import { kvStores, messageQueues } from "../lib.mjs";
|
|
3
|
+
import webFrameworks from "../webframeworks/mod.mjs";
|
|
4
4
|
import { pipe } from "@fxts/core";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { realpath } from "node:fs/promises";
|
|
7
7
|
import { basename, normalize } from "node:path";
|
|
8
|
-
|
|
9
8
|
//#region src/action/set.ts
|
|
10
9
|
/**
|
|
11
10
|
* Set all necessary data for initializing the project.
|
|
@@ -17,12 +16,10 @@ import { basename, normalize } from "node:path";
|
|
|
17
16
|
* @returns A promise resolving to a complete InitCommandData object
|
|
18
17
|
*/
|
|
19
18
|
const setData = (data) => pipe(data, setProjectName, setInitializer, setKv, setMq, setEnv);
|
|
20
|
-
var set_default = setData;
|
|
21
19
|
const setProjectName = set("projectName", async ({ dir }) => basename(existsSync(dir) ? await realpath(dir) : normalize(dir)));
|
|
22
|
-
const setInitializer = set("initializer", (data) =>
|
|
20
|
+
const setInitializer = set("initializer", (data) => webFrameworks[data.webFramework].init(data));
|
|
23
21
|
const setKv = set("kv", ({ kvStore }) => kvStores[kvStore]);
|
|
24
22
|
const setMq = set("mq", ({ messageQueue }) => messageQueues[messageQueue]);
|
|
25
23
|
const setEnv = set("env", ({ kv, mq }) => merge(kv.env)(mq.env));
|
|
26
|
-
|
|
27
24
|
//#endregion
|
|
28
|
-
export {
|
|
25
|
+
export { setData as default };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { replace } from "../utils.
|
|
2
|
-
import { readTemplate } from "../lib.
|
|
1
|
+
import { replace } from "../utils.mjs";
|
|
2
|
+
import { readTemplate } from "../lib.mjs";
|
|
3
3
|
import { entries, join, map, pipe } from "@fxts/core";
|
|
4
4
|
import { toMerged } from "es-toolkit";
|
|
5
|
-
|
|
6
5
|
//#region src/action/templates.ts
|
|
7
6
|
/**
|
|
8
7
|
* Loads the federation configuration file content from template.
|
|
@@ -27,7 +26,7 @@ const loadLogging = async ({ projectName }) => pipe(await readTemplate("defaults
|
|
|
27
26
|
* @param param0 - Destructured object containing kv and mq configurations
|
|
28
27
|
* @returns A multi-line string containing all necessary import statements
|
|
29
28
|
*/
|
|
30
|
-
const getImports = ({ kv, mq }) => pipe(toMerged(kv.imports, mq.imports), entries, map(([module, { "default": defaultImport = ""
|
|
29
|
+
const getImports = ({ kv, mq }) => pipe(toMerged(kv.imports, mq.imports), entries, map(([module, { "default": defaultImport = "", ...imports }]) => [
|
|
31
30
|
module,
|
|
32
31
|
defaultImport,
|
|
33
32
|
getAlias(imports)
|
|
@@ -50,6 +49,5 @@ const ENV_REG_EXP = /process\.env\.(\w+)/g;
|
|
|
50
49
|
* @returns The converted object string with appropriate environment variable access syntax
|
|
51
50
|
*/
|
|
52
51
|
const convertEnv = (obj, pm) => pm === "deno" && ENV_REG_EXP.test(obj) ? obj.replaceAll(ENV_REG_EXP, (_, g1) => `Deno.env.get("${g1}")`) : obj;
|
|
53
|
-
|
|
54
52
|
//#endregion
|
|
55
|
-
export { getImports, loadFederation, loadLogging };
|
|
53
|
+
export { getImports, loadFederation, loadLogging };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
|
|
3
2
|
//#region src/action/utils.ts
|
|
4
3
|
/** Returns `true` if the current run is in dry-run mode. */
|
|
5
4
|
const isDry = ({ dryRun }) => dryRun;
|
|
@@ -49,6 +48,5 @@ function stringifyEnvs(object) {
|
|
|
49
48
|
}
|
|
50
49
|
return lines.join("\n");
|
|
51
50
|
}
|
|
52
|
-
|
|
53
51
|
//#endregion
|
|
54
|
-
export { hasCommand, isDeno, isDry, joinDir, stringifyEnvs };
|
|
52
|
+
export { hasCommand, isDeno, isDry, joinDir, stringifyEnvs };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { getCwd, getOsType, runSubCommand } from "../utils.
|
|
2
|
-
import { isDirectoryEmpty, logger } from "../lib.
|
|
1
|
+
import { getCwd, getOsType, runSubCommand } from "../utils.mjs";
|
|
2
|
+
import { isDirectoryEmpty, logger } from "../lib.mjs";
|
|
3
3
|
import { identity, pipe, when } from "@fxts/core";
|
|
4
4
|
import { input } from "@inquirer/prompts";
|
|
5
5
|
import { message } from "@optique/core/message";
|
|
6
6
|
import { printError } from "@optique/run";
|
|
7
7
|
import toggle from "inquirer-toggle";
|
|
8
|
-
|
|
9
8
|
//#region src/ask/dir.ts
|
|
10
9
|
/**
|
|
11
10
|
* Fills in the project directory by prompting the user if not provided.
|
|
@@ -23,7 +22,6 @@ const fillDir = async (options) => {
|
|
|
23
22
|
dir
|
|
24
23
|
} : await fillDir(options);
|
|
25
24
|
};
|
|
26
|
-
var dir_default = fillDir;
|
|
27
25
|
const askDir = (cwd) => input({
|
|
28
26
|
message: "Project directory:",
|
|
29
27
|
default: cwd
|
|
@@ -74,6 +72,5 @@ const getPowershellTrashCommand = (dir) => [
|
|
|
74
72
|
"'OnlyErrorDialogs',",
|
|
75
73
|
"'SendToRecycleBin')"
|
|
76
74
|
].join(" ");
|
|
77
|
-
|
|
78
75
|
//#endregion
|
|
79
|
-
export {
|
|
76
|
+
export { fillDir as default };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { printErrorMessage } from "../utils.
|
|
2
|
-
import { isTest, kvStores } from "../lib.
|
|
3
|
-
import { KV_STORE } from "../const.
|
|
1
|
+
import { printErrorMessage } from "../utils.mjs";
|
|
2
|
+
import { isTest, kvStores } from "../lib.mjs";
|
|
3
|
+
import { KV_STORE } from "../const.mjs";
|
|
4
4
|
import { select } from "@inquirer/prompts";
|
|
5
5
|
import { pipe, tap, throwError, unless, when } from "@fxts/core/index.js";
|
|
6
|
-
|
|
7
6
|
//#region src/ask/kv.ts
|
|
8
7
|
/**
|
|
9
8
|
* Fills in the key-value store by prompting the user if not provided.
|
|
@@ -13,7 +12,6 @@ import { pipe, tap, throwError, unless, when } from "@fxts/core/index.js";
|
|
|
13
12
|
* @returns A promise resolving to options with a guaranteed kvStore
|
|
14
13
|
*/
|
|
15
14
|
const fillKvStore = (options) => pipe(options, when(isKvStoreEmpty, askKvStore), unless(isKvSupportsPm, (opt) => pipe(opt, when(isTest, throwError(unmatchedWhileTesting)), tap(noticeUnmatched), fillKvStore)));
|
|
16
|
-
var kv_default = fillKvStore;
|
|
17
15
|
const isKvStoreEmpty = (options) => !options.kvStore;
|
|
18
16
|
const askKvStore = async (data) => ({
|
|
19
17
|
...data,
|
|
@@ -36,6 +34,5 @@ const choiceKvStore = (pm) => (kv) => ({
|
|
|
36
34
|
})
|
|
37
35
|
});
|
|
38
36
|
const isKvSupportsPm = ({ kvStore, packageManager }) => kvStores[kvStore].packageManagers.includes(packageManager);
|
|
39
|
-
|
|
40
37
|
//#endregion
|
|
41
|
-
export {
|
|
38
|
+
export { fillKvStore as default };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import fillDir from "./dir.mjs";
|
|
2
|
+
import fillKvStore from "./kv.mjs";
|
|
3
|
+
import fillMessageQueue from "./mq.mjs";
|
|
4
|
+
import fillPackageManager from "./pm.mjs";
|
|
5
|
+
import fillWebFramework from "./wf.mjs";
|
|
6
6
|
import { pipe } from "@fxts/core";
|
|
7
|
-
|
|
8
7
|
//#region src/ask/mod.ts
|
|
9
8
|
/**
|
|
10
9
|
* Orchestrates all interactive prompts to fill in missing initialization options.
|
|
@@ -12,8 +11,6 @@ import { pipe } from "@fxts/core";
|
|
|
12
11
|
* package manager, message queue, and key-value store.
|
|
13
12
|
* Returns a fully resolved {@link InitCommandOptions} with all fields guaranteed.
|
|
14
13
|
*/
|
|
15
|
-
const askOptions = (options) => pipe(options,
|
|
16
|
-
var ask_default = askOptions;
|
|
17
|
-
|
|
14
|
+
const askOptions = (options) => pipe(options, fillDir, fillWebFramework, fillPackageManager, fillMessageQueue, fillKvStore);
|
|
18
15
|
//#endregion
|
|
19
|
-
export {
|
|
16
|
+
export { askOptions as default };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { printErrorMessage } from "../utils.
|
|
2
|
-
import { isTest, messageQueues } from "../lib.
|
|
3
|
-
import { MESSAGE_QUEUE } from "../const.
|
|
1
|
+
import { printErrorMessage } from "../utils.mjs";
|
|
2
|
+
import { isTest, messageQueues } from "../lib.mjs";
|
|
3
|
+
import { MESSAGE_QUEUE } from "../const.mjs";
|
|
4
4
|
import { select } from "@inquirer/prompts";
|
|
5
5
|
import { pipe, tap, throwError, unless, when } from "@fxts/core/index.js";
|
|
6
|
-
|
|
7
6
|
//#region src/ask/mq.ts
|
|
8
7
|
/**
|
|
9
8
|
* Fills in the message queue by prompting the user if not provided.
|
|
@@ -13,7 +12,6 @@ import { pipe, tap, throwError, unless, when } from "@fxts/core/index.js";
|
|
|
13
12
|
* @returns A promise resolving to options with a guaranteed messageQueue
|
|
14
13
|
*/
|
|
15
14
|
const fillMessageQueue = (options) => pipe(options, when(isMessageQueueEmpty, askMessageQueue), unless(isMqSupportsPm, (opt) => pipe(opt, when(isTest, throwError(unmatchedWhileTesting)), tap(noticeUnmatched), fillMessageQueue)));
|
|
16
|
-
var mq_default = fillMessageQueue;
|
|
17
15
|
const isMessageQueueEmpty = (options) => !options.messageQueue;
|
|
18
16
|
const askMessageQueue = async (data) => ({
|
|
19
17
|
...data,
|
|
@@ -38,6 +36,5 @@ const choiceMessageQueue = (packageManager) => (messageQueue) => ({
|
|
|
38
36
|
})
|
|
39
37
|
});
|
|
40
38
|
const isMqSupportsPm = ({ messageQueue, packageManager }) => messageQueues[messageQueue].packageManagers.includes(packageManager);
|
|
41
|
-
|
|
42
39
|
//#endregion
|
|
43
|
-
export {
|
|
40
|
+
export { fillMessageQueue as default };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { getInstallUrl, isPackageManagerAvailable, kvStores, messageQueues, packageManagers, runtimes } from "../lib.
|
|
2
|
-
import { PACKAGE_MANAGER } from "../const.
|
|
3
|
-
import
|
|
1
|
+
import { getInstallUrl, isPackageManagerAvailable, kvStores, messageQueues, packageManagers, runtimes } from "../lib.mjs";
|
|
2
|
+
import { PACKAGE_MANAGER } from "../const.mjs";
|
|
3
|
+
import webFrameworks from "../webframeworks/mod.mjs";
|
|
4
4
|
import { pipe, when } from "@fxts/core";
|
|
5
5
|
import { select } from "@inquirer/prompts";
|
|
6
6
|
import { message } from "@optique/core/message";
|
|
7
7
|
import { print } from "@optique/run";
|
|
8
|
-
|
|
9
8
|
//#region src/ask/pm.ts
|
|
10
9
|
/**
|
|
11
10
|
* Fills in the package manager by prompting the user if not provided.
|
|
@@ -15,7 +14,7 @@ import { print } from "@optique/run";
|
|
|
15
14
|
* @param options - Initialization options possibly containing a packageManager and webFramework
|
|
16
15
|
* @returns A promise resolving to options with a guaranteed packageManager
|
|
17
16
|
*/
|
|
18
|
-
const fillPackageManager = async ({ packageManager
|
|
17
|
+
const fillPackageManager = async ({ packageManager, ...options }) => {
|
|
19
18
|
const pm = packageManager ?? await askPackageManager(options.webFramework);
|
|
20
19
|
if (await isPackageManagerAvailable(pm)) return {
|
|
21
20
|
...options,
|
|
@@ -24,17 +23,16 @@ const fillPackageManager = async ({ packageManager,...options }) => {
|
|
|
24
23
|
noticeInstallUrl(pm);
|
|
25
24
|
return await fillPackageManager(options);
|
|
26
25
|
};
|
|
27
|
-
var pm_default = fillPackageManager;
|
|
28
26
|
const askPackageManager = (wf) => select({
|
|
29
27
|
message: "Choose the package manager to use",
|
|
30
28
|
choices: PACKAGE_MANAGER.map(choicePackageManager(wf))
|
|
31
29
|
});
|
|
32
30
|
const choicePackageManager = (wf) => (value) => ({
|
|
33
|
-
name: isWfSupportsPm(wf, value) ? value : `${value} (not supported with ${
|
|
31
|
+
name: isWfSupportsPm(wf, value) ? value : `${value} (not supported with ${webFrameworks[wf].label})`,
|
|
34
32
|
value,
|
|
35
33
|
disabled: !isWfSupportsPm(wf, value)
|
|
36
34
|
});
|
|
37
|
-
const isWfSupportsPm = (wf, pm) =>
|
|
35
|
+
const isWfSupportsPm = (wf, pm) => webFrameworks[wf].packageManagers.includes(pm);
|
|
38
36
|
const noticeInstallUrl = (pm) => {
|
|
39
37
|
const label = getLabel(pm);
|
|
40
38
|
const url = getInstallUrl(pm);
|
|
@@ -42,8 +40,7 @@ const noticeInstallUrl = (pm) => {
|
|
|
42
40
|
print(message` You can install it from following link: ${url}`);
|
|
43
41
|
print(message` or choose another package manager:`);
|
|
44
42
|
};
|
|
45
|
-
const getLabel = (name) => pipe(name, whenHasLabel(
|
|
43
|
+
const getLabel = (name) => pipe(name, whenHasLabel(webFrameworks), whenHasLabel(packageManagers), whenHasLabel(messageQueues), whenHasLabel(kvStores), whenHasLabel(runtimes));
|
|
46
44
|
const whenHasLabel = (desc) => when((name) => name in desc, (name) => desc[name].label);
|
|
47
|
-
|
|
48
45
|
//#endregion
|
|
49
|
-
export {
|
|
46
|
+
export { fillPackageManager as default };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { WEB_FRAMEWORK } from "../const.
|
|
2
|
-
import
|
|
1
|
+
import { WEB_FRAMEWORK } from "../const.mjs";
|
|
2
|
+
import webFrameworks from "../webframeworks/mod.mjs";
|
|
3
3
|
import { select } from "@inquirer/prompts";
|
|
4
|
-
|
|
5
4
|
//#region src/ask/wf.ts
|
|
6
5
|
/**
|
|
7
6
|
* Fills in the web framework by prompting the user if not provided.
|
|
@@ -13,14 +12,12 @@ const fillWebFramework = async (options) => ({
|
|
|
13
12
|
...options,
|
|
14
13
|
webFramework: options.webFramework ?? await askWebFramework()
|
|
15
14
|
});
|
|
16
|
-
var wf_default = fillWebFramework;
|
|
17
15
|
const askWebFramework = () => select({
|
|
18
16
|
message: "Choose the web framework to use",
|
|
19
17
|
choices: WEB_FRAMEWORK.map((value) => ({
|
|
20
|
-
name:
|
|
18
|
+
name: webFrameworks[value].label,
|
|
21
19
|
value
|
|
22
20
|
}))
|
|
23
21
|
});
|
|
24
|
-
|
|
25
22
|
//#endregion
|
|
26
|
-
export {
|
|
23
|
+
export { fillWebFramework as default };
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import * as _optique_core0 from "@optique/core";
|
|
1
|
+
import * as _$_optique_core0 from "@optique/core";
|
|
2
2
|
import { InferValue } from "@optique/core";
|
|
3
3
|
|
|
4
4
|
//#region src/command.d.ts
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* The `@optique/core` option schema for the `fedify init` command.
|
|
8
7
|
* Defines `dir`, `webFramework`, `packageManager`, `kvStore`, `messageQueue`,
|
|
9
8
|
* and `dryRun` options that the CLI parser will accept.
|
|
10
9
|
*/
|
|
11
|
-
declare const initOptions: _optique_core0.Parser<"sync", {
|
|
10
|
+
declare const initOptions: _$_optique_core0.Parser<"sync", {
|
|
12
11
|
readonly dir: string;
|
|
13
12
|
readonly webFramework: "bare-bones" | "hono" | "nitro" | "next" | "elysia" | "astro" | "express";
|
|
14
13
|
readonly packageManager: "deno" | "pnpm" | "bun" | "yarn" | "npm";
|
|
@@ -16,17 +15,17 @@ declare const initOptions: _optique_core0.Parser<"sync", {
|
|
|
16
15
|
readonly messageQueue: "postgres" | "mysql" | "redis" | "denokv" | "in-process" | "amqp";
|
|
17
16
|
readonly dryRun: boolean;
|
|
18
17
|
}, {
|
|
19
|
-
readonly dir: [_optique_core0.ValueParserResult<string>];
|
|
20
|
-
readonly webFramework: [_optique_core0.ValueParserResult<"bare-bones" | "hono" | "nitro" | "next" | "elysia" | "astro" | "express">];
|
|
21
|
-
readonly packageManager: [_optique_core0.ValueParserResult<"deno" | "pnpm" | "bun" | "yarn" | "npm">];
|
|
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
|
-
readonly dryRun: _optique_core0.ValueParserResult<boolean>;
|
|
18
|
+
readonly dir: [_$_optique_core0.ValueParserResult<string>];
|
|
19
|
+
readonly webFramework: [_$_optique_core0.ValueParserResult<"bare-bones" | "hono" | "nitro" | "next" | "elysia" | "astro" | "express">];
|
|
20
|
+
readonly packageManager: [_$_optique_core0.ValueParserResult<"deno" | "pnpm" | "bun" | "yarn" | "npm">];
|
|
21
|
+
readonly kvStore: [_$_optique_core0.ValueParserResult<"postgres" | "mysql" | "in-memory" | "redis" | "denokv">];
|
|
22
|
+
readonly messageQueue: [_$_optique_core0.ValueParserResult<"postgres" | "mysql" | "redis" | "denokv" | "in-process" | "amqp">];
|
|
23
|
+
readonly dryRun: _$_optique_core0.ValueParserResult<boolean>;
|
|
25
24
|
}>;
|
|
26
25
|
/**
|
|
27
26
|
* The `fedify init` CLI command parser.
|
|
28
27
|
*/
|
|
29
|
-
declare const initCommand: _optique_core0.Parser<"sync", {
|
|
28
|
+
declare const initCommand: _$_optique_core0.Parser<"sync", {
|
|
30
29
|
readonly dir: string;
|
|
31
30
|
readonly webFramework: "bare-bones" | "hono" | "nitro" | "next" | "elysia" | "astro" | "express";
|
|
32
31
|
readonly packageManager: "deno" | "pnpm" | "bun" | "yarn" | "npm";
|
|
@@ -38,8 +37,5 @@ declare const initCommand: _optique_core0.Parser<"sync", {
|
|
|
38
37
|
}, ["matched", string] | ["parsing", Record<string | symbol, unknown>]>;
|
|
39
38
|
/** The inferred value type produced by parsing the `fedify init` command. */
|
|
40
39
|
type InitCommand = InferValue<typeof initCommand>;
|
|
41
|
-
/**
|
|
42
|
-
* The `test-init` CLI command parser.
|
|
43
|
-
*/
|
|
44
40
|
//#endregion
|
|
45
41
|
export { InitCommand, initCommand, initOptions };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { KV_STORE, MESSAGE_QUEUE, PACKAGE_MANAGER, WEB_FRAMEWORK } from "./const.
|
|
1
|
+
import { KV_STORE, MESSAGE_QUEUE, PACKAGE_MANAGER, WEB_FRAMEWORK } from "./const.mjs";
|
|
2
2
|
import { path } from "@optique/run";
|
|
3
3
|
import { argument, choice, command, constant, merge, message, multiple, object, option, optionNames, optional, or } from "@optique/core";
|
|
4
|
-
|
|
5
4
|
//#region src/command.ts
|
|
6
5
|
const webFramework = optional(option("-w", "--web-framework", choice(WEB_FRAMEWORK, { metavar: "WEB_FRAMEWORK" }), { description: message`The web framework to integrate Fedify with.` }));
|
|
7
6
|
const packageManager = optional(option("-p", "--package-manager", choice(PACKAGE_MANAGER, { metavar: "PACKAGE_MANAGER" }), { description: message`The package manager to use for installing dependencies.` }));
|
|
@@ -47,6 +46,5 @@ const testInitCommand = command("test-init", merge(object("Initialization option
|
|
|
47
46
|
|
|
48
47
|
Unless you specify all options (${optionNames(["-w", "--web-framework"])}, ${optionNames(["-p", "--package-manager"])}, ${optionNames(["-k", "--kv-store"])}, and ${optionNames(["-m", "--message-queue"])}), it will test all combinations of the options.`
|
|
49
48
|
});
|
|
50
|
-
|
|
51
49
|
//#endregion
|
|
52
|
-
export { initCommand, initOptions, testInitCommand };
|
|
50
|
+
export { initCommand, initOptions, testInitCommand };
|