tsx-strict 0.4.2 → 0.6.0
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/README.md +35 -0
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +7 -0
- package/dist/config.js.map +1 -0
- package/dist/file-watcher.d.ts +2 -1
- package/dist/file-watcher.d.ts.map +1 -1
- package/dist/file-watcher.js +10 -4
- package/dist/file-watcher.js.map +1 -1
- package/dist/index.d.ts +13 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -99
- package/dist/index.js.map +1 -1
- package/dist/utils/config-loader.d.ts +3 -0
- package/dist/utils/config-loader.d.ts.map +1 -0
- package/dist/utils/config-loader.js +60 -0
- package/dist/utils/config-loader.js.map +1 -0
- package/package.json +9 -2
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ Run TypeScript files with TSX while providing real-time type checking.
|
|
|
9
9
|
- Intelligent process management
|
|
10
10
|
- Customizable compiler support
|
|
11
11
|
- Memory management options
|
|
12
|
+
- Config file support (`tsx-strict.config.ts` / `tsxs.config.ts`)
|
|
12
13
|
|
|
13
14
|
## Installation
|
|
14
15
|
|
|
@@ -52,6 +53,40 @@ tsxs --no-type-check app.ts
|
|
|
52
53
|
| `--silent` | Suppress output | `false` |
|
|
53
54
|
| `--no-type-check` | Skip type checking (run tsx directly) | `false` |
|
|
54
55
|
|
|
56
|
+
## Config File
|
|
57
|
+
|
|
58
|
+
Create a `tsx-strict.config.ts` or `tsxs.config.ts` at your project root for persistent configuration. CLI args always take precedence over the config file.
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { defineConfig } from "tsx-strict/config";
|
|
62
|
+
|
|
63
|
+
export default defineConfig({
|
|
64
|
+
watch: true,
|
|
65
|
+
clear: true,
|
|
66
|
+
typeCheck: true,
|
|
67
|
+
compiler: "typescript/bin/tsc",
|
|
68
|
+
tscArgs: ["--strict"],
|
|
69
|
+
tsxArgs: ["--env-file=.env"],
|
|
70
|
+
maxNodeMem: "4096",
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Watch Options
|
|
75
|
+
|
|
76
|
+
`watch` can be `true` to use defaults, or an object for full control:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { defineConfig } from "tsx-strict/config";
|
|
80
|
+
|
|
81
|
+
export default defineConfig({
|
|
82
|
+
watch: {
|
|
83
|
+
include: ["src/**"],
|
|
84
|
+
ignore: ["**/*.test.ts", /generated/, (path) => path.includes("dist")],
|
|
85
|
+
extensions: ["ts", "tsx", "js"],
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
55
90
|
## How It Works
|
|
56
91
|
|
|
57
92
|
Runs `tsc --noEmit` for type checking and `tsx` for execution. Restarts tsx only when type checking passes and kills previous instances to prevent conflicts.
|
package/dist/cli.js
CHANGED
|
@@ -27,7 +27,8 @@ program
|
|
|
27
27
|
.option("-p, --path <path>", "tsconfig.json path", "tsconfig.json")
|
|
28
28
|
.option("--tsc-args <args...>", "Additional tsc arguments")
|
|
29
29
|
.option("--tsx-args <args...>", "Additional tsx arguments")
|
|
30
|
-
.option("--no-type-check", "Skip type checking (run tsx directly)", true)
|
|
30
|
+
.option("-n, --no-type-check", "Skip type checking (run tsx directly)", true)
|
|
31
|
+
.option("--maxNodeMem <maxNodeMem>", "Sets up max node memory", "4096")
|
|
31
32
|
.action(async (file, options) => {
|
|
32
33
|
try {
|
|
33
34
|
await (0, index_1.runTsxStrict)(file, options);
|
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;AAClC,gDAAwB;AAExB,MAAM,WAAW,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,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ProgramOptions } from ".";
|
|
2
|
+
export type WatchOptions = {
|
|
3
|
+
include?: string[];
|
|
4
|
+
ignore?: (string | RegExp | ((path: string) => boolean))[];
|
|
5
|
+
extensions?: string[];
|
|
6
|
+
};
|
|
7
|
+
export type TsxStrictConfig = ProgramOptions & {
|
|
8
|
+
watch?: boolean | WatchOptions;
|
|
9
|
+
};
|
|
10
|
+
export declare function defineConfig(config: TsxStrictConfig): TsxStrictConfig;
|
|
11
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,CAAC;AAEnC,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC;IAC3D,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG;IAC7C,KAAK,CAAC,EAAE,OAAO,GAAG,YAAY,CAAC;CAChC,CAAC;AAEF,wBAAgB,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAErE"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;AAYA,oCAEC;AAFD,SAAgB,YAAY,CAAC,MAAuB;IAClD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/file-watcher.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { TsxStrictConfig } from "./config";
|
|
2
|
+
export declare function setupFileWatcher(restartTsx: () => void, config?: Partial<TsxStrictConfig>): void;
|
|
2
3
|
export declare function stopFileWatcher(): void;
|
|
3
4
|
//# sourceMappingURL=file-watcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-watcher.d.ts","sourceRoot":"","sources":["../src/file-watcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-watcher.d.ts","sourceRoot":"","sources":["../src/file-watcher.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAgB,MAAM,UAAU,CAAC;AAIzD,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,IAAI,EACtB,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,QA+DtC;AAED,wBAAgB,eAAe,SAK9B"}
|
package/dist/file-watcher.js
CHANGED
|
@@ -9,13 +9,16 @@ const chokidar_1 = __importDefault(require("chokidar"));
|
|
|
9
9
|
const sheu_1 = __importDefault(require("./sheu"));
|
|
10
10
|
const _1 = require(".");
|
|
11
11
|
let fileWatcher = null;
|
|
12
|
-
function setupFileWatcher(restartTsx) {
|
|
12
|
+
function setupFileWatcher(restartTsx, config = {}) {
|
|
13
13
|
if (fileWatcher) {
|
|
14
14
|
fileWatcher.close();
|
|
15
15
|
fileWatcher = null;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const watchOptions = typeof config.watch === "object"
|
|
18
|
+
? config.watch
|
|
19
|
+
: {};
|
|
20
|
+
fileWatcher = chokidar_1.default.watch(watchOptions.include ?? [process.cwd()], {
|
|
21
|
+
ignored: [/node_modules/, /.build/, /dist/, ...(watchOptions.ignore ?? [])],
|
|
19
22
|
ignoreInitial: true,
|
|
20
23
|
persistent: true,
|
|
21
24
|
});
|
|
@@ -23,7 +26,9 @@ function setupFileWatcher(restartTsx) {
|
|
|
23
26
|
fileWatcher.on("all", (event, path) => {
|
|
24
27
|
if (event === "ready" ||
|
|
25
28
|
isRestarting ||
|
|
26
|
-
(
|
|
29
|
+
(!(watchOptions.extensions
|
|
30
|
+
? new RegExp(`\\.(${watchOptions.extensions.join("|")})$`).test(path)
|
|
31
|
+
: /\.(ts|js|jsx|tsx|mts|cts|mjs|cjs)$/.test(path)) &&
|
|
27
32
|
!path.includes(".env")))
|
|
28
33
|
return;
|
|
29
34
|
isRestarting = true;
|
|
@@ -41,6 +46,7 @@ function setupFileWatcher(restartTsx) {
|
|
|
41
46
|
else
|
|
42
47
|
setTimeout(() => {
|
|
43
48
|
if (status.hasTsErrors) {
|
|
49
|
+
console.log("");
|
|
44
50
|
sheu_1.default.warn(`Waiting for TypeScript errors to be fixed in order to restart`, { timestamp: true });
|
|
45
51
|
}
|
|
46
52
|
else {
|
package/dist/file-watcher.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-watcher.js","sourceRoot":"","sources":["../src/file-watcher.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"file-watcher.js","sourceRoot":"","sources":["../src/file-watcher.ts"],"names":[],"mappings":";;;;;AAOA,4CAiEC;AAED,0CAKC;AA/ED,wDAA+C;AAC/C,kDAA0B;AAC1B,wBAA8B;AAG9B,IAAI,WAAW,GAAqB,IAAI,CAAC;AAEzC,SAAgB,gBAAgB,CAC9B,UAAsB,EACtB,SAAmC,EAAE;IAErC,IAAI,WAAW,EAAE,CAAC;QAChB,WAAW,CAAC,KAAK,EAAE,CAAC;QACpB,WAAW,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,MAAM,YAAY,GAChB,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ;QAC9B,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAE,EAA4B,CAAC;IAEpC,WAAW,GAAG,kBAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE;QACpE,OAAO,EAAE,CAAC,c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BACd,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;oBACvB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;oBAChB,cAAI,CAAC,IAAI,CACP,+DAA+D,EAC/D,EAAE,SAAS,EAAE,IAAI,EAAE,CACpB,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,cAAI,CAAC,IAAI,CAAC,uCAAuC,IAAI,EAAE,EAAE;wBACvD,SAAS,EAAE,IAAI;qBAChB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC,EAAE,GAAG,CAAC,CAAC;QAEV,UAAU,CAAC,GAAG,EAAE;YACd,YAAY,GAAG,KAAK,CAAC;QACvB,CAAC,EAAE,GAAG,CAAC,CAAC;QACR,UAAU,EAAE,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,eAAe;IAC7B,IAAI,WAAW,EAAE,CAAC;QAChB,WAAW,CAAC,KAAK,EAAE,CAAC;QACpB,WAAW,GAAG,IAAI,CAAC;IACrB,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
2
|
export declare let tsxKiller: (() => Promise<void>) | null;
|
|
3
3
|
export declare function setTsxKiller(value: typeof tsxKiller): void;
|
|
4
4
|
export declare function getTsxKiller(): (() => Promise<void>) | null;
|
|
@@ -8,5 +8,16 @@ export declare let status: {
|
|
|
8
8
|
export declare function getStatus(): {
|
|
9
9
|
hasTsErrors?: boolean;
|
|
10
10
|
} & Record<string, any>;
|
|
11
|
-
export
|
|
11
|
+
export type ProgramOptions = {
|
|
12
|
+
watch: boolean;
|
|
13
|
+
include?: string | undefined;
|
|
14
|
+
clear: boolean;
|
|
15
|
+
compiler: string;
|
|
16
|
+
path: string;
|
|
17
|
+
tscArgs?: string[] | undefined;
|
|
18
|
+
tsxArgs?: string[] | undefined;
|
|
19
|
+
typeCheck: boolean;
|
|
20
|
+
maxNodeMem: string;
|
|
21
|
+
};
|
|
22
|
+
export declare function runTsxStrict(file: string, options: ProgramOptions): Promise<void>;
|
|
12
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAaA,eAAO,IAAI,SAAS,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAW,CAAC;AAE1D,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,SAAS,QAEnD;AAED,wBAAgB,YAAY,WANC,OAAO,CAAC,IAAI,CAAC,SAQzC;AAED,eAAO,IAAI,MAAM,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,CAAC;AAExE,wBAAgB,SAAS;kBAFU,OAAO;wBAIzC;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,iBA6HvE"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
2
|
"use strict";
|
|
3
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
4
|
if (k2 === undefined) k2 = k;
|
|
@@ -50,6 +50,7 @@ const readline_1 = require("readline");
|
|
|
50
50
|
const killer_1 = require("./killer");
|
|
51
51
|
const compiler_provider_1 = require("./compiler-provider");
|
|
52
52
|
const file_watcher_1 = require("./file-watcher");
|
|
53
|
+
const config_loader_1 = require("./utils/config-loader");
|
|
53
54
|
let firstTime = true;
|
|
54
55
|
exports.tsxKiller = null;
|
|
55
56
|
function setTsxKiller(value) {
|
|
@@ -63,26 +64,30 @@ function getStatus() {
|
|
|
63
64
|
return exports.status;
|
|
64
65
|
}
|
|
65
66
|
async function runTsxStrict(file, options) {
|
|
66
|
-
const
|
|
67
|
+
const fileConfig = await (0, config_loader_1.loadConfig)();
|
|
68
|
+
const { clear = true, typeCheck = true, compiler, watch = false, tscArgs = [], tsxArgs = [], maxNodeMem, } = { ...options, ...fileConfig };
|
|
67
69
|
exports.status = { ...options, ...exports.status };
|
|
70
|
+
const sendSignal = (msg) => process.send && process.send(msg);
|
|
71
|
+
const Signal = {
|
|
72
|
+
emitStarted: () => sendSignal("started"),
|
|
73
|
+
emitFirstSuccess: () => sendSignal("first_success"),
|
|
74
|
+
emitSuccess: () => sendSignal("success"),
|
|
75
|
+
emitFail: () => sendSignal("compile_errors"),
|
|
76
|
+
emitFile: (path) => sendSignal(`file_emitted:${path}`),
|
|
77
|
+
};
|
|
68
78
|
function runTsxCommand() {
|
|
69
79
|
const tsxArgsArray = [];
|
|
70
80
|
tsxArgsArray.push(file);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
.split(/\s+/)
|
|
75
|
-
.filter((arg) => arg.length > 0);
|
|
76
|
-
const uniqueArgs = Array.from(new Set([...tsxArgsArray, ...additionalArgs]));
|
|
77
|
-
tsxArgsArray.length = 0;
|
|
78
|
-
tsxArgsArray.push(...uniqueArgs);
|
|
79
|
-
}
|
|
81
|
+
const uniqueArgs = Array.from(new Set([...tsxArgsArray, ...tsxArgs]));
|
|
82
|
+
tsxArgsArray.length = 0;
|
|
83
|
+
tsxArgsArray.push(...uniqueArgs);
|
|
80
84
|
const tsxCommand = `${process.env.npm_lifecycle_script === "npx" ? "npx " : ""}tsx ${tsxArgsArray.join(" ")}`;
|
|
81
85
|
if (exports.tsxKiller)
|
|
82
86
|
((0, exports.tsxKiller)?.()).then(() => (exports.tsxKiller = (0, runner_1.run)(tsxCommand)));
|
|
83
87
|
else
|
|
84
88
|
exports.tsxKiller = (0, runner_1.run)(tsxCommand);
|
|
85
89
|
}
|
|
90
|
+
// tsx starts immediately, no waiting for tsc
|
|
86
91
|
runTsxCommand();
|
|
87
92
|
if (!typeCheck)
|
|
88
93
|
return;
|
|
@@ -91,108 +96,71 @@ async function runTsxStrict(file, options) {
|
|
|
91
96
|
tscArgsArray.push((0, compiler_provider_1.getCompilerPath)(compiler));
|
|
92
97
|
tscArgsArray.push(...(0, compiler_provider_1.getTscArgs)(file));
|
|
93
98
|
tscArgsArray.push("--noEmit");
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
.trim()
|
|
99
|
-
.split(/\s+/)
|
|
100
|
-
.filter((arg) => arg.length > 0);
|
|
101
|
-
const uniqueArgs = Array.from(new Set([...tscArgsArray, ...additionalArgs]));
|
|
102
|
-
tscArgsArray.length = 0;
|
|
103
|
-
tscArgsArray.push(...uniqueArgs);
|
|
104
|
-
}
|
|
105
|
-
const tscProcess = (0, cross_spawn_1.default)("node", [...nodeArgs, ...tscArgsArray]);
|
|
106
|
-
if (!tscProcess.stdout)
|
|
107
|
-
throw new Error("Unable to read Typescript stdout");
|
|
108
|
-
if (!tscProcess.stderr)
|
|
109
|
-
throw new Error("Unable to read Typescript stderr");
|
|
110
|
-
tscProcess.on("exit", (_, signal) => {
|
|
111
|
-
if (signal !== null)
|
|
112
|
-
process.kill(process.pid, signal);
|
|
113
|
-
});
|
|
114
|
-
tscProcess.stderr.pipe(process.stderr);
|
|
115
|
-
let compilationId = 0;
|
|
116
|
-
let compilationErrorSinceStart = false;
|
|
99
|
+
// No --watch — tsc is always a fresh single-pass process
|
|
100
|
+
const uniqueArgs = Array.from(new Set([...tscArgsArray, ...tscArgs]));
|
|
101
|
+
tscArgsArray.length = 0;
|
|
102
|
+
tscArgsArray.push(...uniqueArgs);
|
|
117
103
|
exports.status.hasTsErrors = false;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
104
|
+
let currentTscProcess = null;
|
|
105
|
+
function spawnTscProcess() {
|
|
106
|
+
if (currentTscProcess)
|
|
107
|
+
currentTscProcess.kill();
|
|
108
|
+
const tscProcess = (0, cross_spawn_1.default)("node", [...nodeArgs, ...tscArgsArray]);
|
|
109
|
+
currentTscProcess = tscProcess;
|
|
110
|
+
if (!tscProcess.stdout)
|
|
111
|
+
throw new Error("Unable to read Typescript stdout");
|
|
112
|
+
if (!tscProcess.stderr)
|
|
113
|
+
throw new Error("Unable to read Typescript stderr");
|
|
114
|
+
tscProcess.on("exit", (_, signal) => {
|
|
115
|
+
if (signal !== null)
|
|
116
|
+
process.kill(process.pid, signal);
|
|
129
117
|
});
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const compilationCompleteWithoutError = state.compilationCompleteWithoutError;
|
|
142
|
-
if (compilationCompleteWithoutError)
|
|
143
|
-
exports.status.hasTsErrors = false;
|
|
144
|
-
if (compilationError) {
|
|
145
|
-
exports.status.hasTsErrors = true;
|
|
146
|
-
compilationId++;
|
|
147
|
-
(0, killer_1.killProcesses)(compilationId).then((previousCompilationId) => {
|
|
148
|
-
if (previousCompilationId !== compilationId)
|
|
149
|
-
return;
|
|
150
|
-
Signal.emitStarted();
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
compilationErrorSinceStart =
|
|
154
|
-
(!compilationStarted && compilationErrorSinceStart) || compilationError;
|
|
155
|
-
if (state.fileEmitted !== null)
|
|
156
|
-
Signal.emitFile(state.fileEmitted);
|
|
157
|
-
if (compilationCompleteWithoutError && !exports.status.hasTsErrors && !firstTime) {
|
|
158
|
-
compilationId++;
|
|
159
|
-
(0, killer_1.killProcesses)(compilationId).then((previousCompilationId) => {
|
|
160
|
-
if (previousCompilationId !== compilationId)
|
|
161
|
-
return;
|
|
162
|
-
if (compilationErrorSinceStart)
|
|
163
|
-
Signal.emitFail();
|
|
118
|
+
tscProcess.stderr.pipe(process.stderr);
|
|
119
|
+
const rl = (0, readline_1.createInterface)({ input: tscProcess.stdout });
|
|
120
|
+
rl.on("line", function (line) {
|
|
121
|
+
(0, stdout_manipulator_1.print)(line, { clear });
|
|
122
|
+
const state = (0, stdout_manipulator_1.detectState)(line);
|
|
123
|
+
if (state.compilationCompleteWithoutError) {
|
|
124
|
+
exports.status.hasTsErrors = false;
|
|
125
|
+
if (firstTime) {
|
|
126
|
+
firstTime = false;
|
|
127
|
+
Signal.emitFirstSuccess();
|
|
128
|
+
}
|
|
164
129
|
else {
|
|
165
130
|
Signal.emitSuccess();
|
|
166
131
|
runTsxCommand();
|
|
167
132
|
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
133
|
+
}
|
|
134
|
+
if (state.compilationError && !exports.status.hasTsErrors) {
|
|
135
|
+
exports.status.hasTsErrors = true;
|
|
136
|
+
// tsc found errors — kill tsx immediately
|
|
137
|
+
if (exports.tsxKiller)
|
|
138
|
+
(0, exports.tsxKiller)();
|
|
139
|
+
Signal.emitFail();
|
|
140
|
+
}
|
|
141
|
+
if (state.fileEmitted !== null)
|
|
142
|
+
Signal.emitFile(state.fileEmitted);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function restartTsx() {
|
|
146
|
+
if (!exports.status.hasTsErrors)
|
|
147
|
+
runTsxCommand();
|
|
148
|
+
spawnTscProcess();
|
|
149
|
+
}
|
|
150
|
+
if (watch)
|
|
151
|
+
(0, file_watcher_1.setupFileWatcher)(restartTsx, fileConfig);
|
|
152
|
+
// Initial tsc run (tsx already started above)
|
|
153
|
+
spawnTscProcess();
|
|
177
154
|
if (typeof process.on === "function")
|
|
178
155
|
process.on("message", (msg) => {
|
|
179
156
|
if (msg === "run-on-success-command" && exports.tsxKiller)
|
|
180
157
|
(0, exports.tsxKiller)().then(runTsxCommand);
|
|
181
158
|
});
|
|
182
|
-
const sendSignal = (msg) => process.send && process.send(msg);
|
|
183
|
-
const Signal = {
|
|
184
|
-
emitStarted: () => sendSignal("started"),
|
|
185
|
-
emitFirstSuccess: () => sendSignal("first_success"),
|
|
186
|
-
emitSuccess: () => sendSignal("success"),
|
|
187
|
-
emitFail: () => sendSignal("compile_errors"),
|
|
188
|
-
emitFile: (path) => sendSignal(`file_emitted:${path}`),
|
|
189
|
-
};
|
|
190
159
|
(0, node_cleanup_1.default)((_exitCode, signal) => {
|
|
191
|
-
if (signal)
|
|
192
|
-
|
|
160
|
+
if (signal && currentTscProcess)
|
|
161
|
+
currentTscProcess.kill(signal);
|
|
193
162
|
(0, file_watcher_1.stopFileWatcher)();
|
|
194
163
|
(0, killer_1.killProcesses)(0).then(() => process.exit());
|
|
195
|
-
// don't call cleanup handler again
|
|
196
164
|
(0, node_cleanup_1.uninstall)();
|
|
197
165
|
return false;
|
|
198
166
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,GAAW,EAAE,EAAE;YACpC,IAAI,GAAG,KAAK,wBAAwB,IAAI,iBAAS;gBAC/C,IAAA,iBAAS,GAAE,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IAEL,IAAA,sBAAW,EAAC,CAAC,SAAwB,EAAE,MAAqB,EAAE,EAAE;QAC9D,IAAI,MAAM,IAAI,iBAAiB;YAAE,iBAAiB,CAAC,IAAI,CAAC,MAAa,CAAC,CAAC;QACvE,IAAA,8BAAe,GAAE,CAAC;QAClB,IAAA,sBAAa,EAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5C,IAAA,wBAAS,GAAE,CAAC;QACZ,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/utils/config-loader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAa5C,wBAAsB,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAWpE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.loadConfig = loadConfig;
|
|
37
|
+
const fs_1 = require("fs");
|
|
38
|
+
const path_1 = require("path");
|
|
39
|
+
const CONFIG_FILES = [
|
|
40
|
+
"tsx-strict.config.ts",
|
|
41
|
+
"tsx-strict.config.js",
|
|
42
|
+
"tsx-strict.config.mjs",
|
|
43
|
+
"tsxs.config.ts",
|
|
44
|
+
"tsxs.config.js",
|
|
45
|
+
"tsxs.config.mjs",
|
|
46
|
+
];
|
|
47
|
+
let config;
|
|
48
|
+
async function loadConfig() {
|
|
49
|
+
if (config)
|
|
50
|
+
return config;
|
|
51
|
+
for (const file of CONFIG_FILES) {
|
|
52
|
+
const fullPath = (0, path_1.join)(process.cwd(), file);
|
|
53
|
+
if ((0, fs_1.existsSync)(fullPath)) {
|
|
54
|
+
const mod = await Promise.resolve(`${fullPath}`).then(s => __importStar(require(s)));
|
|
55
|
+
config = mod.default ?? mod;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return config || {};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=config-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../../src/utils/config-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,gCAWC;AA1BD,2BAAgC;AAChC,+BAA4B;AAG5B,MAAM,YAAY,GAAG;IACnB,sBAAsB;IACtB,sBAAsB;IACtB,uBAAuB;IACvB,gBAAgB;IAChB,gBAAgB;IAChB,iBAAiB;CAClB,CAAC;AAEF,IAAI,MAAuB,CAAC;AAErB,KAAK,UAAU,UAAU;IAC9B,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAE1B,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;QAC3C,IAAI,IAAA,eAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;YACzB,MAAM,GAAG,GAAG,yBAAa,QAAQ,uCAAC,CAAC;YACnC,MAAM,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAO,MAAM,IAAI,EAAE,CAAC;AACtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsx-strict",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "TSX runner with automatic Type-checking",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
"tsx-strict": "./bin/tsx-strict.js",
|
|
9
9
|
"tsxs": "./bin/tsx-strict.js"
|
|
10
10
|
},
|
|
11
|
+
"exports": {
|
|
12
|
+
"./config": {
|
|
13
|
+
"types": "./dist/config.d.ts",
|
|
14
|
+
"import": "./dist/config.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
11
17
|
"scripts": {
|
|
12
18
|
"build": "npx rimraf dist && tsc",
|
|
13
19
|
"prepublishOnly": "npm run build",
|
|
@@ -35,7 +41,7 @@
|
|
|
35
41
|
"bugs": {
|
|
36
42
|
"url": "https://github.com/uanela/tsx-strict/issues"
|
|
37
43
|
},
|
|
38
|
-
"homepage": "https://github.com/uanela/tsx-strict
|
|
44
|
+
"homepage": "https://github.com/uanela/tsx-strict",
|
|
39
45
|
"files": ["dist", "bin", "README.md", "LICENSE"],
|
|
40
46
|
"engines": {
|
|
41
47
|
"node": ">=20.0.0"
|
|
@@ -44,6 +50,7 @@
|
|
|
44
50
|
"tsx": "^4.20.5"
|
|
45
51
|
},
|
|
46
52
|
"devDependencies": {
|
|
53
|
+
"@commander-js/extra-typings": "^14.0.0",
|
|
47
54
|
"@types/cross-spawn": "^6.0.6",
|
|
48
55
|
"@types/jest": "^30.0.0",
|
|
49
56
|
"@types/node": "^18.0.0",
|