@icebreakers/monorepo 6.2.1 → 6.3.0

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.
Files changed (25) hide show
  1. package/dist/{baseline-BQu4IKz4.mjs → baseline-BXoKjFDc.mjs} +1 -1
  2. package/dist/{catalog-CCIOouaT.mjs → catalog-DudDvxE5.mjs} +3 -3
  3. package/dist/cli.mjs +62 -62
  4. package/dist/{commands-CWJn-_PI.mjs → commands-G_3pcd5o.mjs} +351 -50
  5. package/dist/{config-DnZHBngA.mjs → config-DqJ0beGQ.mjs} +3 -3
  6. package/dist/{create-flow-C0CPG04P.mjs → create-flow-vqU0T6DM.mjs} +3 -3
  7. package/dist/{deps-8UyoQQd6.mjs → deps-CVyYELEM.mjs} +3 -3
  8. package/dist/{execute-BYzX0pIK.mjs → execute-C0tk43nV.mjs} +2 -2
  9. package/dist/{execute-CiqUeURT.mjs → execute-UZ1AUrmz.mjs} +2 -2
  10. package/dist/{format-B059MkpS.mjs → format-3OSXfhZY.mjs} +1 -1
  11. package/dist/index.d.mts +61 -4
  12. package/dist/index.mjs +9 -9
  13. package/dist/{inputs-DfmfV3ft.mjs → inputs-qTTW0pSA.mjs} +1 -1
  14. package/dist/{npm-DO0l0ypv.mjs → npm-BdWubZeI.mjs} +1 -1
  15. package/dist/{plan-Cnl_s1t5.mjs → plan-BLXqSULE.mjs} +1 -1
  16. package/dist/{run-BO8ggtNx.mjs → run-PZp-5W7K.mjs} +4 -4
  17. package/dist/{save-DJijxFFK.mjs → save-DMGOqrDC.mjs} +3 -3
  18. package/dist/{scan-BBXEVepK.mjs → scan-CCqgGghe.mjs} +2 -2
  19. package/dist/{template-drift-BD8maCoP.mjs → template-drift-Bzhsxp8j.mjs} +3 -3
  20. package/dist/tooling-entry.mjs +2 -2
  21. package/dist/{transaction-CglLPcZ_.mjs → transaction-DfrFvDMo.mjs} +2 -2
  22. package/dist/{tsconfig-DCmFfA6W.mjs → tsconfig-DPfr8Ok1.mjs} +1 -1
  23. package/dist/{vitest-D8nnSzlj.mjs → vitest-DoVgJQaG.mjs} +1 -1
  24. package/dist/{workspace-tasks-BK8EQ2x4.mjs → workspace-tasks-B3GGECnD.mjs} +5 -5
  25. package/package.json +1 -1
@@ -1,12 +1,12 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
2
- import { A as referenceTarget, B as saveKnipBaseline, C as loadCompiler, D as ownershipFile, E as exists$1, Gt as getWorkspacePackages, Ht as clearWorkspaceCache, I as getKnipConfigurationSuggestions, J as getWorkspaceGraph, Jt as GitClient, K as mergeText, M as formatEnvironmentCache, O as readText, P as checkEnvironmentCache, R as planKnipCheck, S as configReader, St as localize, T as compare$1, Tt as resolveRepoctlLocale, Ut as getWorkspaceData, W as analyzeTurboRuns, Wt as getWorkspacePackageSummaries, Z as getWorkspaceImpact, _ as planTemplateLink, _t as assetsDir$1, at as record$5, b as planGenerate, c as loadTemplateInstanceRegistry$1, ct as renderCreateNewProject, dt as migrateLegacyToolingReferences, et as compareGraphValues, f as recoverTemplateUpgrade, ft as setByPath, g as applyTemplateLinkPlan, gt as validateCleanTargets, h as loadTemplateUpgradeJournal, ht as isWithin, it as readInput, j as relativeFile, jt as fs$2, k as referencePath, l as rebuildTemplateInstanceBaseline, lt as rewriteTemplateSnapshotReferences, m as planTemplateUpgrade, mt as assertSafePath, nt as workspaceDependencyTypes, o as listTemplateInstances, ot as safeFile, p as applyTemplateUpgradePlan, pt as stageFileTransaction, q as withOperationLock, qt as findWorkspacePackages, rt as hash$1, s as loadTemplateBaseline$1, tt as resolveWorkspaceGraphNode, u as relocateTemplateInstance, w as validateGraph, x as generators, xt as templatesDir, y as applyGeneratePlan, yt as packageDir$1, z as runKnipCheck } from "./workspace-tasks-BK8EQ2x4.mjs";
3
- import { a as resolveFullWorkspaceCheckPlan, c as verifyCommitMsg, d as logger, i as getKnownRepoCheckCommands, l as verifyPreCommit, n as resolveAffectedCheckContext, o as resolveRecommendedCheckPlan, r as resolveAffectedCheckPlan, s as runRecommendedCheck, t as runCheckWithReport, u as runPnpmCommand } from "./execute-BYzX0pIK.mjs";
4
- import { A as package_default$1, B as templateSourcePath, C as checkedFile, D as relativeFile$1, E as readOptionalSource, G as presetVersion, H as isUpgradeExpiry, I as normalizeTemplateRemoteSource, J as isRecord$2, K as withLegacyHookConfig, L as normalizeTemplateSourceRequest, N as ConfigValidationError, O as engines$1, Q as commandConfigDirectory, S as canonicalDirectory, T as readOptional$1, U as resolveNightlyConfig, W as presetPackageName, X as appendConfigPath, _ as listToolingCapabilities, b as presetRelativePath, d as loadMonorepoConfig, f as loadMonorepoConfigDetails, g as presetAssetTarget, j as version$2, n as defineTsconfigConfig, p as resolveCommandConfig, u as getRepoctlConfigCandidates, v as installedPresetDirectory, w as hash$2, x as readPresetFile, y as parsePresetJson, z as sourceRequestKey } from "./tsconfig-DCmFfA6W.mjs";
5
- import { c as selectCommandOverrides, i as rangesOverlap, l as chinaMirrorsEnvs, o as matchGroup, r as parseSpecifier, s as resolveCommandValues, t as scanDependencies } from "./scan-BBXEVepK.mjs";
6
- import { A as isRootAsset, B as toWorkspaceAssetPath, C as lockfileRecord, D as baselineDirectory, E as checkDependencyAdmission, F as getWorkspacePatterns, I as summarizeChecks, L as legacyStagedConfigNames, M as templatePackage, N as getAssetTargets, O as baselinePath, P as record$6, S as inspectPnpmRuntime, a as applyDoctorSuppressions, b as resolveReleaseBranches, c as collectSelectedDoctorChecks, d as recommendedRepoScripts, f as inspectInstallSecurity, g as isLegacyReleaseWorkflow, h as supportedVersion, i as hasTemplateDriftIssues, j as parseBaseline, k as encodeBaseline, l as getDoctorRuleIds, m as settingState, o as validateDoctorSuppressions, p as readSecuritySources, r as formatTemplateDriftReport, s as validateDoctorConfiguration, t as checkTemplateDrift, u as selectDoctorRules, v as renderReleaseWorkflow, w as parseWorkspaceLockfile, x as ReleaseCommandError, y as releasePullRequestHead } from "./template-drift-BD8maCoP.mjs";
7
- import { t as writeDependencyTransaction } from "./transaction-CglLPcZ_.mjs";
8
- import { i as applyDependencyFixPlan, r as planDependencyFix, t as checkDependencies } from "./deps-8UyoQQd6.mjs";
9
- import { i as applyCatalogMigrationPlan, n as checkCatalogs, r as planCatalogMigration } from "./catalog-CCIOouaT.mjs";
2
+ import { A as referenceTarget, B as saveKnipBaseline, C as loadCompiler, D as ownershipFile, E as exists$1, Gt as getWorkspacePackages, Ht as clearWorkspaceCache, I as getKnipConfigurationSuggestions, J as getWorkspaceGraph, Jt as GitClient, K as mergeText, M as formatEnvironmentCache, O as readText, P as checkEnvironmentCache, R as planKnipCheck, S as configReader, St as localize, T as compare$1, Tt as resolveRepoctlLocale, Ut as getWorkspaceData, W as analyzeTurboRuns, Wt as getWorkspacePackageSummaries, Z as getWorkspaceImpact, _ as planTemplateLink, _t as assetsDir$1, at as record$5, b as planGenerate, c as loadTemplateInstanceRegistry$1, ct as renderCreateNewProject, dt as migrateLegacyToolingReferences, et as compareGraphValues, f as recoverTemplateUpgrade, ft as setByPath, g as applyTemplateLinkPlan, gt as validateCleanTargets, h as loadTemplateUpgradeJournal, ht as isWithin, it as readInput, j as relativeFile, jt as fs$2, k as referencePath, l as rebuildTemplateInstanceBaseline, lt as rewriteTemplateSnapshotReferences, m as planTemplateUpgrade, mt as assertSafePath, nt as workspaceDependencyTypes, o as listTemplateInstances, ot as safeFile, p as applyTemplateUpgradePlan, pt as stageFileTransaction, q as withOperationLock, qt as findWorkspacePackages, rt as hash$1, s as loadTemplateBaseline$1, tt as resolveWorkspaceGraphNode, u as relocateTemplateInstance, w as validateGraph, x as generators, xt as templatesDir, y as applyGeneratePlan, yt as packageDir$1, z as runKnipCheck } from "./workspace-tasks-B3GGECnD.mjs";
3
+ import { a as resolveFullWorkspaceCheckPlan, c as verifyCommitMsg, d as logger, i as getKnownRepoCheckCommands, l as verifyPreCommit, n as resolveAffectedCheckContext, o as resolveRecommendedCheckPlan, r as resolveAffectedCheckPlan, s as runRecommendedCheck, t as runCheckWithReport, u as runPnpmCommand } from "./execute-C0tk43nV.mjs";
4
+ import { A as package_default$1, B as templateSourcePath, C as checkedFile, D as relativeFile$1, E as readOptionalSource, G as presetVersion, H as isUpgradeExpiry, I as normalizeTemplateRemoteSource, J as isRecord$2, K as withLegacyHookConfig, L as normalizeTemplateSourceRequest, N as ConfigValidationError, O as engines$1, Q as commandConfigDirectory, S as canonicalDirectory, T as readOptional$1, U as resolveNightlyConfig, W as presetPackageName, X as appendConfigPath, _ as listToolingCapabilities, b as presetRelativePath, d as loadMonorepoConfig, f as loadMonorepoConfigDetails, g as presetAssetTarget, j as version$2, n as defineTsconfigConfig, p as resolveCommandConfig, u as getRepoctlConfigCandidates, v as installedPresetDirectory, w as hash$2, x as readPresetFile, y as parsePresetJson, z as sourceRequestKey } from "./tsconfig-DPfr8Ok1.mjs";
5
+ import { c as selectCommandOverrides, i as rangesOverlap, l as chinaMirrorsEnvs, o as matchGroup, r as parseSpecifier, s as resolveCommandValues, t as scanDependencies } from "./scan-CCqgGghe.mjs";
6
+ import { A as isRootAsset, B as toWorkspaceAssetPath, C as lockfileRecord, D as baselineDirectory, E as checkDependencyAdmission, F as getWorkspacePatterns, I as summarizeChecks, L as legacyStagedConfigNames, M as templatePackage, N as getAssetTargets, O as baselinePath, P as record$6, S as inspectPnpmRuntime, a as applyDoctorSuppressions, b as resolveReleaseBranches, c as collectSelectedDoctorChecks, d as recommendedRepoScripts, f as inspectInstallSecurity, g as isLegacyReleaseWorkflow, h as supportedVersion, i as hasTemplateDriftIssues, j as parseBaseline, k as encodeBaseline, l as getDoctorRuleIds, m as settingState, o as validateDoctorSuppressions, p as readSecuritySources, r as formatTemplateDriftReport, s as validateDoctorConfiguration, t as checkTemplateDrift, u as selectDoctorRules, v as renderReleaseWorkflow, w as parseWorkspaceLockfile, x as ReleaseCommandError, y as releasePullRequestHead } from "./template-drift-Bzhsxp8j.mjs";
7
+ import { t as writeDependencyTransaction } from "./transaction-DfrFvDMo.mjs";
8
+ import { i as applyDependencyFixPlan, r as planDependencyFix, t as checkDependencies } from "./deps-CVyYELEM.mjs";
9
+ import { i as applyCatalogMigrationPlan, n as checkCatalogs, r as planCatalogMigration } from "./catalog-DudDvxE5.mjs";
10
10
  import { createRequire, isBuiltin } from "node:module";
11
11
  import { findWorkspaceDir } from "@pnpm/find-workspace-dir";
12
12
  import { readWorkspaceManifest } from "@pnpm/workspace.read-manifest";
@@ -1542,7 +1542,7 @@ async function downloadGitTemplate(source, directory, timeout) {
1542
1542
  async function resolveRemoteTemplateSource(source, templatePath = ".", options = {}) {
1543
1543
  const request = normalizeTemplateSourceRequest(source, templatePath);
1544
1544
  const cwd = path$1.resolve(options.cwd ?? process.cwd());
1545
- const npm = request.source.kind === "npm" ? await import("./npm-DO0l0ypv.mjs") : void 0;
1545
+ const npm = request.source.kind === "npm" ? await import("./npm-BdWubZeI.mjs") : void 0;
1546
1546
  const configuration = request.source.kind === "npm" ? await npm.npmTemplateConfiguration(request.source, cwd) : void 0;
1547
1547
  if (request.source.kind === "npm") request.source.registry = configuration.registry;
1548
1548
  const cacheDir = path$1.resolve(cwd, options.cacheDir ?? path$1.join(process.env["XDG_CACHE_HOME"] ?? path$1.join(homedir(), ".cache"), "repoctl", "template-sources-v1"));
@@ -5146,7 +5146,7 @@ function selectLevel(policy, revision) {
5146
5146
  const type = titleType(revision.title);
5147
5147
  return explicit ?? (type ? ownValue(policy.titleTypes, type) ?? (type === "feat" ? "minor" : void 0) : void 0) ?? policy.defaultLevel ?? "patch";
5148
5148
  }
5149
- function matches$1(value, patterns) {
5149
+ function matches$2(value, patterns) {
5150
5150
  return micromatch.isMatch(value, patterns, { dot: true });
5151
5151
  }
5152
5152
  function owner(filename, packages) {
@@ -5170,17 +5170,17 @@ function selectPackages$1(files, head, base, policy, level) {
5170
5170
  return changed;
5171
5171
  }
5172
5172
  for (const file of files) for (const filename of [file.filename, ...file.previousFilename ? [file.previousFilename] : []]) {
5173
- if (matches$1(filename, [
5173
+ if (matches$2(filename, [
5174
5174
  ".changeset/**",
5175
5175
  "**/node_modules/**",
5176
5176
  "**/dist/**",
5177
5177
  ...policy.ignorePaths ?? []
5178
5178
  ])) continue;
5179
- const rule = policy.paths?.find((item) => matches$1(filename, item.patterns));
5179
+ const rule = policy.paths?.find((item) => matches$2(filename, item.patterns));
5180
5180
  if (rule?.release === false) continue;
5181
5181
  const previous = owner(filename, base);
5182
5182
  const current = owner(filename, head);
5183
- const candidates = rule?.packages ? head.filter((pkg) => matches$1(pkg.name, rule.packages)) : [current, previous ? head.find((pkg) => pkg.name === previous.name) ?? previous : void 0].filter((pkg) => Boolean(pkg));
5183
+ const candidates = rule?.packages ? head.filter((pkg) => matches$2(pkg.name, rule.packages)) : [current, previous ? head.find((pkg) => pkg.name === previous.name) ?? previous : void 0].filter((pkg) => Boolean(pkg));
5184
5184
  if (rule?.packages && !candidates.length) throw new Error(`Release path policy selected no workspace packages: ${filename}.`);
5185
5185
  for (const pkg of candidates) {
5186
5186
  if (!head.some((item) => item.name === pkg.name)) {
@@ -5195,14 +5195,14 @@ function selectPackages$1(files, head, base, policy, level) {
5195
5195
  while (changed) {
5196
5196
  changed = false;
5197
5197
  for (const link of policy.links ?? []) {
5198
- const sources = [...selections.values()].filter((pkg) => matches$1(pkg.name, link.from));
5198
+ const sources = [...selections.values()].filter((pkg) => matches$2(pkg.name, link.from));
5199
5199
  for (const source of sources) {
5200
5200
  const fields = link.dependencyFields ?? [
5201
5201
  "dependencies",
5202
5202
  "optionalDependencies",
5203
5203
  "peerDependencies"
5204
5204
  ];
5205
- for (const pkg of head) if (link.to && matches$1(pkg.name, link.to) || link.dependents && pkg.dependencies.some((dependency) => dependency.name === source.name && fields.includes(dependency.field))) changed = select(pkg, !link.level || link.level === "same" ? source.level : link.level, `linked:${source.name}`) || changed;
5205
+ for (const pkg of head) if (link.to && matches$2(pkg.name, link.to) || link.dependents && pkg.dependencies.some((dependency) => dependency.name === source.name && fields.includes(dependency.field))) changed = select(pkg, !link.level || link.level === "same" ? source.level : link.level, `linked:${source.name}`) || changed;
5206
5206
  }
5207
5207
  }
5208
5208
  }
@@ -6984,6 +6984,19 @@ var GitHubClient = class extends GitHubTransport {
6984
6984
  return recovered.data;
6985
6985
  }
6986
6986
  }
6987
+ /** 只按准确 tag 读取,分页集合不能证明某个已知版本不存在。 */
6988
+ async readRelease(tag) {
6989
+ let response;
6990
+ try {
6991
+ response = await this.request("GET", `/releases/tags/${encodeURIComponent(tag)}`);
6992
+ } catch (error) {
6993
+ if (error instanceof GitHubApiError && error.status === 404) return;
6994
+ throw error;
6995
+ }
6996
+ const data = response.data;
6997
+ if (!data || Array.isArray(data) || typeof data !== "object" || !Number.isSafeInteger(data.id) || data.id <= 0 || typeof data.html_url !== "string" || data.tag_name !== tag || typeof data.draft !== "boolean" || typeof data.prerelease !== "boolean") throw new GitHubApiError(`GitHub returned invalid release response for ${tag}; release state is unknown`, response.status);
6998
+ return data;
6999
+ }
6987
7000
  async listReleases() {
6988
7001
  const releases = [];
6989
7002
  for (let page = 1;; page++) {
@@ -8144,7 +8157,7 @@ async function assertPreviousReleaseComplete(options, distTag = "latest") {
8144
8157
  }
8145
8158
  if (!prepared.length) return;
8146
8159
  const github = options.github;
8147
- const releases = github?.listReleases ? await github.listReleases() : void 0;
8160
+ const releases = !github?.readRelease && github?.listReleases ? await github.listReleases() : void 0;
8148
8161
  const repository = getReleaseEnv(options)["GITHUB_REPOSITORY"];
8149
8162
  const sources = /* @__PURE__ */ new Map();
8150
8163
  const cohorts = /* @__PURE__ */ new Map();
@@ -8163,9 +8176,9 @@ async function assertPreviousReleaseComplete(options, distTag = "latest") {
8163
8176
  const rule = options.config?.branches ? await resolveReleaseBranch(options) : void 0;
8164
8177
  for (const pkg of prepared) {
8165
8178
  const published = await inspectRegistry(pkg, options);
8166
- const release = releases?.find((item) => item.tag_name === packageKey(pkg));
8179
+ const release = github?.readRelease ? await github.readRelease(packageKey(pkg)) : releases?.find((item) => item.tag_name === packageKey(pkg));
8167
8180
  const tag = github?.readTagTarget ? await github.readTagTarget(packageKey(pkg)) : void 0;
8168
- if (!published || unfinished.has(packageKey(pkg)) || releases && (!release || release.draft || Boolean(release.prerelease) !== Boolean(semver.prerelease(pkg.version))) || github?.readTagTarget && (!tag || published.gitHead && tag !== published.gitHead)) {
8181
+ if (!published || unfinished.has(packageKey(pkg)) || (github?.readRelease || releases) && (!release || release.draft || Boolean(release.prerelease) !== Boolean(semver.prerelease(pkg.version))) || github?.readTagTarget && (!tag || published.gitHead && tag !== published.gitHead)) {
8169
8182
  const source = sources.get(packageKey(pkg));
8170
8183
  const recovery = rule?.kind === "maintenance" || distTag === "latest" ? `${rule ? `check out ${rule.branch} and run ` : ""}repo release ci --mode publish --source-sha ${source}` : `check out ${source} on ${rule?.branch ?? distTag} and run repo release ci`;
8171
8184
  blocked.push(`${packageKey(pkg)} (source ${source}); recover with ${recovery}`);
@@ -11273,7 +11286,7 @@ function readinessUrl(target) {
11273
11286
  if (url.protocol !== "https:" || url.username || url.password || url.search || url.hash) throw new DocsDiagnosticError("readiness-url-invalid");
11274
11287
  return new URL(`/${docsManifestPath}`, url).href;
11275
11288
  }
11276
- function matches(value, plan) {
11289
+ function matches$1(value, plan) {
11277
11290
  if (!value || typeof value !== "object" || Array.isArray(value)) return false;
11278
11291
  return Object.entries(docsManifest(plan)).every(([key, expected]) => Reflect.get(value, key) === expected) && (plan.releaseId !== void 0 || !Object.hasOwn(value, "releaseId"));
11279
11292
  }
@@ -11340,7 +11353,7 @@ async function probe(url, plan, request, timeoutMs) {
11340
11353
  }
11341
11354
  const value = await readBody(response, controller.signal);
11342
11355
  if (!value || typeof value !== "object" || Array.isArray(value)) return "invalid-payload";
11343
- return matches(value, plan) ? void 0 : "identity-mismatch";
11356
+ return matches$1(value, plan) ? void 0 : "identity-mismatch";
11344
11357
  } catch (error) {
11345
11358
  return controller.signal.aborted ? "request-timeout" : error instanceof DocsReadinessError ? error.reason : "network-error";
11346
11359
  }
@@ -13481,7 +13494,7 @@ function expand(subpath, target, files) {
13481
13494
  };
13482
13495
  });
13483
13496
  }
13484
- /** Only exercise declared Node entrypoints; browser/assets/type-only paths are not Node modules. */
13497
+ /** 仅执行声明的 Node 入口;原生扩展通过 CommonJS 实际加载。 */
13485
13498
  function consumerEntries(manifest, files) {
13486
13499
  const assets = consumerRuntimeAssets(manifest);
13487
13500
  const exports = manifest.exports;
@@ -13494,7 +13507,9 @@ function consumerEntries(manifest, files) {
13494
13507
  condition,
13495
13508
  "default"
13496
13509
  ]));
13497
- const runtime = !!runtimeTarget && /\.[cm]?js$/u.test(runtimeTarget);
13510
+ const native = !!runtimeTarget && runtimeTarget.endsWith(".node");
13511
+ if (native && format !== "cjs") continue;
13512
+ const runtime = !!runtimeTarget && (/\.[cm]?js$/u.test(runtimeTarget) || native);
13498
13513
  const target = runtime ? runtimeTarget : resolveTarget(value, /* @__PURE__ */ new Set([
13499
13514
  "types",
13500
13515
  "node",
@@ -13502,15 +13517,16 @@ function consumerEntries(manifest, files) {
13502
13517
  "default"
13503
13518
  ])) ?? (subpath === "." ? manifest.types : void 0);
13504
13519
  if (!target || !runtime && !/\.d\.[cm]?ts$/u.test(target)) continue;
13505
- if ((/\.(?:mjs|mts)$/u.test(target) || !/\.(?:cjs|cts)$/u.test(target) && manifest.type === "module" ? "esm" : "cjs") !== format && !declaresCondition(value, condition)) continue;
13520
+ if ((!native && (/\.(?:mjs|mts)$/u.test(target) || !/\.(?:cjs|cts)$/u.test(target) && manifest.type === "module") ? "esm" : "cjs") !== format && !declaresCondition(value, condition)) continue;
13506
13521
  for (const expanded of expand(subpath, target, files)) {
13507
13522
  const asset = assets.has(expanded.subpath);
13508
13523
  const declaration = expanded.target.replace(/\.([cm]?)js$/u, ".d.$1ts").replace(/^\.\//u, "");
13509
- const typecheck = declaresCondition(value, "types") || expanded.subpath === "." && typeof manifest.types === "string" || files.includes(declaration);
13524
+ const typecheck = declaresCondition(value, "types") || expanded.subpath === "." && typeof manifest.types === "string" || !native && files.includes(declaration);
13510
13525
  entries.push({
13511
13526
  ...expanded,
13512
13527
  format,
13513
13528
  runtime,
13529
+ ...native ? { typecheck } : {},
13514
13530
  ...asset ? {
13515
13531
  asset: true,
13516
13532
  typecheck
@@ -13690,23 +13706,115 @@ async function resolveConsumerPeerAliases(dependencies, query) {
13690
13706
  return resolved;
13691
13707
  }
13692
13708
  //#endregion
13709
+ //#region src/commands/package-check/consumer/platform.ts
13710
+ let actualHost;
13711
+ /** 仅使用当前 Node 进程和系统证据,忽略包管理器的目标平台覆盖配置。 */
13712
+ function consumerHost() {
13713
+ if (actualHost) return actualHost;
13714
+ const host = {
13715
+ os: process.platform,
13716
+ cpu: process.arch
13717
+ };
13718
+ if (process.platform === "linux") {
13719
+ const report = process.report?.getReport();
13720
+ if (report?.header?.glibcVersionRuntime) host.libc = "glibc";
13721
+ else if (report?.sharedObjects?.some((file) => /ld-musl|libc\.musl/u.test(file))) host.libc = "musl";
13722
+ else {
13723
+ let output = "";
13724
+ try {
13725
+ output = execFileSync("ldd", ["--version"], {
13726
+ encoding: "utf8",
13727
+ timeout: 5e3,
13728
+ stdio: [
13729
+ "ignore",
13730
+ "pipe",
13731
+ "pipe"
13732
+ ]
13733
+ });
13734
+ } catch (error) {
13735
+ const failure = error;
13736
+ output = `${String(failure.stdout ?? "")}\n${String(failure.stderr ?? "")}`;
13737
+ }
13738
+ if (/musl/iu.test(output)) host.libc = "musl";
13739
+ else if (/glibc|gnu libc|gnu c library/iu.test(output)) host.libc = "glibc";
13740
+ }
13741
+ }
13742
+ actualHost = Object.freeze(host);
13743
+ return actualHost;
13744
+ }
13745
+ function matches(values, actual) {
13746
+ const blocked = values.some((value) => value === "!any" || actual !== void 0 && value === `!${actual}`);
13747
+ const allowed = values.filter((value) => !value.startsWith("!"));
13748
+ return !blocked && (!allowed.length || allowed.includes("any") || actual !== void 0 && allowed.includes(actual));
13749
+ }
13750
+ /** 正负约束分别求交;无法确定 libc 时不宣称满足任何具体 libc。 */
13751
+ function consumerApplicability(manifest, host = consumerHost()) {
13752
+ for (const field of [
13753
+ "os",
13754
+ "cpu",
13755
+ "libc"
13756
+ ]) {
13757
+ const values = manifest[field];
13758
+ if (values === void 0) continue;
13759
+ if (!Array.isArray(values) || values.some((value) => typeof value !== "string" || !value || value === "!")) throw new Error(`Consumer package ${manifest.name} has invalid ${field} constraints.`);
13760
+ if (!matches(values, host[field])) return {
13761
+ status: "not-applicable",
13762
+ host,
13763
+ reason: `${field} ${host[field] ?? "unknown"} does not satisfy ${JSON.stringify(values)}.`
13764
+ };
13765
+ }
13766
+ return {
13767
+ status: "applicable",
13768
+ host
13769
+ };
13770
+ }
13771
+ /** 每个已校验产物都记录宿主适用性,供批量消费者筛选安装根节点。 */
13772
+ function consumerPackageApplicability(manifests) {
13773
+ const host = consumerHost();
13774
+ return manifests.map((manifest) => ({
13775
+ name: String(manifest.name),
13776
+ version: String(manifest.version),
13777
+ ...consumerApplicability(manifest, host)
13778
+ }));
13779
+ }
13780
+ //#endregion
13693
13781
  //#region src/commands/package-check/consumer/runtime-closure.ts
13694
13782
  /** Follow checked runtime dependencies and peers without importing development tooling. */
13695
13783
  function consumerRuntimeClosure(roots, manifests, expected) {
13696
13784
  const known = new Map(manifests.map((manifest) => [manifest.name, manifest]));
13697
13785
  const visited = /* @__PURE__ */ new Set();
13698
13786
  const references = [];
13787
+ const optional = (manifest, reference) => reference.field === "optionalDependencies" || reference.field === "peerDependencies" && manifest.peerDependenciesMeta?.[reference.alias]?.optional === true;
13788
+ const runtimeReferences = (manifest) => dependencyReferences(manifest, ".").filter((reference) => reference.field !== "dependencies" || manifest.optionalDependencies?.[reference.alias] === void 0);
13789
+ const incompatible = (manifest, seen = /* @__PURE__ */ new Set()) => {
13790
+ const applicability = consumerApplicability(manifest);
13791
+ if (applicability.status === "not-applicable") return `${manifest.name}: ${applicability.reason}`;
13792
+ if (seen.has(manifest)) return;
13793
+ seen.add(manifest);
13794
+ for (const reference of runtimeReferences(manifest)) {
13795
+ if (optional(manifest, reference)) continue;
13796
+ const name = consumerDependency({ manifest }, reference, expected)?.name ?? reference.name;
13797
+ const local = known.get(name);
13798
+ const reason = local && incompatible(local, seen);
13799
+ if (reason) return reason;
13800
+ }
13801
+ };
13699
13802
  const visit = (manifest) => {
13700
13803
  if (visited.has(manifest)) return;
13701
13804
  visited.add(manifest);
13702
- for (const reference of dependencyReferences(manifest, ".")) {
13805
+ for (const reference of runtimeReferences(manifest)) {
13703
13806
  const name = consumerDependency({ manifest }, reference, expected)?.name ?? reference.name;
13807
+ const local = known.get(name);
13808
+ const reason = local && incompatible(local);
13809
+ if (reason) {
13810
+ if (optional(manifest, reference)) continue;
13811
+ throw new Error(`Consumer required dependency ${manifest.name}>${reference.alias} is incompatible with this host: ${reason}`);
13812
+ }
13704
13813
  references.push({
13705
13814
  manifest,
13706
13815
  reference,
13707
13816
  name
13708
13817
  });
13709
- const local = known.get(name);
13710
13818
  if (local) visit(local);
13711
13819
  }
13712
13820
  };
@@ -13896,7 +14004,9 @@ async function consumeTarball(pkg, packages, results, entries, directory, timeou
13896
14004
  const { result } = pkg;
13897
14005
  const { packageManager } = options;
13898
14006
  checkDependencyRanges(pkg, packages, results, options.expectedWorkspaceLocators);
14007
+ result.applicability = consumerApplicability(pkg.manifest);
13899
14008
  if (result.diagnostics.some((item) => item.severity === "error")) return;
14009
+ if (result.applicability.status === "not-applicable") return;
13900
14010
  const checkTypes = entries.length > 0 && result.files.some((file) => /\.d\.[cm]?ts$/u.test(file));
13901
14011
  const closure = consumerRuntimeClosure([pkg.manifest], packages.map((item) => item.manifest), options.expectedWorkspaceLocators);
13902
14012
  const dependencies = {
@@ -14649,6 +14759,78 @@ async function assertSnapshotAuthorization(options) {
14649
14759
  } else if (!["schedule", "workflow_dispatch"].includes(env["GITHUB_EVENT_NAME"] ?? "")) throw new Error("Nightly snapshot publication requires a schedule or workflow_dispatch event.");
14650
14760
  }
14651
14761
  //#endregion
14762
+ //#region src/commands/release/snapshot/source/paths.ts
14763
+ /** 产物和 Git tree 使用逻辑路径;只在文件系统边界转换分隔符。 */
14764
+ function sourceRelativePath(value) {
14765
+ if (typeof value !== "string" || !value || path$1.posix.isAbsolute(value) || path$1.win32.isAbsolute(value) || /[\\:\p{Cc}]/u.test(value) || value.split("/").some((part) => !part || part === "." || part === ".." || [".git", "node_modules"].includes(part.toLowerCase()))) throw new Error("Snapshot source paths must be canonical relative paths without Git or node_modules components.");
14766
+ return value;
14767
+ }
14768
+ function sourcePath(directory, relative) {
14769
+ return path$1.join(directory, ...sourceRelativePath(relative).split("/"));
14770
+ }
14771
+ //#endregion
14772
+ //#region src/commands/release/snapshot/source/references.ts
14773
+ function snapshotSourceEvidence(options) {
14774
+ const allowed = options.referenceGitlinks ?? [];
14775
+ if (!Array.isArray(allowed)) throw new TypeError("Snapshot referenceGitlinks must be an explicit array of Git tree paths.");
14776
+ const expected = new Set(allowed.map(sourceRelativePath));
14777
+ if (expected.size !== allowed.length) throw new Error("Snapshot referenceGitlinks contains duplicate paths.");
14778
+ const tree = snapshotCommand("git", ["rev-parse", `${options.identity.commit}^{tree}`], options);
14779
+ if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(tree)) throw new Error("Snapshot source tree identity is invalid.");
14780
+ const entries = snapshotCommand("git", [
14781
+ "ls-tree",
14782
+ "-rz",
14783
+ "--full-tree",
14784
+ options.identity.commit
14785
+ ], options);
14786
+ const referenceGitlinks = [];
14787
+ for (const entry of entries.split("\0").filter(Boolean)) {
14788
+ const match = /^(\d{6}) (\w+) ([a-f0-9]{40}|[a-f0-9]{64})\t([\s\S]+)$/u.exec(entry);
14789
+ if (!match) throw new Error("Snapshot source tree contains an invalid Git entry.");
14790
+ if (match[1] !== "160000") continue;
14791
+ const relative = sourceRelativePath(match[4]);
14792
+ if (match[2] !== "commit" || !expected.delete(relative)) throw new Error(`Snapshot source archives do not support Git submodules unless explicitly listed in referenceGitlinks: ${relative}`);
14793
+ referenceGitlinks.push({
14794
+ path: relative,
14795
+ commit: match[3]
14796
+ });
14797
+ }
14798
+ if (expected.size) throw new Error(`Snapshot referenceGitlinks must name actual Git gitlinks: ${[...expected].join(", ")}`);
14799
+ return {
14800
+ tree,
14801
+ referenceGitlinks
14802
+ };
14803
+ }
14804
+ function assertReferenceDependencies(source, paths, references) {
14805
+ for (const reference of references) {
14806
+ const root = sourcePath(source, reference.path);
14807
+ if (paths.some((target) => {
14808
+ const relative = path$1.relative(root, path$1.resolve(target));
14809
+ return relative === "" || relative !== ".." && !relative.startsWith(`..${path$1.sep}`) && !path$1.isAbsolute(relative);
14810
+ })) throw new Error(`Snapshot workspace packages and local dependencies cannot use omitted reference gitlink: ${reference.path}`);
14811
+ }
14812
+ }
14813
+ async function assertOmittedReferences(source, references) {
14814
+ for (const reference of references) {
14815
+ const target = sourcePath(source, reference.path);
14816
+ try {
14817
+ if (!(await lstat(target)).isDirectory() || (await readdir(target)).length) throw new Error(`Snapshot reference gitlink must remain an empty omitted directory: ${reference.path}`);
14818
+ } catch (error) {
14819
+ if (error.code !== "ENOENT") throw error;
14820
+ }
14821
+ }
14822
+ }
14823
+ function assertSnapshotEvidence(report, options) {
14824
+ const evidence = snapshotSourceEvidence({
14825
+ ...options,
14826
+ cwd: report.source
14827
+ });
14828
+ if (report.sourceTree !== void 0 && report.sourceTree !== evidence.tree || report.referenceGitlinks !== void 0 && JSON.stringify(report.referenceGitlinks) !== JSON.stringify(evidence.referenceGitlinks)) throw new Error("Snapshot source tree or reference gitlinks changed after planning.");
14829
+ report.sourceTree = evidence.tree;
14830
+ report.referenceGitlinks = evidence.referenceGitlinks;
14831
+ return evidence;
14832
+ }
14833
+ //#endregion
14652
14834
  //#region src/commands/release/snapshot/plan.ts
14653
14835
  /** Reuse pnpm's version explanations, while snapshotting every public package together. */
14654
14836
  async function createSnapshotPlan(options) {
@@ -14660,11 +14842,10 @@ async function createSnapshotPlan(options) {
14660
14842
  "[::1]"
14661
14843
  ].includes(registry.hostname))) throw new Error("Snapshot registry must use HTTPS (HTTP is only allowed for a local test registry), without URL credentials, queries or fragments.");
14662
14844
  const source = await realpath(assertSnapshotSource(options));
14663
- const nativePlan = await createNativeReleasePlan({
14845
+ const evidence = snapshotSourceEvidence({
14664
14846
  ...options,
14665
14847
  cwd: source
14666
14848
  });
14667
- if (nativePlan.status === "blocked") throw new Error(`Snapshot native release plan is blocked: ${nativePlan.blockers.map((item) => `${item.id}: ${item.detail}`).join("; ")}`);
14668
14849
  clearWorkspaceCache();
14669
14850
  const workspace = await getWorkspaceData(source, {
14670
14851
  ignorePrivatePackage: false,
@@ -14673,7 +14854,9 @@ async function createSnapshotPlan(options) {
14673
14854
  if (parse$1(await readFile(path$1.join(source, "pnpm-workspace.yaml"), "utf8")).packages?.some((pattern) => path$1.isAbsolute(pattern.replace(/^!/, "")) || pattern.split(/[\\/]/).includes(".."))) throw new Error("Snapshot workspace patterns must stay inside the source repository.");
14674
14855
  const seen = /* @__PURE__ */ new Set();
14675
14856
  for (const pkg of workspace.packages) {
14676
- if ([pkg.rootDir, ...dependencyReferences(pkg.manifest, pkg.rootDir, true).flatMap((ref) => ref.directory ? [ref.directory] : [])].some((target) => {
14857
+ const paths = [pkg.rootDir, ...dependencyReferences(pkg.manifest, pkg.rootDir, true).flatMap((ref) => ref.directory ? [ref.directory] : [])];
14858
+ assertReferenceDependencies(source, paths, evidence.referenceGitlinks);
14859
+ if (paths.some((target) => {
14677
14860
  const relative = path$1.relative(source, path$1.resolve(target));
14678
14861
  return relative === ".." || relative.startsWith(`..${path$1.sep}`) || path$1.isAbsolute(relative);
14679
14862
  })) throw new Error("Snapshot packages and local dependencies must stay inside the source repository.");
@@ -14682,6 +14865,11 @@ async function createSnapshotPlan(options) {
14682
14865
  seen.add(pkg.manifest.name);
14683
14866
  }
14684
14867
  }
14868
+ const nativePlan = await createNativeReleasePlan({
14869
+ ...options,
14870
+ cwd: source
14871
+ });
14872
+ if (nativePlan.status === "blocked") throw new Error(`Snapshot native release plan is blocked: ${nativePlan.blockers.map((item) => `${item.id}: ${item.detail}`).join("; ")}`);
14685
14873
  const packages = workspace.packages.filter((pkg) => pkg.manifest.private !== true).map((pkg) => {
14686
14874
  const name = pkg.manifest.name;
14687
14875
  const planned = nativePlan.packages.find((item) => item.name === name);
@@ -14712,6 +14900,8 @@ async function createSnapshotPlan(options) {
14712
14900
  identity,
14713
14901
  identityKey: key,
14714
14902
  source,
14903
+ sourceTree: evidence.tree,
14904
+ referenceGitlinks: evidence.referenceGitlinks,
14715
14905
  tag,
14716
14906
  registry: registry.href,
14717
14907
  status: "planned",
@@ -14725,6 +14915,21 @@ async function createSnapshotPlan(options) {
14725
14915
  };
14726
14916
  }
14727
14917
  //#endregion
14918
+ //#region src/commands/release/snapshot/source/archive.ts
14919
+ /** 最终归档中出现的外部输入必须保留回执字节,防止 pack 生命周期临时替换后还原。 */
14920
+ function assertPreparedArchive(entries, pkg, report) {
14921
+ if (!report.preparation) return;
14922
+ const packed = new Map(entries.map((entry) => [entry.path.replace(/\/$/u, ""), entry]));
14923
+ const root = path$1.resolve(report.source, pkg.directory);
14924
+ for (const expected of report.preparation.files) {
14925
+ const relative = path$1.relative(root, sourcePath(report.source, expected.path));
14926
+ if (!relative || relative === ".." || relative.startsWith(`..${path$1.sep}`) || path$1.isAbsolute(relative)) continue;
14927
+ const archivePath = ["package", ...relative.split(path$1.sep)].join("/");
14928
+ const entry = packed.get(archivePath);
14929
+ if (entry && (entry.type !== "File" || createHash("sha256").update(entry.data).digest("hex") !== expected.sha256)) throw new Error(`Snapshot prepared artifact changed during build or pack: ${expected.path} in tarball ${pkg.name}.`);
14930
+ }
14931
+ }
14932
+ //#endregion
14728
14933
  //#region src/commands/release/snapshot/archive/index.ts
14729
14934
  /** Read without extracting archive paths or following links on the filesystem. */
14730
14935
  async function readSnapshotArchive(bytes) {
@@ -14786,6 +14991,7 @@ function writeSnapshotArchive(entries) {
14786
14991
  async function finalizeSnapshotTarball(bytes, pkg, report, target, references) {
14787
14992
  if (target.provider === "pkg-pr-new" && !/^[\w.-]+\/[\w.-]+$/.test(target.repository)) throw new Error("Snapshot pkg.pr.new target requires an owner/repository identity.");
14788
14993
  const entries = await readSnapshotArchive(bytes);
14994
+ assertPreparedArchive(entries, pkg, report);
14789
14995
  const entry = entries.find((item) => item.path === "package/package.json");
14790
14996
  if (!entry || entry.type !== "File") throw new Error(`Snapshot tarball has no package/package.json: ${pkg.name}.`);
14791
14997
  const manifest = JSON.parse(entry.data.toString("utf8"));
@@ -14907,14 +15113,7 @@ async function isolateSnapshot(report, options) {
14907
15113
  report.outputDirectory = directory;
14908
15114
  const source = path$1.join(directory, "source");
14909
15115
  await mkdir(source);
14910
- if (/^160000 /m.test(snapshotCommand("git", [
14911
- "ls-tree",
14912
- "-r",
14913
- report.identity.commit
14914
- ], {
14915
- ...options,
14916
- cwd: report.source
14917
- }))) throw new Error("Snapshot source archives do not support Git submodules.");
15116
+ const evidence = assertSnapshotEvidence(report, options);
14918
15117
  const archive = path$1.join(directory, "source.tar");
14919
15118
  snapshotCommand("git", [
14920
15119
  "archive",
@@ -14934,6 +15133,7 @@ async function isolateSnapshot(report, options) {
14934
15133
  ], options);
14935
15134
  await rm(archive);
14936
15135
  await rejectLinks(source);
15136
+ await assertOmittedReferences(source, evidence.referenceGitlinks);
14937
15137
  snapshotCommand("pnpm", [
14938
15138
  ...isolatedPnpmOptions,
14939
15139
  "install",
@@ -14943,6 +15143,7 @@ async function isolateSnapshot(report, options) {
14943
15143
  cwd: source,
14944
15144
  env: isolatedSnapshotEnvironment(options, directory)
14945
15145
  });
15146
+ await assertOmittedReferences(source, evidence.referenceGitlinks);
14946
15147
  return source;
14947
15148
  }
14948
15149
  //#endregion
@@ -14992,6 +15193,85 @@ async function writeSnapshotManifests(source, report) {
14992
15193
  return references;
14993
15194
  }
14994
15195
  //#endregion
15196
+ //#region src/commands/release/snapshot/source/inventory.ts
15197
+ /** 安装依赖不属于归档源码;其余原有文件和所有新增产物均逐字节检查。 */
15198
+ async function sourceInventory(directory) {
15199
+ const files = /* @__PURE__ */ new Map();
15200
+ const visit = async (root, parts) => {
15201
+ for (const entry of await readdir(root, { withFileTypes: true })) {
15202
+ if (entry.name === "node_modules") continue;
15203
+ const relative = [...parts, entry.name];
15204
+ const target = path$1.join(root, entry.name);
15205
+ const stat = await lstat(target);
15206
+ if (stat.isSymbolicLink() || !stat.isDirectory() && !stat.isFile() || entry.name.toLowerCase() === ".git") throw new Error(`Snapshot source preparation cannot create links, Git metadata or special files: ${relative.join("/")}`);
15207
+ if (stat.isDirectory()) await visit(target, relative);
15208
+ else files.set(relative.join("/"), {
15209
+ sha256: createHash("sha256").update(await readFile(target)).digest("hex"),
15210
+ mode: stat.mode & 511
15211
+ });
15212
+ }
15213
+ };
15214
+ await visit(directory, []);
15215
+ return files;
15216
+ }
15217
+ //#endregion
15218
+ //#region src/commands/release/snapshot/source/prepare.ts
15219
+ function preparationContext(directory, report) {
15220
+ if (!report.sourceTree) throw new Error("Snapshot source preparation requires verified Git tree evidence.");
15221
+ return Object.freeze({
15222
+ directory,
15223
+ identity: Object.freeze({ ...report.identity }),
15224
+ tree: report.sourceTree,
15225
+ packages: Object.freeze(report.packages.map(({ name, directory, currentVersion, version }) => Object.freeze({
15226
+ name,
15227
+ directory,
15228
+ currentVersion,
15229
+ version
15230
+ }))),
15231
+ referenceGitlinks: Object.freeze((report.referenceGitlinks ?? []).map((reference) => Object.freeze({ ...reference })))
15232
+ });
15233
+ }
15234
+ /** 回调与构建脚本具有相同信任级别;receipt 验证产物契约,不提供代码沙箱。 */
15235
+ async function prepareSnapshotSource(directory, report, options) {
15236
+ delete report.preparation;
15237
+ if (!options.prepareSource) return;
15238
+ if (typeof options.prepareSource !== "function") throw new TypeError("Snapshot prepareSource must be a programmatic function.");
15239
+ const before = await sourceInventory(directory);
15240
+ const result = await options.prepareSource(preparationContext(directory, report));
15241
+ if (!result || typeof result !== "object" || !Array.isArray(result.files) || Object.keys(result).some((key) => !["files", "metadata"].includes(key))) throw new TypeError("Snapshot prepareSource must return a complete files receipt.");
15242
+ const declared = /* @__PURE__ */ new Map();
15243
+ for (const file of result.files) {
15244
+ const relative = sourceRelativePath(file?.path);
15245
+ if (!file || Object.keys(file).some((key) => !["path", "sha256"].includes(key)) || !/^[a-f0-9]{64}$/u.test(file.sha256) || declared.has(relative) || before.has(relative)) throw new Error(`Snapshot preparation receipt contains an invalid, duplicate or existing artifact: ${relative}`);
15246
+ declared.set(relative, file.sha256);
15247
+ }
15248
+ if (result.metadata !== void 0 && (!result.metadata || typeof result.metadata !== "object" || Array.isArray(result.metadata) || Object.values(result.metadata).some((value) => typeof value !== "string"))) throw new TypeError("Snapshot preparation metadata must contain only string values.");
15249
+ const after = await sourceInventory(directory);
15250
+ for (const [relative, original] of before) {
15251
+ const actual = after.get(relative);
15252
+ if (!actual || actual.sha256 !== original.sha256 || actual.mode !== original.mode) throw new Error(`Snapshot source preparation changed an existing source file: ${relative}`);
15253
+ }
15254
+ for (const [relative, actual] of after) if (!before.has(relative) && declared.get(relative) !== actual.sha256) throw new Error(`Snapshot source preparation has an undeclared or mismatched artifact: ${relative}`);
15255
+ for (const relative of declared.keys()) if (!after.has(relative)) throw new Error(`Snapshot preparation receipt names a missing artifact: ${relative}`);
15256
+ await assertOmittedReferences(directory, report.referenceGitlinks ?? []);
15257
+ report.preparation = {
15258
+ commit: report.identity.commit,
15259
+ tree: report.sourceTree,
15260
+ files: [...declared].sort(([left], [right]) => left.localeCompare(right)).map(([path, sha256]) => ({
15261
+ path,
15262
+ sha256
15263
+ })),
15264
+ ...result.metadata ? { metadata: { ...result.metadata } } : {}
15265
+ };
15266
+ }
15267
+ /** 构建或打包生命周期不得替换已经核验的外部输入。 */
15268
+ async function assertPreparedArtifacts(directory, report) {
15269
+ await assertOmittedReferences(directory, report.referenceGitlinks ?? []);
15270
+ if (!report.preparation) return;
15271
+ const files = await sourceInventory(directory);
15272
+ for (const expected of report.preparation.files) if (files.get(expected.path)?.sha256 !== expected.sha256) throw new Error(`Snapshot prepared artifact changed during build or pack: ${expected.path}`);
15273
+ }
15274
+ //#endregion
14995
15275
  //#region src/commands/release/snapshot/prepare.ts
14996
15276
  async function checkpointSnapshot(report) {
14997
15277
  if (report.outputDirectory) {
@@ -15006,10 +15286,13 @@ async function prepareNightlySnapshot(report, options, target) {
15006
15286
  const source = await isolateSnapshot(report, options);
15007
15287
  await checkpointSnapshot(report);
15008
15288
  const references = await writeSnapshotManifests(source, report);
15289
+ await prepareSnapshotSource(source, report, options);
15290
+ await checkpointSnapshot(report);
15009
15291
  await prepareSnapshotArtifacts(source, report, {
15010
15292
  ...options,
15011
15293
  env: isolatedSnapshotEnvironment(options, report.outputDirectory)
15012
15294
  }, target, references);
15295
+ await assertPreparedArtifacts(source, report);
15013
15296
  await checkpointSnapshot(report);
15014
15297
  } catch (error) {
15015
15298
  report.status = "failed";
@@ -15369,13 +15652,20 @@ async function verifyNightlyConsumer(report, options) {
15369
15652
  const pin = /^pnpm@(\d+\.\d+\.\d+)(?:\+sha\d+\.[a-f0-9]+)?$/u.exec(source.packageManager ?? "");
15370
15653
  if (!pin) throw new Error("Nightly consumer requires an exact pnpm packageManager pin.");
15371
15654
  const manifests = await nightlyConsumerManifests(report);
15655
+ result.applicability = consumerPackageApplicability(manifests);
15656
+ const applicable = new Set(result.applicability.filter((item) => item.status === "applicable").map((item) => item.name));
15657
+ const packages = report.packages.filter((pkg) => applicable.has(pkg.name));
15658
+ const closure = consumerRuntimeClosure(manifests.filter((manifest) => applicable.has(String(manifest.name))), manifests);
15659
+ if (!packages.length) {
15660
+ result.status = "verified";
15661
+ return;
15662
+ }
15372
15663
  await mkdir(report.outputDirectory, { recursive: true });
15373
15664
  directory = await realpath(await mkdtemp(path$1.join(report.outputDirectory, "consumer-")));
15374
- const checkTypes = report.snapshot.checks?.some((check) => check.files.some((file) => /\.d\.[cm]?ts$/u.test(file)));
15375
- const closure = consumerRuntimeClosure(manifests, manifests);
15665
+ const checkTypes = report.snapshot.checks?.some((check) => applicable.has(check.name) && check.files.some((file) => /\.d\.[cm]?ts$/u.test(file)));
15376
15666
  const dependencies = {
15377
- ...consumerOptionalPeers(closure, new Map(report.packages.map((pkg) => [pkg.name, report.provider === "npm" ? `npm:${pkg.name}@snapshot-nightly` : pkg.locator]))),
15378
- ...Object.fromEntries(report.packages.map((pkg) => [pkg.name, report.provider === "npm" ? "snapshot-nightly" : pkg.locator]))
15667
+ ...consumerOptionalPeers(closure, new Map(packages.map((pkg) => [pkg.name, report.provider === "npm" ? `npm:${pkg.name}@snapshot-nightly` : pkg.locator]))),
15668
+ ...Object.fromEntries(packages.map((pkg) => [pkg.name, report.provider === "npm" ? "snapshot-nightly" : pkg.locator]))
15379
15669
  };
15380
15670
  const tooling = checkTypes ? await consumerTypeToolchain(options.cwd, dependencies, closure) : void 0;
15381
15671
  const manifest = {
@@ -15408,7 +15698,7 @@ async function verifyNightlyConsumer(report, options) {
15408
15698
  await installNightlyConsumer(report, options, directory, run);
15409
15699
  const toolchain = tooling ? await installedConsumerTypeToolchain(directory, tooling) : void 0;
15410
15700
  const validated = [];
15411
- for (const pkg of report.packages) {
15701
+ for (const pkg of packages) {
15412
15702
  const installed = await realpath(path$1.join(directory, "node_modules", pkg.name));
15413
15703
  const relative = path$1.relative(directory, installed);
15414
15704
  if (!relative || relative === ".." || relative.startsWith(`..${path$1.sep}`) || path$1.isAbsolute(relative)) throw new Error(`Nightly consumer resolved ${pkg.name} outside its isolated directory.`);
@@ -16330,11 +16620,12 @@ function snapshotPublicationReport(manifest, directory) {
16330
16620
  //#endregion
16331
16621
  //#region src/commands/release/snapshot/prepared/consumer/installed.ts
16332
16622
  /** Validate the entire installed batch before any candidate entrypoint can run. */
16333
- async function installedSnapshotPackages(manifest, directory) {
16623
+ async function installedSnapshotPackages(manifest, directory, applicable) {
16334
16624
  const packages = object$1(object$1(parse$1(await readFile(path$1.join(directory, "pnpm-lock.yaml"), "utf8")))["packages"]);
16335
16625
  const snapshot = snapshotPublicationReport(manifest, directory);
16336
16626
  const validated = [];
16337
16627
  for (const pkg of manifest.packages) {
16628
+ if (applicable && !applicable.has(pkg.name)) continue;
16338
16629
  if (object$1(object$1(packages[`${pkg.name}@${pkg.version}`])["resolution"])["integrity"] !== pkg.integrity) throw new Error(`Snapshot consumer installation did not retain the verified integrity for ${pkg.name}.`);
16339
16630
  const installed = await realpath(path$1.join(directory, "node_modules", pkg.name));
16340
16631
  const relative = path$1.relative(directory, installed);
@@ -16367,14 +16658,21 @@ async function verifyPreparedSnapshotConsumer(options) {
16367
16658
  try {
16368
16659
  const budget = snapshotConsumerBudget(options);
16369
16660
  const manifests = await publishedSnapshotManifests(manifest, options, budget);
16661
+ result.applicability = consumerPackageApplicability(manifests);
16662
+ const applicable = new Set(result.applicability.filter((item) => item.status === "applicable").map((item) => item.name));
16663
+ const packages = manifest.packages.filter((pkg) => applicable.has(pkg.name));
16664
+ const closure = consumerRuntimeClosure(manifests.filter((pkg) => applicable.has(String(pkg.name))), manifests);
16665
+ if (!packages.length) {
16666
+ result.status = "verified";
16667
+ return result;
16668
+ }
16370
16669
  directory = await realpath(await mkdtemp(path$1.join(path$1.resolve(options.outputDirectory), "snapshot-consumer-")));
16371
16670
  const clean = consumerEnvironment(options.env ?? process.env, directory);
16372
16671
  const run = consumerRunner(result, {
16373
16672
  ...options,
16374
16673
  cwd: directory
16375
16674
  }, directory, clean);
16376
- const closure = consumerRuntimeClosure(manifests, manifests);
16377
- const exact = Object.fromEntries(manifest.packages.map((pkg) => [pkg.name, pkg.version]));
16675
+ const exact = Object.fromEntries(packages.map((pkg) => [pkg.name, pkg.version]));
16378
16676
  const dependencies = await resolveConsumerPeerAliases({
16379
16677
  ...consumerOptionalPeers(closure, new Map(Object.entries(exact).map(([name, version]) => [name, `npm:${name}@${version}`]))),
16380
16678
  ...exact
@@ -16385,7 +16683,7 @@ async function verifyPreparedSnapshotConsumer(options) {
16385
16683
  "version",
16386
16684
  "--json"
16387
16685
  ]));
16388
- const toolchain = manifest.checks.packages.some((check) => check.files.some((file) => /\.d\.[cm]?ts$/u.test(file))) ? await consumerTypeToolchain(directory, dependencies, closure) : void 0;
16686
+ const toolchain = manifest.checks.packages.some((check) => applicable.has(check.name) && check.files.some((file) => /\.d\.[cm]?ts$/u.test(file))) ? await consumerTypeToolchain(directory, dependencies, closure) : void 0;
16389
16687
  await Promise.all([
16390
16688
  writeFile(path$1.join(directory, "package.json"), `${JSON.stringify({
16391
16689
  name: "repoctl-snapshot-consumer",
@@ -16405,11 +16703,12 @@ async function verifyPreparedSnapshotConsumer(options) {
16405
16703
  const expectedPnpm = /^pnpm@([^+]+)/u.exec(manifest.plan.packageManager)[1];
16406
16704
  if (await run("pnpm", [...consumerPnpmOptions, "--version"]) !== expectedPnpm) throw new Error(`Snapshot consumer requires pnpm ${expectedPnpm}.`);
16407
16705
  await installPreparedSnapshotConsumer(manifest, directory, run, budget);
16408
- const installedPackages = await installedSnapshotPackages(manifest, directory);
16706
+ const installedPackages = await installedSnapshotPackages(manifest, directory, applicable);
16409
16707
  const compiler = toolchain ? await installedConsumerTypeToolchain(directory, toolchain) : void 0;
16410
- for (const [index, pkg] of manifest.packages.entries()) {
16708
+ for (const [index, pkg] of packages.entries()) {
16411
16709
  const { packed, installed } = installedPackages[index];
16412
- await checkInstalledEntries(packed, manifest.checks.packages[index].files, installed, directory, run, index, compiler);
16710
+ const files = manifest.checks.packages.find((check) => check.name === pkg.name).files;
16711
+ await checkInstalledEntries(packed, files, installed, directory, run, index, compiler);
16413
16712
  result.packages.push({
16414
16713
  name: pkg.name,
16415
16714
  version: pkg.version
@@ -16428,8 +16727,8 @@ async function verifyPreparedSnapshotConsumer(options) {
16428
16727
  result.status = "failed";
16429
16728
  result.error = `Snapshot consumer cleanup failed: ${error instanceof Error ? error.message : String(error)}`;
16430
16729
  }
16730
+ await writeFile(path$1.join(options.outputDirectory, "consumer-report.json"), `${JSON.stringify(result, null, 2)}\n`);
16431
16731
  }
16432
- await writeFile(path$1.join(options.outputDirectory, "consumer-report.json"), `${JSON.stringify(result, null, 2)}\n`);
16433
16732
  return result;
16434
16733
  }
16435
16734
  //#endregion
@@ -16737,6 +17036,7 @@ async function verifySnapshotRun(options) {
16737
17036
  //#region src/commands/release/snapshot/prepared/plan.ts
16738
17037
  /** Freeze the existing version solver and workspace graph without installing or building candidates. */
16739
17038
  async function createSnapshotBuildPlan(options) {
17039
+ if ("referenceGitlinks" in options || "prepareSource" in options) throw new Error("Prepared snapshots do not accept source preparation extensions outside the frozen plan.");
16740
17040
  const source = validateSnapshotSource(options.source);
16741
17041
  if (/^(?:120000|160000) /m.test(snapshotCommand("git", [
16742
17042
  "ls-tree",
@@ -16812,6 +17112,7 @@ async function createSnapshotBuildPlan(options) {
16812
17112
  //#region src/commands/release/snapshot/prepared/prepare.ts
16813
17113
  /** Build on an unprivileged runner; emit a portable bundle separate from retained diagnostics. */
16814
17114
  async function prepareSnapshot(options) {
17115
+ if ("referenceGitlinks" in options || "prepareSource" in options) throw new Error("Prepared snapshots do not accept source preparation extensions outside the frozen plan.");
16815
17116
  const env = options.env ?? process.env;
16816
17117
  if ([
16817
17118
  "ACTIONS_ID_TOKEN_REQUEST_TOKEN",