react-mfe-gen 1.1.0 β 1.1.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/.github/PULL_REQUEST_TEMPLATE.md +9 -0
- package/README.md +6 -5
- package/creation/container-creation.js +3 -2
- package/creation/new-pro-creation.js +5 -6
- package/creation/single-mfe-creation.js +5 -4
- package/docs/ANSI-COLOR-CODES.md +14 -0
- package/mfe-gen.js +7 -2
- package/package.json +2 -1
- package/templates/container/container-comp-template.js +11 -3
- package/utility.js +15 -3
package/README.md
CHANGED
|
@@ -6,11 +6,12 @@ This tool uses the Runtime Integration approach β meaning each MFE is built as
|
|
|
6
6
|
|
|
7
7
|
## π Features:
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
9
|
+
- Spin up a React Microfrontend Base in Seconds β No hassle, just code.
|
|
10
|
+
- Built on Runtime Integration Best Practices β Seamless, scalable, and future-proof.
|
|
11
|
+
- Generates Production-Ready Microfrontends β Pre-configured and good to go.
|
|
12
|
+
- Smart Library Installer β Dynamically adds state management, styling, and form tools based on your choices.
|
|
13
|
+
- Self-Healing Setup β Auto-cleans incomplete code if something breaks mid-process.
|
|
14
|
+
- True Cross-Platform Compatibility β Works flawlessly on Windows, macOS, and Linux.
|
|
14
15
|
|
|
15
16
|
## π¦ Prerequisites:
|
|
16
17
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import inquirer from "inquirer";
|
|
2
2
|
import { PROMPT, INFO_MESSAGE, CHOICE_CONSTANTS } from "../constants.js";
|
|
3
|
-
import utils from "../utility.js";
|
|
3
|
+
import { utils } from "../utility.js";
|
|
4
4
|
|
|
5
5
|
const containerCreation = async (language) => {
|
|
6
6
|
// To store different working dir
|
|
@@ -72,7 +72,8 @@ const containerCreation = async (language) => {
|
|
|
72
72
|
console.log(
|
|
73
73
|
`${INFO_MESSAGE.SUCCESS.CONTAINER}\n${INFO_MESSAGE.HAPPY_CODING}`
|
|
74
74
|
);
|
|
75
|
-
} catch {
|
|
75
|
+
} catch (e) {
|
|
76
|
+
console.log("Error:", e);
|
|
76
77
|
utils.cleanupProject(workingDirectories);
|
|
77
78
|
}
|
|
78
79
|
};
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
QUESTION,
|
|
7
7
|
CHOICE_CONSTANTS,
|
|
8
8
|
} from "../constants.js";
|
|
9
|
-
import utils from "../utility.js";
|
|
9
|
+
import { utils, mfeGenLogger } from "../utility.js";
|
|
10
10
|
|
|
11
11
|
const newProjectCreation = async (language) => {
|
|
12
12
|
// To store different working dir
|
|
@@ -89,7 +89,7 @@ const newProjectCreation = async (language) => {
|
|
|
89
89
|
// store working dir
|
|
90
90
|
const mfeFullPath = path.join(mfeInfo.path, mfeName);
|
|
91
91
|
workingDirectories.push(mfeFullPath);
|
|
92
|
-
|
|
92
|
+
// Go inside user specified mfe dir
|
|
93
93
|
process.chdir(mfeInfo.path);
|
|
94
94
|
const mfeAppCommand = utils.getLanguageTemplate(mfeName, isTypeScript);
|
|
95
95
|
|
|
@@ -104,10 +104,9 @@ const newProjectCreation = async (language) => {
|
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
)
|
|
110
|
-
} catch {
|
|
107
|
+
mfeGenLogger.successLog(`${INFO_MESSAGE.SUCCESS.NEW_PRO}\n${INFO_MESSAGE.HAPPY_CODING}`);
|
|
108
|
+
} catch (e) {
|
|
109
|
+
mfeGenLogger.ErrorLog(`Error: ${e}`)
|
|
111
110
|
utils.cleanupProject(workingDirectories);
|
|
112
111
|
}
|
|
113
112
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import inquirer from "inquirer";
|
|
2
2
|
import { PROMPT, INFO_MESSAGE, CHOICE_CONSTANTS } from "../constants.js";
|
|
3
|
-
import utils from "../utility.js";
|
|
3
|
+
import { utils } from "../utility.js";
|
|
4
4
|
|
|
5
5
|
const singleMfeCreation = async (language) => {
|
|
6
6
|
// To store different working dir
|
|
@@ -34,15 +34,16 @@ const singleMfeCreation = async (language) => {
|
|
|
34
34
|
|
|
35
35
|
// Make normal react app into MFE container
|
|
36
36
|
await utils.configureMfe(
|
|
37
|
-
{ ...mfeInfo, projectName: mfeName,mfeDescription, isTypeScript },
|
|
37
|
+
{ ...mfeInfo, projectName: mfeName, mfeDescription, isTypeScript },
|
|
38
38
|
mfeName,
|
|
39
39
|
0
|
|
40
40
|
);
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
mfeGenLogger.successLog(
|
|
43
43
|
`${INFO_MESSAGE.SUCCESS.ONE_MFE}\n${INFO_MESSAGE.HAPPY_CODING}`
|
|
44
44
|
);
|
|
45
|
-
} catch {
|
|
45
|
+
} catch (e) {
|
|
46
|
+
mfeGenLogger.ErrorLog(`Error: ${e}`);
|
|
46
47
|
utils.cleanupProject(workingDirectories);
|
|
47
48
|
}
|
|
48
49
|
};
|
package/mfe-gen.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import inquirer from "inquirer";
|
|
2
2
|
import { PROMPT, INFO_MESSAGE, CHOICE_CONSTANTS } from "./constants.js";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
newProjectCreation,
|
|
5
|
+
containerCreation,
|
|
6
|
+
singleMfeCreation,
|
|
7
|
+
} from "./creation/index.js";
|
|
8
|
+
import { mfeGenLogger } from "./utility.js";
|
|
4
9
|
|
|
5
10
|
const mfeGen = async () => {
|
|
6
|
-
|
|
11
|
+
mfeGenLogger.notifyLog(INFO_MESSAGE.DISCLAIMER);
|
|
7
12
|
|
|
8
13
|
const { typeOfAction, language } = await inquirer.prompt(PROMPT.USER_NEED);
|
|
9
14
|
switch (typeOfAction) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-mfe-gen",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Generate React micro-frontends, containers, and projects using a simple CLI with runtime integration support.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
+
"start": "node ./index.js",
|
|
7
8
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
9
|
},
|
|
9
10
|
"repository": {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import utils from "../../utility.js";
|
|
1
|
+
import { utils } from "../../utility.js";
|
|
2
2
|
|
|
3
3
|
export const getContainerCompContent = (containerCompName, mfes) => {
|
|
4
4
|
let containerComp = `import React from "react";\n`;
|
|
5
5
|
|
|
6
6
|
for (let i = 0; i < mfes.length; i++) {
|
|
7
|
-
containerComp += `import {${utils.toCompName(
|
|
7
|
+
containerComp += `import {${utils.toCompName(
|
|
8
|
+
mfes[i]
|
|
9
|
+
)}} from "./microfrontends/${utils.toCompName(mfes[i])}";\n`;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
containerComp += `\n\nfunction ${containerCompName}() {
|
|
@@ -15,7 +17,13 @@ export const getContainerCompContent = (containerCompName, mfes) => {
|
|
|
15
17
|
<h1>Hello from ${containerCompName}</h1>\n`;
|
|
16
18
|
|
|
17
19
|
for (let i = 0; i < mfes.length; i++) {
|
|
18
|
-
containerComp += ` <${utils.toCompName(
|
|
20
|
+
containerComp += ` <${utils.toCompName(
|
|
21
|
+
mfes[i]
|
|
22
|
+
)} name={"${utils.toCompName(
|
|
23
|
+
mfes[i]
|
|
24
|
+
)}"} host={getMfeOrigin(process.env.REACT_APP_${mfes[
|
|
25
|
+
i
|
|
26
|
+
].toUpperCase()})} />\n`;
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
containerComp += `</div>
|
package/utility.js
CHANGED
|
@@ -39,11 +39,11 @@ class utils {
|
|
|
39
39
|
static async cleanupProject(dirs) {
|
|
40
40
|
try {
|
|
41
41
|
for (let i = 0; i < dirs.length; i++) {
|
|
42
|
-
|
|
42
|
+
mfeGenLogger.notifyLog(`Cleaning up the project directory: ${dirs[i]}`);
|
|
43
43
|
await rm(dirs[i], { recursive: true });
|
|
44
44
|
}
|
|
45
45
|
} catch (err) {
|
|
46
|
-
|
|
46
|
+
mfeGenLogger.ErrorLog(`Failed to clean project directory\n Error:${err}`);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -224,4 +224,16 @@ class utils {
|
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
class mfeGenLogger {
|
|
228
|
+
static successLog(message) {
|
|
229
|
+
console.log(`\x1b[32m${message}\x1b[0m`);
|
|
230
|
+
}
|
|
231
|
+
static ErrorLog(message) {
|
|
232
|
+
console.log(`\x1b[31m${message}\x1b[0m`);
|
|
233
|
+
}
|
|
234
|
+
static notifyLog(message) {
|
|
235
|
+
console.log(`\x1b[33m${message}\x1b[0m`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export { utils, mfeGenLogger };
|