@fedify/init
Advanced tools
@@ -5,3 +5,3 @@ import { merge } from "../utils.js"; | ||
| import vscode_settings_default from "../json/vscode-settings.js"; | ||
| import { PACKAGES_PATH } from "./const.js"; | ||
| import { getPackagesPath } from "./const.js"; | ||
| import { getDependencies, getDevDependencies, joinDepsReg } from "./deps.js"; | ||
@@ -33,3 +33,3 @@ import { uniq } from "es-toolkit"; | ||
| const getUnstable = ({ kv: { denoUnstable: kv = [] }, mq: { denoUnstable: mq = [] } }) => pipe(["temporal"], concat(kv), concat(mq), toArray, uniq); | ||
| 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(PACKAGES_PATH, dep)), map((absolutePath) => realpathSync(absolutePath)), map((realAbsolutePath) => relative(realpathSync(dir), realAbsolutePath)), toArray); | ||
| 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((absolutePath) => realpathSync(absolutePath)), map((realAbsolutePath) => relative(realpathSync(dir), realAbsolutePath)), toArray); | ||
| /** | ||
@@ -36,0 +36,0 @@ * Loads TypeScript configuration object for Node.js/Bun projects. |
| import { join } from "node:path"; | ||
| //#region src/action/const.ts | ||
| const PACKAGES_PATH = join(import.meta.dirname, "..", "..", ".."); | ||
| const getPackagesPath = () => join(import.meta.dirname, "..", "..", ".."); | ||
| //#endregion | ||
| export { PACKAGES_PATH }; | ||
| export { getPackagesPath }; |
| import { merge, replace } from "../utils.js"; | ||
| import { PACKAGE_VERSION } from "../lib.js"; | ||
| import { PACKAGES_PATH } from "./const.js"; | ||
| import { getPackagesPath } from "./const.js"; | ||
| import { isDeno } from "./utils.js"; | ||
@@ -24,3 +24,3 @@ import { always, entries, filter, fromEntries, map, pipe, when } from "@fxts/core"; | ||
| const addLocalFedifyDeps = (deps) => pipe(deps, entries, map(when(([name]) => name.includes("@fedify/"), ([name, _version]) => [name, convertFedifyToLocal(name)])), fromEntries); | ||
| const convertFedifyToLocal = (name) => pipe(name, replace("@fedify/", ""), (pkg) => join$1(PACKAGES_PATH, pkg)); | ||
| const convertFedifyToLocal = (name) => pipe(name, replace("@fedify/", ""), (pkg) => join$1(getPackagesPath(), pkg)); | ||
| /** Gathers all devDependencies required for the project based on the | ||
@@ -27,0 +27,0 @@ * initializer, key-value store, and message queue configurations, |
@@ -32,8 +32,8 @@ import { formatJson, merge, replaceAll, set } from "../utils.js"; | ||
| */ | ||
| const getFiles = (data) => ({ | ||
| [data.initializer.federationFile]: loadFederation({ | ||
| const getFiles = async (data) => ({ | ||
| [data.initializer.federationFile]: await loadFederation({ | ||
| imports: getImports(data), | ||
| ...data | ||
| }), | ||
| [data.initializer.loggingFile]: loadLogging(data), | ||
| [data.initializer.loggingFile]: await loadLogging(data), | ||
| ".env": stringifyEnvs(data.env), | ||
@@ -40,0 +40,0 @@ ...data.initializer.files |
+1
-1
| //#region deno.json | ||
| var name = "@fedify/init"; | ||
| var version = "2.0.6-dev.559+50ac1c17"; | ||
| var version = "2.0.6-dev.561+ae0a7bc0"; | ||
| var license = "MIT"; | ||
@@ -5,0 +5,0 @@ var exports = "./src/mod.ts"; |
+8
-1
@@ -41,3 +41,10 @@ import { isNotFoundError, runSubCommand } from "./utils.js"; | ||
| } | ||
| const readTemplate = (templatePath) => readFileSync(join$1(import.meta.dirname, "templates", ...(templatePath + ".tpl").split("/")), "utf8"); | ||
| const readTemplate = async (templatePath) => { | ||
| const segments = (templatePath + ".tpl").split("/"); | ||
| if (import.meta.dirname) return readFileSync(join$1(import.meta.dirname, "templates", ...segments), "utf8"); | ||
| const url = new URL(["templates", ...segments].join("/"), import.meta.url); | ||
| const resp = await fetch(url); | ||
| if (!resp.ok) throw new Error(`Failed to fetch template: ${url}`); | ||
| return resp.text(); | ||
| }; | ||
| const getInstruction = (pm, port) => message` | ||
@@ -44,0 +51,0 @@ To start the server, run the following command: |
+20
-20
@@ -11,3 +11,3 @@ import { replace } from "./utils.js"; | ||
| packageManagers: PACKAGE_MANAGER, | ||
| init: ({ projectName, packageManager: pm }) => ({ | ||
| init: async ({ projectName, packageManager: pm }) => ({ | ||
| dependencies: pm === "deno" ? { | ||
@@ -38,5 +38,5 @@ ...defaultDenoDependencies, | ||
| files: { | ||
| "src/app.tsx": pipe("hono/app.tsx", readTemplate, replace(/\/\* hono \*\//, pm === "deno" ? "@hono/hono" : "hono"), replace(/\/\* logger \*\//, projectName)), | ||
| "src/index.ts": readTemplate(`hono/index/${packageManagerToRuntime(pm)}.ts`), | ||
| ...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {} | ||
| "src/app.tsx": pipe(await readTemplate("hono/app.tsx"), replace(/\/\* hono \*\//, pm === "deno" ? "@hono/hono" : "hono"), replace(/\/\* logger \*\//, projectName)), | ||
| "src/index.ts": await readTemplate(`hono/index/${packageManagerToRuntime(pm)}.ts`), | ||
| ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {} | ||
| }, | ||
@@ -67,3 +67,3 @@ compilerOptions: pm === "deno" ? void 0 : { | ||
| packageManagers: PACKAGE_MANAGER, | ||
| init: ({ projectName, packageManager: pm }) => ({ | ||
| init: async ({ projectName, packageManager: pm }) => ({ | ||
| dependencies: pm === "deno" ? { | ||
@@ -96,4 +96,4 @@ ...defaultDenoDependencies, | ||
| files: { | ||
| "src/index.ts": readTemplate(`elysia/index/${packageManagerToRuntime(pm)}.ts`).replace(/\/\* logger \*\//, projectName), | ||
| ...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {} | ||
| "src/index.ts": (await readTemplate(`elysia/index/${packageManagerToRuntime(pm)}.ts`)).replace(/\/\* logger \*\//, projectName), | ||
| ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {} | ||
| }, | ||
@@ -125,3 +125,3 @@ compilerOptions: pm === "deno" || pm === "bun" ? void 0 : { | ||
| packageManagers: PACKAGE_MANAGER, | ||
| init: ({ projectName, packageManager: pm }) => ({ | ||
| init: async ({ projectName, packageManager: pm }) => ({ | ||
| dependencies: { | ||
@@ -144,5 +144,5 @@ "npm:express": "^4.19.2", | ||
| files: { | ||
| "src/app.ts": readTemplate("express/app.ts").replace(/\/\* logger \*\//, projectName), | ||
| "src/index.ts": readTemplate("express/index.ts"), | ||
| ...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {} | ||
| "src/app.ts": (await readTemplate("express/app.ts")).replace(/\/\* logger \*\//, projectName), | ||
| "src/index.ts": await readTemplate("express/index.ts"), | ||
| ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {} | ||
| }, | ||
@@ -171,3 +171,3 @@ compilerOptions: pm === "deno" ? void 0 : { | ||
| packageManagers: PACKAGE_MANAGER, | ||
| init: ({ packageManager: pm, testMode }) => ({ | ||
| init: async ({ packageManager: pm, testMode }) => ({ | ||
| command: getNitroInitCommand(pm), | ||
@@ -182,7 +182,7 @@ dependencies: { | ||
| files: { | ||
| "server/middleware/federation.ts": readTemplate("nitro/server/middleware/federation.ts"), | ||
| "server/error.ts": readTemplate("nitro/server/error.ts"), | ||
| "nitro.config.ts": readTemplate("nitro/nitro.config.ts"), | ||
| ...testMode ? { ".env": readTemplate("nitro/.env.test") } : {}, | ||
| ...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {} | ||
| "server/middleware/federation.ts": await readTemplate("nitro/server/middleware/federation.ts"), | ||
| "server/error.ts": await readTemplate("nitro/server/error.ts"), | ||
| "nitro.config.ts": await readTemplate("nitro/nitro.config.ts"), | ||
| ...testMode ? { ".env": await readTemplate("nitro/.env.test") } : {}, | ||
| ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {} | ||
| }, | ||
@@ -197,3 +197,3 @@ tasks: { ...pm !== "deno" ? { "lint": "eslint ." } : {} }, | ||
| packageManagers: PACKAGE_MANAGER, | ||
| init: ({ packageManager: pm }) => ({ | ||
| init: async ({ packageManager: pm }) => ({ | ||
| label: "Next.js", | ||
@@ -212,4 +212,4 @@ command: getNextInitCommand(pm), | ||
| files: { | ||
| "middleware.ts": readTemplate("next/middleware.ts"), | ||
| ...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {} | ||
| "middleware.ts": await readTemplate("next/middleware.ts"), | ||
| ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {} | ||
| }, | ||
@@ -216,0 +216,0 @@ tasks: { ...pm !== "deno" ? { "lint": "eslint ." } : {} }, |
+1
-1
| { | ||
| "name": "@fedify/init", | ||
| "version": "2.0.6-dev.559+50ac1c17", | ||
| "version": "2.0.6-dev.561+ae0a7bc0", | ||
| "description": "Project initializer for Fedify", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
104758
0.42%2516
0.28%3
50%