next-issue 16.4.0 → 16.5.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/dist/cli/start.mjs +1 -1
- package/dist/cli/switch-run.mjs +39 -7
- package/dist/shared/args.mjs +2 -2
- package/dist/shared/config.mjs +1 -1
- package/dist/worker/run.mjs +2 -1
- package/dist/worker/worker-run.mjs +5 -3
- package/package.json +1 -1
package/dist/cli/start.mjs
CHANGED
|
@@ -9,7 +9,7 @@ const REFUSED_GOING = [
|
|
|
9
9
|
'the worker is restarting, try again soon',
|
|
10
10
|
];
|
|
11
11
|
const SILENT = 'the next-issue worker did not answer';
|
|
12
|
-
const STARTED = 'next-issue: the run started in the worker; follow it with next-issue logs and stop it with next-issue stop\n';
|
|
12
|
+
const STARTED = 'next-issue: the run started in the worker; follow it with npx -y next-issue@latest logs and stop it with npx -y next-issue@latest stop\n';
|
|
13
13
|
export async function startInWorker(root, argv) {
|
|
14
14
|
const version = await packageVersion();
|
|
15
15
|
const given = givenStartFlags(argv);
|
package/dist/cli/switch-run.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { isNewer } from '../shared/protocol.mjs';
|
|
3
3
|
import { packageVersion } from '../shared/version.mjs';
|
|
4
|
-
import { CLOSED, findWorker, going } from '../shared/worker-client.mjs';
|
|
4
|
+
import { ANSWER_TIMEOUT_MS, CLOSED, findWorker, going, } from '../shared/worker-client.mjs';
|
|
5
5
|
const FIELDS = { watch: 'watching', hunt: 'hunting' };
|
|
6
6
|
const NO_RUN = 'next-issue: no run is going in this repository\n';
|
|
7
7
|
function onOffText(on) {
|
|
@@ -58,14 +58,46 @@ export function stopInWorker(root) {
|
|
|
58
58
|
if (progress.status === 'stopping' && progress.upgrade === undefined) {
|
|
59
59
|
return 'next-issue: the run is stopping already\n';
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (progress.upgrade !== undefined) {
|
|
64
|
-
return 'next-issue: the run will stop after its current issues and not start again\n';
|
|
65
|
-
}
|
|
66
|
-
return 'next-issue: the run will stop after its current issues\n';
|
|
61
|
+
const reply = await stopReply(connection, root);
|
|
62
|
+
return `next-issue: ${stopText(progress, reply)}\n`;
|
|
67
63
|
});
|
|
68
64
|
}
|
|
65
|
+
function stopReply(connection, root) {
|
|
66
|
+
const id = randomUUID();
|
|
67
|
+
return new Promise((resolve) => {
|
|
68
|
+
const timer = setTimeout(() => resolve(undefined), ANSWER_TIMEOUT_MS);
|
|
69
|
+
connection.listen((message) => {
|
|
70
|
+
if (message.type === 'stopping' && message.id === id) {
|
|
71
|
+
clearTimeout(timer);
|
|
72
|
+
resolve(message);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
void connection.closed.then(() => {
|
|
76
|
+
clearTimeout(timer);
|
|
77
|
+
resolve(undefined);
|
|
78
|
+
});
|
|
79
|
+
connection.send({ type: 'stop', root, after: 'issue', id });
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function stopText(progress, reply) {
|
|
83
|
+
const upgrading = progress.upgrade !== undefined;
|
|
84
|
+
const ending = upgrading ? ' and not start again' : '';
|
|
85
|
+
if (reply === undefined) {
|
|
86
|
+
return `the run will stop after its current issues${ending}`;
|
|
87
|
+
}
|
|
88
|
+
const waits = progress.issues.map(({ issue }) => `#${issue}`);
|
|
89
|
+
if (reply.hunting) {
|
|
90
|
+
waits.push('its current hunt');
|
|
91
|
+
}
|
|
92
|
+
if (waits.length > 0) {
|
|
93
|
+
return `the run will stop after ${listText(waits)}${ending}`;
|
|
94
|
+
}
|
|
95
|
+
const state = reply.waiting ? 'the run stopped' : 'the run is stopping';
|
|
96
|
+
return upgrading ? `${state} and will not start again` : state;
|
|
97
|
+
}
|
|
98
|
+
function listText(items) {
|
|
99
|
+
return items.length === 1 ? items[0] : `${items.slice(0, -1).join(', ')} and ${items.at(-1)}`;
|
|
100
|
+
}
|
|
69
101
|
export function statusInWorker(root) {
|
|
70
102
|
return inWorker(root, async (connection, progress) => statusText(connection.version, progress));
|
|
71
103
|
}
|
package/dist/shared/args.mjs
CHANGED
|
@@ -8,7 +8,7 @@ const RUN_FLAGS = new Map([
|
|
|
8
8
|
['--hunt', 'hunt'],
|
|
9
9
|
]);
|
|
10
10
|
const COMMANDS = ['start', 'init', 'serve', 'stop', 'status', 'logs', 'watch', 'hunt'];
|
|
11
|
-
export const USAGE = `next-issue <command> [options]
|
|
11
|
+
export const USAGE = `npx -y next-issue@latest <command> [options]
|
|
12
12
|
|
|
13
13
|
start start a run: claim issues, fix them and push them to the base branch
|
|
14
14
|
--watch on|off on: read the issues again after each pass; off: do one pass and end (default on)
|
|
@@ -31,7 +31,7 @@ export function parseArgs(argv) {
|
|
|
31
31
|
return args;
|
|
32
32
|
}
|
|
33
33
|
if (args.command === undefined && flag !== undefined) {
|
|
34
|
-
throw new Error('no command given: use next-issue start to start a run, or see next-issue --help');
|
|
34
|
+
throw new Error('no command given: use npx -y next-issue@latest start to start a run, or see npx -y next-issue@latest --help');
|
|
35
35
|
}
|
|
36
36
|
if (args.command !== undefined && args.command !== 'start' && runFlag !== undefined) {
|
|
37
37
|
throw new Error(`${args.command} does not take ${runFlag}: it belongs to start`);
|
package/dist/shared/config.mjs
CHANGED
|
@@ -114,7 +114,7 @@ export async function moveOldConfig(root, force) {
|
|
|
114
114
|
}
|
|
115
115
|
export async function rejectOldConfig(root) {
|
|
116
116
|
if ((await readTextIfPresent(join(root, OLD_CONFIG_FILE))) !== undefined) {
|
|
117
|
-
throw new Error(`${OLD_CONFIG_FILE} moved to ${CONFIG_FILE}. Run next-issue init to move it.`);
|
|
117
|
+
throw new Error(`${OLD_CONFIG_FILE} moved to ${CONFIG_FILE}. Run npx -y next-issue@latest init to move it.`);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
export async function loadConfig(root, options = {}) {
|
package/dist/worker/run.mjs
CHANGED
|
@@ -72,12 +72,13 @@ export function watchRun(args, loop, context, controls, print) {
|
|
|
72
72
|
const { interrupts } = controls;
|
|
73
73
|
let passStart = recorder.summary();
|
|
74
74
|
const hunt = hunter(context);
|
|
75
|
+
controls.onHunter?.(() => hunt.busy());
|
|
75
76
|
return watchIssues({
|
|
76
77
|
...loop,
|
|
77
78
|
wait: (minutes, woken) => {
|
|
78
79
|
recorder.event('watch.wait', { minutes });
|
|
79
80
|
passStart = recorder.summary();
|
|
80
|
-
return interrupts.sleep(minutesToMs(minutes),
|
|
81
|
+
return interrupts.sleep(minutesToMs(minutes), woken);
|
|
81
82
|
},
|
|
82
83
|
passEnd: (issues) => print({ ...recorder.summary(passStart), issues }),
|
|
83
84
|
hunter: hunt,
|
|
@@ -77,7 +77,7 @@ export function stoppingMessage(root, run, id) {
|
|
|
77
77
|
type: 'stopping',
|
|
78
78
|
root,
|
|
79
79
|
waiting,
|
|
80
|
-
hunting:
|
|
80
|
+
hunting: run.huntBusy?.() === true,
|
|
81
81
|
...(id === undefined ? {} : { id }),
|
|
82
82
|
};
|
|
83
83
|
}
|
|
@@ -127,8 +127,7 @@ function runInterrupts(run) {
|
|
|
127
127
|
return {
|
|
128
128
|
afterIssue: () => run.stop !== undefined,
|
|
129
129
|
afterRound: () => run.stop === 'round' || run.stop === 'now',
|
|
130
|
-
sleep: (ms,
|
|
131
|
-
run.huntBusy = hunting;
|
|
130
|
+
sleep: (ms, woken) => {
|
|
132
131
|
return wakeableSleep(run, ms, run.stop !== undefined, woken);
|
|
133
132
|
},
|
|
134
133
|
};
|
|
@@ -139,5 +138,8 @@ export function runControls(run, update) {
|
|
|
139
138
|
hunting: run.hunting,
|
|
140
139
|
watching: run.watching,
|
|
141
140
|
onEvent: (record) => update(applyEvent(run.progress, record)),
|
|
141
|
+
onHunter: (busy) => {
|
|
142
|
+
run.huntBusy = busy;
|
|
143
|
+
},
|
|
142
144
|
};
|
|
143
145
|
}
|