@wavemaker/angular-codegen 12.0.0-next.46502 → 12.0.0-next.47809

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.
Files changed (199) hide show
  1. {angular-codegen → package}/angular-app/angular.json +38 -19
  2. {angular-codegen → package}/angular-app/build-scripts/build.js +1 -0
  3. {angular-codegen → package}/angular-app/build-scripts/post-build.js +16 -110
  4. package/angular-app/dependency-report.html +124 -0
  5. package/angular-app/generate-dependency-report.js +240 -0
  6. package/angular-app/npm-shrinkwrap.json +25765 -0
  7. {angular-codegen → package}/angular-app/package-lock.json +12424 -10431
  8. {angular-codegen → package}/angular-app/package.json +51 -43
  9. package/angular-app/src/app/lazy-load-scripts.resolve.ts +13 -0
  10. package/angular-app/src/assets/styles/css/wm-style.css +1 -0
  11. package/angular-app/src/framework/services/customwidget-config-provider.service.ts +13 -0
  12. package/angular-app/src/framework/util/page-util.ts +7 -0
  13. {angular-codegen → package}/angular-app/src/index.html +1 -1
  14. package/angular-app/src/main.ts +61 -0
  15. {angular-codegen → package}/angular-app/src/setup-jest.js +4 -1
  16. angular-codegen/angular-app/tsconfig.web-app.json → package/angular-app/tsconfig.json +15 -23
  17. package/angular-app/tsconfig.web-app.json +81 -0
  18. {angular-codegen → package}/angular-app/wm-custom-webpack.config.js +18 -0
  19. package/build-angular-app.js +501 -0
  20. package/dependencies/app.component.html +40 -0
  21. package/dependencies/custom-widgets-bundle.cjs.js +415 -0
  22. {angular-codegen → package}/dependencies/expression-parser.cjs.js +13920 -17378
  23. {angular-codegen → package}/dependencies/pipe-provider.cjs.js +63958 -38833
  24. {angular-codegen → package}/dependencies/transpilation-web.cjs.js +37524 -24755
  25. package/download-packages.js +149 -0
  26. {angular-codegen → package}/generate-angular-app.js +3 -1
  27. package/npm-shrinkwrap.json +8121 -0
  28. package/package-lock.json +8121 -0
  29. {angular-codegen → package}/package.json +9 -3
  30. package/src/codegen-args-cli.js +1 -0
  31. package/src/codegen-cli.js +1 -0
  32. package/src/codegen.js +1 -0
  33. package/src/copy-utils.js +1 -0
  34. package/src/eslintrc_config.js +1 -0
  35. package/src/gen-app-codegen-module.js +1 -0
  36. package/src/gen-app-override-css.js +1 -0
  37. package/src/gen-app-routes.js +1 -0
  38. package/src/gen-app-skeleton.js +1 -0
  39. package/src/gen-components.js +1 -0
  40. package/src/gen-customwidget-config.js +1 -0
  41. package/src/gen-index-html.js +1 -0
  42. package/src/gen-layouts.js +1 -0
  43. package/src/handlebar-helpers.js +1 -0
  44. package/src/pages-util.js +1 -0
  45. package/src/project-meta.js +1 -0
  46. package/src/update-angular-json.js +1 -0
  47. package/src/wm-utils.js +1 -0
  48. {angular-codegen → package}/templates/app-routes.ts.hbs +2 -2
  49. package/templates/app.config.ts.hbs +128 -0
  50. {angular-codegen → package}/templates/app.module.ts.hbs +5 -3
  51. package/templates/component.config.ts.hbs +1 -0
  52. package/templates/customwidget/customwidget-config.ts.hbs +6 -0
  53. package/templates/customwidget/customwidget.component.script.js.hbs +3 -0
  54. package/templates/customwidget/customwidget.component.ts.hbs +43 -0
  55. {angular-codegen → package}/templates/layout/layout.component.ts.hbs +26 -4
  56. package/templates/page/page.component.ts.hbs +76 -0
  57. {angular-codegen → package}/templates/page/page.module.ts.hbs +12 -1
  58. angular-codegen/angular-app/src/app/lazy-load-scripts.resolve.ts +0 -20
  59. angular-codegen/angular-app/src/assets/styles/css/wm-style.css +0 -1
  60. angular-codegen/angular-app/src/framework/util/page-util.ts +0 -5
  61. angular-codegen/angular-app/src/main.ts +0 -30
  62. angular-codegen/angular-app/tsconfig.json +0 -131
  63. angular-codegen/build-angular-app.js +0 -79
  64. angular-codegen/dependencies/app.component.html +0 -28
  65. angular-codegen/dependencies/transpilation-mobile.cjs.js +0 -93296
  66. angular-codegen/download-packages.js +0 -69
  67. angular-codegen/package-lock.json +0 -6059
  68. angular-codegen/src/codegen-args-cli.js +0 -1
  69. angular-codegen/src/codegen-cli.js +0 -1
  70. angular-codegen/src/codegen.js +0 -1
  71. angular-codegen/src/gen-app-codegen-module.js +0 -1
  72. angular-codegen/src/gen-app-routes.js +0 -1
  73. angular-codegen/src/gen-app-skeleton.js +0 -1
  74. angular-codegen/src/gen-components.js +0 -1
  75. angular-codegen/src/gen-index-html.js +0 -1
  76. angular-codegen/src/gen-layouts.js +0 -1
  77. angular-codegen/src/handlebar-helpers.js +0 -1
  78. angular-codegen/src/pages-util.js +0 -1
  79. angular-codegen/src/project-meta.js +0 -1
  80. angular-codegen/src/update-angular-json.js +0 -1
  81. angular-codegen/src/wm-utils.js +0 -1
  82. angular-codegen/templates/page/page.component.ts.hbs +0 -45
  83. {angular-codegen → package}/.npmrc +0 -0
  84. {angular-codegen → package}/angular-app/.npmrc +0 -0
  85. {angular-codegen → package}/angular-app/build-scripts/index-html-transform.js +0 -0
  86. {angular-codegen → package}/angular-app/build-scripts/optimize-css.gulpfile.js +0 -0
  87. {angular-codegen → package}/angular-app/build-scripts/update-version.js +0 -0
  88. {angular-codegen → package}/angular-app/src/.browserslistrc +0 -0
  89. {angular-codegen → package}/angular-app/src/app/app-codegen.module.ts +0 -0
  90. {angular-codegen → package}/angular-app/src/app/app.component.css +0 -0
  91. {angular-codegen → package}/angular-app/src/app/app.component.script.js +0 -0
  92. {angular-codegen → package}/angular-app/src/app/app.component.variables.ts +0 -0
  93. {angular-codegen → package}/angular-app/src/app/app.routes.ts +0 -0
  94. {angular-codegen → package}/angular-app/src/app/prefabs/prefab-config.js +0 -0
  95. {angular-codegen → package}/angular-app/src/app/wm-project-properties.ts +0 -0
  96. {angular-codegen → package}/angular-app/src/assets/.gitkeep +0 -0
  97. {angular-codegen → package}/angular-app/src/assets/print.css +0 -0
  98. {angular-codegen → package}/angular-app/src/assets/styles/css/bootstrap.css.map +0 -0
  99. {angular-codegen → package}/angular-app/src/assets/styles/css/font/summernote.eot +0 -0
  100. {angular-codegen → package}/angular-app/src/assets/styles/css/font/summernote.ttf +0 -0
  101. {angular-codegen → package}/angular-app/src/assets/styles/css/font/summernote.woff +0 -0
  102. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  103. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  104. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  105. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  106. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  107. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  108. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  109. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  110. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-icons_222222_256x240.png +0 -0
  111. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-icons_2e83ff_256x240.png +0 -0
  112. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-icons_444444_256x240.png +0 -0
  113. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-icons_454545_256x240.png +0 -0
  114. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-icons_555555_256x240.png +0 -0
  115. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-icons_777620_256x240.png +0 -0
  116. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-icons_777777_256x240.png +0 -0
  117. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-icons_888888_256x240.png +0 -0
  118. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-icons_cc0000_256x240.png +0 -0
  119. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-icons_cd0a0a_256x240.png +0 -0
  120. {angular-codegen → package}/angular-app/src/assets/styles/css/images/ui-icons_ffffff_256x240.png +0 -0
  121. {angular-codegen → package}/angular-app/src/assets/styles/css/wm-responsive.css +0 -0
  122. {angular-codegen → package}/angular-app/src/assets/styles/fonts/FontAwesome.otf +0 -0
  123. {angular-codegen → package}/angular-app/src/assets/styles/fonts/fontawesome-webfont.eot +0 -0
  124. {angular-codegen → package}/angular-app/src/assets/styles/fonts/fontawesome-webfont.svg +0 -0
  125. {angular-codegen → package}/angular-app/src/assets/styles/fonts/fontawesome-webfont.ttf +0 -0
  126. {angular-codegen → package}/angular-app/src/assets/styles/fonts/fontawesome-webfont.woff +0 -0
  127. {angular-codegen → package}/angular-app/src/assets/styles/fonts/fontawesome-webfont.woff2 +0 -0
  128. {angular-codegen → package}/angular-app/src/assets/styles/fonts/glyphicons-halflings-regular.eot +0 -0
  129. {angular-codegen → package}/angular-app/src/assets/styles/fonts/glyphicons-halflings-regular.svg +0 -0
  130. {angular-codegen → package}/angular-app/src/assets/styles/fonts/glyphicons-halflings-regular.ttf +0 -0
  131. {angular-codegen → package}/angular-app/src/assets/styles/fonts/glyphicons-halflings-regular.woff +0 -0
  132. {angular-codegen → package}/angular-app/src/assets/styles/fonts/glyphicons-halflings-regular.woff2 +0 -0
  133. {angular-codegen → package}/angular-app/src/assets/styles/fonts/wavicon.eot +0 -0
  134. {angular-codegen → package}/angular-app/src/assets/styles/fonts/wavicon.ttf +0 -0
  135. {angular-codegen → package}/angular-app/src/assets/styles/fonts/wavicon.woff +0 -0
  136. {angular-codegen → package}/angular-app/src/assets/styles/fonts/wm-streamline-light-icon.eot +0 -0
  137. {angular-codegen → package}/angular-app/src/assets/styles/fonts/wm-streamline-light-icon.ttf +0 -0
  138. {angular-codegen → package}/angular-app/src/assets/styles/fonts/wm-streamline-light-icon.woff +0 -0
  139. {angular-codegen → package}/angular-app/src/assets/styles/fonts/wm-streamline-regular-icon.eot +0 -0
  140. {angular-codegen → package}/angular-app/src/assets/styles/fonts/wm-streamline-regular-icon.ttf +0 -0
  141. {angular-codegen → package}/angular-app/src/assets/styles/fonts/wm-streamline-regular-icon.woff +0 -0
  142. {angular-codegen → package}/angular-app/src/assets/styles/images/live-sync-icon.png +0 -0
  143. {angular-codegen → package}/angular-app/src/assets/styles/images/live-sync-touch-icon.png +0 -0
  144. {angular-codegen → package}/angular-app/src/assets/styles/images/loader.gif +0 -0
  145. {angular-codegen → package}/angular-app/src/assets/styles/images/spinner-small.gif +0 -0
  146. {angular-codegen → package}/angular-app/src/assets/styles/images/ui-icons.png +0 -0
  147. {angular-codegen → package}/angular-app/src/environments/environment.dev.ts +0 -0
  148. {angular-codegen → package}/angular-app/src/environments/environment.prod.ts +0 -0
  149. {angular-codegen → package}/angular-app/src/environments/environment.ts +0 -0
  150. {angular-codegen → package}/angular-app/src/framework/angular1.polyfills.ts +0 -0
  151. {angular-codegen → package}/angular-app/src/framework/services/app-extension.service.ts +0 -0
  152. {angular-codegen → package}/angular-app/src/framework/services/app-js-provider.service.ts +0 -0
  153. {angular-codegen → package}/angular-app/src/framework/services/app-variables-provider.service.ts +0 -0
  154. {angular-codegen → package}/angular-app/src/framework/services/component-ref-provider.service.ts +0 -0
  155. {angular-codegen → package}/angular-app/src/framework/services/lazy-component-ref-provider.service.ts +0 -0
  156. {angular-codegen → package}/angular-app/src/framework/services/prefab-config-provider.service.ts +0 -0
  157. {angular-codegen → package}/angular-app/src/framework/util/lazy-module-routes.ts +0 -0
  158. {angular-codegen → package}/angular-app/src/polyfills.ts +0 -0
  159. {angular-codegen → package}/angular-app/src/styles.css +0 -0
  160. {angular-codegen → package}/angular-app/src/tsconfig.app.json +0 -0
  161. {angular-codegen → package}/angular-app/src/tslint.json +0 -0
  162. {angular-codegen → package}/build-util.js +0 -0
  163. {angular-codegen → package}/pwa-assets/icons/icon-128x128.png +0 -0
  164. {angular-codegen → package}/pwa-assets/icons/icon-144x144.png +0 -0
  165. {angular-codegen → package}/pwa-assets/icons/icon-152x152.png +0 -0
  166. {angular-codegen → package}/pwa-assets/icons/icon-192x192.png +0 -0
  167. {angular-codegen → package}/pwa-assets/icons/icon-384x384.png +0 -0
  168. {angular-codegen → package}/pwa-assets/icons/icon-512x512.png +0 -0
  169. {angular-codegen → package}/pwa-assets/icons/icon-72x72.png +0 -0
  170. {angular-codegen → package}/pwa-assets/icons/icon-96x96.png +0 -0
  171. {angular-codegen → package}/pwa-assets/manifest.json +0 -0
  172. {angular-codegen → package}/pwa-assets/ngsw-config.json +0 -0
  173. {angular-codegen → package}/pwa-assets/wmsw-worker.js +0 -0
  174. {angular-codegen → package}/src/expr-parser-utils.js +0 -0
  175. {angular-codegen → package}/src/gen-app-js.js +0 -0
  176. {angular-codegen → package}/src/gen-app-prefabs-module.js +0 -0
  177. {angular-codegen → package}/src/gen-app-variables.js +0 -0
  178. {angular-codegen → package}/src/gen-lazy-module-routes.js +0 -0
  179. {angular-codegen → package}/src/gen-prefabs.js +0 -0
  180. {angular-codegen → package}/src/gen-pwa-files.js +0 -0
  181. {angular-codegen → package}/src/gen-tsconfig.js +0 -0
  182. {angular-codegen → package}/src/gen-wm-project-properties.js +0 -0
  183. {angular-codegen → package}/templates/app-codegen.module.ts.hbs +0 -0
  184. {angular-codegen → package}/templates/app-prefabs.module.ts.hbs +0 -0
  185. {angular-codegen → package}/templates/app.component.script.js.hbs +0 -0
  186. {angular-codegen → package}/templates/component.expressions.ts.hbs +0 -0
  187. {angular-codegen → package}/templates/component.variables.ts.hbs +0 -0
  188. {angular-codegen → package}/templates/expr-vs-fn.hbs +0 -0
  189. {angular-codegen → package}/templates/layout/layout.module.ts.hbs +0 -0
  190. {angular-codegen → package}/templates/lazy-module-routes.ts.hbs +0 -0
  191. {angular-codegen → package}/templates/page/page.component.script.js.hbs +0 -0
  192. {angular-codegen → package}/templates/partial/partial.component.script.js.hbs +0 -0
  193. {angular-codegen → package}/templates/partial/partial.component.ts.hbs +0 -0
  194. {angular-codegen → package}/templates/partial/partial.module.ts.hbs +0 -0
  195. {angular-codegen → package}/templates/prefab/prefab-config.ts.hbs +0 -0
  196. {angular-codegen → package}/templates/prefab/prefab.component.script.js.hbs +0 -0
  197. {angular-codegen → package}/templates/prefab/prefab.component.ts.hbs +0 -0
  198. {angular-codegen → package}/templates/prefab/prefab.module.ts.hbs +0 -0
  199. {angular-codegen → package}/templates/wm-project-properties.ts.hbs +0 -0
@@ -0,0 +1,501 @@
1
+
2
+ /**
3
+ * Download and install the app-ng-runtime package
4
+ * Run the build and post build for the generated angular app.
5
+ *
6
+ * CONSOLE ARGUMENTS:-
7
+ * nodeVMArgs:String: Node environment params (Eg: '--max-old-space-size=2040')
8
+ * ngBuildParams:String: Anglar build params (Eg: '--prod=true --source-map=false')
9
+ * runtimeUIVersion:String: Runtime version (Eg: 10.6.6-next.10243)
10
+ * appSrc:String: Source folder to generate the angular app (current directory Eg: '.')
11
+ * appTarget:String: Target folder to save the generated app (Eg: 'target/ui-build/generated-app')
12
+ * codegenPath:String: Input to the codegen-CLI --> Codegen installation path to copy the angular-template-app
13
+ * optimizeUIBuild : By default this flag will be true. If it's windows platform we are making the flag to false, it means no optimisation for windows.
14
+ */
15
+ const fs = require('fs');
16
+ const rimraf = require('rimraf');
17
+ const { downloadNPMPackage } = require('./download-packages');
18
+ const { generateRandomHash } = require('./src/wm-utils');
19
+ const archiver = require('archiver');
20
+ const path = require("path");
21
+ const { executeSyncCmd, MSG_NG_RUNTIME_LOG, MSG_NG_RUNTIME_SUCCESS } = require('./build-util');
22
+ const os = require("os");
23
+ const cheerio = require(`cheerio`);
24
+
25
+ const NPM_PACKAGE_SCOPE = '@wavemaker';
26
+ const BUILD_TYPE = { WM: 'wm', ANGULAR: 'angular' };
27
+
28
+ const UI_BUILD_ERROR_LOG = 'UI BUILD ERROR';
29
+ const MSG_CODEGEN_LOG = 'CODEGEN ANGULAR APP: ';
30
+ const MSG_APP_RUNTIME_WM_BUILD_LOG = 'APP RUNTIME WM BUILD : ';
31
+ const MSG_APP_RUNTIME_WM_BUILD_SUCCESS = 'WAVEMAKER_APP_RUNTIME_WM_BUILD_SUCCESS';
32
+
33
+ const ANGULAR_APP_TEMPLATE_NAME = "angular-app";
34
+
35
+ /**
36
+ * @TODO: This is a temporary workaround to extract deploy-url from 'ngBuildParams', need to be replaced in future.
37
+ */
38
+ const updateDeployUrl = (args) => {
39
+ let buildArgs = args.ngBuildParams.split(' ');
40
+ const deployParam = buildArgs.find(i => i.startsWith("--deploy-url="));
41
+ if(!deployParam) {
42
+ buildArgs.push(`--deploy-url=ng-bundle/${global.randomHash}/`);
43
+ } else {
44
+ buildArgs.filter((param, index) => {
45
+ if (param.includes('--deploy-url=_cdnUrl_')) {
46
+ buildArgs[index] = `--deploy-url=_cdnUrl_/ng-bundle/${global.randomHash}/`
47
+ return true;
48
+ }
49
+ });
50
+ }
51
+ buildArgs.push(args.nodeVMArgs);
52
+ return buildArgs.join(" ");
53
+ };
54
+ /**
55
+ *
56
+ * @param sourcePath
57
+ * @param targetPath
58
+ * @param packageName
59
+ * @param isOptimized
60
+ */
61
+ const processAngularAppPackage = async (sourcePath, targetPath, packageName, isOptimized) => {
62
+ const ANGULAR_APP_TARBALL_NAME = 'wavemaker' + '-' + ANGULAR_APP_TEMPLATE_NAME + '-' + global.buildConfigObj.runtimeUIVersion + '.tgz';
63
+ try {
64
+ // Download the package as a tarball
65
+ executeSyncCmd(
66
+ `cd ${sourcePath} && npm pack ${packageName}`,
67
+ (e) => { throw new Error(`Failed to download package: ${packageName}, Error: ${e}`); },
68
+ `Downloading tarball - ${packageName} to ${sourcePath}`
69
+ );
70
+ // Extract the tarball
71
+ executeSyncCmd(
72
+ `cd ${sourcePath} && tar -xvf ${ANGULAR_APP_TARBALL_NAME}`,
73
+ (e) => { throw new Error(`Failed to extract package: ${packageName}, Error: ${e}`); },
74
+ `Unzipping tarball - ${ANGULAR_APP_TARBALL_NAME}`
75
+ );
76
+
77
+ // Copy essential files
78
+ ['package.json', 'package-lock.json', '.npmrc'].forEach(file => {
79
+ fs.copyFileSync( path.join(sourcePath, 'package', file), path.join(targetPath, file) );
80
+ });
81
+
82
+ // Install dependencies
83
+ const installPath = isOptimized ? sourcePath : targetPath;
84
+ let npmCommnd = `npm install --prefix ${installPath}`
85
+ // For windows platforms, npm install command needs to be executed in the same directory as package.json file
86
+ if (os.platform() === 'win32') {
87
+ npmCommnd = `cd ${installPath} && ${npmCommnd}`
88
+ }
89
+ executeSyncCmd(
90
+ `${npmCommnd}`,
91
+ (e) => { throw new Error(`Failed to install dependencies: ${packageName}, Error: ${e}`); },
92
+ `Installing app dependencies to ${installPath}`
93
+ );
94
+ } catch (error) {
95
+ if (isOptimized) rimraf.sync(`${sourcePath}/node_modules`);
96
+ throw new Error(`Something went wrong : ${packageName}, Error: ${error}`);
97
+ }
98
+ };
99
+
100
+ /**
101
+ *
102
+ * @param lockFile
103
+ * @param timeout
104
+ * @returns {Promise<void>}
105
+ */
106
+ const waitForLock = async (lockFile, timeout) => {
107
+ timeout = timeout || 20 * 60 * 1000 // Wait for 20 minutes (timeout in milliseconds)
108
+ // Helper function to wait for the lock to be released with a timeout
109
+ const startTime = Date.now();
110
+ while (fs.existsSync(lockFile)) {
111
+ if (Date.now() - startTime > timeout) {
112
+ console.error('Timeout!! - waiting for the lock to be released. Exiting...');
113
+ process.exit(1); // Terminate the process with an error code
114
+ }
115
+ await sleep(1000); // Wait for 1 second before checking again
116
+ }
117
+ };
118
+
119
+ /**
120
+ *
121
+ * @param ms
122
+ * @returns {Promise<unknown>}
123
+ */
124
+ const sleep = (ms) => {
125
+ // Helper function to sleep for a given time
126
+ return new Promise(resolve => setTimeout(resolve, ms));
127
+ };
128
+
129
+ /**
130
+ * Download the app runtime package
131
+ * Symlink to reuse the existing node modules (If windows optimizeUIBuild will be false and install all node modules every build )
132
+ * Run the ng build and post build for the project
133
+ */
134
+ const buildAngularApp = async (args) => {
135
+ const HOME_DIR = os.homedir();
136
+ let TARBALL_DOWNLOAD_PATH = path.join((path.join(HOME_DIR, '.wm', 'node_modules')), ANGULAR_APP_TEMPLATE_NAME, args.runtimeUIVersion);
137
+ const PACKAGE_NAME = NPM_PACKAGE_SCOPE + '/' + ANGULAR_APP_TEMPLATE_NAME + '@' + global.buildConfigObj.runtimeUIVersion;
138
+ const SUCCESS_FILE = path.join(TARBALL_DOWNLOAD_PATH, ".SUCCESS"), LOCK_FILE = path.join(TARBALL_DOWNLOAD_PATH, ".LOCK");
139
+
140
+ //to handle windows build(optimizeUIBuild will be false for windows)
141
+ TARBALL_DOWNLOAD_PATH = args.optimizeUIBuild ? TARBALL_DOWNLOAD_PATH : args.appTarget;
142
+ const ANGULAR_APP_TARBALL_NAME = 'wavemaker' + '-' + ANGULAR_APP_TEMPLATE_NAME + '-' + global.buildConfigObj.runtimeUIVersion + '.tgz';
143
+
144
+ fs.mkdirSync(TARBALL_DOWNLOAD_PATH, { recursive: true });
145
+
146
+ try {
147
+ if (args.optimizeUIBuild) {
148
+ if (!fs.existsSync(SUCCESS_FILE)) {
149
+ // Check if another process is already installing
150
+ if (fs.existsSync(LOCK_FILE)) {
151
+ console.log(`Waiting for another build to complete npm install... for package ${PACKAGE_NAME}`);
152
+ await waitForLock(LOCK_FILE, 20 * 60 * 1000); // Wait for 20 minutes (timeout in milliseconds)
153
+ } else {
154
+ // Acquire the lock
155
+ fs.mkdirSync(TARBALL_DOWNLOAD_PATH, { recursive: true });
156
+ fs.writeFileSync(LOCK_FILE, "PROGRESS");
157
+ await processAngularAppPackage(TARBALL_DOWNLOAD_PATH, TARBALL_DOWNLOAD_PATH, PACKAGE_NAME, true);
158
+ fs.writeFileSync(SUCCESS_FILE, "SUCCESS");
159
+ }
160
+ } else {
161
+ console.log(`node_modules for angular-app already installed - ${TARBALL_DOWNLOAD_PATH}`);
162
+ }
163
+ console.log(`Symlinking the node_modules to angular-app - ${args.appTarget}`);
164
+ fs.symlinkSync( `${TARBALL_DOWNLOAD_PATH}/node_modules`,`${args.appTarget}/node_modules`,'dir');
165
+ } else {
166
+ await processAngularAppPackage(TARBALL_DOWNLOAD_PATH, args.appTarget, PACKAGE_NAME, false);
167
+ }
168
+ } catch (err) {
169
+ deleteFiles([SUCCESS_FILE, LOCK_FILE])
170
+ console.log(MSG_NG_RUNTIME_LOG + `Something went wrong - for package ${PACKAGE_NAME}`, err);
171
+ process.exit(err.code || err.pid);
172
+ } finally {
173
+ //cleanup : in windows / optimizeUIBuild is false, we need to delete the temp downloaded package
174
+ if (args.optimizeUIBuild) {
175
+ deleteFiles([path.join(TARBALL_DOWNLOAD_PATH, 'package'), path.join(TARBALL_DOWNLOAD_PATH, ANGULAR_APP_TARBALL_NAME), LOCK_FILE])
176
+ }
177
+ }
178
+
179
+ let ngBuildParams = updateDeployUrl(args);
180
+ const NG_BUILD_MSG = 'NG BUILD MIGHT HAVE FAILED WITH HEAP OUT OF MEMORY, RE-EXECUTE THE BUILD BY INCREASING THE MAX-OLD-SPACE-SIZE ARGUMENT VALUE FOR BUILD.UI.NODE.ARGS PROPERTY IN DEPLOYMENT PROFILE';
181
+ // Generating the angular build and post build process.
182
+ executeSyncCmd('cd ' + args.appTarget + ' && node ./build-scripts/build.js ' + ngBuildParams, null, MSG_NG_RUNTIME_LOG, false, NG_BUILD_MSG);
183
+ }
184
+
185
+ /**
186
+ *
187
+ */
188
+ const deleteFiles = (files) => {
189
+ files.forEach(file => {
190
+ try {
191
+ rimraf.sync(file);
192
+ console.log(`Successfully deleted file - ${file}`);
193
+ } catch (err) {
194
+ console.error(`Error while deleting file ${file}`, err);
195
+ throw new Error(`Error while deleting file: ${file}, Error: ${err}`);
196
+ }
197
+ });
198
+ }
199
+
200
+ const generateUiZip = async( sourceDir ) => {
201
+ return new Promise((resolve, reject) => {
202
+ const distDir = path.resolve(sourceDir + '/target/ui-build/output-files');
203
+ const zipFile = path.resolve(sourceDir + '/target/ui-artifact.zip');
204
+
205
+ const output = fs.createWriteStream(zipFile);
206
+ const archive = archiver('zip', {
207
+ zlib: {level: 9}
208
+ });
209
+ output.on('close', () => {
210
+ console.log(`✅ ui-artifact.zip created successfully: ${zipFile}`);
211
+ resolve();
212
+ });
213
+ archive.on('error', (err) => {
214
+ reject(err);
215
+ });
216
+ archive.pipe(output);
217
+ archive.directory(distDir, false);
218
+ archive.finalize();
219
+ });
220
+ }
221
+
222
+ const updateWarIndexHtml = async( sourceDir ) => {
223
+ const destDir = path.resolve(sourceDir + '/target/ui-build/output-files');
224
+ let indexHtml = fs.readFileSync(destDir + '/index.html', 'utf8');
225
+
226
+ const $ = cheerio.load(indexHtml);
227
+ const cdnMetaTag = $('meta[name="cdnUrl"]');
228
+ const cdnUrl = cdnMetaTag.length > 0 ? cdnMetaTag.attr('content') : `ng-bundle/${global.randomHash}/`;
229
+
230
+ $('*').each((_, element) => {
231
+ if (element.tagName === 'meta' && $(element).attr('name') === 'cdnUrl') {
232
+ $(element).attr('content', `ng-bundle/${global.randomHash}/`)
233
+ return;
234
+ }
235
+ const attributes = element.attribs;
236
+ for (const attrName in attributes) {
237
+ if (attributes[attrName].includes(cdnUrl)) {
238
+ attributes[attrName] = attributes[attrName].replace(cdnUrl, `_cdnUrl_/ng-bundle/${global.randomHash}/`);
239
+ }
240
+ }
241
+ });
242
+
243
+ const updatedHtml = $.html();
244
+ fs.writeFileSync(destDir + '/index.html', updatedHtml);
245
+ console.log(`✅ Updated index.html in the war file`);
246
+ }
247
+
248
+ /**
249
+ * sample obj param structure
250
+ * buildConfigObj = {
251
+ * runtimeUIVersion: args.runtimeUIVersion ,
252
+ * codegenPath: pathAngularCodegen,
253
+ * optimizeUIBuild: angularBuildConfig.optimizeUIBuild,
254
+ * appTarget: angularBuildConfig.appTarget,
255
+ * appSrc: angularBuildConfig.sourceDir,
256
+ * nodeVMArgs: args.nodeVMArgs,
257
+ * ngBuildParams: ngBuildParams
258
+ * }
259
+ * @param buildConfigObj
260
+ * @returns {Promise<void>}
261
+ */
262
+ const postBuild = async( buildConfigObj ) => {
263
+ console.log(`Running post build ops with the build config ${JSON.stringify(buildConfigObj)}`);
264
+ await generateUiZip(buildConfigObj.appSrc);
265
+ await updateWarIndexHtml(buildConfigObj.appSrc);
266
+ }
267
+
268
+ /**
269
+ * Read the console arguments and prepare the object.
270
+ * @returns console arguments as key value pairs
271
+ */
272
+ const getArgs = (customArgs) => {
273
+ const args = {};
274
+ let arguments = customArgs || process.argv;
275
+ arguments = customArgs ? customArgs : arguments.slice(2, arguments.length);
276
+ arguments.forEach(arg => {
277
+ if (arg.slice(0, 2) === '--') {
278
+ const longArg = arg.split('=');
279
+ const longArgFlag = longArg[0].slice(2, longArg[0].length);
280
+ let longArgValue = longArg.length > 2 ? longArg.slice(1, longArg.length).join('=') : longArg[1];
281
+ if (longArgFlag === "cdnUrl") {
282
+ longArgValue = longArgValue === "" ? "./" : longArgValue;
283
+ }
284
+ args[longArgFlag] = longArgValue;
285
+ }
286
+ });
287
+ return args;
288
+ }
289
+
290
+ /**
291
+ * Copy source to destination each file by navigating to the folder recursively
292
+ * @param {string} src Source folder to copy.
293
+ * @param {string} dest Destination folder to copy.
294
+ */
295
+ const copyRecursiveSync = (src, dest) => {
296
+ let exists = fs.existsSync(src), stats = exists && fs.statSync(src), isDirectory = exists && stats.isDirectory();
297
+ if (isDirectory) {
298
+ if (!fs.existsSync(dest)) {
299
+ fs.mkdirSync(dest, { recursive: true });
300
+ }
301
+ fs.readdirSync(src).forEach(function (childItemName) {
302
+ copyRecursiveSync(src + '/' + childItemName, dest + '/' + childItemName);
303
+ });
304
+ } else {
305
+ fs.copyFileSync(src, dest);
306
+ }
307
+ };
308
+
309
+ /**
310
+ * Check the app-runtime-wm-build npm package already installed or not.
311
+ * Install the app-runtime-wm-build if package not yet installed.
312
+ * Based on the platform type copy the bundle script into '/src/main/webapp'
313
+ * @param {*} sourceDir
314
+ * @param {*} baseDir
315
+ * @returns
316
+ */
317
+ const buildAppInWMMode = async (sourceDir, baseDir) => {
318
+
319
+ /**
320
+ * Download app-runtime-wm-build package and install if it doesn't exist
321
+ */
322
+ let appRuntimeWMBuildPackageInfo = {
323
+ scope: NPM_PACKAGE_SCOPE,
324
+ version: global.buildConfigObj.runtimeUIVersion,
325
+ name: 'app-runtime-wm-build',
326
+ packageJsonFile: '',
327
+ successMsg: MSG_APP_RUNTIME_WM_BUILD_SUCCESS,
328
+ infoMsg: MSG_APP_RUNTIME_WM_BUILD_LOG
329
+ };
330
+
331
+ appRuntimeWMBuildPackageInfo.baseDir = baseDir;
332
+ const PATH_WAVEMAKER_APP_RUNTIME_WM_BUILD = await downloadNPMPackage(appRuntimeWMBuildPackageInfo);
333
+
334
+ const FILE_PATH_WAVEMAKER_APP_RUNTIME_WM_BUILD = PATH_WAVEMAKER_APP_RUNTIME_WM_BUILD + '/node_modules/' + appRuntimeWMBuildPackageInfo.scope + '/' + appRuntimeWMBuildPackageInfo.name + '/';
335
+
336
+ const PLATFORM_TYPE = { WEB: 'wmapp', MOBILE: 'wmmobile' }
337
+ let bundleFolder = '';
338
+ if (global.buildConfigObj.platformType === PLATFORM_TYPE.WEB) {
339
+ bundleFolder = 'wmapp/';
340
+ } else if (global.buildConfigObj.platformType = PLATFORM_TYPE.MOBILE) {
341
+ bundleFolder = 'wmmobile/';
342
+ } else {
343
+ console.log(UI_BUILD_ERROR_LOG + ' Invalid script path!');
344
+ return;
345
+ }
346
+ copyRecursiveSync(FILE_PATH_WAVEMAKER_APP_RUNTIME_WM_BUILD + bundleFolder, sourceDir + '/target/ui-build/output-files/' + bundleFolder);
347
+ }
348
+
349
+ /**
350
+ *
351
+ * @param {*} sourceDir project source directory to generate the angular app
352
+ * @param {*} ngBuildParams angular app build params along with cdn URL
353
+ * @param {*} codegenPath codegen path to generate the angular app
354
+ * Generate the angular app from codegen in target folder
355
+ */
356
+ const generateAngularApp = async (sourceDir, ngBuildParams, codegenPath, appTarget, baseDir) => {
357
+ const CODEGEN_PATH = codegenPath + 'src/codegen-cli.js';
358
+ if (fs.existsSync(CODEGEN_PATH)) {
359
+ let deployUrl = `ng-bundle/${global.randomHash}/`;
360
+ if(ngBuildParams) {
361
+ let buildArgs = getArgs(ngBuildParams.split(' '));
362
+ if (buildArgs && buildArgs["deploy-url"]) {
363
+ deployUrl = buildArgs["deploy-url"];
364
+ }
365
+ }
366
+ const { generateCodegenAngularApp } = require(CODEGEN_PATH);
367
+ console.log(MSG_CODEGEN_LOG + 'Generating the angular App...');
368
+ let apiUrl = global.buildConfigObj.apiUrl && global.buildConfigObj.apiUrl.trim() !== "" ? global.buildConfigObj.apiUrl.trim() : "./";
369
+ console.log("API-Url - ", apiUrl, " - CDN-Url - ", deployUrl);
370
+ await generateCodegenAngularApp(sourceDir, appTarget, deployUrl, (global.buildConfigObj.pwa === 'true' ? true : false), codegenPath, global.buildConfigObj.csp === 'true', global.buildConfigObj.spa === 'true', apiUrl, global.buildConfigObj, baseDir);
371
+ console.log(MSG_CODEGEN_LOG + 'Angular app generated !');
372
+ } else {
373
+ console.log(MSG_CODEGEN_LOG + " : CODEGEN-CLI not found");
374
+ }
375
+ }
376
+
377
+ /**
378
+ *
379
+ * @param {*} sourceDir
380
+ * @param {*} appTarget
381
+ * @param {*} generate_page The generated page name
382
+ * @param {*} codegenPath
383
+ */
384
+ const generateAngularAppPage = async (sourceDir, appTarget, generate_page, codegenPath) => {
385
+ const CODEGEN_PATH = codegenPath + 'src/codegen-cli.js';
386
+ if (fs.existsSync(CODEGEN_PATH)) {
387
+ const { generatePage } = require(CODEGEN_PATH);
388
+ await generatePage(sourceDir, appTarget, generate_page, codegenPath, global.buildConfigObj.csp === 'true');
389
+ } else {
390
+ console.log(MSG_CODEGEN_LOG + " : CODEGEN-CLI not found")
391
+ }
392
+
393
+ }
394
+
395
+ /**
396
+ * validate the cdn url and returns the angular build params
397
+ * @returns build params
398
+ */
399
+ const getNgBuildParams = () => {
400
+ let cdnUrl = global.buildConfigObj.cdnUrl && global.buildConfigObj.cdnUrl.trim() !== "" ? global.buildConfigObj.cdnUrl.trim() : "./";
401
+ let ngBuildParams = global.buildConfigObj.ngBuildParams;
402
+ // if the cdn url doesn't contain ng-bundle append it
403
+ // this is required for BE/FE separation. Now index.html file gets served directly from cdn bucket so there is no replacement
404
+ // happening from the server. So need to validate and properly create the URL from cdnUrl param passed and append ng-bundle
405
+ if (cdnUrl) {
406
+ cdnUrl = (cdnUrl.slice(-1) === "/" ? cdnUrl.slice(0, -1) : cdnUrl);
407
+ cdnUrl = cdnUrl + `/ng-bundle/${global.randomHash}/`;
408
+ ngBuildParams += ` --deploy-url=${cdnUrl}`;
409
+ }
410
+ return ngBuildParams;
411
+ }
412
+
413
+ /**
414
+ * Check codegen npm package already installed or not.
415
+ * Install the codegen if package not yet installed.
416
+ * Run generate and build angular script.
417
+ * Prepare the ng-build params deploy url if cdn url present in arguments
418
+ * @param {*} angularBuildConfig
419
+ * Properties: sourceDir,appTarget, baseDir
420
+ */
421
+ const buildAppInAngularMode = async (angularBuildConfig) => {
422
+ let ngBuildParams = getNgBuildParams();
423
+ let buildConfigObj = {
424
+ runtimeUIVersion: global.buildConfigObj.runtimeUIVersion,
425
+ codegenPath: global.buildConfigObj.codegenPath,
426
+ optimizeUIBuild: global.buildConfigObj.optimizeUIBuild,
427
+ appTarget: angularBuildConfig.appTarget,
428
+ appSrc: angularBuildConfig.sourceDir,
429
+ nodeVMArgs: global.buildConfigObj.nodeVMArgs,
430
+ ngBuildParams: ngBuildParams
431
+ }
432
+ await buildAngularApp(buildConfigObj);
433
+ copyRecursiveSync(angularBuildConfig.sourceDir + '/target/ui-build/generated-app/dist/', angularBuildConfig.sourceDir + '/target/ui-build/output-files/');
434
+
435
+ await postBuild(buildConfigObj)
436
+ }
437
+
438
+ /**
439
+ *
440
+ * @param
441
+ * @returns {Promise<void>}
442
+ */
443
+ const buildAsWebComponent = async () => {
444
+ let wcCommand = "npx --yes @wavemaker/webcomponents-cli -s ."
445
+ executeSyncCmd(wcCommand, () => {
446
+ console.log('Something wrong with WebComponent build');
447
+ }, 'Building WebComponent');
448
+ }
449
+
450
+ const initBuild = async (buildConfigObj) => {
451
+ global.randomHash = generateRandomHash();
452
+ //making it global
453
+ global.buildConfigObj = buildConfigObj;
454
+
455
+ let buildType = buildConfigObj.buildType, isWebComponentBuild = buildConfigObj.exportWebComponent === 'true';
456
+ if(isWebComponentBuild) {
457
+ buildType = BUILD_TYPE.ANGULAR;
458
+ }
459
+ let CODEGEN_INSTALLATION = buildConfigObj.codegenPath
460
+ const sourceDir = buildConfigObj.appSrc;
461
+ let appTarget = buildConfigObj.appTarget;
462
+
463
+ let baseDir = buildConfigObj.optimizeUIBuild ? undefined : appTarget.split('/').slice(0, -2).join('/') + '/';
464
+ if (buildConfigObj.generateOverrideCSS) {
465
+ const { generateOverrideCSS } = require(CODEGEN_INSTALLATION + 'src/gen-app-override-css.js');
466
+ await generateOverrideCSS(buildConfigObj, sourceDir, baseDir);
467
+ }
468
+ if (buildConfigObj.generate_page) {
469
+ // To generate the angular app specific page
470
+ await generateAngularAppPage(sourceDir, appTarget, buildConfigObj.generate_page, CODEGEN_INSTALLATION);
471
+ } else if (buildConfigObj.generateAngularApp) {
472
+ // TO generate the angular app
473
+ console.log('Angular app generation mode');
474
+ await generateAngularApp(sourceDir, getNgBuildParams(), CODEGEN_INSTALLATION, appTarget, baseDir);
475
+ } else if (buildType === BUILD_TYPE.WM) {
476
+ await buildAppInWMMode(sourceDir, baseDir);
477
+ } else if (buildType === BUILD_TYPE.ANGULAR) {
478
+ if(!isWebComponentBuild) {
479
+ await generateAngularApp(sourceDir, getNgBuildParams(), CODEGEN_INSTALLATION, appTarget, baseDir);
480
+ }
481
+ //pre - run the custom for this project
482
+ await global.buildConfigObj.hooks.preBuildHook();
483
+
484
+ let angularBuildConfig = {
485
+ sourceDir: sourceDir,
486
+ appTarget: appTarget,
487
+ baseDir: baseDir,
488
+ };
489
+ if(isWebComponentBuild) {
490
+ await buildAsWebComponent();
491
+ } else {
492
+ await buildAppInAngularMode(angularBuildConfig);
493
+ }
494
+ //post - run the custom for this project
495
+ await global.buildConfigObj.hooks.postBuildHook();
496
+ }
497
+ }
498
+
499
+ module.exports = {
500
+ initBuild
501
+ }
@@ -0,0 +1,40 @@
1
+ @if (startApp) {
2
+ @if(enableSkipToMainContent) {
3
+ <div id="app-focus-start" tabindex="-1"></div>
4
+ <a href="javascript:void(0);" class="skip" (click)="skipToAppContent($event)">{{appLocale.LABEL_SKIP_TO_MAIN_CONTENT || 'Skip to main content'}}</a>
5
+ }
6
+ <router-outlet></router-outlet>
7
+ @if (isApplicationType) {
8
+ <div wmContainer partialContainer content="Common" hidden class="ng-hide"></div>
9
+ }
10
+ <app-spinner name="globalspinner" classname="global-spinner" role="alert" aria-live="assertive" [attr.aria-label]="spinner.arialabel || 'Loading'" [show]="spinner.show" [spinnermessages]="spinner.messages"></app-spinner>
11
+ <div wmDialog name="oAuthLoginDialog" title="Application is requesting you to sign in with"
12
+ close.event="closeOAuthDialog()">
13
+ <ng-template #dialogBody>
14
+ <ul class="list-items">
15
+ @for (provider of providersConfig; track provider) {
16
+ <li class="list-item">
17
+ <button class="btn" (click)="provider.invoke()">{{provider.name}}</button>
18
+ </li>
19
+ }
20
+ </ul>
21
+ </ng-template>
22
+ </div>
23
+ <div wmConfirmDialog name="_app-confirm-dialog" title.bind="title" message.bind="message" oktext.bind="oktext"
24
+ canceltext.bind="canceltext" closable="false" iconclass.bind="iconclass"
25
+ escape.event="onEscape()" ok.event="onOk()" cancel.event="onCancel()" close.event="onClose()" opened.event="onOpen()"></div>
26
+ @if (!isApplicationType) {
27
+ <div wmConfirmDialog name="PrefabConfirmDialog" title.bind="title" message.bind="text" oktext.bind="okButtonText"
28
+ canceltext.bind="cancelButtonText" closable="false" iconclass.bind="iconclass"
29
+ escape.event="onEscape()" ok.event="onOk()" cancel.event="onCancel()" close.event="onClose()" opened.event="onOpen()"></div>
30
+ }
31
+ @if (!isApplicationType) {
32
+ <div wmAlertDialog name="PrefabAlertDialog" title.bind="title" message.bind="text" oktext.bind="okButtonText"
33
+ canceltext.bind="cancelButtonText" closable="false" iconclass.bind="iconclass"
34
+ escape.event="onEscape()" ok.event="onOk()" cancel.event="onCancel()" close.event="onClose()" opened.event="onOpen()"></div>
35
+ }
36
+ <div wmAppExt></div>
37
+ <i id="wm-mobile-display"></i>
38
+ }
39
+ <!--Dummy container to create the component dynamically-->
40
+ <ng-container #dynamicComponent></ng-container>