buildrush 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +84 -2
- package/SECURITY.md +57 -0
- package/bin/buildrush.js +6 -0
- package/dist/src/adapters.d.ts +23 -0
- package/dist/src/adapters.js +187 -0
- package/dist/src/adapters.js.map +1 -0
- package/dist/src/affected.d.ts +28 -0
- package/dist/src/affected.js +59 -0
- package/dist/src/affected.js.map +1 -0
- package/dist/src/cache.d.ts +94 -0
- package/dist/src/cache.js +362 -0
- package/dist/src/cache.js.map +1 -0
- package/dist/src/cli.d.ts +33 -0
- package/dist/src/cli.js +684 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/config.d.ts +84 -0
- package/dist/src/config.js +394 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/daemon/cli.d.ts +36 -0
- package/dist/src/daemon/cli.js +202 -0
- package/dist/src/daemon/cli.js.map +1 -0
- package/dist/src/daemon/client.d.ts +106 -0
- package/dist/src/daemon/client.js +267 -0
- package/dist/src/daemon/client.js.map +1 -0
- package/dist/src/daemon/ops.d.ts +66 -0
- package/dist/src/daemon/ops.js +47 -0
- package/dist/src/daemon/ops.js.map +1 -0
- package/dist/src/daemon/paths.d.ts +62 -0
- package/dist/src/daemon/paths.js +192 -0
- package/dist/src/daemon/paths.js.map +1 -0
- package/dist/src/daemon/protocol.d.ts +60 -0
- package/dist/src/daemon/protocol.js +62 -0
- package/dist/src/daemon/protocol.js.map +1 -0
- package/dist/src/daemon/server.d.ts +68 -0
- package/dist/src/daemon/server.js +441 -0
- package/dist/src/daemon/server.js.map +1 -0
- package/dist/src/detect.d.ts +12 -0
- package/dist/src/detect.js +68 -0
- package/dist/src/detect.js.map +1 -0
- package/dist/src/doctor.d.ts +6 -0
- package/dist/src/doctor.js +94 -0
- package/dist/src/doctor.js.map +1 -0
- package/dist/src/engine.d.ts +70 -0
- package/dist/src/engine.js +655 -0
- package/dist/src/engine.js.map +1 -0
- package/dist/src/fsindex.d.ts +37 -0
- package/dist/src/fsindex.js +128 -0
- package/dist/src/fsindex.js.map +1 -0
- package/dist/src/fswatch.d.ts +30 -0
- package/dist/src/fswatch.js +141 -0
- package/dist/src/fswatch.js.map +1 -0
- package/dist/src/graph.d.ts +77 -0
- package/dist/src/graph.js +486 -0
- package/dist/src/graph.js.map +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/project.d.ts +45 -0
- package/dist/src/project.js +138 -0
- package/dist/src/project.js.map +1 -0
- package/dist/src/runner.d.ts +36 -0
- package/dist/src/runner.js +174 -0
- package/dist/src/runner.js.map +1 -0
- package/dist/src/scheduler.d.ts +30 -0
- package/dist/src/scheduler.js +143 -0
- package/dist/src/scheduler.js.map +1 -0
- package/dist/src/testcache.d.ts +60 -0
- package/dist/src/testcache.js +93 -0
- package/dist/src/testcache.js.map +1 -0
- package/dist/src/util/fsx.d.ts +11 -0
- package/dist/src/util/fsx.js +61 -0
- package/dist/src/util/fsx.js.map +1 -0
- package/dist/src/util/glob.d.ts +19 -0
- package/dist/src/util/glob.js +193 -0
- package/dist/src/util/glob.js.map +1 -0
- package/dist/src/util/hash.d.ts +14 -0
- package/dist/src/util/hash.js +57 -0
- package/dist/src/util/hash.js.map +1 -0
- package/dist/src/util/paths.d.ts +17 -0
- package/dist/src/util/paths.js +67 -0
- package/dist/src/util/paths.js.map +1 -0
- package/dist/src/watch.d.ts +101 -0
- package/dist/src/watch.js +289 -0
- package/dist/src/watch.js.map +1 -0
- package/dist/src/workspaces.d.ts +118 -0
- package/dist/src/workspaces.js +590 -0
- package/dist/src/workspaces.js.map +1 -0
- package/package.json +47 -4
package/dist/src/cli.js
ADDED
|
@@ -0,0 +1,684 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { CONFIG_FILE, ConfigError, findProjectRoot, loadConfig } from './config.js';
|
|
5
|
+
import { detectProject, starterConfig } from './detect.js';
|
|
6
|
+
import { closure, expandNames, loadTaskState, runTasks } from './engine.js';
|
|
7
|
+
import { Project } from './project.js';
|
|
8
|
+
import { selectTests } from './affected.js';
|
|
9
|
+
import { runDoctor } from './doctor.js';
|
|
10
|
+
import { startWatch } from './watch.js';
|
|
11
|
+
import { analyze, cacheStats, packageImportEdges, writeLastRun } from './daemon/ops.js';
|
|
12
|
+
import { cmdDaemon, daemonWanted, tryDaemon } from './daemon/cli.js';
|
|
13
|
+
import { readJson, writeFileAtomic } from './util/fsx.js';
|
|
14
|
+
import { compileGlobs } from './util/glob.js';
|
|
15
|
+
export const EXIT = { OK: 0, FAILED: 1, USAGE: 2, INTERNAL: 3, CANCELLED: 130 };
|
|
16
|
+
const VERSION = createRequire(import.meta.url)('../../package.json').version;
|
|
17
|
+
const HELP = `buildrush ${VERSION} - local-first incremental build & test engine
|
|
18
|
+
|
|
19
|
+
Usage: buildrush <command> [options]
|
|
20
|
+
|
|
21
|
+
Commands:
|
|
22
|
+
init Create ${CONFIG_FILE} from the detected project
|
|
23
|
+
analyze Summarise the project, tasks and module graph
|
|
24
|
+
graph [--dot|--packages] Print the module dependency graph (JSON, or Graphviz with --dot); --packages: workspace package graph only
|
|
25
|
+
run [task|pipeline...] Run tasks (default pipeline "default") with caching
|
|
26
|
+
build | test | check Shortcuts for the task or pipeline of that name
|
|
27
|
+
explain [task|file] Why tasks ran or were reused; what a file change affects
|
|
28
|
+
cache stats|verify|clean Inspect, verify (--repair) or empty the local cache
|
|
29
|
+
doctor Diagnose environment, config and cache problems
|
|
30
|
+
config validate Validate ${CONFIG_FILE}
|
|
31
|
+
daemon start|stop|status Manage this project's optional local daemon (see docs/daemon.md)
|
|
32
|
+
|
|
33
|
+
Options:
|
|
34
|
+
--daemon Serve run/build/test/check, analyze --json and cache stats from a warm local daemon
|
|
35
|
+
(started on demand; BUILDRUSH_DAEMON=1 is the same). Always falls back to a normal run.
|
|
36
|
+
--no-daemon Never use the daemon, even if BUILDRUSH_DAEMON=1
|
|
37
|
+
--watch Keep running; re-run affected work on every file change (run/build/test/check)
|
|
38
|
+
--affected Run only tests affected by changes (test tasks; falls back to all tests when unsure).
|
|
39
|
+
In a workspace, also only the tasks of affected packages (changed + dependents)
|
|
40
|
+
--since <git-ref> Baseline for --affected (default HEAD)
|
|
41
|
+
--no-cache Execute everything; do not read or write the cache
|
|
42
|
+
--bail Cancel remaining work after the first failure
|
|
43
|
+
--concurrency <n> Max parallel resource units
|
|
44
|
+
--root <dir> Project directory (default: nearest ${CONFIG_FILE})
|
|
45
|
+
--json Machine-readable output
|
|
46
|
+
--verbose, -v Show task logs and details
|
|
47
|
+
--quiet, -q Only print failures and the final summary
|
|
48
|
+
-h, --help Show help --version Show version
|
|
49
|
+
|
|
50
|
+
Exit codes: 0 success, 1 task failure, 2 usage/config error, 3 internal error, 130 cancelled.
|
|
51
|
+
`;
|
|
52
|
+
export function parseArgs(argv) {
|
|
53
|
+
const flags = {
|
|
54
|
+
json: false, verbose: false, quiet: false, affected: false, noCache: false, bail: false,
|
|
55
|
+
force: false, repair: false, dot: false, help: false, version: false, watch: false,
|
|
56
|
+
packages: false, daemon: false, noDaemon: false,
|
|
57
|
+
};
|
|
58
|
+
const positional = [];
|
|
59
|
+
const need = (i, name) => {
|
|
60
|
+
const v = argv[i + 1];
|
|
61
|
+
if (v === undefined || v.startsWith('--'))
|
|
62
|
+
throw new UsageError(`${name} requires a value`);
|
|
63
|
+
return v;
|
|
64
|
+
};
|
|
65
|
+
for (let i = 0; i < argv.length; i++) {
|
|
66
|
+
const a = argv[i];
|
|
67
|
+
switch (a) {
|
|
68
|
+
case '--json':
|
|
69
|
+
flags.json = true;
|
|
70
|
+
break;
|
|
71
|
+
case '--verbose':
|
|
72
|
+
case '-v':
|
|
73
|
+
flags.verbose = true;
|
|
74
|
+
break;
|
|
75
|
+
case '--quiet':
|
|
76
|
+
case '-q':
|
|
77
|
+
flags.quiet = true;
|
|
78
|
+
break;
|
|
79
|
+
case '--watch':
|
|
80
|
+
case '-w':
|
|
81
|
+
flags.watch = true;
|
|
82
|
+
break;
|
|
83
|
+
case '--daemon':
|
|
84
|
+
flags.daemon = true;
|
|
85
|
+
break;
|
|
86
|
+
case '--no-daemon':
|
|
87
|
+
flags.noDaemon = true;
|
|
88
|
+
break;
|
|
89
|
+
case '--affected':
|
|
90
|
+
flags.affected = true;
|
|
91
|
+
break;
|
|
92
|
+
case '--no-cache':
|
|
93
|
+
flags.noCache = true;
|
|
94
|
+
break;
|
|
95
|
+
case '--bail':
|
|
96
|
+
flags.bail = true;
|
|
97
|
+
break;
|
|
98
|
+
case '--force':
|
|
99
|
+
flags.force = true;
|
|
100
|
+
break;
|
|
101
|
+
case '--repair':
|
|
102
|
+
flags.repair = true;
|
|
103
|
+
break;
|
|
104
|
+
case '--dot':
|
|
105
|
+
flags.dot = true;
|
|
106
|
+
break;
|
|
107
|
+
case '--packages':
|
|
108
|
+
flags.packages = true;
|
|
109
|
+
break;
|
|
110
|
+
case '--help':
|
|
111
|
+
case '-h':
|
|
112
|
+
flags.help = true;
|
|
113
|
+
break;
|
|
114
|
+
case '--version':
|
|
115
|
+
flags.version = true;
|
|
116
|
+
break;
|
|
117
|
+
case '--since':
|
|
118
|
+
flags.since = need(i++, a);
|
|
119
|
+
break;
|
|
120
|
+
case '--root':
|
|
121
|
+
flags.root = need(i++, a);
|
|
122
|
+
break;
|
|
123
|
+
case '--concurrency': {
|
|
124
|
+
const n = Number(need(i++, a));
|
|
125
|
+
if (!Number.isInteger(n) || n < 1)
|
|
126
|
+
throw new UsageError('--concurrency must be a positive integer');
|
|
127
|
+
flags.concurrency = n;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
case '--':
|
|
131
|
+
positional.push(...argv.slice(i + 1));
|
|
132
|
+
i = argv.length;
|
|
133
|
+
break;
|
|
134
|
+
default:
|
|
135
|
+
if (a.startsWith('-') && a.length > 1)
|
|
136
|
+
throw new UsageError(`unknown option ${a}`);
|
|
137
|
+
positional.push(a);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return { positional, flags };
|
|
141
|
+
}
|
|
142
|
+
class UsageError extends Error {
|
|
143
|
+
}
|
|
144
|
+
const color = process.stdout.isTTY && !process.env.NO_COLOR && process.env.TERM !== 'dumb';
|
|
145
|
+
const paint = (code, s) => (color ? `\x1b[${code}m${s}\x1b[0m` : s);
|
|
146
|
+
const dim = (s) => paint(2, s);
|
|
147
|
+
function fmtMs(ms) {
|
|
148
|
+
return ms < 1000 ? `${Math.round(ms)}ms` : `${(ms / 1000).toFixed(ms < 10_000 ? 2 : 1)}s`;
|
|
149
|
+
}
|
|
150
|
+
function fmtBytes(n) {
|
|
151
|
+
if (n < 1024)
|
|
152
|
+
return `${n} B`;
|
|
153
|
+
const u = ['KiB', 'MiB', 'GiB', 'TiB'];
|
|
154
|
+
let v = n / 1024;
|
|
155
|
+
let i = 0;
|
|
156
|
+
while (v >= 1024 && i < u.length - 1) {
|
|
157
|
+
v /= 1024;
|
|
158
|
+
i++;
|
|
159
|
+
}
|
|
160
|
+
return `${v.toFixed(1)} ${u[i]}`;
|
|
161
|
+
}
|
|
162
|
+
export async function main(argv) {
|
|
163
|
+
let parsed;
|
|
164
|
+
try {
|
|
165
|
+
parsed = parseArgs(argv);
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
console.error(`buildrush: ${e.message}\nRun \`buildrush --help\` for usage.`);
|
|
169
|
+
return EXIT.USAGE;
|
|
170
|
+
}
|
|
171
|
+
const { positional, flags } = parsed;
|
|
172
|
+
if (flags.version) {
|
|
173
|
+
console.log(VERSION);
|
|
174
|
+
return EXIT.OK;
|
|
175
|
+
}
|
|
176
|
+
const [cmd, ...rest] = positional;
|
|
177
|
+
if (flags.help || !cmd || cmd === 'help') {
|
|
178
|
+
console.log(HELP);
|
|
179
|
+
return cmd || flags.help ? EXIT.OK : EXIT.USAGE;
|
|
180
|
+
}
|
|
181
|
+
const ac = new AbortController();
|
|
182
|
+
let interrupted = 0;
|
|
183
|
+
const onSig = () => {
|
|
184
|
+
if (++interrupted > 1)
|
|
185
|
+
process.exit(EXIT.CANCELLED);
|
|
186
|
+
if (!flags.json)
|
|
187
|
+
console.error('\nbuildrush: cancelling (press Ctrl+C again to force quit)...');
|
|
188
|
+
ac.abort();
|
|
189
|
+
};
|
|
190
|
+
process.on('SIGINT', onSig);
|
|
191
|
+
process.on('SIGTERM', onSig);
|
|
192
|
+
try {
|
|
193
|
+
if (flags.watch && !['run', 'build', 'test', 'check'].includes(cmd))
|
|
194
|
+
throw new UsageError('--watch only applies to run, build, test and check');
|
|
195
|
+
switch (cmd) {
|
|
196
|
+
case 'init': return await cmdInit(flags);
|
|
197
|
+
case 'analyze': return await cmdAnalyze(flags);
|
|
198
|
+
case 'graph': return await cmdGraph(flags);
|
|
199
|
+
case 'run': return await (flags.watch ? cmdWatch : cmdRun)(rest.length ? rest : ['default'], flags, ac.signal);
|
|
200
|
+
case 'build':
|
|
201
|
+
case 'test':
|
|
202
|
+
case 'check': return await (flags.watch ? cmdWatch : cmdRun)([cmd], flags, ac.signal);
|
|
203
|
+
case 'explain': return await cmdExplain(rest[0], flags);
|
|
204
|
+
case 'cache': return await cmdCache(rest[0], flags);
|
|
205
|
+
case 'doctor': return await cmdDoctor(flags);
|
|
206
|
+
case 'daemon':
|
|
207
|
+
if (!['start', 'stop', 'status', '__serve'].includes(rest[0] ?? ''))
|
|
208
|
+
throw new UsageError('usage: buildrush daemon start|stop|status');
|
|
209
|
+
return await cmdDaemon(rest[0], startDir(flags), flags, rest.slice(1));
|
|
210
|
+
case 'config':
|
|
211
|
+
if (rest[0] === 'validate')
|
|
212
|
+
return await cmdValidate(flags);
|
|
213
|
+
throw new UsageError('usage: buildrush config validate');
|
|
214
|
+
default: throw new UsageError(`unknown command ${JSON.stringify(cmd)}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch (e) {
|
|
218
|
+
if (e instanceof UsageError || e instanceof ConfigError) {
|
|
219
|
+
console.error(`buildrush: ${e.message}${e instanceof UsageError ? '\nRun `buildrush --help` for usage.' : ''}`);
|
|
220
|
+
return EXIT.USAGE;
|
|
221
|
+
}
|
|
222
|
+
if (e instanceof Error && /no buildrush\.json|unknown task|dependency cycle/.test(e.message)) {
|
|
223
|
+
console.error(`buildrush: ${e.message}`);
|
|
224
|
+
return EXIT.USAGE;
|
|
225
|
+
}
|
|
226
|
+
throw e;
|
|
227
|
+
}
|
|
228
|
+
finally {
|
|
229
|
+
process.off('SIGINT', onSig);
|
|
230
|
+
process.off('SIGTERM', onSig);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
const startDir = (f) => path.resolve(f.root ?? process.cwd());
|
|
234
|
+
const open = (f, scan = true) => Project.open(startDir(f), { scan });
|
|
235
|
+
const printJson = (v) => console.log(JSON.stringify(v, null, 2));
|
|
236
|
+
async function cmdInit(f) {
|
|
237
|
+
const root = startDir(f);
|
|
238
|
+
const file = path.join(root, CONFIG_FILE);
|
|
239
|
+
if (!f.force && (await fs.access(file).then(() => true, () => false))) {
|
|
240
|
+
console.error(`buildrush: ${CONFIG_FILE} already exists (use --force to overwrite)`);
|
|
241
|
+
return EXIT.USAGE;
|
|
242
|
+
}
|
|
243
|
+
const det = await detectProject(root);
|
|
244
|
+
const cfg = starterConfig(det);
|
|
245
|
+
if (Object.keys(cfg.tasks).length === 0) {
|
|
246
|
+
console.error('buildrush: no supported tools or package scripts detected (looked for vite, vitest, eslint, typescript and build/test/lint scripts).\n' +
|
|
247
|
+
`Create ${CONFIG_FILE} by hand; see docs/configuration.md.`);
|
|
248
|
+
return EXIT.USAGE;
|
|
249
|
+
}
|
|
250
|
+
await writeFileAtomic(file, JSON.stringify(cfg, null, 2) + '\n', 0o644);
|
|
251
|
+
if (f.json)
|
|
252
|
+
printJson({ created: file, detected: det });
|
|
253
|
+
else {
|
|
254
|
+
console.log(`Created ${CONFIG_FILE} (${Object.keys(cfg.tasks).join(', ')}).`);
|
|
255
|
+
console.log(`Detected: ${det.packageManager ?? 'no lockfile'}, tools: ${det.tools.join(', ') || 'none'}.`);
|
|
256
|
+
console.log('Next: add ".buildrush/" to .gitignore, review the file, then run `buildrush doctor` and `buildrush run`.');
|
|
257
|
+
}
|
|
258
|
+
return EXIT.OK;
|
|
259
|
+
}
|
|
260
|
+
async function cmdValidate(f) {
|
|
261
|
+
const root = await findProjectRoot(startDir(f));
|
|
262
|
+
if (!root)
|
|
263
|
+
throw new Error(`no ${CONFIG_FILE} found`);
|
|
264
|
+
const cfg = await loadConfig(root);
|
|
265
|
+
if (f.json)
|
|
266
|
+
printJson({ ok: true, tasks: Object.keys(cfg.tasks) });
|
|
267
|
+
else
|
|
268
|
+
console.log(`${CONFIG_FILE} is valid (${Object.keys(cfg.tasks).length} tasks).`);
|
|
269
|
+
return EXIT.OK;
|
|
270
|
+
}
|
|
271
|
+
async function cmdAnalyze(f) {
|
|
272
|
+
if (f.json && daemonWanted(f)) {
|
|
273
|
+
const via = await tryDaemon(startDir(f), 'analyze', {});
|
|
274
|
+
if (via.ok) {
|
|
275
|
+
printJson(via.data);
|
|
276
|
+
return EXIT.OK;
|
|
277
|
+
}
|
|
278
|
+
if (f.verbose)
|
|
279
|
+
console.error(`buildrush: daemon unavailable (${via.reason}); analysing in-process`);
|
|
280
|
+
}
|
|
281
|
+
const p = await open(f);
|
|
282
|
+
const { result, det, g, uncertain, cycles, edges } = await analyze(p);
|
|
283
|
+
if (f.json) {
|
|
284
|
+
printJson(result);
|
|
285
|
+
return EXIT.OK;
|
|
286
|
+
}
|
|
287
|
+
console.log(`${result.project} (${p.root})`);
|
|
288
|
+
console.log(` package manager : ${det.packageManager ?? 'none detected'}${det.lockfiles.length > 1 ? ` (WARNING: multiple lockfiles: ${det.lockfiles.join(', ')})` : ''}`);
|
|
289
|
+
console.log(` tools : ${det.tools.join(', ') || 'none detected'}`);
|
|
290
|
+
console.log(` files indexed : ${result.files} modules: ${result.modules} import edges: ${edges} tests: ${result.tests}`);
|
|
291
|
+
if (p.workspace) {
|
|
292
|
+
const ws = p.workspace;
|
|
293
|
+
console.log(` workspace : ${ws.manager} (${ws.source}), ${ws.packages.length} package(s)`);
|
|
294
|
+
for (const k of ws.packages)
|
|
295
|
+
console.log(` - ${k.name}@${k.version ?? '?'} ${k.dir}${k.workspaceDeps.length ? ` -> ${k.workspaceDeps.join(', ')}` : ''}`);
|
|
296
|
+
const cyc = ws.findCycle();
|
|
297
|
+
if (cyc)
|
|
298
|
+
console.log(` WARNING package dependency cycle: ${cyc.join(' -> ')}`);
|
|
299
|
+
for (const w of ws.warnings)
|
|
300
|
+
console.log(` warning: ${w}`);
|
|
301
|
+
}
|
|
302
|
+
else if (g.workspacePackages.size > 1)
|
|
303
|
+
console.log(` workspace pkgs : ${[...g.workspacePackages.keys()].join(', ')}`);
|
|
304
|
+
console.log(` tasks : ${Object.keys(p.config.tasks).join(', ')}`);
|
|
305
|
+
console.log(` import cycles : ${cycles.length}`);
|
|
306
|
+
for (const c of cycles.slice(0, 5))
|
|
307
|
+
console.log(` - ${c.join(' <-> ')}`);
|
|
308
|
+
console.log(` uncertain : ${uncertain.length} module(s) with dynamic/unresolved imports (handled conservatively)`);
|
|
309
|
+
for (const m of uncertain.slice(0, 5))
|
|
310
|
+
console.log(` - ${m.path}: ${m.uncertain[0]}`);
|
|
311
|
+
if (p.index.skippedSymlinks.length)
|
|
312
|
+
console.log(` symlinks : ${p.index.skippedSymlinks.length} skipped (never followed)`);
|
|
313
|
+
return EXIT.OK;
|
|
314
|
+
}
|
|
315
|
+
async function cmdGraph(f) {
|
|
316
|
+
const p = await open(f);
|
|
317
|
+
const g = await p.graph();
|
|
318
|
+
if (f.packages) {
|
|
319
|
+
if (!p.workspace)
|
|
320
|
+
throw new UsageError('--packages needs a workspace (none detected; see docs/configuration.md)');
|
|
321
|
+
const ws = p.workspace;
|
|
322
|
+
const edges = ws.packages.flatMap((k) => k.workspaceDeps.map((d) => ({ from: k.name, to: d, via: 'package.json' })));
|
|
323
|
+
for (const [from, tos] of packageImportEdges(g))
|
|
324
|
+
for (const to of tos)
|
|
325
|
+
if (!edges.some((e) => e.from === from && e.to === to))
|
|
326
|
+
edges.push({ from, to, via: 'import' });
|
|
327
|
+
if (f.dot) {
|
|
328
|
+
console.log(['digraph packages {', ' rankdir=LR;', ...edges.map((e) => ` ${JSON.stringify(e.from)} -> ${JSON.stringify(e.to)} [label=${JSON.stringify(e.via)}];`), '}'].join('\n'));
|
|
329
|
+
}
|
|
330
|
+
else
|
|
331
|
+
printJson({ packages: ws.summary().packages, edges });
|
|
332
|
+
return EXIT.OK;
|
|
333
|
+
}
|
|
334
|
+
if (f.dot) {
|
|
335
|
+
const lines = ['digraph buildrush {', ' rankdir=LR;'];
|
|
336
|
+
if (p.workspace) {
|
|
337
|
+
p.workspace.packages.forEach((k, i) => {
|
|
338
|
+
const members = [...g.modules.values()].filter((m) => m.pkg === k.name).map((m) => ` ${JSON.stringify(m.path)};`);
|
|
339
|
+
lines.push(` subgraph ${JSON.stringify(`cluster_${i}`)} {`, ` label=${JSON.stringify(k.name)};`, ...members, ' }');
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
for (const [from, m] of g.deps)
|
|
343
|
+
for (const [to, kind] of m)
|
|
344
|
+
lines.push(` ${JSON.stringify(from)} -> ${JSON.stringify(to)} [label=${JSON.stringify(kind)}];`);
|
|
345
|
+
lines.push('}');
|
|
346
|
+
console.log(lines.join('\n'));
|
|
347
|
+
}
|
|
348
|
+
else
|
|
349
|
+
printJson(p.workspace ? { ...g.serialize(), workspace: p.workspace.summary() } : g.serialize());
|
|
350
|
+
return EXIT.OK;
|
|
351
|
+
}
|
|
352
|
+
function line(r, verbose) {
|
|
353
|
+
const label = { cached: '[cached]', succeeded: '[ran]', failed: '[FAILED]', skipped: '[skipped]', cancelled: '[cancelled]', pending: '[pending]', ready: '[ready]', running: '[running]' }[r.state];
|
|
354
|
+
const colored = r.state === 'failed' ? paint(31, label) : r.state === 'cached' ? paint(32, label) : r.state === 'succeeded' ? paint(36, label) : paint(33, label);
|
|
355
|
+
const pad = ' '.repeat(Math.max(0, 11 - label.length));
|
|
356
|
+
let s = `${colored}${pad} ${r.task.padEnd(14)} ${fmtMs(r.durationMs).padStart(7)}`;
|
|
357
|
+
if (r.state === 'cached')
|
|
358
|
+
s += ` ${dim(r.testCache ? `${r.testCache.skipped.length} test file(s) skipped` : `restored ${fmtBytes(r.restoredBytes)}`)}`;
|
|
359
|
+
if (r.testCache) {
|
|
360
|
+
for (const x of r.testCache.skipped)
|
|
361
|
+
s += `\n ${dim(`skip ${x.test}: ${x.reason}`)}`;
|
|
362
|
+
if (verbose)
|
|
363
|
+
for (const x of r.testCache.ran)
|
|
364
|
+
s += `\n ${dim(`run ${x.test}: ${x.reason}`)}`;
|
|
365
|
+
}
|
|
366
|
+
if (r.state === 'succeeded' && r.reasons.length)
|
|
367
|
+
s += ` ${dim('why: ' + r.reasons[0] + (r.reasons.length > 1 ? ` (+${r.reasons.length - 1} more)` : ''))}`;
|
|
368
|
+
if (r.notes.length && (verbose || r.state !== 'cached'))
|
|
369
|
+
for (const n of r.notes)
|
|
370
|
+
s += `\n ${dim('note: ' + n)}`;
|
|
371
|
+
if (verbose && r.reasons.length > 1)
|
|
372
|
+
for (const x of r.reasons.slice(1))
|
|
373
|
+
s += `\n ${dim('why: ' + x)}`;
|
|
374
|
+
return s;
|
|
375
|
+
}
|
|
376
|
+
async function cmdRun(names, f, signal) {
|
|
377
|
+
const header = (project, tasks) => {
|
|
378
|
+
if (!f.json && !f.quiet)
|
|
379
|
+
console.log(dim(`BuildRush ${VERSION} · ${project} · ${tasks} task(s)`));
|
|
380
|
+
};
|
|
381
|
+
const onTaskDone = (r) => {
|
|
382
|
+
if (f.json)
|
|
383
|
+
return;
|
|
384
|
+
const bad = r.state === 'failed' || r.state === 'cancelled';
|
|
385
|
+
if (f.quiet && !bad)
|
|
386
|
+
return;
|
|
387
|
+
console.log(line(r, f.verbose));
|
|
388
|
+
for (const d of r.diagnostics.slice(0, 10))
|
|
389
|
+
console.log(` ! ${d}`);
|
|
390
|
+
if (r.log && (r.state === 'failed' || f.verbose))
|
|
391
|
+
console.log(r.log.replace(/\n$/, '').split('\n').map((l) => ' | ' + l).join('\n'));
|
|
392
|
+
};
|
|
393
|
+
let remote = null;
|
|
394
|
+
if (daemonWanted(f)) {
|
|
395
|
+
// Opt-in fast path. Anything other than a complete result (including a crash mid-run) falls
|
|
396
|
+
// through to the ordinary in-process run below; the cache makes re-doing finished work free.
|
|
397
|
+
const via = await tryDaemon(startDir(f), 'run', { tasks: names, flags: { noCache: f.noCache, bail: f.bail, concurrency: f.concurrency, affected: f.affected, since: f.since } }, {
|
|
398
|
+
signal,
|
|
399
|
+
onMessage: (m) => {
|
|
400
|
+
if (m.type === 'begin')
|
|
401
|
+
header(m.project, m.tasks);
|
|
402
|
+
else if (m.type === 'task')
|
|
403
|
+
onTaskDone(m.report);
|
|
404
|
+
},
|
|
405
|
+
});
|
|
406
|
+
if (via.ok)
|
|
407
|
+
remote = via.data;
|
|
408
|
+
else if (via.midRun) {
|
|
409
|
+
// Not re-run silently: tasks may already have executed. The cache makes an explicit re-run cheap.
|
|
410
|
+
console.error(`buildrush: the daemon failed mid-run (${via.reason}); some tasks may have executed. Re-run with --no-daemon.`);
|
|
411
|
+
return EXIT.INTERNAL;
|
|
412
|
+
}
|
|
413
|
+
else if (f.verbose)
|
|
414
|
+
console.error(`buildrush: daemon unavailable (${via.reason}); running in-process`);
|
|
415
|
+
}
|
|
416
|
+
const runLocal = async () => {
|
|
417
|
+
const p = await open(f);
|
|
418
|
+
for (const n of names) {
|
|
419
|
+
if (!p.config.tasks[n] && !p.config.pipelines[n] && !p.taskGroups[n]) {
|
|
420
|
+
throw new Error(`unknown task ${JSON.stringify(n)} (tasks: ${Object.keys(p.config.tasks).join(', ')}; pipelines: ${Object.keys(p.config.pipelines).join(', ') || 'none'}${Object.keys(p.taskGroups).length ? `; per-package tasks: ${Object.keys(p.taskGroups).join(', ')}` : ''})`);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
header(p.config.project.name, closure(p, expandNames(p, names)).length);
|
|
424
|
+
const r = await runTasks(p, names, {
|
|
425
|
+
noCache: f.noCache,
|
|
426
|
+
bail: f.bail,
|
|
427
|
+
concurrency: f.concurrency,
|
|
428
|
+
affected: f.affected ? { since: f.since } : null,
|
|
429
|
+
signal,
|
|
430
|
+
onTaskDone,
|
|
431
|
+
});
|
|
432
|
+
await writeLastRun(p, names, r);
|
|
433
|
+
return r;
|
|
434
|
+
};
|
|
435
|
+
const report = remote ?? (await runLocal());
|
|
436
|
+
const count = (s) => report.tasks.filter((t) => t.state === s).length;
|
|
437
|
+
const saved = report.tasks.reduce((n, t) => n + t.savedMsEstimate, 0);
|
|
438
|
+
if (f.json) {
|
|
439
|
+
printJson({ ok: report.ok, cancelled: report.cancelled, durationMs: report.durationMs, selection: report.selection, packages: report.packages ?? null, tasks: report.tasks.map((t) => ({ ...t, log: f.verbose ? t.log : undefined })) });
|
|
440
|
+
}
|
|
441
|
+
else if (!f.quiet || !report.ok) {
|
|
442
|
+
if (report.packages && !f.quiet) {
|
|
443
|
+
const k = report.packages;
|
|
444
|
+
console.log(dim(k.mode === 'all' ? `package selection: ALL packages (${k.reason})` : `package selection: ${k.affected.length} affected (${k.affected.join(', ') || 'none'}), ${k.skipped.length} unaffected`));
|
|
445
|
+
}
|
|
446
|
+
if (report.selection && !f.quiet) {
|
|
447
|
+
const s = report.selection;
|
|
448
|
+
console.log(dim(s.mode === 'all' ? `test selection: ALL tests (${s.reason})` : `test selection: ${s.selected.length} selected, ${s.skipped.length} skipped, ${s.changed.length} changed file(s)`));
|
|
449
|
+
}
|
|
450
|
+
console.log(`\n${report.ok ? 'BuildRush succeeded' : report.cancelled ? 'BuildRush cancelled' : 'BuildRush FAILED'}: ` +
|
|
451
|
+
`${count('succeeded')} ran, ${count('cached')} cached, ${count('failed')} failed, ${count('skipped')} skipped` +
|
|
452
|
+
`${count('cancelled') ? `, ${count('cancelled')} cancelled` : ''} in ${fmtMs(report.durationMs)}` +
|
|
453
|
+
(saved > 0 ? dim(` (estimated time saved by cache: ${fmtMs(saved)}; estimate = original run duration)`) : ''));
|
|
454
|
+
}
|
|
455
|
+
return report.ok ? EXIT.OK : report.cancelled ? EXIT.CANCELLED : EXIT.FAILED;
|
|
456
|
+
}
|
|
457
|
+
async function cmdExplain(target, f) {
|
|
458
|
+
const p = await open(f);
|
|
459
|
+
const last = await readJson(path.join(p.stateDir, 'last-run.json'));
|
|
460
|
+
if (!target) {
|
|
461
|
+
if (!last) {
|
|
462
|
+
console.log('No run recorded yet. Run `buildrush run` first.');
|
|
463
|
+
return EXIT.OK;
|
|
464
|
+
}
|
|
465
|
+
if (f.json) {
|
|
466
|
+
printJson(last);
|
|
467
|
+
return EXIT.OK;
|
|
468
|
+
}
|
|
469
|
+
console.log(`Last run: ${new Date(last.at).toISOString()}`);
|
|
470
|
+
for (const t of last.tasks) {
|
|
471
|
+
console.log(` ${t.task}: ${t.state}${t.cache === 'hit' ? ' (cache hit)' : ''}`);
|
|
472
|
+
for (const r of t.reasons)
|
|
473
|
+
console.log(` why it ran: ${r}`);
|
|
474
|
+
for (const n of t.notes)
|
|
475
|
+
console.log(` note: ${n}`);
|
|
476
|
+
}
|
|
477
|
+
return EXIT.OK;
|
|
478
|
+
}
|
|
479
|
+
if (p.config.tasks[target]) {
|
|
480
|
+
const t = p.config.tasks[target];
|
|
481
|
+
const st = await loadTaskState(p, target);
|
|
482
|
+
const lastRep = last?.tasks.find((x) => x.task === target);
|
|
483
|
+
const info = {
|
|
484
|
+
task: target, command: t.command, dependsOn: t.dependsOn, cache: t.cache,
|
|
485
|
+
lastState: lastRep?.state ?? null, lastReasons: lastRep?.reasons ?? [], lastNotes: lastRep?.notes ?? [],
|
|
486
|
+
lastSuccessfulFingerprint: st?.fingerprint ?? null, inputsAtLastSuccess: st ? Object.keys(st.components.inputs).length : null,
|
|
487
|
+
};
|
|
488
|
+
if (f.json)
|
|
489
|
+
printJson(info);
|
|
490
|
+
else {
|
|
491
|
+
console.log(`${target}: ${t.command.join(' ')}`);
|
|
492
|
+
console.log(` depends on : ${t.dependsOn.join(', ') || '-'}`);
|
|
493
|
+
console.log(` last state : ${info.lastState ?? 'never run'}`);
|
|
494
|
+
for (const r of info.lastReasons)
|
|
495
|
+
console.log(` why it ran: ${r}`);
|
|
496
|
+
for (const n of info.lastNotes)
|
|
497
|
+
console.log(` note: ${n}`);
|
|
498
|
+
if (st)
|
|
499
|
+
console.log(` last good fingerprint: ${st.fingerprint.slice(0, 16)} (${info.inputsAtLastSuccess} input files)`);
|
|
500
|
+
}
|
|
501
|
+
return EXIT.OK;
|
|
502
|
+
}
|
|
503
|
+
// A file: show what it affects.
|
|
504
|
+
const rel = path.relative(p.root, path.resolve(startDir(f), target)).split(path.sep).join('/');
|
|
505
|
+
if (rel.startsWith('..'))
|
|
506
|
+
throw new UsageError(`${target} is outside the project`);
|
|
507
|
+
const g = await p.graph();
|
|
508
|
+
const { reached, conservative } = g.impact([rel]);
|
|
509
|
+
const direct = Object.values(p.config.tasks).filter((t) => t.inputs === null || compileGlobs(t.inputs)(rel)).map((t) => t.name);
|
|
510
|
+
const affectedTasks = new Set(direct);
|
|
511
|
+
for (let grew = true; grew;) {
|
|
512
|
+
grew = false;
|
|
513
|
+
for (const t of Object.values(p.config.tasks))
|
|
514
|
+
if (!affectedTasks.has(t.name) && t.dependsOn.some((d) => affectedTasks.has(d))) {
|
|
515
|
+
affectedTasks.add(t.name);
|
|
516
|
+
grew = true;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
const sel = selectTests(g, null, [rel]);
|
|
520
|
+
const owner = p.workspace?.packageOfFile(rel) ?? null;
|
|
521
|
+
const out = {
|
|
522
|
+
file: rel, package: owner?.name ?? null, known: p.index.files.has(rel), affectedTasks: [...affectedTasks], conservative,
|
|
523
|
+
importedBy: [...reached.keys()].filter((k) => k !== rel).map((k) => ({ module: k, chain: g.chain(reached, k) })),
|
|
524
|
+
tests: { mode: sel.mode, selected: sel.selected, chains: sel.chains },
|
|
525
|
+
};
|
|
526
|
+
if (f.json) {
|
|
527
|
+
printJson(out);
|
|
528
|
+
return EXIT.OK;
|
|
529
|
+
}
|
|
530
|
+
console.log(`${rel}${out.known ? '' : ' (not in the index: new, deleted, ignored or outside the project)'}`);
|
|
531
|
+
if (p.workspace)
|
|
532
|
+
console.log(` package : ${out.package ?? '(outside every workspace package)'}`);
|
|
533
|
+
console.log(` tasks affected : ${out.affectedTasks.join(', ') || 'none'}`);
|
|
534
|
+
if (conservative)
|
|
535
|
+
console.log(` CONSERVATIVE : ${conservative} -> all tests run`);
|
|
536
|
+
console.log(` modules affected (${out.importedBy.length}):`);
|
|
537
|
+
for (const m of out.importedBy.slice(0, 15))
|
|
538
|
+
console.log(` ${m.chain.join(' -> ')}`);
|
|
539
|
+
if (out.importedBy.length > 15)
|
|
540
|
+
console.log(` ...and ${out.importedBy.length - 15} more`);
|
|
541
|
+
console.log(` tests selected (${sel.selected.length}${sel.mode === 'all' ? ', all' : ''}): ${sel.selected.slice(0, 10).join(', ') || 'none'}`);
|
|
542
|
+
return EXIT.OK;
|
|
543
|
+
}
|
|
544
|
+
async function cmdCache(sub, f) {
|
|
545
|
+
const p = await open(f, false);
|
|
546
|
+
switch (sub) {
|
|
547
|
+
case 'stats': {
|
|
548
|
+
let cs = null;
|
|
549
|
+
if (daemonWanted(f)) {
|
|
550
|
+
const via = await tryDaemon(startDir(f), 'cacheStats', {});
|
|
551
|
+
if (via.ok)
|
|
552
|
+
cs = via.data;
|
|
553
|
+
else if (f.verbose)
|
|
554
|
+
console.error(`buildrush: daemon unavailable (${via.reason}); reading in-process`);
|
|
555
|
+
}
|
|
556
|
+
const { stats: s, lifetime: life, maxSizeMB } = cs ?? (await cacheStats(p));
|
|
557
|
+
if (f.json) {
|
|
558
|
+
printJson({ ...s, lifetime: life });
|
|
559
|
+
break;
|
|
560
|
+
}
|
|
561
|
+
console.log(`cache: ${s.dir}`);
|
|
562
|
+
console.log(` entries ${s.entries}, blobs ${s.blobs}, size ${fmtBytes(s.bytes)} (limit ${maxSizeMB} MiB)`);
|
|
563
|
+
console.log(` lifetime: ${life.hits} hit(s), ${life.misses} miss(es), restored ${fmtBytes(life.bytesRestored)}, stored ${fmtBytes(life.bytesStored)}`);
|
|
564
|
+
console.log(` estimated time saved: ${fmtMs(life.estimatedSavedMs)} (estimate: sum of original durations of reused results)`);
|
|
565
|
+
break;
|
|
566
|
+
}
|
|
567
|
+
case 'verify': {
|
|
568
|
+
const r = await p.cache.verify({ repair: f.repair });
|
|
569
|
+
if (f.json)
|
|
570
|
+
printJson(r);
|
|
571
|
+
else {
|
|
572
|
+
console.log(`verified ${r.entries} entries, ${r.blobs} blobs: ${r.corruptBlobs.length} corrupt blob(s), ${r.badEntries.length} bad entr(ies), ${r.missingBlobs.length} missing blob reference(s)`);
|
|
573
|
+
if (f.repair)
|
|
574
|
+
console.log(`repaired: ${r.repaired}`);
|
|
575
|
+
}
|
|
576
|
+
return r.corruptBlobs.length + r.badEntries.length + r.missingBlobs.length > 0 && !f.repair ? EXIT.FAILED : EXIT.OK;
|
|
577
|
+
}
|
|
578
|
+
case 'clean': {
|
|
579
|
+
await p.cache.clean();
|
|
580
|
+
await fs.rm(path.join(p.stateDir, 'tasks'), { recursive: true, force: true });
|
|
581
|
+
if (f.json)
|
|
582
|
+
printJson({ cleaned: true });
|
|
583
|
+
else
|
|
584
|
+
console.log('cache cleaned.');
|
|
585
|
+
break;
|
|
586
|
+
}
|
|
587
|
+
default: throw new UsageError('usage: buildrush cache stats|verify|clean');
|
|
588
|
+
}
|
|
589
|
+
return EXIT.OK;
|
|
590
|
+
}
|
|
591
|
+
async function cmdDoctor(f) {
|
|
592
|
+
const checks = await runDoctor(startDir(f));
|
|
593
|
+
if (f.json)
|
|
594
|
+
printJson(checks);
|
|
595
|
+
else {
|
|
596
|
+
for (const c of checks)
|
|
597
|
+
console.log(`${{ ok: '[ok] ', warn: '[warn]', fail: '[FAIL]' }[c.status]} ${c.name}: ${c.detail}`);
|
|
598
|
+
}
|
|
599
|
+
return checks.some((c) => c.status === 'fail') ? EXIT.FAILED : EXIT.OK;
|
|
600
|
+
}
|
|
601
|
+
// ---- watch mode ---------------------------------------------------------------------------------
|
|
602
|
+
function describeChanges(c) {
|
|
603
|
+
const all = [...c.added.map((x) => `+${x}`), ...c.modified.map((x) => `~${x}`), ...c.removed.map((x) => `-${x}`)];
|
|
604
|
+
return all.slice(0, 6).join(' ') + (all.length > 6 ? ` ...and ${all.length - 6} more` : '');
|
|
605
|
+
}
|
|
606
|
+
async function cmdWatch(names, f, signal) {
|
|
607
|
+
const p = await open(f);
|
|
608
|
+
for (const n of names) {
|
|
609
|
+
if (!p.config.tasks[n] && !p.config.pipelines[n]) {
|
|
610
|
+
throw new Error(`unknown task ${JSON.stringify(n)} (tasks: ${Object.keys(p.config.tasks).join(', ')}; pipelines: ${Object.keys(p.config.pipelines).join(', ') || 'none'})`);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
if (!f.json && !f.quiet)
|
|
614
|
+
console.log(dim(`BuildRush ${VERSION} · ${p.config.project.name} · watching ${closure(p, expandNames(p, names)).length} task(s) · Ctrl+C to stop`));
|
|
615
|
+
let writes = Promise.resolve();
|
|
616
|
+
const session = await startWatch(p, {
|
|
617
|
+
tasks: names,
|
|
618
|
+
run: { noCache: f.noCache, bail: f.bail, concurrency: f.concurrency, affected: f.affected ? { since: f.since } : null },
|
|
619
|
+
signal,
|
|
620
|
+
onNotice: (m) => console.error(`buildrush: ${m}`),
|
|
621
|
+
onCycleStart: ({ n, trigger, changed }) => {
|
|
622
|
+
if (f.json || f.quiet)
|
|
623
|
+
return;
|
|
624
|
+
const what = trigger === 'initial' ? 'initial run' : describeChanges(changed);
|
|
625
|
+
const how = trigger === 'reconcile' ? ' (found by reconciliation scan; the watcher did not report it)' : trigger === 'error' ? ' (found after a watcher error)' : '';
|
|
626
|
+
console.log(`\n${dim(`--- cycle ${n}: ${what}${how}`)}`);
|
|
627
|
+
},
|
|
628
|
+
onTaskDone: (r) => {
|
|
629
|
+
if (f.json)
|
|
630
|
+
return;
|
|
631
|
+
const bad = r.state === 'failed' || r.state === 'cancelled';
|
|
632
|
+
if (f.quiet && !bad)
|
|
633
|
+
return;
|
|
634
|
+
console.log(line(r, f.verbose));
|
|
635
|
+
for (const d of r.diagnostics.slice(0, 10))
|
|
636
|
+
console.log(` ! ${d}`);
|
|
637
|
+
if (r.log && (r.state === 'failed' || f.verbose))
|
|
638
|
+
console.log(r.log.replace(/\n$/, '').split('\n').map((l) => ' | ' + l).join('\n'));
|
|
639
|
+
},
|
|
640
|
+
onCycle: (c) => {
|
|
641
|
+
const tasks = c.report?.tasks ?? [];
|
|
642
|
+
const count = (s) => tasks.filter((t) => t.state === s).length;
|
|
643
|
+
if (c.report && !c.superseded) {
|
|
644
|
+
const r = c.report;
|
|
645
|
+
writes = writes.then(() => writeFileAtomic(path.join(p.stateDir, 'last-run.json'), JSON.stringify({ at: Date.now(), requested: names, tasks: r.tasks.map((t) => ({ ...t, log: undefined })), selection: r.selection })).catch(() => undefined));
|
|
646
|
+
}
|
|
647
|
+
if (f.json) {
|
|
648
|
+
console.log(JSON.stringify({
|
|
649
|
+
cycle: c.n, trigger: c.trigger, at: new Date().toISOString(), changed: c.changed,
|
|
650
|
+
ok: c.report?.ok ?? false, cancelled: c.report?.cancelled ?? false, superseded: c.superseded,
|
|
651
|
+
configReloaded: c.configReloaded, error: c.error, scanMs: c.scanMs, durationMs: c.durationMs,
|
|
652
|
+
counts: { ran: count('succeeded'), cached: count('cached'), failed: count('failed'), skipped: count('skipped'), cancelled: count('cancelled') },
|
|
653
|
+
selection: c.report?.selection ?? null,
|
|
654
|
+
tasks: tasks.map((t) => ({ ...t, log: f.verbose ? t.log : undefined })),
|
|
655
|
+
}));
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
if (c.configReloaded)
|
|
659
|
+
console.log(dim('configuration reloaded'));
|
|
660
|
+
if (c.error) {
|
|
661
|
+
console.log(paint(31, `cycle ${c.n} error: ${c.error}`) + dim(' (waiting for changes)'));
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
if (c.superseded) {
|
|
665
|
+
console.log(paint(33, `cycle ${c.n} superseded by newer changes after ${fmtMs(c.durationMs)}; results discarded, restarting`));
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
if (c.report?.cancelled) {
|
|
669
|
+
console.log(paint(33, `cycle ${c.n} cancelled after ${fmtMs(c.durationMs)}`));
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
if (!f.quiet || !c.report?.ok) {
|
|
673
|
+
console.log(`${c.report?.ok ? 'ok' : paint(31, 'FAILED')} cycle ${c.n}: ${count('succeeded')} ran, ${count('cached')} cached, ${count('failed')} failed, ${count('skipped')} skipped in ${fmtMs(c.durationMs)}` +
|
|
674
|
+
dim(' (waiting for changes)'));
|
|
675
|
+
}
|
|
676
|
+
},
|
|
677
|
+
});
|
|
678
|
+
await session.done;
|
|
679
|
+
await writes;
|
|
680
|
+
if (!f.json)
|
|
681
|
+
console.log(dim('\nwatch stopped.'));
|
|
682
|
+
return EXIT.OK;
|
|
683
|
+
}
|
|
684
|
+
//# sourceMappingURL=cli.js.map
|