@theholocron/cli 5.0.0-alpha.546 → 5.0.0-alpha.548
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/dist/cli.mjs +43 -3
- package/dist/cli.mjs.map +1 -1
- package/package.json +5 -5
package/dist/cli.mjs
CHANGED
|
@@ -10017,6 +10017,40 @@ function pinAlphaReleases(dependencies, lookup) {
|
|
|
10017
10017
|
mismatches: peerRanges.flatMap(([name, version, peers]) => Object.entries(peers).filter(([peer, range]) => peer in pinned && EXACT_VERSION.test(range) && pinned[peer] !== range).map(([peer, range]) => `${name}@${version} peers ${peer}@${range}, but ${peer}@${pinned[peer]} is staged`))
|
|
10018
10018
|
};
|
|
10019
10019
|
}
|
|
10020
|
+
// src/commands/deploy-stage/settle-alpha-pins/settle-alpha-pins.ts
|
|
10021
|
+
/** Milliseconds between look-ups: a release publishes its packages one after another, over a few minutes. */
|
|
10022
|
+
const DEFAULT_PIN_WAITS_MS = [
|
|
10023
|
+
15e3,
|
|
10024
|
+
3e4,
|
|
10025
|
+
6e4,
|
|
10026
|
+
6e4
|
|
10027
|
+
];
|
|
10028
|
+
function blockFor(milliseconds) {
|
|
10029
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds);
|
|
10030
|
+
}
|
|
10031
|
+
/**
|
|
10032
|
+
* Pins the `alpha` releases (`pinAlphaReleases()`) and looks them up again, after a wait, while a pinned release's exact
|
|
10033
|
+
* peer differs from the version staged for it. A deploy that starts while a release is publishing reads some tags before
|
|
10034
|
+
* the release and some after, and the install Vercel runs then fails; once every package reports the same release the
|
|
10035
|
+
* look-ups agree.
|
|
10036
|
+
*
|
|
10037
|
+
* @throws when the look-ups still disagree after the last try, naming each package and the versions that differ, so the
|
|
10038
|
+
* stage stops with the cause and not an install error on Vercel.
|
|
10039
|
+
*/
|
|
10040
|
+
function settleAlphaPins(installed, lookup, options = {}) {
|
|
10041
|
+
const waits = options.waits ?? DEFAULT_PIN_WAITS_MS;
|
|
10042
|
+
const sleep = options.sleep ?? blockFor;
|
|
10043
|
+
const print = options.print ?? (() => {});
|
|
10044
|
+
let pinned = pinAlphaReleases(installed, lookup);
|
|
10045
|
+
for (const wait of waits) {
|
|
10046
|
+
if (pinned.mismatches.length === 0) return pinned;
|
|
10047
|
+
print(` the alpha tags do not agree yet (${pinned.mismatches.length} mismatched); looking again in ${Math.round(wait / 1e3)}s`);
|
|
10048
|
+
sleep(wait);
|
|
10049
|
+
pinned = pinAlphaReleases(installed, lookup);
|
|
10050
|
+
}
|
|
10051
|
+
if (pinned.mismatches.length > 0) throw new Error(["npm's alpha tags still do not agree after waiting, so the staged install would fail; a release is probably still publishing. Run the deploy again once it has finished —", ...pinned.mismatches.map((mismatch) => ` - ${mismatch}`)].join("\n"));
|
|
10052
|
+
return pinned;
|
|
10053
|
+
}
|
|
10020
10054
|
// src/commands/deploy-stage/undeclared-externals.ts
|
|
10021
10055
|
/** `"@scope/pkg/sub"` → `"@scope/pkg"`, `"pkg/sub"` → `"pkg"`. */
|
|
10022
10056
|
function packageName(specifier) {
|
|
@@ -10115,6 +10149,9 @@ function vercelEngines(engines) {
|
|
|
10115
10149
|
* released (the plugins sit at 5.0.0-alpha.132 on disk and 5.0.0-alpha.393 on npm, and each peers on exactly one CLI
|
|
10116
10150
|
* version), so an `@theholocron/*` dependency installed at an `alpha` prerelease is pinned to npm's `alpha` tag
|
|
10117
10151
|
* instead (`pinAlphaReleases()`); the lookup fails when npm cannot be reached, rather than staging the stale version.
|
|
10152
|
+
* A release that is still publishing leaves the tags disagreeing (one package at the new release, another at the old),
|
|
10153
|
+
* which Vercel's install rejects, so `settleAlphaPins()` looks them up again after a wait and fails, naming the
|
|
10154
|
+
* packages, if they never agree.
|
|
10118
10155
|
*/
|
|
10119
10156
|
function installedVersion(packageDir, name) {
|
|
10120
10157
|
const pkgPath = join(packageDir, "node_modules", name, "package.json");
|
|
@@ -10147,12 +10184,15 @@ function stageDeploy(input) {
|
|
|
10147
10184
|
].join("\n"));
|
|
10148
10185
|
const direct = Object.fromEntries(Object.keys(pkg.dependencies ?? {}).map((name) => [name, resolveVersion(packageDir, name)]));
|
|
10149
10186
|
const peers = Object.fromEntries(Object.keys(direct).flatMap((name) => Object.entries(resolvePeers(packageDir, name))).filter(([name]) => !(name in direct)));
|
|
10150
|
-
const { dependencies, changes
|
|
10187
|
+
const { dependencies, changes } = settleAlphaPins(Object.fromEntries(Object.entries({
|
|
10151
10188
|
...direct,
|
|
10152
10189
|
...peers
|
|
10153
|
-
}).sort(([a], [b]) => a.localeCompare(b))), input.alphaRelease ?? alphaRelease
|
|
10190
|
+
}).sort(([a], [b]) => a.localeCompare(b))), input.alphaRelease ?? alphaRelease, {
|
|
10191
|
+
print,
|
|
10192
|
+
...input.sleep ? { sleep: input.sleep } : {},
|
|
10193
|
+
...input.pinWaits ? { waits: input.pinWaits } : {}
|
|
10194
|
+
});
|
|
10154
10195
|
for (const change of changes) print(` pinned to npm's alpha tag: ${change}`);
|
|
10155
|
-
for (const mismatch of mismatches) print(` warning: ${mismatch}`);
|
|
10156
10196
|
rmSync(outDir, {
|
|
10157
10197
|
recursive: true,
|
|
10158
10198
|
force: true
|