-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathoptionalFeature.js
More file actions
86 lines (77 loc) · 2.28 KB
/
Copy pathoptionalFeature.js
File metadata and controls
86 lines (77 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const path = require('path');
const { appConstants } = require('./constants');
const loggerUtil = require('./logHelpers');
const { createDir, copyDir, dirFileExists } = require('./fileDirOps');
function getDestionPath(microAppPath, feature) {
const configOptionalFeaturePath = path.join(microAppPath, appConstants.CONFIG_DIR);
if (!dirFileExists(configOptionalFeaturePath)) {
createDir(configOptionalFeaturePath);
}
return path.join(microAppPath, appConstants.CONFIG_DIR, feature);
}
function checkDirAndCopy({ opFeatTemplate, microAppPath, feature }) {
let status = false;
if (dirFileExists(opFeatTemplate)) {
const destinationOpFeatureDir = getDestionPath(microAppPath, feature);
if (!dirFileExists(destinationOpFeatureDir)) {
createDir(destinationOpFeatureDir);
}
copyDir(opFeatTemplate, destinationOpFeatureDir, []);
status = true;
}
return status;
}
function copySWSetup({ opFeatTemplate, microAppPath }) {
loggerUtil({
serverity: 'info',
color: 'blue',
message: 'copying service worker setup and guide..'
});
const isSuccess = checkDirAndCopy({
opFeatTemplate,
microAppPath,
feature: appConstants.SERVICE_WORKER
});
if (isSuccess) {
loggerUtil({
serverity: 'info',
color: 'default',
message: `Service worker config is copied successfully. Refer readme.md file create in the config/service-worker dir for next steps.`
});
} else {
loggerUtil({
serverity: 'error',
color: 'red',
message: `Service worker config missing. skipping Service worker setup...`
});
}
}
function copyPWASetup({ opFeatTemplate, microAppPath }) {
loggerUtil({
serverity: 'info',
color: 'blue',
message: 'copying pwa setup guide..'
});
const isSuccess = checkDirAndCopy({
opFeatTemplate,
microAppPath,
feature: appConstants.PWA
});
if (isSuccess) {
loggerUtil({
serverity: 'info',
color: 'default',
message: `PWA guide is copied successfully. Refer readme.md file create in the config/pwa dir for next steps.`
});
} else {
loggerUtil({
serverity: 'error',
color: 'red',
message: `PWA config missing. skipping PWA setup...`
});
}
}
module.exports = {
[appConstants.SERVICE_WORKER]: copySWSetup,
pwa: copyPWASetup
};