diff --git a/docs/migration/v0.6.x-to-v0.7.x.md b/docs/migration/v0.6.x-to-v0.7.x.md index 447418803fe..8b683e13419 100644 --- a/docs/migration/v0.6.x-to-v0.7.x.md +++ b/docs/migration/v0.6.x-to-v0.7.x.md @@ -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. diff --git a/packages/migration/src/data.ts b/packages/migration/src/data.ts index 7443cec93c2..08dac40353d 100644 --- a/packages/migration/src/data.ts +++ b/packages/migration/src/data.ts @@ -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 = { colorQ32024, iconQ32024, - v005_v006 + v005_v006, + v006_v007 }; export const options: ProgrammOptionsType[] = [ diff --git a/packages/migration/src/migration/additional-information.ts b/packages/migration/src/migration/additional-information.ts new file mode 100644 index 00000000000..032370e3427 --- /dev/null +++ b/packages/migration/src/migration/additional-information.ts @@ -0,0 +1,4 @@ +export const AdditionalInformation: Record = { + v006_v007: + 'https://github.com/db-ui/mono/blob/main/docs/migration/v0.6.x-to-v0.7.x.md' +}; diff --git a/packages/migration/src/migration/index.ts b/packages/migration/src/migration/index.ts index 48700783c02..c41fc72bb9e 100644 --- a/packages/migration/src/migration/index.ts +++ b/packages/migration/src/migration/index.ts @@ -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, @@ -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, diff --git a/packages/migration/src/migration/v0.0.6-v0.0.7.ts b/packages/migration/src/migration/v0.0.6-v0.0.7.ts new file mode 100644 index 00000000000..c229d47f535 --- /dev/null +++ b/packages/migration/src/migration/v0.0.6-v0.0.7.ts @@ -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' + } +]; diff --git a/packages/migration/src/types.ts b/packages/migration/src/types.ts index cfd22dc126b..6359021e84d 100644 --- a/packages/migration/src/types.ts +++ b/packages/migration/src/types.ts @@ -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; }; diff --git a/packages/migration/test/v0.0.6-v0.0.7/has-changes.txt b/packages/migration/test/v0.0.6-v0.0.7/has-changes.txt new file mode 100644 index 00000000000..fe3cbca5eec --- /dev/null +++ b/packages/migration/test/v0.0.6-v0.0.7/has-changes.txt @@ -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"; diff --git a/packages/migration/test/v0.0.6-v0.0.7/no-change.txt b/packages/migration/test/v0.0.6-v0.0.7/no-change.txt new file mode 100644 index 00000000000..ff1027c2b6d --- /dev/null +++ b/packages/migration/test/v0.0.6-v0.0.7/no-change.txt @@ -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"; diff --git a/packages/migration/test/v0.0.6-v0.0.7/v006_v007.spec.ts b/packages/migration/test/v0.0.6-v0.0.7/v006_v007.spec.ts new file mode 100644 index 00000000000..61d5fa2b758 --- /dev/null +++ b/packages/migration/test/v0.0.6-v0.0.7/v006_v007.spec.ts @@ -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); + }); +});