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
package/src/utils/utility.ts
CHANGED
|
@@ -1,248 +1,248 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { Spinner } from "cli-spinner";
|
|
3
|
-
import { execa } from "execa";
|
|
4
|
-
import {
|
|
5
|
-
INFO_MESSAGE,
|
|
6
|
-
LIBRARY_PAIR,
|
|
7
|
-
DEFAULT_DEPENDENCIES,
|
|
8
|
-
DEFAULT_DEV_DEPENDENCIES,
|
|
9
|
-
} from "../constants/constants";
|
|
10
|
-
import {
|
|
11
|
-
getHeartContent,
|
|
12
|
-
getAppContent,
|
|
13
|
-
getMfeCompContent,
|
|
14
|
-
getContainerCompContent,
|
|
15
|
-
getEnvContent,
|
|
16
|
-
} from "../templates/container";
|
|
17
|
-
import { writeFile, unlink, mkdir, readFile, rm } from "fs/promises";
|
|
18
|
-
import {
|
|
19
|
-
getConfigOverridesContent,
|
|
20
|
-
getMfeAppContent,
|
|
21
|
-
getmfeIndexContent,
|
|
22
|
-
} from "../templates/mfe";
|
|
23
|
-
|
|
24
|
-
class utils {
|
|
25
|
-
static async runTask(logMessage: string, task: () => void) {
|
|
26
|
-
const spinner = new Spinner(logMessage + "%s");
|
|
27
|
-
spinner.setSpinnerString("⠋⠙⠹⠸⠼⠴⠦⠧⠏");
|
|
28
|
-
spinner.setSpinnerDelay(40);
|
|
29
|
-
spinner.start();
|
|
30
|
-
try {
|
|
31
|
-
await task();
|
|
32
|
-
spinner.stop(true);
|
|
33
|
-
} catch (err) {
|
|
34
|
-
spinner.stop(true);
|
|
35
|
-
throw err;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
static async cleanupProject(dirs: string[]) {
|
|
40
|
-
try {
|
|
41
|
-
for (let i = 0; i < dirs.length; i++) {
|
|
42
|
-
mfeGenLogger.notifyLog(`Cleaning up the project directory: ${dirs[i]}`);
|
|
43
|
-
await rm(dirs[i], { recursive: true });
|
|
44
|
-
}
|
|
45
|
-
} catch (err) {
|
|
46
|
-
mfeGenLogger.ErrorLog(`Failed to clean project directory\n Error:${err}`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
static async createReactApp(appCommand: string[]) {
|
|
51
|
-
try {
|
|
52
|
-
await utils.runTask(INFO_MESSAGE.APP_CREATION, () =>
|
|
53
|
-
execa("npx", ["create-react-app", ...appCommand])
|
|
54
|
-
);
|
|
55
|
-
} catch (err) {
|
|
56
|
-
throw err;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
static async installPackages(packages: string[], isDev = false) {
|
|
61
|
-
try {
|
|
62
|
-
let message = INFO_MESSAGE.i_DEPENDENCIES;
|
|
63
|
-
if (isDev) {
|
|
64
|
-
message = INFO_MESSAGE.i_DEV_DEPENDENCIES;
|
|
65
|
-
packages = [...packages, "--save-dev"];
|
|
66
|
-
}
|
|
67
|
-
await utils.runTask(message, () =>
|
|
68
|
-
execa("npm", ["install", ...packages])
|
|
69
|
-
);
|
|
70
|
-
} catch (err) {
|
|
71
|
-
throw err;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
static getLanguageTemplate(appName: string, isTs: boolean) {
|
|
76
|
-
return isTs ? [appName, "--template", "typescript"] : [appName];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
static withExt(name: string, isTs: boolean) {
|
|
80
|
-
return isTs ? `${name}.tsx` : `${name}.jsx`;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
static withScript(name: string, isTs: boolean) {
|
|
84
|
-
return isTs ? `${name}.ts` : `${name}.js`;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static toCompName(AppName: string) {
|
|
88
|
-
return AppName.replace(/[-\s]+/g, " ")
|
|
89
|
-
.split(" ")
|
|
90
|
-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
91
|
-
.join("");
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
static async updateScripts(dir: string, newScripts: any) {
|
|
95
|
-
const rawPackageJson: any = await readFile(dir);
|
|
96
|
-
const packageJSON = JSON.parse(rawPackageJson);
|
|
97
|
-
|
|
98
|
-
packageJSON.scripts = newScripts;
|
|
99
|
-
|
|
100
|
-
await writeFile(dir, JSON.stringify(packageJSON, null, 2), "utf8");
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
static async configureContainer(info: any, mfeNames: string[]) {
|
|
104
|
-
const {
|
|
105
|
-
projectName,
|
|
106
|
-
projectDescription,
|
|
107
|
-
isTypeScript,
|
|
108
|
-
styling,
|
|
109
|
-
stateManagement,
|
|
110
|
-
} = info;
|
|
111
|
-
|
|
112
|
-
// Go inside src
|
|
113
|
-
const srcPath = path.join(process.cwd(), projectName, "src");
|
|
114
|
-
process.chdir(srcPath);
|
|
115
|
-
|
|
116
|
-
await utils.runTask(INFO_MESSAGE.CONFIGURE_CONTAINER, () =>
|
|
117
|
-
writeFile("MicroFrontend.js", getHeartContent(projectName))
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
const containerCompName = utils.toCompName(projectName);
|
|
121
|
-
|
|
122
|
-
await utils.runTask(INFO_MESSAGE.CONFIGURE_CONTAINER, () =>
|
|
123
|
-
writeFile(
|
|
124
|
-
utils.withExt(containerCompName, isTypeScript),
|
|
125
|
-
getContainerCompContent(containerCompName, mfeNames)
|
|
126
|
-
)
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
await utils.runTask(INFO_MESSAGE.CONFIGURE_CONTAINER, () =>
|
|
130
|
-
writeFile(
|
|
131
|
-
utils.withExt("App", isTypeScript),
|
|
132
|
-
getAppContent(containerCompName)
|
|
133
|
-
)
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
await unlink("App.css");
|
|
137
|
-
await unlink("logo.svg");
|
|
138
|
-
|
|
139
|
-
// Remove App.js file if template is javascript
|
|
140
|
-
if (!isTypeScript) await unlink("App.js");
|
|
141
|
-
|
|
142
|
-
await mkdir("microfrontends");
|
|
143
|
-
|
|
144
|
-
const mfeFolderPath = path.join(process.cwd(), "microfrontends");
|
|
145
|
-
process.chdir(mfeFolderPath);
|
|
146
|
-
|
|
147
|
-
for (let i = 0; i < mfeNames.length; i++) {
|
|
148
|
-
const mfeCompName = utils.toCompName(mfeNames[i]);
|
|
149
|
-
await writeFile(
|
|
150
|
-
utils.withExt(mfeCompName, isTypeScript),
|
|
151
|
-
getMfeCompContent(mfeCompName, isTypeScript)
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
process.chdir(path.resolve(srcPath, ".."));
|
|
156
|
-
|
|
157
|
-
await writeFile(".env", getEnvContent(mfeNames));
|
|
158
|
-
|
|
159
|
-
const packagesList = [
|
|
160
|
-
...DEFAULT_DEPENDENCIES,
|
|
161
|
-
...LIBRARY_PAIR.STYLING[styling],
|
|
162
|
-
...LIBRARY_PAIR.STATE_MANAGEMENT[stateManagement],
|
|
163
|
-
];
|
|
164
|
-
await utils.installPackages(packagesList);
|
|
165
|
-
|
|
166
|
-
await writeFile("README.md", `# ${projectName}\n${projectDescription}`);
|
|
167
|
-
|
|
168
|
-
console.log(`${projectName} created
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
static async configureMfe(info: any, mfeName: string, index: number) {
|
|
172
|
-
const {
|
|
173
|
-
projectName,
|
|
174
|
-
formManagement,
|
|
175
|
-
styling,
|
|
176
|
-
stateManagement,
|
|
177
|
-
mfeDescription = "",
|
|
178
|
-
isTypeScript,
|
|
179
|
-
} = info;
|
|
180
|
-
|
|
181
|
-
const mfeSrcPath = path.join(process.cwd(), mfeName, "src");
|
|
182
|
-
process.chdir(mfeSrcPath);
|
|
183
|
-
|
|
184
|
-
await writeFile(
|
|
185
|
-
utils.withExt("App", isTypeScript),
|
|
186
|
-
getMfeAppContent(utils.toCompName(mfeName), isTypeScript)
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
await writeFile(
|
|
190
|
-
utils.withExt("index", isTypeScript),
|
|
191
|
-
getmfeIndexContent(utils.toCompName(mfeName), projectName, isTypeScript)
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
await unlink("App.css");
|
|
195
|
-
await unlink("logo.svg");
|
|
196
|
-
await unlink("index.css");
|
|
197
|
-
|
|
198
|
-
// Remove default js files if template is javascript
|
|
199
|
-
if (!isTypeScript) {
|
|
200
|
-
await unlink("App.js");
|
|
201
|
-
await unlink("index.js");
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
process.chdir(path.resolve(mfeSrcPath, ".."));
|
|
205
|
-
|
|
206
|
-
await writeFile("config-overrides.js", getConfigOverridesContent());
|
|
207
|
-
|
|
208
|
-
const updatedScript = {
|
|
209
|
-
start: `cross-env PORT=900${index} react-app-rewired start`,
|
|
210
|
-
build: "react-app-rewired build",
|
|
211
|
-
test: "react-app-rewired test",
|
|
212
|
-
eject: "react-app-rewired eject",
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
await utils.updateScripts(
|
|
216
|
-
path.join(process.cwd(), "package.json"),
|
|
217
|
-
updatedScript
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
const packagesList = [
|
|
221
|
-
...DEFAULT_DEPENDENCIES,
|
|
222
|
-
...LIBRARY_PAIR.STYLING[styling],
|
|
223
|
-
...LIBRARY_PAIR.STATE_MANAGEMENT[stateManagement],
|
|
224
|
-
...LIBRARY_PAIR.FORM_MANAGEMENT[formManagement],
|
|
225
|
-
];
|
|
226
|
-
|
|
227
|
-
await utils.installPackages(packagesList);
|
|
228
|
-
await utils.installPackages(DEFAULT_DEV_DEPENDENCIES, true);
|
|
229
|
-
|
|
230
|
-
await writeFile("README.md", `# ${mfeName}\n##${mfeDescription}`);
|
|
231
|
-
|
|
232
|
-
console.log(`${mfeName} created ✅`);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
class mfeGenLogger {
|
|
237
|
-
static successLog(message: string) {
|
|
238
|
-
console.log(`\x1b[32m${message}\x1b[0m`);
|
|
239
|
-
}
|
|
240
|
-
static ErrorLog(message: string) {
|
|
241
|
-
console.log(`\x1b[31m${message}\x1b[0m`);
|
|
242
|
-
}
|
|
243
|
-
static notifyLog(message: string) {
|
|
244
|
-
console.log(`\x1b[33m${message}\x1b[0m`);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
export { utils, mfeGenLogger };
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { Spinner } from "cli-spinner";
|
|
3
|
+
import { execa } from "execa";
|
|
4
|
+
import {
|
|
5
|
+
INFO_MESSAGE,
|
|
6
|
+
LIBRARY_PAIR,
|
|
7
|
+
DEFAULT_DEPENDENCIES,
|
|
8
|
+
DEFAULT_DEV_DEPENDENCIES,
|
|
9
|
+
} from "../constants/constants";
|
|
10
|
+
import {
|
|
11
|
+
getHeartContent,
|
|
12
|
+
getAppContent,
|
|
13
|
+
getMfeCompContent,
|
|
14
|
+
getContainerCompContent,
|
|
15
|
+
getEnvContent,
|
|
16
|
+
} from "../templates/container";
|
|
17
|
+
import { writeFile, unlink, mkdir, readFile, rm } from "fs/promises";
|
|
18
|
+
import {
|
|
19
|
+
getConfigOverridesContent,
|
|
20
|
+
getMfeAppContent,
|
|
21
|
+
getmfeIndexContent,
|
|
22
|
+
} from "../templates/mfe";
|
|
23
|
+
|
|
24
|
+
class utils {
|
|
25
|
+
static async runTask(logMessage: string, task: () => void) {
|
|
26
|
+
const spinner = new Spinner(logMessage + "%s");
|
|
27
|
+
spinner.setSpinnerString("⠋⠙⠹⠸⠼⠴⠦⠧⠏");
|
|
28
|
+
spinner.setSpinnerDelay(40);
|
|
29
|
+
spinner.start();
|
|
30
|
+
try {
|
|
31
|
+
await task();
|
|
32
|
+
spinner.stop(true);
|
|
33
|
+
} catch (err) {
|
|
34
|
+
spinner.stop(true);
|
|
35
|
+
throw err;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static async cleanupProject(dirs: string[]) {
|
|
40
|
+
try {
|
|
41
|
+
for (let i = 0; i < dirs.length; i++) {
|
|
42
|
+
mfeGenLogger.notifyLog(`Cleaning up the project directory: ${dirs[i]}`);
|
|
43
|
+
await rm(dirs[i], { recursive: true });
|
|
44
|
+
}
|
|
45
|
+
} catch (err) {
|
|
46
|
+
mfeGenLogger.ErrorLog(`Failed to clean project directory\n Error:${err}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static async createReactApp(appCommand: string[]) {
|
|
51
|
+
try {
|
|
52
|
+
await utils.runTask(INFO_MESSAGE.APP_CREATION, () =>
|
|
53
|
+
execa("npx", ["create-react-app", ...appCommand])
|
|
54
|
+
);
|
|
55
|
+
} catch (err) {
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static async installPackages(packages: string[], isDev = false) {
|
|
61
|
+
try {
|
|
62
|
+
let message = INFO_MESSAGE.i_DEPENDENCIES;
|
|
63
|
+
if (isDev) {
|
|
64
|
+
message = INFO_MESSAGE.i_DEV_DEPENDENCIES;
|
|
65
|
+
packages = [...packages, "--save-dev"];
|
|
66
|
+
}
|
|
67
|
+
await utils.runTask(message, () =>
|
|
68
|
+
execa("npm", ["install", ...packages])
|
|
69
|
+
);
|
|
70
|
+
} catch (err) {
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static getLanguageTemplate(appName: string, isTs: boolean) {
|
|
76
|
+
return isTs ? [appName, "--template", "typescript"] : [appName];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static withExt(name: string, isTs: boolean) {
|
|
80
|
+
return isTs ? `${name}.tsx` : `${name}.jsx`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static withScript(name: string, isTs: boolean) {
|
|
84
|
+
return isTs ? `${name}.ts` : `${name}.js`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static toCompName(AppName: string) {
|
|
88
|
+
return AppName.replace(/[-\s]+/g, " ")
|
|
89
|
+
.split(" ")
|
|
90
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
91
|
+
.join("");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static async updateScripts(dir: string, newScripts: any) {
|
|
95
|
+
const rawPackageJson: any = await readFile(dir);
|
|
96
|
+
const packageJSON = JSON.parse(rawPackageJson);
|
|
97
|
+
|
|
98
|
+
packageJSON.scripts = newScripts;
|
|
99
|
+
|
|
100
|
+
await writeFile(dir, JSON.stringify(packageJSON, null, 2), "utf8");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static async configureContainer(info: any, mfeNames: string[]) {
|
|
104
|
+
const {
|
|
105
|
+
projectName,
|
|
106
|
+
projectDescription,
|
|
107
|
+
isTypeScript,
|
|
108
|
+
styling,
|
|
109
|
+
stateManagement,
|
|
110
|
+
} = info;
|
|
111
|
+
|
|
112
|
+
// Go inside src
|
|
113
|
+
const srcPath = path.join(process.cwd(), projectName, "src");
|
|
114
|
+
process.chdir(srcPath);
|
|
115
|
+
|
|
116
|
+
await utils.runTask(INFO_MESSAGE.CONFIGURE_CONTAINER, () =>
|
|
117
|
+
writeFile("MicroFrontend.js", getHeartContent(projectName))
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const containerCompName = utils.toCompName(projectName);
|
|
121
|
+
|
|
122
|
+
await utils.runTask(INFO_MESSAGE.CONFIGURE_CONTAINER, () =>
|
|
123
|
+
writeFile(
|
|
124
|
+
utils.withExt(containerCompName, isTypeScript),
|
|
125
|
+
getContainerCompContent(containerCompName, mfeNames)
|
|
126
|
+
)
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
await utils.runTask(INFO_MESSAGE.CONFIGURE_CONTAINER, () =>
|
|
130
|
+
writeFile(
|
|
131
|
+
utils.withExt("App", isTypeScript),
|
|
132
|
+
getAppContent(containerCompName)
|
|
133
|
+
)
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
await unlink("App.css");
|
|
137
|
+
await unlink("logo.svg");
|
|
138
|
+
|
|
139
|
+
// Remove App.js file if template is javascript
|
|
140
|
+
if (!isTypeScript) await unlink("App.js");
|
|
141
|
+
|
|
142
|
+
await mkdir("microfrontends");
|
|
143
|
+
|
|
144
|
+
const mfeFolderPath = path.join(process.cwd(), "microfrontends");
|
|
145
|
+
process.chdir(mfeFolderPath);
|
|
146
|
+
|
|
147
|
+
for (let i = 0; i < mfeNames.length; i++) {
|
|
148
|
+
const mfeCompName = utils.toCompName(mfeNames[i]);
|
|
149
|
+
await writeFile(
|
|
150
|
+
utils.withExt(mfeCompName, isTypeScript),
|
|
151
|
+
getMfeCompContent(mfeCompName, isTypeScript)
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
process.chdir(path.resolve(srcPath, ".."));
|
|
156
|
+
|
|
157
|
+
await writeFile(".env", getEnvContent(mfeNames));
|
|
158
|
+
|
|
159
|
+
const packagesList = [
|
|
160
|
+
...DEFAULT_DEPENDENCIES,
|
|
161
|
+
...LIBRARY_PAIR.STYLING[styling],
|
|
162
|
+
...LIBRARY_PAIR.STATE_MANAGEMENT[stateManagement],
|
|
163
|
+
];
|
|
164
|
+
await utils.installPackages(packagesList);
|
|
165
|
+
|
|
166
|
+
await writeFile("README.md", `# ${projectName}\n${projectDescription}`);
|
|
167
|
+
|
|
168
|
+
console.log(`${projectName} created\n`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
static async configureMfe(info: any, mfeName: string, index: number) {
|
|
172
|
+
const {
|
|
173
|
+
projectName,
|
|
174
|
+
formManagement,
|
|
175
|
+
styling,
|
|
176
|
+
stateManagement,
|
|
177
|
+
mfeDescription = "",
|
|
178
|
+
isTypeScript,
|
|
179
|
+
} = info;
|
|
180
|
+
|
|
181
|
+
const mfeSrcPath = path.join(process.cwd(), mfeName, "src");
|
|
182
|
+
process.chdir(mfeSrcPath);
|
|
183
|
+
|
|
184
|
+
await writeFile(
|
|
185
|
+
utils.withExt("App", isTypeScript),
|
|
186
|
+
getMfeAppContent(utils.toCompName(mfeName), isTypeScript)
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
await writeFile(
|
|
190
|
+
utils.withExt("index", isTypeScript),
|
|
191
|
+
getmfeIndexContent(utils.toCompName(mfeName), projectName, isTypeScript)
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
await unlink("App.css");
|
|
195
|
+
await unlink("logo.svg");
|
|
196
|
+
await unlink("index.css");
|
|
197
|
+
|
|
198
|
+
// Remove default js files if template is javascript
|
|
199
|
+
if (!isTypeScript) {
|
|
200
|
+
await unlink("App.js");
|
|
201
|
+
await unlink("index.js");
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
process.chdir(path.resolve(mfeSrcPath, ".."));
|
|
205
|
+
|
|
206
|
+
await writeFile("config-overrides.js", getConfigOverridesContent());
|
|
207
|
+
|
|
208
|
+
const updatedScript = {
|
|
209
|
+
start: `cross-env PORT=900${index} react-app-rewired start`,
|
|
210
|
+
build: "react-app-rewired build",
|
|
211
|
+
test: "react-app-rewired test",
|
|
212
|
+
eject: "react-app-rewired eject",
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
await utils.updateScripts(
|
|
216
|
+
path.join(process.cwd(), "package.json"),
|
|
217
|
+
updatedScript
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
const packagesList = [
|
|
221
|
+
...DEFAULT_DEPENDENCIES,
|
|
222
|
+
...LIBRARY_PAIR.STYLING[styling],
|
|
223
|
+
...LIBRARY_PAIR.STATE_MANAGEMENT[stateManagement],
|
|
224
|
+
...LIBRARY_PAIR.FORM_MANAGEMENT[formManagement],
|
|
225
|
+
];
|
|
226
|
+
|
|
227
|
+
await utils.installPackages(packagesList);
|
|
228
|
+
await utils.installPackages(DEFAULT_DEV_DEPENDENCIES, true);
|
|
229
|
+
|
|
230
|
+
await writeFile("README.md", `# ${mfeName}\n##${mfeDescription}`);
|
|
231
|
+
|
|
232
|
+
console.log(`${mfeName} created ✅`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
class mfeGenLogger {
|
|
237
|
+
static successLog(message: string) {
|
|
238
|
+
console.log(`\x1b[32m${message}\x1b[0m`);
|
|
239
|
+
}
|
|
240
|
+
static ErrorLog(message: string) {
|
|
241
|
+
console.log(`\x1b[31m${message}\x1b[0m`);
|
|
242
|
+
}
|
|
243
|
+
static notifyLog(message: string) {
|
|
244
|
+
console.log(`\x1b[33m${message}\x1b[0m`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export { utils, mfeGenLogger };
|
package/tsconfig.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"rootDir": "src",
|
|
6
|
-
"outDir": "dist",
|
|
7
|
-
"strict": true,
|
|
8
|
-
"removeComments": false,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"skipLibCheck": true
|
|
12
|
-
},
|
|
13
|
-
"include": ["src"],
|
|
14
|
-
"exclude": ["node_modules"]
|
|
15
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"rootDir": "src",
|
|
6
|
+
"outDir": "dist",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"removeComments": false,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"skipLibCheck": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"],
|
|
14
|
+
"exclude": ["node_modules"]
|
|
15
|
+
}
|