uni-run 1.1.25 → 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 +100 -149
  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 -97
  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,194 +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 Ctrl+R or F5.
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
24
  ```sh
30
- run script.ext [options] -- [args for internal bin]
31
- uni-run script.ext [options] -- [args for internal bin]
32
- rux script.ext [options] -- [args for internal bin]
33
- uni-rux script.ext [options] -- [args for internal bin]
25
+ run <script> [options] -- [args for script]
26
+ uni-run <script> [options] -- [args for script]
34
27
  ```
35
28
 
36
- Note: `rux` and `uni-rux` run scripts once and exit (no watch mode by default).
37
-
38
- ### Examples
39
-
40
- #### Running a JavaScript File
29
+ `rux` / `uni-rux` are aliases that run once and exit (no watch mode, keeps console output):
41
30
 
42
31
  ```sh
43
- run ./scripts/main.js
32
+ rux <script> [options] -- [args for script]
33
+ uni-rux <script> [options] -- [args for script]
44
34
  ```
45
35
 
46
- #### Running a TypeScript File
36
+ ### Examples
47
37
 
48
38
  ```sh
49
- run ./scripts/main.ts
39
+ run ./main.ts
40
+ run ./main.py
41
+ run ./Main.java
42
+ run ./hello.c
43
+ run ./main.js -- --port 3000
50
44
  ```
51
45
 
52
- #### Running a Python File
46
+ ### Subcommands
53
47
 
54
48
  ```sh
55
- run ./scripts/main.py
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
56
52
  ```
57
53
 
58
- #### Running a Java File
54
+ ## Options
59
55
 
60
- ```sh
61
- run ./scripts/Main.java
62
- ```
56
+ ### Watch Mode
63
57
 
64
- #### Running with script argv
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) |
65
65
 
66
- ```sh
67
- run ./scripts/main.js -- --some someValue
68
- ```
66
+ ### Reload / Console
69
67
 
70
- Here `--some someValue` will be passed to `node` and will be ignored by `uni-run`.
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 |
71
74
 
72
- #### Executing with a custom binary
75
+ ### Execution
73
76
 
74
- ```sh
75
- run exec python ./scripts/custom.py
76
- run exec custom-binary arg1 arg2
77
- ```
78
-
79
- #### Listing supported scripts
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` |
80
84
 
81
- ```sh
82
- run list
83
- ```
85
+ ### Benchmarking / Info
84
86
 
85
- #### Cleaning cache
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 |
86
93
 
87
- ```sh
88
- run clean
89
- ```
94
+ ## Configuration
90
95
 
91
- ## Define Custom Configuration
92
-
93
- Create `.uni-run.json` file in your user home directory or current working directory.
96
+ Create `~/.uni-run.json` to override default runtimes:
94
97
 
95
98
  ```json
96
99
  {
97
- "javascript-runtime": "bun",
98
- "typescript-runtime": "deno"
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
+ }
99
106
  }
100
107
  ```
101
108
 
102
- Now you can run your script with `run script.js` or `run script.ts` with your own runtime.
103
-
104
- ## Setup Custom Executors
105
-
106
- Create `.uni-run.cjs` file in your user home directory or current working directory.
107
- NOTE: Your custom executors will have more priority than the default executors.
108
-
109
- ```js
110
- module.exports = [
111
- {
112
- name: 'Name',
113
- exts: ['ext'],
114
- getRuntime(args, options, config) {
115
- return {
116
- exec: ['YOUR_BIN', ...args],
117
- }
118
- },
119
- },
120
- ]
121
- ```
122
-
123
- Now you can run your script with `run script.ext`.
124
-
125
- ## API
126
-
127
- The `uni-run` package provides a simple API to manage and execute scripts.
128
-
129
- #### `addExecutorBefore(options: ExecutorOptions)` or `addExecutorAfter(options: ExecutorOptions)`:
130
-
131
- 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.
132
-
133
- ```typescript
134
- import uniRun from 'uni-run'
135
-
136
- uniRun.addExecutorBefore({
137
- name: 'Name',
138
- exts: ['ext'],
139
- getRuntime(args, options, config) {
140
- return {
141
- exec: ['YOUR_BIN', ...args],
142
- }
143
- },
144
- })
145
- ```
146
-
147
- #### `start(args?: string[])`:
148
-
149
- Starts the application with the provided arguments. If no arguments are provided, it inherits from CLI.
150
-
151
- ```typescript
152
- import uniRun from 'uni-run'
153
-
154
- uniRun.start(['arg1', 'arg2'])
155
- ```
156
-
157
- ### Exports
158
-
159
- The package also exports the following utilities:
160
-
161
- - `currentModule` - Get the current module information
162
- - `getConfig(cwd?: string)` - Get configuration from `.uni-run.json`
163
- - `getUserExecutors(cwd?: string)` - Get user-defined executors from `.uni-run.cjs`
164
- - `ScriptExecutorOptions` and other types from `./scriptExecutors/types.t`
165
-
166
- ```typescript
167
- import { getConfig, getUserExecutors } from 'uni-run'
168
-
169
- const config = getConfig('/path/to/project')
170
- const executors = getUserExecutors('/path/to/project')
171
- ```
172
-
173
- ### Example Usage
174
-
175
- ```typescript
176
- import uniRun from 'uni-run'
177
-
178
- // Add the Executor to uni-run
179
- uniRun.addExecutorBefore({
180
- name: 'Name',
181
- exts: ['ext'],
182
- getRuntime(args, options, config) {
183
- return {
184
- exec: ['YOUR_BIN', ...args],
185
- }
186
- },
187
- })
188
-
189
- // Start the application with arguments
190
- uniRun.start(['arg1.some'])
191
-
192
- // Or inherit from CLI
193
- uniRun.start()
194
- ```
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.