runset 0.0.1 → 0.0.2
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 +17 -12
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +8 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
# runset
|
|
2
2
|
|
|
3
|
-
Run npm scripts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
Run npm scripts and shell commands in parallel or sequence, with glob matching,
|
|
4
|
+
reusable pipelines, colored labels, and grouped output. Inspired by
|
|
5
|
+
`npm-run-all`, with more control over execution and output.
|
|
6
|
+
|
|
7
|
+
- **Flexible execution** — mix parallel and sequential steps, with concurrency
|
|
8
|
+
limits
|
|
9
|
+
- **Readable output** — colored labels, grouped logs, and output redirection
|
|
10
|
+
- **Process control** — stop, continue, or restart on exit, clean up process
|
|
11
|
+
trees on interruption
|
|
12
|
+
- **Workspace support**
|
|
13
|
+
- **Zero dependencies**
|
|
8
14
|
|
|
9
15
|
```sh
|
|
10
16
|
npm install --save-dev runset
|
|
@@ -214,21 +220,21 @@ to the commands that follow them.
|
|
|
214
220
|
The same object may live in a `runset` section of `package.json` instead; a
|
|
215
221
|
`runset.config.*` file in the same directory wins over it.
|
|
216
222
|
|
|
217
|
-
Use `
|
|
223
|
+
Use `scripts` to give a command or pipeline a reusable name:
|
|
218
224
|
|
|
219
225
|
```ts
|
|
220
226
|
import type { ConfigJs } from 'runset';
|
|
221
227
|
|
|
222
228
|
export default {
|
|
223
|
-
|
|
229
|
+
scripts: {
|
|
224
230
|
check: ['lint', 'test'],
|
|
225
231
|
api: { command: 'node server.js', env: { PORT: '4000' } },
|
|
226
232
|
},
|
|
227
233
|
} satisfies ConfigJs;
|
|
228
234
|
```
|
|
229
235
|
|
|
230
|
-
Run these with `npx runset check` or `npx runset api`.
|
|
231
|
-
priority over
|
|
236
|
+
Run these with `npx runset check` or `npx runset api`. Names in `scripts` take
|
|
237
|
+
priority over the same names in `package.json`.
|
|
232
238
|
|
|
233
239
|
Config files also support `.js`, `.mjs`, `.cjs`, and `.json`. runset looks in
|
|
234
240
|
the working directory and its parents. CLI commands run **after** any `commands`
|
|
@@ -248,9 +254,8 @@ Config modules can also export a synchronous function receiving
|
|
|
248
254
|
`commands` are skipped, so lists can contain conditional commands.
|
|
249
255
|
|
|
250
256
|
Named pipelines can run together: with `api: ['build:api', 'test:api']` and
|
|
251
|
-
`web: ['build:web', 'test:web']` in `
|
|
252
|
-
|
|
253
|
-
starts.
|
|
257
|
+
`web: ['build:web', 'test:web']` in `scripts`, `npx runset -p api web` runs both
|
|
258
|
+
builds, then both tests. Both builds must finish before either test starts.
|
|
254
259
|
|
|
255
260
|
## Library
|
|
256
261
|
|
package/dist/index.d.mts
CHANGED
|
@@ -76,8 +76,6 @@ export type CommandDefinition = CommandEntry | CommandSettings | false | null |
|
|
|
76
76
|
export interface ConfigJs {
|
|
77
77
|
/** Default: `'auto'`. */
|
|
78
78
|
color?: ColorMode;
|
|
79
|
-
/** Named commands, resolved before `package.json` scripts. An entry may be a list. */
|
|
80
|
-
commandDictionary?: Record<string, CommandDefinition | CommandDefinition[]>;
|
|
81
79
|
commands?: CommandDefinition[];
|
|
82
80
|
cwd?: string;
|
|
83
81
|
dryRun?: boolean;
|
|
@@ -107,6 +105,8 @@ export interface ConfigJs {
|
|
|
107
105
|
parallel?: boolean;
|
|
108
106
|
/** The default `recursive` for every command. Default: `false`. */
|
|
109
107
|
recursive?: boolean;
|
|
108
|
+
/** Named commands, resolved before `package.json` scripts. An entry may be a list. */
|
|
109
|
+
scripts?: Record<string, CommandDefinition | CommandDefinition[]>;
|
|
110
110
|
/** Print each command before it starts. Default: `false`. */
|
|
111
111
|
showCommand?: boolean;
|
|
112
112
|
/** Print how each command exited, green or red. Default: `false`. */
|
|
@@ -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
|
|
181
|
+
readonly scripts: Record<string, CommandDefinition | CommandDefinition[]>;
|
|
182
182
|
/** Everything after `--`, for placeholders. */
|
|
183
183
|
readonly args: string[];
|
|
184
184
|
readonly cwd: string;
|
package/dist/index.mjs
CHANGED
|
@@ -563,7 +563,7 @@ const COLOR_MODES = /* @__PURE__ */ new Set([
|
|
|
563
563
|
]);
|
|
564
564
|
const KNOWN_KEYS = /* @__PURE__ */ new Set([
|
|
565
565
|
"color",
|
|
566
|
-
"
|
|
566
|
+
"scripts",
|
|
567
567
|
"commands",
|
|
568
568
|
"cwd",
|
|
569
569
|
"dryRun",
|
|
@@ -599,7 +599,7 @@ function createConfig({ cli = parseCli(process.argv.slice(2)), configJs, cwd = p
|
|
|
599
599
|
/** The resolved run-wide configuration: CLI flag → config file → default. */
|
|
600
600
|
var Config = class {
|
|
601
601
|
commands;
|
|
602
|
-
|
|
602
|
+
scripts;
|
|
603
603
|
/** Everything after `--`, for placeholders. */
|
|
604
604
|
args;
|
|
605
605
|
cwd;
|
|
@@ -647,7 +647,7 @@ var Config = class {
|
|
|
647
647
|
...options.env
|
|
648
648
|
};
|
|
649
649
|
this.commands = [...file.commands ?? [], ...cli.commands].filter(Boolean);
|
|
650
|
-
this.
|
|
650
|
+
this.scripts = file.scripts ?? {};
|
|
651
651
|
this.args = cli.positional;
|
|
652
652
|
this.jobs = options.jobs ?? file.jobs ?? Number.POSITIVE_INFINITY;
|
|
653
653
|
this.killTimeout = options.killTimeout ?? file.killTimeout ?? DEFAULT_KILL_TIMEOUT;
|
|
@@ -694,7 +694,7 @@ var Config = class {
|
|
|
694
694
|
stdError("stdout", this.stdout),
|
|
695
695
|
stdError("stderr", this.stderr),
|
|
696
696
|
this.formatLabel !== void 0 && typeof this.formatLabel !== "function" ? "formatLabel must be a function." : void 0,
|
|
697
|
-
typeof this.
|
|
697
|
+
typeof this.scripts !== "object" || this.scripts === null || Array.isArray(this.scripts) ? "scripts must be an object." : void 0,
|
|
698
698
|
actionError("onSuccess", this.onSuccess),
|
|
699
699
|
actionError("onFailure", this.onFailure)
|
|
700
700
|
].find((error) => error !== void 0), ConfigError);
|
|
@@ -1376,9 +1376,9 @@ function normalize(config, packageInfo) {
|
|
|
1376
1376
|
function resolveToken(raw, inherited, overrides, seen) {
|
|
1377
1377
|
const token = splitToken(raw);
|
|
1378
1378
|
const inline = resolveCwd(parseInlineOptions(token.options, config.args), inherited.cwd ?? config.cwd);
|
|
1379
|
-
if (Object.hasOwn(config.
|
|
1379
|
+
if (Object.hasOwn(config.scripts, token.name)) {
|
|
1380
1380
|
if (seen.has(token.name)) throw new NormalizeError(`Command "${token.name}" refers to itself.`);
|
|
1381
|
-
const resolved = resolveEntry(config.
|
|
1381
|
+
const resolved = resolveEntry(config.scripts[token.name], inherited, layer(inline, overrides), /* @__PURE__ */ new Set([...seen, token.name]));
|
|
1382
1382
|
return token.args === "" ? resolved : appendArgs(resolved, token);
|
|
1383
1383
|
}
|
|
1384
1384
|
const settled = layer(inherited, inline, overrides);
|
|
@@ -1414,7 +1414,7 @@ function normalize(config, packageInfo) {
|
|
|
1414
1414
|
function resolve(definition, inherited, overrides, seen) {
|
|
1415
1415
|
if (!definition) return EMPTY_SEGMENT;
|
|
1416
1416
|
if (typeof definition === "string") return resolveToken(definition, inherited, overrides, seen);
|
|
1417
|
-
if (Array.isArray(definition)) throw new NormalizeError("A list of commands belongs in \"commands\" or in a \"
|
|
1417
|
+
if (Array.isArray(definition)) throw new NormalizeError("A list of commands belongs in \"commands\" or in a \"scripts\" entry, not inside one.");
|
|
1418
1418
|
if (isCommandSettings(definition)) throw new NormalizeError("A command definition needs a \"command\" field.");
|
|
1419
1419
|
const entry = definition;
|
|
1420
1420
|
if (typeof entry.command !== "string") throw new NormalizeError("A command's \"command\" must be a string.");
|
|
@@ -1422,7 +1422,7 @@ function normalize(config, packageInfo) {
|
|
|
1422
1422
|
return resolveToken(command, layer(inherited, resolveCwd(raw, inherited.cwd ?? config.cwd)), overrides, seen);
|
|
1423
1423
|
}
|
|
1424
1424
|
/**
|
|
1425
|
-
* `commands`, or a
|
|
1425
|
+
* `commands`, or a `scripts` entry that is a list. The list's own
|
|
1426
1426
|
* `parallel` places the list as a whole and is not passed to its members.
|
|
1427
1427
|
*/
|
|
1428
1428
|
function resolveList(definitions, inherited, overrides, seen) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "runset",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Run npm scripts and shell commands in parallel or sequence, with glob matching, reusable pipelines, colored labels, and grouped output",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"npm-run-all",
|
|
7
7
|
"run",
|