greprag 5.85.5 → 5.85.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.
|
@@ -22,6 +22,8 @@ Exit 0 when production is proven to serve the commit, 1 otherwise.
|
|
|
22
22
|
|
|
23
23
|
For a target with no HTTP stamp — a Discord bot, a worker process — use --heroku:
|
|
24
24
|
it reads the app's release list and confirms the running release names your commit.
|
|
25
|
+
The Heroku CLI is asked once for a login token (heroku auth:token); each check is then
|
|
26
|
+
one request to the Heroku API.
|
|
25
27
|
It refuses while the current release is pending or failed, which is the case most
|
|
26
28
|
worth catching, because the git push succeeded and looks fine. A config-var change
|
|
27
29
|
creates a release naming no commit, and the code running is still the last real
|
package/dist/deploy-verify.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.BUILD_STAMP_PATH = void 0;
|
|
24
|
+
exports.fetchHerokuToken = fetchHerokuToken;
|
|
24
25
|
exports.fetchHerokuReleases = fetchHerokuReleases;
|
|
25
26
|
exports.verifyHerokuRelease = verifyHerokuRelease;
|
|
26
27
|
exports.sameCommit = sameCommit;
|
|
@@ -32,36 +33,62 @@ exports.describeHerokuRelease = describeHerokuRelease;
|
|
|
32
33
|
exports.assertBuildStampUncacheable = assertBuildStampUncacheable;
|
|
33
34
|
const proc_1 = require("./proc");
|
|
34
35
|
exports.BUILD_STAMP_PATH = '/__build.json';
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
/** The Heroku CLI's login token, asked for ONCE per verify. The CLI is only a token
|
|
37
|
+
* source here: on Windows it takes 9-35s just to start, so polling releases through it
|
|
38
|
+
* under a 30s kill turned ordinary slowness into "not logged in" on every check, and
|
|
39
|
+
* two good PayBot deploys on 2026-10-23 were reported as failed. `~/_netrc` is no
|
|
40
|
+
* substitute — CLI 11 keeps the live login elsewhere and the netrc token there was
|
|
41
|
+
* stale. Honours HEROKU_API_KEY, because the CLI itself does. */
|
|
42
|
+
function fetchHerokuToken() {
|
|
41
43
|
// One command string through a shell: `heroku` is a `.cmd` shim on Windows, which
|
|
42
|
-
// Node refuses to spawn directly.
|
|
43
|
-
const result = (0, proc_1.safeSpawnSync)(
|
|
44
|
+
// Node refuses to spawn directly.
|
|
45
|
+
const result = (0, proc_1.safeSpawnSync)('heroku auth:token', [], {
|
|
44
46
|
encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'],
|
|
45
|
-
shell: true, windowsHide: true, timeout:
|
|
47
|
+
shell: true, windowsHide: true, timeout: 120_000,
|
|
46
48
|
});
|
|
47
49
|
if (result.status !== 0)
|
|
48
50
|
return null;
|
|
51
|
+
return String(result.stdout).trim() || null;
|
|
52
|
+
}
|
|
53
|
+
/** Read an app's releases from the Heroku Platform API, newest first. Returns why it
|
|
54
|
+
* could not when it cannot — the caller reports that as a failure to verify, never as
|
|
55
|
+
* a pass. */
|
|
56
|
+
async function fetchHerokuReleases(app, token, num = 10, fetchImpl = fetch) {
|
|
57
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(app))
|
|
58
|
+
return `${app} is not a Heroku app name`;
|
|
49
59
|
try {
|
|
50
|
-
const
|
|
51
|
-
|
|
60
|
+
const response = await fetchImpl(`https://api.heroku.com/apps/${app}/releases`, {
|
|
61
|
+
headers: {
|
|
62
|
+
Accept: 'application/vnd.heroku+json; version=3',
|
|
63
|
+
Authorization: `Bearer ${token}`,
|
|
64
|
+
Range: `version ..; order=desc, max=${num}`,
|
|
65
|
+
},
|
|
66
|
+
signal: AbortSignal.timeout(20_000),
|
|
67
|
+
});
|
|
68
|
+
if (!response.ok)
|
|
69
|
+
return `Heroku answered ${response.status}`;
|
|
70
|
+
const parsed = await response.json();
|
|
71
|
+
return Array.isArray(parsed) ? parsed : 'Heroku did not return a release list';
|
|
52
72
|
}
|
|
53
|
-
catch {
|
|
54
|
-
return
|
|
73
|
+
catch (error) {
|
|
74
|
+
return `could not reach Heroku: ${error instanceof Error ? error.message : String(error)}`;
|
|
55
75
|
}
|
|
56
76
|
}
|
|
57
77
|
/** Poll Heroku until the app is running `sha`. A push returns as soon as the slug is
|
|
58
78
|
* received; the build and release follow, so the first look is usually too early. */
|
|
59
|
-
async function verifyHerokuRelease({ app, sha, attempts = 12, intervalMs = 5000, fetchReleases = fetchHerokuReleases, sleep = (ms) => new Promise(resolve => { setTimeout(resolve, ms); }), }) {
|
|
79
|
+
async function verifyHerokuRelease({ app, sha, attempts = 12, intervalMs = 5000, fetchToken = fetchHerokuToken, fetchReleases = fetchHerokuReleases, sleep = (ms) => new Promise(resolve => { setTimeout(resolve, ms); }), }) {
|
|
80
|
+
const token = fetchToken();
|
|
81
|
+
if (!token) {
|
|
82
|
+
return {
|
|
83
|
+
ok: false, attempts: 0,
|
|
84
|
+
reason: 'could not get a Heroku login token (heroku auth:token) — is the Heroku CLI installed and logged in?',
|
|
85
|
+
};
|
|
86
|
+
}
|
|
60
87
|
let last = 'Heroku was never reached';
|
|
61
88
|
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
62
|
-
const releases = fetchReleases(app);
|
|
63
|
-
if (releases ===
|
|
64
|
-
last = `could not read Heroku releases for ${app}
|
|
89
|
+
const releases = await fetchReleases(app, token);
|
|
90
|
+
if (typeof releases === 'string') {
|
|
91
|
+
last = `could not read Heroku releases for ${app}: ${releases}`;
|
|
65
92
|
}
|
|
66
93
|
else {
|
|
67
94
|
const drift = describeHerokuRelease(releases, sha);
|
|
@@ -583,12 +583,15 @@ function applyNativeSkillMirror(params) {
|
|
|
583
583
|
const projectRoot = projectDir ? writerOwnedProjectSkillRoot(params.platform, projectDir, homeDir) : null;
|
|
584
584
|
if (projectRoot)
|
|
585
585
|
rootState(projectRoot);
|
|
586
|
+
const keepGlobal = new Set(params.globalRoster || []);
|
|
586
587
|
for (const [root, entry] of roots) {
|
|
587
588
|
if (params.pruneGlobalRoot === false && root === globalRoot)
|
|
588
589
|
continue;
|
|
589
590
|
for (const [skillName, managed] of Object.entries(entry.state.skills)) {
|
|
590
591
|
if (entry.present.has(skillName))
|
|
591
592
|
continue;
|
|
593
|
+
if (root === globalRoot && keepGlobal.has(skillName))
|
|
594
|
+
continue;
|
|
592
595
|
const target = targetPath(root, skillName);
|
|
593
596
|
const currentFiles = (0, skill_mirror_files_1.isSkillFolderOwnedElsewhere)(target) ? null : readManagedFiles(target, managed);
|
|
594
597
|
if (!currentFiles || (0, skill_mirror_files_1.computeSkillFileHash)(currentFiles) !== managed.hash) {
|
|
@@ -668,13 +671,25 @@ async function syncNativeSkillMirror(params) {
|
|
|
668
671
|
throw new Error('skill mirror snapshot incomplete; existing native adapters preserved');
|
|
669
672
|
}
|
|
670
673
|
const skills = fetched;
|
|
674
|
+
// In a project the effective list can hide a replaced global, so the global
|
|
675
|
+
// root is pruned against the plain global list (a skill retired in git).
|
|
676
|
+
let globalRoster;
|
|
677
|
+
if (params.projectId) {
|
|
678
|
+
const globals = await fetch(`${params.apiUrl}/v1/skillmirror?scope=global`, {
|
|
679
|
+
headers: { Authorization: `Bearer ${params.apiKey}` },
|
|
680
|
+
});
|
|
681
|
+
if (!globals.ok)
|
|
682
|
+
throw new Error(`skill mirror list failed: HTTP ${globals.status}`);
|
|
683
|
+
const body = await globals.json();
|
|
684
|
+
globalRoster = (body.skills || []).map(row => row.skillName).filter((n) => typeof n === 'string');
|
|
685
|
+
}
|
|
671
686
|
return applyNativeSkillMirror({
|
|
672
687
|
platform: params.platform,
|
|
673
688
|
skills,
|
|
674
689
|
homeDir: params.homeDir,
|
|
675
690
|
projectDir: params.projectDir,
|
|
676
691
|
prune: true,
|
|
677
|
-
|
|
692
|
+
globalRoster,
|
|
678
693
|
});
|
|
679
694
|
}
|
|
680
695
|
function nativeSkillMirrorSummary(result) {
|
|
@@ -4636,12 +4636,15 @@ function applyNativeSkillMirror(params) {
|
|
|
4636
4636
|
const projectRoot = projectDir ? writerOwnedProjectSkillRoot(params.platform, projectDir, homeDir) : null;
|
|
4637
4637
|
if (projectRoot)
|
|
4638
4638
|
rootState(projectRoot);
|
|
4639
|
+
const keepGlobal = new Set(params.globalRoster || []);
|
|
4639
4640
|
for (const [root, entry] of roots) {
|
|
4640
4641
|
if (params.pruneGlobalRoot === false && root === globalRoot)
|
|
4641
4642
|
continue;
|
|
4642
4643
|
for (const [skillName, managed] of Object.entries(entry.state.skills)) {
|
|
4643
4644
|
if (entry.present.has(skillName))
|
|
4644
4645
|
continue;
|
|
4646
|
+
if (root === globalRoot && keepGlobal.has(skillName))
|
|
4647
|
+
continue;
|
|
4645
4648
|
const target = targetPath(root, skillName);
|
|
4646
4649
|
const currentFiles = isSkillFolderOwnedElsewhere(target) ? null : readManagedFiles(target, managed);
|
|
4647
4650
|
if (!currentFiles || computeSkillFileHash(currentFiles) !== managed.hash) {
|