trm-core 6.1.0 → 6.1.2

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.
@@ -371,7 +371,8 @@ class Manifest {
371
371
  }
372
372
  catch (e) { }
373
373
  }
374
- manifestClone.authors = aAuthors;
374
+ aAuthors = aAuthors.filter(o => !o.name && !o.email);
375
+ manifestClone.authors = Array.from(new Map(aAuthors.map(o => [`${o.name}${o.email}`, o])).values());
375
376
  if (manifestClone.authors.length === 0) {
376
377
  delete manifestClone.authors;
377
378
  }
@@ -391,7 +392,9 @@ class Manifest {
391
392
  for (var originalKeyword of originalKeywords) {
392
393
  try {
393
394
  originalKeyword = originalKeyword.replace(/\s/g, '').toLowerCase();
394
- manifestClone.keywords.push(originalKeyword);
395
+ if (!originalKeyword || !manifestClone.keywords.includes(originalKeyword)) {
396
+ manifestClone.keywords.push(originalKeyword);
397
+ }
395
398
  }
396
399
  catch (e) { }
397
400
  }
@@ -413,10 +416,15 @@ class Manifest {
413
416
  if (semver.validRange(originalDependency.version)) {
414
417
  dependency.version = originalDependency.version;
415
418
  dependency.integrity = originalDependency.integrity;
419
+ if (!dependency.integrity) {
420
+ throw new Error(`Dependency ${dependency.name} is missing its integrity.`);
421
+ }
416
422
  if (originalDependency.registry) {
417
423
  dependency.registry = originalDependency.registry;
418
424
  }
419
- manifestClone.dependencies.push(dependency);
425
+ if (!manifestClone.dependencies.find(o => o.name === dependency.name && o.registry === dependency.registry)) {
426
+ manifestClone.dependencies.push(dependency);
427
+ }
420
428
  }
421
429
  }
422
430
  }
@@ -429,9 +437,21 @@ class Manifest {
429
437
  else {
430
438
  delete manifestClone.dependencies;
431
439
  }
432
- if (!manifestClone.sapEntries) {
440
+ if (!manifestClone.sapEntries || typeof manifestClone.sapEntries !== 'object') {
433
441
  delete manifestClone.sapEntries;
434
442
  }
443
+ else {
444
+ for (const key in manifestClone.sapEntries) {
445
+ if (!Array.isArray(manifestClone.sapEntries[key])) {
446
+ throw new Error(`Invalid structure in SAP entries declaration.`);
447
+ }
448
+ for (const item of manifestClone.sapEntries[key]) {
449
+ if (typeof item !== 'object' || item === null) {
450
+ throw new Error(`Invalid structure in SAP entries declaration.`);
451
+ }
452
+ }
453
+ }
454
+ }
435
455
  if (manifestClone.distFolder) {
436
456
  try {
437
457
  manifestClone.distFolder = manifestClone.distFolder.replace(/^\//, '');
@@ -603,7 +623,7 @@ class Manifest {
603
623
  if (sAuthors) {
604
624
  sAuthors.split(',').forEach(s => {
605
625
  if (s) {
606
- const match = sAuthors.trim().match(/^(.*?)(?:\s*<([^>]+)>)?$/);
626
+ const match = s.trim().match(/^(.*?)(?:\s*<([^>]+)>)?$/);
607
627
  if (match && match.length >= 3) {
608
628
  authors.push({
609
629
  name: match[1] ? match[1].trim() : undefined,
@@ -617,11 +637,11 @@ class Manifest {
617
637
  }
618
638
  static stringKeywordsToArray(sKeywords) {
619
639
  if (sKeywords) {
620
- sKeywords.split(',').map(s => {
640
+ return sKeywords.split(',').map(s => {
621
641
  if (s) {
622
642
  return s.trim();
623
643
  }
624
- });
644
+ }).filter(k => k !== undefined);
625
645
  }
626
646
  else {
627
647
  return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trm-core",
3
- "version": "6.1.0",
3
+ "version": "6.1.2",
4
4
  "description": "TRM (Transport Request Manager) Core",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",