@mnci/cli 4.40.6 → 4.40.8

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
@@ -4464,6 +4464,28 @@ function setGoModulePath(workspaceRoot, projectDir) {
4464
4464
  const rewritten = (0, import_node_fs18.readFileSync)(goModPath, "utf8").replace(/^module\s+\S+/m, () => `module ${prefix}/${projectDir}`);
4465
4465
  writeFileEnsured(goModPath, rewritten);
4466
4466
  }
4467
+ var GO_DIRECTIVE_CEILING = "1.24";
4468
+ function exceedsGoCeiling(version) {
4469
+ const [major, minor] = version.split(".").map(Number);
4470
+ const [ceilingMajor, ceilingMinor] = GO_DIRECTIVE_CEILING.split(".").map(Number);
4471
+ return major > ceilingMajor || major === ceilingMajor && minor > ceilingMinor;
4472
+ }
4473
+ function clampGoDirective(filePath) {
4474
+ if (!fileExists(filePath)) {
4475
+ return;
4476
+ }
4477
+ const before = (0, import_node_fs18.readFileSync)(filePath, "utf8");
4478
+ const directive = /^go\s+(\d+\.\d+(?:\.\d+)?)/m.exec(before);
4479
+ if (directive === null || !exceedsGoCeiling(directive[1])) {
4480
+ return;
4481
+ }
4482
+ const after = before.replace(/^go\s+\d+\.\d+(?:\.\d+)?/m, () => `go ${GO_DIRECTIVE_CEILING}`).replace(/^toolchain\s+\S+(?:\r?\n){1,2}/m, "");
4483
+ writeFileEnsured(filePath, after);
4484
+ }
4485
+ function pinGoDirective(workspaceRoot, projectDir) {
4486
+ clampGoDirective((0, import_node_path17.join)(workspaceRoot, projectDir, "go.mod"));
4487
+ clampGoDirective((0, import_node_path17.join)(workspaceRoot, "go.work"));
4488
+ }
4467
4489
  function writeGoAppExample(workspaceRoot, projectDir) {
4468
4490
  const goModPath = (0, import_node_path17.join)(workspaceRoot, projectDir, "go.mod");
4469
4491
  const modulePath = fileExists(goModPath) ? /^module\s+(\S+)/m.exec((0, import_node_fs18.readFileSync)(goModPath, "utf8"))?.[1] : void 0;
@@ -4654,6 +4676,7 @@ function addGoApp(workspaceRoot, name, options = {}) {
4654
4676
  workspaceRoot
4655
4677
  );
4656
4678
  setGoModulePath(workspaceRoot, `apps/${name}`);
4679
+ pinGoDirective(workspaceRoot, `apps/${name}`);
4657
4680
  if (options.web === void 0) {
4658
4681
  writeGoAppExample(workspaceRoot, `apps/${name}`);
4659
4682
  }
@@ -4696,6 +4719,7 @@ function addGoFunctionApp(workspaceRoot, name) {
4696
4719
  workspaceRoot
4697
4720
  );
4698
4721
  setGoModulePath(workspaceRoot, `apps/${name}`);
4722
+ pinGoDirective(workspaceRoot, `apps/${name}`);
4699
4723
  writeGoAppExample(workspaceRoot, `apps/${name}`);
4700
4724
  addProjectJsonTargets((0, import_node_path17.join)(workspaceRoot, "apps", name, "project.json"), {
4701
4725
  "build": goBuildTarget(name),
@@ -4721,6 +4745,7 @@ function addGoLib(workspaceRoot, name) {
4721
4745
  workspaceRoot
4722
4746
  );
4723
4747
  setGoModulePath(workspaceRoot, `packages/${name}`);
4748
+ pinGoDirective(workspaceRoot, `packages/${name}`);
4724
4749
  addProjectJsonTargets((0, import_node_path17.join)(workspaceRoot, "packages", name, "project.json"), {
4725
4750
  test: goTestTarget(),
4726
4751
  lint: goLintTarget()
@@ -4746,6 +4771,7 @@ function addGoInternalLib(workspaceRoot, name) {
4746
4771
  workspaceRoot
4747
4772
  );
4748
4773
  setGoModulePath(workspaceRoot, `libs/${name}`);
4774
+ pinGoDirective(workspaceRoot, `libs/${name}`);
4749
4775
  addProjectJsonTargets((0, import_node_path17.join)(workspaceRoot, "libs", name, "project.json"), {
4750
4776
  test: goTestTarget(),
4751
4777
  lint: goLintTarget()
@@ -5948,6 +5974,7 @@ async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
5948
5974
  publishableManifest,
5949
5975
  () => {
5950
5976
  markPublic(publishableManifest);
5977
+ dropNxProjectName(publishableManifest);
5951
5978
  repairPublishableManifest(publishableManifest);
5952
5979
  repairDeclarationSpecifiers(projectRoot);
5953
5980
  writeProjectReadme(projectRoot, `${scope}/${name}`, stack.testRunner);
@@ -5962,6 +5989,15 @@ async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
5962
5989
  }
5963
5990
  );
5964
5991
  }
5992
+ function dropNxProjectName(manifestPath) {
5993
+ const manifest = readJson(manifestPath);
5994
+ if (manifest.nx?.name === void 0) {
5995
+ return;
5996
+ }
5997
+ const { name: _projectName, ...nx } = manifest.nx;
5998
+ const { nx: _nx, ...rest } = manifest;
5999
+ writeFileEnsured(manifestPath, toJson(Object.keys(nx).length > 0 ? { ...rest, nx } : rest));
6000
+ }
5965
6001
  function addReactInternalLib(workspaceRoot, name, stack, empty = false) {
5966
6002
  ensurePlugin(workspaceRoot, "@nx/react");
5967
6003
  const projectRoot = (0, import_node_path27.join)(workspaceRoot, "libs", name);