tsx-strict 0.3.3 → 0.4.0-canary

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.
package/dist/cli.js CHANGED
@@ -1,18 +1,23 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
3
6
  Object.defineProperty(exports, "__esModule", { value: true });
4
7
  const commander_1 = require("commander");
5
8
  const index_1 = require("./index");
6
9
  require("./index");
7
10
  const fs_1 = require("fs");
8
- const packageJson = JSON.parse((0, fs_1.readFileSync)("./package.json", "utf8"));
11
+ const path_1 = __importDefault(require("path"));
12
+ const packageJson = JSON.parse((0, fs_1.readFileSync)(path_1.default.resolve(__dirname, "../package.json"), "utf8"));
9
13
  const program = new commander_1.Command();
10
14
  function collect(value, previous) {
11
15
  return previous.concat([value]);
12
16
  }
13
17
  program
14
18
  .name("tsx-strict")
15
- .description("Run TSX with automatic Type-checking")
19
+ .name("tsxs")
20
+ .description("The TSX with automatic Type-checking")
16
21
  .version(packageJson.version)
17
22
  .argument("<file>", "TypeScript file to run")
18
23
  .option("-w, --watch", "Enable watch mode", false)
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AACA,yCAAoC;AACpC,mCAAuC;AACvC,mBAAiB;AACjB,2BAAkC;AAElC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,CAAC;AACvE,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,SAAS,OAAO,CAAC,KAAU,EAAE,QAAa;IACxC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAClC,CAAC;AAED,OAAO;KACJ,IAAI,CAAC,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,EAAE,MAAM,GAAG,IAAI,EAC1B,QAAQ,GAAE,WAAW,CAAC,SAAS,CAAmB,GACjD,MAAM,CAkBR"}
1
+ {"version":3,"file":"compiler-provider.d.ts","sourceRoot":"","sources":["../src/compiler-provider.ts"],"names":[],"mappings":"AAsBA,wBAAgB,eAAe,CAC7B,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,QAAQ,GAAE,WAAW,CAAC,SAAS,CAAmB,GACjD,MAAM,CA8DR"}
@@ -1,24 +1,84 @@
1
1
  "use strict";
2
+ // export function getCompilerPath(
3
+ // compilerArg: string | null,
4
+ // resolver: NodeRequire["resolve"] = require.resolve
5
+ // ): string {
6
+ // if (!compilerArg) compilerArg = "typescript/bin/tsc";
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
8
  exports.getCompilerPath = getCompilerPath;
9
+ // try {
10
+ // return resolver(compilerArg, { paths: [process.cwd()] });
11
+ // } catch (e) {
12
+ // // Local compiler not found, ignore and try global compiler
13
+ // }
14
+ // try {
15
+ // return resolver(compilerArg);
16
+ // } catch (e: any) {
17
+ // if (e.code === "MODULE_NOT_FOUND") {
18
+ // console.error(e.message);
19
+ // process.exit(9);
20
+ // }
21
+ // throw e;
22
+ // }
23
+ // }
4
24
  function getCompilerPath(compilerArg, resolver = require.resolve) {
5
25
  if (!compilerArg)
6
26
  compilerArg = "typescript/bin/tsc";
27
+ // 1. Try local node_modules in current directory
7
28
  try {
8
29
  return resolver(compilerArg, { paths: [process.cwd()] });
9
30
  }
10
31
  catch (e) {
11
- // Local compiler not found, ignore and try global compiler
32
+ // Continue to next attempt
12
33
  }
34
+ // 2. Try parent directories (walk up the tree)
35
+ let currentDir = process.cwd();
36
+ const root = require("path").parse(currentDir).root;
37
+ while (currentDir !== root) {
38
+ try {
39
+ return resolver(compilerArg, { paths: [currentDir] });
40
+ }
41
+ catch (e) {
42
+ // Continue to parent
43
+ }
44
+ currentDir = require("path").dirname(currentDir);
45
+ }
46
+ // 3. Try global node_modules
13
47
  try {
14
48
  return resolver(compilerArg);
15
49
  }
16
50
  catch (e) {
17
- if (e.code === "MODULE_NOT_FOUND") {
18
- console.error(e.message);
19
- process.exit(9);
51
+ // Continue to next attempt
52
+ }
53
+ // 4. Try common global installation paths
54
+ const globalPaths = [
55
+ `${process.env.HOME}/.nvm/versions/node/${process.version}/lib/node_modules`,
56
+ `${process.env.HOME}/.npm-global/lib/node_modules`,
57
+ `${process.env.HOME}/.pnpm-global`,
58
+ "/usr/local/lib/node_modules",
59
+ "/usr/lib/node_modules",
60
+ ];
61
+ for (const globalPath of globalPaths) {
62
+ try {
63
+ return resolver(compilerArg, { paths: [globalPath] });
64
+ }
65
+ catch (e) {
66
+ // Continue to next path
20
67
  }
21
- throw e;
22
68
  }
69
+ // 5. Final fallback - check if tsc is in PATH
70
+ try {
71
+ const { execSync } = require("child_process");
72
+ const tscPath = execSync("which tsc", { encoding: "utf-8" }).trim();
73
+ if (tscPath)
74
+ return tscPath;
75
+ }
76
+ catch (e) {
77
+ // Continue to error
78
+ }
79
+ // If nothing worked, throw error
80
+ console.error(`Could not find TypeScript compiler at "${compilerArg}"`);
81
+ console.error("Tried local node_modules, parent directories, and global installations");
82
+ process.exit(9);
23
83
  }
24
84
  //# sourceMappingURL=compiler-provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compiler-provider.js","sourceRoot":"","sources":["../src/compiler-provider.ts"],"names":[],"mappings":";;AAAA,0CAqBC;AArBD,SAAgB,eAAe,CAC7B,WAA0B,EAC1B,WAAmC,OAAO,CAAC,OAAO;IAElD,IAAI,CAAC,WAAW;QAAE,WAAW,GAAG,oBAAoB,CAAC;IAErD,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;IAC3D,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,2DAA2D;IAC7D,CAAC;IAED,IAAI,CAAC;QACH,OA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CAAC,0CAA0C,WAAW,GAAG,CAAC,CAAC;IACxE,OAAO,CAAC,KAAK,CACX,wEAAwE,CACzE,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsx-strict",
3
- "version": "0.3.3",
3
+ "version": "0.4.0-canary",
4
4
  "description": "TSX runner with automatic Type-checking",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",