@mnci/cli 4.10.2 → 4.10.4

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
@@ -573,13 +573,9 @@ var ROOT_LINT_TARGET = {
573
573
  cwd: "."
574
574
  }
575
575
  };
576
- function reactExpressPeerOverride(manifest) {
577
- const declared = {
578
- ...manifest.dependencies,
579
- ...manifest.devDependencies
580
- };
581
- return declared.express === void 0 ? {} : { "@nx/react": { express: "$express" } };
582
- }
576
+ var NX_PEER_OVERRIDES = {
577
+ "@nx/react": { express: ">=4.0.0 <6.0.0" }
578
+ };
583
579
  var ESLINT_PEER_OVERRIDES = {
584
580
  "eslint-plugin-jsx-a11y": { eslint: "$eslint" },
585
581
  // Scoped to EACH named parent, not top-level and not `nx` alone.
@@ -1861,11 +1857,9 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
1861
1857
  ...manifest.overrides,
1862
1858
  ...ESLINT_PEER_OVERRIDES,
1863
1859
  ...SECURITY_OVERRIDES,
1864
- // Last, and conditional — see reactExpressPeerOverride. At `mnci new` there
1865
- // is no express yet, so this is a no-op; `mnci add node-app --framework
1866
- // express` is what puts express in the root manifest, and syncs the override
1867
- // itself. This line is what carries it across an `mnci upgrade`.
1868
- ...reactExpressPeerOverride(manifest)
1860
+ // Static, so it is present before any generator can run an install — see
1861
+ // NX_PEER_OVERRIDES for why the conditional form could never be.
1862
+ ...NX_PEER_OVERRIDES
1869
1863
  };
1870
1864
  const existingNx = manifest.nx;
1871
1865
  const existingTargets = withoutKey(
@@ -2093,8 +2087,22 @@ function projectTask(name, kind) {
2093
2087
  const base = { label: `${name}: ${kind}`, type: "npm", script, problemMatcher: [] };
2094
2088
  return kind === "start" ? { ...base, isBackground: true } : { ...base, group: kind };
2095
2089
  }
2090
+ function ensureNxPeerOverrides(workspaceRoot) {
2091
+ const manifestPath = (0, import_node_path3.join)(workspaceRoot, "package.json");
2092
+ if (!(0, import_node_fs3.existsSync)(manifestPath)) {
2093
+ return;
2094
+ }
2095
+ const manifest = readJson(manifestPath);
2096
+ const existing = manifest.overrides ?? {};
2097
+ const overrides = { ...existing, ...NX_PEER_OVERRIDES };
2098
+ if (JSON.stringify(existing) === JSON.stringify(overrides)) {
2099
+ return;
2100
+ }
2101
+ writeFileEnsured(manifestPath, toJson({ ...manifest, overrides }));
2102
+ }
2096
2103
  function registerProjectCommands(workspaceRoot, name, commands) {
2097
2104
  removeStaleGitkeeps(workspaceRoot);
2105
+ ensurePythonArtefactsIgnored(workspaceRoot);
2098
2106
  const scripts = {
2099
2107
  [`${name}:qa`]: `nx run ${name}:lint && nx run ${name}:test`
2100
2108
  };
@@ -2111,16 +2119,11 @@ function registerProjectCommands(workspaceRoot, name, commands) {
2111
2119
  const manifestPath = (0, import_node_path3.join)(workspaceRoot, "package.json");
2112
2120
  const manifest = readJson(manifestPath);
2113
2121
  const existingScripts = manifest.scripts ?? {};
2114
- const overrides = {
2115
- ...manifest.overrides,
2116
- ...reactExpressPeerOverride(manifest)
2117
- };
2118
2122
  writeFileEnsured(
2119
2123
  manifestPath,
2120
2124
  toJson({
2121
2125
  ...manifest,
2122
- scripts: { ...existingScripts, ...scripts },
2123
- ...Object.keys(overrides).length > 0 && { overrides }
2126
+ scripts: { ...existingScripts, ...scripts }
2124
2127
  })
2125
2128
  );
2126
2129
  const codeWorkspacePath = findCodeWorkspaceFile(workspaceRoot);
@@ -2712,6 +2715,46 @@ function runNodeApp(workspaceRoot, name, stack, framework) {
2712
2715
  ],
2713
2716
  workspaceRoot
2714
2717
  );
2718
+ const appRoot = (0, import_node_path7.join)(workspaceRoot, "apps", name);
2719
+ separateDeclarationOutput(appRoot);
2720
+ repairAssetMapping(appRoot, name);
2721
+ }
2722
+ function separateDeclarationOutput(appRoot) {
2723
+ const tsconfigPath = (0, import_node_path7.join)(appRoot, "tsconfig.app.json");
2724
+ if (!fileExists(tsconfigPath)) {
2725
+ return;
2726
+ }
2727
+ const tsconfig = readJson(tsconfigPath);
2728
+ const compilerOptions = tsconfig.compilerOptions ?? {};
2729
+ if (compilerOptions.outDir !== "dist") {
2730
+ return;
2731
+ }
2732
+ writeFileEnsured(
2733
+ tsconfigPath,
2734
+ toJson({
2735
+ ...tsconfig,
2736
+ compilerOptions: {
2737
+ ...compilerOptions,
2738
+ outDir: "out-tsc/app",
2739
+ tsBuildInfoFile: "out-tsc/app/tsconfig.app.tsbuildinfo"
2740
+ }
2741
+ })
2742
+ );
2743
+ }
2744
+ function repairAssetMapping(appRoot, name) {
2745
+ const manifestPath = (0, import_node_path7.join)(appRoot, "package.json");
2746
+ if (!fileExists(manifestPath)) {
2747
+ return;
2748
+ }
2749
+ const manifest = readJson(manifestPath);
2750
+ const options = manifest.nx?.targets?.build?.options;
2751
+ if (!options || !Array.isArray(options.assets)) {
2752
+ return;
2753
+ }
2754
+ options.assets = options.assets.map(
2755
+ (asset) => typeof asset === "string" ? { input: asset, glob: "**/*", output: asset.replace(`apps/${name}/src/`, "") } : asset
2756
+ );
2757
+ writeFileEnsured(manifestPath, toJson(manifest));
2715
2758
  }
2716
2759
  function nodeAppPackageTarget(name) {
2717
2760
  const zip = `dist/drop/node-app-${name}.zip`;
@@ -2800,7 +2843,7 @@ function repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot) {
2800
2843
  function nodeFunctionAppPackageTarget(name) {
2801
2844
  const zip = `dist/drop/node-function-app-${name}.zip`;
2802
2845
  const root = `apps/${name}`;
2803
- const command = `node -e "const fs=require('node:fs');fs.mkdirSync('dist/drop',{recursive:true});const A=require('adm-zip');const z=new A();z.addLocalFolder('${root}/dist','dist');z.addLocalFile('${root}/host.json');z.addLocalFile('${root}/package.json');z.writeZip('${zip}')"`;
2846
+ const command = String.raw`node -e "const fs=require('node:fs');fs.mkdirSync('dist/drop',{recursive:true});const A=require('adm-zip');const z=new A();z.addLocalFolder('${root}/dist','dist',(e)=>!/\.d\.ts(\.map)?$/.test(e));z.addLocalFile('${root}/host.json');z.addLocalFile('${root}/package.json');z.writeZip('${zip}')"`;
2804
2847
  return {
2805
2848
  executor: "nx:run-commands",
2806
2849
  dependsOn: ["build"],
@@ -2808,6 +2851,15 @@ function nodeFunctionAppPackageTarget(name) {
2808
2851
  options: { command }
2809
2852
  };
2810
2853
  }
2854
+ function nodeFunctionAppPruneTarget(name) {
2855
+ const pruned = `apps/${name}/dist/package.json`;
2856
+ const command = String.raw`node -e "const fs=require('node:fs');const root=JSON.parse(fs.readFileSync('package.json','utf8'));const o=root.overrides;if(!o||Object.keys(o).length===0){console.log('No root overrides - nothing to carry into the pruned manifest.');process.exit(0)}const p='${pruned}';if(!fs.existsSync(p)){console.error('Pruned manifest not found at '+p+' - run the prune-lockfile target first.');process.exit(1)}const m=JSON.parse(fs.readFileSync(p,'utf8'));m.overrides={...o,...m.overrides};fs.writeFileSync(p,JSON.stringify(m,null,2)+'\n');console.log('Carried '+Object.keys(o).length+' root override(s) into '+p)"`;
2857
+ return {
2858
+ executor: "nx:run-commands",
2859
+ dependsOn: ["prune-lockfile", "copy-workspace-modules"],
2860
+ options: { command }
2861
+ };
2862
+ }
2811
2863
  function nodeFunctionAppStartTarget(name) {
2812
2864
  return {
2813
2865
  executor: "nx:run-commands",
@@ -2835,6 +2887,7 @@ function addNodeFunctionApp(workspaceRoot, name, stack) {
2835
2887
  ensureAdmZip(workspaceRoot);
2836
2888
  addNxTargets((0, import_node_path7.join)(nodeFunctionAppRoot, "package.json"), {
2837
2889
  package: nodeFunctionAppPackageTarget(name),
2890
+ prune: nodeFunctionAppPruneTarget(name),
2838
2891
  start: nodeFunctionAppStartTarget(name)
2839
2892
  });
2840
2893
  removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
@@ -4624,6 +4677,7 @@ async function runAdd(kind, name, options) {
4624
4677
  const resolvedName = name ?? await promptText("Project name");
4625
4678
  assertValidProjectName(resolvedName, "Project name");
4626
4679
  const rootDependenciesBefore = rootRuntimeDependencies(workspaceRoot);
4680
+ ensureNxPeerOverrides(workspaceRoot);
4627
4681
  switch (resolvedKind) {
4628
4682
  case "react-app": {
4629
4683
  addReactApp(workspaceRoot, resolvedName, stack);