@eui/tools 6.2.5 → 6.2.7

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.
@@ -1 +1 @@
1
- 6.2.5
1
+ 6.2.7
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 6.2.7 (2022-11-10)
2
+
3
+ ##### Chores
4
+
5
+ * **other:**
6
+ * adapted remotes serve and build for v15+ - MWP-8946 [MWP-8946](https://webgate.ec.europa.eu/CITnet/jira/browse/MWP-8946) ([3d7d0b73](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/3d7d0b73540b18802773bb7780505142302c0bdc))
7
+
8
+ * * *
9
+ * * *
10
+ ## 6.2.6 (2022-11-10)
11
+
12
+ ##### Chores
13
+
14
+ * **other:**
15
+ * add exclude non compatible routes per environment on dynamic replacement for MWP - EUI-6448 [EUI-6448](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-6448) ([bdaf38b4](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/bdaf38b478b797e454abdc1b73d3cc9ecae071b0))
16
+
17
+ * * *
18
+ * * *
1
19
  ## 6.2.5 (2022-11-10)
2
20
 
3
21
  ##### Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eui/tools",
3
- "version": "6.2.5",
3
+ "version": "6.2.7",
4
4
  "tag": "latest",
5
5
  "license": "EUPL-1.1",
6
6
  "description": "eUI common tools and scripts",
package/sandbox.js CHANGED
@@ -934,12 +934,12 @@ const versionUtils = require('./scripts/csdr/version/version-utils');
934
934
 
935
935
  // STYLES AUDIT TESTS
936
936
 
937
- Promise.resolve()
938
- .then(() => {
939
- const { pkg } = tools.getArgs();
940
- const p = configUtils.packages.getPackage(pkg, true);
941
- return auditUtils.styles.audit(p);
942
- })
937
+ // Promise.resolve()
938
+ // .then(() => {
939
+ // const { pkg } = tools.getArgs();
940
+ // const p = configUtils.packages.getPackage(pkg, true);
941
+ // return auditUtils.styles.audit(p);
942
+ // })
943
943
 
944
944
  // const installPackages = async packages => {
945
945
  // const promises = packages.map(async p => {
@@ -1027,3 +1027,32 @@ Promise.resolve()
1027
1027
  // // })
1028
1028
 
1029
1029
  // })
1030
+
1031
+ // Promise.resolve()
1032
+ // .then(() => {
1033
+ // const dev = tools.getJsonFileContent(path.join(process.cwd(), 'packages', 'mywp-routes-config', 'assets', 'route-defs.dev.json'));
1034
+ // const tst = tools.getJsonFileContent(path.join(process.cwd(), 'packages', 'mywp-routes-config', 'assets', 'route-defs.test.json'));
1035
+
1036
+ // const devPaths = dev.map((p) => {
1037
+ // return p.path;
1038
+ // })
1039
+ // const tstPaths = tst.map((p) => {
1040
+ // return p.path;
1041
+ // })
1042
+
1043
+ // console.log(devPaths);
1044
+ // console.log(tstPaths);
1045
+
1046
+
1047
+ // console.log(devPaths.filter(n => !tstPaths.includes(n)))
1048
+ // console.log(tstPaths.filter(n => !devPaths.includes(n)))
1049
+ // })
1050
+
1051
+
1052
+ Promise.resolve()
1053
+ .then(() => {
1054
+ const prjName = 'my-workplace-host';
1055
+ const project = configUtils.projects.getCsdrProject(prjName);
1056
+
1057
+ return injectionUtils.routesReplacement.buildRoutes(project, 'TST', true);
1058
+ })
@@ -58,6 +58,7 @@ module.exports.getRemote = (remoteName, euiVersion) => {
58
58
  dependencies: tools.getJsonFileContent(path.join(remotePath, 'dependencies.json')),
59
59
  paths: {
60
60
  root: remoteRootPath,
61
+ dist: path.join(remoteRootPath, 'dist'),
61
62
  fromRoot: `remotes/${fullName}`,
62
63
  repoNodeModules: path.join(remoteRootPath, 'node_modules'),
63
64
  },
package/scripts/index.js CHANGED
@@ -62,6 +62,9 @@ module.exports.publishNpm = require('./utils/publish/npm');
62
62
  module.exports.publishAll = require('./utils/publish/publish-all');
63
63
  module.exports.publishUtils = require('./utils/publish/publish-utils');
64
64
 
65
+ // utils - remotes
66
+ module.exports.remotesUtils = require('./utils/remotes/remotes-utils');
67
+
65
68
  // utils - serve - test
66
69
  module.exports.serveApp = require('./utils/serve/app');
67
70
  module.exports.serveElement = require('./utils/serve/element');
@@ -90,9 +93,13 @@ module.exports.configSync = require('./csdr/config/sync');
90
93
 
91
94
  // csdr -init
92
95
  module.exports.init = require('./csdr/init/init');
96
+ module.exports.initGlobal = require('./csdr/init/global');
93
97
  module.exports.initUtils = require('./csdr/init/init-utils');
94
98
  module.exports.initMeta = require('./csdr/init/meta');
99
+ module.exports.initPackages = require('./csdr/init/packages');
100
+ module.exports.initProjects = require('./csdr/init/projects');
95
101
  module.exports.initPrompt = require('./csdr/init/prompt');
102
+ module.exports.initRemotes = require('./csdr/init/remotes');
96
103
  module.exports.initRepos = require('./csdr/init/repos');
97
104
 
98
105
  // csdr - install
@@ -8,6 +8,7 @@ const execa = require('execa');
8
8
  const tools = require('../../tools');
9
9
  const configUtils = require('../../../csdr/config/config-utils');
10
10
  const preBuildUtils = require('../../pre-build/pre-build-utils');
11
+ const remotesUtils = require('../../remotes/remotes-utils');
11
12
 
12
13
  let {
13
14
  skipLint, skipTest, configuration, baseHref, watch, dryRun, maxSpaceSize, statsJson,
@@ -181,6 +182,9 @@ module.exports.build = (pkg, isMaster) => {
181
182
  module.exports.postBuild = (pkg, version) => {
182
183
  tools.logInfo('Executing element post-build...');
183
184
 
185
+ const remoteEuiVersion = configUtils.packages.getRemoteEuiVersion(pkg);
186
+ const euiVersionNumber = remoteEuiVersion.split('.')[0];
187
+
184
188
  if (dryRun) {
185
189
  tools.logInfo('DRY-RUN...skipping');
186
190
  return;
@@ -190,27 +194,29 @@ module.exports.postBuild = (pkg, version) => {
190
194
  .then(() => {
191
195
  tools.logTitle('ELEMENT POST build');
192
196
  tools.logInfo('Copying dist to bundles folder');
193
- tools.mkdir(path.join(pkg.paths.pkgBuild, 'bundles'));
194
- return tools.copydir(path.join(pkg.paths.pkgBuild), path.join(pkg.paths.pkgBuild, 'bundles'));
197
+ tools.mkdir(path.join(pkg.paths.dist, 'bundles'));
198
+ return tools.copydir(path.join(pkg.paths.pkgBuild), path.join(pkg.paths.dist, 'bundles'));
195
199
  })
200
+
196
201
  .then(() => {
197
- tools.logInfo(`Renaming main.js file to current version : ${version}`);
198
- return tools.move(path.join(pkg.paths.pkgBuild, 'bundles', 'main.js'), path.join(pkg.paths.pkgBuild, 'bundles', 'main-' + version + '.js'));
202
+ if (euiVersionNumber >= 15) {
203
+ return remotesUtils.concatFiles(path.join(pkg.paths.dist, 'bundles'));
204
+ }
199
205
  })
206
+
200
207
  .then(() => {
201
- tools.logInfo('Copying package.json to dist');
202
- return tools.copy(path.join(pkg.paths.pkgRootDirectory, 'package.json'), path.join(pkg.paths.pkgBuild, 'package.json'));
208
+ return remotesUtils.copyPackageJson(pkg.paths.root, pkg.paths.dist, remoteEuiVersion);
203
209
  })
210
+
204
211
  .then(() => {
205
- try {
206
- tools.logInfo('Set empty index.html');
207
- const emptyIndexHtmlFile = path.join(__dirname, 'skeletons', 'elements', 'index.html');
208
- const outputIndexHmtlFile = path.join(pkg.paths.pkgBuild, 'bundles', 'index.html');
209
- return tools.copy(emptyIndexHtmlFile, outputIndexHmtlFile);
210
- } catch(e) {
211
- console.log(e);
212
- }
212
+ tools.logInfo(`Renaming main.js file to current version : ${version}`);
213
+ return tools.move(path.join(pkg.paths.dist, 'bundles', 'main.js'), path.join(pkg.paths.dist, 'bundles', 'main-' + version + '.js'));
214
+ })
215
+
216
+ .then(() => {
217
+ return remotesUtils.emptyIndexHtml(path.join(pkg.paths.dist, 'bundles'));
213
218
  })
219
+
214
220
  .catch((e) => {
215
221
  throw e;
216
222
  })
@@ -304,16 +304,23 @@ const replaceRoutes = (project, envTarget, build, routesFileContent, euiVersion)
304
304
  finalRouteDefs.forEach((route) => {
305
305
  if (debug) tools.logInfo(`====> route : ${route.path}`);
306
306
 
307
- if (euiVersion === 'DEFAULT' || euiVersion === '10.x') {
308
- tools.logInfo(`Legacy routes replacement for v7 and v10 => replacing ${route.path}`);
309
- placeHolderContent += replaceRouteLegacy(route);
307
+ if (!route.loadChildren) {
308
+ tools.logInfo('Loadchildren does not exist for route...skipping');
309
+ tools.logInfo('Route excluded:');
310
+ console.log(route);
310
311
 
311
312
  } else {
312
- tools.logInfo(`New route replacement for v14+ => replacing ${route.path}`);
313
- placeHolderContent += replaceRoute(route);
314
- }
313
+ if (euiVersion === 'DEFAULT' || euiVersion === '10.x') {
314
+ tools.logInfo(`Legacy routes replacement for v7 and v10 => replacing ${route.path}`);
315
+ placeHolderContent += replaceRouteLegacy(route);
316
+
317
+ } else {
318
+ tools.logInfo(`New route replacement for v14+ => replacing ${route.path}`);
319
+ placeHolderContent += replaceRoute(route);
320
+ }
315
321
 
316
- if (debug) tools.logSuccess('======> OK replaced');
322
+ if (debug) tools.logSuccess('======> OK replaced');
323
+ }
317
324
  })
318
325
 
319
326
  const placeHolderToken = '// routes-placeholder';
@@ -0,0 +1,77 @@
1
+ 'use strict';
2
+
3
+ // GLOBAL
4
+ const path = require('path');
5
+ const concat = require('concat');
6
+
7
+ // LOCAL
8
+ const tools = require('../tools');
9
+
10
+
11
+ module.exports.concatFiles = (workingPath) => {
12
+ return Promise.resolve()
13
+ .then(() => {
14
+ tools.logInfo('Concatening JS files to main.js');
15
+
16
+ tools.move(path.join(workingPath, 'main.js'), path.join(workingPath, 'main-old.js'));
17
+
18
+ const files = [
19
+ 'runtime.js',
20
+ 'polyfills.js',
21
+ 'scripts.js',
22
+ 'main-old.js'
23
+ ].map(f => path.join(workingPath, f));
24
+
25
+ const outFilePath = path.join(workingPath, 'main.js');
26
+
27
+ return concat(files, outFilePath);
28
+ })
29
+
30
+ .catch((e) => {
31
+ throw e;
32
+ })
33
+ }
34
+
35
+
36
+ module.exports.copyPackageJson = (srcPath, destPath, euiVersion) => {
37
+ return Promise.resolve()
38
+ .then(() => {
39
+ tools.logInfo('Copying package.json to dist');
40
+
41
+ tools.copy(path.join(srcPath, 'package.json'), path.join(destPath, 'package.json'));
42
+
43
+ if (euiVersion) {
44
+ const packageJsonFile = path.join(destPath, 'package.json');
45
+ const packageJson = require(packageJsonFile);
46
+
47
+ packageJson.euiVersion = euiVersion;
48
+
49
+ tools.writeJsonFileSync(packageJsonFile, packageJson);
50
+ }
51
+ })
52
+
53
+ .catch((e) => {
54
+ throw e;
55
+ })
56
+ }
57
+
58
+
59
+ module.exports.emptyIndexHtml = (destPath) => {
60
+ return Promise.resolve()
61
+ .then(() => {
62
+ try {
63
+ tools.logInfo('Set empty index.html');
64
+
65
+ const emptyIndexHtmlFile = path.join(__dirname, 'skeletons', 'elements', 'index.html');
66
+ const outputIndexHmtlFile = path.join(destPath, 'index.html');
67
+ return tools.copy(emptyIndexHtmlFile, outputIndexHmtlFile);
68
+
69
+ } catch(e) {
70
+ console.log(e);
71
+ }
72
+ })
73
+
74
+ .catch((e) => {
75
+ throw e;
76
+ })
77
+ }
@@ -2,9 +2,9 @@
2
2
 
3
3
  const path = require('path');
4
4
  const execa = require('execa');
5
- const concat = require('concat');
6
5
 
7
6
  const tools = require('../tools');
7
+ const remotesUtils = require('../remotes/remotes-utils');
8
8
 
9
9
  const preBuildUtils = require('../pre-build/pre-build-utils');
10
10
  const configUtils = require('../../csdr/config/config-utils');
@@ -28,8 +28,8 @@ module.exports.serve = (remote = false) => {
28
28
  pkgName = pkg.name;
29
29
  }
30
30
 
31
-
32
31
  const remoteEuiVersion = configUtils.packages.getRemoteEuiVersion(pkg);
32
+ const euiVersionNumber = remoteEuiVersion.split('.')[0];
33
33
 
34
34
  const ng = path.resolve(pkg.paths.repoNodeModules, '@angular', 'cli', 'bin', 'ng');
35
35
 
@@ -67,16 +67,14 @@ module.exports.serve = (remote = false) => {
67
67
  destPath = path.join(process.cwd(), 'apps', project, 'src', 'assets', 'elements', pkgName, 'bundles');
68
68
  }
69
69
 
70
- const versionNumber = remoteEuiVersion.split('.')[0];
71
-
72
- if (versionNumber <= 10) {
70
+ if (euiVersionNumber <= 10) {
73
71
  args.push(`--outputPath=${destPath}`);
74
72
  args.push(`--single-bundle=true`);
73
+ args.push('--watch=true');
75
74
  } else {
76
75
  args.push(`--output-path=${destPath}`);
77
76
  }
78
77
 
79
- args.push('--watch=true');
80
78
  args.push(`--output-hashing=none`);
81
79
 
82
80
  if (configuration) {
@@ -98,23 +96,21 @@ module.exports.serve = (remote = false) => {
98
96
  }
99
97
  })
100
98
 
101
- // activate in case concat is needed
102
- // .then(() => {
103
- // const destPath = path.join(process.cwd(), 'hosts', project, 'src', 'assets', 'elements', pkg.name, 'bundles');
104
-
105
- // tools.move(path.join(destPath, 'main.js'), path.join(destPath, 'main-old.js'));
106
-
107
- // const files = [
108
- // 'runtime.js',
109
- // 'polyfills.js',
110
- // 'scripts.js',
111
- // 'main-old.js'
112
- // ].map(f => path.join(destPath, f));
99
+ .then(() => {
100
+ if (euiVersionNumber >= 15) {
101
+ return remotesUtils.concatFiles(destPath);
102
+ }
103
+ })
113
104
 
114
- // const outFilePath = path.join(destPath, 'main.js');
105
+ .then(() => {
106
+ return remotesUtils.copyPackageJson(pkg.paths.root, destPath, remoteEuiVersion);
107
+ })
115
108
 
116
- // return concat(files, outFilePath);
117
- // })
109
+ .then(() => {
110
+ if (euiVersionNumber >= 15) {
111
+ return remotesUtils.emptyIndexHtml(destPath);
112
+ }
113
+ })
118
114
 
119
115
  .catch((e) => {
120
116
  throw e;
@@ -65,7 +65,7 @@ module.exports.runMocha = (pkg) => {
65
65
  if (timeout) {
66
66
  args.push(`--timeout ${timeout}`);
67
67
  } else {
68
- args.push('--timeout 5000');
68
+ args.push('--timeout 20000');
69
69
  }
70
70
 
71
71
  return execa('node', args, { cwd: process.cwd(), stdio: 'inherit' });