@entur/typography 1.10.0-beta.11 → 1.10.0-beta.13

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entur/typography",
3
- "version": "1.10.0-beta.11",
3
+ "version": "1.10.0-beta.13",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/typography.esm.js",
@@ -42,5 +42,5 @@
42
42
  "devDependencies": {
43
43
  "dts-cli": "2.0.5"
44
44
  },
45
- "gitHead": "43d0a9514cbaeb6c8e319c4286bed9bd3ea21b22"
45
+ "gitHead": "c9b59ab0f79e2611a602951c89f4f2c8213e235f"
46
46
  }
@@ -658,7 +658,26 @@ function updateImports(content) {
658
658
  let hasChanges = false;
659
659
  const uniqueComponents = new Set();
660
660
 
661
- // Check each component in the import list
661
+ // First, collect all existing components that should be preserved
662
+ const existingComponents = importList
663
+ .split(',')
664
+ .map(comp => comp.trim())
665
+ .filter(comp => {
666
+ // Skip empty components
667
+ if (!comp) return false;
668
+
669
+ // Keep components that are:
670
+ // 1. Not in the migration mapping (old components), OR
671
+ // 2. Are the target components (new beta components)
672
+ const isOldComponent = Object.keys(COMPONENT_MAPPING).includes(comp);
673
+ const isTargetComponent = Object.values(COMPONENT_MAPPING).some(
674
+ mapping => mapping.component === comp,
675
+ );
676
+
677
+ return !isOldComponent || isTargetComponent;
678
+ });
679
+
680
+ // Then, update components that need migration
662
681
  Object.entries(COMPONENT_MAPPING).forEach(([oldComponent, mapping]) => {
663
682
  const componentRegex = new RegExp(`\\b${oldComponent}\\b`, 'g');
664
683
  if (componentRegex.test(updatedImportList)) {
@@ -673,8 +692,18 @@ function updateImports(content) {
673
692
 
674
693
  if (hasChanges) {
675
694
  changes++;
676
- // Deduplicate components and create clean import statement
677
- const finalImportList = Array.from(uniqueComponents).join(', ');
695
+ // Combine existing components with migrated components
696
+ const allComponents = [
697
+ ...existingComponents,
698
+ ...Array.from(uniqueComponents),
699
+ ];
700
+
701
+ // Filter out any empty components and deduplicate
702
+ const finalComponents = allComponents
703
+ .filter(comp => comp && comp.trim())
704
+ .filter((comp, index, arr) => arr.indexOf(comp) === index); // Remove duplicates
705
+
706
+ const finalImportList = finalComponents.join(', ');
678
707
  return `import {${finalImportList}} from '${BETA_IMPORT}'`;
679
708
  }
680
709