@fedify/init 2.1.0-dev.408 → 2.1.0-dev.418

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.
@@ -5,11 +5,19 @@ import vscode_settings_default from "../json/vscode-settings.js";
5
5
  import { PACKAGES_PATH } from "./const.js";
6
6
  import { getDependencies, getDevDependencies, joinDepsReg } from "./deps.js";
7
7
  import { uniq } from "es-toolkit";
8
+ import { execFileSync } from "node:child_process";
9
+ import { getLogger } from "@logtape/logtape";
8
10
  import { realpathSync } from "node:fs";
9
11
  import { join, relative } from "node:path";
10
12
  import { concat, filter, keys, map, pick, pipe, toArray } from "@fxts/core/index.js";
11
13
 
12
14
  //#region src/action/configs.ts
15
+ const logger = getLogger([
16
+ "fedify",
17
+ "init",
18
+ "action",
19
+ "configs"
20
+ ]);
13
21
  /**
14
22
  * Loads Deno configuration object with compiler options, unstable features, and tasks.
15
23
  * Combines unstable features required by KV store and message queue with framework-specific options.
@@ -17,18 +25,73 @@ import { concat, filter, keys, map, pick, pipe, toArray } from "@fxts/core/index
17
25
  * @param param0 - Destructured initialization data containing KV, MQ, initializer, and directory
18
26
  * @returns Configuration object with path and Deno-specific settings
19
27
  */
20
- const loadDenoConfig = (data) => ({
21
- path: "deno.json",
22
- data: {
23
- ...pick(["compilerOptions", "tasks"], data.initializer),
24
- unstable: getUnstable(data),
25
- nodeModulesDir: "auto",
26
- imports: joinDepsReg("deno")(getDependencies(data)),
27
- lint: { plugins: ["jsr:@fedify/lint"] },
28
- ...data.testMode ? { links: getLinks(data) } : {}
28
+ const loadDenoConfig = (data) => {
29
+ const unstable = getUnstable(data);
30
+ return {
31
+ path: "deno.json",
32
+ data: {
33
+ ...pick(["compilerOptions", "tasks"], data.initializer),
34
+ ...unstable.length > 0 ? { unstable } : {},
35
+ nodeModulesDir: "auto",
36
+ imports: joinDepsReg("deno")(getDependencies(data)),
37
+ lint: { plugins: ["jsr:@fedify/lint"] },
38
+ ...data.testMode ? { links: getLinks(data) } : {}
39
+ }
40
+ };
41
+ };
42
+ const getUnstable = ({ kv: { denoUnstable: kv = [] }, mq: { denoUnstable: mq = [] } }) => pipe(needsUnstableTemporal() ? ["temporal"] : [], concat(kv), concat(mq), toArray, uniq);
43
+ const TEMPORAL_STABLE_FROM = [
44
+ 2,
45
+ 7,
46
+ 0
47
+ ];
48
+ const needsUnstableTemporal = () => {
49
+ const version = getInstalledDenoVersion();
50
+ if (version == null) return true;
51
+ return compareVersions(version, TEMPORAL_STABLE_FROM) < 0;
52
+ };
53
+ const getInstalledDenoVersion = () => {
54
+ const deno = getDenoVersionFromRuntime();
55
+ if (deno != null) return deno;
56
+ try {
57
+ const output = execFileSync("deno", ["--version"], {
58
+ encoding: "utf8",
59
+ stdio: [
60
+ "ignore",
61
+ "pipe",
62
+ "ignore"
63
+ ]
64
+ });
65
+ const version = output.match(/^deno\s+(\d+)\.(\d+)\.(\d+)/m);
66
+ if (version == null) return null;
67
+ return [
68
+ Number(version[1]),
69
+ Number(version[2]),
70
+ Number(version[3])
71
+ ];
72
+ } catch (error) {
73
+ logger.debug("Failed to get Deno version by executing `deno --version`: {error}", { error });
74
+ return null;
29
75
  }
30
- });
31
- const getUnstable = ({ kv: { denoUnstable: kv = [] }, mq: { denoUnstable: mq = [] } }) => pipe(["temporal"], concat(kv), concat(mq), toArray, uniq);
76
+ };
77
+ const getDenoVersionFromRuntime = () => {
78
+ const deno = globalThis.Deno?.version?.deno;
79
+ if (deno == null) return null;
80
+ const version = deno.match(/^(\d+)\.(\d+)\.(\d+)/);
81
+ if (version == null) return null;
82
+ return [
83
+ Number(version[1]),
84
+ Number(version[2]),
85
+ Number(version[3])
86
+ ];
87
+ };
88
+ const compareVersions = (a, b) => {
89
+ for (let i = 0; i < a.length; i++) {
90
+ if (a[i] < b[i]) return -1;
91
+ if (a[i] > b[i]) return 1;
92
+ }
93
+ return 0;
94
+ };
32
95
  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);
33
96
  /**
34
97
  * Loads TypeScript configuration object for Node.js/Bun projects.
package/dist/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region deno.json
2
2
  var name = "@fedify/init";
3
- var version = "2.1.0-dev.408+5c3c9d78";
3
+ var version = "2.1.0-dev.418+6c060f4a";
4
4
  var license = "MIT";
5
5
  var exports = "./src/mod.ts";
6
6
  var imports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/init",
3
- "version": "2.1.0-dev.408+5c3c9d78",
3
+ "version": "2.1.0-dev.418+6c060f4a",
4
4
  "description": "Project initializer for Fedify",
5
5
  "keywords": [
6
6
  "fedify",