@fedify/init 2.4.0-dev.1666 → 2.4.0-dev.1668

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.
@@ -66,7 +66,10 @@ const getDenoVersionFromCommand = () => {
66
66
  const getDenoVersionFromRuntime = () => pipe(globalThis, prop("Deno"), prop("version"), prop("deno"));
67
67
  const parseVersion = (deno) => pipe(deno.match(/^(\d+)\.(\d+)\.(\d+)/), unless(isNull, ([, ...segments]) => segments.map(Number)));
68
68
  const isLaterOrEqualThan = (basis) => (target) => pipe(zip(basis, target), filter(([b, t]) => t !== b), head, (a) => a ? a[0] < a[1] : true);
69
- 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);
69
+ const getLinks = ({ kv, mq, initializer, dir }) => pipe({
70
+ "@fedify/fedify": "",
71
+ "@fedify/vocab": ""
72
+ }, 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);
70
73
  /**
71
74
  * Loads TypeScript configuration object for Node.js/Bun projects.
72
75
  * Uses compiler options from the framework initializer.
@@ -14,7 +14,7 @@ import { join as join$1 } from "node:path";
14
14
  * message queue descriptions
15
15
  * @returns A record of dependencies with their versions
16
16
  */
17
- const getDependencies = ({ initializer, kv, mq, env, testMode, packageManager }) => pipe({
17
+ const getDependencies = ({ initializer, kv, mq, env, testMode, packageManager, webFramework }) => pipe({
18
18
  "@fedify/fedify": PACKAGE_VERSION,
19
19
  "@fedify/vocab": PACKAGE_VERSION,
20
20
  "@logtape/logtape": _logtape_logtape,
@@ -22,7 +22,8 @@ const getDependencies = ({ initializer, kv, mq, env, testMode, packageManager })
22
22
  packageManager,
23
23
  env
24
24
  }) && { "@std/dotenv": _std_dotenv }
25
- }, merge(initializer.dependencies), merge(kv.dependencies), merge(mq.dependencies), when(always(testMode), isDeno({ packageManager }) ? removeFedifyDeps : addLocalFedifyDeps), normalizePackageNames(packageManager));
25
+ }, merge(initializer.dependencies), merge(kv.dependencies), merge(mq.dependencies), when(always(packageManager === "deno" && webFramework === "astro"), useNpmForFedifyPackages), when(always(testMode), isDeno({ packageManager }) ? removeFedifyDeps : addLocalFedifyDeps), normalizePackageNames(packageManager));
26
+ const useNpmForFedifyPackages = (deps) => pipe(deps, entries, map(([name, version]) => name.startsWith("@fedify/") && name !== "@fedify/lint" && !version.startsWith("npm:") ? [name, `npm:${name}@${version}`] : [name, version]), fromEntries);
26
27
  const removeFedifyDeps = (deps) => pipe(deps, entries, filter(([name]) => !name.includes("@fedify")), fromEntries);
27
28
  const addLocalFedifyDeps = (deps) => pipe(deps, entries, map(when(([name]) => name.includes("@fedify/"), ([name, _version]) => [name, convertFedifyToLocal(name)])), fromEntries);
28
29
  const convertFedifyToLocal = (name) => pipe(name, replace("@fedify/", ""), (pkg) => join$1(getPackagesPath(), pkg));
@@ -1,4 +1,5 @@
1
1
  import $ from "@david/dax";
2
+ import { readFile, writeFile } from "node:fs/promises";
2
3
  import { join } from "node:path";
3
4
  //#region src/action/utils.ts
4
5
  /** Returns `true` if the current run is in dry-run mode. */
@@ -60,7 +61,21 @@ function stringifyEnvs(object) {
60
61
  * Runs `<packageManager> install` in the project directory to install all
61
62
  * dependencies. Logs an error message if the installation fails.
62
63
  */
63
- const installDependencies = ({ packageManager, dir }) => $`${packageManager} install`.cwd(dir).spawn();
64
+ const installDependencies = async (data) => {
65
+ const { packageManager, dir, testMode } = data;
66
+ if (packageManager !== "deno" || !testMode) return await $`${packageManager} install`.cwd(dir).spawn();
67
+ const configPath = join(dir, "deno.json");
68
+ const config = JSON.parse(await readFile(configPath, "utf8"));
69
+ const links = config.links;
70
+ delete config.links;
71
+ await writeFile(configPath, JSON.stringify(config, null, 2) + "\n");
72
+ try {
73
+ return await $`${packageManager} install`.cwd(dir).spawn();
74
+ } finally {
75
+ config.links = links;
76
+ await writeFile(configPath, JSON.stringify(config, null, 2) + "\n");
77
+ }
78
+ };
64
79
  /**
65
80
  * Runs the precommand specified in the initializer to set up the project.
66
81
  *
package/dist/deno.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region deno.json
2
- var version = "2.4.0-dev.1666+690d9b28";
2
+ var version = "2.4.0-dev.1668+90797b01";
3
3
  //#endregion
4
4
  export { version };
package/dist/json/deps.js CHANGED
@@ -3,12 +3,11 @@ var _hongminhee_x_forwarded_fetch = "^0.2.0";
3
3
  var _hono_hono = "^4.12.27";
4
4
  var _logtape_logtape = "^2.2.1";
5
5
  var _std_dotenv = "^0.225.7";
6
- var npm__astrojs_node = "^10.0.4";
7
- var npm__deno_astro_adapter = "^0.5.2";
6
+ var npm__astrojs_node = "^11.0.2";
7
+ var npm__deno_astro_adapter = "^0.6.0";
8
8
  var npm__dotenvx_dotenvx = "^1.75.1";
9
9
  var npm__elysiajs_node = "^1.4.5";
10
10
  var npm__hono_node_server = "^1.19.12";
11
- var npm__nurodev_astro_bun = "^2.1.2";
12
11
  var npm__sinclair_typebox = "^0.34.49";
13
12
  var npm__solidjs_router = "^0.16.1";
14
13
  var npm__solidjs_start = "^1.3.2";
@@ -17,6 +16,8 @@ var npm__types_express = "^4.17.21";
17
16
  var npm__types_node_20 = "^20.11.2";
18
17
  var npm__types_node_22 = "^22.17.0";
19
18
  var npm__types_node_25 = "^25.5.0";
19
+ var npm_astro = "^7.0.7";
20
+ var npm_create_astro = "^5.2.2";
20
21
  var npm_elysia = "^1.4.29";
21
22
  var npm_express = "^5.2.1";
22
23
  var npm_hono = "^4.12.27";
@@ -31,4 +32,4 @@ var npm_typescript = "^5.9.3";
31
32
  var npm_vinxi = "^0.5.11";
32
33
  var npm_x_forwarded_fetch = "^0.2.0";
33
34
  //#endregion
34
- export { _hongminhee_x_forwarded_fetch, _hono_hono, _logtape_logtape, _std_dotenv, npm__astrojs_node, npm__deno_astro_adapter, npm__dotenvx_dotenvx, npm__elysiajs_node, npm__hono_node_server, npm__nurodev_astro_bun, npm__sinclair_typebox, npm__solidjs_router, npm__solidjs_start, npm__types_bun, npm__types_express, npm__types_node_20, npm__types_node_22, npm__types_node_25, npm_elysia, npm_express, npm_hono, npm_openapi_types, npm_oxfmt, npm_oxlint, npm_prettier, npm_prettier_plugin_astro, npm_solid_js, npm_tsx, npm_typescript, npm_vinxi, npm_x_forwarded_fetch };
35
+ export { _hongminhee_x_forwarded_fetch, _hono_hono, _logtape_logtape, _std_dotenv, npm__astrojs_node, npm__deno_astro_adapter, npm__dotenvx_dotenvx, npm__elysiajs_node, npm__hono_node_server, npm__sinclair_typebox, npm__solidjs_router, npm__solidjs_start, npm__types_bun, npm__types_express, npm__types_node_20, npm__types_node_22, npm__types_node_25, npm_astro, npm_create_astro, npm_elysia, npm_express, npm_hono, npm_openapi_types, npm_oxfmt, npm_oxlint, npm_prettier, npm_prettier_plugin_astro, npm_solid_js, npm_tsx, npm_typescript, npm_vinxi, npm_x_forwarded_fetch };
@@ -3,13 +3,12 @@
3
3
  "@hono/hono": "^4.12.27",
4
4
  "@logtape/logtape": "^2.2.1",
5
5
  "@std/dotenv": "^0.225.7",
6
- "npm:@astrojs/node": "^10.0.4",
7
- "npm:@deno/astro-adapter": "^0.5.2",
6
+ "npm:@astrojs/node": "^11.0.2",
7
+ "npm:@deno/astro-adapter": "^0.6.0",
8
8
  "npm:@dotenvx/dotenvx": "^1.75.1",
9
9
  "npm:@elysiajs/node": "^1.4.5",
10
10
  "npm:@hono/node-server": "^1.19.12",
11
11
  "npm:@nuxt/kit": "^4.4.8",
12
- "npm:@nurodev/astro-bun": "^2.1.2",
13
12
  "npm:@sinclair/typebox": "^0.34.49",
14
13
  "npm:@solidjs/router": "^0.16.1",
15
14
  "npm:@solidjs/start": "^1.3.2",
@@ -18,7 +17,8 @@
18
17
  "npm:@types/node@20": "^20.11.2",
19
18
  "npm:@types/node@22": "^22.17.0",
20
19
  "npm:@types/node@25": "^25.5.0",
21
- "npm:astro": "^6.1.1",
20
+ "npm:astro": "^7.0.7",
21
+ "npm:create-astro": "^5.2.2",
22
22
  "npm:elysia": "^1.4.29",
23
23
  "npm:express": "^5.2.1",
24
24
  "npm:h3": "^1.15.0",
package/dist/lib.js CHANGED
@@ -87,6 +87,20 @@ const readTemplate = async (templatePath) => {
87
87
  * package manager (e.g., `"deno task dev"`, `"bun dev"`, `"npm run dev"`).
88
88
  */
89
89
  const getDevCommand = (pm) => pm === "deno" ? "deno task dev" : pm === "bun" ? "bun dev" : `${pm} run dev`;
90
+ /** Returns the command to build for the given package manager. */
91
+ const getBuildCommand = (pm) => pm === "deno" ? [
92
+ "deno",
93
+ "task",
94
+ "build"
95
+ ] : pm === "bun" ? [
96
+ "bun",
97
+ "run",
98
+ "build"
99
+ ] : [
100
+ pm,
101
+ "run",
102
+ "build"
103
+ ];
90
104
  async function isCommandAvailable({ checkCommand, outputPattern }) {
91
105
  try {
92
106
  const { stdout } = await $`${checkCommand}`.stdout("piped").spawn();
@@ -277,4 +291,4 @@ const isDirectory = async (path) => {
277
291
  /** Returns `true` if the current run is in test mode. */
278
292
  const isTest = ({ testMode }) => testMode;
279
293
  //#endregion
280
- export { PACKAGE_VERSION, createFile, getDevCommand, getInstallUrl, isDirectoryEmpty, isPackageManagerAvailable, isTest, kvStores, logger, messageQueues, packageManagers, readTemplate, runtimes, throwUnlessNotExists };
294
+ export { PACKAGE_VERSION, createFile, getBuildCommand, getDevCommand, getInstallUrl, isDirectoryEmpty, isPackageManagerAvailable, isTest, kvStores, logger, messageQueues, packageManagers, readTemplate, runtimes, throwUnlessNotExists };
@@ -1,4 +1,4 @@
1
- import bun from "@nurodev/astro-bun";
1
+ import node from "@astrojs/node";
2
2
  import { fedifyIntegration } from "@fedify/astro";
3
3
  import { defineConfig } from "astro/config";
4
4
 
@@ -6,5 +6,5 @@ import { defineConfig } from "astro/config";
6
6
  export default defineConfig({
7
7
  integrations: [fedifyIntegration()],
8
8
  output: "server",
9
- adapter: bun(),
9
+ adapter: node({ mode: "standalone" }),
10
10
  });
@@ -1,12 +1,12 @@
1
1
  import pm_default from "../json/pm.js";
2
2
  import { printErrorMessage, printMessage, product } from "../utils.js";
3
- import { kvStores, messageQueues } from "../lib.js";
3
+ import { getBuildCommand, kvStores, messageQueues } from "../lib.js";
4
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 $ from "@david/dax";
8
- import { appendFile, mkdir, stat } from "node:fs/promises";
9
- import { join as join$1, sep } from "node:path";
8
+ import { appendFile, lstat, mkdir, readFile, stat, symlink } from "node:fs/promises";
9
+ import { dirname, join as join$1, resolve, sep } from "node:path";
10
10
  import { values } from "@optique/core";
11
11
  //#region src/test/create.ts
12
12
  const BANNED_PMS = ["bun", "yarn"];
@@ -16,7 +16,7 @@ const createTestApp = (testDirPrefix, dry) => async (options) => {
16
16
  const result = await $`${toArray(genInitCommand(testDir, dry, options))}`.cwd(join$1(import.meta.dirname, "..", "..")).stdin("null").stdout("piped").stderr("piped").noThrow().spawn();
17
17
  await saveOutputs(testDir, result);
18
18
  if (result.code === 0) {
19
- if (!dry && !await validateDevToolScripts(testDir, options)) {
19
+ if (!dry && (!await validateDevToolScripts(testDir, options) || !await validateFrameworkBuild(testDir, options))) {
20
20
  printMessage` Fail: ${vals}`;
21
21
  printMessage` Check out these files for more details: \
22
22
  ${join$1(testDir, "out.txt")} and \
@@ -74,9 +74,18 @@ const saveOutputs = async (dirPath, { stdout, stderr }) => {
74
74
  if (stderr) await appendFile(join$1(dirPath, "err.txt"), stderr + "\n", "utf8");
75
75
  };
76
76
  async function validateDevToolScripts(dir, options) {
77
- const [, packageManager] = options;
77
+ const [webFramework, packageManager] = options;
78
78
  if (packageManager === "deno") return true;
79
79
  if (!await hasInstalledNodeDependencies(dir)) return true;
80
+ if (webFramework === "astro") {
81
+ const format = await $`${[
82
+ packageManager,
83
+ "run",
84
+ "format"
85
+ ]}`.cwd(dir).stdin("null").stdout("piped").stderr("piped").noThrow().spawn();
86
+ await saveOutputs(dir, format);
87
+ if (format.code !== 0) return false;
88
+ }
80
89
  for (const script of ["format:check", "lint"]) {
81
90
  const result = await $`${[
82
91
  packageManager,
@@ -95,6 +104,27 @@ async function hasInstalledNodeDependencies(dir) {
95
104
  return false;
96
105
  }
97
106
  }
107
+ async function validateFrameworkBuild(dir, options) {
108
+ const [webFramework, packageManager] = options;
109
+ if (webFramework !== "astro") return true;
110
+ if (packageManager === "deno") await linkDenoWorkspacePackages(dir);
111
+ const result = await $`${getBuildCommand(packageManager)}`.cwd(dir).stdin("null").stdout("piped").stderr("piped").noThrow().spawn();
112
+ await saveOutputs(dir, result);
113
+ return result.code === 0;
114
+ }
115
+ async function linkDenoWorkspacePackages(dir) {
116
+ const config = JSON.parse(await readFile(join$1(dir, "deno.json"), "utf8"));
117
+ for (const link of config.links ?? []) {
118
+ const packageDir = resolve(dir, link);
119
+ const target = join$1(dir, "node_modules", ...JSON.parse(await readFile(join$1(packageDir, "package.json"), "utf8")).name.split("/"));
120
+ await mkdir(dirname(target), { recursive: true });
121
+ try {
122
+ await lstat(target);
123
+ } catch {
124
+ await symlink(packageDir, target, "junction");
125
+ }
126
+ }
127
+ }
98
128
  function filterOptions(options) {
99
129
  const [wf, pm, kv, mq] = options;
100
130
  return [
@@ -1,6 +1,6 @@
1
1
  import { PACKAGE_VERSION, readTemplate } from "../lib.js";
2
2
  import { PACKAGE_MANAGER } from "../const.js";
3
- import { npm__astrojs_node, npm__deno_astro_adapter, npm__dotenvx_dotenvx, npm__nurodev_astro_bun, npm__types_node_22, npm_oxlint, npm_prettier, npm_prettier_plugin_astro, npm_typescript } from "../json/deps.js";
3
+ import { _logtape_logtape, npm__astrojs_node, npm__deno_astro_adapter, npm__dotenvx_dotenvx, npm__types_node_22, npm_astro, npm_create_astro, npm_oxlint, npm_prettier, npm_prettier_plugin_astro, npm_typescript } from "../json/deps.js";
4
4
  import { defaultDenoDependencies } from "./const.js";
5
5
  import { getInstruction, pmToRt } from "./utils.js";
6
6
  //#region src/webframeworks/astro.ts
@@ -15,6 +15,14 @@ const astroNodeBunDevToolTasks = {
15
15
  "format:check": "prettier --plugin prettier-plugin-astro --check .",
16
16
  lint: "oxlint ."
17
17
  };
18
+ const astroDenoCommand = `deno run -A npm:astro@${npm_astro}`;
19
+ const ASTRO_NODE_VERSION_CHECK = `
20
+ const [major, minor] = process.versions.node.split(".").map(Number);
21
+ if (major < 22 || (major === 22 && minor < 12)) {
22
+ console.error("Astro 7 requires Node.js 22.12 or later.");
23
+ process.exit(1);
24
+ }
25
+ `.trim();
18
26
  const astroDescription = {
19
27
  label: "Astro",
20
28
  packageManagers: PACKAGE_MANAGER,
@@ -22,15 +30,21 @@ const astroDescription = {
22
30
  init: async ({ packageManager: pm }) => {
23
31
  const dependencies = pm === "deno" ? {
24
32
  ...defaultDenoDependencies,
33
+ "@fedify/fedify": `npm:@fedify/fedify@${PACKAGE_VERSION}`,
34
+ "@fedify/vocab": `npm:@fedify/vocab@${PACKAGE_VERSION}`,
35
+ "@logtape/logtape": `npm:@logtape/logtape@${_logtape_logtape}`,
36
+ astro: `npm:astro@${npm_astro}`,
25
37
  "@deno/astro-adapter": `npm:@deno/astro-adapter@${npm__deno_astro_adapter}`,
26
- "@fedify/astro": PACKAGE_VERSION
38
+ "@fedify/astro": `npm:@fedify/astro@${PACKAGE_VERSION}`
27
39
  } : pm === "bun" ? {
40
+ "@astrojs/node": npm__astrojs_node,
28
41
  "@fedify/astro": PACKAGE_VERSION,
29
- "@nurodev/astro-bun": npm__nurodev_astro_bun
42
+ astro: npm_astro
30
43
  } : {
31
44
  "@astrojs/node": npm__astrojs_node,
32
45
  "@fedify/astro": PACKAGE_VERSION,
33
- "@dotenvx/dotenvx": npm__dotenvx_dotenvx
46
+ "@dotenvx/dotenvx": npm__dotenvx_dotenvx,
47
+ astro: npm_astro
34
48
  };
35
49
  return {
36
50
  command: Array.from(getAstroInitCommand(pm)),
@@ -61,13 +75,21 @@ const astroDescription = {
61
75
  * by a template.
62
76
  */
63
77
  function* getAstroInitCommand(pm) {
78
+ if (pm !== "deno" && pm !== "bun") {
79
+ yield "node";
80
+ yield "-e";
81
+ yield ASTRO_NODE_VERSION_CHECK;
82
+ yield "&&";
83
+ }
64
84
  yield* createAstroAppCommand(pm);
65
- yield "astro@latest";
85
+ yield `astro@${npm_create_astro}`;
66
86
  yield ".";
67
87
  yield "--";
68
88
  yield "--no-git";
69
89
  yield "--skip-houston";
70
90
  yield "-y";
91
+ yield "--ref";
92
+ yield `astro@${npm_astro.replace(/^\D+/, "")}`;
71
93
  if (pm !== "deno") yield "--no-install";
72
94
  yield "&&";
73
95
  yield "rm";
@@ -82,9 +104,9 @@ const createAstroAppCommand = (pm) => pm === "deno" ? [
82
104
  ] : [pm, "create"];
83
105
  const TASKS = {
84
106
  "deno": {
85
- dev: "deno run -A npm:astro dev",
86
- build: "deno run -A npm:astro build",
87
- preview: "deno run -A npm:astro preview"
107
+ dev: `${astroDenoCommand} dev`,
108
+ build: `${astroDenoCommand} build`,
109
+ preview: `${astroDenoCommand} preview`
88
110
  },
89
111
  "bun": {
90
112
  dev: "bunx --bun astro dev",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/init",
3
- "version": "2.4.0-dev.1666+690d9b28",
3
+ "version": "2.4.0-dev.1668+90797b01",
4
4
  "description": "Project initializer for Fedify",
5
5
  "keywords": [
6
6
  "fedify",