next-issue 6.6.42 → 6.6.43
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 +4 -1
- package/dist/files.mjs +13 -1
- package/dist/state.mjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -483,7 +483,10 @@ A `setupCommand` that fails, or that does not finish in `setupTimeoutMinutes`,
|
|
|
483
483
|
hands the issue to a person. The wait for the checks has its own limit, so
|
|
484
484
|
`commandTimeoutMinutes` holds for every other `git` and `gh` command. State per
|
|
485
485
|
issue goes to `.next-issue/<issue>.json`, so a new run continues where the last
|
|
486
|
-
run stopped.
|
|
486
|
+
run stopped. The harness writes a state file to a temporary file in the same
|
|
487
|
+
folder and renames it over the old one, so a state file is replaced in one
|
|
488
|
+
step: a run killed or a disk that fills up during a write leaves the earlier
|
|
489
|
+
state. A state file that is not valid JSON, or that does not hold a valid
|
|
487
490
|
state, gives the issue an `error` outcome that names the file, rather than a
|
|
488
491
|
silent skip.
|
|
489
492
|
|
package/dist/files.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { readdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
2
3
|
import { hasCode } from './errors.mjs';
|
|
3
4
|
export function readTextOrEmpty(path) {
|
|
4
5
|
return readFile(path, 'utf8').catch(() => '');
|
|
@@ -12,6 +13,17 @@ export function prettyJson(value) {
|
|
|
12
13
|
export function writeJson(path, value, options) {
|
|
13
14
|
return writeFile(path, prettyJson(value), options);
|
|
14
15
|
}
|
|
16
|
+
export async function replaceJson(path, value) {
|
|
17
|
+
const draft = `${path}.${process.pid}.${randomUUID()}.tmp`;
|
|
18
|
+
try {
|
|
19
|
+
await writeFile(draft, prettyJson(value));
|
|
20
|
+
await rename(draft, path);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
await rm(draft, { force: true });
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
15
27
|
export async function unlessMissing(read) {
|
|
16
28
|
try {
|
|
17
29
|
return await read();
|
package/dist/state.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mkdir, readdir, rm } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { parseJson } from './errors.mjs';
|
|
4
|
-
import { readTextIfPresent,
|
|
4
|
+
import { readTextIfPresent, replaceJson, unlessMissing } from './files.mjs';
|
|
5
5
|
import { isRecord } from './records.mjs';
|
|
6
6
|
export const STATE_DIR = '.next-issue';
|
|
7
7
|
export function stateDir(root) {
|
|
@@ -80,7 +80,7 @@ export function resetState(state) {
|
|
|
80
80
|
}
|
|
81
81
|
export async function writeState(repo, state) {
|
|
82
82
|
await mkdir(stateDir(repo.root), { recursive: true });
|
|
83
|
-
await
|
|
83
|
+
await replaceJson(file(repo, state.issue), state);
|
|
84
84
|
}
|
|
85
85
|
export async function dropState(repo, issue) {
|
|
86
86
|
await rm(file(repo, issue), { force: true });
|