@agjs/tsforge 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/package.json +8 -2
  2. package/src/detect-gate.ts +40 -6
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agjs/tsforge",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "license": "MIT",
6
6
  "description": "TypeScript coding harness with a deterministic gate, stack-aware guardrails, and stream-level correction.",
7
7
  "repository": {
@@ -30,6 +30,12 @@
30
30
  "test": "bun test"
31
31
  },
32
32
  "dependencies": {
33
- "cli-highlight": "2.1.11"
33
+ "@stylistic/eslint-plugin": "^5.10.0",
34
+ "@typescript-eslint/utils": "8.60.0",
35
+ "cli-highlight": "2.1.11",
36
+ "eslint": "10.4.0",
37
+ "prettier": "3.8.3",
38
+ "typescript": "6.0.3",
39
+ "typescript-eslint": "8.60.0"
34
40
  }
35
41
  }
@@ -1,4 +1,5 @@
1
- import { join } from "node:path";
1
+ import { join, dirname } from "node:path";
2
+ import { existsSync } from "node:fs";
2
3
  import { ESLint } from "eslint";
3
4
  import { WEB_TEMPLATES, type WebFramework } from "./web-templates";
4
5
 
@@ -23,11 +24,44 @@ export interface IGate {
23
24
  }
24
25
 
25
26
  // tsforge's own toolchain, resolved from this module's location so it's found
26
- // wherever the harness lives.
27
- const ROOT = join(import.meta.dir, "..", "..", "..");
28
- const ESLINT_BIN = join(ROOT, "node_modules", ".bin", "eslint");
29
- const TSC_BIN = join(ROOT, "node_modules", ".bin", "tsc");
30
- const PRETTIER_BIN = join(ROOT, "node_modules", ".bin", "prettier");
27
+ // wherever the harness lives. We walk UP from this file to the nearest
28
+ // `node_modules/.bin` that actually has the tool, which is correct in BOTH
29
+ // layouts tsforge ships in: the monorepo (deps hoisted to <repo>/node_modules)
30
+ // AND a published install, where the deps are hoisted into the install's
31
+ // node_modules and an ANCESTOR dir is itself `node_modules`. The old
32
+ // `../../../node_modules/.bin` hard-coding only matched the monorepo; once
33
+ // published it pointed at `.../node_modules/node_modules/.bin` and the CLI
34
+ // crashed on startup the moment it touched the toolchain.
35
+ function resolveToolBin(name: string): string {
36
+ let dir = import.meta.dir;
37
+ let parent = dirname(dir);
38
+
39
+ while (parent !== dir) {
40
+ const hoisted = join(dir, "node_modules", ".bin", name);
41
+
42
+ if (existsSync(hoisted)) {
43
+ return hoisted;
44
+ }
45
+
46
+ // When `dir` is itself a `node_modules` (the published/global-install case),
47
+ // the .bin sits directly inside it.
48
+ const direct = join(dir, ".bin", name);
49
+
50
+ if (existsSync(direct)) {
51
+ return direct;
52
+ }
53
+
54
+ dir = parent;
55
+ parent = dirname(dir);
56
+ }
57
+
58
+ // Last resort: let the shell resolve it from PATH rather than a wrong abspath.
59
+ return name;
60
+ }
61
+
62
+ const ESLINT_BIN = resolveToolBin("eslint");
63
+ const TSC_BIN = resolveToolBin("tsc");
64
+ const PRETTIER_BIN = resolveToolBin("prettier");
31
65
  const STRICT_CONFIG = join(import.meta.dir, "..", "strict.eslint.config.mjs");
32
66
  const BROWSER_CHECK = join(
33
67
  import.meta.dir,