@mnci/cli 4.8.0 → 4.8.2

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
@@ -440,8 +440,26 @@ function withPythonGraphPlugin(nxJson, pluginInstalled) {
440
440
  }
441
441
  return { ...nxJson, plugins: [...plugins, PYTHON_GRAPH_PLUGIN] };
442
442
  }
443
+ function isMergeableObject(value) {
444
+ return typeof value === "object" && value !== null && !Array.isArray(value);
445
+ }
446
+ function preservingUnknownKeys(existing, owned) {
447
+ if (!isMergeableObject(existing)) {
448
+ return owned;
449
+ }
450
+ const merged = { ...existing };
451
+ for (const [key, value] of Object.entries(owned)) {
452
+ const previous = merged[key];
453
+ merged[key] = isMergeableObject(value) && isMergeableObject(previous) ? preservingUnknownKeys(previous, value) : value;
454
+ }
455
+ return merged;
456
+ }
443
457
  function withReleaseConfig(nxJson, ci) {
444
- return { ...nxJson, defaultBase: "main", release: releaseConfig(ci) };
458
+ return {
459
+ ...nxJson,
460
+ defaultBase: "main",
461
+ release: preservingUnknownKeys(nxJson.release, releaseConfig(ci))
462
+ };
445
463
  }
446
464
  var COMMITLINT_CONFIG = `export default { extends: ['@commitlint/config-conventional'] }
447
465
  `;
@@ -944,13 +962,17 @@ function releaseGuard(pythonPublishEnv, nugetPublishEnv) {
944
962
  return String.raw`node -e "const fs=require('node:fs'),cp=require('node:child_process');const npmCount=fs.globSync('packages/*/package.json').length;const csharpCount=fs.globSync('packages/*/*.csproj').length;const pythonCount=fs.globSync('python-packages/*/pyproject.toml').length;const dartCount=fs.globSync('packages/*/pubspec.yaml').length;const hasNpm=npmCount>0;const hasPython=pythonCount>0;const hasCsharp=csharpCount>0;const hasDart=dartCount>0;if(!hasNpm&&!hasPython&&!hasCsharp&&!hasDart){console.log('Nothing to release - skipping.');process.exit(0)}const specifier=process.env.RELEASE_SPECIFIER||'';let releaseCmd='npx nx release --yes';if(specifier){if(!/^(major|minor|patch|\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?)$/.test(specifier)){console.error('RELEASE_SPECIFIER value \''+specifier+'\' is invalid - use major, minor, patch, or an exact version like 1.2.3.');process.exit(1)}const releaseProjectCount=npmCount+csharpCount+pythonCount+dartCount;if(/^(major|minor|patch)$/.test(specifier)&&releaseProjectCount>1){console.error('RELEASE_SPECIFIER is a keyword (\''+specifier+'\') but this workspace has '+releaseProjectCount+' releasable packages - a keyword under-bumps interdependent packages, because nx computes the dependency-bump pass from a stale cached version. Set RELEASE_SPECIFIER to an exact version instead, or clear it.');process.exit(1)}releaseCmd='npx nx release '+specifier+' --yes'}const env={...process.env};${pythonPublishEnv}${nugetPublishEnv}process.exit(cp.spawnSync(releaseCmd,{stdio:'inherit',shell:true,env}).status ?? 1)"`;
945
963
  }
946
964
  var PYPI_TOKEN_VARIABLE = "PYPI_TOKEN";
965
+ var AZURE_PAT_VARIABLE = "PAT";
966
+ function azurePatPreflight(countExpression, subject) {
967
+ return `if(!process.env.${AZURE_PAT_VARIABLE}){console.error('This workspace has '+${countExpression}+' ${subject} package(s) to publish to Azure Artifacts but ${AZURE_PAT_VARIABLE} is empty. Add your base64-encoded Azure DevOps PAT as a secret named ${AZURE_PAT_VARIABLE}, or remove the ${subject} packages from release.projects.');process.exit(1)}`;
968
+ }
947
969
  function pypiTokenEnvLine(registryKind, variableReference, indent) {
948
970
  return registryKind === "npm" ? `
949
971
  ${indent}${PYPI_TOKEN_VARIABLE}: ${variableReference(PYPI_TOKEN_VARIABLE)}` : "";
950
972
  }
951
973
  function pythonPublishEnvFragment(pythonPublishUrl2, registryKind) {
952
974
  if (pythonPublishUrl2 !== void 0) {
953
- return `if(hasPython){env.TWINE_REPOSITORY_URL='${pythonPublishUrl2}';env.TWINE_USERNAME='AzureArtifacts';env.TWINE_PASSWORD=Buffer.from(process.env.PAT,'base64').toString()}`;
975
+ return `if(hasPython){${azurePatPreflight("pythonCount", "Python")}env.TWINE_REPOSITORY_URL='${pythonPublishUrl2}';env.TWINE_USERNAME='AzureArtifacts';env.TWINE_PASSWORD=Buffer.from(process.env.${AZURE_PAT_VARIABLE},'base64').toString()}`;
954
976
  }
955
977
  if (registryKind !== "npm") {
956
978
  return "";
@@ -958,10 +980,10 @@ function pythonPublishEnvFragment(pythonPublishUrl2, registryKind) {
958
980
  return `if(hasPython){if(!process.env.${PYPI_TOKEN_VARIABLE}){console.error('This workspace has '+pythonCount+' Python package(s) to publish but ${PYPI_TOKEN_VARIABLE} is empty. Add a PyPI API token as a secret named ${PYPI_TOKEN_VARIABLE}, or remove the Python packages from release.projects.');process.exit(1)}env.TWINE_USERNAME='__token__';env.TWINE_PASSWORD=process.env.${PYPI_TOKEN_VARIABLE};env.TWINE_NON_INTERACTIVE='1'}`;
959
981
  }
960
982
  function nugetPublishEnvFragment(nugetFeedUrl2) {
961
- return nugetFeedUrl2 ? "if(hasCsharp){env.NUGET_PAT=Buffer.from(process.env.PAT,'base64').toString()}" : "";
983
+ return nugetFeedUrl2 ? `if(hasCsharp){${azurePatPreflight("csharpCount", "C#")}env.NUGET_PAT=Buffer.from(process.env.${AZURE_PAT_VARIABLE},'base64').toString()}` : "";
962
984
  }
963
985
  function npmAuthEnvVariable(registryKind, variableReference) {
964
- return registryKind === "npm" ? ["NODE_AUTH_TOKEN", variableReference("NPM_TOKEN")] : ["PAT", variableReference("PAT")];
986
+ return registryKind === "npm" ? ["NODE_AUTH_TOKEN", variableReference("NPM_TOKEN")] : [AZURE_PAT_VARIABLE, variableReference(AZURE_PAT_VARIABLE)];
965
987
  }
966
988
  function poolBlock(agent) {
967
989
  return /^(?:ubuntu|windows|macos)-/i.test(agent) ? ` vmImage: ${agent}` : ` name: ${agent}`;