react-mfe-gen 1.2.6 β 1.2.9
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 +8 -8
- package/.github/workflows/npm-publish.yml +23 -54
- package/README.md +34 -34
- package/dist/constants/constants.js +24 -24
- package/dist/templates/container/app-comp-template.js +7 -7
- package/dist/templates/container/container-comp-template.js +9 -9
- package/dist/templates/container/heart-template.js +57 -57
- package/dist/templates/container/mfe-comp-template.js +5 -5
- package/dist/templates/mfe/app-comp-template.js +11 -11
- package/dist/templates/mfe/config-overrides-template.js +10 -10
- package/dist/templates/mfe/mfe-index-template.js +34 -34
- package/dist/utils/utility.js +1 -1
- package/docs/ANSI-COLOR-CODES.md +14 -14
- package/package.json +58 -58
- package/src/constants/constants.ts +277 -277
- package/src/creation/container-creation.ts +82 -82
- package/src/creation/index.ts +5 -5
- package/src/creation/new-pro-creation.ts +114 -114
- package/src/creation/single-mfe-creation.ts +52 -52
- package/src/mfe-gen.ts +28 -28
- package/src/templates/container/app-comp-template.ts +9 -9
- package/src/templates/container/container-comp-template.ts +36 -36
- package/src/templates/container/env-template.ts +7 -7
- package/src/templates/container/heart-template.ts +59 -59
- package/src/templates/container/index.ts +17 -17
- package/src/templates/container/mfe-comp-template.ts +8 -8
- package/src/templates/mfe/app-comp-template.ts +13 -13
- package/src/templates/mfe/config-overrides-template.ts +12 -12
- package/src/templates/mfe/index.ts +8 -8
- package/src/templates/mfe/mfe-index-template.ts +36 -36
- package/src/types/type.ts +3 -3
- package/src/utils/utility.ts +248 -248
- package/tsconfig.json +15 -15
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# Live releaseπ version(x.xx)
|
|
2
|
-
|
|
3
|
-
## Description:
|
|
4
|
-
|
|
5
|
-
please describe new features introduced in this PR.
|
|
6
|
-
|
|
7
|
-
## Check list:
|
|
8
|
-
- [ ] Version upgraded in the package.json file.
|
|
1
|
+
# Live releaseπ version(x.xx)
|
|
2
|
+
|
|
3
|
+
## Description:
|
|
4
|
+
|
|
5
|
+
please describe new features introduced in this PR.
|
|
6
|
+
|
|
7
|
+
## Check list:
|
|
8
|
+
- [ ] Version upgraded in the package.json file.
|
|
9
9
|
- [ ] E2E flow tested in local.
|
|
@@ -1,54 +1,23 @@
|
|
|
1
|
-
name:
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
|
|
6
|
-
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
with:
|
|
25
|
-
node-version: 20
|
|
26
|
-
registry-url: https://registry.npmjs.org/
|
|
27
|
-
- run: npm ci
|
|
28
|
-
|
|
29
|
-
- name: Get previous version from main
|
|
30
|
-
id: prev_version
|
|
31
|
-
run: |
|
|
32
|
-
git fetch origin main --depth=1
|
|
33
|
-
PREV_VERSION=$(git show origin/main:package.json | grep '"version":' | head -1 | sed -E 's/.*"([^"]+)".*/\1/')
|
|
34
|
-
echo "PREV_VERSION=$PREV_VERSION" >> $GITHUB_ENV
|
|
35
|
-
|
|
36
|
-
- name: Get current version
|
|
37
|
-
id: curr_version
|
|
38
|
-
run: |
|
|
39
|
-
CURR_VERSION=$(grep '"version":' package.json | head -1 | sed -E 's/.*"([^"]+)".*/\1/')
|
|
40
|
-
echo "CURR_VERSION=$CURR_VERSION" >> $GITHUB_ENV
|
|
41
|
-
|
|
42
|
-
- name: Check version change
|
|
43
|
-
run: |
|
|
44
|
-
echo "Previous version: $PREV_VERSION"
|
|
45
|
-
echo "Current version: $CURR_VERSION"
|
|
46
|
-
if [ "$PREV_VERSION" = "$CURR_VERSION" ]; then
|
|
47
|
-
echo "Version not changed. Skipping publish."
|
|
48
|
-
exit 0
|
|
49
|
-
fi
|
|
50
|
-
|
|
51
|
-
- name: Publish to npm
|
|
52
|
-
run: npm publish --access public
|
|
53
|
-
env:
|
|
54
|
-
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
|
|
1
|
+
name: Publish Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
id-token: write
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
publish:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- uses: actions/setup-node@v4
|
|
19
|
+
with:
|
|
20
|
+
node-version: '24'
|
|
21
|
+
registry-url: 'https://registry.npmjs.org'
|
|
22
|
+
- run: npm ci
|
|
23
|
+
- run: npm publish
|
package/README.md
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
# React Microfront end generator (react-mfe-gen)
|
|
2
|
-
|
|
3
|
-
<strong style="color:orange">β οΈ Important:</strong> Install this package globally using `npm install -g` to use the CLI anywhere on your system.
|
|
4
|
-
|
|
5
|
-
react-mfe-gen is a CLI tool that helps you quickly scaffold a base setup for React Micro-Frontend (MFE) architecture.
|
|
6
|
-
|
|
7
|
-
This tool uses the Runtime Integration approach β meaning each MFE is built as a Web Component and integrated dynamically at runtime. This keeps your applications modular, scalable, and independent.
|
|
8
|
-
|
|
9
|
-
## Features:
|
|
10
|
-
|
|
11
|
-
- Spin up a React Microfrontend Base in Seconds β No hassle, just code.
|
|
12
|
-
- Built on Runtime Integration Best Practices β Seamless, scalable, and future-proof.
|
|
13
|
-
- Generates Production-Ready Microfrontends β Pre-configured and good to go.
|
|
14
|
-
- Smart Library Installer β Dynamically adds state management, styling, and form tools based on your choices.
|
|
15
|
-
- Self-Healing Setup β Auto-cleans incomplete code if something breaks mid-process.
|
|
16
|
-
- True Cross-Platform Compatibility β Works flawlessly on Windows, macOS, and Linux.
|
|
17
|
-
|
|
18
|
-
## Prerequisites:
|
|
19
|
-
|
|
20
|
-
Node.js installed (latest LTS recommended).
|
|
21
|
-
|
|
22
|
-
## Installation & Usage:
|
|
23
|
-
|
|
24
|
-
- Install the package globally
|
|
25
|
-
`npm install -g react-mfe-gen`
|
|
26
|
-
|
|
27
|
-
- Run the CLI
|
|
28
|
-
`create-react-mfe`
|
|
29
|
-
|
|
30
|
-
- You will see the below message in your terminal
|
|
31
|
-
|
|
32
|
-

|
|
33
|
-
|
|
34
|
-
- Answer the prompts to generate your project, container, or micro-frontend.
|
|
1
|
+
# React Microfront end generator (react-mfe-gen)
|
|
2
|
+
|
|
3
|
+
<strong style="color:orange">β οΈ Important:</strong> Install this package globally using `npm install -g` to use the CLI anywhere on your system.
|
|
4
|
+
|
|
5
|
+
react-mfe-gen is a CLI tool that helps you quickly scaffold a base setup for React Micro-Frontend (MFE) architecture.
|
|
6
|
+
|
|
7
|
+
This tool uses the Runtime Integration approach β meaning each MFE is built as a Web Component and integrated dynamically at runtime. This keeps your applications modular, scalable, and independent.
|
|
8
|
+
|
|
9
|
+
## Features:
|
|
10
|
+
|
|
11
|
+
- Spin up a React Microfrontend Base in Seconds β No hassle, just code.
|
|
12
|
+
- Built on Runtime Integration Best Practices β Seamless, scalable, and future-proof.
|
|
13
|
+
- Generates Production-Ready Microfrontends β Pre-configured and good to go.
|
|
14
|
+
- Smart Library Installer β Dynamically adds state management, styling, and form tools based on your choices.
|
|
15
|
+
- Self-Healing Setup β Auto-cleans incomplete code if something breaks mid-process.
|
|
16
|
+
- True Cross-Platform Compatibility β Works flawlessly on Windows, macOS, and Linux.
|
|
17
|
+
|
|
18
|
+
## Prerequisites:
|
|
19
|
+
|
|
20
|
+
Node.js installed (latest LTS recommended).
|
|
21
|
+
|
|
22
|
+
## Installation & Usage:
|
|
23
|
+
|
|
24
|
+
- Install the package globally
|
|
25
|
+
`npm install -g react-mfe-gen`
|
|
26
|
+
|
|
27
|
+
- Run the CLI
|
|
28
|
+
`create-react-mfe`
|
|
29
|
+
|
|
30
|
+
- You will see the below message in your terminal
|
|
31
|
+
|
|
32
|
+

|
|
33
|
+
|
|
34
|
+
-That's it! Answer the prompts to generate your project, container, or micro-frontend.
|
|
@@ -21,30 +21,30 @@ exports.QUESTION = {
|
|
|
21
21
|
};
|
|
22
22
|
exports.CHOICE_CONSTANTS = {
|
|
23
23
|
ACTION: {
|
|
24
|
-
NEW_PROJECT: "Create a new project
|
|
25
|
-
CONTAINER: "Create only a container
|
|
26
|
-
SINGLE_MFE: "Create a single micro-frontend
|
|
24
|
+
NEW_PROJECT: "Create a new project",
|
|
25
|
+
CONTAINER: "Create only a container",
|
|
26
|
+
SINGLE_MFE: "Create a single micro-frontend",
|
|
27
27
|
},
|
|
28
28
|
STYLING: {
|
|
29
|
-
SASS: "Sass
|
|
30
|
-
TAILWIND: "Tailwind
|
|
31
|
-
MATERIAL_UI: "Material UI
|
|
32
|
-
BOOTSTRAP: "Bootstrap
|
|
33
|
-
STYLED_COMPONENTS: "Styled Components
|
|
29
|
+
SASS: "Sass",
|
|
30
|
+
TAILWIND: "Tailwind",
|
|
31
|
+
MATERIAL_UI: "Material UI",
|
|
32
|
+
BOOTSTRAP: "Bootstrap",
|
|
33
|
+
STYLED_COMPONENTS: "Styled Components",
|
|
34
34
|
},
|
|
35
35
|
LANGUAGE: {
|
|
36
|
-
JAVA_SCRIPT: "JavaScript
|
|
37
|
-
TYPE_SCRIPT: "TypeScript
|
|
36
|
+
JAVA_SCRIPT: "JavaScript",
|
|
37
|
+
TYPE_SCRIPT: "TypeScript",
|
|
38
38
|
},
|
|
39
39
|
STATE_MANAGEMENT: {
|
|
40
|
-
REDUX: "Redux
|
|
41
|
-
ZUSTAND: "Zustand
|
|
40
|
+
REDUX: "Redux",
|
|
41
|
+
ZUSTAND: "Zustand",
|
|
42
42
|
},
|
|
43
43
|
FORM_MANAGEMENT: {
|
|
44
|
-
REACT_HOOK_FORM: "React-hook-form
|
|
45
|
-
FORMIK: "Formik
|
|
44
|
+
REACT_HOOK_FORM: "React-hook-form",
|
|
45
|
+
FORMIK: "Formik",
|
|
46
46
|
},
|
|
47
|
-
NONE: "None
|
|
47
|
+
NONE: "None",
|
|
48
48
|
};
|
|
49
49
|
exports.CHOICES = {
|
|
50
50
|
ACTION: [
|
|
@@ -214,18 +214,18 @@ exports.PROMPT = {
|
|
|
214
214
|
},
|
|
215
215
|
};
|
|
216
216
|
exports.INFO_MESSAGE = {
|
|
217
|
-
DISCLAIMER: "Hello there!
|
|
217
|
+
DISCLAIMER: "Hello there! \n\nThis tool currently supports micro-frontend creation using runtime integration via custom script injection .\nPlease keep this limitation in mind when developing your MFE applications.\n",
|
|
218
218
|
CREATE_APP: "Let's create ",
|
|
219
|
-
CONFIGURE_CONTAINER: "Configuring the container...
|
|
220
|
-
APP_CREATION: "Creating your React app...
|
|
221
|
-
i_DEPENDENCIES: "Installing dependencies...
|
|
222
|
-
i_DEV_DEPENDENCIES: "Installing dev dependencies...
|
|
219
|
+
CONFIGURE_CONTAINER: "Configuring the container...",
|
|
220
|
+
APP_CREATION: "Creating your React app...",
|
|
221
|
+
i_DEPENDENCIES: "Installing dependencies...",
|
|
222
|
+
i_DEV_DEPENDENCIES: "Installing dev dependencies...",
|
|
223
223
|
SUCCESS: {
|
|
224
|
-
NEW_PRO: "New project created successfully!
|
|
225
|
-
CONTAINER: "Container created successfully!
|
|
226
|
-
ONE_MFE: "Microfront end created successfully!
|
|
224
|
+
NEW_PRO: "New project created successfully!",
|
|
225
|
+
CONTAINER: "Container created successfully!",
|
|
226
|
+
ONE_MFE: "Microfront end created successfully!",
|
|
227
227
|
},
|
|
228
|
-
HAPPY_CODING: "Happy coding!
|
|
228
|
+
HAPPY_CODING: "Happy coding!",
|
|
229
229
|
};
|
|
230
230
|
exports.LIBRARY_PAIR = {
|
|
231
231
|
STYLING: {
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAppContent = void 0;
|
|
4
4
|
const getAppContent = (containerName = 'container') => {
|
|
5
|
-
return `import ${containerName} from "./${containerName}";
|
|
6
|
-
|
|
7
|
-
function App() {
|
|
8
|
-
return <${containerName} />;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default App;
|
|
5
|
+
return `import ${containerName} from "./${containerName}";
|
|
6
|
+
|
|
7
|
+
function App() {
|
|
8
|
+
return <${containerName} />;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default App;
|
|
12
12
|
`;
|
|
13
13
|
};
|
|
14
14
|
exports.getAppContent = getAppContent;
|
|
@@ -7,19 +7,19 @@ const getContainerCompContent = (containerCompName, mfes) => {
|
|
|
7
7
|
for (let i = 0; i < mfes.length; i++) {
|
|
8
8
|
containerComp += `import {${utility_1.utils.toCompName(mfes[i])}} from "./microfrontends/${utility_1.utils.toCompName(mfes[i])}";\n`;
|
|
9
9
|
}
|
|
10
|
-
containerComp += `\n\nfunction ${containerCompName}() {
|
|
11
|
-
const getMfeOrigin =(port:string|undefined='')=> \`\${window.location.protocol}//\${window.location.hostname}:\${port}\`;
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<div>
|
|
10
|
+
containerComp += `\n\nfunction ${containerCompName}() {
|
|
11
|
+
const getMfeOrigin =(port:string|undefined='')=> \`\${window.location.protocol}//\${window.location.hostname}:\${port}\`;
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div>
|
|
15
15
|
<h1>Hello from ${containerCompName}</h1>\n`;
|
|
16
16
|
for (let i = 0; i < mfes.length; i++) {
|
|
17
17
|
containerComp += ` <${utility_1.utils.toCompName(mfes[i])} name={"${utility_1.utils.toCompName(mfes[i])}"} host={getMfeOrigin(process.env.REACT_APP_${mfes[i].toUpperCase()})} />\n`;
|
|
18
18
|
}
|
|
19
|
-
containerComp += `</div>
|
|
20
|
-
);
|
|
21
|
-
};
|
|
22
|
-
|
|
19
|
+
containerComp += `</div>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
23
|
export default ${containerCompName};`;
|
|
24
24
|
return containerComp;
|
|
25
25
|
};
|
|
@@ -2,63 +2,63 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getHeartContent = void 0;
|
|
4
4
|
const getHeartContent = (containerName = 'container') => {
|
|
5
|
-
return `
|
|
6
|
-
import React from "react";
|
|
7
|
-
|
|
8
|
-
class MicroFrontend extends React.Component {
|
|
9
|
-
componentDidMount() {
|
|
10
|
-
const { name, host, document } = this.props;
|
|
11
|
-
const scriptId = \`micro-frontend-script-\${name}\`;
|
|
12
|
-
|
|
13
|
-
if (document.getElementById(scriptId)) {
|
|
14
|
-
this.renderMicroFrontend();
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
fetch(\`\${host}/asset-manifest.json\`)
|
|
19
|
-
.then((res) => res.json())
|
|
20
|
-
.then((manifest) => {
|
|
21
|
-
const script = document.createElement("script");
|
|
22
|
-
script.id = scriptId;
|
|
23
|
-
script.crossOrigin = "";
|
|
24
|
-
script.src = \`\${host}\${manifest["files"]["main.js"]}\`;
|
|
25
|
-
script.onload = this.renderMicroFrontend;
|
|
26
|
-
document.head.appendChild(script);
|
|
27
|
-
const link = document.createElement("link");
|
|
28
|
-
link.id = scriptId;
|
|
29
|
-
link.href = \`\${host}\${manifest["files"]["main.css"]}\`;
|
|
30
|
-
link.onload = this.renderMicroFrontend;
|
|
31
|
-
link.rel = "stylesheet";
|
|
32
|
-
document.head.appendChild(link);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
componentWillUnmount() {
|
|
37
|
-
const { name, window } = this.props;
|
|
38
|
-
|
|
39
|
-
window[\`unmount\${name}\`] && window[\`unmount\${name}\`](
|
|
40
|
-
\`\${name}-${containerName}\`
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
renderMicroFrontend = () => {
|
|
45
|
-
const { name, window, history } = this.props;
|
|
46
|
-
|
|
47
|
-
window[\`render\${name}\`] &&
|
|
48
|
-
window[\`render\${name}\`](\`\${name}-${containerName}\`, history);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
render() {
|
|
52
|
-
return <main id={\`\${this.props.name}-${containerName}\`} />;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
MicroFrontend.defaultProps = {
|
|
57
|
-
document,
|
|
58
|
-
window,
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export default MicroFrontend;
|
|
5
|
+
return `
|
|
6
|
+
import React from "react";
|
|
7
|
+
|
|
8
|
+
class MicroFrontend extends React.Component {
|
|
9
|
+
componentDidMount() {
|
|
10
|
+
const { name, host, document } = this.props;
|
|
11
|
+
const scriptId = \`micro-frontend-script-\${name}\`;
|
|
12
|
+
|
|
13
|
+
if (document.getElementById(scriptId)) {
|
|
14
|
+
this.renderMicroFrontend();
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
fetch(\`\${host}/asset-manifest.json\`)
|
|
19
|
+
.then((res) => res.json())
|
|
20
|
+
.then((manifest) => {
|
|
21
|
+
const script = document.createElement("script");
|
|
22
|
+
script.id = scriptId;
|
|
23
|
+
script.crossOrigin = "";
|
|
24
|
+
script.src = \`\${host}\${manifest["files"]["main.js"]}\`;
|
|
25
|
+
script.onload = this.renderMicroFrontend;
|
|
26
|
+
document.head.appendChild(script);
|
|
27
|
+
const link = document.createElement("link");
|
|
28
|
+
link.id = scriptId;
|
|
29
|
+
link.href = \`\${host}\${manifest["files"]["main.css"]}\`;
|
|
30
|
+
link.onload = this.renderMicroFrontend;
|
|
31
|
+
link.rel = "stylesheet";
|
|
32
|
+
document.head.appendChild(link);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
componentWillUnmount() {
|
|
37
|
+
const { name, window } = this.props;
|
|
38
|
+
|
|
39
|
+
window[\`unmount\${name}\`] && window[\`unmount\${name}\`](
|
|
40
|
+
\`\${name}-${containerName}\`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
renderMicroFrontend = () => {
|
|
45
|
+
const { name, window, history } = this.props;
|
|
46
|
+
|
|
47
|
+
window[\`render\${name}\`] &&
|
|
48
|
+
window[\`render\${name}\`](\`\${name}-${containerName}\`, history);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
render() {
|
|
52
|
+
return <main id={\`\${this.props.name}-${containerName}\`} />;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
MicroFrontend.defaultProps = {
|
|
57
|
+
document,
|
|
58
|
+
window,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default MicroFrontend;
|
|
62
62
|
`;
|
|
63
63
|
};
|
|
64
64
|
exports.getHeartContent = getHeartContent;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getMfeCompContent = void 0;
|
|
4
4
|
const getMfeCompContent = (mfeName, isTypeScript) => {
|
|
5
|
-
return `import MicroFrontend from "../MicroFrontend";
|
|
6
|
-
|
|
7
|
-
export const ${mfeName} = (props${isTypeScript ? ": any" : ""}) => {
|
|
8
|
-
return <MicroFrontend name={props.name} host={props.host} />;
|
|
9
|
-
};
|
|
5
|
+
return `import MicroFrontend from "../MicroFrontend";
|
|
6
|
+
|
|
7
|
+
export const ${mfeName} = (props${isTypeScript ? ": any" : ""}) => {
|
|
8
|
+
return <MicroFrontend name={props.name} host={props.host} />;
|
|
9
|
+
};
|
|
10
10
|
`;
|
|
11
11
|
};
|
|
12
12
|
exports.getMfeCompContent = getMfeCompContent;
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getMfeAppContent = void 0;
|
|
4
4
|
const getMfeAppContent = (mfeName = 'mfe', isTs) => {
|
|
5
|
-
return `import React from 'react';
|
|
6
|
-
|
|
7
|
-
function App(prop${isTs ? ": any" : ""}) {
|
|
8
|
-
return (
|
|
9
|
-
<div>
|
|
10
|
-
<h1>Hello from ${mfeName}</h1>
|
|
11
|
-
</div>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default App;
|
|
5
|
+
return `import React from 'react';
|
|
6
|
+
|
|
7
|
+
function App(prop${isTs ? ": any" : ""}) {
|
|
8
|
+
return (
|
|
9
|
+
<div>
|
|
10
|
+
<h1>Hello from ${mfeName}</h1>
|
|
11
|
+
</div>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default App;
|
|
16
16
|
`;
|
|
17
17
|
};
|
|
18
18
|
exports.getMfeAppContent = getMfeAppContent;
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getConfigOverridesContent = void 0;
|
|
4
4
|
const getConfigOverridesContent = () => {
|
|
5
|
-
return `module.exports = {
|
|
6
|
-
webpack: (config, env) => {
|
|
7
|
-
config.optimization.runtimeChunk = false;
|
|
8
|
-
config.optimization.splitChunks = {
|
|
9
|
-
cacheGroups: {
|
|
10
|
-
default: false,
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
return config;
|
|
14
|
-
},
|
|
5
|
+
return `module.exports = {
|
|
6
|
+
webpack: (config, env) => {
|
|
7
|
+
config.optimization.runtimeChunk = false;
|
|
8
|
+
config.optimization.splitChunks = {
|
|
9
|
+
cacheGroups: {
|
|
10
|
+
default: false,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
return config;
|
|
14
|
+
},
|
|
15
15
|
};`;
|
|
16
16
|
};
|
|
17
17
|
exports.getConfigOverridesContent = getConfigOverridesContent;
|
|
@@ -2,40 +2,40 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getmfeIndexContent = void 0;
|
|
4
4
|
const getmfeIndexContent = (mfeName = 'mfe', container, isTs) => {
|
|
5
|
-
return `import React from "react";
|
|
6
|
-
import { createRoot } from "react-dom/client";
|
|
7
|
-
import App from "./App";
|
|
8
|
-
|
|
9
|
-
${isTs ? `declare global {
|
|
10
|
-
interface Window {
|
|
11
|
-
render${mfeName}: (containerId${isTs ? ": string" : ""}, history${isTs ? "?: any" : ""}) => void;
|
|
12
|
-
unmount${mfeName}: (containerId${isTs ? ": string" : ""}) => void;
|
|
13
|
-
}
|
|
14
|
-
}` : ''}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
window.render${mfeName} = (containerId${isTs ? ": string" : ""}, history${isTs ? "?: any" : ""}) => {
|
|
18
|
-
const container${isTs ? ": any" : ""} = document.getElementById(containerId);
|
|
19
|
-
if (container) {
|
|
20
|
-
const root = createRoot(container);
|
|
21
|
-
root.render(<App history={history} />);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
window.unmount${mfeName} = (containerId${isTs ? ": string" : ""}) => {
|
|
26
|
-
const container = document.getElementById(containerId);
|
|
27
|
-
if (container) {
|
|
28
|
-
const root = createRoot(container);
|
|
29
|
-
root.unmount();
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const rootContainer = document.getElementById("root");
|
|
34
|
-
if (rootContainer && !document.getElementById("${mfeName}-${container}")) {
|
|
35
|
-
createRoot(rootContainer).render(<App />);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
5
|
+
return `import React from "react";
|
|
6
|
+
import { createRoot } from "react-dom/client";
|
|
7
|
+
import App from "./App";
|
|
8
|
+
|
|
9
|
+
${isTs ? `declare global {
|
|
10
|
+
interface Window {
|
|
11
|
+
render${mfeName}: (containerId${isTs ? ": string" : ""}, history${isTs ? "?: any" : ""}) => void;
|
|
12
|
+
unmount${mfeName}: (containerId${isTs ? ": string" : ""}) => void;
|
|
13
|
+
}
|
|
14
|
+
}` : ''}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
window.render${mfeName} = (containerId${isTs ? ": string" : ""}, history${isTs ? "?: any" : ""}) => {
|
|
18
|
+
const container${isTs ? ": any" : ""} = document.getElementById(containerId);
|
|
19
|
+
if (container) {
|
|
20
|
+
const root = createRoot(container);
|
|
21
|
+
root.render(<App history={history} />);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
window.unmount${mfeName} = (containerId${isTs ? ": string" : ""}) => {
|
|
26
|
+
const container = document.getElementById(containerId);
|
|
27
|
+
if (container) {
|
|
28
|
+
const root = createRoot(container);
|
|
29
|
+
root.unmount();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const rootContainer = document.getElementById("root");
|
|
34
|
+
if (rootContainer && !document.getElementById("${mfeName}-${container}")) {
|
|
35
|
+
createRoot(rootContainer).render(<App />);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
39
|
`;
|
|
40
40
|
};
|
|
41
41
|
exports.getmfeIndexContent = getmfeIndexContent;
|
package/dist/utils/utility.js
CHANGED
|
@@ -109,7 +109,7 @@ class utils {
|
|
|
109
109
|
];
|
|
110
110
|
await utils.installPackages(packagesList);
|
|
111
111
|
await (0, promises_1.writeFile)("README.md", `# ${projectName}\n${projectDescription}`);
|
|
112
|
-
console.log(`${projectName} created
|
|
112
|
+
console.log(`${projectName} created\n`);
|
|
113
113
|
}
|
|
114
114
|
static async configureMfe(info, mfeName, index) {
|
|
115
115
|
const { projectName, formManagement, styling, stateManagement, mfeDescription = "", isTypeScript, } = info;
|
package/docs/ANSI-COLOR-CODES.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
## Color codes for CLI logs:
|
|
2
|
-
|
|
3
|
-
\x1b[31m β Red
|
|
4
|
-
|
|
5
|
-
\x1b[32m β Green
|
|
6
|
-
|
|
7
|
-
\x1b[33m β Yellow
|
|
8
|
-
|
|
9
|
-
\x1b[34m β Blue
|
|
10
|
-
|
|
11
|
-
\x1b[35m β Magenta
|
|
12
|
-
|
|
13
|
-
\x1b[36m β Cyan
|
|
14
|
-
|
|
1
|
+
## Color codes for CLI logs:
|
|
2
|
+
|
|
3
|
+
\x1b[31m β Red
|
|
4
|
+
|
|
5
|
+
\x1b[32m β Green
|
|
6
|
+
|
|
7
|
+
\x1b[33m β Yellow
|
|
8
|
+
|
|
9
|
+
\x1b[34m β Blue
|
|
10
|
+
|
|
11
|
+
\x1b[35m β Magenta
|
|
12
|
+
|
|
13
|
+
\x1b[36m β Cyan
|
|
14
|
+
|
|
15
15
|
\x1b[0m β Reset
|