@fedify/init 2.1.0-dev.543 → 2.1.0-dev.565
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 +2 -2
- package/dist/action/const.js +2 -2
- package/dist/action/deps.js +2 -2
- package/dist/action/patch.js +3 -3
- package/dist/action/templates.js +2 -2
- package/dist/deno.js +1 -1
- package/dist/lib.js +8 -1
- package/dist/webframeworks/astro.js +4 -4
- package/dist/webframeworks/elysia.js +3 -3
- package/dist/webframeworks/express.js +4 -4
- package/dist/webframeworks/hono.js +4 -4
- package/dist/webframeworks/next.js +3 -3
- package/dist/webframeworks/nitro.js +6 -6
- package/package.json +1 -1
package/dist/action/configs.js
CHANGED
|
@@ -2,7 +2,7 @@ import { merge } from "../utils.js";
|
|
|
2
2
|
import biome_default from "../json/biome.js";
|
|
3
3
|
import vscode_settings_for_deno_default from "../json/vscode-settings-for-deno.js";
|
|
4
4
|
import vscode_settings_default from "../json/vscode-settings.js";
|
|
5
|
-
import {
|
|
5
|
+
import { getPackagesPath } from "./const.js";
|
|
6
6
|
import { getDependencies, getDevDependencies, joinDepsReg } from "./deps.js";
|
|
7
7
|
import { execFileSync } from "node:child_process";
|
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
|
@@ -60,7 +60,7 @@ const getDenoVersionFromCommand = () => {
|
|
|
60
60
|
const getDenoVersionFromRuntime = () => pipe(globalThis, prop("Deno"), prop("version"), prop("deno"));
|
|
61
61
|
const parseVersion = (deno) => pipe(deno.match(/^(\d+)\.(\d+)\.(\d+)/), unless(isNull, (arr) => arr.map(Number)));
|
|
62
62
|
const isLaterOrEqualThan = (basis) => (target) => pipe(zip(basis, target), filter(([b, t]) => t !== b), head, (a) => a ? a[0] < a[1] : true);
|
|
63
|
-
const getLinks = ({ kv, mq, initializer, dir }) => pipe({ "@fedify/fedify": "" }, merge(initializer.dependencies), merge(kv.dependencies), merge(mq.dependencies), keys, filter((dep) => dep.includes("@fedify/")), map((dep) => dep.replace("@fedify/", "")), map((dep) => join(
|
|
63
|
+
const getLinks = ({ kv, mq, initializer, dir }) => pipe({ "@fedify/fedify": "" }, merge(initializer.dependencies), merge(kv.dependencies), merge(mq.dependencies), keys, filter((dep) => dep.includes("@fedify/")), map((dep) => dep.replace("@fedify/", "")), map((dep) => join(getPackagesPath(), dep)), map(realpathSync), map((realAbsolutePath) => relative(realpathSync(dir), realAbsolutePath)), toArray);
|
|
64
64
|
/**
|
|
65
65
|
* Loads TypeScript configuration object for Node.js/Bun projects.
|
|
66
66
|
* Uses compiler options from the framework initializer.
|
package/dist/action/const.js
CHANGED
|
@@ -5,7 +5,7 @@ import { join } from "node:path";
|
|
|
5
5
|
* Absolute path to the monorepo *packages/* directory.
|
|
6
6
|
* Used in test mode to resolve local `@fedify/*` package paths.
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
8
|
+
const getPackagesPath = () => join(import.meta.dirname, "..", "..", "..");
|
|
9
9
|
|
|
10
10
|
//#endregion
|
|
11
|
-
export {
|
|
11
|
+
export { getPackagesPath };
|
package/dist/action/deps.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { merge, replace } from "../utils.js";
|
|
2
2
|
import { PACKAGE_VERSION } from "../lib.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getPackagesPath } from "./const.js";
|
|
4
4
|
import { isDeno } from "./utils.js";
|
|
5
5
|
import { always, entries, filter, fromEntries, map, pipe, when } from "@fxts/core";
|
|
6
6
|
import { join as join$1 } from "node:path";
|
|
@@ -21,7 +21,7 @@ const getDependencies = ({ initializer, kv, mq, testMode, packageManager }) => p
|
|
|
21
21
|
}, merge(initializer.dependencies), merge(kv.dependencies), merge(mq.dependencies), when(always(testMode), isDeno({ packageManager }) ? removeFedifyDeps : addLocalFedifyDeps), normalizePackageNames(packageManager));
|
|
22
22
|
const removeFedifyDeps = (deps) => pipe(deps, entries, filter(([name]) => !name.includes("@fedify")), fromEntries);
|
|
23
23
|
const addLocalFedifyDeps = (deps) => pipe(deps, entries, map(when(([name]) => name.includes("@fedify/"), ([name, _version]) => [name, convertFedifyToLocal(name)])), fromEntries);
|
|
24
|
-
const convertFedifyToLocal = (name) => pipe(name, replace("@fedify/", ""), (pkg) => join$1(
|
|
24
|
+
const convertFedifyToLocal = (name) => pipe(name, replace("@fedify/", ""), (pkg) => join$1(getPackagesPath(), pkg));
|
|
25
25
|
/** Gathers all devDependencies required for the project based on the
|
|
26
26
|
* initializer, key-value store, and message queue configurations,
|
|
27
27
|
* including Biome for linting/formatting.
|
package/dist/action/patch.js
CHANGED
|
@@ -29,12 +29,12 @@ const recommendPatchFiles = (data) => pipe(data, set("files", getFiles), set("js
|
|
|
29
29
|
* @param data - The initialization command data
|
|
30
30
|
* @returns A record of file paths to their string content
|
|
31
31
|
*/
|
|
32
|
-
const getFiles = (data) => ({
|
|
33
|
-
[data.initializer.federationFile]: loadFederation({
|
|
32
|
+
const getFiles = async (data) => ({
|
|
33
|
+
[data.initializer.federationFile]: await loadFederation({
|
|
34
34
|
imports: getImports(data),
|
|
35
35
|
...data
|
|
36
36
|
}),
|
|
37
|
-
[data.initializer.loggingFile]: loadLogging(data),
|
|
37
|
+
[data.initializer.loggingFile]: await loadLogging(data),
|
|
38
38
|
".env": stringifyEnvs(data.env),
|
|
39
39
|
...data.initializer.files
|
|
40
40
|
});
|
package/dist/action/templates.js
CHANGED
|
@@ -11,7 +11,7 @@ import { toMerged } from "es-toolkit";
|
|
|
11
11
|
* @param param0 - Configuration object containing imports, project name, KV store, message queue, and package manager
|
|
12
12
|
* @returns The complete federation configuration file content as a string
|
|
13
13
|
*/
|
|
14
|
-
const loadFederation = ({ imports, projectName, kv, mq, packageManager }) => pipe("defaults/federation.ts",
|
|
14
|
+
const loadFederation = async ({ imports, projectName, kv, mq, packageManager }) => pipe(await readTemplate("defaults/federation.ts"), replace(/\/\* imports \*\//, imports), replace(/\/\* logger \*\//, JSON.stringify(projectName)), replace(/\/\* kv \*\//, convertEnv(kv.object, packageManager)), replace(/\/\* queue \*\//, convertEnv(mq.object, packageManager)));
|
|
15
15
|
/**
|
|
16
16
|
* Loads the logging configuration file content from template.
|
|
17
17
|
* Reads the default logging template and replaces the project name placeholder.
|
|
@@ -19,7 +19,7 @@ const loadFederation = ({ imports, projectName, kv, mq, packageManager }) => pip
|
|
|
19
19
|
* @param param0 - Destructured object containing the project name
|
|
20
20
|
* @returns The complete logging configuration file content as a string
|
|
21
21
|
*/
|
|
22
|
-
const loadLogging = ({ projectName }) => pipe("defaults/logging.ts",
|
|
22
|
+
const loadLogging = async ({ projectName }) => pipe(await readTemplate("defaults/logging.ts"), replace(/\/\* project name \*\//, JSON.stringify(projectName)));
|
|
23
23
|
/**
|
|
24
24
|
* Generates import statements for KV store and message queue dependencies.
|
|
25
25
|
* Merges imports from both KV and MQ configurations and creates proper ES module import syntax.
|
package/dist/deno.js
CHANGED
package/dist/lib.js
CHANGED
|
@@ -69,7 +69,14 @@ async function isPackageManagerAvailable(pm) {
|
|
|
69
69
|
* (e.g., `"defaults/federation.ts"`)
|
|
70
70
|
* @returns The template file content as a string
|
|
71
71
|
*/
|
|
72
|
-
const readTemplate = (templatePath) =>
|
|
72
|
+
const readTemplate = async (templatePath) => {
|
|
73
|
+
const segments = (templatePath + ".tpl").split("/");
|
|
74
|
+
if (import.meta.dirname) return readFileSync(join$1(import.meta.dirname, "templates", ...segments), "utf8");
|
|
75
|
+
const url = new URL(["templates", ...segments].join("/"), import.meta.url);
|
|
76
|
+
const resp = await fetch(url);
|
|
77
|
+
if (!resp.ok) throw new Error(`Failed to fetch template: ${url}`);
|
|
78
|
+
return resp.text();
|
|
79
|
+
};
|
|
73
80
|
/**
|
|
74
81
|
* Returns the shell command string to start the dev server for the given
|
|
75
82
|
* package manager (e.g., `"deno task dev"`, `"bun dev"`, `"npm run dev"`).
|
|
@@ -8,7 +8,7 @@ const astroDescription = {
|
|
|
8
8
|
label: "Astro",
|
|
9
9
|
packageManagers: PACKAGE_MANAGER,
|
|
10
10
|
defaultPort: 4321,
|
|
11
|
-
init: ({ packageManager: pm }) => ({
|
|
11
|
+
init: async ({ packageManager: pm }) => ({
|
|
12
12
|
command: Array.from(getAstroInitCommand(pm)),
|
|
13
13
|
dependencies: pm === "deno" ? {
|
|
14
14
|
...defaultDenoDependencies,
|
|
@@ -28,9 +28,9 @@ const astroDescription = {
|
|
|
28
28
|
federationFile: "src/federation.ts",
|
|
29
29
|
loggingFile: "src/logging.ts",
|
|
30
30
|
files: {
|
|
31
|
-
[`astro.config.ts`]: readTemplate(`astro/astro.config.${pm === "deno" ? "deno" : "node"}.ts`),
|
|
32
|
-
"src/middleware.ts": readTemplate("astro/src/middleware.ts"),
|
|
33
|
-
...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
|
|
31
|
+
[`astro.config.ts`]: await readTemplate(`astro/astro.config.${pm === "deno" ? "deno" : "node"}.ts`),
|
|
32
|
+
"src/middleware.ts": await readTemplate("astro/src/middleware.ts"),
|
|
33
|
+
...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
|
|
34
34
|
},
|
|
35
35
|
compilerOptions: void 0,
|
|
36
36
|
tasks: {
|
|
@@ -8,7 +8,7 @@ const elysiaDescription = {
|
|
|
8
8
|
label: "ElysiaJS",
|
|
9
9
|
packageManagers: PACKAGE_MANAGER,
|
|
10
10
|
defaultPort: 3e3,
|
|
11
|
-
init: ({ projectName, packageManager: pm }) => ({
|
|
11
|
+
init: async ({ projectName, packageManager: pm }) => ({
|
|
12
12
|
dependencies: pm === "deno" ? {
|
|
13
13
|
...defaultDenoDependencies,
|
|
14
14
|
elysia: "npm:elysia@^1.3.6",
|
|
@@ -36,8 +36,8 @@ const elysiaDescription = {
|
|
|
36
36
|
federationFile: "src/federation.ts",
|
|
37
37
|
loggingFile: "src/logging.ts",
|
|
38
38
|
files: {
|
|
39
|
-
"src/index.ts": readTemplate(`elysia/index/${packageManagerToRuntime(pm)}.ts`).replace(/\/\* logger \*\//, projectName),
|
|
40
|
-
...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
|
|
39
|
+
"src/index.ts": (await readTemplate(`elysia/index/${packageManagerToRuntime(pm)}.ts`)).replace(/\/\* logger \*\//, projectName),
|
|
40
|
+
...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
|
|
41
41
|
},
|
|
42
42
|
compilerOptions: pm === "deno" || pm === "bun" ? void 0 : {
|
|
43
43
|
"lib": ["ESNext", "DOM"],
|
|
@@ -8,7 +8,7 @@ const expressDescription = {
|
|
|
8
8
|
label: "Express",
|
|
9
9
|
packageManagers: PACKAGE_MANAGER,
|
|
10
10
|
defaultPort: 8e3,
|
|
11
|
-
init: ({ projectName, packageManager: pm }) => ({
|
|
11
|
+
init: async ({ projectName, packageManager: pm }) => ({
|
|
12
12
|
dependencies: {
|
|
13
13
|
"npm:express": "^4.19.2",
|
|
14
14
|
"@fedify/express": PACKAGE_VERSION,
|
|
@@ -26,9 +26,9 @@ const expressDescription = {
|
|
|
26
26
|
federationFile: "src/federation.ts",
|
|
27
27
|
loggingFile: "src/logging.ts",
|
|
28
28
|
files: {
|
|
29
|
-
"src/app.ts": readTemplate("express/app.ts").replace(/\/\* logger \*\//, projectName),
|
|
30
|
-
"src/index.ts": readTemplate("express/index.ts"),
|
|
31
|
-
...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
|
|
29
|
+
"src/app.ts": (await readTemplate("express/app.ts")).replace(/\/\* logger \*\//, projectName),
|
|
30
|
+
"src/index.ts": await readTemplate("express/index.ts"),
|
|
31
|
+
...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
|
|
32
32
|
},
|
|
33
33
|
compilerOptions: pm === "deno" ? void 0 : {
|
|
34
34
|
"lib": ["ESNext", "DOM"],
|
|
@@ -10,7 +10,7 @@ const honoDescription = {
|
|
|
10
10
|
label: "Hono",
|
|
11
11
|
packageManagers: PACKAGE_MANAGER,
|
|
12
12
|
defaultPort: 8e3,
|
|
13
|
-
init: ({ projectName, packageManager: pm }) => ({
|
|
13
|
+
init: async ({ projectName, packageManager: pm }) => ({
|
|
14
14
|
dependencies: pm === "deno" ? {
|
|
15
15
|
...defaultDenoDependencies,
|
|
16
16
|
"@std/dotenv": "^0.225.2",
|
|
@@ -36,9 +36,9 @@ const honoDescription = {
|
|
|
36
36
|
federationFile: "src/federation.ts",
|
|
37
37
|
loggingFile: "src/logging.ts",
|
|
38
38
|
files: {
|
|
39
|
-
"src/app.tsx": pipe("hono/app.tsx",
|
|
40
|
-
"src/index.ts": readTemplate(`hono/index/${packageManagerToRuntime(pm)}.ts`),
|
|
41
|
-
...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
|
|
39
|
+
"src/app.tsx": pipe(await readTemplate("hono/app.tsx"), replace(/\/\* hono \*\//, pm === "deno" ? "@hono/hono" : "hono"), replace(/\/\* logger \*\//, projectName)),
|
|
40
|
+
"src/index.ts": await readTemplate(`hono/index/${packageManagerToRuntime(pm)}.ts`),
|
|
41
|
+
...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
|
|
42
42
|
},
|
|
43
43
|
compilerOptions: pm === "deno" ? void 0 : {
|
|
44
44
|
"lib": ["ESNext", "DOM"],
|
|
@@ -8,7 +8,7 @@ const nextDescription = {
|
|
|
8
8
|
label: "Next.js",
|
|
9
9
|
packageManagers: PACKAGE_MANAGER,
|
|
10
10
|
defaultPort: 3e3,
|
|
11
|
-
init: ({ packageManager: pm }) => ({
|
|
11
|
+
init: async ({ packageManager: pm }) => ({
|
|
12
12
|
command: getNextInitCommand(pm),
|
|
13
13
|
dependencies: {
|
|
14
14
|
"@fedify/next": PACKAGE_VERSION,
|
|
@@ -21,8 +21,8 @@ const nextDescription = {
|
|
|
21
21
|
federationFile: "federation/index.ts",
|
|
22
22
|
loggingFile: "logging.ts",
|
|
23
23
|
files: {
|
|
24
|
-
"middleware.ts": readTemplate("next/middleware.ts"),
|
|
25
|
-
...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
|
|
24
|
+
"middleware.ts": await readTemplate("next/middleware.ts"),
|
|
25
|
+
...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
|
|
26
26
|
},
|
|
27
27
|
tasks: { ...pm !== "deno" ? { "lint": "eslint ." } : {} },
|
|
28
28
|
instruction: getInstruction(pm, 3e3)
|
|
@@ -8,7 +8,7 @@ const nitroDescription = {
|
|
|
8
8
|
label: "Nitro",
|
|
9
9
|
packageManagers: PACKAGE_MANAGER,
|
|
10
10
|
defaultPort: 3e3,
|
|
11
|
-
init: ({ packageManager: pm, testMode }) => ({
|
|
11
|
+
init: async ({ packageManager: pm, testMode }) => ({
|
|
12
12
|
command: getNitroInitCommand(pm),
|
|
13
13
|
dependencies: {
|
|
14
14
|
"@fedify/h3": PACKAGE_VERSION,
|
|
@@ -18,11 +18,11 @@ const nitroDescription = {
|
|
|
18
18
|
federationFile: "server/federation.ts",
|
|
19
19
|
loggingFile: "server/logging.ts",
|
|
20
20
|
files: {
|
|
21
|
-
"server/middleware/federation.ts": readTemplate("nitro/server/middleware/federation.ts"),
|
|
22
|
-
"server/error.ts": readTemplate("nitro/server/error.ts"),
|
|
23
|
-
"nitro.config.ts": readTemplate("nitro/nitro.config.ts"),
|
|
24
|
-
...testMode ? { ".env": readTemplate("nitro/.env.test") } : {},
|
|
25
|
-
...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
|
|
21
|
+
"server/middleware/federation.ts": await readTemplate("nitro/server/middleware/federation.ts"),
|
|
22
|
+
"server/error.ts": await readTemplate("nitro/server/error.ts"),
|
|
23
|
+
"nitro.config.ts": await readTemplate("nitro/nitro.config.ts"),
|
|
24
|
+
...testMode ? { ".env": await readTemplate("nitro/.env.test") } : {},
|
|
25
|
+
...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
|
|
26
26
|
},
|
|
27
27
|
tasks: pm !== "deno" ? { "lint": "eslint ." } : {},
|
|
28
28
|
instruction: getInstruction(pm, 3e3)
|