next-issue 17.2.5 → 17.2.7
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 +1 -1
- package/dist/cli.mjs +15 -5
- package/dist/shared/setup.mjs +49 -20
- package/dist/worker/run.mjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ flowchart TD
|
|
|
28
28
|
|
|
29
29
|
## Install and quick start
|
|
30
30
|
|
|
31
|
-
You need Node 24 or later, git 2.40 or later, `gh` logged in with write access to the repository, a `remote` on GitHub and Claude Code, logged in. The
|
|
31
|
+
You need Node 24 or later, git 2.40 or later, `gh` logged in with write access to the repository, a `remote` on GitHub and Claude Code, logged in. The base branch on the remote needs a root `package.json` with the scripts `format`, `lint`, `typecheck` and `test` (commit and push them before you start), each of which fails on a problem; `format` checks the formatting and does not write files. The harness runs them before each push, since no person checks the change, see [Local checks](https://github.com/ravshansbox/next-issue/blob/main/packages/next-issue/docs/behaviour.md#local-checks). See [Requirements](https://github.com/ravshansbox/next-issue/blob/main/packages/next-issue/docs/behaviour.md#requirements).
|
|
32
32
|
|
|
33
33
|
Run the harness inside a git repository:
|
|
34
34
|
|
package/dist/cli.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { parseArgs, USAGE } from './shared/args.mjs';
|
|
3
|
-
import { moveOldConfig, rejectOldConfig, writeDefaultConfig } from './shared/config.mjs';
|
|
3
|
+
import { loadConfig, moveOldConfig, rejectOldConfig, writeDefaultConfig, } from './shared/config.mjs';
|
|
4
4
|
import { OLD_CONFIG_FILE } from './shared/config-fields.mjs';
|
|
5
5
|
import { message } from './shared/errors.mjs';
|
|
6
|
-
import { repoRoot } from './shared/git.mjs';
|
|
7
|
-
import { requireScripts } from './shared/setup.mjs';
|
|
6
|
+
import { detectRepo, repoRoot } from './shared/git.mjs';
|
|
7
|
+
import { basePackage, requireScripts } from './shared/setup.mjs';
|
|
8
8
|
import { ensureExcluded, excludeFile, removeIgnored } from './cli/ignore.mjs';
|
|
9
9
|
import { followLog, newestRunLog } from './cli/logs.mjs';
|
|
10
10
|
import { serve } from './worker/serve.mjs';
|
|
@@ -50,7 +50,7 @@ async function main() {
|
|
|
50
50
|
return logs(root);
|
|
51
51
|
}
|
|
52
52
|
if (args.command === 'start') {
|
|
53
|
-
await
|
|
53
|
+
requireScripts(await rootBasePackage(root));
|
|
54
54
|
}
|
|
55
55
|
await excludeStateDirectories(root, process.stderr);
|
|
56
56
|
if (args.command === 'serve') {
|
|
@@ -85,9 +85,19 @@ async function init(root, args) {
|
|
|
85
85
|
for (const folder of await installSkills(scope)) {
|
|
86
86
|
await write(process.stdout, `wrote ${folder}\n`);
|
|
87
87
|
}
|
|
88
|
-
await
|
|
88
|
+
const base = await rootBasePackage(root).catch((error) => {
|
|
89
|
+
const reason = message(error);
|
|
90
|
+
return write(process.stderr, `could not check the scripts on the base branch: ${reason}\n`);
|
|
91
|
+
});
|
|
92
|
+
if (base !== undefined) {
|
|
93
|
+
requireScripts(base);
|
|
94
|
+
}
|
|
89
95
|
return 0;
|
|
90
96
|
}
|
|
97
|
+
async function rootBasePackage(root) {
|
|
98
|
+
const { remote } = await loadConfig(root);
|
|
99
|
+
return basePackage(await detectRepo(root, remote), remote);
|
|
100
|
+
}
|
|
91
101
|
async function excludeStateDirectories(root, stream) {
|
|
92
102
|
const exclude = await excludeFile(root);
|
|
93
103
|
const entries = [
|
package/dist/shared/setup.mjs
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { access } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { message, parseJson } from './errors.mjs';
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { run, succeeded } from './exec.mjs';
|
|
5
|
+
import { gitFetch, remoteRef } from './git.mjs';
|
|
6
|
+
import { defaultBranch } from './github.mjs';
|
|
7
|
+
const JS_MARKERS = [
|
|
6
8
|
['pnpm-lock.yaml', 'pnpm install --frozen-lockfile'],
|
|
7
9
|
['package-lock.json', 'npm ci'],
|
|
8
10
|
['yarn.lock', 'yarn install --frozen-lockfile'],
|
|
9
11
|
['bun.lock', 'bun install --frozen-lockfile'],
|
|
10
12
|
['bun.lockb', 'bun install --frozen-lockfile'],
|
|
13
|
+
];
|
|
14
|
+
const OTHER_MARKERS = [
|
|
11
15
|
['Cargo.lock', 'cargo fetch --locked'],
|
|
12
16
|
['go.sum', 'go mod download'],
|
|
13
17
|
['uv.lock', 'uv sync --locked'],
|
|
@@ -17,21 +21,34 @@ const MARKERS = [
|
|
|
17
21
|
function exists(path) {
|
|
18
22
|
return access(path).then(() => true, () => false);
|
|
19
23
|
}
|
|
20
|
-
|
|
21
|
-
for (const
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
if (file === 'yarn.lock' && (await exists(join(root, '.yarnrc.yml')))) {
|
|
26
|
-
return 'yarn install --immutable';
|
|
24
|
+
async function firstMatch(root, markers) {
|
|
25
|
+
for (const marker of markers) {
|
|
26
|
+
if (await exists(join(root, marker[0]))) {
|
|
27
|
+
return marker;
|
|
27
28
|
}
|
|
28
|
-
return command;
|
|
29
|
-
}
|
|
30
|
-
if (await exists(join(root, 'package.json'))) {
|
|
31
|
-
return 'npm install --no-package-lock';
|
|
32
29
|
}
|
|
33
30
|
return undefined;
|
|
34
31
|
}
|
|
32
|
+
async function jsLockCommand(root) {
|
|
33
|
+
const match = await firstMatch(root, JS_MARKERS);
|
|
34
|
+
if (match === undefined) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
const [file, command] = match;
|
|
38
|
+
if (file === 'yarn.lock' && (await exists(join(root, '.yarnrc.yml')))) {
|
|
39
|
+
return 'yarn install --immutable';
|
|
40
|
+
}
|
|
41
|
+
return command;
|
|
42
|
+
}
|
|
43
|
+
export async function detectSetupCommand(root) {
|
|
44
|
+
const jsCommand = await jsLockCommand(root);
|
|
45
|
+
const otherCommand = (await firstMatch(root, OTHER_MARKERS))?.[1];
|
|
46
|
+
const fallback = jsCommand === undefined && (await exists(join(root, 'package.json')))
|
|
47
|
+
? 'npm install --no-package-lock'
|
|
48
|
+
: undefined;
|
|
49
|
+
const commands = [jsCommand, otherCommand, fallback].filter((command) => command !== undefined);
|
|
50
|
+
return commands.length === 0 ? undefined : commands.join(' && ');
|
|
51
|
+
}
|
|
35
52
|
export const SCRIPTS = ['format', 'lint', 'typecheck', 'test'];
|
|
36
53
|
const RUNNERS = [
|
|
37
54
|
['pnpm-lock.yaml', 'pnpm run'],
|
|
@@ -56,17 +73,29 @@ function listed(names) {
|
|
|
56
73
|
: `${quoted.slice(0, -1).join(', ')} and ${quoted.at(-1)}`;
|
|
57
74
|
}
|
|
58
75
|
const WHY = `next-issue runs ${listed(SCRIPTS)} before each push, since the humanless flow relies on these checks instead of a person. Each script must fail on a problem, and \`format\` must check the formatting, not write files.`;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
76
|
+
const BASE_CHECK_REF = 'refs/next-issue/base';
|
|
77
|
+
/** Fetches the base branch from the remote into a ref of its own, so a fetch or push of the worker never clashes with it, and reads the `package.json` at its root. */
|
|
78
|
+
export async function basePackage(repo, remote) {
|
|
79
|
+
const branch = await defaultBranch(repo);
|
|
80
|
+
await gitFetch(repo.root, [
|
|
81
|
+
'--no-write-fetch-head',
|
|
82
|
+
'--refmap=',
|
|
83
|
+
remote,
|
|
84
|
+
`+refs/heads/${branch}:${BASE_CHECK_REF}`,
|
|
85
|
+
]);
|
|
86
|
+
const result = await run('git', ['show', `${BASE_CHECK_REF}:package.json`], { cwd: repo.root });
|
|
87
|
+
return { base: remoteRef(remote, branch), text: succeeded(result) ? result.stdout : undefined };
|
|
88
|
+
}
|
|
89
|
+
/** Fails when the `package.json` of the base is missing or lacks any of the scripts of the local gate. */
|
|
90
|
+
export function requireScripts({ base, text }) {
|
|
62
91
|
if (text === undefined) {
|
|
63
|
-
throw new Error(`there is no package.json at the root of
|
|
92
|
+
throw new Error(`there is no package.json at the root of \`${base}\`, so it lacks the scripts ${listed(SCRIPTS)}. Commit them and push them to \`${base}\`. ${WHY}`);
|
|
64
93
|
}
|
|
65
|
-
const file = parseJson(text, (error) => `package.json is not valid JSON: ${message(error)}`);
|
|
94
|
+
const file = parseJson(text, (error) => `the package.json on \`${base}\` is not valid JSON: ${message(error)}`);
|
|
66
95
|
const scripts = file?.scripts ?? {};
|
|
67
96
|
const missing = SCRIPTS.filter((name) => typeof scripts[name] !== 'string');
|
|
68
97
|
if (missing.length > 0) {
|
|
69
|
-
const noun = missing.length === 1 ? 'script' : 'scripts';
|
|
70
|
-
throw new Error(`the
|
|
98
|
+
const [noun, pronoun] = missing.length === 1 ? ['script', 'it'] : ['scripts', 'them'];
|
|
99
|
+
throw new Error(`the package.json on \`${base}\` lacks the ${noun} ${listed(missing)}. Commit ${pronoun} and push ${pronoun} to \`${base}\`. ${WHY}`);
|
|
71
100
|
}
|
|
72
101
|
}
|
package/dist/worker/run.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import { pendingIssues } from './pending.mjs';
|
|
|
16
16
|
import { processIssue } from './pipeline.mjs';
|
|
17
17
|
import { PORTS } from '../shared/ports.mjs';
|
|
18
18
|
import { pruneRuns } from './prune-runs.mjs';
|
|
19
|
-
import { requireScripts } from '../shared/setup.mjs';
|
|
19
|
+
import { basePackage, requireScripts } from '../shared/setup.mjs';
|
|
20
20
|
import { count } from '../shared/summary.mjs';
|
|
21
21
|
import { packageVersion } from '../shared/version.mjs';
|
|
22
22
|
import { watchIssues } from '../shared/watch.mjs';
|
|
@@ -29,7 +29,7 @@ async function runWithConfig(root, args, controls, config) {
|
|
|
29
29
|
const repo = await detectRepo(root, config.remote);
|
|
30
30
|
const recorder = await Recorder.create(repo.root, controls.onEvent, undefined, controls.output);
|
|
31
31
|
try {
|
|
32
|
-
await
|
|
32
|
+
requireScripts(await basePackage(repo, config.remote));
|
|
33
33
|
const pruned = await pruneRuns(repo.root, config.keepRunDays);
|
|
34
34
|
if (pruned > 0) {
|
|
35
35
|
recorder.record('runs.pruned', { files: pruned, keepDays: config.keepRunDays });
|