@fedify/init 2.0.6-dev.559 → 2.0.6-pr.633.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 { PACKAGES_PATH } from "./const.js";
5
+ import { getPackagesPath } from "./const.js";
6
6
  import { getDependencies, getDevDependencies, joinDepsReg } from "./deps.js";
7
7
  import { uniq } from "es-toolkit";
8
8
  import { realpathSync } from "node:fs";
@@ -29,7 +29,7 @@ const loadDenoConfig = (data) => ({
29
29
  }
30
30
  });
31
31
  const getUnstable = ({ kv: { denoUnstable: kv = [] }, mq: { denoUnstable: mq = [] } }) => pipe(["temporal"], concat(kv), concat(mq), toArray, uniq);
32
- 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);
32
+ 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);
33
33
  /**
34
34
  * Loads TypeScript configuration object for Node.js/Bun projects.
35
35
  * Uses compiler options from the framework initializer.
@@ -1,7 +1,7 @@
1
1
  import { join } from "node:path";
2
2
 
3
3
  //#region src/action/const.ts
4
- const PACKAGES_PATH = join(import.meta.dirname, "..", "..", "..");
4
+ const getPackagesPath = () => join(import.meta.dirname, "..", "..", "..");
5
5
 
6
6
  //#endregion
7
- export { PACKAGES_PATH };
7
+ export { getPackagesPath };
@@ -1,6 +1,6 @@
1
1
  import { merge, replace } from "../utils.js";
2
2
  import { PACKAGE_VERSION } from "../lib.js";
3
- import { PACKAGES_PATH } from "./const.js";
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(PACKAGES_PATH, pkg));
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.
@@ -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/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region deno.json
2
2
  var name = "@fedify/init";
3
- var version = "2.0.6-dev.559+50ac1c17";
3
+ var version = "2.0.6-pr.633.9+12093e72";
4
4
  var license = "MIT";
5
5
  var exports = "./src/mod.ts";
6
6
  var imports = {
package/dist/lib.js CHANGED
@@ -38,7 +38,14 @@ async function isPackageManagerAvailable(pm) {
38
38
  })) return true;
39
39
  return false;
40
40
  }
41
- const readTemplate = (templatePath) => readFileSync(join$1(import.meta.dirname, "templates", ...(templatePath + ".tpl").split("/")), "utf8");
41
+ const readTemplate = async (templatePath) => {
42
+ const segments = (templatePath + ".tpl").split("/");
43
+ if (import.meta.dirname) return readFileSync(join$1(import.meta.dirname, "templates", ...segments), "utf8");
44
+ const url = new URL(["templates", ...segments].join("/"), import.meta.url);
45
+ const resp = await fetch(url);
46
+ if (!resp.ok) throw new Error(`Failed to fetch template: ${url}`);
47
+ return resp.text();
48
+ };
42
49
  const getInstruction = (pm, port) => message`
43
50
  To start the server, run the following command:
44
51
 
@@ -8,7 +8,7 @@ const webFrameworks = {
8
8
  hono: {
9
9
  label: "Hono",
10
10
  packageManagers: PACKAGE_MANAGER,
11
- init: ({ projectName, packageManager: pm }) => ({
11
+ init: async ({ projectName, packageManager: pm }) => ({
12
12
  dependencies: pm === "deno" ? {
13
13
  ...defaultDenoDependencies,
14
14
  "@std/dotenv": "^0.225.2",
@@ -34,9 +34,9 @@ const webFrameworks = {
34
34
  federationFile: "src/federation.ts",
35
35
  loggingFile: "src/logging.ts",
36
36
  files: {
37
- "src/app.tsx": pipe("hono/app.tsx", readTemplate, replace(/\/\* hono \*\//, pm === "deno" ? "@hono/hono" : "hono"), replace(/\/\* logger \*\//, projectName)),
38
- "src/index.ts": readTemplate(`hono/index/${packageManagerToRuntime(pm)}.ts`),
39
- ...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
37
+ "src/app.tsx": pipe(await readTemplate("hono/app.tsx"), replace(/\/\* hono \*\//, pm === "deno" ? "@hono/hono" : "hono"), replace(/\/\* logger \*\//, projectName)),
38
+ "src/index.ts": await readTemplate(`hono/index/${packageManagerToRuntime(pm)}.ts`),
39
+ ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
40
40
  },
41
41
  compilerOptions: pm === "deno" ? void 0 : {
42
42
  "lib": ["ESNext", "DOM"],
@@ -62,7 +62,7 @@ const webFrameworks = {
62
62
  elysia: {
63
63
  label: "ElysiaJS",
64
64
  packageManagers: PACKAGE_MANAGER,
65
- init: ({ projectName, packageManager: pm }) => ({
65
+ init: async ({ projectName, packageManager: pm }) => ({
66
66
  dependencies: pm === "deno" ? {
67
67
  ...defaultDenoDependencies,
68
68
  elysia: "npm:elysia@^1.3.6",
@@ -90,8 +90,8 @@ const webFrameworks = {
90
90
  federationFile: "src/federation.ts",
91
91
  loggingFile: "src/logging.ts",
92
92
  files: {
93
- "src/index.ts": readTemplate(`elysia/index/${packageManagerToRuntime(pm)}.ts`).replace(/\/\* logger \*\//, projectName),
94
- ...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
93
+ "src/index.ts": (await readTemplate(`elysia/index/${packageManagerToRuntime(pm)}.ts`)).replace(/\/\* logger \*\//, projectName),
94
+ ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
95
95
  },
96
96
  compilerOptions: pm === "deno" || pm === "bun" ? void 0 : {
97
97
  "lib": ["ESNext", "DOM"],
@@ -118,7 +118,7 @@ const webFrameworks = {
118
118
  express: {
119
119
  label: "Express",
120
120
  packageManagers: PACKAGE_MANAGER,
121
- init: ({ projectName, packageManager: pm }) => ({
121
+ init: async ({ projectName, packageManager: pm }) => ({
122
122
  dependencies: {
123
123
  "npm:express": "^4.19.2",
124
124
  "@fedify/express": PACKAGE_VERSION,
@@ -136,9 +136,9 @@ const webFrameworks = {
136
136
  federationFile: "src/federation.ts",
137
137
  loggingFile: "src/logging.ts",
138
138
  files: {
139
- "src/app.ts": readTemplate("express/app.ts").replace(/\/\* logger \*\//, projectName),
140
- "src/index.ts": readTemplate("express/index.ts"),
141
- ...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
139
+ "src/app.ts": (await readTemplate("express/app.ts")).replace(/\/\* logger \*\//, projectName),
140
+ "src/index.ts": await readTemplate("express/index.ts"),
141
+ ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
142
142
  },
143
143
  compilerOptions: pm === "deno" ? void 0 : {
144
144
  "lib": ["ESNext", "DOM"],
@@ -162,7 +162,7 @@ const webFrameworks = {
162
162
  nitro: {
163
163
  label: "Nitro",
164
164
  packageManagers: PACKAGE_MANAGER,
165
- init: ({ packageManager: pm, testMode }) => ({
165
+ init: async ({ packageManager: pm, testMode }) => ({
166
166
  command: getNitroInitCommand(pm),
167
167
  dependencies: {
168
168
  "@fedify/h3": PACKAGE_VERSION,
@@ -172,11 +172,11 @@ const webFrameworks = {
172
172
  federationFile: "server/federation.ts",
173
173
  loggingFile: "server/logging.ts",
174
174
  files: {
175
- "server/middleware/federation.ts": readTemplate("nitro/server/middleware/federation.ts"),
176
- "server/error.ts": readTemplate("nitro/server/error.ts"),
177
- "nitro.config.ts": readTemplate("nitro/nitro.config.ts"),
178
- ...testMode ? { ".env": readTemplate("nitro/.env.test") } : {},
179
- ...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
175
+ "server/middleware/federation.ts": await readTemplate("nitro/server/middleware/federation.ts"),
176
+ "server/error.ts": await readTemplate("nitro/server/error.ts"),
177
+ "nitro.config.ts": await readTemplate("nitro/nitro.config.ts"),
178
+ ...testMode ? { ".env": await readTemplate("nitro/.env.test") } : {},
179
+ ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
180
180
  },
181
181
  tasks: { ...pm !== "deno" ? { "lint": "eslint ." } : {} },
182
182
  instruction: getInstruction(pm, 3e3)
@@ -186,7 +186,7 @@ const webFrameworks = {
186
186
  next: {
187
187
  label: "Next.js",
188
188
  packageManagers: PACKAGE_MANAGER,
189
- init: ({ packageManager: pm }) => ({
189
+ init: async ({ packageManager: pm }) => ({
190
190
  label: "Next.js",
191
191
  command: getNextInitCommand(pm),
192
192
  dependencies: {
@@ -200,8 +200,8 @@ const webFrameworks = {
200
200
  federationFile: "federation/index.ts",
201
201
  loggingFile: "logging.ts",
202
202
  files: {
203
- "middleware.ts": readTemplate("next/middleware.ts"),
204
- ...pm !== "deno" ? { "eslint.config.ts": readTemplate("defaults/eslint.config.ts") } : {}
203
+ "middleware.ts": await readTemplate("next/middleware.ts"),
204
+ ...pm !== "deno" ? { "eslint.config.ts": await readTemplate("defaults/eslint.config.ts") } : {}
205
205
  },
206
206
  tasks: { ...pm !== "deno" ? { "lint": "eslint ." } : {} },
207
207
  instruction: getInstruction(pm, 3e3)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/init",
3
- "version": "2.0.6-dev.559+50ac1c17",
3
+ "version": "2.0.6-pr.633.9+12093e72",
4
4
  "description": "Project initializer for Fedify",
5
5
  "keywords": [
6
6
  "fedify",