uni-run 1.1.24 → 2.0.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.
Files changed (64) hide show
  1. package/README.md +103 -113
  2. package/dist/app-31LC_vYS.js +28304 -0
  3. package/dist/app-31LC_vYS.js.map +1 -0
  4. package/dist/app-IwNLL71t.mjs +28239 -0
  5. package/dist/app-IwNLL71t.mjs.map +1 -0
  6. package/dist/run.cjs +5 -0
  7. package/dist/run.cjs.map +1 -0
  8. package/dist/run.d.cts +1 -0
  9. package/dist/run.d.mts +1 -0
  10. package/dist/run.mjs +6 -0
  11. package/dist/run.mjs.map +1 -0
  12. package/dist/rux.cjs +6 -0
  13. package/dist/rux.cjs.map +1 -0
  14. package/dist/rux.d.cts +1 -0
  15. package/dist/rux.d.mts +1 -0
  16. package/dist/rux.mjs +7 -0
  17. package/dist/rux.mjs.map +1 -0
  18. package/package.json +54 -30
  19. package/dist/app.d.ts +0 -1
  20. package/dist/app.js +0 -94
  21. package/dist/arg.d.ts +0 -229
  22. package/dist/arg.js +0 -18
  23. package/dist/argHelper.d.ts +0 -108
  24. package/dist/argHelper.js +0 -94
  25. package/dist/bin.d.ts +0 -2
  26. package/dist/bin.js +0 -6
  27. package/dist/bix.d.ts +0 -2
  28. package/dist/bix.js +0 -8
  29. package/dist/execution/gitignore.d.ts +0 -1
  30. package/dist/execution/gitignore.js +0 -40
  31. package/dist/execution/index.d.ts +0 -21
  32. package/dist/execution/index.js +0 -177
  33. package/dist/execution/kill-process.d.ts +0 -2
  34. package/dist/execution/kill-process.js +0 -50
  35. package/dist/execution/watcher.d.ts +0 -6
  36. package/dist/execution/watcher.js +0 -60
  37. package/dist/helpers/as.d.ts +0 -1
  38. package/dist/helpers/as.js +0 -6
  39. package/dist/helpers/debounce.d.ts +0 -1
  40. package/dist/helpers/debounce.js +0 -10
  41. package/dist/helpers/getConfig.d.ts +0 -1
  42. package/dist/helpers/getConfig.js +0 -26
  43. package/dist/helpers/getUserExecutors.d.ts +0 -2
  44. package/dist/helpers/getUserExecutors.js +0 -18
  45. package/dist/helpers/os.d.ts +0 -7
  46. package/dist/helpers/os.js +0 -8
  47. package/dist/helpers/utils.d.ts +0 -3
  48. package/dist/helpers/utils.js +0 -28
  49. package/dist/index.d.ts +0 -13
  50. package/dist/index.js +0 -41
  51. package/dist/lib/colors.d.ts +0 -3
  52. package/dist/lib/colors.js +0 -32
  53. package/dist/lib/currentModule.d.ts +0 -5
  54. package/dist/lib/currentModule.js +0 -19
  55. package/dist/local-env.d.ts +0 -4
  56. package/dist/local-env.js +0 -11
  57. package/dist/scriptExecutors/checkRuntime.d.ts +0 -2
  58. package/dist/scriptExecutors/checkRuntime.js +0 -56
  59. package/dist/scriptExecutors/helpers.d.ts +0 -3
  60. package/dist/scriptExecutors/helpers.js +0 -22
  61. package/dist/scriptExecutors/index.d.ts +0 -3
  62. package/dist/scriptExecutors/index.js +0 -313
  63. package/dist/scriptExecutors/types.t.d.ts +0 -17
  64. package/dist/scriptExecutors/types.t.js +0 -2
package/README.md CHANGED
@@ -1,155 +1,145 @@
1
1
  # uni-run
2
2
 
3
- `uni-run` is a versatile CLI tool designed to run various types of scripts, including but not limited to JavaScript, TypeScript, Python, Java, HTML, SASS, Lua, and more. It provides a unified interface to execute scripts with additional features like watching for file changes, benchmarking execution time, and more.
3
+ A universal CLI tool to run scripts in any language JavaScript, TypeScript, Python, Java, C, C++, Rust, Go, Ruby, PHP, Dart, Lua, and more. One command, any script, with watch mode, benchmarking, and automatic runtime detection.
4
4
 
5
5
  ## Features
6
6
 
7
- - **Watch Mode**: Automatically re-run scripts when files change.
8
- - **Benchmarking**: Measure and display the execution time of scripts.
9
- - **Environment Variables**: Set environment variables for script execution.
10
- - **Shell Execution**: Run scripts in a shell for more control.
11
- - **Console Clearing**: Clear the console before running the script.
12
- - **Reload Key**: Enable reloading the script with a specific key combination.
13
- - **Information Display**: Show detailed information about the script execution.
7
+ - **19+ languages** supported out of the box, including compiled languages (C, C++, Rust, C#)
8
+ - **Watch mode** automatically re-runs on file changes with `.gitignore`-aware filtering
9
+ - **Reload keys** press Ctrl+R or F5 to re-run without saving
10
+ - **Benchmarking** measure execution time with `--bench`
11
+ - **Configurable runtimes** swap between `node`/`bun`/`deno`, `python`/`uv`, and more via `~/.uni-run.json`
12
+ - **Environment variables** inject env vars with `--env KEY=VALUE`
13
+ - **Exec mode** run any arbitrary binary with `run exec`
14
+ - **Cross-platform** — works on Windows, macOS, and Linux
14
15
 
15
16
  ## Installation
16
17
 
17
- To install `uni-run`, use npm:
18
-
19
18
  ```sh
20
19
  npm install -g uni-run
21
20
  ```
22
21
 
23
22
  ## CLI Usage
24
23
 
25
- ### Basic Command
26
-
27
- To run a script, use the following command:
28
-
29
- ```sh
30
- run script.ext [options] -- [args for internal bin]
31
- uni-run script.ext [options] -- [args for internal bin]
32
- ```
33
-
34
- ### Examples
35
-
36
- #### Running a JavaScript File
37
-
38
- ```sh
39
- run ./scripts/main.js
40
- ```
41
-
42
- #### Running a TypeScript File
43
-
44
24
  ```sh
45
- run ./scripts/main.ts
25
+ run <script> [options] -- [args for script]
26
+ uni-run <script> [options] -- [args for script]
46
27
  ```
47
28
 
48
- #### Running a Python File
29
+ `rux` / `uni-rux` are aliases that run once and exit (no watch mode, keeps console output):
49
30
 
50
31
  ```sh
51
- run ./scripts/main.py
32
+ rux <script> [options] -- [args for script]
33
+ uni-rux <script> [options] -- [args for script]
52
34
  ```
53
35
 
54
- #### Running a Java File
36
+ ### Examples
55
37
 
56
38
  ```sh
57
- run ./scripts/Main.java
39
+ run ./main.ts
40
+ run ./main.py
41
+ run ./Main.java
42
+ run ./hello.c
43
+ run ./main.js -- --port 3000
58
44
  ```
59
45
 
60
- #### Running with script argv
46
+ ### Subcommands
61
47
 
62
48
  ```sh
63
- run ./scripts/main.js -- --some someValue
64
- ```
65
-
66
- Here `--some someValue` will be passed to `node` and will be ignored by `uni-run`.
67
-
68
- ## Define Custom Configuration
69
-
70
- Create `.uni-run.json` file in your user home directory or current working directory.
71
-
72
- ```json
73
- {
74
- "javascript-runtime": "bun",
75
- "typescript-runtime": "deno"
76
- }
49
+ run exec <binary> [args] # Execute an arbitrary binary
50
+ run list # List all supported script types
51
+ run clean # Clean the temp/cache directory
77
52
  ```
78
53
 
79
- Now you can run your script with `run script.js` or `run script.ts` with your own runtime.
80
-
81
- ## Setup Custom Executors
82
-
83
- Create `.uni-run.cjs` file in your user home directory or current working directory.
84
- NOTE: Your custom executors will have more priority than the default executors.
85
-
86
- ```js
87
- module.exports = [
88
- {
89
- name: 'Name',
90
- exts: ['ext'],
91
- getRuntime(args, options, config) {
92
- return {
93
- exec: ['YOUR_BIN', ...args],
94
- }
95
- },
96
- },
97
- ]
98
- ```
54
+ ## Options
99
55
 
100
- Now you can run your script with `run script.ext`.
56
+ ### Watch Mode
101
57
 
102
- ## API
58
+ | Flag | Alias | Description |
59
+ | ------------------------ | ----- | ------------------------------------------- |
60
+ | `--do-not-watch` | `-dw` | Disable watch mode |
61
+ | `--ext <exts...>` | `-e` | Watch only specific extensions |
62
+ | `--focus <paths...>` | `-f` | Watch only specific paths (chokidar syntax) |
63
+ | `--ignore <patterns...>` | `-ig` | Exclude paths (.gitignore syntax) |
64
+ | `--delay <ms>` | `-d` | Debounce delay in ms (default: 100) |
103
65
 
104
- The `uni-run` package provides a simple API to manage and execute scripts.
66
+ ### Reload / Console
105
67
 
106
- #### `addExecutorBefore(options: ExecutorOptions)` or `addExecutorAfter(options: ExecutorOptions)`:
68
+ | Flag | Alias | Description |
69
+ | ---------------------- | ------ | ----------------------------- |
70
+ | `--disable-reload-key` | `-dk` | Disable Ctrl+R / F5 reload |
71
+ | `--disable-raw-stdin` | `-drs` | Disable raw stdin mode |
72
+ | `--keep` | `-k` | Don't clear console on reload |
73
+ | `--silent` | `-s` | Suppress script output |
107
74
 
108
- Both methods add an executor to the list of executors. The `addExecutorBefore` method adds the executor before the default executors, while the `addExecutorAfter` method adds the executor after the default executors. This means that the executor will be used before or after checking the default executors.
75
+ ### Execution
109
76
 
110
- ```typescript
111
- import uniRun from 'uni-run'
77
+ | Flag | Description |
78
+ | ---------------------- | ------------------------------------- |
79
+ | `--exit` | Run once and exit (default for `rux`) |
80
+ | `--shell` | Run in shell mode |
81
+ | `--cwd <path>` | Set working directory |
82
+ | `--env <KEY=VALUE...>` | Set environment variables |
83
+ | `--node-dev` | Set `NODE_ENV=development` |
112
84
 
113
- uniRun.addExecutorBefore({
114
- name: 'Name',
115
- exts: ['ext'],
116
- getRuntime(args, options, config) {
117
- return {
118
- exec: ['YOUR_BIN', ...args],
119
- }
120
- },
121
- })
122
- ```
85
+ ### Benchmarking / Info
123
86
 
124
- #### `start(args?: string[])`:
87
+ | Flag | Alias | Description |
88
+ | ----------------------- | ----- | ---------------------------------- |
89
+ | `--bench` | `-b` | Show execution time |
90
+ | `--bench-prefix <text>` | `-bp` | Custom prefix for benchmark output |
91
+ | `--info` | | Show execution information |
92
+ | `--time` | | Show start time |
125
93
 
126
- Starts the application with the provided arguments.
94
+ ## Configuration
127
95
 
128
- ```typescript
129
- import uniRun from 'uni-run'
96
+ Create `~/.uni-run.json` to override default runtimes:
130
97
 
131
- uniRun.start(['arg1', 'arg2'])
98
+ ```json
99
+ {
100
+ "$schema": "https://github.com/NazmusSayad/uni-run/raw/refs/heads/main/public/uni-run.schema.json",
101
+ "runtime": {
102
+ "python": "uv",
103
+ "javascript": "bun",
104
+ "typescript": "deno"
105
+ }
106
+ }
132
107
  ```
133
108
 
134
- ### Example Usage
135
-
136
- ```typescript
137
- import uniRun from 'uni-run'
138
-
139
- // Add the Executor to uni-run
140
- uniRun.addExecutorBefore({
141
- name: 'Name',
142
- exts: ['ext'],
143
- getRuntime(args, options, config) {
144
- return {
145
- exec: ['YOUR_BIN', ...args],
146
- }
147
- },
148
- })
149
-
150
- // Start the application with arguments
151
- uniRun.start(['arg1.some'])
152
-
153
- // Or inherit from CLI
154
- uniRun.start()
155
- ```
109
+ ### Configurable Runtimes
110
+
111
+ | Language | Options | Default |
112
+ | ---------- | ------------------------------- | ------------ |
113
+ | JavaScript | `node`, `deno`, `bun` | `node` |
114
+ | TypeScript | `tsx`, `ts-node`, `deno`, `bun` | `tsx` |
115
+ | Python | `python`, `python3`, `uv` | `python` |
116
+ | Dart | `dart`, `dartvm` | `dart` |
117
+ | PowerShell | `powershell`, `pwsh` | `powershell` |
118
+ | Shell | `bash`, `zsh`, `sh` | `bash` |
119
+ | Lua | `lua`, `luac`, `luajit` | `lua` |
120
+
121
+ ## Supported Languages
122
+
123
+ | Language | Extensions |
124
+ | ------------------ | ------------------------------------------ |
125
+ | JavaScript | `.js` `.jsx` `.mjs` `.cjs` `.cjsx` `.mjsx` |
126
+ | TypeScript | `.ts` `.tsx` `.mts` `.cts` `.mtsx` `.ctsx` |
127
+ | Python | `.py` |
128
+ | Java | `.java` |
129
+ | Dart | `.dart` |
130
+ | PowerShell | `.ps1` |
131
+ | Command Prompt | `.cmd` `.bat` |
132
+ | Shell Script | `.sh` |
133
+ | Fish Shell | `.fish` |
134
+ | Lua | `.lua` |
135
+ | Ruby | `.rb` |
136
+ | Go | `.go` |
137
+ | C (GCC) | `.c` |
138
+ | C++ (G++) | `.cpp` |
139
+ | C# (Mono) | `.cs` |
140
+ | Rust (rustc) | `.rs` |
141
+ | SASS/SCSS | `.sass` `.scss` |
142
+ | PHP | `.php` |
143
+ | HTML (live-server) | `.html` `.htm` |
144
+
145
+ Compiled languages (C, C++, C#, Rust) are compiled to a temp directory and executed automatically. Use `run clean` to remove compiled artifacts.