runset 0.0.1 → 0.0.3

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 CHANGED
@@ -1,10 +1,25 @@
1
1
  # runset
2
2
 
3
- Run npm scripts in sequence or in parallel. Based on ideas from
4
- [`npm-run-all`](https://github.com/mysticatea/npm-run-all), with reusable
5
- pipelines, colored labels, and grouped output.
6
-
7
- Requires Node.js 24.2 or later. No runtime dependencies.
3
+ [![Tests](https://github.com/megahertz/runset/actions/workflows/tests.yml/badge.svg)](https://github.com/megahertz/runset/actions/workflows/tests.yml)
4
+ [![NPM version](https://badge.fury.io/js/runset.svg)](https://badge.fury.io/js/runset)
5
+
6
+ Run npm scripts and shell commands in parallel or sequence, with glob matching,
7
+ reusable pipelines, colored labels, and grouped output. Inspired by
8
+ `npm-run-all`, with more control over execution and output.
9
+
10
+ - **Flexible execution** — mix parallel and sequential steps, with concurrency
11
+ limits
12
+ - **Readable output** — colored labels, grouped logs, and output redirection
13
+ - **Process control** — stop, continue, or restart on exit, clean up process
14
+ trees on interruption
15
+ - **Workspace support**
16
+ - **Zero dependencies**
17
+
18
+ <p align="center">
19
+ <img src="docs/screenshot.png" alt="runset output: realtime on the left, grouped on the right">
20
+ <br>
21
+ <sub>Realtime output (default) on the left, grouped (<code>-o grouped</code>) on the right</sub>
22
+ </p>
8
23
 
9
24
  ```sh
10
25
  npm install --save-dev runset
@@ -214,21 +229,21 @@ to the commands that follow them.
214
229
  The same object may live in a `runset` section of `package.json` instead; a
215
230
  `runset.config.*` file in the same directory wins over it.
216
231
 
217
- Use `commandDictionary` to give a command or pipeline a reusable name:
232
+ Use `scripts` to give a command or pipeline a reusable name:
218
233
 
219
234
  ```ts
220
235
  import type { ConfigJs } from 'runset';
221
236
 
222
237
  export default {
223
- commandDictionary: {
238
+ scripts: {
224
239
  check: ['lint', 'test'],
225
240
  api: { command: 'node server.js', env: { PORT: '4000' } },
226
241
  },
227
242
  } satisfies ConfigJs;
228
243
  ```
229
244
 
230
- Run these with `npx runset check` or `npx runset api`. Dictionary names take
231
- priority over npm script names.
245
+ Run these with `npx runset check` or `npx runset api`. Names in `scripts` take
246
+ priority over the same names in `package.json`.
232
247
 
233
248
  Config files also support `.js`, `.mjs`, `.cjs`, and `.json`. runset looks in
234
249
  the working directory and its parents. CLI commands run **after** any `commands`
@@ -248,9 +263,8 @@ Config modules can also export a synchronous function receiving
248
263
  `commands` are skipped, so lists can contain conditional commands.
249
264
 
250
265
  Named pipelines can run together: with `api: ['build:api', 'test:api']` and
251
- `web: ['build:web', 'test:web']` in `commandDictionary`, `npx runset -p api web`
252
- runs both builds, then both tests. Both builds must finish before either test
253
- starts.
266
+ `web: ['build:web', 'test:web']` in `scripts`, `npx runset -p api web` runs both
267
+ builds, then both tests. Both builds must finish before either test starts.
254
268
 
255
269
  ## Library
256
270
 
package/dist/index.d.mts CHANGED
@@ -7,7 +7,6 @@ export interface Std {
7
7
  timing: StdTiming;
8
8
  }
9
9
  export type ExitAction = 'continue' | 'restart' | 'stop';
10
- export declare const EXIT_ACTIONS: Set<ExitAction>;
11
10
  export type LogLevel = 'debug' | 'error' | 'info' | 'warn';
12
11
  /**
13
12
  * How much color runset uses: `basic` is the terminal's 16 theme colors,
@@ -23,7 +22,6 @@ export interface Command {
23
22
  color: string;
24
23
  command: string;
25
24
  cwd: string;
26
- disabled: boolean;
27
25
  env: NodeJS.ProcessEnv;
28
26
  label: string;
29
27
  /** What is handed to the shell: for an npm command, the script's body. */
@@ -32,9 +30,6 @@ export interface Command {
32
30
  onSuccess: ExitAction;
33
31
  /** The workspace package a `recursive` command was expanded into. */
34
32
  packageName?: string;
35
- parallel: boolean;
36
- /** Run an npm script in every workspace package that has it. */
37
- recursive: boolean;
38
33
  /** The `package.json` script name, when `type` is `'npm'`. */
39
34
  scriptName?: string;
40
35
  /** Commands sharing a stage run together; stages run in order. */
@@ -52,13 +47,26 @@ export type LabelFormatter = (context: {
52
47
  defaultPrefix: string;
53
48
  stream: 'stderr' | 'stdout';
54
49
  }) => string;
55
- /** The parts of a {@link Command} a user may set by hand. */
56
- export type CommandOptions = {
50
+ /** What a user may set about a command, by hand. */
51
+ export interface CommandOptions {
52
+ bgColor?: string;
53
+ color?: string;
54
+ cwd?: string;
55
+ /** Leave the command out of the run. */
56
+ disabled?: boolean;
57
+ env?: NodeJS.ProcessEnv;
58
+ label?: string;
59
+ onFailure?: ExitAction;
60
+ onSuccess?: ExitAction;
57
61
  /** Both streams at once; `stdout` / `stderr` in the same place outrank it. */
58
62
  output?: Partial<Std> | string;
63
+ /** Join the group of commands beside it rather than open a stage of its own. */
64
+ parallel?: boolean;
65
+ /** Run an npm script in every workspace package that has it. */
66
+ recursive?: boolean;
59
67
  stderr?: Partial<Std> | string;
60
68
  stdout?: Partial<Std> | string;
61
- } & Partial<Omit<Command, 'line' | 'packageName' | 'scriptName' | 'stage' | 'stderr' | 'stdout' | 'type'>>;
69
+ }
62
70
  /** One command written as an object; `command` is what makes it one. */
63
71
  export type CommandEntry = {
64
72
  command: string;
@@ -69,15 +77,13 @@ export type CommandEntry = {
69
77
  */
70
78
  export type CommandSettings = {
71
79
  serial?: boolean;
72
- } & Omit<CommandOptions, 'command'>;
80
+ } & CommandOptions;
73
81
  /** A command before normalization; falsy entries are skipped. */
74
82
  export type CommandDefinition = CommandEntry | CommandSettings | false | null | string | undefined;
75
83
  /** What a user writes in `runset.config.*`, or hands to `runset({ … })`. */
76
84
  export interface ConfigJs {
77
85
  /** Default: `'auto'`. */
78
86
  color?: ColorMode;
79
- /** Named commands, resolved before `package.json` scripts. An entry may be a list. */
80
- commandDictionary?: Record<string, CommandDefinition | CommandDefinition[]>;
81
87
  commands?: CommandDefinition[];
82
88
  cwd?: string;
83
89
  dryRun?: boolean;
@@ -107,6 +113,8 @@ export interface ConfigJs {
107
113
  parallel?: boolean;
108
114
  /** The default `recursive` for every command. Default: `false`. */
109
115
  recursive?: boolean;
116
+ /** Named commands, resolved before `package.json` scripts. An entry may be a list. */
117
+ scripts?: Record<string, CommandDefinition | CommandDefinition[]>;
110
118
  /** Print each command before it starts. Default: `false`. */
111
119
  showCommand?: boolean;
112
120
  /** Print how each command exited, green or red. Default: `false`. */
@@ -128,14 +136,6 @@ export interface TerminateOptions {
128
136
  /** Default: SIGTERM. Ignored under `force`. */
129
137
  signal?: NodeJS.Signals;
130
138
  }
131
- /** Where a run writes. */
132
- export interface Destinations {
133
- stderr: NodeJS.WritableStream;
134
- stdout: NodeJS.WritableStream;
135
- }
136
- /** True for an object written without a `command` — a settings entry. */
137
- export declare function isCommandSettings(definition: CommandEntry | CommandSettings): definition is CommandSettings;
138
- export declare function isStreamDestination(destination: string): destination is 'stderr' | 'stdout';
139
139
  //#endregion
140
140
  //#region src/utils/colors.d.ts
141
141
  /** A `ColorMode` once `auto` has been settled. */
@@ -144,17 +144,17 @@ type ColorLevel = Exclude<ColorMode, 'auto'>;
144
144
  //#region src/config/parseCli.d.ts
145
145
  /** Run-wide options a CLI flag can set. */
146
146
  interface CliOptions {
147
- color?: string;
147
+ color?: ColorMode;
148
148
  config?: string;
149
149
  cwd?: string;
150
150
  dryRun?: boolean;
151
151
  env?: Record<string, string>;
152
152
  jobs?: number;
153
153
  killTimeout?: number;
154
- labels?: string;
155
- logLevel?: string;
156
- onFailure?: string;
157
- onSuccess?: string;
154
+ labels?: LabelMode;
155
+ logLevel?: LogLevel;
156
+ onFailure?: ExitAction;
157
+ onSuccess?: ExitAction;
158
158
  output?: string;
159
159
  recursive?: boolean;
160
160
  showCommand?: boolean;
@@ -178,7 +178,7 @@ interface ParsedCli {
178
178
  /** The resolved run-wide configuration: CLI flag → config file → default. */
179
179
  declare class Config {
180
180
  readonly commands: CommandDefinition[];
181
- readonly commandDictionary: Record<string, CommandDefinition | CommandDefinition[]>;
181
+ readonly scripts: Record<string, CommandDefinition | CommandDefinition[]>;
182
182
  /** Everything after `--`, for placeholders. */
183
183
  readonly args: string[];
184
184
  readonly cwd: string;
@@ -210,6 +210,11 @@ declare class Config {
210
210
  /** True when `commands` holds something to run, not just settings entries. */
211
211
  hasCommands(): boolean;
212
212
  }
213
+ /** Where a run writes. */
214
+ interface Destinations {
215
+ stderr: NodeJS.WritableStream;
216
+ stdout: NodeJS.WritableStream;
217
+ }
213
218
  interface ResolvedConfigOptions {
214
219
  /** Defaults to the process's own argv; a library caller passes `parseCli([])`. */
215
220
  cli: ParsedCli;
@@ -239,7 +244,6 @@ interface Plan {
239
244
  //#region src/run/Run.d.ts
240
245
  /** One run: the processes built from a plan, and what stops them. */
241
246
  export declare class Run {
242
- readonly config: Config;
243
247
  private readonly logger;
244
248
  private readonly files;
245
249
  private stopping;
@@ -269,8 +273,6 @@ export declare class Run {
269
273
  /** Any failure runset reports itself; `exitCode` is what the CLI exits with. */
270
274
  export declare class RunsetError extends Error {
271
275
  readonly exitCode: number;
272
- /** What the CLI prints in place of `message`; empty when it already said so. */
273
- readonly report: string | undefined;
274
276
  constructor(message: string, exitCode?: number, report?: string);
275
277
  }
276
278
  /** A command line runset cannot read. */