numux 2.10.4 → 2.11.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 +122 -61
- package/dist/man/numux.1 +1127 -0
- package/dist/numux.js +667 -128
- package/package.json +6 -3
package/dist/numux.js
CHANGED
|
@@ -31,13 +31,514 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
31
31
|
return to;
|
|
32
32
|
};
|
|
33
33
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
34
|
+
var __returnValue = (v) => v;
|
|
35
|
+
function __exportSetter(name, newValue) {
|
|
36
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
37
|
+
}
|
|
38
|
+
var __export = (target, all) => {
|
|
39
|
+
for (var name in all)
|
|
40
|
+
__defProp(target, name, {
|
|
41
|
+
get: all[name],
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
set: __exportSetter.bind(all, name)
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
34
48
|
var __require = import.meta.require;
|
|
35
49
|
|
|
50
|
+
// src/generated/help-topics.ts
|
|
51
|
+
var TOPIC_ALIASES, HELP_TOPICS;
|
|
52
|
+
var init_help_topics = __esm(() => {
|
|
53
|
+
TOPIC_ALIASES = {
|
|
54
|
+
keys: "keybindings",
|
|
55
|
+
icons: "tab-icons",
|
|
56
|
+
deps: "dependency-orchestration",
|
|
57
|
+
"env-interpolation": "environment-variable-interpolation"
|
|
58
|
+
};
|
|
59
|
+
HELP_TOPICS = {
|
|
60
|
+
install: { title: "Install", body: `Requires [Bun](https://bun.sh) >= 1.0.
|
|
61
|
+
|
|
62
|
+
\`\`\`sh
|
|
63
|
+
bun install -g numux
|
|
64
|
+
\`\`\`` },
|
|
65
|
+
"quick-start": { title: "Quick start", body: `\`\`\`sh
|
|
66
|
+
numux init
|
|
67
|
+
\`\`\`
|
|
68
|
+
|
|
69
|
+
This creates a starter \`numux.config.ts\` with commented-out examples. Edit it, then run \`numux\`.` },
|
|
70
|
+
"config-file": { title: "Config file", body: `Create \`numux.config.ts\` (or \`.js\`):
|
|
71
|
+
|
|
72
|
+
\`\`\`ts
|
|
73
|
+
import { defineConfig } from 'numux'
|
|
74
|
+
|
|
75
|
+
export default defineConfig({
|
|
76
|
+
processes: {
|
|
77
|
+
db: {
|
|
78
|
+
command: 'docker compose up postgres',
|
|
79
|
+
readyPattern: 'ready to accept connections',
|
|
80
|
+
},
|
|
81
|
+
migrate: {
|
|
82
|
+
command: 'bun run migrate',
|
|
83
|
+
dependsOn: ['db'],
|
|
84
|
+
},
|
|
85
|
+
api: {
|
|
86
|
+
command: 'bun run dev:api',
|
|
87
|
+
dependsOn: ['migrate'],
|
|
88
|
+
readyPattern: 'listening on port 3000',
|
|
89
|
+
},
|
|
90
|
+
// String shorthand for simple processes
|
|
91
|
+
web: 'bun run dev:web',
|
|
92
|
+
// Interactive process \u2014 keyboard input is forwarded
|
|
93
|
+
confirm: {
|
|
94
|
+
command: 'sh -c "printf \\'Deploy to staging? [y/n] \\' && read answer && echo $answer"',
|
|
95
|
+
interactive: true,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
})
|
|
99
|
+
\`\`\`
|
|
100
|
+
|
|
101
|
+
The \`defineConfig()\` helper is optional \u2014 it provides type checking for your config.
|
|
102
|
+
|
|
103
|
+
Processes can be a string (shorthand for \`{ command: "..." }\`), \`true\` or \`{}\` (auto-resolves to a matching \`package.json\` script), or a full config object.
|
|
104
|
+
|
|
105
|
+
Then run:
|
|
106
|
+
|
|
107
|
+
\`\`\`sh
|
|
108
|
+
numux
|
|
109
|
+
\`\`\`` },
|
|
110
|
+
subcommands: { title: "Subcommands", body: `<!-- generated:subcommands -->
|
|
111
|
+
\`\`\`sh
|
|
112
|
+
numux init # Create a starter config file
|
|
113
|
+
numux validate # Validate config and show process graph
|
|
114
|
+
numux exec <name> [--] <cmd> # Run a command in a process's environment
|
|
115
|
+
numux logs [name] # Open the log directory or a specific process log
|
|
116
|
+
numux completions <shell> # Generate shell completions (bash, zsh, fish)
|
|
117
|
+
numux help [topic] # Show help for a topic
|
|
118
|
+
\`\`\`
|
|
119
|
+
<!-- /generated:subcommands -->
|
|
120
|
+
|
|
121
|
+
\`validate\` respects \`--only\`/\`--exclude\` filters and shows processes grouped by dependency tiers.
|
|
122
|
+
|
|
123
|
+
\`exec\` runs a one-off command using a process's configured \`cwd\`, \`env\`, and \`envFile\` \u2014 useful for migrations, scripts, or any command that needs the same environment:
|
|
124
|
+
|
|
125
|
+
\`\`\`sh
|
|
126
|
+
numux exec api -- npx prisma migrate
|
|
127
|
+
numux exec web npm run build
|
|
128
|
+
\`\`\`
|
|
129
|
+
|
|
130
|
+
\`logs\` prints the log directory path, or a specific process's log contents:
|
|
131
|
+
|
|
132
|
+
\`\`\`sh
|
|
133
|
+
numux logs # Print log directory path
|
|
134
|
+
numux logs api # Print the api process log
|
|
135
|
+
\`\`\`
|
|
136
|
+
|
|
137
|
+
Set up completions for your shell:
|
|
138
|
+
|
|
139
|
+
\`\`\`sh
|
|
140
|
+
# Bash (add to ~/.bashrc)
|
|
141
|
+
eval "$(numux completions bash)"
|
|
142
|
+
|
|
143
|
+
# Zsh (add to ~/.zshrc)
|
|
144
|
+
eval "$(numux completions zsh)"
|
|
145
|
+
|
|
146
|
+
# Fish
|
|
147
|
+
numux completions fish | source
|
|
148
|
+
# Or save permanently:
|
|
149
|
+
numux completions fish > ~/.config/fish/completions/numux.fish
|
|
150
|
+
\`\`\`` },
|
|
151
|
+
workspaces: { title: "Workspaces", body: `Run a \`package.json\` script across all workspaces in a monorepo:
|
|
152
|
+
|
|
153
|
+
\`\`\`sh
|
|
154
|
+
numux -w dev
|
|
155
|
+
\`\`\`
|
|
156
|
+
|
|
157
|
+
Reads the \`workspaces\` field from your root \`package.json\`, finds which workspaces have the given script, and spawns \`<pm> run <script>\` in each. The package manager is auto-detected from \`packageManager\` field or lockfiles.
|
|
158
|
+
|
|
159
|
+
Composes with other flags:
|
|
160
|
+
|
|
161
|
+
\`\`\`sh
|
|
162
|
+
numux -w dev -n redis="redis-server" --colors
|
|
163
|
+
\`\`\`` },
|
|
164
|
+
"ad-hoc-commands": { title: "Ad-hoc commands", body: `\`\`\`sh
|
|
165
|
+
# Unnamed (name derived from command)
|
|
166
|
+
numux "bun dev:api" "bun dev:web"
|
|
167
|
+
|
|
168
|
+
# Named process
|
|
169
|
+
numux -n api="bun dev:api" -n web="bun dev:web"
|
|
170
|
+
\`\`\`` },
|
|
171
|
+
"script-patterns": { title: "Script patterns", body: `Run package.json scripts by name \u2014 any colon-containing name is automatically recognized as a script reference:
|
|
172
|
+
|
|
173
|
+
\`\`\`sh
|
|
174
|
+
numux 'lint:eslint --fix' # runs: yarn run lint:eslint --fix
|
|
175
|
+
numux 'dev:*' # all scripts matching dev:*
|
|
176
|
+
numux 'npm:*:dev' # explicit npm: prefix (same behavior)
|
|
177
|
+
\`\`\`
|
|
178
|
+
|
|
179
|
+
<!-- generated:script-pattern-rules -->` },
|
|
180
|
+
"script-pattern-rules": { title: "Script pattern rules", body: `**Recognition:** A process name is treated as a script reference when it:
|
|
181
|
+
- starts with \`npm:\` (e.g. \`npm:dev:*\`)
|
|
182
|
+
- contains glob metacharacters (\`*\`, \`?\`, \`[\`)
|
|
183
|
+
- contains a colon AND has no explicit \`command\` (e.g. \`lint:eslint: {}\`)
|
|
184
|
+
|
|
185
|
+
**Glob matching:** Patterns are matched against \`package.json\` scripts using
|
|
186
|
+
\`Bun.Glob\`. The \`*\` wildcard does NOT match across \`:\` separators \u2014 \`dev:*\`
|
|
187
|
+
matches \`dev:web\` but not \`dev:web:hmr\`. Use \`dev:*:*\` for two levels deep.
|
|
188
|
+
|
|
189
|
+
**Leaf-only (\`^\`):** Append \`^\` to skip scripts that are group runners \u2014
|
|
190
|
+
scripts that have sub-scripts beneath them. E.g. if \`format:check\` has
|
|
191
|
+
\`format:check:store\` and \`format:check:odoo\` below it, \`format:*^\` excludes
|
|
192
|
+
\`format:check\` but keeps the leaf scripts.
|
|
193
|
+
|
|
194
|
+
**Extra args:** Anything after the first space in the pattern is forwarded
|
|
195
|
+
as extra arguments to each matched command: \`lint:* --fix\` \u2192 \`bun run lint:js -- --fix\`.
|
|
196
|
+
|
|
197
|
+
**Template inheritance:** Config properties on a pattern entry (color, env,
|
|
198
|
+
dependsOn, etc.) are inherited by all expanded processes. Color arrays are
|
|
199
|
+
distributed round-robin across matches.
|
|
200
|
+
|
|
201
|
+
**Display names:** The glob's literal prefix and suffix are stripped from
|
|
202
|
+
matched script names: \`dev:*\` + \`dev:web\` \u2192 display name \`web\`.` },
|
|
203
|
+
"auto-resolution": { title: "Auto-resolution", body: `When a process has no \`command\` and its name matches a \`package.json\` script,
|
|
204
|
+
the command is auto-resolved to \`<pm> run <name>\`. This works for:
|
|
205
|
+
- \`true\` or \`{}\` shorthand: \`lint: true\` \u2192 \`bun run lint\`
|
|
206
|
+
- Objects without \`command\`: \`typecheck: { dependsOn: ['db'] }\` \u2192 \`bun run typecheck\`` },
|
|
207
|
+
"npm-prefix": { title: "npm: prefix", body: `Commands starting with \`npm:\` are rewritten to use the detected package
|
|
208
|
+
manager: \`npm:dev\` \u2192 \`bun run dev\` (if bun is detected).
|
|
209
|
+
<!-- /generated:script-pattern-rules -->
|
|
210
|
+
|
|
211
|
+
\`\`\`sh
|
|
212
|
+
numux 'lint:* --fix' # \u2192 bun run lint:js --fix, bun run lint:ts --fix
|
|
213
|
+
\`\`\`
|
|
214
|
+
|
|
215
|
+
In a config file, use the pattern as the process name:
|
|
216
|
+
|
|
217
|
+
\`\`\`ts
|
|
218
|
+
export default defineConfig({
|
|
219
|
+
processes: {
|
|
220
|
+
'dev:*': { color: ['green', 'cyan'] },
|
|
221
|
+
'lint:* --fix': {},
|
|
222
|
+
},
|
|
223
|
+
})
|
|
224
|
+
\`\`\`
|
|
225
|
+
|
|
226
|
+
Auto-resolution example:
|
|
227
|
+
|
|
228
|
+
\`\`\`ts
|
|
229
|
+
export default defineConfig({
|
|
230
|
+
processes: {
|
|
231
|
+
lint: true, // \u2192 bun run lint
|
|
232
|
+
typecheck: { dependsOn: ['db'] }, // \u2192 bun run typecheck (with dependency)
|
|
233
|
+
db: 'docker compose up postgres', // explicit command, not resolved
|
|
234
|
+
},
|
|
235
|
+
})
|
|
236
|
+
\`\`\`` },
|
|
237
|
+
options: { title: "Options", body: `<!-- generated:options -->
|
|
238
|
+
| Flag | Description |
|
|
239
|
+
|------|-------------|
|
|
240
|
+
| \`-s,\` \`--sort\` \`<config|alphabetical|topological>\` | Tab display order |
|
|
241
|
+
| \`-w,\` \`--workspace\` \`<script>\` | Run a package.json script across all workspaces |
|
|
242
|
+
| \`-n,\` \`--name\` \`<name=command>\` | Add a named process |
|
|
243
|
+
| \`-c,\` \`--color\` \`<colors>\` | Comma-separated colors (hex or names: black, red, green, yellow, blue, magenta, cyan, white, gray, orange, purple) |
|
|
244
|
+
| \`--colors\` | Auto-assign colors to processes based on their name |
|
|
245
|
+
| \`-e,\` \`--env-file\` \`<path|false>\` | Env file path, or "false" to disable env file loading |
|
|
246
|
+
| \`--config\` \`<path>\` | Config file path (default: auto-detect) |
|
|
247
|
+
| \`-p,\` \`--prefix\` | Prefixed output mode (no TUI, for CI/scripts) |
|
|
248
|
+
| \`--only\` \`<a,b,...>\` | Only run these processes (+ their dependencies) |
|
|
249
|
+
| \`--exclude\` \`<a,b,...>\` | Exclude these processes |
|
|
250
|
+
| \`--kill-others\` | Kill all processes when any exits (regardless of exit code) |
|
|
251
|
+
| \`--kill-others-on-fail\` | Kill all processes when any exits with non-zero code |
|
|
252
|
+
| \`--max-restarts\` \`<n>\` | Max auto-restarts for crashed processes |
|
|
253
|
+
| \`--no-watch\` | Disable file watching even if config has watch patterns |
|
|
254
|
+
| \`-t,\` \`--timestamps\` \`[<format>]\` | Add timestamps to output (default HH:mm:ss, or pass a format string) |
|
|
255
|
+
| \`--log-dir\` \`<path>\` | Write per-process logs to directory |
|
|
256
|
+
| \`--debug\` | Enable debug logging to .numux/debug.log |
|
|
257
|
+
| \`-h,\` \`--help\` | Show this help |
|
|
258
|
+
| \`-v,\` \`--version\` | Show version |
|
|
259
|
+
<!-- /generated:options -->` },
|
|
260
|
+
"prefix-mode": { title: "Prefix mode", body: `Use \`--prefix\` (\`-p\`) for CI or headless environments. Output is printed with colored \`[name]\` prefixes instead of the TUI:
|
|
261
|
+
|
|
262
|
+
\`\`\`sh
|
|
263
|
+
numux --prefix
|
|
264
|
+
\`\`\`
|
|
265
|
+
|
|
266
|
+
Auto-exits when all processes finish. Exit code 1 if any process failed.` },
|
|
267
|
+
"global-options": { title: "Global options", body: `Top-level options apply to all processes (process-level settings override):
|
|
268
|
+
|
|
269
|
+
<!-- generated:config-global -->
|
|
270
|
+
| Field | Type | Description |
|
|
271
|
+
|-------|------|-------------|
|
|
272
|
+
| \`cwd\` | \`string\` | Global working directory, inherited by all processes |
|
|
273
|
+
| \`env\` | \`Record<string, string>\` | Global env vars, merged into each process (process-level overrides) |
|
|
274
|
+
| \`envFile\` | \`string \\| string[] \\| false\` | Global .env file(s), inherited by processes without their own envFile; \`false\` disables |
|
|
275
|
+
| \`showCommand\` | \`boolean\` | Global showCommand flag, inherited by all processes |
|
|
276
|
+
| \`maxRestarts\` | \`number\` | Global restart limit, inherited by all processes (only restarts on non-zero exit) |
|
|
277
|
+
| \`readyTimeout\` | \`number\` | Global ready timeout (ms), inherited by all processes |
|
|
278
|
+
| \`stopSignal\` | \`'SIGTERM' \\| 'SIGINT' \\| 'SIGHUP'\` | Global stop signal, inherited by all processes |
|
|
279
|
+
| \`errorMatcher\` | \`boolean \\| string\` | Global error matcher, inherited by all processes. \`true\` = detect ANSI red output, string = regex |
|
|
280
|
+
| \`watch\` | \`string \\| string[]\` | Global watch patterns, inherited by processes without their own watch |
|
|
281
|
+
| \`sort\` | \`'config' \\| 'alphabetical' \\| 'topological'\` | Tab display order. \`'config'\` preserves definition order (package.json script order for wildcards), \`'alphabetical'\` sorts by process name, \`'topological'\` sorts by dependency tiers. |
|
|
282
|
+
| \`prefix\` | \`boolean\` | Use prefixed output mode instead of TUI (for CI/scripts) |
|
|
283
|
+
| \`timestamps\` | \`boolean \\| string\` | Add timestamps to output lines. \`true\` uses default \`HH:mm:ss\` format, or pass a format string (e.g. \`"HH:mm:ss.SSS"\`) |
|
|
284
|
+
| \`killOthers\` | \`boolean\` | Kill all processes when any one exits (regardless of exit code) |
|
|
285
|
+
| \`killOthersOnFail\` | \`boolean\` | Kill all processes when any one exits with a non-zero exit code |
|
|
286
|
+
| \`noWatch\` | \`boolean\` | Disable file watching even if processes have watch patterns |
|
|
287
|
+
| \`logDir\` | \`string\` | Directory to write per-process log files |
|
|
288
|
+
<!-- /generated:config-global -->
|
|
289
|
+
|
|
290
|
+
\`\`\`ts
|
|
291
|
+
export default defineConfig({
|
|
292
|
+
cwd: './packages/backend',
|
|
293
|
+
env: { NODE_ENV: 'development' },
|
|
294
|
+
envFile: '.env',
|
|
295
|
+
processes: {
|
|
296
|
+
api: { command: 'node server.js' }, // inherits cwd, env, envFile
|
|
297
|
+
web: { command: 'vite', cwd: './packages/web' }, // overrides cwd
|
|
298
|
+
},
|
|
299
|
+
})
|
|
300
|
+
\`\`\`` },
|
|
301
|
+
"process-options": { title: "Process options", body: `Each process accepts:
|
|
302
|
+
|
|
303
|
+
<!-- generated:config-process -->
|
|
304
|
+
| Field | Type | Default | Description |
|
|
305
|
+
|-------|------|---------|-------------|
|
|
306
|
+
| \`command\` | \`string\` | *required* | Shell command to run. Supports \`$dep.group\` references from dependency capture groups |
|
|
307
|
+
| \`cwd\` | \`string\` | \u2014 | Working directory for the process |
|
|
308
|
+
| \`env\` | \`Record<string, string>\` | \u2014 | Extra environment variables. Values support \`$dep.group\` references from dependency capture groups. |
|
|
309
|
+
| \`envFile\` | \`string \\| string[] \\| false\` | \u2014 | .env file path(s) to load, or \`false\` to disable |
|
|
310
|
+
| \`dependsOn\` | \`string \\| string[]\` | \u2014 | Processes that must be ready before this one starts |
|
|
311
|
+
| \`readyPattern\` | \`string \\| RegExp\` | \u2014 | Regex matched against stdout to signal readiness. Use \`RegExp\` to capture groups for \`$dep.group\` expansion |
|
|
312
|
+
| \`maxRestarts\` | \`number\` | \`0\` | Limit auto-restart attempts (only restarts on non-zero exit) |
|
|
313
|
+
| \`readyTimeout\` | \`number\` | \u2014 | Milliseconds to wait for readyPattern before failing |
|
|
314
|
+
| \`delay\` | \`number\` | \u2014 | Milliseconds to wait before starting the process |
|
|
315
|
+
| \`condition\` | \`string\` | \u2014 | Env var name (prefix with \`!\` to negate); process skipped if condition is falsy |
|
|
316
|
+
| \`platform\` | \`string \\| string[]\` | \u2014 | OS(es) this process runs on (e.g. \`'darwin'\`, \`'linux'\`). Non-matching processes are removed, their dependents still start |
|
|
317
|
+
| \`stopSignal\` | \`'SIGTERM' \\| 'SIGINT' \\| 'SIGHUP'\` | \`'SIGTERM'\` | Signal for graceful stop |
|
|
318
|
+
| \`color\` | \`string \\| string[]\` | \u2014 | Hex color (e.g. \`"#ff6600"\`) or color name. Array for round-robin in script patterns |
|
|
319
|
+
| \`watch\` | \`string \\| string[]\` | \u2014 | Glob patterns \u2014 restart process when matching files change |
|
|
320
|
+
| \`interactive\` | \`boolean\` | \`false\` | When true, keyboard input is forwarded to the process |
|
|
321
|
+
| \`optional\` | \`boolean\` | \u2014 | Process is visible but not started automatically. Use Alt+S to start manually |
|
|
322
|
+
| \`errorMatcher\` | \`boolean \\| string\` | \u2014 | \`true\` = detect ANSI red output, string = regex pattern |
|
|
323
|
+
| \`workspaces\` | \`boolean \\| string \\| string[]\` | \u2014 | Run command in monorepo workspaces. \`true\` = all workspaces, string = specific workspace by name/path, string[] = multiple workspaces |
|
|
324
|
+
| \`showCommand\` | \`boolean\` | \`true\` | Print the command being run as the first line of output |
|
|
325
|
+
<!-- /generated:config-process -->` },
|
|
326
|
+
"workspace-expansion": { title: "Workspace expansion", body: `Use \`workspaces\` on a process to expand it into per-workspace processes. Reads the \`workspaces\` field from your root \`package.json\`.
|
|
327
|
+
|
|
328
|
+
\`\`\`ts
|
|
329
|
+
export default defineConfig({
|
|
330
|
+
processes: {
|
|
331
|
+
// All workspaces \u2014 filters by script availability for PM run commands
|
|
332
|
+
lint: { command: 'npm run lint', workspaces: true },
|
|
333
|
+
|
|
334
|
+
// Specific workspace by package name
|
|
335
|
+
validate: { command: 'npm run validate', workspaces: '@repo/image-worker' },
|
|
336
|
+
|
|
337
|
+
// Multiple specific workspaces
|
|
338
|
+
dev: { command: 'npm run dev', workspaces: ['@repo/api', '@repo/web'] },
|
|
339
|
+
},
|
|
340
|
+
})
|
|
341
|
+
\`\`\`
|
|
342
|
+
|
|
343
|
+
Each entry expands into \`{name}:{wsName}\` processes (e.g. \`lint:api\`, \`lint:web\`) with \`cwd\` set to the workspace directory. All other config (env, dependsOn, color, etc.) is inherited from the template.
|
|
344
|
+
|
|
345
|
+
When \`workspaces: true\` is used with a PM run command (\`npm run lint\`), only workspaces that have the matching script are included. Raw commands (\`eslint .\`) run in all workspaces.
|
|
346
|
+
|
|
347
|
+
String values resolve by package name first (with or without scope), then fall back to relative path. Cannot be combined with \`cwd\`.` },
|
|
348
|
+
"file-watching": { title: "File watching", body: `Use \`watch\` to automatically restart a process when source files change:
|
|
349
|
+
|
|
350
|
+
\`\`\`ts
|
|
351
|
+
export default defineConfig({
|
|
352
|
+
processes: {
|
|
353
|
+
api: {
|
|
354
|
+
command: 'node server.js',
|
|
355
|
+
watch: 'src/**/*.ts',
|
|
356
|
+
},
|
|
357
|
+
styles: {
|
|
358
|
+
command: 'sass --watch src:dist',
|
|
359
|
+
watch: ['src/**/*.scss', 'src/**/*.css'],
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
})
|
|
363
|
+
\`\`\`
|
|
364
|
+
|
|
365
|
+
Patterns are matched relative to the process's \`cwd\` (or the project root). Changes in \`node_modules\` and \`.git\` are always ignored. Rapid file changes are debounced (300ms) to avoid restart storms.
|
|
366
|
+
|
|
367
|
+
A watched process is only restarted if it's currently running, ready, or failed \u2014 manually stopped processes are not affected.` },
|
|
368
|
+
"environment-variable-interpolation": { title: "Environment variable interpolation", body: `Config values support \`\${VAR}\` syntax for environment variable substitution:
|
|
369
|
+
|
|
370
|
+
\`\`\`ts
|
|
371
|
+
export default defineConfig({
|
|
372
|
+
processes: {
|
|
373
|
+
api: {
|
|
374
|
+
command: 'node server.js --port \${PORT:-3000}',
|
|
375
|
+
env: {
|
|
376
|
+
DATABASE_URL: '\${DATABASE_URL:?DATABASE_URL must be set}',
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
},
|
|
380
|
+
})
|
|
381
|
+
\`\`\`
|
|
382
|
+
|
|
383
|
+
| Syntax | Behavior |
|
|
384
|
+
|--------|----------|
|
|
385
|
+
| \`\${VAR}\` | Value of \`VAR\`, or empty string if unset |
|
|
386
|
+
| \`\${VAR:-default}\` | Value of \`VAR\`, or \`default\` if unset |
|
|
387
|
+
| \`\${VAR:?error}\` | Value of \`VAR\`, or error with message if unset |
|
|
388
|
+
|
|
389
|
+
Interpolation applies to all string values in the config (command, cwd, env, envFile, readyPattern, etc.).` },
|
|
390
|
+
"conditional-processes": { title: "Conditional processes", body: `Use \`condition\` to run a process only when an environment variable is set:
|
|
391
|
+
|
|
392
|
+
\`\`\`ts
|
|
393
|
+
export default defineConfig({
|
|
394
|
+
processes: {
|
|
395
|
+
seed: {
|
|
396
|
+
command: 'bun run seed',
|
|
397
|
+
condition: 'SEED_DB', // only runs when SEED_DB is set and truthy
|
|
398
|
+
},
|
|
399
|
+
storybook: {
|
|
400
|
+
command: 'bun run storybook',
|
|
401
|
+
condition: '!CI', // skipped in CI environments
|
|
402
|
+
},
|
|
403
|
+
},
|
|
404
|
+
})
|
|
405
|
+
\`\`\`
|
|
406
|
+
|
|
407
|
+
Falsy values: unset, empty string, \`"0"\`, \`"false"\`, \`"no"\`, \`"off"\` (case-insensitive). If a conditional process is skipped, its dependents are also skipped.` },
|
|
408
|
+
"optional-processes": { title: "Optional processes", body: `Use \`optional\` for tools you want visible in tabs but not auto-started (e.g. Prisma Studio, debug servers):
|
|
409
|
+
|
|
410
|
+
\`\`\`ts
|
|
411
|
+
export default defineConfig({
|
|
412
|
+
processes: {
|
|
413
|
+
app: { command: 'bun run dev' },
|
|
414
|
+
studio: {
|
|
415
|
+
command: 'bunx prisma studio',
|
|
416
|
+
optional: true, // shows as stopped tab, start with Alt+S
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
})
|
|
420
|
+
\`\`\`
|
|
421
|
+
|
|
422
|
+
Unlike \`condition\`, optional processes don't cascade \u2014 their dependents still start normally.` },
|
|
423
|
+
"dependency-orchestration": { title: "Dependency orchestration", body: `Each process starts as soon as its declared \`dependsOn\` dependencies are ready \u2014 it does not wait for unrelated processes. If a process fails, its dependents are skipped.
|
|
424
|
+
|
|
425
|
+
A process becomes **ready** when:
|
|
426
|
+
- **Has \`readyPattern\`** \u2014 the pattern matches in stdout (long-running server)
|
|
427
|
+
- **No \`readyPattern\`** \u2014 exits with code 0 (one-shot task)
|
|
428
|
+
|
|
429
|
+
Processes that crash (non-zero exit) can be auto-restarted by setting \`maxRestarts\` (default: \`0\`). Restarts use exponential backoff (1s\u201330s), which resets after 10s of uptime.` },
|
|
430
|
+
"dependency-output-capture": { title: "Dependency output capture", body: `When \`readyPattern\` is a \`RegExp\` (not a string), capture groups are extracted on match and expanded into dependent process \`command\` and \`env\` values using \`$process.group\` syntax:
|
|
431
|
+
|
|
432
|
+
\`\`\`ts
|
|
433
|
+
export default defineConfig({
|
|
434
|
+
processes: {
|
|
435
|
+
db: {
|
|
436
|
+
command: 'docker compose up postgres',
|
|
437
|
+
readyPattern: /ready to accept connections on port (?<port>\\d+)/,
|
|
438
|
+
},
|
|
439
|
+
api: {
|
|
440
|
+
command: 'node server.js --db-port $db.port',
|
|
441
|
+
dependsOn: ['db'],
|
|
442
|
+
env: { DB_PORT: '$db.port' },
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
})
|
|
446
|
+
\`\`\`
|
|
447
|
+
|
|
448
|
+
Both named (\`$db.port\`) and positional (\`$db.1\`) references work. Named groups also populate positional slots, so \`$db.port\` and \`$db.1\` both resolve to the same value above.
|
|
449
|
+
|
|
450
|
+
Unmatched references are left as-is (the shell will expand \`$db\` as empty + \`.port\` literal, making the issue visible). String \`readyPattern\` values work as before \u2014 readiness detection only, no capture extraction.` },
|
|
451
|
+
keybindings: { title: "Keybindings", body: `Keybindings are shown in the status bar at the bottom of the app. Panes are readonly by default \u2014 keyboard input is not forwarded to processes. Set \`interactive: true\` on processes that need stdin (REPLs, shells, etc.).
|
|
452
|
+
|
|
453
|
+
<!-- generated:keybindings -->
|
|
454
|
+
| Key | Action |
|
|
455
|
+
|-----|--------|
|
|
456
|
+
| \`\u2190\`/\`\u2192\` or \`1\`-\`9\` | Tabs |
|
|
457
|
+
| \`G/Shift+G\` | Top/bottom |
|
|
458
|
+
| \`R\` | Restart |
|
|
459
|
+
| \`S\` | Stop/start |
|
|
460
|
+
| \`F\` | Search |
|
|
461
|
+
| \`Y\` | Copy all |
|
|
462
|
+
| \`L\` | Clear |
|
|
463
|
+
| \`T\` | Timestamps |
|
|
464
|
+
| \`O\` | Open logs |
|
|
465
|
+
| \`Ctrl+Click\` | Open link |
|
|
466
|
+
| \`Ctrl+C\` | Quit |
|
|
467
|
+
<!-- /generated:keybindings -->
|
|
468
|
+
|
|
469
|
+
Search mode (after pressing \`F\`):
|
|
470
|
+
|
|
471
|
+
| Key | Action |
|
|
472
|
+
|-----|--------|
|
|
473
|
+
| \`Tab\` | Toggle between single-pane and all-process search |
|
|
474
|
+
| \`Enter\`/\`Shift+Enter\` | Next/previous match |
|
|
475
|
+
| \`Esc\` | Exit search |
|
|
476
|
+
| \`PageUp\`/\`PageDown\` | Scroll by page |` },
|
|
477
|
+
"tab-icons": { title: "Tab icons", body: `<!-- generated:tab-icons -->
|
|
478
|
+
| Icon | Status |
|
|
479
|
+
|------|--------|
|
|
480
|
+
| \u25CB | Pending |
|
|
481
|
+
| \u25D0 | Starting |
|
|
482
|
+
| \u25C9 | Running |
|
|
483
|
+
| \u25CF | Ready |
|
|
484
|
+
| \u25D1 | Stopping |
|
|
485
|
+
| \u25A0 | Stopped |
|
|
486
|
+
| \u2713 | Finished |
|
|
487
|
+
| \u2716 | Failed |
|
|
488
|
+
| \u2298 | Skipped |
|
|
489
|
+
<!-- /generated:tab-icons -->` },
|
|
490
|
+
"ghostty-opentui": { title: "ghostty-opentui", body: `Despite the name, [\`ghostty-opentui\`](https://github.com/remorses/ghostty-opentui) is **not** a compatibility layer for the [Ghostty](https://ghostty.org) terminal. It uses Ghostty's Zig-based VT parser as the ANSI terminal emulation engine for OpenTUI's terminal renderable. It works in any terminal emulator (iTerm, Kitty, Alacritty, WezTerm, etc.) and adds ~8MB to install size due to native binaries.` },
|
|
491
|
+
license: { title: "License", body: `MIT` }
|
|
492
|
+
};
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
// src/help.ts
|
|
496
|
+
var exports_help = {};
|
|
497
|
+
__export(exports_help, {
|
|
498
|
+
showHelp: () => showHelp
|
|
499
|
+
});
|
|
500
|
+
function stripMarkdown(md) {
|
|
501
|
+
return md.replace(/<!--[\s\S]*?-->/g, "").replace(/\*\*(.+?)\*\*/g, "$1").replace(/\*(.+?)\*/g, "$1").replace(/`([^`]+)`/g, "$1").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/\n{3,}/g, `
|
|
502
|
+
|
|
503
|
+
`).trim();
|
|
504
|
+
}
|
|
505
|
+
function showHelp(topic) {
|
|
506
|
+
if (!topic) {
|
|
507
|
+
const entries = Object.entries(HELP_TOPICS).map(([slug, t]) => ` ${slug.padEnd(40)}${t.title}`).join(`
|
|
508
|
+
`);
|
|
509
|
+
const aliases = Object.entries(TOPIC_ALIASES).map(([alias, target]) => ` ${alias} \u2192 ${target}`).join(`
|
|
510
|
+
`);
|
|
511
|
+
return `Available help topics:
|
|
512
|
+
|
|
513
|
+
${entries}
|
|
514
|
+
|
|
515
|
+
Aliases:
|
|
516
|
+
${aliases}
|
|
517
|
+
|
|
518
|
+
Usage: numux help <topic>`;
|
|
519
|
+
}
|
|
520
|
+
const resolved = TOPIC_ALIASES[topic] ?? topic;
|
|
521
|
+
const entry = HELP_TOPICS[resolved];
|
|
522
|
+
if (!entry) {
|
|
523
|
+
const available = Object.keys(HELP_TOPICS).join(", ");
|
|
524
|
+
return `Unknown topic: "${topic}"
|
|
525
|
+
|
|
526
|
+
Available topics: ${available}`;
|
|
527
|
+
}
|
|
528
|
+
return `${entry.title}
|
|
529
|
+
${"=".repeat(entry.title.length)}
|
|
530
|
+
|
|
531
|
+
${stripMarkdown(entry.body)}`;
|
|
532
|
+
}
|
|
533
|
+
var init_help = __esm(() => {
|
|
534
|
+
init_help_topics();
|
|
535
|
+
});
|
|
536
|
+
|
|
36
537
|
// package.json
|
|
37
538
|
var require_package = __commonJS((exports, module) => {
|
|
38
539
|
module.exports = {
|
|
39
540
|
name: "numux",
|
|
40
|
-
version: "2.
|
|
541
|
+
version: "2.11.0",
|
|
41
542
|
description: "Terminal multiplexer with dependency orchestration",
|
|
42
543
|
type: "module",
|
|
43
544
|
license: "MIT",
|
|
@@ -60,6 +561,7 @@ var require_package = __commonJS((exports, module) => {
|
|
|
60
561
|
bin: {
|
|
61
562
|
numux: "dist/bin.js"
|
|
62
563
|
},
|
|
564
|
+
man: "dist/man/numux.1",
|
|
63
565
|
exports: {
|
|
64
566
|
".": {
|
|
65
567
|
types: "./dist/config.d.ts",
|
|
@@ -67,8 +569,9 @@ var require_package = __commonJS((exports, module) => {
|
|
|
67
569
|
}
|
|
68
570
|
},
|
|
69
571
|
scripts: {
|
|
572
|
+
docs: "bun scripts/generate-docs.ts",
|
|
70
573
|
build: "bun run build.ts",
|
|
71
|
-
prepublishOnly: "bun run build",
|
|
574
|
+
prepublishOnly: "bun run docs && bun run build",
|
|
72
575
|
dev: "cd example && bun run dev --debug",
|
|
73
576
|
test: "bun test",
|
|
74
577
|
typecheck: "bunx tsc --noEmit",
|
|
@@ -87,7 +590,8 @@ var require_package = __commonJS((exports, module) => {
|
|
|
87
590
|
"@biomejs/biome": "^2.4.4",
|
|
88
591
|
"@commitlint/cli": "^20.4.2",
|
|
89
592
|
"@commitlint/config-conventional": "^20.4.2",
|
|
90
|
-
"@types/bun": "^1.3.9"
|
|
593
|
+
"@types/bun": "^1.3.9",
|
|
594
|
+
"marked-man": "^2.1.0"
|
|
91
595
|
},
|
|
92
596
|
patchedDependencies: {
|
|
93
597
|
"ghostty-opentui@1.4.7": "patches/ghostty-opentui@1.4.7.patch"
|
|
@@ -99,6 +603,122 @@ var require_package = __commonJS((exports, module) => {
|
|
|
99
603
|
import { existsSync as existsSync6, writeFileSync } from "fs";
|
|
100
604
|
import { resolve as resolve8 } from "path";
|
|
101
605
|
|
|
606
|
+
// src/config/loader.ts
|
|
607
|
+
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
608
|
+
import { resolve as resolve2 } from "path";
|
|
609
|
+
|
|
610
|
+
// src/utils/logger.ts
|
|
611
|
+
import { appendFileSync, existsSync, mkdirSync } from "fs";
|
|
612
|
+
import { resolve } from "path";
|
|
613
|
+
var enabled = false;
|
|
614
|
+
var logFile = "";
|
|
615
|
+
var debugCallback = null;
|
|
616
|
+
function enableDebugLog(dir) {
|
|
617
|
+
const logDir = dir ?? resolve(process.cwd(), ".numux");
|
|
618
|
+
logFile = resolve(logDir, "debug.log");
|
|
619
|
+
if (!existsSync(logDir)) {
|
|
620
|
+
mkdirSync(logDir, { recursive: true });
|
|
621
|
+
}
|
|
622
|
+
enabled = true;
|
|
623
|
+
}
|
|
624
|
+
function log(...args) {
|
|
625
|
+
if (!enabled)
|
|
626
|
+
return;
|
|
627
|
+
try {
|
|
628
|
+
const timestamp = new Date().toISOString();
|
|
629
|
+
const formatted = args.length > 0 ? `${args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ")}` : "";
|
|
630
|
+
const line = `[${timestamp}] ${formatted}`;
|
|
631
|
+
appendFileSync(logFile, `${line}
|
|
632
|
+
`);
|
|
633
|
+
debugCallback?.(line);
|
|
634
|
+
} catch {
|
|
635
|
+
enabled = false;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// src/config/interpolate.ts
|
|
640
|
+
var VAR_RE = /\$\{([^}:]+)(?::([-?])([^}]*))?\}/g;
|
|
641
|
+
function interpolateConfig(config) {
|
|
642
|
+
return interpolateValue(config);
|
|
643
|
+
}
|
|
644
|
+
function interpolateValue(value) {
|
|
645
|
+
if (typeof value === "string") {
|
|
646
|
+
return interpolateString(value);
|
|
647
|
+
}
|
|
648
|
+
if (Array.isArray(value)) {
|
|
649
|
+
return value.map(interpolateValue);
|
|
650
|
+
}
|
|
651
|
+
if (value instanceof RegExp) {
|
|
652
|
+
return value;
|
|
653
|
+
}
|
|
654
|
+
if (value && typeof value === "object") {
|
|
655
|
+
const result = {};
|
|
656
|
+
for (const [k, v] of Object.entries(value)) {
|
|
657
|
+
result[k] = interpolateValue(v);
|
|
658
|
+
}
|
|
659
|
+
return result;
|
|
660
|
+
}
|
|
661
|
+
return value;
|
|
662
|
+
}
|
|
663
|
+
function interpolateString(str) {
|
|
664
|
+
return str.replace(VAR_RE, (_match, name, operator, operand) => {
|
|
665
|
+
const value = process.env[name];
|
|
666
|
+
if (value !== undefined && value !== "") {
|
|
667
|
+
return value;
|
|
668
|
+
}
|
|
669
|
+
if (operator === "-") {
|
|
670
|
+
return operand ?? "";
|
|
671
|
+
}
|
|
672
|
+
if (operator === "?") {
|
|
673
|
+
throw new Error(operand || `Required variable ${name} is not set`);
|
|
674
|
+
}
|
|
675
|
+
return "";
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// src/config/loader.ts
|
|
680
|
+
var CONFIG_FILES = ["numux.config.ts", "numux.config.js"];
|
|
681
|
+
async function loadConfig(configPath, cwd) {
|
|
682
|
+
if (configPath) {
|
|
683
|
+
return loadExplicitConfig(configPath);
|
|
684
|
+
}
|
|
685
|
+
return autoDetectConfig(cwd ?? process.cwd());
|
|
686
|
+
}
|
|
687
|
+
async function loadFile(path) {
|
|
688
|
+
try {
|
|
689
|
+
const mod = await import(path);
|
|
690
|
+
return interpolateConfig(mod.default ?? mod);
|
|
691
|
+
} catch (err) {
|
|
692
|
+
throw new Error(`Failed to load ${path}: ${err instanceof Error ? err.message : err}`, { cause: err });
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
async function loadExplicitConfig(configPath) {
|
|
696
|
+
const path = resolve2(configPath);
|
|
697
|
+
if (!existsSync2(path)) {
|
|
698
|
+
throw new Error(`Config file not found: ${path}`);
|
|
699
|
+
}
|
|
700
|
+
log(`Loading explicit config: ${path}`);
|
|
701
|
+
return loadFile(path);
|
|
702
|
+
}
|
|
703
|
+
async function autoDetectConfig(cwd) {
|
|
704
|
+
for (const file of CONFIG_FILES) {
|
|
705
|
+
const path = resolve2(cwd, file);
|
|
706
|
+
if (existsSync2(path)) {
|
|
707
|
+
log(`Found config file: ${path}`);
|
|
708
|
+
return loadFile(path);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
const pkgPath = resolve2(cwd, "package.json");
|
|
712
|
+
if (existsSync2(pkgPath)) {
|
|
713
|
+
const pkgJson = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
714
|
+
if (pkgJson.numux && typeof pkgJson.numux === "object") {
|
|
715
|
+
log(`Found numux config in package.json`);
|
|
716
|
+
return interpolateConfig(pkgJson.numux);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
throw new Error(`No numux config found. Create one of: ${CONFIG_FILES.join(", ")}, or add a "numux" key to package.json`);
|
|
720
|
+
}
|
|
721
|
+
|
|
102
722
|
// src/cli-flags.ts
|
|
103
723
|
var commaSplit = (raw) => raw.split(",").map((s) => s.trim()).filter(Boolean);
|
|
104
724
|
var FLAGS = [
|
|
@@ -326,6 +946,20 @@ var SUBCOMMANDS = [
|
|
|
326
946
|
result.completions = next;
|
|
327
947
|
return i;
|
|
328
948
|
}
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
name: "help",
|
|
952
|
+
description: "Show help for a topic",
|
|
953
|
+
usage: "help [topic]",
|
|
954
|
+
parse: (args, i, result) => {
|
|
955
|
+
result.help = true;
|
|
956
|
+
const next = args[i + 1];
|
|
957
|
+
if (next !== undefined && !next.startsWith("-")) {
|
|
958
|
+
result.helpTopic = next;
|
|
959
|
+
i++;
|
|
960
|
+
}
|
|
961
|
+
return i;
|
|
962
|
+
}
|
|
329
963
|
}
|
|
330
964
|
];
|
|
331
965
|
function generateHelp() {
|
|
@@ -355,7 +989,7 @@ function generateHelp() {
|
|
|
355
989
|
const left = ` ${parts.join(" ")}`;
|
|
356
990
|
lines.push(`${left.padEnd(29)}${f.description}`);
|
|
357
991
|
}
|
|
358
|
-
lines.push("", "Config files (auto-detected):",
|
|
992
|
+
lines.push("", "Config files (auto-detected):", ` ${CONFIG_FILES.join(", ")}, or "numux" key in package.json`);
|
|
359
993
|
return lines.join(`
|
|
360
994
|
`);
|
|
361
995
|
}
|
|
@@ -514,7 +1148,9 @@ function filterConfig(config, only, exclude) {
|
|
|
514
1148
|
}
|
|
515
1149
|
|
|
516
1150
|
// src/completions.ts
|
|
1151
|
+
init_help_topics();
|
|
517
1152
|
var SUPPORTED_SHELLS = ["bash", "zsh", "fish"];
|
|
1153
|
+
var HELP_TOPIC_NAMES = [...Object.keys(HELP_TOPICS), ...Object.keys(TOPIC_ALIASES)];
|
|
518
1154
|
function generateCompletions(shell) {
|
|
519
1155
|
switch (shell) {
|
|
520
1156
|
case "bash":
|
|
@@ -555,6 +1191,9 @@ function bashCompletions() {
|
|
|
555
1191
|
caseEntries.push(` completions)
|
|
556
1192
|
COMPREPLY=( $(compgen -W "bash zsh fish" -- "$cur") )
|
|
557
1193
|
return ;;`);
|
|
1194
|
+
caseEntries.push(` help)
|
|
1195
|
+
COMPREPLY=( $(compgen -W "${HELP_TOPIC_NAMES.join(" ")}" -- "$cur") )
|
|
1196
|
+
return ;;`);
|
|
558
1197
|
const allFlags = FLAGS.flatMap((f) => f.short ? [f.short, f.long] : [f.long]);
|
|
559
1198
|
const subcmds = SUBCOMMANDS.map((s) => s.name);
|
|
560
1199
|
return `# numux bash completions
|
|
@@ -634,6 +1273,17 @@ ${argsBlock}
|
|
|
634
1273
|
_describe 'subcommand' subcmds
|
|
635
1274
|
;;
|
|
636
1275
|
esac
|
|
1276
|
+
|
|
1277
|
+
case "\${words[2]}" in
|
|
1278
|
+
help)
|
|
1279
|
+
local -a topics
|
|
1280
|
+
topics=(${HELP_TOPIC_NAMES.map((t) => `'${t}'`).join(" ")})
|
|
1281
|
+
_describe 'topic' topics
|
|
1282
|
+
;;
|
|
1283
|
+
completions)
|
|
1284
|
+
_values 'shell' bash zsh fish
|
|
1285
|
+
;;
|
|
1286
|
+
esac
|
|
637
1287
|
}
|
|
638
1288
|
_numux`;
|
|
639
1289
|
}
|
|
@@ -649,7 +1299,7 @@ function fishCompletions() {
|
|
|
649
1299
|
for (const s of SUBCOMMANDS) {
|
|
650
1300
|
lines.push(`complete -c numux -n __fish_use_subcommand -a ${s.name} -d '${sq(s.description)}'`);
|
|
651
1301
|
}
|
|
652
|
-
lines.push("", "# Completions subcommand", "complete -c numux -n '__fish_seen_subcommand_from completions' -a 'bash zsh fish'", "", "# Options");
|
|
1302
|
+
lines.push("", "# Completions subcommand", "complete -c numux -n '__fish_seen_subcommand_from completions' -a 'bash zsh fish'", "", "# Help subcommand", `complete -c numux -n '__fish_seen_subcommand_from help' -a '${HELP_TOPIC_NAMES.join(" ")}'`, "", "# Options");
|
|
653
1303
|
for (const f of FLAGS) {
|
|
654
1304
|
const parts = ["complete -c numux"];
|
|
655
1305
|
if (f.short)
|
|
@@ -672,8 +1322,8 @@ function fishCompletions() {
|
|
|
672
1322
|
}
|
|
673
1323
|
|
|
674
1324
|
// src/config/expand-scripts.ts
|
|
675
|
-
import { existsSync, readFileSync } from "fs";
|
|
676
|
-
import { resolve } from "path";
|
|
1325
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
|
|
1326
|
+
import { resolve as resolve3 } from "path";
|
|
677
1327
|
var LOCKFILE_PM = [
|
|
678
1328
|
["bun.lockb", "bun"],
|
|
679
1329
|
["bun.lock", "bun"],
|
|
@@ -689,7 +1339,7 @@ function detectPackageManager(pkgJson, cwd) {
|
|
|
689
1339
|
return name;
|
|
690
1340
|
}
|
|
691
1341
|
for (const [file, pm] of LOCKFILE_PM) {
|
|
692
|
-
if (
|
|
1342
|
+
if (existsSync3(resolve3(cwd, file)))
|
|
693
1343
|
return pm;
|
|
694
1344
|
}
|
|
695
1345
|
return "npm";
|
|
@@ -757,11 +1407,11 @@ function expandScriptPatterns(config, cwd) {
|
|
|
757
1407
|
if (!(hasScriptRef || hasNpmCommand || hasCommandlessEntry))
|
|
758
1408
|
return config;
|
|
759
1409
|
const dir = config.cwd ?? cwd ?? process.cwd();
|
|
760
|
-
const pkgPath =
|
|
761
|
-
if (!
|
|
1410
|
+
const pkgPath = resolve3(dir, "package.json");
|
|
1411
|
+
if (!existsSync3(pkgPath) && hasScriptRef) {
|
|
762
1412
|
throw new Error(`Wildcard patterns require a package.json (looked in ${dir})`);
|
|
763
1413
|
}
|
|
764
|
-
const pkgJson =
|
|
1414
|
+
const pkgJson = existsSync3(pkgPath) ? JSON.parse(readFileSync2(pkgPath, "utf-8")) : {};
|
|
765
1415
|
const scripts = pkgJson.scripts;
|
|
766
1416
|
const scriptNames = scripts && typeof scripts === "object" ? Object.keys(scripts) : [];
|
|
767
1417
|
const pm = detectPackageManager(pkgJson, dir);
|
|
@@ -820,122 +1470,6 @@ function expandScriptPatterns(config, cwd) {
|
|
|
820
1470
|
return { ...config, processes: expanded };
|
|
821
1471
|
}
|
|
822
1472
|
|
|
823
|
-
// src/config/loader.ts
|
|
824
|
-
import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
|
|
825
|
-
import { resolve as resolve3 } from "path";
|
|
826
|
-
|
|
827
|
-
// src/utils/logger.ts
|
|
828
|
-
import { appendFileSync, existsSync as existsSync2, mkdirSync } from "fs";
|
|
829
|
-
import { resolve as resolve2 } from "path";
|
|
830
|
-
var enabled = false;
|
|
831
|
-
var logFile = "";
|
|
832
|
-
var debugCallback = null;
|
|
833
|
-
function enableDebugLog(dir) {
|
|
834
|
-
const logDir = dir ?? resolve2(process.cwd(), ".numux");
|
|
835
|
-
logFile = resolve2(logDir, "debug.log");
|
|
836
|
-
if (!existsSync2(logDir)) {
|
|
837
|
-
mkdirSync(logDir, { recursive: true });
|
|
838
|
-
}
|
|
839
|
-
enabled = true;
|
|
840
|
-
}
|
|
841
|
-
function log(...args) {
|
|
842
|
-
if (!enabled)
|
|
843
|
-
return;
|
|
844
|
-
try {
|
|
845
|
-
const timestamp = new Date().toISOString();
|
|
846
|
-
const formatted = args.length > 0 ? `${args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ")}` : "";
|
|
847
|
-
const line = `[${timestamp}] ${formatted}`;
|
|
848
|
-
appendFileSync(logFile, `${line}
|
|
849
|
-
`);
|
|
850
|
-
debugCallback?.(line);
|
|
851
|
-
} catch {
|
|
852
|
-
enabled = false;
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
// src/config/interpolate.ts
|
|
857
|
-
var VAR_RE = /\$\{([^}:]+)(?::([-?])([^}]*))?\}/g;
|
|
858
|
-
function interpolateConfig(config) {
|
|
859
|
-
return interpolateValue(config);
|
|
860
|
-
}
|
|
861
|
-
function interpolateValue(value) {
|
|
862
|
-
if (typeof value === "string") {
|
|
863
|
-
return interpolateString(value);
|
|
864
|
-
}
|
|
865
|
-
if (Array.isArray(value)) {
|
|
866
|
-
return value.map(interpolateValue);
|
|
867
|
-
}
|
|
868
|
-
if (value instanceof RegExp) {
|
|
869
|
-
return value;
|
|
870
|
-
}
|
|
871
|
-
if (value && typeof value === "object") {
|
|
872
|
-
const result = {};
|
|
873
|
-
for (const [k, v] of Object.entries(value)) {
|
|
874
|
-
result[k] = interpolateValue(v);
|
|
875
|
-
}
|
|
876
|
-
return result;
|
|
877
|
-
}
|
|
878
|
-
return value;
|
|
879
|
-
}
|
|
880
|
-
function interpolateString(str) {
|
|
881
|
-
return str.replace(VAR_RE, (_match, name, operator, operand) => {
|
|
882
|
-
const value = process.env[name];
|
|
883
|
-
if (value !== undefined && value !== "") {
|
|
884
|
-
return value;
|
|
885
|
-
}
|
|
886
|
-
if (operator === "-") {
|
|
887
|
-
return operand ?? "";
|
|
888
|
-
}
|
|
889
|
-
if (operator === "?") {
|
|
890
|
-
throw new Error(operand || `Required variable ${name} is not set`);
|
|
891
|
-
}
|
|
892
|
-
return "";
|
|
893
|
-
});
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
// src/config/loader.ts
|
|
897
|
-
var CONFIG_FILES = ["numux.config.ts", "numux.config.js"];
|
|
898
|
-
async function loadConfig(configPath, cwd) {
|
|
899
|
-
if (configPath) {
|
|
900
|
-
return loadExplicitConfig(configPath);
|
|
901
|
-
}
|
|
902
|
-
return autoDetectConfig(cwd ?? process.cwd());
|
|
903
|
-
}
|
|
904
|
-
async function loadFile(path) {
|
|
905
|
-
try {
|
|
906
|
-
const mod = await import(path);
|
|
907
|
-
return interpolateConfig(mod.default ?? mod);
|
|
908
|
-
} catch (err) {
|
|
909
|
-
throw new Error(`Failed to load ${path}: ${err instanceof Error ? err.message : err}`, { cause: err });
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
async function loadExplicitConfig(configPath) {
|
|
913
|
-
const path = resolve3(configPath);
|
|
914
|
-
if (!existsSync3(path)) {
|
|
915
|
-
throw new Error(`Config file not found: ${path}`);
|
|
916
|
-
}
|
|
917
|
-
log(`Loading explicit config: ${path}`);
|
|
918
|
-
return loadFile(path);
|
|
919
|
-
}
|
|
920
|
-
async function autoDetectConfig(cwd) {
|
|
921
|
-
for (const file of CONFIG_FILES) {
|
|
922
|
-
const path = resolve3(cwd, file);
|
|
923
|
-
if (existsSync3(path)) {
|
|
924
|
-
log(`Found config file: ${path}`);
|
|
925
|
-
return loadFile(path);
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
const pkgPath = resolve3(cwd, "package.json");
|
|
929
|
-
if (existsSync3(pkgPath)) {
|
|
930
|
-
const pkgJson = JSON.parse(readFileSync2(pkgPath, "utf-8"));
|
|
931
|
-
if (pkgJson.numux && typeof pkgJson.numux === "object") {
|
|
932
|
-
log(`Found numux config in package.json`);
|
|
933
|
-
return interpolateConfig(pkgJson.numux);
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
throw new Error(`No numux config found. Create one of: ${CONFIG_FILES.join(", ")}, or add a "numux" key to package.json`);
|
|
937
|
-
}
|
|
938
|
-
|
|
939
1473
|
// src/config/platform.ts
|
|
940
1474
|
function filterByPlatform(config, currentPlatform = process.platform) {
|
|
941
1475
|
const excluded = new Set;
|
|
@@ -4392,7 +4926,12 @@ export default defineConfig({
|
|
|
4392
4926
|
async function main() {
|
|
4393
4927
|
const parsed = parseArgs(process.argv);
|
|
4394
4928
|
if (parsed.help) {
|
|
4395
|
-
|
|
4929
|
+
if (parsed.helpTopic) {
|
|
4930
|
+
const { showHelp: showHelp2 } = await Promise.resolve().then(() => (init_help(), exports_help));
|
|
4931
|
+
console.info(showHelp2(parsed.helpTopic));
|
|
4932
|
+
} else {
|
|
4933
|
+
console.info(HELP);
|
|
4934
|
+
}
|
|
4396
4935
|
process.exit(0);
|
|
4397
4936
|
}
|
|
4398
4937
|
if (parsed.version) {
|