@wavemaker-ai/angular-codegen 1.0.0-rc.647469

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 (177) hide show
  1. package/.npmrc +1 -0
  2. package/angular-app/.npmrc +1 -0
  3. package/angular-app/angular.json +274 -0
  4. package/angular-app/build-scripts/build.js +36 -0
  5. package/angular-app/build-scripts/index-html-transform-ng-serve.ts +20 -0
  6. package/angular-app/build-scripts/index-html-transform.js +28 -0
  7. package/angular-app/build-scripts/optimize-css.gulpfile.js +101 -0
  8. package/angular-app/build-scripts/post-build.js +217 -0
  9. package/angular-app/build-scripts/update-version.js +25 -0
  10. package/angular-app/dependency-report.html +124 -0
  11. package/angular-app/generate-dependency-report.js +240 -0
  12. package/angular-app/npm-shrinkwrap.json +24224 -0
  13. package/angular-app/package-lock.json +24224 -0
  14. package/angular-app/package.json +129 -0
  15. package/angular-app/proxy.conf.js +14 -0
  16. package/angular-app/src/.browserslistrc +12 -0
  17. package/angular-app/src/app/app.component.css +0 -0
  18. package/angular-app/src/app/app.component.script.js +3 -0
  19. package/angular-app/src/app/app.component.variables.ts +3 -0
  20. package/angular-app/src/app/app.routes.ts +5 -0
  21. package/angular-app/src/app/lazy-load-scripts.resolve.ts +13 -0
  22. package/angular-app/src/app/prefabs/prefab-config.js +2 -0
  23. package/angular-app/src/app/wm-project-properties.ts +3 -0
  24. package/angular-app/src/assets/.gitkeep +0 -0
  25. package/angular-app/src/assets/print.css +32 -0
  26. package/angular-app/src/assets/styles/css/bootstrap.css.map +1 -0
  27. package/angular-app/src/assets/styles/css/font/summernote.eot +0 -0
  28. package/angular-app/src/assets/styles/css/font/summernote.ttf +0 -0
  29. package/angular-app/src/assets/styles/css/font/summernote.woff +0 -0
  30. package/angular-app/src/assets/styles/css/font/summernote.woff2 +0 -0
  31. package/angular-app/src/assets/styles/css/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  32. package/angular-app/src/assets/styles/css/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  33. package/angular-app/src/assets/styles/css/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  34. package/angular-app/src/assets/styles/css/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  35. package/angular-app/src/assets/styles/css/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  36. package/angular-app/src/assets/styles/css/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  37. package/angular-app/src/assets/styles/css/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  38. package/angular-app/src/assets/styles/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  39. package/angular-app/src/assets/styles/css/images/ui-icons_222222_256x240.png +0 -0
  40. package/angular-app/src/assets/styles/css/images/ui-icons_2e83ff_256x240.png +0 -0
  41. package/angular-app/src/assets/styles/css/images/ui-icons_444444_256x240.png +0 -0
  42. package/angular-app/src/assets/styles/css/images/ui-icons_454545_256x240.png +0 -0
  43. package/angular-app/src/assets/styles/css/images/ui-icons_555555_256x240.png +0 -0
  44. package/angular-app/src/assets/styles/css/images/ui-icons_777620_256x240.png +0 -0
  45. package/angular-app/src/assets/styles/css/images/ui-icons_777777_256x240.png +0 -0
  46. package/angular-app/src/assets/styles/css/images/ui-icons_888888_256x240.png +0 -0
  47. package/angular-app/src/assets/styles/css/images/ui-icons_cc0000_256x240.png +0 -0
  48. package/angular-app/src/assets/styles/css/images/ui-icons_cd0a0a_256x240.png +0 -0
  49. package/angular-app/src/assets/styles/css/images/ui-icons_ffffff_256x240.png +0 -0
  50. package/angular-app/src/assets/styles/css/wm-responsive.css +1 -0
  51. package/angular-app/src/assets/styles/css/wm-style.css +1 -0
  52. package/angular-app/src/assets/styles/fonts/FontAwesome.otf +0 -0
  53. package/angular-app/src/assets/styles/fonts/fontawesome-webfont.eot +0 -0
  54. package/angular-app/src/assets/styles/fonts/fontawesome-webfont.svg +2671 -0
  55. package/angular-app/src/assets/styles/fonts/fontawesome-webfont.ttf +0 -0
  56. package/angular-app/src/assets/styles/fonts/fontawesome-webfont.woff +0 -0
  57. package/angular-app/src/assets/styles/fonts/fontawesome-webfont.woff2 +0 -0
  58. package/angular-app/src/assets/styles/fonts/glyphicons-halflings-regular.eot +0 -0
  59. package/angular-app/src/assets/styles/fonts/glyphicons-halflings-regular.svg +288 -0
  60. package/angular-app/src/assets/styles/fonts/glyphicons-halflings-regular.ttf +0 -0
  61. package/angular-app/src/assets/styles/fonts/glyphicons-halflings-regular.woff +0 -0
  62. package/angular-app/src/assets/styles/fonts/glyphicons-halflings-regular.woff2 +0 -0
  63. package/angular-app/src/assets/styles/fonts/wavicon.eot +0 -0
  64. package/angular-app/src/assets/styles/fonts/wavicon.ttf +0 -0
  65. package/angular-app/src/assets/styles/fonts/wavicon.woff +0 -0
  66. package/angular-app/src/assets/styles/fonts/wm-streamline-light-icon.eot +0 -0
  67. package/angular-app/src/assets/styles/fonts/wm-streamline-light-icon.ttf +0 -0
  68. package/angular-app/src/assets/styles/fonts/wm-streamline-light-icon.woff +0 -0
  69. package/angular-app/src/assets/styles/fonts/wm-streamline-regular-icon.eot +0 -0
  70. package/angular-app/src/assets/styles/fonts/wm-streamline-regular-icon.ttf +0 -0
  71. package/angular-app/src/assets/styles/fonts/wm-streamline-regular-icon.woff +0 -0
  72. package/angular-app/src/assets/styles/images/live-sync-icon.png +0 -0
  73. package/angular-app/src/assets/styles/images/live-sync-touch-icon.png +0 -0
  74. package/angular-app/src/assets/styles/images/loader.gif +0 -0
  75. package/angular-app/src/assets/styles/images/spinner-small.gif +0 -0
  76. package/angular-app/src/assets/styles/images/ui-icons.png +0 -0
  77. package/angular-app/src/environments/environment.dev.ts +3 -0
  78. package/angular-app/src/environments/environment.prod.ts +3 -0
  79. package/angular-app/src/environments/environment.ts +16 -0
  80. package/angular-app/src/framework/services/app-extension.service.ts +20 -0
  81. package/angular-app/src/framework/services/app-js-provider.service.ts +15 -0
  82. package/angular-app/src/framework/services/app-variables-provider.service.ts +15 -0
  83. package/angular-app/src/framework/services/component-ref-provider.service.ts +44 -0
  84. package/angular-app/src/framework/services/customwidget-config-provider.service.ts +13 -0
  85. package/angular-app/src/framework/services/lazy-component-ref-provider.service.ts +56 -0
  86. package/angular-app/src/framework/services/prefab-config-provider.service.ts +13 -0
  87. package/angular-app/src/framework/util/lazy-module-routes.ts +4 -0
  88. package/angular-app/src/framework/util/page-util.ts +7 -0
  89. package/angular-app/src/index.html +17 -0
  90. package/angular-app/src/main.ts +70 -0
  91. package/angular-app/src/polyfills.ts +53 -0
  92. package/angular-app/src/setup-jest.js +121 -0
  93. package/angular-app/src/styles.css +1 -0
  94. package/angular-app/src/tsconfig.app.json +17 -0
  95. package/angular-app/src/tslint.json +17 -0
  96. package/angular-app/src/wm-namespace.js +13 -0
  97. package/angular-app/tsconfig.json +94 -0
  98. package/angular-app/tsconfig.web-app.json +81 -0
  99. package/angular-app/wm-custom-webpack.config.js +51 -0
  100. package/build-angular-app.js +522 -0
  101. package/build-util.js +89 -0
  102. package/dependencies/app.component.html +40 -0
  103. package/dependencies/custom-widgets-bundle.cjs.js +421 -0
  104. package/dependencies/expression-parser.cjs.js +30154 -0
  105. package/dependencies/pipe-provider.cjs.js +208853 -0
  106. package/dependencies/transpilation-web.cjs.js +106547 -0
  107. package/download-packages.js +197 -0
  108. package/generate-angular-app.js +41 -0
  109. package/npm-shrinkwrap.json +8093 -0
  110. package/package-lock.json +8093 -0
  111. package/package.json +44 -0
  112. package/pwa-assets/icons/icon-128x128.png +0 -0
  113. package/pwa-assets/icons/icon-144x144.png +0 -0
  114. package/pwa-assets/icons/icon-152x152.png +0 -0
  115. package/pwa-assets/icons/icon-192x192.png +0 -0
  116. package/pwa-assets/icons/icon-384x384.png +0 -0
  117. package/pwa-assets/icons/icon-512x512.png +0 -0
  118. package/pwa-assets/icons/icon-72x72.png +0 -0
  119. package/pwa-assets/icons/icon-96x96.png +0 -0
  120. package/pwa-assets/manifest.json +59 -0
  121. package/pwa-assets/ngsw-config.json +30 -0
  122. package/pwa-assets/wmsw-worker.js +24 -0
  123. package/src/codegen-args-cli.js +1 -0
  124. package/src/codegen-cli.js +1 -0
  125. package/src/codegen.js +1 -0
  126. package/src/copy-utils.js +1 -0
  127. package/src/eslintrc_config.js +1 -0
  128. package/src/expr-parser-utils.js +1 -0
  129. package/src/gen-app-codegen-module.js +1 -0
  130. package/src/gen-app-js.js +1 -0
  131. package/src/gen-app-override-css.js +1 -0
  132. package/src/gen-app-prefabs-module.js +1 -0
  133. package/src/gen-app-routes.js +1 -0
  134. package/src/gen-app-skeleton.js +1 -0
  135. package/src/gen-app-variables.js +1 -0
  136. package/src/gen-components.js +1 -0
  137. package/src/gen-customwidget-config.js +1 -0
  138. package/src/gen-index-html.js +1 -0
  139. package/src/gen-layouts.js +1 -0
  140. package/src/gen-lazy-module-routes.js +1 -0
  141. package/src/gen-prefabs.js +1 -0
  142. package/src/gen-pwa-files.js +1 -0
  143. package/src/gen-tsconfig.js +1 -0
  144. package/src/gen-wm-project-properties.js +1 -0
  145. package/src/handlebar-helpers.js +1 -0
  146. package/src/pages-util.js +1 -0
  147. package/src/project-meta.js +1 -0
  148. package/src/update-angular-json.js +1 -0
  149. package/src/wm-namespace.js +1 -0
  150. package/src/wm-utils.js +1 -0
  151. package/templates/app-codegen.module.ts.hbs +21 -0
  152. package/templates/app-prefabs.module.ts.hbs +31 -0
  153. package/templates/app-routes.ts.hbs +14 -0
  154. package/templates/app.component.script.js.hbs +8 -0
  155. package/templates/app.config.ts.hbs +211 -0
  156. package/templates/app.module.ts.hbs +294 -0
  157. package/templates/component.config.ts.hbs +1 -0
  158. package/templates/component.expressions.ts.hbs +3 -0
  159. package/templates/component.variables.ts.hbs +3 -0
  160. package/templates/customwidget/customwidget-config.ts.hbs +6 -0
  161. package/templates/customwidget/customwidget.component.script.js.hbs +3 -0
  162. package/templates/customwidget/customwidget.component.ts.hbs +42 -0
  163. package/templates/expr-vs-fn.hbs +3 -0
  164. package/templates/layout/layout.component.ts.hbs +55 -0
  165. package/templates/layout/layout.module.ts.hbs +42 -0
  166. package/templates/lazy-module-routes.ts.hbs +3 -0
  167. package/templates/page/page.component.script.js.hbs +3 -0
  168. package/templates/page/page.component.ts.hbs +74 -0
  169. package/templates/page/page.module.ts.hbs +61 -0
  170. package/templates/partial/partial.component.script.js.hbs +3 -0
  171. package/templates/partial/partial.component.ts.hbs +61 -0
  172. package/templates/partial/partial.module.ts.hbs +43 -0
  173. package/templates/prefab/prefab-config.ts.hbs +6 -0
  174. package/templates/prefab/prefab.component.script.js.hbs +3 -0
  175. package/templates/prefab/prefab.component.ts.hbs +63 -0
  176. package/templates/prefab/prefab.module.ts.hbs +38 -0
  177. package/templates/wm-project-properties.ts.hbs +7 -0
@@ -0,0 +1,217 @@
1
+ const util = require(`util`);
2
+ const fs = require('fs-extra');
3
+ const readFile = util.promisify(fs.readFile);
4
+ const writeFile = util.promisify(fs.writeFile);
5
+ const copyFile = util.promisify(fs.copyFile);
6
+ const exec = util.promisify(require('child_process').exec);
7
+ const cheerio = require(`cheerio`);
8
+ const crypto = require(`crypto`);
9
+
10
+ let isProdBuild;
11
+ let isDevBuild;
12
+ let $;
13
+
14
+ const addScriptForWMStylesPath = (wm_styles_path) => {
15
+ // wm_styles_path will not be present for mobile apps
16
+ if (wm_styles_path) {
17
+ let styleType = wm_styles_path.split(".").pop();
18
+ if(styleType==="css"){
19
+ $("head").append(
20
+ `<link rel="stylesheet" type="text/css" href="${wm_styles_path}"/>`
21
+ );
22
+ } else {
23
+ $("body").append(
24
+ `<script type="text/javascript" defer="true" src="${wm_styles_path}"></script>`
25
+ );
26
+ }
27
+ }
28
+ }
29
+ const addPrintStylesPath = (print_styles_path) => {
30
+ $("head").append(
31
+ `<link rel="stylesheet" type="text/css" media="print" href="${print_styles_path}"/>`
32
+ );
33
+ }
34
+
35
+ /**
36
+ * Read the console arguments and prepare the key value pairs.
37
+ * @returns Object console arguments as key value pairs
38
+ */
39
+ const getArgs = (customArgs) => {
40
+ const args = {};
41
+ let arguments = customArgs || process.argv;
42
+ arguments.slice(2, process.argv.length)
43
+ .forEach(arg => {
44
+ if (arg.slice(0, 2) === '--') {
45
+ const longArg = arg.split('=');
46
+ const longArgFlag = longArg[0].slice(2, longArg[0].length);
47
+ const longArgValue = longArg.length > 2 ? longArg.slice(1, longArg.length).join('=') : longArg[1];
48
+ args[longArgFlag] = longArgValue;
49
+ }
50
+ });
51
+ return args;
52
+ }
53
+
54
+ const args = getArgs();
55
+
56
+ // Files that are moved out of ng-bundle and hence not to be updated.
57
+ const SKIP_UPDATE = ['index.html', 'manifest.json'];
58
+
59
+ /**
60
+ * Checks if a file's name has been changed during the build process
61
+ * and if changed, returns an updated file path.
62
+ *
63
+ * @param {string} deployUrl deployment url
64
+ * @param {string} url an absolute url to check if its filename has changed
65
+ * @param {object} updatedFileNames a map from old filenames to new filenames
66
+ * @returns {string} an updated file path
67
+ */
68
+ const getUpdatedFileName = (deployUrl, url, updatedFileNames) => {
69
+ const absUrl = url.substring(1); // remove leading '/'
70
+ if (SKIP_UPDATE.includes(absUrl)) {
71
+ return absUrl;
72
+ }
73
+
74
+ if (absUrl in updatedFileNames) {
75
+ return `${deployUrl}${updatedFileNames[absUrl]}` // add the leading '/' back
76
+ }
77
+ return `${deployUrl}${url}`;
78
+ }
79
+
80
+ /**
81
+ * Checks if a file's content has been changed during the build process
82
+ * and if changed, returns a new hash to be updated in ngsw.json
83
+ *
84
+ * @param {string} url an absolute url to check if its filename has changed
85
+ * @param {object} updatedFileHashes a map from filenames to file hashes
86
+ * @returns {string} an updated file hash
87
+ */
88
+ const getUpdatedFileHashes = (url, oldHash, updatedFileHashes) => {
89
+ const absUrl = url.substring(1); // remove leading '/'
90
+ if (absUrl in updatedFileHashes) {
91
+ return updatedFileHashes[absUrl];
92
+ }
93
+ return oldHash;
94
+ }
95
+
96
+ /**
97
+ * Get the path of the icon without '/ng-bundle'
98
+ *
99
+ * @param {string} iconPath path with '/ng-bundle'
100
+ * @returns {string} path of the icon without '/ng-bundle'
101
+ */
102
+ const getIconPath = (iconPath) => {
103
+ var index = iconPath.indexOf("/", iconPath.indexOf("/") + 1);
104
+ return iconPath.substring(index + 1);
105
+ }
106
+
107
+ /**
108
+ * Updates name, location and content of PWA related assets.
109
+ *
110
+ * @param {string} deployUrl deployment url
111
+ * @param {object} updatedFileNames a map from old filenames to new filenames
112
+ * @returns {void}
113
+ */
114
+ const updatePwaAssets = (deployUrl, updatedFileNames, updatedFileHashes) => {
115
+ const ngswPath = './dist/ngsw.json';
116
+ const manifestPath = './dist/manifest.json';
117
+ //this is always from server in case of pwa. Need to fix this to use cdnurl from runtime/build config
118
+ deployUrl = deployUrl === "_cdnUrl_" ? 'ng-bundle/' : deployUrl;
119
+
120
+ // copy service worker and its config to root directory
121
+ fs.copyFileSync(`./dist/ng-bundle/${global.randomHash}/ngsw-worker.js`, './dist/ngsw-worker.js');
122
+ fs.copyFileSync(`./dist/ng-bundle/${global.randomHash}/wmsw-worker.js`, './dist/wmsw-worker.js');
123
+ fs.copyFileSync(`./dist/ng-bundle/${global.randomHash}/ngsw.json`, ngswPath);
124
+ fs.copyFileSync(`./dist/ng-bundle/${global.randomHash}/manifest.json`, manifestPath);
125
+
126
+ // update the icons url in manifest.json
127
+ const manifest = JSON.parse(fs.readFileSync(manifestPath).toString());
128
+ const updatedManifest = {
129
+ ...manifest,
130
+ icons: manifest.icons.map(icon => ({ ...icon, src: `${deployUrl}${getIconPath(icon.src)}` })),
131
+ }
132
+ const manifestContent = JSON.stringify(updatedManifest, null, 4);
133
+ fs.writeFileSync(manifestPath, manifestContent);
134
+ updatedFileHashes['manifest.json'] = generateSha1(manifestContent);
135
+
136
+ // edit service worker config to include ./ng-bundle to the path of files to be cached
137
+ // also update the urls to files whose names are modified to include file hash (wm-styles)
138
+ const ngswData = JSON.parse(fs.readFileSync(ngswPath).toString());
139
+ ngswData.assetGroups = ngswData.assetGroups.map(group => ({
140
+ ...group,
141
+ urls: group.urls.map(url => getUpdatedFileName(deployUrl, url, updatedFileNames))
142
+ }));
143
+ ngswData.hashTable = Object.keys(ngswData.hashTable).reduce((prev, current) => ({
144
+ ...prev,
145
+ [getUpdatedFileName(deployUrl, current, updatedFileNames)]: getUpdatedFileHashes(current, ngswData.hashTable[current], updatedFileHashes),
146
+ }), {});
147
+
148
+ const ngswContent = JSON.stringify(ngswData, null, 4);
149
+ fs.writeFileSync(ngswPath, ngswContent);
150
+ }
151
+
152
+ /**
153
+ * Generated sha1 hash for the content supplied.
154
+ *
155
+ * @param {string} content the content to be hashed
156
+ * @returns {string} the hash value
157
+ */
158
+ const generateSha1 = (content) => {
159
+ const buffer = Buffer.from(content, 'utf8');
160
+ return crypto.createHash('sha1').update(buffer).digest("hex");
161
+ }
162
+
163
+ (async () => {
164
+ try {
165
+ const angularJson = require(`${process.cwd()}/angular.json`);
166
+ const build = angularJson['projects']['angular-app']['architect']['build'];
167
+ let deployUrl = args['deploy-url'] || build['configurations']['production']['deployUrl'];
168
+ global.randomHash = deployUrl.split('/')[1];
169
+ let outputPath = global.opPath = args['output-path'] || build['configurations']['production']['outputPath']
170
+ const contents = await readFile(`./dist/index.html`, `utf8`);
171
+ $ = cheerio.load(contents);
172
+ isProdBuild = fs.existsSync(`${process.cwd()}/${outputPath}/wm-styles.css`);
173
+ isDevBuild = fs.existsSync(`${process.cwd()}/${outputPath}/wm-styles.js`);
174
+
175
+ if (isProdBuild) {
176
+ const isOptimizeCss = $('meta[optimizecss]').length;
177
+ if (isOptimizeCss) {
178
+ console.log(`CSS Optimization Selected`);
179
+ const { stdout, stderr } = await exec(`npm run optimizecss`);
180
+ console.log(`Optimization Log | ${stdout}`);
181
+ console.error(`Optimization Error | ${stderr}`);
182
+ }
183
+ }
184
+ // if service worker is enabled the app is a PWA
185
+ const serviceWorkerEnabled = build['configurations']['production']['serviceWorker'];
186
+ const updatedFilenames = {}
187
+ const updatedFileHashes = {}
188
+ let wm_styles_path;
189
+
190
+ if (isDevBuild) {
191
+ wm_styles_path = `${deployUrl}wm-styles.js`;
192
+ } else {
193
+ const fileName = 'wm-styles';
194
+ const updatedFileName = `${fileName}.css`
195
+ wm_styles_path = `${deployUrl}${updatedFileName}`;
196
+ }
197
+
198
+ addScriptForWMStylesPath(wm_styles_path);
199
+ addPrintStylesPath(`${deployUrl}print.css`);
200
+
201
+ //this is required to download all the assets
202
+ $('head').append(`<meta name="deployUrl" content=${deployUrl} />`);
203
+ $('script[src$="services/application/wmProperties.js"]').remove();
204
+ $('link[href$="favicon.png"]').attr('href', `${deployUrl}favicon.png`);
205
+
206
+ const htmlContent = $.html();
207
+ await writeFile(`./dist/index.html`, htmlContent);
208
+
209
+ if (serviceWorkerEnabled) {
210
+ // re-generate hash for index.html since its been modified
211
+ updatedFileHashes['index.html'] = generateSha1(htmlContent);
212
+ updatePwaAssets(deployUrl, updatedFilenames, updatedFileHashes);
213
+ }
214
+ } catch (e) {
215
+ console.error(`Error in Post ng build Script | ${e}`);
216
+ }
217
+ })();
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+ const fs = require('fs');
3
+ const yargs = require('yargs');
4
+ const argv = yargs(process.argv).argv;
5
+ const { WM_NPM_SCOPE } = require('../src/wm-namespace.js');
6
+
7
+ /**
8
+ * Updates the @wavemaker-ai/app-ng-runtime dependency in the specified package.json file.
9
+ * @param {string} path - The path to the package.json file to update.
10
+ */
11
+
12
+ const updateNgRuntimePackage = (path) => {
13
+ if (fs.existsSync(path)) {
14
+ const packageJSON = require('../' + path);
15
+ packageJSON['dependencies'][`${WM_NPM_SCOPE}/app-ng-runtime`] = argv["publish-version"];
16
+ fs.writeFileSync(path, JSON.stringify(packageJSON, null, 4));
17
+ } else {
18
+ console.log('package.json not found at ' + path);
19
+ }
20
+ };
21
+ const init = () => {
22
+ updateNgRuntimePackage('../wavemaker-studio-runtime-integration/package.json');
23
+ };
24
+
25
+ init();
@@ -0,0 +1,124 @@
1
+
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Angular Dependencies Report</title>
8
+ <style>
9
+ body {
10
+ font-family: Arial, sans-serif;
11
+ line-height: 1.6;
12
+ margin: 0;
13
+ padding: 20px;
14
+ color: #333;
15
+ }
16
+ .header {
17
+ background: #f4f4f4;
18
+ padding: 20px;
19
+ margin-bottom: 20px;
20
+ border-radius: 4px;
21
+ }
22
+ .section {
23
+ margin-bottom: 30px;
24
+ }
25
+ table {
26
+ width: 100%;
27
+ border-collapse: collapse;
28
+ margin-bottom: 20px;
29
+ box-shadow: 0 1px 3px rgba(0,0,0,0.2);
30
+ }
31
+ th, td {
32
+ border: 1px solid #ddd;
33
+ padding: 12px;
34
+ text-align: left;
35
+ }
36
+ th {
37
+ background-color: #f8f8f8;
38
+ font-weight: bold;
39
+ }
40
+ tr:nth-child(even) {
41
+ background-color: #f9f9f9;
42
+ }
43
+ tr:hover {
44
+ background-color: #f5f5f5;
45
+ }
46
+ .dependency-type {
47
+ font-size: 1.2em;
48
+ color: #666;
49
+ font-weight: bold;
50
+ margin: 20px 0 10px;
51
+ padding-bottom: 5px;
52
+ border-bottom: 2px solid #eee;
53
+ }
54
+ .transitive {
55
+ margin-left: 20px;
56
+ border-left: 3px solid #eee;
57
+ padding-left: 20px;
58
+ }
59
+ .license-count {
60
+ font-weight: bold;
61
+ color: #2196F3;
62
+ }
63
+ .timestamp {
64
+ color: #666;
65
+ font-style: italic;
66
+ }
67
+ </style>
68
+ </head>
69
+ <body>
70
+ <div class="header">
71
+ <h1>Angular Project Dependencies Report</h1>
72
+ <p class="timestamp">Generated on: 5/4/2026, 3:25:42 PM</p>
73
+ </div>
74
+
75
+ <div class="section">
76
+ <h2>Project Dependencies Overview</h2>
77
+
78
+
79
+ </div>
80
+
81
+ <div class="section">
82
+ <h2>Transitive Dependencies</h2>
83
+
84
+ <div class="dependency-type">Transitive Dependencies</div>
85
+ <table>
86
+ <tr>
87
+ <th>Package</th>
88
+ <th>Version</th>
89
+ <th>License</th>
90
+ <th>Repository</th>
91
+ </tr>
92
+
93
+ <tr>
94
+ <td></td>
95
+ <td>wavemaker-ai/angular-app</td>
96
+ <td>UNKNOWN</td>
97
+ <td>N/A</td>
98
+ </tr>
99
+
100
+ </table>
101
+
102
+ </div>
103
+
104
+ <div class="section">
105
+ <h2>License Summary</h2>
106
+
107
+ <table>
108
+ <tr>
109
+ <th>License</th>
110
+ <th>Count</th>
111
+ <th>Packages</th>
112
+ </tr>
113
+
114
+ <tr>
115
+ <td>UNKNOWN</td>
116
+ <td class="license-count">1</td>
117
+ <td></td>
118
+ </tr>
119
+
120
+ </table>
121
+
122
+ </div>
123
+ </body>
124
+ </html>
@@ -0,0 +1,240 @@
1
+ const checker = require('license-checker');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ // HTML template as a string
6
+ const htmlTemplate = `
7
+ <!DOCTYPE html>
8
+ <html lang="en">
9
+ <head>
10
+ <meta charset="UTF-8">
11
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
12
+ <title>Angular Dependencies Report</title>
13
+ <style>
14
+ body {
15
+ font-family: Arial, sans-serif;
16
+ line-height: 1.6;
17
+ margin: 0;
18
+ padding: 20px;
19
+ color: #333;
20
+ }
21
+ .header {
22
+ background: #f4f4f4;
23
+ padding: 20px;
24
+ margin-bottom: 20px;
25
+ border-radius: 4px;
26
+ }
27
+ .section {
28
+ margin-bottom: 30px;
29
+ }
30
+ table {
31
+ width: 100%;
32
+ border-collapse: collapse;
33
+ margin-bottom: 20px;
34
+ box-shadow: 0 1px 3px rgba(0,0,0,0.2);
35
+ }
36
+ th, td {
37
+ border: 1px solid #ddd;
38
+ padding: 12px;
39
+ text-align: left;
40
+ }
41
+ th {
42
+ background-color: #f8f8f8;
43
+ font-weight: bold;
44
+ }
45
+ tr:nth-child(even) {
46
+ background-color: #f9f9f9;
47
+ }
48
+ tr:hover {
49
+ background-color: #f5f5f5;
50
+ }
51
+ .dependency-type {
52
+ font-size: 1.2em;
53
+ color: #666;
54
+ font-weight: bold;
55
+ margin: 20px 0 10px;
56
+ padding-bottom: 5px;
57
+ border-bottom: 2px solid #eee;
58
+ }
59
+ .transitive {
60
+ margin-left: 20px;
61
+ border-left: 3px solid #eee;
62
+ padding-left: 20px;
63
+ }
64
+ .license-count {
65
+ font-weight: bold;
66
+ color: #2196F3;
67
+ }
68
+ .timestamp {
69
+ color: #666;
70
+ font-style: italic;
71
+ }
72
+ </style>
73
+ </head>
74
+ <body>
75
+ <div class="header">
76
+ <h1>Angular Project Dependencies Report</h1>
77
+ <p class="timestamp">Generated on: {{GENERATED_DATE}}</p>
78
+ </div>
79
+
80
+ <div class="section">
81
+ <h2>Project Dependencies Overview</h2>
82
+ {{PRODUCTION_DEPENDENCIES}}
83
+ {{DEVELOPMENT_DEPENDENCIES}}
84
+ </div>
85
+
86
+ <div class="section">
87
+ <h2>Transitive Dependencies</h2>
88
+ {{TRANSITIVE_DEPENDENCIES}}
89
+ </div>
90
+
91
+ <div class="section">
92
+ <h2>License Summary</h2>
93
+ {{LICENSE_SUMMARY}}
94
+ </div>
95
+ </body>
96
+ </html>
97
+ `;
98
+
99
+ // Main function to generate the report
100
+ function generateDependencyReport() {
101
+ checker.init({
102
+ start: './',
103
+ json: true,
104
+ customPath: {
105
+ licenses: true,
106
+ dependencies: true,
107
+ version: true
108
+ }
109
+ }, function(err, packages) {
110
+ if (err) {
111
+ console.error("Error:", err);
112
+ return;
113
+ }
114
+
115
+ const projectData = processPackages(packages);
116
+ const html = generateHTML(projectData);
117
+
118
+ // Write the report to a file
119
+ fs.writeFileSync('dependency-report.html', html);
120
+ console.log('Dependency report generated successfully!');
121
+ });
122
+ }
123
+
124
+ // Process the packages data
125
+ function processPackages(packages) {
126
+ const data = {
127
+ production: {},
128
+ development: {},
129
+ transitive: {},
130
+ licenses: {}
131
+ };
132
+
133
+ // Read package.json to determine prod vs dev dependencies
134
+ const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
135
+ const prodDeps = packageJson.dependencies || {};
136
+ const devDeps = packageJson.devDependencies || {};
137
+
138
+ Object.entries(packages).forEach(([pkgName, info]) => {
139
+ const name = pkgName.split('@')[0];
140
+ const version = pkgName.split('@')[1];
141
+ const packageInfo = {
142
+ version,
143
+ license: info.licenses,
144
+ description: info.description || '',
145
+ repository: info.repository || '',
146
+ publisher: info.publisher || ''
147
+ };
148
+
149
+ // Track license information
150
+ if (info.licenses) {
151
+ if (!data.licenses[info.licenses]) {
152
+ data.licenses[info.licenses] = {
153
+ count: 0,
154
+ packages: []
155
+ };
156
+ }
157
+ data.licenses[info.licenses].count++;
158
+ data.licenses[info.licenses].packages.push(name);
159
+ }
160
+
161
+ // Categorize dependencies
162
+ if (prodDeps[name]) {
163
+ data.production[name] = packageInfo;
164
+ } else if (devDeps[name]) {
165
+ data.development[name] = packageInfo;
166
+ } else {
167
+ data.transitive[name] = packageInfo;
168
+ }
169
+ });
170
+
171
+ return data;
172
+ }
173
+
174
+ // Generate HTML tables for dependencies
175
+ function generateDependencyTable(dependencies, title) {
176
+ if (Object.keys(dependencies).length === 0) return '';
177
+
178
+ return `
179
+ <div class="dependency-type">${title}</div>
180
+ <table>
181
+ <tr>
182
+ <th>Package</th>
183
+ <th>Version</th>
184
+ <th>License</th>
185
+ <th>Repository</th>
186
+ </tr>
187
+ ${Object.entries(dependencies)
188
+ .map(([name, info]) => `
189
+ <tr>
190
+ <td>${name}</td>
191
+ <td>${info.version}</td>
192
+ <td>${info.license || 'Unknown'}</td>
193
+ <td>${info.repository || 'N/A'}</td>
194
+ </tr>
195
+ `).join('')}
196
+ </table>
197
+ `;
198
+ }
199
+
200
+ // Generate license summary table
201
+ function generateLicenseSummary(licenses) {
202
+ return `
203
+ <table>
204
+ <tr>
205
+ <th>License</th>
206
+ <th>Count</th>
207
+ <th>Packages</th>
208
+ </tr>
209
+ ${Object.entries(licenses)
210
+ .map(([license, info]) => `
211
+ <tr>
212
+ <td>${license}</td>
213
+ <td class="license-count">${info.count}</td>
214
+ <td>${info.packages.join(', ')}</td>
215
+ </tr>
216
+ `).join('')}
217
+ </table>
218
+ `;
219
+ }
220
+
221
+ // Generate the final HTML
222
+ function generateHTML(data) {
223
+ let html = htmlTemplate;
224
+
225
+ // Replace placeholders with actual content
226
+ html = html.replace('{{GENERATED_DATE}}', new Date().toLocaleString());
227
+ html = html.replace('{{PRODUCTION_DEPENDENCIES}}',
228
+ generateDependencyTable(data.production, 'Production Dependencies'));
229
+ html = html.replace('{{DEVELOPMENT_DEPENDENCIES}}',
230
+ generateDependencyTable(data.development, 'Development Dependencies'));
231
+ html = html.replace('{{TRANSITIVE_DEPENDENCIES}}',
232
+ generateDependencyTable(data.transitive, 'Transitive Dependencies'));
233
+ html = html.replace('{{LICENSE_SUMMARY}}',
234
+ generateLicenseSummary(data.licenses));
235
+
236
+ return html;
237
+ }
238
+
239
+ // Run the report generation
240
+ generateDependencyReport();