mfer 2.1.1 → 3.0.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.
@@ -13,6 +13,7 @@ import * as fs from "fs";
13
13
  import * as path from "path";
14
14
  import { checkbox } from "@inquirer/prompts";
15
15
  import { currentConfig, configExists, warnOfMissingConfig, } from "../../utils/config-utils.js";
16
+ import { resolvePackageName } from "../../utils/lib-utils.js";
16
17
  const deployCommand = new Command("deploy")
17
18
  .description("Copy built libraries to micro frontends")
18
19
  .argument("[lib-name]", "Name of the library to deploy (deploys all if not specified)")
@@ -77,14 +78,15 @@ const deployCommand = new Command("deploy")
77
78
  console.log(chalk.yellow(`Please run 'mfer lib build ${lib}' first.`));
78
79
  continue;
79
80
  }
80
- console.log(chalk.blue(`\nDeploying ${chalk.bold(lib)}...`));
81
+ const actualPackageName = resolvePackageName(lib, currentConfig.lib_directory);
82
+ console.log(chalk.blue(`\nDeploying ${chalk.bold(lib)} (package: ${actualPackageName})...`));
81
83
  let deployedCount = 0;
82
84
  for (const mfeDir of mfeDirectories) {
83
85
  if (!fs.existsSync(mfeDir)) {
84
86
  console.log(chalk.yellow(`Warning: MFE directory not found: ${mfeDir}`));
85
87
  continue;
86
88
  }
87
- const targetPath = path.join(mfeDir, "node_modules", lib);
89
+ const targetPath = path.join(mfeDir, "node_modules", actualPackageName);
88
90
  if (fs.existsSync(targetPath)) {
89
91
  try {
90
92
  yield copyLibraryToMfe(libDistPath, targetPath, lib);
@@ -14,6 +14,7 @@ import * as fs from "fs";
14
14
  import * as path from "path";
15
15
  import { checkbox } from "@inquirer/prompts";
16
16
  import { currentConfig, configExists, warnOfMissingConfig, } from "../../utils/config-utils.js";
17
+ import { resolvePackageName } from "../../utils/lib-utils.js";
17
18
  const publishCommand = new Command("publish")
18
19
  .description("Build and deploy libraries to micro frontends")
19
20
  .argument("[lib-name]", "Name of the library to publish (publishes all if not specified)")
@@ -89,13 +90,14 @@ const publishCommand = new Command("publish")
89
90
  }
90
91
  console.log(chalk.blue(` Deploying ${lib}...`));
91
92
  const libDistPath = path.join(libPath, "dist");
93
+ const actualPackageName = resolvePackageName(lib, currentConfig.lib_directory);
92
94
  let deployedCount = 0;
93
95
  for (const mfeDir of mfeDirectories) {
94
96
  if (!fs.existsSync(mfeDir)) {
95
97
  console.log(chalk.yellow(` Warning: MFE directory not found: ${mfeDir}`));
96
98
  continue;
97
99
  }
98
- const targetPath = path.join(mfeDir, "node_modules", lib);
100
+ const targetPath = path.join(mfeDir, "node_modules", actualPackageName);
99
101
  if (fs.existsSync(targetPath)) {
100
102
  try {
101
103
  yield copyLibraryToMfe(libDistPath, targetPath, lib);
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import { loadConfig } from "./utils/config-utils.js";
11
11
  program
12
12
  .name("mfer")
13
13
  .description("Micro Frontend Runner (mfer) - A CLI for running your project's micro frontends.")
14
- .version("2.1.1", "-v, --version", "mfer CLI version")
14
+ .version("3.0.0", "-v, --version", "mfer CLI version")
15
15
  .hook("preAction", () => {
16
16
  console.log();
17
17
  })
@@ -0,0 +1,21 @@
1
+ import * as fs from "fs";
2
+ import * as path from "path";
3
+ import chalk from "chalk";
4
+ export function resolvePackageName(libName, libDirectory) {
5
+ const packageJsonPath = path.join(libDirectory, libName, "package.json");
6
+ if (!fs.existsSync(packageJsonPath)) {
7
+ console.log(chalk.yellow(`Warning: package.json not found for ${libName}, using directory name`));
8
+ return libName;
9
+ }
10
+ try {
11
+ const packageJsonContent = fs.readFileSync(packageJsonPath, "utf8");
12
+ const packageJson = JSON.parse(packageJsonContent);
13
+ if (packageJson.name) {
14
+ return packageJson.name;
15
+ }
16
+ }
17
+ catch (error) {
18
+ console.log(chalk.yellow(`Warning: Could not parse package.json for ${libName}: ${error}`));
19
+ }
20
+ return libName;
21
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mfer",
3
- "version": "2.1.1",
3
+ "version": "3.0.0",
4
4
  "description": "CLI tool designed to sensibly run micro-frontends from the terminal.",
5
5
  "bin": {
6
6
  "mfer": "dist/index.js"