neurastream 0.2.70 → 0.2.71
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/package.json +1 -1
- package/src/core/wip-setup.ts +17 -5
package/package.json
CHANGED
package/src/core/wip-setup.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
// what this replaces.
|
|
7
7
|
|
|
8
8
|
import { spawnSync } from "node:child_process";
|
|
9
|
-
import { accessSync, constants, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
10
|
-
import { homedir } from "node:os";
|
|
9
|
+
import { accessSync, constants, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { homedir, tmpdir } from "node:os";
|
|
11
11
|
import { basename, dirname, join } from "node:path";
|
|
12
12
|
import { fileURLToPath } from "node:url";
|
|
13
13
|
import { checkEdited, setConfigKeys } from "./config-edit.ts";
|
|
@@ -117,9 +117,21 @@ export function wipOn(opts: WipSetupOptions & { backupUrl?: string | null } = {}
|
|
|
117
117
|
executable = false;
|
|
118
118
|
}
|
|
119
119
|
if (!executable) return fail(`${gate} is missing — the backup refuses to upload without the secret gate; nothing was written`);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
// Probe the gate exactly the way the backup calls it (scan <repo> <rev>): a bare `scan`
|
|
121
|
+
// makes the real gate print usage and exit 2, which would read as a broken scanner. Build a
|
|
122
|
+
// throwaway repo with one commit so the gate has a rev to answer on.
|
|
123
|
+
const dir = mkdtempSync(join(tmpdir(), "wip-gate-probe-"));
|
|
124
|
+
try {
|
|
125
|
+
const init = cmd(["git", "init", "-q"], { cwd: dir });
|
|
126
|
+
if (init.code !== 0) return fail(`git init exited ${init.code}: ${init.stderr.trim().split("\n")[0]} — nothing was written`);
|
|
127
|
+
const commit = cmd(["git", "-c", "user.name=probe", "-c", "user.email=probe", "-c", "commit.gpgsign=false", "commit", "-q", "--allow-empty", "-m", "probe"], { cwd: dir });
|
|
128
|
+
if (commit.code !== 0) return fail(`git commit exited ${commit.code}: ${commit.stderr.trim().split("\n")[0]} — nothing was written`);
|
|
129
|
+
const scan = cmd([gate, "scan", dir, "HEAD"]);
|
|
130
|
+
if (scan.code !== 0 && scan.code !== 1) {
|
|
131
|
+
return fail(`${gate} scan exited ${scan.code}${scan.stderr.trim() ? `: ${scan.stderr.trim().split("\n")[0]}` : ""} — nothing was written`);
|
|
132
|
+
}
|
|
133
|
+
} finally {
|
|
134
|
+
rmSync(dir, { recursive: true, force: true });
|
|
123
135
|
}
|
|
124
136
|
}
|
|
125
137
|
// Write the units, then enable them. Always a write: an old hand-made unit would otherwise stay.
|