react-mfe-gen 1.1.1 β 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/creation/container-creation.js +1 -1
- package/creation/new-pro-creation.js +3 -5
- package/creation/single-mfe-creation.js +3 -3
- 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
|
@@ -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
|
|
@@ -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
|
|
@@ -104,11 +104,9 @@ const newProjectCreation = async (language) => {
|
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
`${INFO_MESSAGE.SUCCESS.NEW_PRO}\n${INFO_MESSAGE.HAPPY_CODING}`
|
|
109
|
-
);
|
|
107
|
+
mfeGenLogger.successLog(`${INFO_MESSAGE.SUCCESS.NEW_PRO}\n${INFO_MESSAGE.HAPPY_CODING}`);
|
|
110
108
|
} catch (e) {
|
|
111
|
-
|
|
109
|
+
mfeGenLogger.ErrorLog(`Error: ${e}`)
|
|
112
110
|
utils.cleanupProject(workingDirectories);
|
|
113
111
|
}
|
|
114
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
|
|
@@ -39,11 +39,11 @@ const singleMfeCreation = async (language) => {
|
|
|
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
45
|
} catch (e) {
|
|
46
|
-
|
|
46
|
+
mfeGenLogger.ErrorLog(`Error: ${e}`);
|
|
47
47
|
utils.cleanupProject(workingDirectories);
|
|
48
48
|
}
|
|
49
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 };
|