@wavemaker/angular-codegen 11.10.5-rc.6100 → 11.11.0-1.6140

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 (38) hide show
  1. package/angular-app/angular.json +4 -11
  2. package/angular-app/build-scripts/post-build.js +7 -47
  3. package/angular-app/dependency-report.html +1 -1
  4. package/angular-app/npm-shrinkwrap.json +510 -650
  5. package/angular-app/package-lock.json +510 -650
  6. package/angular-app/package.json +11 -21
  7. package/angular-app/src/app/lazy-load-scripts.resolve.ts +2 -9
  8. package/angular-app/src/assets/styles/css/wm-style.css +1 -1
  9. package/angular-app/src/index.html +1 -1
  10. package/angular-app/src/main.ts +25 -31
  11. package/angular-app/tsconfig.json +0 -30
  12. package/angular-app/tsconfig.web-app.json +0 -21
  13. package/angular-app/wm-custom-webpack.config.js +18 -0
  14. package/build-angular-app.js +11 -7
  15. package/dependencies/app.component.html +34 -26
  16. package/dependencies/pipe-provider.cjs.js +24962 -186
  17. package/dependencies/transpilation-web.cjs.js +13329 -816
  18. package/download-packages.js +99 -31
  19. package/npm-shrinkwrap.json +180 -323
  20. package/package-lock.json +180 -323
  21. package/package.json +2 -2
  22. package/src/codegen.js +1 -1
  23. package/src/gen-app-codegen-module.js +1 -1
  24. package/src/gen-app-override-css.js +1 -1
  25. package/src/gen-app-routes.js +1 -1
  26. package/src/gen-components.js +1 -1
  27. package/src/gen-layouts.js +1 -1
  28. package/src/handlebar-helpers.js +1 -1
  29. package/src/pages-util.js +1 -1
  30. package/src/project-meta.js +1 -1
  31. package/src/update-angular-json.js +1 -1
  32. package/src/wm-utils.js +1 -1
  33. package/templates/app-routes.ts.hbs +2 -2
  34. package/templates/app.config.ts.hbs +128 -0
  35. package/templates/app.module.ts.hbs +0 -2
  36. package/templates/layout/layout.component.ts.hbs +26 -4
  37. package/templates/page/page.component.ts.hbs +36 -5
  38. package/dependencies/transpilation-mobile.cjs.js +0 -93554
@@ -2,6 +2,7 @@ const fs = require('fs');
2
2
  const { executeSyncCmd } = require('./build-util');
3
3
  const os = require('os');
4
4
  const path = require('path');
5
+ const rimraf = require('rimraf');
5
6
 
6
7
 
7
8
  /**
@@ -16,7 +17,6 @@ const isNPMPackageExist = (path, msg) => {
16
17
  if (successMsg == msg) {
17
18
  return true;
18
19
  }
19
-
20
20
  } else {
21
21
  return false;
22
22
  }
@@ -29,52 +29,120 @@ const isNPMPackageExist = (path, msg) => {
29
29
  * Run npm install
30
30
  * Write success file to be make sure it was installed successfully.
31
31
  */
32
- const downloadNPMPackage = (packageInfo) => {
32
+ const downloadNPMPackage = async (packageInfo) => {
33
33
  const HOME_DIR = os.homedir();
34
34
  const PATH_NPM_PACKAGE = (packageInfo.baseDir || HOME_DIR + '/.wm/node_modules/') + packageInfo.name + '/' + packageInfo.version;
35
- const PATH_NPM_PACKAGE_SUCCESS = PATH_NPM_PACKAGE + '/.SUCCESS';
35
+ const PATH_NPM_PACKAGE_SUCCESS = PATH_NPM_PACKAGE + '/.SUCCESS', LOCK_FILE = path.join(PATH_NPM_PACKAGE, ".LOCK");
36
36
  let isError = false;
37
+ try {
38
+ if (!packageInfo.baseDir) { // going to install in the .wm folder if baseDir is not defined(optimizeUIBuild true)
39
+ // To check node modules.
40
+ if (!isNPMPackageExist(PATH_NPM_PACKAGE_SUCCESS, packageInfo.successMsg)) {
41
+ // Check if another process is already installing
42
+ if (fs.existsSync(LOCK_FILE)) {
43
+ console.log(`Waiting for another build to complete npm install... for package ${packageInfo.name}`);
44
+ await waitForLock(LOCK_FILE, 20 * 60 * 1000); // Wait for 20 minutes (timeout in milliseconds)
45
+ } else {
46
+ // Acquire the lock
47
+ fs.mkdirSync(PATH_NPM_PACKAGE, { recursive: true });
48
+ fs.writeFileSync(LOCK_FILE, "PROGRESS");
49
+
50
+ await processPackage(packageInfo, PATH_NPM_PACKAGE);
37
51
 
38
- // To check global app runtime node modules.
39
- if (!isNPMPackageExist(PATH_NPM_PACKAGE_SUCCESS, packageInfo.successMsg)) {
40
- fs.mkdirSync(PATH_NPM_PACKAGE, { recursive: true });
41
- let npmInstallCMD = 'npm install --legacy-peer-deps ';
42
- if (packageInfo.packageJsonFile && fs.existsSync(packageInfo.packageJsonFile)) {
43
- fs.copyFileSync(packageInfo.packageJsonFile, PATH_NPM_PACKAGE + '/package.json');
44
- try {
45
- //expecting this lock file to be present for exact versions to be downloaded from private registry
46
- fs.copyFileSync(`${path.dirname(packageInfo.packageJsonFile)} + /package-lock.json`, `${PATH_NPM_PACKAGE} + /package-lock.json`);
47
- } catch (err) {
48
- if (err.code === 'ENOENT') {
49
- console.error(`Info: package-lock.json file not found at ${path.dirname(packageInfo.packageJsonFile)}`);
52
+ //only create a .SUCCESS file when there is no error
53
+ if(!isError) {
54
+ isError = false;
55
+ fs.writeFileSync(PATH_NPM_PACKAGE_SUCCESS, packageInfo.successMsg);
56
+ }
50
57
  }
58
+ } else {
59
+ console.log(packageInfo.infoMsg + ` Node packages already installed! for package ${packageInfo.name}`);
51
60
  }
52
61
  } else {
53
- npmInstallCMD = 'npm init -y && ' + npmInstallCMD;
54
- npmInstallCMD += packageInfo.skipPackageVersion === true
55
- ? packageInfo.name
56
- : packageInfo.scope + '/' + packageInfo.name + '@' + packageInfo.version;
62
+ await processPackage(packageInfo, PATH_NPM_PACKAGE);
57
63
  }
58
-
59
- executeSyncCmd('cd ' + PATH_NPM_PACKAGE + ' && ' + npmInstallCMD, (errMsg) => {
60
- isError = true;
61
- console.log(packageInfo.infoMsg + ' Something wrong with npm installation ', errMsg);
62
- }, packageInfo.infoMsg);
63
-
64
- //only create a .SUCCESS file when there is no error
65
- if(!isError) {
66
- isError = false;
67
- fs.writeFileSync(PATH_NPM_PACKAGE_SUCCESS, packageInfo.successMsg);
64
+ } catch (err) {
65
+ deleteFiles([PATH_NPM_PACKAGE_SUCCESS, LOCK_FILE])
66
+ console.log(`Something went wrong while installing - for package ${packageInfo.name}`, err);
67
+ process.exit(err.code || err.pid);
68
+ } finally {
69
+ //cleanup : in windows / optimizeUIBuild is false, we need to delete the temp downloaded package
70
+ if (!packageInfo.baseDir) {
71
+ deleteFiles([LOCK_FILE]);
68
72
  }
73
+ }
74
+ return PATH_NPM_PACKAGE;
75
+ }
69
76
 
77
+ const processPackage = (packageInfo, PATH_NPM_PACKAGE) => {
78
+ let npmInstallCMD = 'npm install --legacy-peer-deps ';
79
+ if (packageInfo.packageJsonFile && fs.existsSync(packageInfo.packageJsonFile)) {
80
+ fs.copyFileSync(packageInfo.packageJsonFile, PATH_NPM_PACKAGE + '/package.json');
81
+ try {
82
+ //expecting this lock file to be present for exact versions to be downloaded from private registry
83
+ fs.copyFileSync(`${path.dirname(packageInfo.packageJsonFile)} + /package-lock.json`, `${PATH_NPM_PACKAGE} + /package-lock.json`);
84
+ } catch (err) {
85
+ if (err.code === 'ENOENT') {
86
+ console.error(`Info: package-lock.json file not found at ${path.dirname(packageInfo.packageJsonFile)}`);
87
+ }
88
+ }
70
89
  } else {
71
- console.log(packageInfo.infoMsg + ' Node packages already installed!');
90
+ npmInstallCMD = 'npm init -y && ' + npmInstallCMD;
91
+ npmInstallCMD += packageInfo.skipPackageVersion === true
92
+ ? packageInfo.name
93
+ : packageInfo.scope + '/' + packageInfo.name + '@' + packageInfo.version;
72
94
  }
73
95
 
74
- return PATH_NPM_PACKAGE;
96
+ fs.mkdirSync(PATH_NPM_PACKAGE, { recursive: true });
97
+ executeSyncCmd('cd ' + PATH_NPM_PACKAGE + ' && ' + npmInstallCMD, (errMsg) => {
98
+ console.log(packageInfo.infoMsg + ' Something wrong with npm installation ', errMsg);
99
+ throw Error(errMsg);
100
+ }, packageInfo.infoMsg);
101
+ }
75
102
 
103
+ /**
104
+ *
105
+ */
106
+ const deleteFiles = (files) => {
107
+ files.forEach(file => {
108
+ try {
109
+ rimraf.sync(file);
110
+ console.log(`Successfully deleted file - ${file}`);
111
+ } catch (err) {
112
+ console.error(`Error while deleting file ${file}`, err);
113
+ throw new Error(`Error while deleting file: ${file}, Error: ${err}`);
114
+ }
115
+ });
76
116
  }
77
117
 
118
+ /**
119
+ *
120
+ * @param lockFile
121
+ * @param timeout
122
+ * @returns {Promise<void>}
123
+ */
124
+ const waitForLock = async (lockFile, timeout) => {
125
+ timeout = timeout || 20 * 60 * 1000 // Wait for 20 minutes (timeout in milliseconds)
126
+ // Helper function to wait for the lock to be released with a timeout
127
+ const startTime = Date.now();
128
+ while (fs.existsSync(lockFile)) {
129
+ if (Date.now() - startTime > timeout) {
130
+ console.error('Timeout!! - waiting for the lock to be released. Exiting...');
131
+ process.exit(1); // Terminate the process with an error code
132
+ }
133
+ await sleep(1000); // Wait for 1 second before checking again
134
+ }
135
+ };
136
+
137
+ /**
138
+ *
139
+ * @param ms
140
+ * @returns {Promise<unknown>}
141
+ */
142
+ const sleep = (ms) => {
143
+ // Helper function to sleep for a given time
144
+ return new Promise(resolve => setTimeout(resolve, ms));
145
+ };
78
146
 
79
147
  module.exports = {
80
148
  downloadNPMPackage