@eui/tools 5.3.72 → 5.3.74

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
- 5.3.72
1
+ 5.3.74
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 5.3.74 (2022-10-20)
2
+
3
+ ##### Bug Fixes
4
+
5
+ * **karma:**
6
+ * tests - EUI-6702 [EUI-6702](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-6702) ([d7c136d0](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/d7c136d07f5bf3a8090727f7168a2eb4e21ae247))
7
+
8
+ * * *
9
+ * * *
10
+ ## 5.3.73 (2022-10-11)
11
+
12
+ ##### Chores
13
+
14
+ * **other:**
15
+ * allow array of app sources injection and overrides - MWP-8868 [MWP-8868](https://webgate.ec.europa.eu/CITnet/jira/browse/MWP-8868) ([55ae46fc](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/55ae46fcaea7263983452b9da90c56545561238c))
16
+
17
+ * * *
18
+ * * *
1
19
  ## 5.3.72 (2022-10-07)
2
20
 
3
21
  ##### Chores
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eui/tools",
3
- "version": "5.3.72",
3
+ "version": "5.3.74",
4
4
  "tag": "latest",
5
5
  "license": "EUPL-1.1",
6
6
  "description": "eUI common tools and scripts",
@@ -1145,6 +1145,10 @@ const angularPackageDef = {
1145
1145
  "test": {
1146
1146
  "builder": "@angular-devkit/build-angular:karma",
1147
1147
  "options": {
1148
+ "polyfills": [
1149
+ "zone.js",
1150
+ "zone.js/testing"
1151
+ ],
1148
1152
  "main": "@path@/@module.name@/src/test.ts",
1149
1153
  "tsConfig": "@path@/@module.name@/tsconfig.spec.json",
1150
1154
  "karmaConfig": "@path@/@module.name@/karma.conf.js"
@@ -1174,6 +1178,10 @@ const angularPackageSubEntryDef = {
1174
1178
  "test": {
1175
1179
  "builder": "@angular-devkit/build-angular:karma",
1176
1180
  "options": {
1181
+ "polyfills": [
1182
+ "zone.js",
1183
+ "zone.js/testing"
1184
+ ],
1177
1185
  "main": "packages/eui/packages/components/@subEntry.path@/test.ts",
1178
1186
  "tsConfig": "packages/eui/packages/components/@subEntry.path@/tsconfig.spec.json",
1179
1187
  "karmaConfig": "packages/eui/packages/components/@subEntry.path@/karma.conf.js"
@@ -1262,6 +1270,44 @@ const angularPackageDefV14 = {
1262
1270
  }
1263
1271
  };
1264
1272
 
1273
+ const angularPackageDefV15 = {
1274
+ "root": "@path@/@module.name@",
1275
+ "sourceRoot": "@path@/@module.name@@srcRoot@",
1276
+ "projectType": "library",
1277
+ "prefix": "lib",
1278
+ "architect": {
1279
+ "lint": {
1280
+ "builder": "@angular-eslint/builder:lint",
1281
+ "options": {
1282
+ "lintFilePatterns": [
1283
+ "@path@/@module.name@/**/*.ts",
1284
+ "@path@/@module.name@/**/*.html"
1285
+ ],
1286
+ "eslintConfig": "@path@/@module.name@/.eslintrc.json"
1287
+ }
1288
+ },
1289
+ "build": {
1290
+ "builder": "@angular-devkit/build-angular:ng-packagr",
1291
+ "options": {
1292
+ "tsConfig": "@path@/@module.name@/@tsconfig@",
1293
+ "project": "@path@/@module.name@/ng-package.json"
1294
+ },
1295
+ "configurations": {
1296
+ "production": {
1297
+ "tsConfig": "@path@/@module.name@/tsconfig.lib.prod.json"
1298
+ }
1299
+ }
1300
+ },
1301
+ "test": {
1302
+ "builder": "@angular-devkit/build-angular:karma",
1303
+ "options": {
1304
+ "tsConfig": "@path@/@module.name@/tsconfig.spec.json",
1305
+ "karmaConfig": "@path@/@module.name@/karma.conf.js"
1306
+ }
1307
+ }
1308
+ }
1309
+ };
1310
+
1265
1311
 
1266
1312
 
1267
1313
 
@@ -1418,10 +1464,12 @@ module.exports.registerAngularPackage = (pkg, isReset) => {
1418
1464
  if (packageEuiVersion === '13.x') {
1419
1465
  projectDef = JSON.stringify(angularPackageDefV13);
1420
1466
  }
1421
- if (packageEuiVersion === '14.x' || packageEuiVersion === '15.x') {
1467
+ if (packageEuiVersion === '14.x') {
1422
1468
  projectDef = JSON.stringify(angularPackageDefV14);
1423
1469
  }
1424
-
1470
+ if (packageEuiVersion === '15.x') {
1471
+ projectDef = JSON.stringify(angularPackageDefV15);
1472
+ }
1425
1473
 
1426
1474
  let srcRoot = '/src', srcRootTesting = '';
1427
1475
  if (pkg.build && typeof pkg.build.srcRootDefault === 'boolean' && pkg.build.srcRootDefault === false) {
@@ -1445,15 +1493,25 @@ module.exports.registerAngularPackageSubEntry = (subEntryName, subEntryPath, pkg
1445
1493
  const file = path.join(process.cwd(), 'angular.json');
1446
1494
  const jsonFile = require(file);
1447
1495
 
1496
+ let packageEuiVersion;
1497
+ if (pkg.build && pkg.build.euiVersion) {
1498
+ packageEuiVersion = pkg.build.euiVersion;
1499
+ } else {
1500
+ packageEuiVersion = innerPackages.getPackageEuiVerison(pkg);
1501
+ }
1502
+
1448
1503
  let projectDef = JSON.stringify(angularPackageSubEntryDef);
1449
1504
 
1450
- let replacePath = tools.replaceAll(projectDef, '@subEntry.path@', subEntryName)
1451
- replacePath = tools.replaceAll(replacePath, '@subEntry.package.name@', 'ng-package.json');
1452
- replacePath = tools.replaceAll(replacePath, '@tsconfig@', pkg.tsConfigFileName);
1505
+ if (packageEuiVersion === '15.x') {
1506
+ projectDef = projectDef.replace('"main":"packages/eui/packages/components/@subEntry.path@/test.ts",', '');
1507
+ }
1508
+ projectDef = tools.replaceAll(projectDef, '@subEntry.path@', subEntryName)
1509
+ projectDef = tools.replaceAll(projectDef, '@subEntry.package.name@', 'ng-package.json');
1510
+ projectDef = tools.replaceAll(projectDef, '@tsconfig@', pkg.tsConfigFileName);
1453
1511
 
1454
- jsonFile['projects'][subEntryName] = JSON.parse(replacePath);
1512
+ jsonFile['projects'][subEntryName] = JSON.parse(projectDef);
1455
1513
 
1456
- console.log(jsonFile['projects'][subEntryName]);
1514
+ // console.log(jsonFile['projects'][subEntryName]);
1457
1515
 
1458
1516
  tools.writeJsonFileSync(file, jsonFile);
1459
1517
  }
@@ -221,7 +221,13 @@ module.exports.buildSubEntry = (pkg, subEntry) => {
221
221
  };
222
222
  }
223
223
  })
224
-
224
+ .then(() => {
225
+ tools.logInfo('Testing...');
226
+ const ng = path.resolve(process.cwd(), 'node_modules', '@angular', 'cli', 'bin', 'ng');
227
+ let args = ['--max_old_space_size=8096', ng, 'test', subEntry, '--code-coverage', '--watch=false'];
228
+ tools.logInfo(`running ng test : with args: ${args} on folder : ${pkg.paths.pkgRootDirectory}`);
229
+ return execa('node', args, { cwd: pkg.paths.pkgRootDirectory, stdio: 'inherit' });
230
+ })
225
231
  .then(() => {
226
232
  const ng = path.resolve(process.cwd(), 'node_modules', '@angular', 'cli', 'bin', 'ng');
227
233
 
@@ -64,89 +64,119 @@ module.exports.injectExternalFeatures = (project) => {
64
64
  }
65
65
 
66
66
 
67
+
68
+ const injectExternalAppSourcesCore = (project, build = false, injectedNpmPkg, injectedFolder) => {
69
+
70
+ tools.logInfo(`Injecting : ${injectedNpmPkg} / ${injectedFolder}`);
71
+
72
+ return Promise.resolve()
73
+ .then(() => {
74
+ // check if package is locally cloned
75
+ const localPackage = configUtils.packages.getPackages().filter((p) => {
76
+ return p.npmPkg === injectedNpmPkg
77
+ })[0];
78
+
79
+ let appSourcesSrcPath;
80
+ const projectSrcPath = path.join(process.cwd(), project.folder, 'src');
81
+
82
+ // if local package is found
83
+ if (localPackage) {
84
+ tools.logInfo('local project found, copying from local');
85
+ appSourcesSrcPath = path.join(process.cwd(), 'packages', localPackage.name, injectedFolder);
86
+
87
+ // if not sources are taken from the npm package def in node_modules
88
+ } else {
89
+ tools.logInfo('remote project found, copying from remote');
90
+ const npmPkgScope = injectedNpmPkg.substr(0, injectedNpmPkg.indexOf('/'));
91
+ const npmPkgName = injectedNpmPkg.substr(injectedNpmPkg.indexOf('/') + 1);
92
+
93
+ appSourcesSrcPath = path.join(process.cwd(), 'node_modules', npmPkgScope, npmPkgName, injectedFolder);
94
+ }
95
+
96
+ if (!tools.isDirExists(appSourcesSrcPath)) {
97
+ tools.logWarning(`External sources location : ${appSourcesSrcPath} cannot be found in node_modules`);
98
+ throw new Error('External sources not found');
99
+
100
+ } else {
101
+
102
+ return Promise.resolve()
103
+ .then(() => {
104
+ tools.logInfo(`${appSourcesSrcPath} injecting in ${projectSrcPath}`);
105
+ return tools.copydir(appSourcesSrcPath, projectSrcPath, true);
106
+ })
107
+ .catch((e) => {
108
+ throw e;
109
+ })
110
+ }
111
+ })
112
+
113
+ .catch((e) => {
114
+ throw e;
115
+ })
116
+ }
117
+
118
+
119
+
67
120
  module.exports.injectExternalAppSources = (project, build = false) => {
68
121
 
69
122
  tools.logTitle(`Injecting project external application sources for : ${project.name}`);
70
123
 
71
124
  return Promise.resolve()
72
125
  .then(() => {
73
- if (!project.appSources) {
126
+ if (!build) {
127
+ // removing previously injected content, except assets
128
+ const projectSrcPath = path.join(process.cwd(), project.folder, 'src');
129
+ const projectSrcAppPath = path.join(projectSrcPath, 'app');
130
+ const projectSrcConfigPath = path.join(projectSrcPath, 'config');
131
+ const projectSrcEnvironmentsPath = path.join(projectSrcPath, 'environments');
132
+
133
+ return Promise.resolve()
134
+ .then(() => {
135
+ tools.logInfo(`Removing ${projectSrcAppPath} content`);
136
+ return tools.rimraf(projectSrcAppPath);
137
+ })
138
+ .then(() => {
139
+ tools.logInfo(`Removing ${projectSrcConfigPath} content`);
140
+ return tools.rimraf(projectSrcConfigPath);
141
+ })
142
+ .then(() => {
143
+ tools.logInfo(`Removing ${projectSrcEnvironmentsPath} content`);
144
+ return tools.rimraf(projectSrcEnvironmentsPath);
145
+ })
146
+ .catch((e) => {
147
+ throw e;
148
+ })
149
+ }
150
+ })
151
+ .then(() => {
152
+ if (!project.externalSources) {
74
153
  tools.logInfo('No external app sources setup...skipping');
75
154
  return;
76
155
  }
77
156
 
78
- if (!project.appSources.npmPkg || !project.appSources.folder) {
79
- return tools.logWarning('External appSources use requires a source [npmPkg] and a [folder] declared');
80
-
157
+ // in case of multiple injection are defined, we promise loop on each injection
158
+ if (Array.isArray(project.externalSources)) {
159
+ return Promise.resolve().then(() => {
160
+ return project.externalSources.reduce((promise, appSource) => {
161
+ return promise.then(() => (
162
+ injectExternalAppSourcesCore(project, build, appSource.npmPkg, appSource.folder)
163
+ ));
164
+ }, Promise.resolve());
165
+ })
166
+
167
+ // if only one injection externalSources is defined
81
168
  } else {
82
- // check if package is locally cloned
83
- const localPackage = configUtils.packages.getPackages().filter((p) => {
84
- return p.npmPkg === project.appSources.npmPkg
85
- })[0];
86
-
87
- let appSourcesSrcPath;
88
- const projectSrcPath = path.join(process.cwd(), project.folder, 'src');
89
-
90
- // if local package is found
91
- if (localPackage) {
92
- tools.logInfo('local project found, copying from local');
93
- appSourcesSrcPath = path.join(process.cwd(), 'packages', localPackage.name, project.appSources.folder);
94
-
95
- // if not sources are taken from the npm package def in node_modules
96
- } else {
97
- tools.logInfo('remote project found, copying from remote');
98
- const npmPkgScope = project.appSources.npmPkg.substr(0, project.appSources.npmPkg.indexOf('/'));
99
- const npmPkgName = project.appSources.npmPkg.substr(project.appSources.npmPkg.indexOf('/') + 1);
100
-
101
- appSourcesSrcPath = path.join(process.cwd(), 'node_modules', npmPkgScope, npmPkgName, project.appSources.folder);
102
- }
103
-
104
- if (!tools.isDirExists(appSourcesSrcPath)) {
105
- tools.logWarning(`External features location : ${appSourcesSrcPath} cannot be found in node_modules`);
106
- throw new Error('External features not found');
169
+ if (!project.externalSources.npmPkg || !project.externalSources.folder) {
170
+ return tools.logWarning('External externalSources use requires a source [npmPkg] and a [folder] declared');
107
171
 
108
172
  } else {
109
-
110
- return Promise.resolve()
111
- .then(() => {
112
- if (!build) {
113
- // removing previously injected content, except assets
114
- const projectSrcAppPath = path.join(projectSrcPath, 'app');
115
- const projectSrcConfigPath = path.join(projectSrcPath, 'config');
116
- const projectSrcEnvironmentsPath = path.join(projectSrcPath, 'environments');
117
-
118
- return Promise.resolve()
119
- .then(() => {
120
- tools.logInfo(`Removing ${projectSrcAppPath} content`);
121
- return tools.rimraf(projectSrcAppPath);
122
- })
123
- .then(() => {
124
- tools.logInfo(`Removing ${projectSrcConfigPath} content`);
125
- return tools.rimraf(projectSrcConfigPath);
126
- })
127
- .then(() => {
128
- tools.logInfo(`Removing ${projectSrcEnvironmentsPath} content`);
129
- return tools.rimraf(projectSrcEnvironmentsPath);
130
- })
131
- .catch((e) => {
132
- throw e;
133
- })
134
- }
135
- })
136
- .then(() => {
137
- tools.logInfo(`${appSourcesSrcPath} injecting in ${projectSrcPath}`);
138
- return tools.copydir(appSourcesSrcPath, projectSrcPath, true);
139
- })
140
- .catch((e) => {
141
- throw e;
142
- })
173
+ return injectExternalAppSourcesCore(project, build, project.externalSources.npmPkg, project.externalSources.folder);
143
174
  }
144
175
  }
145
176
  })
146
177
  .catch((e) => {
147
178
  throw e;
148
179
  })
149
-
150
180
  }
151
181
 
152
182
 
@@ -6,6 +6,10 @@ const _ = require('lodash');
6
6
  const tools = require('../../tools');
7
7
  const configUtils = require('../../../csdr/config/config-utils');
8
8
 
9
+ // const { subRoutes, debug } = tools.getArgs();
10
+ const { debug } = tools.getArgs();
11
+
12
+
9
13
 
10
14
  const getEnvTarget = (envTargetIn, build) => {
11
15
  if (!envTargetIn) {
@@ -71,39 +75,39 @@ const getRoutesFile = (project) => {
71
75
 
72
76
  return Promise.resolve()
73
77
  .then(() => {
74
- if (!project.appSources) {
75
- tools.logError('project requires appSources definition');
78
+ if (!project.externalRoutesSources) {
79
+ tools.logError('project requires externalRoutesSources definition');
76
80
  return;
77
81
  }
78
82
 
79
83
  let routesFilePath;
80
84
  let srcRoutesFilePath;
81
85
 
82
- if (!project.appSources.routesFileNpmPkg || !project.appSources.routesFileSource || !project.appSources.routesFilePath) {
83
- tools.logError('project requires appSources.routesFileNpmPkg, routesFileSources and routesFilePath definitions');
86
+ if (!project.externalRoutesSources.routesFileNpmPkg || !project.externalRoutesSources.routesFileSource || !project.externalRoutesSources.routesFilePath) {
87
+ tools.logError('project requires externalRoutesSources.routesFileNpmPkg, routesFileSources and routesFilePath definitions');
84
88
  return;
85
89
  }
86
90
 
87
91
  // check if package is locally cloned
88
92
  const localPackage = configUtils.packages.getPackages().filter((p) => {
89
- return p.npmPkg === project.appSources.routesFileNpmPkg
93
+ return p.npmPkg === project.externalRoutesSources.routesFileNpmPkg
90
94
  })[0];
91
95
 
92
96
  // if local package is found
93
97
  if (localPackage) {
94
98
  tools.logInfo('local package found, copying from local');
95
- srcRoutesFilePath = path.join(process.cwd(), 'packages', localPackage.name, project.appSources.routesFileSource);
99
+ srcRoutesFilePath = path.join(process.cwd(), 'packages', localPackage.name, project.externalRoutesSources.routesFileSource);
96
100
 
97
101
  // if not sources are taken from the npm package def in node_modules
98
102
  } else {
99
103
  tools.logInfo('remote package found, copying from remote');
100
- const npmPkgScope = project.appSources.routesFileNpmPkg.substr(0, project.appSources.routesFileNpmPkg.indexOf('/'));
101
- const npmPkgName = project.appSources.routesFileNpmPkg.substr(project.appSources.routesFileNpmPkg.indexOf('/') + 1);
104
+ const npmPkgScope = project.externalRoutesSources.routesFileNpmPkg.substr(0, project.externalRoutesSources.routesFileNpmPkg.indexOf('/'));
105
+ const npmPkgName = project.externalRoutesSources.routesFileNpmPkg.substr(project.externalRoutesSources.routesFileNpmPkg.indexOf('/') + 1);
102
106
 
103
- srcRoutesFilePath = path.join(process.cwd(), 'node_modules', npmPkgScope, npmPkgName, project.appSources.routesFileSource);
107
+ srcRoutesFilePath = path.join(process.cwd(), 'node_modules', npmPkgScope, npmPkgName, project.externalRoutesSources.routesFileSource);
104
108
  }
105
109
 
106
- routesFilePath = path.join(project.paths.rootPath, project.appSources.routesFilePath);
110
+ routesFilePath = path.join(project.paths.rootPath, project.externalRoutesSources.routesFilePath);
107
111
 
108
112
  // copy source file to project destination
109
113
  tools.copy(srcRoutesFilePath, routesFilePath);
@@ -130,8 +134,8 @@ const replaceRoutes = (project, envTarget, build, routesFileContent) => {
130
134
  // getting base route defs content
131
135
  const projectAssetsPath = path.join(process.cwd(), project.folder, 'src', 'assets');
132
136
  let routeDefsBaseFilename = 'route-defs-base.json';
133
- if (project.appSources.routesBaseFilename) {
134
- routeDefsBaseFilename = project.appSources.routesBaseFilename;
137
+ if (project.externalRoutesSources.routesBaseFilename) {
138
+ routeDefsBaseFilename = project.externalRoutesSources.routesBaseFilename;
135
139
  }
136
140
  const baseRouteDefsPath = path.join(projectAssetsPath, routeDefsBaseFilename);
137
141
 
@@ -160,13 +164,22 @@ const replaceRoutes = (project, envTarget, build, routesFileContent) => {
160
164
  const mergedRouteDefs = _.merge(_.keyBy(baseRouteDefsJSON, 'path'), _.keyBy(envRouteDefsJSON, 'path'));
161
165
  const finalRouteDefs = _.values(mergedRouteDefs);
162
166
 
167
+ // getting subRoutes if passed as arguments
168
+ // let subRoutesArray;
169
+
170
+ // if (subRoutes) {
171
+ // subRoutesArray = subRoutes.split(',');
172
+
173
+ // tools.logInfo('subRoutes arguments foound : ');
174
+ // tools.logInfo(subRoutesArray);
175
+ // }
163
176
 
164
177
  // processing routes
165
178
  let placeHolderContent = '';
166
179
 
167
180
  tools.logInfo('Processing routes replacement');
168
181
  finalRouteDefs.forEach((route) => {
169
- tools.logInfo(`====> route : ${route.path}`);
182
+ if (debug) tools.logInfo(`====> route : ${route.path}`);
170
183
 
171
184
  let routeContent = '{\n';
172
185
 
@@ -204,14 +217,24 @@ const replaceRoutes = (project, envTarget, build, routesFileContent) => {
204
217
 
205
218
  placeHolderContent += routeContent;
206
219
 
207
- tools.logSuccess('======> OK replaced');
220
+ // if (subRoutesArray) {
221
+ // if (subRoutesArray.includes(route.path)) {
222
+ // placeHolderContent += routeContent;
223
+ // }
224
+ // } else {
225
+ // placeHolderContent += routeContent;
226
+ // }
227
+
228
+ if (debug) tools.logSuccess('======> OK replaced');
208
229
  })
209
230
 
210
231
  const placeHolderToken = '// routes-placeholder';
211
232
  routesFileContent = tools.replaceAll(routesFileContent, placeHolderToken, placeHolderContent);
212
233
 
213
- tools.logInfo('Routes file content replaced : ');
214
- console.log(routesFileContent);
234
+ if (debug) {
235
+ tools.logInfo('Routes file content replaced : ');
236
+ console.log(routesFileContent);
237
+ }
215
238
 
216
239
  return routesFileContent;
217
240
  })
@@ -29,7 +29,7 @@ module.exports.preBuild = (project, envTarget, build, configEnvTarget) => {
29
29
 
30
30
  // inject external app sources declaration
31
31
  .then(() => {
32
- if (project.appSources && project.appSources.external) {
32
+ if (project.externalSources) {
33
33
  return injectionUtils.externals.injectExternalAppSources(project, build);
34
34
  }
35
35
  })
@@ -62,7 +62,7 @@ module.exports.preBuild = (project, envTarget, build, configEnvTarget) => {
62
62
 
63
63
 
64
64
  .then(() => {
65
- if (project.config && project.appSources && project.appSources.external && project.appSources.remapRoutesByEnvConfig) {
65
+ if (project.config && project.externalRoutesSources) {
66
66
  return injectionUtils.routesReplacement.buildRoutes(project, envTarget, build);
67
67
  }
68
68
  })