Skip to content

Commit

Permalink
chore: update migration tool to run 006-007 (#3700)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmerget authored Jan 21, 2025
1 parent a251296 commit b7dc6bc
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 4 deletions.
24 changes: 22 additions & 2 deletions docs/migration/v0.6.x-to-v0.7.x.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
## Migration Beta (0.6.x) ➡ Beta (0.7.x)

### Removed brand fonts
### Removed brand assets

We needed to remove the brand fonts from our [`@db-ui/foundations`](https://www.npmjs.com/package/@db-ui/foundations) node package. Please follow the guidelines within [DB Marketingportal](https://marketingportal.extranet.deutschebahn.com/marketingportal/Design-Anwendungen/db-ux-design-system/resources/db-theme) on how to retrieve it as an Inner Source package (DB internal) or to still install the node package from npmjs.com (DB external).
We needed to remove the brand assets (font & icons) from our [`@db-ui/foundations`](https://www.npmjs.com/package/@db-ui/foundations) node package. Please follow the guidelines within [DB Marketingportal](https://marketingportal.extranet.deutschebahn.com/marketingportal/Design-Anwendungen/db-ux-design-system/resources/db-theme) on how to retrieve it either as an Inner Source package (DB internal) or to still install the node package from [npmjs.com](https://www.npmjs.com/package/@db-ux/db-theme) (DB external).

### Path changes

We needed to change some path, so you would probably need to make some adaptions within your code:
- Changed `@db-ui/foundations/build/scss/` to `@db-ui/foundations/build/styles/`
- Changed `@db-ui/foundations/build/css/` to `@db-ui/foundations/build/styles/`
- Changed `@db-ux/core-icons/` to `@db-ux/core-icons/build`

And icon font files have been moved from `functional/fonts/` one level up to `fonts/` folder, probably you would need to copy those to your codebase as well again if you don't use a bundler.

## Automate migration via CLI

We provide a CLI tool to auto migrate your source code. Use this command in your repository:

\```shell

npx @db-ui/migration --type=v006_v007 --src=./src
\```

Please check the changes made in your codebase afterwards, as this is mainly a simple search & replace regarding the path.
4 changes: 3 additions & 1 deletion packages/migration/src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { colorQ32024 } from './migration/color-q32024';
import type { ReplaceInFileConfig } from 'replace-in-file';
import { iconQ32024 } from './migration/icon-q32024';
import { v005_v006 } from './migration/v0.0.5-v0.0.6';
import { v006_v007 } from './migration/v0.0.6-v0.0.7';

export const migrationTypes: Record<string, ReplaceInFileConfig[]> = {
colorQ32024,
iconQ32024,
v005_v006
v005_v006,
v006_v007
};

export const options: ProgrammOptionsType[] = [
Expand Down
4 changes: 4 additions & 0 deletions packages/migration/src/migration/additional-information.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const AdditionalInformation: Record<string, string> = {
v006_v007:
'https://github.com/db-ui/mono/blob/main/docs/migration/v0.6.x-to-v0.7.x.md'
};
8 changes: 8 additions & 0 deletions packages/migration/src/migration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { ReplaceInFileConfig, ReplaceResult } from 'replace-in-file';
import { replaceInFileSync } from 'replace-in-file';
import type { OptionsType } from '../types';
import { migrationTypes } from '../data';
import { AdditionalInformation } from './additional-information';

export const migrate = (
options?: OptionsType,
Expand Down Expand Up @@ -31,6 +32,13 @@ export const migrate = (
[]
);

for (const t of type) {
const additionalInfo = AdditionalInformation[t];
if (additionalInfo) {
console.log(`Find more information here: ${additionalInfo}`);
}
}

for (const update of replacements) {
const option = {
...update,
Expand Down
34 changes: 34 additions & 0 deletions packages/migration/src/migration/v0.0.6-v0.0.7.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { ReplaceInFileConfig } from 'replace-in-file';

export const v006_v007: ReplaceInFileConfig[] = [
{
files: '',
from: /db-ui-42-/g,
to: ''
},
{
files: '',
from: /db-ui-42/g,
to: 'relative'
},
{
files: '',
from: /db-ui-foundations-/g,
to: ''
},
{
files: '',
from: /db-ui-foundations/g,
to: 'relative'
},
{
files: '',
from: /foundations\/build\/css/g,
to: 'foundations/build/styles'
},
{
files: '',
from: /foundations\/build\/scss/g,
to: 'foundations/build/styles'
}
];
2 changes: 1 addition & 1 deletion packages/migration/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export type ProgrammOptionsType = {

export type OptionsType = {
src: string;
type: (string | 'colorQ32024' | 'iconQ32024' | 'v005_v006')[];
type: (string | 'colorQ32024' | 'iconQ32024' | 'v005_v006' | 'v006_v007')[];
dryRun?: string | boolean;
};
5 changes: 5 additions & 0 deletions packages/migration/test/v0.0.6-v0.0.7/has-changes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import "@db-ui/components/build/styles/db-ui-42-rollup.css";

@use "@db-ui/foundations/build/scss/variables";
@use "@db-ui/foundations/build/scss/colors";
@use "@db-ui/foundations/build/scss/screen-sizes";
5 changes: 5 additions & 0 deletions packages/migration/test/v0.0.6-v0.0.7/no-change.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import "@db-ui/components/build/styles/rollup.css";

@use "@db-ui/foundations/build/styles/variables";
@use "@db-ui/foundations/build/styles/colors";
@use "@db-ui/foundations/build/styles/screen-sizes";
19 changes: 19 additions & 0 deletions packages/migration/test/v0.0.6-v0.0.7/v006_v007.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { describe, expect, test } from 'vitest';
import { type ReplaceResult } from 'replace-in-file';
import { migrate } from '../../src/migration';

describe('v006_v007', () => {
test('check if changes are detected', async () => {
const result = migrate({
src: './test/v0.0.6-v0.0.7',
type: ['v006_v007'],
dryRun: true
});

expect(result).not.undefined;

expect(
(result as ReplaceResult[]).filter((res) => res.hasChanged)
).toHaveLength(1);
});
});

0 comments on commit b7dc6bc

Please sign in to comment.