@theholocron/cli 5.0.0-alpha.547 → 5.0.0-alpha.549

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 CHANGED
@@ -7700,6 +7700,12 @@ function areaLabelDefs(areas) {
7700
7700
  });
7701
7701
  }
7702
7702
  // src/area-labels/path-matches/path-matches.ts
7703
+ /** `value` without the slashes at its end. A scan from the end, not a pattern, so a long run of slashes costs one pass. */
7704
+ function withoutTrailingSlashes(value) {
7705
+ let end = value.length;
7706
+ while (end > 0 && value[end - 1] === "/") end -= 1;
7707
+ return value.slice(0, end);
7708
+ }
7703
7709
  /** Turns one glob into the expression a whole path must match: `**` crosses folders, `*` and `?` stay in one. */
7704
7710
  function globToRegExp(glob) {
7705
7711
  let out = "";
@@ -7724,7 +7730,7 @@ function globToRegExp(glob) {
7724
7730
  function pathMatches(path, pattern) {
7725
7731
  const clean = path.replace(/^\.?\//, "");
7726
7732
  if (/[*?]/.test(pattern)) return globToRegExp(pattern.replace(/^\.?\//, "")).test(clean);
7727
- const plain = pattern.replace(/^\.?\//, "").replace(/\/+$/, "");
7733
+ const plain = withoutTrailingSlashes(pattern.replace(/^\.?\//, ""));
7728
7734
  return clean === plain || clean.startsWith(`${plain}/`);
7729
7735
  }
7730
7736
  // src/area-labels/area-labels-for-files/area-labels-for-files.ts
@@ -10017,6 +10023,40 @@ function pinAlphaReleases(dependencies, lookup) {
10017
10023
  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
10024
  };
10019
10025
  }
10026
+ // src/commands/deploy-stage/settle-alpha-pins/settle-alpha-pins.ts
10027
+ /** Milliseconds between look-ups: a release publishes its packages one after another, over a few minutes. */
10028
+ const DEFAULT_PIN_WAITS_MS = [
10029
+ 15e3,
10030
+ 3e4,
10031
+ 6e4,
10032
+ 6e4
10033
+ ];
10034
+ function blockFor(milliseconds) {
10035
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds);
10036
+ }
10037
+ /**
10038
+ * Pins the `alpha` releases (`pinAlphaReleases()`) and looks them up again, after a wait, while a pinned release's exact
10039
+ * peer differs from the version staged for it. A deploy that starts while a release is publishing reads some tags before
10040
+ * the release and some after, and the install Vercel runs then fails; once every package reports the same release the
10041
+ * look-ups agree.
10042
+ *
10043
+ * @throws when the look-ups still disagree after the last try, naming each package and the versions that differ, so the
10044
+ * stage stops with the cause and not an install error on Vercel.
10045
+ */
10046
+ function settleAlphaPins(installed, lookup, options = {}) {
10047
+ const waits = options.waits ?? DEFAULT_PIN_WAITS_MS;
10048
+ const sleep = options.sleep ?? blockFor;
10049
+ const print = options.print ?? (() => {});
10050
+ let pinned = pinAlphaReleases(installed, lookup);
10051
+ for (const wait of waits) {
10052
+ if (pinned.mismatches.length === 0) return pinned;
10053
+ print(` the alpha tags do not agree yet (${pinned.mismatches.length} mismatched); looking again in ${Math.round(wait / 1e3)}s`);
10054
+ sleep(wait);
10055
+ pinned = pinAlphaReleases(installed, lookup);
10056
+ }
10057
+ 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"));
10058
+ return pinned;
10059
+ }
10020
10060
  // src/commands/deploy-stage/undeclared-externals.ts
10021
10061
  /** `"@scope/pkg/sub"` → `"@scope/pkg"`, `"pkg/sub"` → `"pkg"`. */
10022
10062
  function packageName(specifier) {
@@ -10115,6 +10155,9 @@ function vercelEngines(engines) {
10115
10155
  * 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
10156
  * version), so an `@theholocron/*` dependency installed at an `alpha` prerelease is pinned to npm's `alpha` tag
10117
10157
  * instead (`pinAlphaReleases()`); the lookup fails when npm cannot be reached, rather than staging the stale version.
10158
+ * A release that is still publishing leaves the tags disagreeing (one package at the new release, another at the old),
10159
+ * which Vercel's install rejects, so `settleAlphaPins()` looks them up again after a wait and fails, naming the
10160
+ * packages, if they never agree.
10118
10161
  */
10119
10162
  function installedVersion(packageDir, name) {
10120
10163
  const pkgPath = join(packageDir, "node_modules", name, "package.json");
@@ -10147,12 +10190,15 @@ function stageDeploy(input) {
10147
10190
  ].join("\n"));
10148
10191
  const direct = Object.fromEntries(Object.keys(pkg.dependencies ?? {}).map((name) => [name, resolveVersion(packageDir, name)]));
10149
10192
  const peers = Object.fromEntries(Object.keys(direct).flatMap((name) => Object.entries(resolvePeers(packageDir, name))).filter(([name]) => !(name in direct)));
10150
- const { dependencies, changes, mismatches } = pinAlphaReleases(Object.fromEntries(Object.entries({
10193
+ const { dependencies, changes } = settleAlphaPins(Object.fromEntries(Object.entries({
10151
10194
  ...direct,
10152
10195
  ...peers
10153
- }).sort(([a], [b]) => a.localeCompare(b))), input.alphaRelease ?? alphaRelease);
10196
+ }).sort(([a], [b]) => a.localeCompare(b))), input.alphaRelease ?? alphaRelease, {
10197
+ print,
10198
+ ...input.sleep ? { sleep: input.sleep } : {},
10199
+ ...input.pinWaits ? { waits: input.pinWaits } : {}
10200
+ });
10154
10201
  for (const change of changes) print(` pinned to npm's alpha tag: ${change}`);
10155
- for (const mismatch of mismatches) print(` warning: ${mismatch}`);
10156
10202
  rmSync(outDir, {
10157
10203
  recursive: true,
10158
10204
  force: true
@@ -16898,7 +16944,7 @@ function realReleasesIo(repoRoot, deps = defaultDeps$1) {
16898
16944
  },
16899
16945
  packages: (scope) => [...deps.discover(repoRoot, scope)],
16900
16946
  distTags: async (name) => {
16901
- const response = await deps.fetch(`${REGISTRY}/-/package/${name.replace("/", "%2f")}/dist-tags`);
16947
+ const response = await deps.fetch(`${REGISTRY}/-/package/${name.split("/").join("%2f")}/dist-tags`);
16902
16948
  if (response.status === 404 || response.status === 401) return void 0;
16903
16949
  if (!response.ok) throw new Error(`npm answered ${response.status} for ${name}`);
16904
16950
  return await response.json();