@mnci/cli 4.21.0 → 4.22.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/README.md CHANGED
@@ -204,7 +204,7 @@ value always wins.
204
204
  swc's `transform()` without `sourceMaps`, so swc returns no map, the rollup
205
205
  chain breaks, and the map comes out valid-looking and **empty** — `sources: []`.
206
206
  Measured on a real package: swc gave 0 sources, babel gave 9. Revert the swap
207
- once Nx passes `sourceMaps` through; ROADMAP 7d has the one-line upstream fix.
207
+ once Nx passes `sourceMaps` through; issue #308 has the one-line upstream fix.
208
208
 
209
209
  Re-measured against the exact toolchain `mnci new` pins today (Nx 23.2.0,
210
210
  `@swc/core` 1.15.8): `@nx/rollup`'s swc plugin still does **not** pass
package/dist/cli.js CHANGED
@@ -2673,27 +2673,33 @@ function projectTask(name, kind) {
2673
2673
  return kind === "start" ? { ...base, isBackground: true } : { ...base, group: kind };
2674
2674
  }
2675
2675
  function renameScaffoldPlaceholder(projectRoot, name) {
2676
+ reshapeScaffoldSlice(projectRoot, name, "ts", "use-case");
2677
+ }
2678
+ function reshapeReactScaffold(projectRoot, name) {
2679
+ reshapeScaffoldSlice(projectRoot, name, "tsx", "component");
2680
+ }
2681
+ function reshapeScaffoldSlice(projectRoot, name, extension, role) {
2676
2682
  const sourceDir = (0, import_node_path5.join)(projectRoot, "src");
2677
- const placeholder = (0, import_node_path5.join)(sourceDir, "lib", `${name}.ts`);
2678
- if (!(0, import_node_fs5.existsSync)(placeholder)) {
2683
+ const libDir = (0, import_node_path5.join)(sourceDir, "lib");
2684
+ if (!(0, import_node_fs5.existsSync)((0, import_node_path5.join)(libDir, `${name}.${extension}`))) {
2679
2685
  return;
2680
2686
  }
2681
2687
  const sliceDir = (0, import_node_path5.join)(sourceDir, name);
2682
2688
  (0, import_node_fs5.mkdirSync)(sliceDir, { recursive: true });
2683
- (0, import_node_fs5.renameSync)(placeholder, (0, import_node_path5.join)(sliceDir, `${name}.use-case.ts`));
2684
- const spec = (0, import_node_path5.join)(sourceDir, "lib", `${name}.spec.ts`);
2685
- if ((0, import_node_fs5.existsSync)(spec)) {
2686
- const renamed = (0, import_node_path5.join)(sliceDir, `${name}.use-case.spec.ts`);
2687
- (0, import_node_fs5.renameSync)(spec, renamed);
2688
- writeFileEnsured(
2689
- renamed,
2690
- // The spec still sits beside the implementation, so only its role suffix changes.
2691
- repointSpecifier((0, import_node_fs5.readFileSync)(renamed, "utf8"), `./${name}`, `./${name}.use-case`)
2692
- );
2689
+ for (const entry of (0, import_node_fs5.readdirSync)(libDir)) {
2690
+ if (entry === `${name}.${extension}`) {
2691
+ (0, import_node_fs5.renameSync)((0, import_node_path5.join)(libDir, entry), (0, import_node_path5.join)(sliceDir, `${name}.${role}.${extension}`));
2692
+ } else if (entry === `${name}.spec.${extension}`) {
2693
+ const renamed = (0, import_node_path5.join)(sliceDir, `${name}.${role}.spec.${extension}`);
2694
+ (0, import_node_fs5.renameSync)((0, import_node_path5.join)(libDir, entry), renamed);
2695
+ writeFileEnsured(renamed, repointSpecifier((0, import_node_fs5.readFileSync)(renamed, "utf8"), `./${name}`, `./${name}.${role}`));
2696
+ } else {
2697
+ (0, import_node_fs5.renameSync)((0, import_node_path5.join)(libDir, entry), (0, import_node_path5.join)(sliceDir, entry));
2698
+ }
2693
2699
  }
2694
2700
  const barrel = (0, import_node_path5.join)(sourceDir, "index.ts");
2695
2701
  const esm = (0, import_node_fs5.existsSync)(barrel) && (0, import_node_fs5.readFileSync)(barrel, "utf8").includes(`./lib/${name}.js'`);
2696
- writeFileEnsured((0, import_node_path5.join)(sliceDir, "index.ts"), `export * from './${name}.use-case${esm ? ".js" : ""}'
2702
+ writeFileEnsured((0, import_node_path5.join)(sliceDir, "index.ts"), `export * from './${name}.${role}${esm ? ".js" : ""}'
2697
2703
  `);
2698
2704
  if ((0, import_node_fs5.existsSync)(barrel)) {
2699
2705
  writeFileEnsured(
@@ -2701,7 +2707,7 @@ function renameScaffoldPlaceholder(projectRoot, name) {
2701
2707
  (0, import_node_fs5.readFileSync)(barrel, "utf8").replaceAll(`./lib/${name}.js'`, () => `./${name}/index.js'`).replaceAll(`./lib/${name}'`, () => `./${name}'`)
2702
2708
  );
2703
2709
  }
2704
- (0, import_node_fs5.rmSync)((0, import_node_path5.join)(sourceDir, "lib"), { recursive: true, force: true });
2710
+ (0, import_node_fs5.rmSync)(libDir, { recursive: true, force: true });
2705
2711
  }
2706
2712
  function repointSpecifier(source, from, to) {
2707
2713
  return source.replaceAll(`${from}'`, () => `${to}'`).replaceAll(`${from}.js'`, () => `${to}.js'`);
@@ -4136,7 +4142,7 @@ function sourceMapCapableCompiler(indent) {
4136
4142
  return [
4137
4143
  `${indent}// Swapped from swc by MoNecromanCI. @nx/rollup runs swc without`,
4138
4144
  `${indent}// sourceMaps, so it returns no map and the bundle's map comes out empty -`,
4139
- `${indent}// valid-looking, and useless for debugging. See ROADMAP.`,
4145
+ `${indent}// valid-looking, and useless for debugging. See issue #308.`,
4140
4146
  `${indent}compiler: 'babel',`
4141
4147
  ].join("\n");
4142
4148
  }
@@ -4764,6 +4770,7 @@ async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
4764
4770
  repairPublishableManifest(publishableManifest);
4765
4771
  repairDeclarationSpecifiers(projectRoot);
4766
4772
  writeProjectReadme(projectRoot, `${scope}/${name}`, stack.testRunner);
4773
+ reshapeReactScaffold(projectRoot, name);
4767
4774
  removeGeneratedEslintConfig(workspaceRoot, `packages/${name}`);
4768
4775
  removeLocalRegistryScaffolding(workspaceRoot);
4769
4776
  registerProjectCommands(workspaceRoot, name, { build: true });