@mnci/cli 4.40.9 → 4.41.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.
package/dist/cli.js CHANGED
@@ -7898,6 +7898,33 @@ function runKinds(options) {
7898
7898
  var import_node_child_process = require("child_process");
7899
7899
  var import_node_fs29 = require("fs");
7900
7900
  var import_node_path34 = require("path");
7901
+
7902
+ // src/workspace-diagnostics/stranded-release-tags.algorithm.ts
7903
+ function compareVersions2(left, right) {
7904
+ const a = left.split(".").map(Number);
7905
+ const b = right.split(".").map(Number);
7906
+ return a[0] - b[0] || a[1] - b[1] || a[2] - b[2] || 0;
7907
+ }
7908
+ function versionsOf(tags, name) {
7909
+ return tags.filter((tag) => tag.startsWith(`${name}@`)).map((tag) => tag.slice(name.length + 1)).filter((version) => /^\d+\.\d+\.\d+$/.test(version));
7910
+ }
7911
+ function findStrandedReleaseTags(projects, tags) {
7912
+ const stranded = [];
7913
+ for (const project of projects) {
7914
+ const unscoped = /^@[^/]+\/(.+)$/.exec(project)?.[1];
7915
+ if (unscoped === void 0) {
7916
+ continue;
7917
+ }
7918
+ const current = versionsOf(tags, project).sort(compareVersions2).at(-1);
7919
+ const newest = versionsOf(tags, unscoped).sort(compareVersions2).at(-1);
7920
+ if (newest !== void 0 && (current === void 0 || compareVersions2(newest, current) > 0)) {
7921
+ stranded.push({ project, oldTag: `${unscoped}@${newest}`, newTag: `${project}@${newest}` });
7922
+ }
7923
+ }
7924
+ return stranded;
7925
+ }
7926
+
7927
+ // src/workspace-diagnostics/check-invariants.use-case.ts
7901
7928
  var SUPPORTED_ESLINT_MAJOR = ESLINT_VERSION.replace(/^\D*/, "").split(".", 1)[0];
7902
7929
  function toPosix2(path) {
7903
7930
  return path.replaceAll("\\", "/");
@@ -8366,6 +8393,24 @@ function checkLockfileHasNoLocalRegistry(workspaceRoot) {
8366
8393
  remedy: "run `mnci upgrade`, which removes it, then commit package-lock.json"
8367
8394
  };
8368
8395
  }
8396
+ function checkReleaseTagsResolve(workspaceRoot, nxJson) {
8397
+ const pattern = nxJson.release?.releaseTag?.pattern;
8398
+ if (pattern !== void 0 && pattern !== "{projectName}@{version}") {
8399
+ return void 0;
8400
+ }
8401
+ const listed = runCapture("git", ["tag", "--list"], workspaceRoot);
8402
+ if (listed.status !== 0) {
8403
+ return void 0;
8404
+ }
8405
+ const projects = (0, import_node_fs29.globSync)("{apps,libs,packages}/*/package.json", { cwd: workspaceRoot }).map((path) => readJson((0, import_node_path34.join)(workspaceRoot, path))).filter((manifest) => manifest.private !== true && manifest.name !== void 0).map((manifest) => manifest.name);
8406
+ const stranded = findStrandedReleaseTags(projects, listed.stdout.split(/\r?\n/).filter(Boolean));
8407
+ return {
8408
+ check: "release tags resolve under each project's current name",
8409
+ ok: stranded.length === 0,
8410
+ detail: `${stranded.map((entry) => `${entry.project} has only ${entry.oldTag}`).join("; ")} - nx release finds no tag under the new name and would release from the disk version, a downgrade`,
8411
+ remedy: `on the commit of each old tag run: ${stranded.map((entry) => `git tag ${entry.newTag} ${entry.oldTag}^{commit}`).join(" ; ")} - then push the tags`
8412
+ };
8413
+ }
8369
8414
  function collectFindings(workspaceRoot) {
8370
8415
  const nxJsonPath = (0, import_node_path34.join)(workspaceRoot, "nx.json");
8371
8416
  if (!fileExists(nxJsonPath)) {
@@ -8394,7 +8439,8 @@ function collectFindings(workspaceRoot) {
8394
8439
  ...checkPipelinePhases(workspaceRoot),
8395
8440
  ...checkNativeBuildConfig(workspaceRoot),
8396
8441
  checkDependencyRangesNotPreserved(nxJson),
8397
- checkLockfileHasNoLocalRegistry(workspaceRoot)
8442
+ checkLockfileHasNoLocalRegistry(workspaceRoot),
8443
+ checkReleaseTagsResolve(workspaceRoot, nxJson)
8398
8444
  ].filter((finding) => finding !== void 0);
8399
8445
  }
8400
8446
  function runDoctor(workspaceRoot, options = {}) {