@eui/tools 6.3.30 → 6.3.32

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.3.30
1
+ 6.3.32
package/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## 6.3.32 (2023-02-14)
2
+
3
+ ##### Chores
4
+
5
+ * **other:**
6
+ * refactor and cleanup - added remotes sync on global sync and skipRemotes option - gather installable remotes for MWP - EUI-7121 [EUI-7121](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7121) ([a6cfdff9](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/a6cfdff96d90334382fa9501c277ea8332190831))
7
+ ##### Bug Fixes
8
+
9
+ * **other:**
10
+ * registration of remotes at init - sync and creation time - MWP-9204 [MWP-9204](https://webgate.ec.europa.eu/CITnet/jira/browse/MWP-9204) ([d1d972de](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/d1d972de9de724de4180d72ce024fc7070395cbc))
11
+
12
+ * * *
13
+ * * *
14
+ ## 6.3.31 (2023-02-13)
15
+
16
+ ##### Chores
17
+
18
+ * **other:**
19
+ * added eui-legacy.css for default remotes v15 config entry - MWP-9204 [MWP-9204](https://webgate.ec.europa.eu/CITnet/jira/browse/MWP-9204) ([104e3e73](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/104e3e73d97aa861abc8fa128c75da5c5f71de7b))
20
+
21
+ * * *
22
+ * * *
1
23
  ## 6.3.30 (2023-02-12)
2
24
 
3
25
  ##### Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eui/tools",
3
- "version": "6.3.30",
3
+ "version": "6.3.32",
4
4
  "tag": "latest",
5
5
  "license": "EUPL-1.1",
6
6
  "description": "eUI common tools and scripts",
package/sandbox.js CHANGED
@@ -916,17 +916,6 @@ const versionUtils = require('./scripts/csdr/version/version-utils');
916
916
  // console.log(tools.sortArray(a, 'name'));
917
917
  // })
918
918
 
919
- // Promise.resolve()
920
- // .then(() => {
921
- // const prj = configUtils.projects.getCsdrProject('my-workplace-host-playground');
922
- // return installUtils.projects.getLocalProjectRemoteDeps(prj);
923
- // })
924
-
925
- // Promise.resolve()
926
- // .then(() => {
927
-
928
- // })
929
-
930
919
 
931
920
 
932
921
 
@@ -1144,3 +1133,23 @@ const versionUtils = require('./scripts/csdr/version/version-utils');
1144
1133
  // .catch((e) => {
1145
1134
  // console.log(e);
1146
1135
  // })
1136
+
1137
+ Promise.resolve()
1138
+ .then(() => {
1139
+ // const remotes = configUtils.remotes.getRemotes();
1140
+ // console.log(remotes);
1141
+ return installUtils.remotes.installDeps();
1142
+ })
1143
+
1144
+
1145
+ // Promise.resolve()
1146
+ // .then(() => {
1147
+ // const prj = configUtils.projects.getCsdrProject('my-workplace-host-playground');
1148
+ // return installUtils.projects.getLocalProjectRemoteDeps(prj);
1149
+ // })
1150
+ // .then((deps) => {
1151
+ // console.log(deps);
1152
+ // })
1153
+
1154
+
1155
+
@@ -129,7 +129,7 @@ module.exports.audit = (pkg) => {
129
129
  const configOptions = configUtils.global.getConfigOptions();
130
130
 
131
131
  // getting local csdr euiVersion
132
- const euiVersion = initUtils.global.getLocalEuiVersion();
132
+ const euiVersion = configUtils.global.getLocalEuiVersion();
133
133
 
134
134
  // if eUI version not found, no action
135
135
  if (!euiVersion) {
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "styles": [
3
3
  "node_modules/@eui/styles/dist/styles/eui.css",
4
+ "node_modules/@eui/styles/dist/styles/eui-legacy.css",
4
5
  "node_modules/@eui/styles/dist/styles/eui-extra-utilities.css",
5
6
  "node_modules/@eui/styles/dist/styles/eui-legacy-bootstrap.css",
6
7
  "node_modules/@eui/styles/dist/styles/eui-legacy-icons-font.css"
@@ -8,6 +8,7 @@ const tools = require('../../utils/tools');
8
8
 
9
9
  const innerPackages = require('./packages');
10
10
  const innerProjects = require('./projects');
11
+ const innerRemotes = require('./remotes');
11
12
 
12
13
  // CONFIGS skeletons
13
14
  const {
@@ -177,7 +178,7 @@ module.exports.registerAngularProjectDef = (project, build = false, element = fa
177
178
  let angularRootPath;
178
179
 
179
180
  if (element) {
180
- euiVersion = innerPackages.getRemoteEuiVersion(project);
181
+ euiVersion = innerPackages.getPackageEuiVersion(project);
181
182
  angularRootPath = project.paths.root;
182
183
  } else {
183
184
  euiVersion = innerProjects.getProjectEuiVersion(project);
@@ -349,7 +350,7 @@ module.exports.registerAngularElementModule = (pkg) => {
349
350
 
350
351
 
351
352
  module.exports.registerModulePaths = (pkg, isReset) => {
352
- tools.logTitle(`Registering tsconfig paths for package : ${pkg.name}`);
353
+ tools.logInfo(`Registering tsconfig paths for package : ${pkg.name}`);
353
354
 
354
355
  const fileDev = path.join(process.cwd(), 'tsconfig.json');
355
356
  const fileBuild = path.join(process.cwd(), 'tsconfig.build.json');
@@ -6,17 +6,23 @@ const path = require('path');
6
6
  // LOCAL
7
7
  const tools = require('../../utils/tools');
8
8
 
9
+ // INNER MODULES
10
+ const innerPackages = require('./packages');
11
+ const innerProjects = require('./projects');
12
+
9
13
 
10
14
 
11
15
  module.exports.getCsdrConfig = (full = true) => {
12
16
  const globalConfig = require(path.join(process.cwd(), '.csdr', '.euirc-csdr-config.json'));
13
17
  const appsConfig = require(path.join(process.cwd(), '.csdr', '.euirc-csdr-apps.json'));
14
18
  const packagesConfig = require(path.join(process.cwd(), '.csdr', '.euirc-csdr-packages.json'));
19
+ const remotesConfig = require(path.join(process.cwd(), '.csdr', '.euirc-csdr-remotes.json'));
15
20
 
16
21
  const config = globalConfig;
17
22
 
18
23
  config.projects = {};
19
24
  config.packages = {};
25
+ config.remotes = {};
20
26
 
21
27
  Object.keys(appsConfig).forEach((p) => {
22
28
  config.projects[p] = appsConfig[p];
@@ -42,6 +48,10 @@ module.exports.getCsdrConfig = (full = true) => {
42
48
  }
43
49
  })
44
50
 
51
+ Object.keys(remotesConfig).forEach((r) => {
52
+ config.remotes[r] = remotesConfig[r];
53
+ })
54
+
45
55
  if (full) {
46
56
  // flatten children packages
47
57
  Object.keys(config.packages).forEach((p) => {
@@ -75,6 +85,7 @@ const getGeneratedConfig = (euircBaseFile) => {
75
85
  // initializing projects and packages objects
76
86
  genConfig.projects = {};
77
87
  genConfig.packages = {};
88
+ genConfig.remotes = {};
78
89
 
79
90
  // remapping projects against csdr projects config
80
91
  configContent.projects.forEach((p) => {
@@ -115,6 +126,13 @@ const getGeneratedConfig = (euircBaseFile) => {
115
126
  }
116
127
  })
117
128
 
129
+ // remapping remotes
130
+ if (configContent.remotes) {
131
+ configContent.remotes.forEach((r) => {
132
+ genConfig.remotes[r] = globalConfig.remotes[r];
133
+ })
134
+ }
135
+
118
136
  return genConfig;
119
137
  }
120
138
 
@@ -146,32 +164,41 @@ module.exports.getConfig = () => {
146
164
 
147
165
 
148
166
 
149
- module.exports.updateConfig = (project, packages, reset = false) => {
167
+ module.exports.updateConfig = (args = { project, packages, remotes, reset}) => {
168
+
150
169
  const configFile = path.join(process.cwd(), '.csdr', '.euirc.json');
151
170
 
152
171
  let newConfig = {};
153
172
 
154
- if (!tools.isFileExists(configFile) || reset) {
173
+ if (!tools.isFileExists(configFile) || args.reset) {
155
174
  newConfig.projects = [];
156
- if (project && project !== 'NONE') {
157
- newConfig.projects.push(project);
175
+ if (args.project && args.project !== 'NONE') {
176
+ newConfig.projects.push(args.project);
158
177
  }
159
178
  newConfig.packages = [];
160
- if (packages) {
161
- newConfig.packages = packages;
179
+ if (args.packages) {
180
+ newConfig.packages = args.packages;
181
+ }
182
+ newConfig.remotes = [];
183
+ if (args.remotes) {
184
+ newConfig.remotes = args.remotes;
162
185
  }
163
186
 
164
187
  } else {
165
188
  newConfig = require(configFile);
166
189
 
167
- if (project && project !== 'NONE') {
168
- if (newConfig.projects.indexOf(project) < 0) {
169
- newConfig.projects.push(project);
190
+ if (args.project && args.project !== 'NONE') {
191
+ if (newConfig.projects.indexOf(args.project) < 0) {
192
+ newConfig.projects.push(args.project);
170
193
  }
171
194
  }
172
195
 
173
- if (packages) {
174
- newConfig.packages = tools.removeArrayDuplicates([...newConfig.packages, ...packages]);
196
+ if (args.packages) {
197
+ newConfig.packages = tools.removeArrayDuplicates([...newConfig.packages, ...args.packages]);
198
+ }
199
+
200
+ if (args.remotes) {
201
+ newConfig.remotes = tools.removeArrayDuplicates([...newConfig.remotes, ...args.remotes]);
175
202
  }
176
203
  }
177
204
 
@@ -381,3 +408,28 @@ module.exports.getNotificationMailAddress = (channelName) => {
381
408
  return channelPrefix + config.notification.mail.addressSuffix;
382
409
  }
383
410
 
411
+
412
+ module.exports.getLocalEuiVersion = () => {
413
+ let euiVersionsLocal = [
414
+ ...innerPackages.getLocalPackagesEuiVersion(),
415
+ ...innerProjects.getLocalProjectsEuiVersion(),
416
+ ];
417
+ euiVersionsLocal = tools.removeArrayDuplicates(euiVersionsLocal);
418
+
419
+ if (euiVersionsLocal.length > 1) {
420
+ tools.logError('Multiple versions of eUI found in local CSDR...aborting');
421
+ tools.logError(`Ensure tha you've not installed packages that differs in versions, check the log above to identify which one is problematic`);
422
+ console.log(euiVersionsLocal);
423
+ throw new Error('MULTIPLE_LOCAL_EUI_VERSIONS_FOUND');
424
+
425
+ } else {
426
+ tools.logSuccess('eUI version checked OK');
427
+ }
428
+
429
+ if (euiVersionsLocal) {
430
+ return euiVersionsLocal[0];
431
+
432
+ } else {
433
+ return null;
434
+ }
435
+ }
@@ -9,6 +9,7 @@ const tools = require('../../utils/tools');
9
9
  // INNER MODULES
10
10
  const innerProjects = require('./projects');
11
11
  const innerPackages = require('./packages');
12
+ const innerRemotes = require('./remotes');
12
13
  const innerGlobal = require('./global');
13
14
 
14
15
 
@@ -18,14 +19,21 @@ module.exports.run = (args) => {
18
19
  .then(() => {
19
20
  tools.logInfo('Updating local configuration')
20
21
 
21
- return getInputPackages(args.project, args.pkg, args.team, args.prjOnly, args.containerOnly);
22
- })
22
+ let packages = [], remotes = [];
23
+ if (args.project || args.pkg) {
24
+ packages = getInputPackages(args.project, args.pkg, args.team, args.prjOnly, args.containerOnly);
25
+ tools.logInfo('Found packages : ');
26
+ console.log(packages);
27
+ }
23
28
 
24
- .then((packages) => {
25
- tools.logInfo('Found packages : ');
26
- console.log(packages);
29
+ if (args.remote) {
30
+ const remote = innerRemotes.getRemote(args.remote);
31
+ if (remote) {
32
+ remotes.push(args.remote);
33
+ }
34
+ }
27
35
 
28
- return innerGlobal.updateConfig(args.project, packages, args.reset);
36
+ return innerGlobal.updateConfig({ project: args.project, packages: packages, remotes: remotes, reset: args.reset });
29
37
  })
30
38
 
31
39
  .catch((e) => {
@@ -46,7 +54,7 @@ const getInputPackages = (project, pkg, team, prjOnly, containerOnly) => {
46
54
  tools.logTitle(`Creating package entry for : ${pkg}`);
47
55
  addPackage(pkg);
48
56
 
49
- // when project or project and team are provided
57
+ // when project or project and team are provided
50
58
  } else {
51
59
  if (!containerOnly && !prjOnly) {
52
60
  tools.logTitle(`Creating packages entries for project:${project} / team:${team}`);
@@ -14,15 +14,6 @@ module.exports.getCsdrPackages = () => {
14
14
  return innerGlobal.getCsdrConfig(false).packages;
15
15
  }
16
16
 
17
- module.exports.getCsdrPackagesArray = () => {
18
- const pkgs = this.getCsdrPackages();
19
- const pkgsArray = Object.keys(this.getCsdrPackages()).map((p) => {
20
- return pkgs[p];
21
- });
22
-
23
- return pkgsArray;
24
- }
25
-
26
17
  module.exports.getCsdrPackagesFull = (flattenChildren = true) => {
27
18
  const packages = innerGlobal.getCsdrConfig(flattenChildren).packages;
28
19
  const packagesKeys = Object.keys(packages);
@@ -32,8 +23,8 @@ module.exports.getCsdrPackagesFull = (flattenChildren = true) => {
32
23
  try {
33
24
  outputPackages.push(this.getPackage(p, true));
34
25
  } catch (e) {
35
- // tools.logInfo(`Package: ${p} is in local config but not found in global... should be cleaned up`);
36
- // console.log(e);
26
+ tools.logInfo(`Package: ${p} is in local config but not found in global... should be cleaned up`);
27
+ console.log(e);
37
28
  }
38
29
  })
39
30
  return outputPackages;
@@ -48,8 +39,8 @@ const getPackages = module.exports.getPackages = () => {
48
39
  try {
49
40
  outputPackages.push(this.getPackage(p));
50
41
  } catch (e) {
51
- // tools.logInfo(`Package: ${p} is in local config but not found in global... should be cleaned up`);
52
- // console.log(e);
42
+ tools.logInfo(`Package: ${p} is in local config but not found in global... should be cleaned up`);
43
+ console.log(e);
53
44
  }
54
45
  })
55
46
  return outputPackages;
@@ -217,58 +208,6 @@ module.exports.getRemotePackages = () => {
217
208
  })
218
209
  }
219
210
 
220
- module.exports.getCsdrRemotePackages = (euiVersionNumber, hostNameTarget) => {
221
-
222
- const euiVersionFilterFn = (r) => {
223
- return r.name.indexOf(`eui${euiVersionNumber}`) > -1;
224
- }
225
-
226
- const appTargetFilterFn = (r) => {
227
- if (r.build) {
228
- if (!r.build.appTarget || r.build.appTarget === 'MWP_ONLY') {
229
- if (hostNameTarget === 'my-workplace') {
230
- return true;
231
- }
232
- } else if (r.build.appTarget === 'SEDIA_ONLY') {
233
- if (hostNameTarget === 'sedia') {
234
- return true;
235
- }
236
- } else if (r.build.appTarget === 'MWP_SEDIA') {
237
- if (hostNameTarget === 'my-workplace' || hostNameTarget === 'sedia') {
238
- return true;
239
- }
240
- } else {
241
- return false;
242
- }
243
- }
244
- }
245
-
246
- const remotes = this.getCsdrPackagesArray().filter(pkg => {
247
- return pkg.remote;
248
- })
249
-
250
- if (!euiVersionNumber && !hostNameTarget) {
251
- return remotes;
252
-
253
- } else if (euiVersionNumber && !hostNameTarget) {
254
- return remotes.filter((r) => {
255
- return euiVersionFilterFn(r);
256
- });
257
-
258
- } else if (!euiVersionNumber && hostNameTarget) {
259
- return remotes.filter((r) => {
260
- return appTargetFilterFn(r);
261
- });
262
-
263
- } else {
264
- return remotes.filter((r) => {
265
- return euiVersionFilterFn(r);
266
- }).filter((r) => {
267
- return appTargetFilterFn(r);
268
- })
269
- }
270
- }
271
-
272
211
  module.exports.getBuildablePackagesWithDeps = () => {
273
212
  return this.getDepGraph().overallOrder().filter(pkg => {
274
213
  if (!pkg.build) {
@@ -306,12 +245,8 @@ const getEuiVersionCore = (pkg) => {
306
245
  let version;
307
246
 
308
247
  const depsCompositeFile = path.join(pkg.paths.root, 'dependencies-composite.json');
309
- tools.logInfo(`---- Try fetching version from ${depsCompositeFile}`);
310
-
311
- if (!tools.isFileExists(depsCompositeFile)) {
312
- tools.logInfo('---- no dependencies-composite.json file found');
313
248
 
314
- } else {
249
+ if (tools.isFileExists(depsCompositeFile)) {
315
250
  const deps = tools.getJsonFileContent(depsCompositeFile);
316
251
  const euiDepsBase = deps['@eui/deps-base'];
317
252
 
@@ -333,47 +268,26 @@ const getEuiVersionCore = (pkg) => {
333
268
  }
334
269
 
335
270
 
336
- module.exports.getRemoteEuiVersion = (pkg) => {
271
+ const getPackageEuiVersion = module.exports.getPackageEuiVersion = (pkg, log = false) => {
337
272
  if (pkg.parent !== true && pkg.tsPackage !== false) {
338
- tools.logInfo(`checking --> ${pkg.name} <--`);
339
-
340
273
  let version;
341
274
 
342
275
  if (pkg.build && pkg.build.euiVersion) {
343
276
  version = pkg.build.euiVersion;
344
277
 
345
- } else {
346
- version = getEuiVersionCore(pkg);
347
- }
348
-
349
- if (version) {
350
- tools.logInfo(`---- version found : ${version}\n`);
351
- } else {
352
- tools.logInfo('---- version detection skipped');
353
- }
354
-
355
- return version;
356
- }
357
- }
358
-
359
-
360
- const getPackageEuiVersion = module.exports.getPackageEuiVersion = (pkg) => {
361
- if (pkg.parent !== true && pkg.tsPackage !== false) {
362
- tools.logInfo(`checking --> ${pkg.name} <--`);
363
-
364
- let version;
365
-
366
- if (pkg.build && pkg.build.euiVersion) {
367
- version = pkg.build.euiVersion;
278
+ } else if (pkg.euiVersion) {
279
+ version = pkg.euiVersion;
368
280
 
369
281
  } else if (!pkg.remote) {
370
282
  version = getEuiVersionCore(pkg);
371
283
  }
372
284
 
373
- if (version) {
374
- tools.logInfo(`---- version found : ${version}\n`);
375
- } else {
376
- tools.logInfo('---- version detection skipped');
285
+ if (log) {
286
+ if (version) {
287
+ tools.logInfo(`checking -->${pkg.name}<-- => version found : ${version}\n`);
288
+ } else {
289
+ tools.logInfo(`checking -->${pkg.name}<-- => version detection skipped`);
290
+ }
377
291
  }
378
292
 
379
293
  return version;
@@ -382,14 +296,14 @@ const getPackageEuiVersion = module.exports.getPackageEuiVersion = (pkg) => {
382
296
 
383
297
 
384
298
 
385
- module.exports.getLocalPackagesEuiVersion = () => {
299
+ module.exports.getLocalPackagesEuiVersion = (log = true) => {
386
300
  tools.logTitle('getting local packages installed eUI version...');
387
301
 
388
302
  const pkgs = getPackages();
389
303
  let versionsFound = [];
390
304
 
391
305
  pkgs.forEach((p) => {
392
- const version = getPackageEuiVersion(p);
306
+ const version = getPackageEuiVersion(p, log);
393
307
 
394
308
  if (version) {
395
309
  versionsFound.push(version);
@@ -224,12 +224,8 @@ const getEuiVersionCore = (project) => {
224
224
  let version;
225
225
 
226
226
  const depsCompositeFile = path.join(project.folder, 'dependencies-composite.json');
227
- tools.logInfo(`---- Try fetching version from ${depsCompositeFile}`);
228
227
 
229
- if (!tools.isFileExists(depsCompositeFile)) {
230
- tools.logInfo('---- no dependencies-composite.json file found');
231
-
232
- } else {
228
+ if (tools.isFileExists(depsCompositeFile)) {
233
229
  const jsonFileContnet = JSON.parse(tools.getFileContent(depsCompositeFile));
234
230
  const deps = jsonFileContnet.dependencies;
235
231
 
@@ -263,9 +259,9 @@ module.exports.getProjectEuiVersion = (project) => {
263
259
  const version = getEuiVersionCore(project);
264
260
 
265
261
  if (version) {
266
- tools.logInfo(`---- version found : ${version}\n`);
262
+ tools.logInfo(`checking ${project.name} => version found : ${version}\n`);
267
263
  } else {
268
- tools.logInfo('---- version detection skipped');
264
+ tools.logInfo(`checking ${project.name} => version detection skipped`);
269
265
  }
270
266
 
271
267
  return version;
@@ -279,18 +275,14 @@ module.exports.getLocalProjectsEuiVersion = () => {
279
275
  let versionsFound = [];
280
276
 
281
277
  prjs.forEach((p) => {
282
- tools.logInfo(`checking ${p.name}`);
283
-
284
278
  let version = 'DEFAULT';
285
279
 
286
280
  if (p.build && p.build.euiVersion) {
287
281
  version = p.build.euiVersion;
288
282
  } else {
289
- version = getEuiVersionCore(p);
283
+ version = this.getProjectEuiVersion(p);
290
284
  }
291
285
 
292
- tools.logInfo(`---- version found : ${version}`);
293
-
294
286
  versionsFound.push(version);
295
287
  })
296
288
 
@@ -58,7 +58,7 @@ module.exports.registerCsdrProject = (name, isFullSkeleton) => {
58
58
  tools.writeJsonFileSync(file, jsonFile);
59
59
 
60
60
  // inserting project entry into local config
61
- innerGlobal.updateConfig(name, null);
61
+ innerGlobal.updateConfig({ project: name });
62
62
  }
63
63
 
64
64
 
@@ -182,7 +182,6 @@ module.exports.registerCsdrPackage = (pkg, isRemote, rootPkgScope, rootPkgName,
182
182
  }
183
183
  }
184
184
 
185
-
186
185
  // inserting package in root config
187
186
  let packageDef;
188
187
 
@@ -202,6 +201,7 @@ module.exports.registerCsdrPackage = (pkg, isRemote, rootPkgScope, rootPkgName,
202
201
  packageDef = JSON.stringify(csdrConfigPackage);
203
202
  }
204
203
 
204
+ // replacing tokens
205
205
  let replaceModule = tools.replaceAll(packageDef, '@module.full.name@', pkg.name);
206
206
  replaceModule = tools.replaceAll(replaceModule, '@module.repo.name@', pkg.repoName);
207
207
  replaceModule = tools.replaceAll(replaceModule, '@module.npmPkg.name@', pkg.npmPkgName);
@@ -221,5 +221,12 @@ module.exports.registerCsdrPackage = (pkg, isRemote, rootPkgScope, rootPkgName,
221
221
  // inserting project entry into local config
222
222
  const packages = [];
223
223
  packages.push(pkg.name);
224
- innerGlobal.updateConfig(null, packages);
224
+
225
+ // updating euirc.json local config
226
+ if (isRemote && isVirtualRemote) {
227
+ innerGlobal.updateConfig({ remotes: packages });
228
+
229
+ } else {
230
+ innerGlobal.updateConfig({ packages: packages });
231
+ }
225
232
  }
@@ -6,6 +6,11 @@ const path = require('path');
6
6
  // LOCAL
7
7
  const tools = require('../../utils/tools');
8
8
 
9
+ // INNER
10
+ const innerGlobal = require('./global');
11
+
12
+
13
+
9
14
 
10
15
  module.exports.getRemote = (remoteName) => {
11
16
 
@@ -14,18 +19,13 @@ module.exports.getRemote = (remoteName) => {
14
19
  remoteName = tools.getArgs().root;
15
20
  }
16
21
 
17
- tools.logTitle(`Getting remote config for ${remoteName}`);
22
+ tools.logInfo(`Getting remote config for ${remoteName}`);
18
23
 
19
24
  const remotesConfig = require(path.join(process.cwd(), '.csdr', '.euirc-csdr-remotes.json'));
20
25
  const remoteConfig = remotesConfig[remoteName];
21
26
 
22
- tools.logInfo('Global config found');
23
- console.log(remoteConfig);
24
-
25
27
  const remotePath = path.join(process.cwd(), 'packages', 'csdr-remotes-config', 'assets', remoteName);
26
28
 
27
- tools.logInfo(`Getting remote information from ${remotePath}`);
28
-
29
29
  if (!tools.isDirExists(remotePath)) {
30
30
  throw new Error(`Remote ${remoteName} cannot be found in the remotes global config - check packages/csdr-remotes-config for available remotes`);
31
31
  }
@@ -37,8 +37,6 @@ module.exports.getRemote = (remoteName) => {
37
37
  element: true,
38
38
  remote: true,
39
39
  virtual: true,
40
- angularConfig: tools.getJsonFileContent(path.join(remotePath, 'angular-config.json')),
41
- dependencies: tools.getJsonFileContent(path.join(remotePath, 'dependencies.json')),
42
40
  paths: {
43
41
  root: remoteRootPath,
44
42
  dist: path.join(remoteRootPath, 'dist'),
@@ -46,6 +44,8 @@ module.exports.getRemote = (remoteName) => {
46
44
  fromRoot: `remotes/${remoteName}`,
47
45
  repoNodeModules: path.join(remoteRootPath, 'node_modules'),
48
46
  },
47
+ angularConfig: tools.getJsonFileContent(path.join(remotePath, 'angular-config.json')),
48
+ dependencies: tools.getJsonFileContent(path.join(remotePath, 'dependencies.json')),
49
49
  devopsMetadataFile: `${remoteName}-build-metadata.json`,
50
50
  devopsVersionsMetadataFile: `${remoteName}-versions-metadata.json`,
51
51
  devopsHistoryMetadataFile: `${remoteName}-history-metadata.json`,
@@ -59,3 +59,59 @@ module.exports.getRemote = (remoteName) => {
59
59
 
60
60
  return remote;
61
61
  }
62
+
63
+
64
+ module.exports.getCsdrRemotes = (hostName, euiVersion) => {
65
+
66
+ const hostNameFilterFn = (r) => {
67
+ if (r.build) {
68
+ if (!r.build.appTarget || r.build.appTarget === 'MWP_ONLY') {
69
+ if (hostName === 'my-workplace') {
70
+ return true;
71
+ }
72
+ } else if (r.build.appTarget === 'SEDIA_ONLY') {
73
+ if (hostName === 'sedia') {
74
+ return true;
75
+ }
76
+ } else if (r.build.appTarget === 'MWP_SEDIA') {
77
+ if (hostName === 'my-workplace' || hostName === 'sedia') {
78
+ return true;
79
+ }
80
+ } else {
81
+ return false;
82
+ }
83
+ }
84
+ }
85
+
86
+ tools.logInfo(`Getting remotes for host: ${hostName} - euiVersion: ${euiVersion}`);
87
+
88
+ const remotesConfig = require(path.join(process.cwd(), '.csdr', '.euirc-csdr-remotes.json'));
89
+ const remotesArray = Object.keys(remotesConfig).map((r) => {
90
+ const remote = remotesConfig[r];
91
+ remote.name = r;
92
+ return remote;
93
+ });
94
+
95
+ let outRemotes = remotesArray;
96
+
97
+ if (hostName) {
98
+ outRemotes = outRemotes.filter(r => hostNameFilterFn(r));
99
+ }
100
+ if (euiVersion) {
101
+ outRemotes = outRemotes.filter(r => r.euiVersion === euiVersion);
102
+ }
103
+
104
+ return outRemotes;
105
+ }
106
+
107
+
108
+ module.exports.getRemotes = () => {
109
+ const remotes = innerGlobal.getConfig().remotes;
110
+ const remotesKeys = Object.keys(remotes);
111
+
112
+ let outputRemotes = [];
113
+ remotesKeys.forEach((r) => {
114
+ outputRemotes.push(this.getRemote(r));
115
+ })
116
+ return outputRemotes;
117
+ }
@@ -22,7 +22,7 @@ module.exports.run = () => {
22
22
  tools.logInfo('Synching packages and local config');
23
23
 
24
24
  // just for recall of the config getter which potentially execute the migrate from old config version
25
- const packages = innerPackages.getPackages();
25
+ // const packages = innerPackages.getPackages();
26
26
 
27
27
  const pkgFolders = tools.getFolders(path.join(process.cwd(), 'packages'));
28
28
  const prjFolders = tools.getFolders(path.join(process.cwd(), 'apps'));
@@ -40,6 +40,8 @@ module.exports.run = () => {
40
40
  tools.logInfo('Host projects folders found:');
41
41
  console.log(hostFolders);
42
42
 
43
+ tools.logInfo('Remotes folders found:');
44
+ console.log(remoteFolders);
43
45
 
44
46
  // for projects, we need to take the known rootName based on the folder from the CSDR global config
45
47
  let projects = [];
@@ -69,7 +71,8 @@ module.exports.run = () => {
69
71
  // update the local config file
70
72
  const config = {
71
73
  projects: projects,
72
- packages: [...pkgFolders, ...remoteFolders]
74
+ packages: pkgFolders,
75
+ remotes: remoteFolders
73
76
  };
74
77
 
75
78
  tools.writeJsonFileSync(path.join(process.cwd(), '.csdr', '.euirc.json'), config);
@@ -8,40 +8,12 @@ const tools = require('../../utils/tools');
8
8
  const configUtils = require('../config/config-utils');
9
9
 
10
10
 
11
-
12
- const getLocalEuiVersion = module.exports.getLocalEuiVersion = () => {
13
- let euiVersionsLocal = [
14
- ...configUtils.packages.getLocalPackagesEuiVersion(),
15
- ...configUtils.projects.getLocalProjectsEuiVersion(),
16
- ];
17
- euiVersionsLocal = tools.removeArrayDuplicates(euiVersionsLocal);
18
-
19
- if (euiVersionsLocal.length > 1) {
20
- tools.logError('Multiple versions of eUI found in local CSDR...aborting');
21
- tools.logError(`Ensure tha you've not installed packages that differs in versions, check the log above to identify which one is problematic`);
22
- console.log(euiVersionsLocal);
23
- throw new Error('MULTIPLE_LOCAL_EUI_VERSIONS_FOUND');
24
-
25
- } else {
26
- tools.logSuccess('eUI version checked OK');
27
- }
28
-
29
- if (euiVersionsLocal) {
30
- return euiVersionsLocal[0];
31
-
32
- } else {
33
- return null;
34
- }
35
- }
36
-
37
-
38
-
39
11
  module.exports.processLocalEuiVersions = () => {
40
12
  tools.logTitle('Processing injections for local installed eUI versions if needed');
41
13
 
42
14
  return Promise.resolve()
43
15
  .then(() => {
44
- const euiVersion = getLocalEuiVersion();
16
+ const euiVersion = configUtils.global.getLocalEuiVersion();
45
17
 
46
18
  if (!euiVersion || euiVersion === 'DEFAULT') {
47
19
  tools.logInfo('Default eUI version found or empty...skipping');
@@ -61,7 +61,16 @@ module.exports.init = () => {
61
61
 
62
62
  // if no project has been provided we prompt for project and team selection
63
63
  if (!project && !pkg && !remote) {
64
- return initUtils.prompt.start();
64
+ // TODO refactor to handle dynamic mywp-host-playground install (pre-remotes install etc...)
65
+ // return initUtils.prompt.start();
66
+ tools.logError('****************************************');
67
+ tools.logError('*************** ERROR ******************');
68
+ tools.logError('****************************************\n');
69
+ tools.logError('At least "pkg" or "project" or "remote" type should be used for init, for example :\n');
70
+ tools.logError('npm run init -- --pkg PKG_NAME [--branch BRANCH_NAME|default develop] [--git local] [--pkgOnly] [--skipInstall]');
71
+ tools.logError('npm run init -- --project PROJECT_NAME [--branch BRANCH_NAME|default develop] [--git local] [--prjOnly] [--skipInstall]');
72
+ tools.logError('npm run init -- --remote VIRTUAL_REMOTE_NAME [--remoteOnly] [--skipInstall]');
73
+ process.exit(0);
65
74
 
66
75
  // if provided, we are on automated mode, we use the initialized response
67
76
  } else {
@@ -80,9 +89,7 @@ module.exports.init = () => {
80
89
  // Initializing .euirc.json local file - the core of CSDR operations
81
90
  .then(() => {
82
91
  // Initialize config
83
- if (!finalResponse.remote) {
84
- return configUtils.init.run(finalResponse);
85
- }
92
+ return configUtils.init.run(finalResponse);
86
93
  })
87
94
 
88
95
  // clone or install linked host package to project if any
@@ -17,37 +17,23 @@ const importPackage = (pkg, args) => {
17
17
 
18
18
  if (pkg.parent) {
19
19
  tools.logInfo('Parent package ... skipping import');
20
- return Promise.resolve();
21
20
 
22
21
  } else {
23
22
  if (pkg.tsPackage !== false) {
24
- return Promise.resolve()
25
- .then(() => {
26
- if (!pkg.element) {
27
- return configUtils.angular.registerAngularPackage(pkg, args.reset);
28
- } else if (pkg.element) {
29
- return configUtils.angular.registerAngularProjectDef(pkg, args.reset, true);
30
- } else {
31
- return configUtils.angular.registerAngularProjectDef(pkg, args.reset);
32
- }
33
- })
34
- .then(() => {
35
- if (pkg.pathInclude !== false && !pkg.element) {
36
- return configUtils.angular.registerModulePaths(pkg, args.reset);
37
- }
38
- })
39
-
40
- .then(() => {
41
- tools.logSuccess('OK => package imported');
42
- })
43
-
44
- .catch((e) => {
45
- throw e;
46
- })
23
+ if (!pkg.element) {
24
+ configUtils.angular.registerAngularPackage(pkg, args.reset);
25
+ } else if (pkg.element) {
26
+ configUtils.angular.registerAngularProjectDef(pkg, args.reset, true);
27
+ } else {
28
+ configUtils.angular.registerAngularProjectDef(pkg, args.reset);
29
+ }
30
+ if (pkg.pathInclude !== false && !pkg.element) {
31
+ configUtils.angular.registerModulePaths(pkg, args.reset);
32
+ }
33
+ tools.logSuccess('OK => package imported');
47
34
 
48
35
  } else {
49
36
  tools.logInfo('Non TS package... skipping registration');
50
- return Promise.resolve();
51
37
  }
52
38
  }
53
39
  }
@@ -55,43 +41,31 @@ const importPackage = (pkg, args) => {
55
41
 
56
42
 
57
43
 
58
-
59
44
  module.exports.importPackages = (args = {}) => {
60
45
 
61
46
  tools.logTitle('Importing configuration of packages');
62
47
 
63
- const packages = configUtils.packages.getPackages();
48
+ // checking configFiles / force reset on sync
49
+ configUtils.angular.checkConfigFiles(args.reset);
64
50
 
65
- return Promise.resolve()
66
- .then(() => {
67
- configUtils.angular.checkConfigFiles(args.reset);
68
- })
51
+ // registering package in local config
69
52
 
70
- .then(() => {
71
- if (args.pkgOnly || args.remoteOnly) {
72
- if (args.pkg) {
73
- return importPackage(configUtils.packages.getPackage(args.pkg), args);
74
- } else if (args.remote) {
75
- return importPackage(configUtils.remotes.getRemote(args.remote), args);
76
- }
77
- } else {
78
- Promise.resolve().then(() => {
79
- return packages.reduce((promise, pkg) => {
80
- return promise.then(() => (
81
- importPackage(pkg, args)
82
- ));
83
- }, Promise.resolve());
84
- })
85
- }
86
- })
53
+ // in case of "only" param we initialize only the package or remote provided as arg
54
+ if (args.pkgOnly || args.remoteOnly) {
55
+ if (args.pkg) {
56
+ importPackage(configUtils.packages.getPackage(args.pkg), args);
57
+ } else if (args.remote) {
58
+ importPackage(configUtils.remotes.getRemote(args.remote), args);
59
+ }
87
60
 
88
- .then(() => {
89
- tools.logSuccess('OK => all packages successfully imported');
90
- })
61
+ // otherwise all known packages are re-registered (in case of sync this happens by default to force refresh packages config)
62
+ } else {
63
+ const packages = configUtils.packages.getPackages();
91
64
 
92
- .catch((e) => {
93
- throw e;
65
+ packages.forEach((p) => {
66
+ importPackage(p, args);
94
67
  })
68
+ }
95
69
  }
96
70
 
97
71
 
@@ -119,7 +93,7 @@ module.exports.cloneHostPackage = (projectName) => {
119
93
  .then(() => {
120
94
  const newPackages = [];
121
95
  newPackages.push(pkg.name);
122
- return configUtils.global.updateConfig(null, newPackages);
96
+ return configUtils.global.updateConfig({ packages: newPackages });
123
97
  })
124
98
 
125
99
  .catch((e) => {
@@ -22,7 +22,7 @@ const cloneRemotesConfig = module.exports.cloneRemotesConfig = () => {
22
22
 
23
23
  const newPackages = [];
24
24
  newPackages.push(pkg.name);
25
- return configUtils.global.updateConfig(null, newPackages);
25
+ return configUtils.global.updateConfig({ packages: newPackages });
26
26
  })
27
27
 
28
28
  .then(() => {
@@ -191,36 +191,26 @@ const getLocalProjectRemoteDeps = module.exports.getLocalProjectRemoteDeps = (pr
191
191
 
192
192
  if (prj.initRemoteDependencies && remotesImport) {
193
193
 
194
- tools.logTitle('Importing remotes deps');
194
+ tools.logTitle(`Detecting remotes deps for project : ${prj.name}`);
195
195
 
196
- return Promise.resolve()
197
- .then(() => {
198
- return metadataUtils.package.getPackagesDeps('packages');
199
- })
200
-
201
- .then((snapshotsMetadata) => {
202
- let remoteDeps = {};
203
-
204
- const euiVersion = configUtils.projects.getProjectEuiVersion(prj).split('.')[0];
205
- const remotes = configUtils.packages.getCsdrRemotePackages(euiVersion, prj.hostName);
206
-
207
- remotes
208
- .map((p) => {
209
- return { npmgPkg: p.npmPkg, version: snapshotsMetadata[p.npmPkg] }
210
- })
211
- .forEach((r) => {
212
- if (!r.version) {
213
- tools.logInfo(`${r.npmgPkg} => no version found, probably the remote hasn't been released yet...skipping`)
214
- } else {
215
- remoteDeps[r.npmgPkg] = r.version;
216
- }
217
- })
218
-
219
- tools.logInfo('Remotes found :');
220
- console.log(remoteDeps);
196
+ const euiVersion = configUtils.global.getLocalEuiVersion();
197
+ const remotes = configUtils.remotes.getCsdrRemotes(prj.hostName, euiVersion);
221
198
 
222
- return remoteDeps;
199
+ let remoteDeps = {};
200
+ remotes
201
+ .map(r => configUtils.remotes.getRemote(r.name))
202
+ .map((r) => {
203
+ return { npmgPkg: r.npmPkg, version: metadataUtils.package.getPackageVersionLast(r) }
223
204
  })
205
+ .forEach((r) => {
206
+ if (!r.version) {
207
+ tools.logInfo(`${r.npmgPkg} => no version found, probably the remote hasn't been released yet...skipping`)
208
+ } else {
209
+ remoteDeps[r.npmgPkg] = r.version;
210
+ }
211
+ })
212
+
213
+ return remoteDeps;
224
214
  }
225
215
  }
226
216
 
@@ -13,7 +13,7 @@ const innerCommon = require('./common');
13
13
  const innerCompositeCore = require('./composite-core');
14
14
 
15
15
  // FETCH ARGS
16
- const { dryRun } = tools.getArgs();
16
+ const { dryRun, skipRemotes } = tools.getArgs();
17
17
 
18
18
 
19
19
  const allPkgInstall = (envTarget, compositeType) => {
@@ -24,11 +24,17 @@ const allPkgInstall = (envTarget, compositeType) => {
24
24
  tools.logInfo('Getting remote installable packages');
25
25
 
26
26
  // filter on packages who are considered remote and for which dependencies have been found
27
- let packages = configUtils.packages.getRemotePackages().filter((p) => {
27
+ const packages = configUtils.packages.getRemotePackages().filter((p) => {
28
28
  return p.paths.remoteNodeModules;
29
29
  });
30
30
 
31
- return packages;
31
+ // adding new "remotes" type for new stand-alone remote config
32
+ let remotes = [];
33
+ if (!skipRemotes) {
34
+ remotes = configUtils.remotes.getRemotes();
35
+ }
36
+
37
+ return [...packages, ...remotes];
32
38
  })
33
39
 
34
40
  // iterate on all packages found earlier
@@ -230,9 +230,7 @@ module.exports.getPackageVersionsLatest = (pkg) => {
230
230
  module.exports.getPackageVersionLast = (pkg) => {
231
231
  const pkgVersionsJson = this.getPackageVersionsJson(pkg);
232
232
 
233
-
234
-
235
- if (pkgVersionsJson) {
233
+ if (pkgVersionsJson && pkgVersionsJson.versions) {
236
234
  return pkgVersionsJson.versions.splice(-1)[0].version;
237
235
  }
238
236
 
@@ -4,9 +4,6 @@
4
4
  const tools = require('./tools');
5
5
  const configUtils = require('../csdr/config/config-utils');
6
6
 
7
- // FETCH OPTIONS
8
- const { API_HOST } = configUtils.global.getConfigOptions();
9
-
10
7
  // FETCH ARGS
11
8
  const { apiUserId, apiPassword } = tools.getArgs();
12
9
 
@@ -26,6 +23,7 @@ const handleResponse = (response) => {
26
23
 
27
24
  module.exports.login = () => {
28
25
  const fetch = require('node-fetch');
26
+ const { API_HOST } = configUtils.global.getConfigOptions();
29
27
 
30
28
  tools.logInfo(`API Login - userId:${apiUserId}`);
31
29
 
@@ -57,6 +55,7 @@ module.exports.login = () => {
57
55
 
58
56
  module.exports.get = (pathName) => {
59
57
  const fetch = require('node-fetch');
58
+ const { API_HOST } = configUtils.global.getConfigOptions();
60
59
 
61
60
  tools.logInfo(`API get - pathName: ${pathName}`);
62
61
 
@@ -91,6 +90,7 @@ module.exports.get = (pathName) => {
91
90
 
92
91
  module.exports.post = (pathName, body) => {
93
92
  const fetch = require('node-fetch');
93
+ const { API_HOST } = configUtils.global.getConfigOptions();
94
94
 
95
95
  tools.logInfo(`API post - pathName: ${pathName} - body: ${JSON.stringify(body)}`);
96
96
 
@@ -16,7 +16,7 @@ let { configuration, baseHref, dryRun, statsJson, sourceMap, build } = tools.get
16
16
  module.exports.build = (pkg, isMaster) => {
17
17
 
18
18
  const ng = path.resolve(pkg.paths.repoNodeModules, '@angular', 'cli', 'bin', 'ng');
19
- const remoteEuiVersion = configUtils.packages.getRemoteEuiVersion(pkg);
19
+ const remoteEuiVersion = configUtils.packages.getPackageEuiVersion(pkg, true);
20
20
  const pkgName = pkg.name;
21
21
 
22
22
  tools.logTitle(`Building element : ${pkgName}...`);
@@ -94,7 +94,7 @@ module.exports.build = (pkg, isMaster) => {
94
94
  module.exports.postBuild = (pkg, version) => {
95
95
  tools.logInfo('Executing element post-build...');
96
96
 
97
- const remoteEuiVersion = configUtils.packages.getRemoteEuiVersion(pkg);
97
+ const remoteEuiVersion = configUtils.packages.getPackageEuiVersion(pkg);
98
98
  const euiVersionNumber = remoteEuiVersion.split('.')[0];
99
99
 
100
100
  if (dryRun) {
@@ -23,7 +23,7 @@ module.exports.serve = (remote = false) => {
23
23
 
24
24
  const pkgName = pkg.name;
25
25
 
26
- const remoteEuiVersion = configUtils.packages.getRemoteEuiVersion(pkg);
26
+ const remoteEuiVersion = configUtils.packages.getPackageEuiVersion(pkg);
27
27
  const euiVersionNumber = remoteEuiVersion.split('.')[0];
28
28
 
29
29
  const ng = path.resolve(pkg.paths.repoNodeModules, '@angular', 'cli', 'bin', 'ng');