@wavemaker/angular-codegen 11.7.0-next.139418 → 11.7.0-next.24769

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,6 +29,11 @@
29
29
  "assets": [
30
30
  "src/favicon.ico",
31
31
  "src/assets",
32
+ {
33
+ "glob": "print.css",
34
+ "input": "src/assets/",
35
+ "output": "."
36
+ },
32
37
  {
33
38
  "glob": "**/*",
34
39
  "input": "libraries/locales/",
@@ -187,7 +192,12 @@
187
192
  "tsConfig": "src/tsconfig.app.json",
188
193
  "assets": [
189
194
  "src/favicon.ico",
190
- "src/assets"
195
+ "src/assets",
196
+ {
197
+ "glob": "print.css",
198
+ "input": "src/assets/",
199
+ "output": "."
200
+ }
191
201
  ],
192
202
  "styles": [
193
203
  "src/styles.css",
@@ -0,0 +1,30 @@
1
+ const { spawnSync } = require('child_process');
2
+ const path = require('path');
3
+
4
+ const args = process.argv.slice(2);
5
+
6
+ const ngBuildArgs = ['build', ...args];
7
+ console.log("Build params - ", ngBuildArgs);
8
+
9
+ //Trigger angular build with the passed params
10
+ const ngPath = path.resolve(process.cwd(), 'node_modules', '.bin', "ng");
11
+ const ngBuildProcess = spawnSync(ngPath, ngBuildArgs, { stdio: 'inherit', shell: true });
12
+
13
+ if (ngBuildProcess.status === 0) {
14
+ console.log('ng build completed successfully!');
15
+ } else {
16
+ console.error('Error during ng build:', ngBuildProcess.error || ngBuildProcess.stderr);
17
+ process.exit(1);
18
+ }
19
+
20
+ const ngPostBuildArgs = ['build-scripts/post-build.js', ...args];
21
+ console.log("Post build params - ", ngPostBuildArgs);
22
+
23
+ const ngPostBuildProcess = spawnSync('node', ngPostBuildArgs, { stdio: 'inherit' });
24
+
25
+ if (ngPostBuildProcess.status === 0) {
26
+ console.log('ng post build completed successfully!');
27
+ } else {
28
+ console.error('Error during ng build:', ngPostBuildProcess.error || ngPostBuildProcess.stderr);
29
+ process.exit(1);
30
+ }
@@ -76,7 +76,7 @@ const setMobileProjectType = (angularJson) => {
76
76
  const addMobileSpecificStyles = async (deployUrl) => {
77
77
  if (isDevBuild) {
78
78
  $("body").append(
79
- `<script type="text/javascript" defer="true" src="${deployUrl}/wm-android-styles.js"></script>`
79
+ `<script type="text/javascript" defer="true" src="${deployUrl}wm-android-styles.js"></script>`
80
80
  );
81
81
  }
82
82
 
@@ -84,12 +84,12 @@ const addMobileSpecificStyles = async (deployUrl) => {
84
84
  let hash = await generateHash(`${opPath}/wm-android-styles.css`);
85
85
  copyMobileCssFiles(hash, 'wm-android-styles');
86
86
  $("head").append(
87
- `<link rel="stylesheet" theme="wmtheme" href="${deployUrl}/wm-android-styles.${hash}.css" >`
87
+ `<link rel="stylesheet" theme="wmtheme" href="${deployUrl}wm-android-styles.${hash}.css" >`
88
88
  );
89
89
  hash = await generateHash(`${opPath}/wm-ios-styles.css`);
90
90
  copyMobileCssFiles(hash, 'wm-ios-styles');
91
91
  $("head").append(
92
- `<link rel="stylesheet" theme="wmtheme" href="${deployUrl}/wm-ios-styles.${hash}.css" >`
92
+ `<link rel="stylesheet" theme="wmtheme" href="${deployUrl}wm-ios-styles.${hash}.css" >`
93
93
  );
94
94
  }
95
95
  }
@@ -108,8 +108,10 @@ const addScriptForWMStylesPath = (wm_styles_path) => {
108
108
  );
109
109
  }
110
110
  }
111
+ }
112
+ const addPrintStylesPath = (print_styles_path) => {
111
113
  $("head").append(
112
- `<link rel="stylesheet" type="text/css" media="print" href="print.css"/>`
114
+ `<link rel="stylesheet" type="text/css" media="print" href="${print_styles_path}"/>`
113
115
  );
114
116
  }
115
117
 
@@ -153,7 +155,7 @@ const getUpdatedFileName = (deployUrl, url, updatedFileNames) => {
153
155
  }
154
156
 
155
157
  if (absUrl in updatedFileNames) {
156
- return `${deployUrl}/${updatedFileNames[absUrl]}` // add the leading '/' back
158
+ return `${deployUrl}${updatedFileNames[absUrl]}` // add the leading '/' back
157
159
  }
158
160
  return `${deployUrl}${url}`;
159
161
  }
@@ -195,6 +197,8 @@ const getIconPath = (iconPath) => {
195
197
  const updatePwaAssets = (deployUrl, updatedFileNames, updatedFileHashes) => {
196
198
  const ngswPath = './dist/ngsw.json';
197
199
  const manifestPath = './dist/manifest.json';
200
+ //this is always from server in case of pwa. Need to fix this to use cdnurl from runtime/build config
201
+ deployUrl = deployUrl === "_cdnUrl_" ? 'ng-bundle/' : deployUrl;
198
202
 
199
203
  // copy service worker and its config to root directory
200
204
  fs.copyFileSync('./dist/ng-bundle/ngsw-worker.js', './dist/ngsw-worker.js');
@@ -206,7 +210,7 @@ const updatePwaAssets = (deployUrl, updatedFileNames, updatedFileHashes) => {
206
210
  const manifest = JSON.parse(fs.readFileSync(manifestPath).toString());
207
211
  const updatedManifest = {
208
212
  ...manifest,
209
- icons: manifest.icons.map(icon => ({ ...icon, src: `${deployUrl}/${getIconPath(icon.src)}` })),
213
+ icons: manifest.icons.map(icon => ({ ...icon, src: `${deployUrl}${getIconPath(icon.src)}` })),
210
214
  }
211
215
  const manifestContent = JSON.stringify(updatedManifest, null, 4);
212
216
  fs.writeFileSync(manifestPath, manifestContent);
@@ -244,9 +248,6 @@ const generateSha1 = (content) => {
244
248
  const angularJson = require(`${process.cwd()}/angular.json`);
245
249
  const build = angularJson['projects']['angular-app']['architect']['build'];
246
250
  let deployUrl = args['deploy-url'] || build['options']['deployUrl'];
247
- if (deployUrl.endsWith('/')) {
248
- deployUrl = deployUrl.slice(0, deployUrl.length - 1);
249
- }
250
251
 
251
252
  const contents = await readFile(`./dist/index.html`, `utf8`);
252
253
  $ = cheerio.load(contents);
@@ -278,17 +279,22 @@ const generateSha1 = (content) => {
278
279
  await addMobileSpecificStyles(deployUrl);
279
280
  } else {
280
281
  if (isDevBuild) {
281
- wm_styles_path = `${deployUrl}/wm-styles.js`;
282
+ wm_styles_path = `${deployUrl}wm-styles.js`;
282
283
  } else {
283
284
  const fileName = 'wm-styles';
284
285
  const hash = await generateHash(`${opPath}/${fileName}.css`);
285
286
  copyCssFiles(hash, updatedFilenames);
286
287
  const updatedFileName = `${fileName}.${hash}.css`
287
- wm_styles_path = `${deployUrl}/${updatedFileName}`;
288
+ wm_styles_path = `${deployUrl}${updatedFileName}`;
288
289
  }
289
290
  }
290
291
 
291
292
  addScriptForWMStylesPath(wm_styles_path);
293
+ addPrintStylesPath(`${deployUrl}print.css`);
294
+
295
+ //this is required to download all the assets
296
+ $('head').append(`<meta name="deployUrl" content=${deployUrl} />`);
297
+
292
298
  const htmlContent = $.html();
293
299
  await writeFile(`./dist/index.html`, htmlContent);
294
300