@payez/next-mvp 4.4.0 → 4.4.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/package.json +1 -1
- package/scripts/check-publish-health.mjs +53 -11
package/package.json
CHANGED
|
@@ -43,6 +43,10 @@ function run(args) {
|
|
|
43
43
|
}).trim();
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
function sleepSync(ms) {
|
|
47
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
48
|
+
}
|
|
49
|
+
|
|
46
50
|
/** Numeric-aware semver compare. Returns >0 if a > b, 0 if equal, <0 if a < b. */
|
|
47
51
|
function compareVersions(a, b) {
|
|
48
52
|
const norm = (v) => String(v).split('-')[0].split('.').map((n) => parseInt(n, 10) || 0);
|
|
@@ -74,19 +78,57 @@ try {
|
|
|
74
78
|
authUser = null;
|
|
75
79
|
}
|
|
76
80
|
|
|
81
|
+
// READ THE REGISTRY, NOT npm's CACHE (measured 2026-09-10, Nextpert-Scout).
|
|
82
|
+
//
|
|
83
|
+
// This script is wired as `postpublish` in package.json. postpublish runs ONLY after
|
|
84
|
+
// a SUCCESSFUL upload — so the one moment it is guaranteed to run is the one moment
|
|
85
|
+
// npm's metadata cache is guaranteed to be stale. Publishing 4.4.0 produced:
|
|
86
|
+
//
|
|
87
|
+
// [publish-health] FAIL: the registry LAGS local by at least one version.
|
|
88
|
+
// [publish-health] 4.4.0 is built locally but the registry serves 4.1.21.
|
|
89
|
+
// npm error code 1
|
|
90
|
+
//
|
|
91
|
+
// 4.4.0 was already live. THE HONEST REACTION TO THAT OUTPUT IS TO PUBLISH AGAIN,
|
|
92
|
+
// which is the dangerous action — and against a registry that refuses republication
|
|
93
|
+
// it burns a version number, which is how a version string ends up naming two trees.
|
|
94
|
+
//
|
|
95
|
+
// `--prefer-online` forces revalidation. The bounded retry covers real propagation
|
|
96
|
+
// delay, which is seconds, not weeks.
|
|
97
|
+
//
|
|
98
|
+
// THIS DOES NOT SOFTEN THE CHECK, and it must not be "helpfully" turned into a warning:
|
|
99
|
+
// a genuine lag (the 171900 failure mode — a dead credential leaving versions
|
|
100
|
+
// unpublished for WEEKS) still exhausts every attempt and still exits non-zero. The
|
|
101
|
+
// retry changes how accurately we read the registry, never what counts as a failure.
|
|
102
|
+
const REGISTRY_ATTEMPTS = 4;
|
|
103
|
+
const REGISTRY_RETRY_MS = 2000;
|
|
104
|
+
|
|
77
105
|
let registryVersion = null;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
106
|
+
for (let attempt = 1; attempt <= REGISTRY_ATTEMPTS; attempt++) {
|
|
107
|
+
try {
|
|
108
|
+
registryVersion = run(['view', name, 'version', '--prefer-online']);
|
|
109
|
+
} catch (err) {
|
|
110
|
+
const msg = String(err.stderr || err.message || '');
|
|
111
|
+
if (/E404|404 Not Found/.test(msg)) {
|
|
112
|
+
console.error(`[publish-health] FAIL: ${name} has NEVER been published to the registry.`);
|
|
113
|
+
console.error(`[publish-health] local=${localVersion} registry=<absent>`);
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
console.error(`[publish-health] INCONCLUSIVE: could not query the registry: ${msg.split('\n')[0]}`);
|
|
117
|
+
console.error('[publish-health] Treat as UNKNOWN, not as a pass.');
|
|
118
|
+
process.exit(2);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Stop as soon as the registry is at or ahead of local. Only an apparent lag is
|
|
122
|
+
// worth re-reading, and only because THIS script's own hook makes a stale read likely.
|
|
123
|
+
if (compareVersions(localVersion, registryVersion) <= 0) break;
|
|
124
|
+
|
|
125
|
+
if (attempt < REGISTRY_ATTEMPTS) {
|
|
126
|
+
console.log(
|
|
127
|
+
`[publish-health] registry says ${registryVersion}, local is ${localVersion} — ` +
|
|
128
|
+
`re-reading (${attempt}/${REGISTRY_ATTEMPTS - 1}) in case this is post-publish propagation lag.`,
|
|
129
|
+
);
|
|
130
|
+
sleepSync(REGISTRY_RETRY_MS);
|
|
86
131
|
}
|
|
87
|
-
console.error(`[publish-health] INCONCLUSIVE: could not query the registry: ${msg.split('\n')[0]}`);
|
|
88
|
-
console.error('[publish-health] Treat as UNKNOWN, not as a pass.');
|
|
89
|
-
process.exit(2);
|
|
90
132
|
}
|
|
91
133
|
|
|
92
134
|
const delta = compareVersions(localVersion, registryVersion);
|