tsx-strict 0.1.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/LICENSE +21 -0
- package/README.md +136 -0
- package/bin/tsx-strict.js +3 -0
- package/dist/@types/fs-extra.d.ts +2 -0
- package/dist/@types/fs-extra.d.ts.map +1 -0
- package/dist/@types/fs-extra.js +2 -0
- package/dist/@types/fs-extra.js.map +1 -0
- package/dist/args-manager.d.ts +20 -0
- package/dist/args-manager.d.ts.map +1 -0
- package/dist/args-manager.js +88 -0
- package/dist/args-manager.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +32 -0
- package/dist/cli.js.map +1 -0
- package/dist/compiler-provider.d.ts +2 -0
- package/dist/compiler-provider.d.ts.map +1 -0
- package/dist/compiler-provider.js +25 -0
- package/dist/compiler-provider.js.map +1 -0
- package/dist/debounce.d.ts +2 -0
- package/dist/debounce.d.ts.map +1 -0
- package/dist/debounce.js +11 -0
- package/dist/debounce.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +152 -0
- package/dist/index.js.map +1 -0
- package/dist/killer.d.ts +4 -0
- package/dist/killer.d.ts.map +1 -0
- package/dist/killer.js +67 -0
- package/dist/killer.js.map +1 -0
- package/dist/runner.d.ts +2 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +23 -0
- package/dist/runner.js.map +1 -0
- package/dist/stdout-manipulator.d.ts +17 -0
- package/dist/stdout-manipulator.d.ts.map +1 -0
- package/dist/stdout-manipulator.js +114 -0
- package/dist/stdout-manipulator.js.map +1 -0
- package/dist/utils/sheu.d.ts +9 -0
- package/dist/utils/sheu.d.ts.map +1 -0
- package/dist/utils/sheu.js +24 -0
- package/dist/utils/sheu.js.map +1 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present Uanela Como
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# tsx-strict
|
|
2
|
+
|
|
3
|
+
Type-safe TSX runner with automatic type-checking
|
|
4
|
+
|
|
5
|
+
tsx-strict is a CLI tool that runs TypeScript files with TSX while providing real-time type checking. It combines the speed of tsx with the safety of TypeScript's compiler, ensuring your code is both executable and type-safe.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Real-time type checking**: Runs TypeScript compiler alongside tsx for immediate feedback
|
|
10
|
+
- **Watch mode**: Automatically restarts on file changes
|
|
11
|
+
- **Intelligent process management**: Kills previous processes when recompilation starts
|
|
12
|
+
- **Customizable compiler**: Support for different TypeScript compiler versions
|
|
13
|
+
- **Silent mode**: Suppress output when needed
|
|
14
|
+
- **Memory management**: Configure Node.js memory limits
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g tsx-strict
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or use with npx:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx tsx-strict your-file.ts
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
### Basic Usage
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
tsx-strict app.ts
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Watch Mode
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
tsx-strict --watch app.ts
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Skip Type Checking
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
tsx-strict --no-type-check app.ts
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## CLI Options
|
|
49
|
+
|
|
50
|
+
| Option | Description | Default |
|
|
51
|
+
| ---------------------- | ---------------------------------------- | -------------------- |
|
|
52
|
+
| `-w, --watch` | Enable watch mode | `false` |
|
|
53
|
+
| `--no-clear` | Do not clear screen | `false` |
|
|
54
|
+
| `--compiler` | Compiler path | `typescript/bin/tsc` |
|
|
55
|
+
| `--tsc-args <args...>` | Additional TypeScript compiler arguments | `[]` |
|
|
56
|
+
| `--tsx-args <args...>` | Additional tsx arguments | `[]` |
|
|
57
|
+
| `--silent` | Suppress output | `false` |
|
|
58
|
+
| `--no-type-check` | Skip type checking (run tsx directly) | `false` |
|
|
59
|
+
|
|
60
|
+
## Examples
|
|
61
|
+
|
|
62
|
+
### Basic TypeScript File
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
tsx-strict src/index.ts
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Watch Mode with Custom TSC Arguments
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
tsx-strict --watch --tsc-args --strict --exactOptionalPropertyTypes src/app.ts
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Silent Mode
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
tsx-strict --silent --no-clear src/worker.ts
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Skip Type Checking for Quick Execution
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
tsx-strict --no-type-check src/script.ts
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## How It Works
|
|
87
|
+
|
|
88
|
+
tsx-strict runs two processes simultaneously:
|
|
89
|
+
|
|
90
|
+
1. **TypeScript Compiler (tsc)**: Performs type checking with `--noEmit` flag
|
|
91
|
+
2. **tsx Runner**: Executes the TypeScript file when compilation succeeds
|
|
92
|
+
|
|
93
|
+
The tool intelligently manages these processes, restarting tsx only when type checking passes and killing previous instances to prevent resource conflicts.
|
|
94
|
+
|
|
95
|
+
## Requirements
|
|
96
|
+
|
|
97
|
+
- Node.js >= 20.0.0
|
|
98
|
+
- tsx ^4.20.5 (peer dependency)
|
|
99
|
+
|
|
100
|
+
## API
|
|
101
|
+
|
|
102
|
+
You can also use tsx-strict programmatically:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import { runTsxStrict } from "tsx-strict";
|
|
106
|
+
|
|
107
|
+
await runTsxStrict("src/app.ts", {
|
|
108
|
+
watch: true,
|
|
109
|
+
silent: false,
|
|
110
|
+
noClear: false,
|
|
111
|
+
compiler: "typescript/bin/tsc",
|
|
112
|
+
tscArgs: ["--strict"],
|
|
113
|
+
tsxArgs: [],
|
|
114
|
+
noTypeCheck: false,
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Error Handling
|
|
119
|
+
|
|
120
|
+
tsx-strict provides clear error messages and exits gracefully on compilation errors. Type errors are displayed in real-time, and the tsx process only runs when compilation is successful.
|
|
121
|
+
|
|
122
|
+
## Contributing
|
|
123
|
+
|
|
124
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
MIT
|
|
129
|
+
|
|
130
|
+
## Repository
|
|
131
|
+
|
|
132
|
+
[https://github.com/uanela/tsx-strict](https://github.com/uanela/tsx-strict)
|
|
133
|
+
|
|
134
|
+
## Issues
|
|
135
|
+
|
|
136
|
+
Report issues at: [https://github.com/uanela/tsx-strict/issues](https://github.com/uanela/tsx-strict/issues)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-extra.d.ts","sourceRoot":"","sources":["../../src/@types/fs-extra.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-extra.js","sourceRoot":"","sources":["../../src/@types/fs-extra.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare function isCommandExist(args: string[], command: string): boolean;
|
|
2
|
+
export declare function hasWatchCommand(args: string[]): boolean;
|
|
3
|
+
export declare function extractArgs(inputArgs: string[]): {
|
|
4
|
+
onFirstSuccessCommand: string | null;
|
|
5
|
+
onSuccessCommand: string | null;
|
|
6
|
+
onFailureCommand: string | null;
|
|
7
|
+
onEmitCommand: string | null;
|
|
8
|
+
onEmitDebounceMs: number;
|
|
9
|
+
onCompilationStarted: string | null;
|
|
10
|
+
onCompilationComplete: string | null;
|
|
11
|
+
maxNodeMem: string | null;
|
|
12
|
+
noColors: boolean;
|
|
13
|
+
noClear: boolean;
|
|
14
|
+
requestedToListEmittedFiles: boolean;
|
|
15
|
+
signalEmittedFiles: boolean;
|
|
16
|
+
silent: boolean;
|
|
17
|
+
compiler: string;
|
|
18
|
+
args: string[];
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=args-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args-manager.d.ts","sourceRoot":"","sources":["../src/args-manager.ts"],"names":[],"mappings":"AAWA,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAEvE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAEvD;AAgCD,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE;;;;;;;;;;;;;;;;EA2D9C"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCommandExist = isCommandExist;
|
|
4
|
+
exports.hasWatchCommand = hasWatchCommand;
|
|
5
|
+
exports.extractArgs = extractArgs;
|
|
6
|
+
const compiler_provider_1 = require("./compiler-provider");
|
|
7
|
+
function removeRunnerArgs(args) {
|
|
8
|
+
return args.splice(2); // removing "node tsc-watch.js"
|
|
9
|
+
}
|
|
10
|
+
function getCommandIdx(args, command) {
|
|
11
|
+
const lowerCasedCommand = command.toLowerCase();
|
|
12
|
+
return args.map((arg) => arg.toLowerCase()).indexOf(lowerCasedCommand);
|
|
13
|
+
}
|
|
14
|
+
function isCommandExist(args, command) {
|
|
15
|
+
return getCommandIdx(args, command) >= 0;
|
|
16
|
+
}
|
|
17
|
+
function hasWatchCommand(args) {
|
|
18
|
+
return isCommandExist(args, "-w") || isCommandExist(args, "--watch");
|
|
19
|
+
}
|
|
20
|
+
function forceWatch(args) {
|
|
21
|
+
if (!hasWatchCommand(args)) {
|
|
22
|
+
args.push("--watch");
|
|
23
|
+
}
|
|
24
|
+
return args;
|
|
25
|
+
}
|
|
26
|
+
function extractCommandWithValue(args, command) {
|
|
27
|
+
let commandValue = null;
|
|
28
|
+
let commandIdx = getCommandIdx(args, command);
|
|
29
|
+
if (commandIdx > -1) {
|
|
30
|
+
commandValue = args[commandIdx + 1];
|
|
31
|
+
args.splice(commandIdx, 2);
|
|
32
|
+
}
|
|
33
|
+
return commandValue;
|
|
34
|
+
}
|
|
35
|
+
function extractCommand(args, command) {
|
|
36
|
+
let commandIdx = getCommandIdx(args, command);
|
|
37
|
+
if (commandIdx > -1) {
|
|
38
|
+
args.splice(commandIdx, 1);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
function extractArgs(inputArgs) {
|
|
44
|
+
const cleanArgs = removeRunnerArgs(inputArgs);
|
|
45
|
+
const noWatch = extractCommand(cleanArgs, "--noWatch");
|
|
46
|
+
const args = noWatch ? cleanArgs : forceWatch(cleanArgs);
|
|
47
|
+
const onFirstSuccessCommand = extractCommandWithValue(args, "--onFirstSuccess");
|
|
48
|
+
const onSuccessCommand = extractCommandWithValue(args, "--onSuccess");
|
|
49
|
+
const onFailureCommand = extractCommandWithValue(args, "--onFailure");
|
|
50
|
+
const onEmitCommand = extractCommandWithValue(args, "--onEmit");
|
|
51
|
+
const onEmitDebounceMs = Number(extractCommandWithValue(args, "--onEmitDebounceMs")) || 300;
|
|
52
|
+
const onCompilationStarted = extractCommandWithValue(args, "--onCompilationStarted");
|
|
53
|
+
const onCompilationComplete = extractCommandWithValue(args, "--onCompilationComplete");
|
|
54
|
+
const maxNodeMem = extractCommandWithValue(args, "--maxNodeMem");
|
|
55
|
+
const noColors = extractCommand(args, "--noColors");
|
|
56
|
+
const noClear = extractCommand(args, "--noClear");
|
|
57
|
+
const silent = extractCommand(args, "--silent");
|
|
58
|
+
const signalEmittedFiles = extractCommand(args, "--signalEmittedFiles");
|
|
59
|
+
const requestedToListEmittedFiles = extractCommand(args, "--listEmittedFiles");
|
|
60
|
+
const compiler = (0, compiler_provider_1.getCompilerPath)(extractCommandWithValue(args, "--compiler"));
|
|
61
|
+
if (signalEmittedFiles || requestedToListEmittedFiles) {
|
|
62
|
+
if (args[0] === "--build" || args[0] === "-b") {
|
|
63
|
+
// TS6369: Option '--build' must be the first command line argument.
|
|
64
|
+
args.splice(1, 0, "--listEmittedFiles");
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
args.unshift("--listEmittedFiles");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
onFirstSuccessCommand,
|
|
72
|
+
onSuccessCommand,
|
|
73
|
+
onFailureCommand,
|
|
74
|
+
onEmitCommand,
|
|
75
|
+
onEmitDebounceMs,
|
|
76
|
+
onCompilationStarted,
|
|
77
|
+
onCompilationComplete,
|
|
78
|
+
maxNodeMem,
|
|
79
|
+
noColors,
|
|
80
|
+
noClear,
|
|
81
|
+
requestedToListEmittedFiles,
|
|
82
|
+
signalEmittedFiles,
|
|
83
|
+
silent,
|
|
84
|
+
compiler,
|
|
85
|
+
args,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=args-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args-manager.js","sourceRoot":"","sources":["../src/args-manager.ts"],"names":[],"mappings":";;AAWA,wCAEC;AAED,0CAEC;AAgCD,kCA2DC;AA5GD,2DAAsD;AAEtD,SAAS,gBAAgB,CAAC,IAAc;IACtC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,+BAA+B;AACxD,CAAC;AAED,SAAS,aAAa,CAAC,IAAc,EAAE,OAAe;IACpD,MAAM,iBAAiB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAChD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACzE,CAAC;AAED,SAAgB,cAAc,CAAC,IAAc,EAAE,OAAe;IAC5D,OAAO,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;AAC3C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C,CAAC,EAAE,CAAC,EAAE,oBAAoB,CAAC,CAAC;QAC1C,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,OAAO;QACL,qBAAqB;QACrB,gBAAgB;QAChB,gBAAgB;QAChB,aAAa;QACb,gBAAgB;QAChB,oBAAoB;QACpB,qBAAqB;QACrB,UAAU;QACV,QAAQ;QACR,OAAO;QACP,2BAA2B;QAC3B,kBAAkB;QAClB,MAAM;QACN,QAAQ;QACR,IAAI;KACL,CAAC;AACJ,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAGA,OAAO,SAAS,CAAC"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const index_1 = require("./index");
|
|
6
|
+
require("./index");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const packageJson = JSON.parse((0, fs_1.readFileSync)("./package.json", "utf8"));
|
|
9
|
+
const program = new commander_1.Command();
|
|
10
|
+
program
|
|
11
|
+
.name("tsx-strict")
|
|
12
|
+
.description("Run TSX with automatic Type-checking")
|
|
13
|
+
.version(packageJson.version)
|
|
14
|
+
.argument("<file>", "TypeScript file to run")
|
|
15
|
+
.option("-w, --watch", "Enable watch mode", false)
|
|
16
|
+
.option("--no-clear", "Do not clear screen", false)
|
|
17
|
+
.option("--compiler", "Compiler", "typescript/bin/tsc")
|
|
18
|
+
.option("--tsc-args <args...>", "Additional tsc arguments")
|
|
19
|
+
.option("--tsx-args <args...>", "Additional tsx arguments")
|
|
20
|
+
.option("--silent", "Suppress output", false)
|
|
21
|
+
.option("--no-type-check", "Skip type checking (run tsx directly)", true)
|
|
22
|
+
.action(async (file, options) => {
|
|
23
|
+
try {
|
|
24
|
+
await (0, index_1.runTsxStrict)(file, options);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.error("Error uanela:", error.message);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
program.parse();
|
|
32
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +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,OAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,WAAW,CAAC,sCAAsC,CAAC;KACnD,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC;KAC5B,QAAQ,CAAC,QAAQ,EAAE,wBAAwB,CAAC;KAC5C,MAAM,CAAC,aAAa,EAAE,mBAAmB,EAAE,KAAK,CAAC;KACjD,MAAM,CAAC,YAAY,EAAE,qBAAqB,EAAE,KAAK,CAAC;KAClD,MAAM,CAAC,YAAY,EAAE,UAAU,EAAE,oBAAoB,CAAC;KACtD,MAAM,CAAC,sBAAsB,EAAE,0BAA0B,CAAC;KAC1D,MAAM,CAAC,sBAAsB,EAAE,0BAA0B,CAAC;KAC1D,MAAM,CAAC,UAAU,EAAE,iBAAiB,EAAE,KAAK,CAAC;KAC5C,MAAM,CAAC,iBAAiB,EAAE,uCAAuC,EAAE,IAAI,CAAC;KACxE,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;IAC9B,IAAI,CAAC;QACH,MAAM,IAAA,oBAAY,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AACL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler-provider.d.ts","sourceRoot":"","sources":["../src/compiler-provider.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,GAAE,WAAW,CAAC,SAAS,CAAmB,GAAG,MAAM,CAoBtH"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCompilerPath = getCompilerPath;
|
|
4
|
+
function getCompilerPath(compilerArg, resolver = require.resolve) {
|
|
5
|
+
if (!compilerArg) {
|
|
6
|
+
compilerArg = 'typescript/bin/tsc';
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
return resolver(compilerArg, { paths: [process.cwd()] });
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
// Local compiler not found, ignore and try global compiler
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
return resolver(compilerArg);
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
if (e.code === 'MODULE_NOT_FOUND') {
|
|
19
|
+
console.error(e.message);
|
|
20
|
+
process.exit(9);
|
|
21
|
+
}
|
|
22
|
+
throw e;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=compiler-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler-provider.js","sourceRoot":"","sources":["../src/compiler-provider.ts"],"names":[],"mappings":";;AAAA,0CAoBC;AApBD,SAAgB,eAAe,CAAC,WAA0B,EAAE,WAAmC,OAAO,CAAC,OAAO;IAC5G,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,WAAW,GAAG,oBAAoB,CAAC;IACrC,CAAC;IAED,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,OAAO,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,IAAI,CAAC,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;YAClC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../src/debounce.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,SAAM,IAEzG,GAAG,MAAM,UAAU,CAAC,CAAC,CAAC,UAI/B"}
|
package/dist/debounce.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.debounce = debounce;
|
|
4
|
+
function debounce(fn, delay = 300) {
|
|
5
|
+
let timer;
|
|
6
|
+
return (...args) => {
|
|
7
|
+
timer && clearTimeout(timer);
|
|
8
|
+
timer = setTimeout(() => fn.apply(this, args), delay);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=debounce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.js","sourceRoot":"","sources":["../src/debounce.ts"],"names":[],"mappings":";;AAAA,4BAMC;AAND,SAAgB,QAAQ,CAAyE,EAAK,EAAE,KAAK,GAAG,GAAG;IACjH,IAAI,KAAgD,CAAA;IACpD,OAAO,CAAC,GAAG,IAAmB,EAAE,EAAE;QAChC,KAAK,IAAI,YAAY,CAAC,KAAK,CAAC,CAAA;QAC5B,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,CAAA;IACvD,CAAC,CAAA;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export declare let successKiller: (() => Promise<void>) | null;
|
|
3
|
+
export declare function setSuccessKiller(value: typeof successKiller): void;
|
|
4
|
+
export declare function getSuccessKiller(): (() => Promise<void>) | null;
|
|
5
|
+
export declare function runTsxStrict(file: string, options: Record<string, any>): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAgBA,eAAO,IAAI,aAAa,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAW,CAAC;AAE9D,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,aAAa,QAE3D;AAED,wBAAgB,gBAAgB,WANC,OAAO,CAAC,IAAI,CAAC,SAQ7C;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,iBAqH5E"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.successKiller = void 0;
|
|
41
|
+
exports.setSuccessKiller = setSuccessKiller;
|
|
42
|
+
exports.getSuccessKiller = getSuccessKiller;
|
|
43
|
+
exports.runTsxStrict = runTsxStrict;
|
|
44
|
+
const node_cleanup_1 = __importStar(require("node-cleanup"));
|
|
45
|
+
const cross_spawn_1 = __importDefault(require("cross-spawn"));
|
|
46
|
+
const runner_1 = require("./runner");
|
|
47
|
+
const stdout_manipulator_1 = require("./stdout-manipulator");
|
|
48
|
+
const readline_1 = require("readline");
|
|
49
|
+
const killer_1 = require("./killer");
|
|
50
|
+
const compiler_provider_1 = require("./compiler-provider");
|
|
51
|
+
let firstTime = true;
|
|
52
|
+
exports.successKiller = null;
|
|
53
|
+
function setSuccessKiller(value) {
|
|
54
|
+
exports.successKiller = value;
|
|
55
|
+
}
|
|
56
|
+
function getSuccessKiller() {
|
|
57
|
+
return exports.successKiller;
|
|
58
|
+
}
|
|
59
|
+
async function runTsxStrict(file, options) {
|
|
60
|
+
const { noClear, noTypeCheck, silent, compiler, watch, tscArgs = [], tsxArgs = [], maxNodeMem, } = options;
|
|
61
|
+
if (!noTypeCheck)
|
|
62
|
+
runTsxCommand();
|
|
63
|
+
function runTsxCommand() {
|
|
64
|
+
exports.successKiller = (0, runner_1.run)(`npx tsx ${[watch ? "--watch" : "", file, tsxArgs].join(" ")}`);
|
|
65
|
+
}
|
|
66
|
+
const tscProcess = (0, cross_spawn_1.default)("node", [
|
|
67
|
+
...(maxNodeMem ? [`--max_old_space_size=${maxNodeMem}`] : []),
|
|
68
|
+
(0, compiler_provider_1.getCompilerPath)(compiler),
|
|
69
|
+
"--noEmit",
|
|
70
|
+
watch ? "--watch" : "",
|
|
71
|
+
...tscArgs,
|
|
72
|
+
]);
|
|
73
|
+
if (!tscProcess.stdout)
|
|
74
|
+
throw new Error("Unable to read Typescript stdout");
|
|
75
|
+
if (!tscProcess.stderr)
|
|
76
|
+
throw new Error("Unable to read Typescript stderr");
|
|
77
|
+
tscProcess.on("exit", (_, signal) => {
|
|
78
|
+
if (signal !== null)
|
|
79
|
+
process.kill(process.pid, signal);
|
|
80
|
+
});
|
|
81
|
+
tscProcess.stderr.pipe(process.stderr);
|
|
82
|
+
let compilationId = 0;
|
|
83
|
+
let compilationErrorSinceStart = false;
|
|
84
|
+
const rl = (0, readline_1.createInterface)({ input: tscProcess.stdout });
|
|
85
|
+
rl.on("line", function (input) {
|
|
86
|
+
if (noClear)
|
|
87
|
+
input = (0, stdout_manipulator_1.deleteClear)(input);
|
|
88
|
+
const line = (0, stdout_manipulator_1.manipulate)(input);
|
|
89
|
+
if (!silent) {
|
|
90
|
+
(0, stdout_manipulator_1.print)(line, {
|
|
91
|
+
noClear,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
const state = (0, stdout_manipulator_1.detectState)(line);
|
|
95
|
+
const compilationStarted = state.compilationStarted;
|
|
96
|
+
const compilationError = state.compilationError;
|
|
97
|
+
const compilationComplete = state.compilationComplete;
|
|
98
|
+
compilationErrorSinceStart =
|
|
99
|
+
(!compilationStarted && compilationErrorSinceStart) || compilationError;
|
|
100
|
+
if (state.fileEmitted !== null) {
|
|
101
|
+
Signal.emitFile(state.fileEmitted);
|
|
102
|
+
// triggerOnEmit();
|
|
103
|
+
}
|
|
104
|
+
if (compilationStarted) {
|
|
105
|
+
compilationId++;
|
|
106
|
+
(0, killer_1.killProcesses)(compilationId).then((previousCompilationId) => {
|
|
107
|
+
if (previousCompilationId !== compilationId)
|
|
108
|
+
return;
|
|
109
|
+
Signal.emitStarted();
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if (compilationComplete) {
|
|
113
|
+
compilationId++;
|
|
114
|
+
(0, killer_1.killProcesses)(compilationId).then((previousCompilationId) => {
|
|
115
|
+
if (previousCompilationId !== compilationId)
|
|
116
|
+
return;
|
|
117
|
+
if (compilationErrorSinceStart)
|
|
118
|
+
Signal.emitFail();
|
|
119
|
+
else {
|
|
120
|
+
if (firstTime) {
|
|
121
|
+
firstTime = false;
|
|
122
|
+
Signal.emitFirstSuccess();
|
|
123
|
+
}
|
|
124
|
+
Signal.emitSuccess();
|
|
125
|
+
runTsxCommand();
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
if (typeof process.on === "function")
|
|
131
|
+
process.on("message", (msg) => {
|
|
132
|
+
if (msg === "run-on-success-command" && exports.successKiller)
|
|
133
|
+
(0, exports.successKiller)().then(runTsxCommand);
|
|
134
|
+
});
|
|
135
|
+
const sendSignal = (msg) => process.send && process.send(msg);
|
|
136
|
+
const Signal = {
|
|
137
|
+
emitStarted: () => sendSignal("started"),
|
|
138
|
+
emitFirstSuccess: () => sendSignal("first_success"),
|
|
139
|
+
emitSuccess: () => sendSignal("success"),
|
|
140
|
+
emitFail: () => sendSignal("compile_errors"),
|
|
141
|
+
emitFile: (path) => sendSignal(`file_emitted:${path}`),
|
|
142
|
+
};
|
|
143
|
+
(0, node_cleanup_1.default)((_exitCode, signal) => {
|
|
144
|
+
if (signal)
|
|
145
|
+
tscProcess.kill(signal);
|
|
146
|
+
(0, killer_1.killProcesses)(0, true).then(() => process.exit());
|
|
147
|
+
// don't call cleanup handler again
|
|
148
|
+
(0, node_cleanup_1.uninstall)();
|
|
149
|
+
return false;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,4CAEC;AAED,4CAEC;AAED,oCAqHC;AA7ID,6DAAsD;AACtD,8D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AAC,UAAU,CAAC,eAAe,CAAC;QACnD,WAAW,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;QACxC,QAAQ,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC;QAC5C,QAAQ,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,UAAU,CAAC,gBAAgB,IAAI,EAAE,CAAC;KAC/D,CAAC;IAEF,IAAA,sBAAW,EAAC,CAAC,SAAwB,EAAE,MAAqB,EAAE,EAAE;QAC9D,IAAI,MAAM;YAAE,UAAU,CAAC,IAAI,CAAC,MAAa,CAAC,CAAC;QAE3C,IAAA,sBAAa,EAAC,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAClD,mCAAmC;QACnC,IAAA,wBAAS,GAAE,CAAC;QACZ,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/killer.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"killer.d.ts","sourceRoot":"","sources":["../src/killer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAQ,MAAM,eAAe,CAAC;AAenD,wBAAgB,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBvD;AAID,wBAAsB,aAAa,CACjC,oBAAoB,EAAE,MAAM,EAC5B,OAAO,GAAE,OAAe,GACvB,OAAO,CAAC,MAAM,CAAC,CAyBjB"}
|
package/dist/killer.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.kill = kill;
|
|
7
|
+
exports.killProcesses = killProcesses;
|
|
8
|
+
const ps_tree_1 = __importDefault(require("ps-tree"));
|
|
9
|
+
const cross_spawn_1 = __importDefault(require("cross-spawn"));
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
const _1 = require(".");
|
|
12
|
+
let KILL_SIGNAL = "15"; // SIGTERM
|
|
13
|
+
let hasPS = true;
|
|
14
|
+
const isWindows = process.platform === "win32";
|
|
15
|
+
// discover if the OS has `ps`, and therefore can use psTree
|
|
16
|
+
(0, child_process_1.exec)("ps", function (error) {
|
|
17
|
+
if (error) {
|
|
18
|
+
hasPS = false;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
function kill(child) {
|
|
22
|
+
return new Promise((resolve) => {
|
|
23
|
+
if (!child.pid) {
|
|
24
|
+
resolve();
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (isWindows) {
|
|
28
|
+
(0, child_process_1.exec)(`taskkill /pid ${child.pid} /T /F`, () => resolve());
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
if (hasPS) {
|
|
32
|
+
(0, ps_tree_1.default)(child.pid, (_, kids) => {
|
|
33
|
+
const kidsPIDs = kids.map((p) => p.PID);
|
|
34
|
+
const args = [`-${KILL_SIGNAL}`, child.pid.toString(), ...kidsPIDs];
|
|
35
|
+
(0, cross_spawn_1.default)("kill", args).on("close", resolve);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
(0, child_process_1.exec)(`kill -${KILL_SIGNAL} ${child.pid}`, () => resolve());
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
let runningKillProcessesPromise = null;
|
|
45
|
+
async function killProcesses(currentCompilationId, killAll = false) {
|
|
46
|
+
if (runningKillProcessesPromise) {
|
|
47
|
+
return runningKillProcessesPromise.then(() => currentCompilationId);
|
|
48
|
+
}
|
|
49
|
+
const promisesToWaitFor = [];
|
|
50
|
+
const successKiller = (0, _1.getSuccessKiller)();
|
|
51
|
+
if (successKiller) {
|
|
52
|
+
promisesToWaitFor.push(successKiller());
|
|
53
|
+
(0, _1.setSuccessKiller)(null);
|
|
54
|
+
}
|
|
55
|
+
runningKillProcessesPromise = Promise.all(promisesToWaitFor)
|
|
56
|
+
.then(() => {
|
|
57
|
+
runningKillProcessesPromise = null;
|
|
58
|
+
return currentCompilationId;
|
|
59
|
+
})
|
|
60
|
+
.catch((error) => {
|
|
61
|
+
console.error("Error killing processes:", error);
|
|
62
|
+
runningKillProcessesPromise = null;
|
|
63
|
+
return currentCompilationId;
|
|
64
|
+
});
|
|
65
|
+
return runningKillProcessesPromise;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=killer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"killer.js","sourceRoot":"","sources":["../src/killer.ts"],"names":[],"mappings":";;;;;AAiBA,oBAqBC;AAID,sCA4BC;AAtED,sDAA6B;AAC7B,8DAAgC;AAChC,iDAAmD;AACnD,wBAAuD;AAEvD,IAAI,WAAW,GAAG,IAAI,CAAC,CAAC,UAAU;AAClC,IAAI,KAAK,GAAG,IAAI,CAAC;AAEjB,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;AAE/C,4DAA4D;AAC5D,IAAA,oBAAI,EAAC,IAAI,EAAE,UAAU,KAAK;IACxB,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,GAAG,KAAK,CAAC;IAChB,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,SAAgB,IAAI,CAAC,KAAmB;IACtC,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QACnC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;YACf,OAAO,EAAE,CAAC;YACV,OAAO;QACT,CAAC;QAED,IAAI,SAAS,EAAE,CAAC;YACd,IAAA,oBAAI,EAAC,iBAAiB,KAAK,CAAC,GAAG,QAAQ,EAAE,GAAG,EAAE,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CAAC;SACzD,IAAI,CAAC,GAAG,EAAE;QACT,2BAA2B,GAAG,IAAI,CAAC;QACnC,OAAO,oBAAoB,CAAC;IAC9B,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACf,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;QACjD,2BAA2B,GAAG,IAAI,CAAC;QACnC,OAAO,oBAAoB,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEL,OAAO,2BAA2B,CAAC;AACrC,CAAC"}
|
package/dist/runner.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAcA,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAOvD"}
|
package/dist/runner.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.run = run;
|
|
7
|
+
const cross_spawn_1 = __importDefault(require("cross-spawn"));
|
|
8
|
+
const string_argv_1 = __importDefault(require("string-argv"));
|
|
9
|
+
const killer_1 = require("./killer");
|
|
10
|
+
function runCommand(fullCommand) {
|
|
11
|
+
const parts = (0, string_argv_1.default)(fullCommand);
|
|
12
|
+
const exec = parts[0];
|
|
13
|
+
const args = parts.splice(1);
|
|
14
|
+
return (0, cross_spawn_1.default)(exec, args, {
|
|
15
|
+
stdio: "inherit",
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function run(command) {
|
|
19
|
+
const process = runCommand(command);
|
|
20
|
+
const exitPromise = new Promise((resolve) => process.on("exit", resolve));
|
|
21
|
+
return () => Promise.all([(0, killer_1.kill)(process), exitPromise]);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":";;;;;AAcA,kBAOC;AApBD,8DAAgC;AAChC,8DAAqC;AACrC,qCAAgC;AAEhC,SAAS,UAAU,CAAC,WAAmB;IACrC,MAAM,KAAK,GAAa,IAAA,qBAAU,EAAC,WAAW,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACtB,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7B,OAAO,IAAA,qBAAK,EAAC,IAAI,EAAE,IAAI,EAAE;QACvB,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,GAAG,CAAC,OAAe;IACjC,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAChD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAC5B,CAAC;IAEF,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAA,aAAI,EAAC,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type TPrintParams = {
|
|
2
|
+
noColors?: boolean;
|
|
3
|
+
noClear?: boolean;
|
|
4
|
+
requestedToListEmittedFiles?: boolean;
|
|
5
|
+
signalEmittedFiles?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function print(line: string, { noColors, noClear, requestedToListEmittedFiles, signalEmittedFiles, }?: TPrintParams): void;
|
|
8
|
+
export declare function deleteClear(line: string): string;
|
|
9
|
+
export declare function manipulate(line: string): string;
|
|
10
|
+
export declare function detectState(line: string): {
|
|
11
|
+
compilationStarted: boolean;
|
|
12
|
+
compilationError: boolean;
|
|
13
|
+
compilationComplete: boolean;
|
|
14
|
+
fileEmitted: string | null;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=stdout-manipulator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdout-manipulator.d.ts","sourceRoot":"","sources":["../src/stdout-manipulator.ts"],"names":[],"mappings":"AAkFA,KAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAKF,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EACZ,EACE,QAAgB,EAChB,OAAe,EACf,2BAAmC,EACnC,kBAA0B,GAC3B,GAAE,YAAiB,GACnB,IAAI,CA+BN;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAShD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM;;;;;EAwBvC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.print = print;
|
|
7
|
+
exports.deleteClear = deleteClear;
|
|
8
|
+
exports.manipulate = manipulate;
|
|
9
|
+
exports.detectState = detectState;
|
|
10
|
+
const sheu_1 = __importDefault(require("./utils/sheu"));
|
|
11
|
+
const ANSI_REGEX = new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))", "g");
|
|
12
|
+
const stripAnsi = (str) => str.replace(ANSI_REGEX, "");
|
|
13
|
+
const tscUsageSyntaxRegex = / -w, --watch.*Watch input files\./;
|
|
14
|
+
const typescriptPrettyErrorRegex = /:\d+:\d+ \- error TS\d+: /;
|
|
15
|
+
const typescriptErrorRegex = /\(\d+,\d+\): error TS\d+: /;
|
|
16
|
+
const typescriptEmittedFileRegex = /(TSFILE:)\s*(.*)/;
|
|
17
|
+
// errors
|
|
18
|
+
const compilationCompleteWithErrorRegex = / Found [^0][0-9]* error[s]?\. Watching for file changes\./;
|
|
19
|
+
const nativeCompilationCompleteWithErrorRegex = /Found [^0]?\d* error[s]? in /;
|
|
20
|
+
// no errors
|
|
21
|
+
const compilationCompleteWithoutErrorRegex = / Found 0 errors\. Watching for file changes\./;
|
|
22
|
+
// compilation started
|
|
23
|
+
const compilationStartedRegex = /( Starting compilation in watch mode\.\.\.| File change detected\. Starting incremental compilation\.\.\.)/;
|
|
24
|
+
const nativeCompilationStartedRegex = /build starting at /;
|
|
25
|
+
// compilation complete
|
|
26
|
+
const compilationCompleteRegex = /( Compilation complete\. Watching for file changes\.| Found \d+ error[s]?\. Watching for file changes\.)/;
|
|
27
|
+
const nativeCompilationCompleteRegex = /build finished in /;
|
|
28
|
+
const newAdditionToSyntax = [
|
|
29
|
+
" -w, --watch Watch input files. [on by default, use --noWatch to disable]",
|
|
30
|
+
" --onSuccess COMMAND Executes `COMMAND` on **every successful** compilation.",
|
|
31
|
+
" --onFirstSuccess COMMAND Executes `COMMAND` on the **first successful** compilation.",
|
|
32
|
+
" --onFailure COMMAND Executes `COMMAND` on **every failed** compilation.",
|
|
33
|
+
" --onEmit COMMAND Executes debounced `COMMAND` on **every emitted file**, ignoring unchanged files and disregards compilation success or failure.",
|
|
34
|
+
" --onEmitDebounceMs DELAY Delay by which to debounce `--onEmit` (default: 300).",
|
|
35
|
+
" --onCompilationStarted COMMAND Executes `COMMAND` on **every compilation start** event.",
|
|
36
|
+
" --onCompilationComplete COMMAND Executes `COMMAND` on **every successful or failed** compilation.",
|
|
37
|
+
" --noColors Removes the red/green colors from the compiler output",
|
|
38
|
+
" --noClear Prevents the compiler from clearing the screen",
|
|
39
|
+
" --compiler PATH The PATH will be used instead of typescript compiler. Defaults typescript/bin/tsc.",
|
|
40
|
+
].join("\n");
|
|
41
|
+
function color(line, noClear = false) {
|
|
42
|
+
// coloring errors:
|
|
43
|
+
line = line.replace(typescriptErrorRegex, (m) => `\u001B[36m${m}\u001B[39m`); // Cyan
|
|
44
|
+
line = line.replace(typescriptPrettyErrorRegex, (m) => `\u001B[36m${m}\u001B[39m`); // Cyan
|
|
45
|
+
// completed with error:
|
|
46
|
+
line = line.replace(compilationCompleteWithErrorRegex, (m) => `\u001B[31m${m}\u001B[39m`); // Red
|
|
47
|
+
line = line.replace(nativeCompilationCompleteWithErrorRegex, (m) => `\u001B[31m${m}\u001B[39m`); // Red
|
|
48
|
+
// completed without error:
|
|
49
|
+
line = line.replace(compilationCompleteWithoutErrorRegex, (m) => `\u001B[32m${m}\u001B[39m`); // Green
|
|
50
|
+
// usage
|
|
51
|
+
line = line.replace(tscUsageSyntaxRegex, (m) => `\u001B[33m${m}\u001B[39m`); // Yellow
|
|
52
|
+
if (noClear && compilationStartedRegex.test(line)) {
|
|
53
|
+
return "\n\n----------------------\n" + line;
|
|
54
|
+
}
|
|
55
|
+
return line;
|
|
56
|
+
}
|
|
57
|
+
let tsErrorMessagePrinted = false;
|
|
58
|
+
let prevLine = "";
|
|
59
|
+
function print(line, { noColors = false, noClear = false, requestedToListEmittedFiles = false, signalEmittedFiles = false, } = {}) {
|
|
60
|
+
if (signalEmittedFiles &&
|
|
61
|
+
!requestedToListEmittedFiles &&
|
|
62
|
+
line.startsWith("TSFILE:")) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (!line &&
|
|
66
|
+
(prevLine.includes("Starting") || prevLine.includes("Found 0 Errors")))
|
|
67
|
+
return;
|
|
68
|
+
if (line.includes("Starting") || line.includes("Found 0 errors")) {
|
|
69
|
+
tsErrorMessagePrinted = false;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (line.includes(": error TS") && !tsErrorMessagePrinted) {
|
|
73
|
+
console.error(`[${sheu_1.default.red("Error")}] Unable to compile TypeScript:`);
|
|
74
|
+
tsErrorMessagePrinted = true;
|
|
75
|
+
}
|
|
76
|
+
if (line.includes("Founnd ") || line.includes(" errors."))
|
|
77
|
+
line = sheu_1.default.red(line.split(" - ")[1]);
|
|
78
|
+
if (line)
|
|
79
|
+
prevLine = line;
|
|
80
|
+
console.log(noColors ? line : color(line, noClear));
|
|
81
|
+
}
|
|
82
|
+
function deleteClear(line) {
|
|
83
|
+
// '\x1bc11:40:16 - Starting compilation in watch mode...'
|
|
84
|
+
// '\x1b[2J\x1b[3J\x1b[H11:33:28 - Starting compilation in watch mode...'
|
|
85
|
+
const result = line
|
|
86
|
+
.replace(/^\x1b\[2J/, "")
|
|
87
|
+
.replace(/^\x1b\[3J/, "")
|
|
88
|
+
.replace(/^\x1b\[H/, "")
|
|
89
|
+
.replace(/^\x1bc/, "");
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
function manipulate(line) {
|
|
93
|
+
return line.replace(tscUsageSyntaxRegex, newAdditionToSyntax);
|
|
94
|
+
}
|
|
95
|
+
function detectState(line) {
|
|
96
|
+
const clearLine = stripAnsi(line);
|
|
97
|
+
const compilationStarted = compilationStartedRegex.test(clearLine) ||
|
|
98
|
+
nativeCompilationStartedRegex.test(clearLine);
|
|
99
|
+
const compilationError = compilationCompleteWithErrorRegex.test(clearLine) ||
|
|
100
|
+
nativeCompilationCompleteWithErrorRegex.test(clearLine) ||
|
|
101
|
+
typescriptErrorRegex.test(clearLine) ||
|
|
102
|
+
typescriptPrettyErrorRegex.test(clearLine);
|
|
103
|
+
const compilationComplete = compilationCompleteRegex.test(clearLine) ||
|
|
104
|
+
nativeCompilationCompleteRegex.test(clearLine);
|
|
105
|
+
const fileEmittedExec = typescriptEmittedFileRegex.exec(clearLine);
|
|
106
|
+
const fileEmitted = fileEmittedExec !== null ? fileEmittedExec[2] : null; // if the regex is not null it will return an array with 3 elements
|
|
107
|
+
return {
|
|
108
|
+
compilationStarted,
|
|
109
|
+
compilationError,
|
|
110
|
+
compilationComplete,
|
|
111
|
+
fileEmitted,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=stdout-manipulator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdout-manipulator.js","sourceRoot":"","sources":["../src/stdout-manipulator.ts"],"names":[],"mappings":";;;;;AA4FA,sBAuCC;AAED,kCASC;AAED,gCAEC;AAED,kCAwBC;AA5KD,wDAAgC;AAEhC,MAAM,UAAU,GAAG,IAAI,MAAM,CAC3B,uLAAuL,EACvL,GAAG,CACJ,CAAC;AACF,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AAE/D,MAAM,mBAAmB,GAAG,mCAAmC,CAAC;AAChE,MAAM,0BAA0B,GAAG,2BAA2B,CAAC;AAC/D,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AAC1D,MAAM,0BAA0B,GAAG,kBAAkB,CAAC;AAEtD,SAAS;AACT,MAAM,iCAAiC,GACrC,2DAA2D,CAAC;AAC9D,MAAM,uCAAuC,GAAG,8BAA8B,CAAC;AAE/E,YAAY;AACZ,MAAM,oCAAoC,GACxC,+CAA+C,CAAC;AAElD,sBAAsB;AACtB,MAAM,uBAAuB,GAC3B,4GAA4G,CAAC;AAE/G,MAAM,6BAA6B,GAAG,oBAAoB,CA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AAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,mEAAmE;IAE7I,OAAO;QACL,kBAAkB;QAClB,gBAAgB;QAChB,mBAAmB;QACnB,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export default class sheu {
|
|
2
|
+
static red(text: string): string;
|
|
3
|
+
static green(text: string): string;
|
|
4
|
+
static yellow(text: string): string;
|
|
5
|
+
static blue(text: string): string;
|
|
6
|
+
static magenta(text: string): string;
|
|
7
|
+
static cyan(text: string): string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=sheu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sheu.d.ts","sourceRoot":"","sources":["../../src/utils/sheu.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,IAAI;IACvB,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIhC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIlC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAInC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIjC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAIpC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAGlC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class sheu {
|
|
4
|
+
static red(text) {
|
|
5
|
+
return `\x1b[31m${text}\x1b[0m`;
|
|
6
|
+
}
|
|
7
|
+
static green(text) {
|
|
8
|
+
return `\x1b[32m${text}\x1b[0m`;
|
|
9
|
+
}
|
|
10
|
+
static yellow(text) {
|
|
11
|
+
return `\x1b[33m${text}\x1b[0m`;
|
|
12
|
+
}
|
|
13
|
+
static blue(text) {
|
|
14
|
+
return `\x1b[34m${text}\x1b[0m`;
|
|
15
|
+
}
|
|
16
|
+
static magenta(text) {
|
|
17
|
+
return `\x1b[35m${text}\x1b[0m`;
|
|
18
|
+
}
|
|
19
|
+
static cyan(text) {
|
|
20
|
+
return `\x1b[36m${text}\x1b[0m`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.default = sheu;
|
|
24
|
+
//# sourceMappingURL=sheu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sheu.js","sourceRoot":"","sources":["../../src/utils/sheu.ts"],"names":[],"mappings":";;AAAA,MAAqB,IAAI;IACvB,MAAM,CAAC,GAAG,CAAC,IAAY;QACrB,OAAO,WAAW,IAAI,SAAS,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,IAAY;QACvB,OAAO,WAAW,IAAI,SAAS,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,IAAY;QACxB,OAAO,WAAW,IAAI,SAAS,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,IAAY;QACtB,OAAO,WAAW,IAAI,SAAS,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,IAAY;QACzB,OAAO,WAAW,IAAI,SAAS,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,IAAY;QACtB,OAAO,WAAW,IAAI,SAAS,CAAC;IAClC,CAAC;CACF;AAxBD,uBAwBC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tsx-strict",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Type-safe TSX runner with automatic Type-checking",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"tsx-strict": "./bin/strict.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "npx rimraf dist && tsc",
|
|
12
|
+
"prepublishOnly": "npm run build",
|
|
13
|
+
"postbuild": "npx rimraf dist/examples",
|
|
14
|
+
"dev": "ts-node-dev src/cli.ts src/examples/development/src/app.ts",
|
|
15
|
+
"start": "node bin/tsx-strict.js src/examples/development/src/app.ts",
|
|
16
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
17
|
+
"clean": "npx rimraf dist",
|
|
18
|
+
"typecheck": "tsc --noEmit"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"tsx",
|
|
22
|
+
"typescript",
|
|
23
|
+
"type-checking",
|
|
24
|
+
"cli",
|
|
25
|
+
"runner",
|
|
26
|
+
"type-safe"
|
|
27
|
+
],
|
|
28
|
+
"author": "Uanela Como",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/uanela/tsx-strict.git"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/uanela/tsx-strict/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/uanela/tsx-strict#readme",
|
|
38
|
+
"files": ["dist", "bin", "README.md", "LICENSE"],
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=20.0.0"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"tsx": "^4.20.5"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/cross-spawn": "^6.0.6",
|
|
47
|
+
"@types/node": "^18.0.0",
|
|
48
|
+
"@types/node-cleanup": "^2.1.5",
|
|
49
|
+
"@types/ps-tree": "^1.1.6",
|
|
50
|
+
"rimraf": "^5.0.0",
|
|
51
|
+
"ts-node-dev": "^2.0.0",
|
|
52
|
+
"typescript": "^5.3.0"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"commander": "^14.0.0",
|
|
56
|
+
"cross-spawn": "^7.0.6",
|
|
57
|
+
"node-cleanup": "^2.1.2",
|
|
58
|
+
"ps-tree": "^1.2.0",
|
|
59
|
+
"string-argv": "^0.3.2"
|
|
60
|
+
}
|
|
61
|
+
}
|