-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebcomponent.cli.js
More file actions
102 lines (90 loc) · 2.54 KB
/
Copy pathwebcomponent.cli.js
File metadata and controls
102 lines (90 loc) · 2.54 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
const {
generateNgCode,
validateProject,
updatePackageJson,
updateAngularJson,
updateMainTsFile,
updateAppConfig,
updateMainFile,
updateComponentFiles,
generateDist,
generateDummyUIBuildDir,
updatePrefabScriptFile
} = require('./update.project');
const { printFailure, updateStatus, endStatus, printHeader, initStatus} = require('./console.utils');
const { initTemplates } = require('./template.helpers');
const { logProjectMetadata, generateDocs, isPrefabProject} = require("./utils");
const path = require('path');
const {scaffoldPrefabProject} = require("./scaffold.prefab");
const fs = require("fs");
const argv = require("yargs")
.usage("Usage: $0 -s [source WaveMaker Prefab project path]")
.options({
"source": {
alias: "s",
describe: "source project web-app path",
type: "string"
}
})
.demandOption(["source"], "please provide source project")
.help()
.argv;
const addNgElementToApp = async (source) => {
updateStatus(`Generating Angular code...`);
await generateNgCode(source);
updateStatus(`Validating the generated project...`);
await validateProject(source);
updateStatus(`Updating the project files...`);
await updatePackageJson(source);
await updateAngularJson(source);
await updateMainTsFile(source);
await updateAppConfig(source);
//if(global.WMPropsObj.type === "PREFAB") {
await updateMainFile(source);
//}
if(global.WMPropsObj.type === "PREFAB"){
await updatePrefabScriptFile(source);
}
await updateComponentFiles(source);
updateStatus(`Generating documentation...`);
await generateDocs(source);
updateStatus(`Generating the dist...`);
await generateDist(source);
await generateDummyUIBuildDir(source);
};
const convertToAbsolutePath = async (source) => {
if (path.isAbsolute(source)) {
return source;
}
return path.resolve(source);
}
async function restoreBackUpWMPropsFile(sourceDir) {
const fileName = ".wmproject.properties"
const bkFileName = ".wmproject.properties.bk"
fs.copyFileSync(`${sourceDir}/${bkFileName}`, `${sourceDir}/${fileName}`);
}
(async () => {
printHeader();
argv.source = await convertToAbsolutePath(argv.source);
let sourceDir = argv.source;
await logProjectMetadata(argv.source);
initStatus();
try {
if (argv.source) {
initTemplates();
if(isPrefabProject()) {
await scaffoldPrefabProject(sourceDir)
}
updateStatus(`Transpiling the Project...`);
await addNgElementToApp(sourceDir);
if(isPrefabProject()) {
await restoreBackUpWMPropsFile(sourceDir)
}
}
} catch (e) {
printFailure(e);
} finally {
endStatus();
process.exit(0);
}
})();