Skip to content

Commit

Permalink
chore: move migration to own package
Browse files Browse the repository at this point in the history
  • Loading branch information
nmerget committed Dec 10, 2024
1 parent 1f5d1f2 commit 9f170db
Show file tree
Hide file tree
Showing 30 changed files with 139 additions and 57 deletions.
4 changes: 2 additions & 2 deletions .github/scripts/publish-npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ echo "goto build-outputs"
cd build-outputs || exit 1

# TODO: Add other build as well
for PACKAGE in 'foundations' 'components' 'ngx-components' 'react-components' 'v-components' 'web-components'; do
for PACKAGE in 'foundations' 'migration' 'components' 'ngx-components' 'react-components' 'v-components' 'web-components'; do
echo "Start $PACKAGE bundle:"

echo "🆚 Update Version"
npm version --no-git-tag-version "$VALID_SEMVER_VERSION" --workspace=@db-ui/"$PACKAGE"

if [[ $PACKAGE != 'foundations' ]]; then
if [[ $PACKAGE != 'foundations' && $PACKAGE != 'migration' ]]; then
echo "🕵️‍ Set foundations dependency"
npm pkg set dependencies.@db-ui/foundations="$VALID_SEMVER_VERSION" --workspace=@db-ui/"$PACKAGE"
if [[ $PACKAGE != 'components' ]]; then
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/01-build-outputs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ jobs:
name: db-ui-components-build
path: packages/components/build

- name: ⏬ Download migration build
uses: actions/download-artifact@v4
with:
name: db-ui-migration-build
path: packages/migration/build

- name: ⏬ Download output
uses: actions/download-artifact@v4
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/01-build-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ jobs:
name: db-ui-components-build
path: packages/components/build

- name: ⏫ Upload migration build
uses: actions/upload-artifact@v4
with:
name: db-ui-migration-build
path: packages/migration/build

- name: 💀 Killing me softly
uses: ./.github/actions/cancel-workflow
if: failure()
Expand Down
5 changes: 1 addition & 4 deletions .xo-config.cjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
module.exports = {
prettier: true,
ignores: [
'./showcases/nuxt-showcase/**',
'./packages/foundations/scripts/**'
],
ignores: ['./showcases/nuxt-showcase/**', './packages/migration/**'],
overrides: [
{
files: ['./showcases/angular-showcase/**'],
Expand Down
44 changes: 23 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions packages/foundations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,7 @@ If you want to optimize the size of the loaded styles, you might skip loading `@

## Migration

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

```shell
npx @db-ui/foundations migration --src=./src
```
We provide a [cli tool](https://github.com/db-ui/mono/blob/main/packages/migration/README.md) to auto migrate your source code.

## Deutsche Bahn brand

Expand Down
11 changes: 2 additions & 9 deletions packages/foundations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"build:04_tailwind": "cpr tailwind build/tailwind -o",
"build:05_postcss": "postcss build/css/**/*.css --replace",
"build:06_ide": "cpr ide build/ide -o",
"build:99_foundations_common": "node scripts/esbuild.js",
"clean": "rm -rf build",
"copy-build": "npm-run-all copy-build:*",
"copy-build:assets": "cpr assets ../../build-outputs/foundations/assets -o",
Expand All @@ -41,24 +40,18 @@
"prestart": "npm-run-all copy-prepare:*",
"regenerate:screenshots": "npx playwright test -c ./test/playwright.config.js --update-snapshots",
"start": "nodemon --config nodemon.json",
"test": "vitest run --config scripts/vitest.config.ts",
"test:e2e": "npx playwright test --config=./test/playwright.config.js",
"test:migration": "tsx scripts/cli.ts migration --type v005_v006 --src=./scss --dryRun=true"
"test:e2e": "npx playwright test --config=./test/playwright.config.js"
},
"devDependencies": {
"@csstools/normalize.css": "12.1.1",
"@db-ux/core-icons": "^0.0.6",
"commander": "^12.0.0",
"cpr": "3.0.1",
"cssnano": "^7.0.6",
"dotenv": "^16.4.7",
"glob": "^11.0.0",
"nodemon": "3.1.7",
"replace-in-file": "^8.2.0",
"sass": "1.77.4",
"tsx": "^4.19.2",
"vite": "^6.0.3",
"vitest": "^2.1.8"
"vite": "^6.0.3"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
Expand Down
34 changes: 34 additions & 0 deletions packages/migration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# @db-ui/migration

![Apache 2.0 license badge](https://img.shields.io/badge/License-Apache_2.0-blue.svg)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)

## Usage

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

```shell
npx @db-ui/foundations migration --type XXX --src=./src
```

## Deutsche Bahn brand

As we'd like to perfectly support our users and customers on their digital journey, the usage of Deutsche Bahn brand and trademarks are bound of clear guidelines and restrictions even when being used with the code that we're provide with this product; Deutsche Bahn fully reserves all rights regarding the Deutsche Bahn brand, even though that we're providing the code of DB UI products free to use and release it under the Apache 2.0 license.
Please have a look at our brand portal at <https://marketingportal.extranet.deutschebahn.com/> for any further questions and whom to contact on any brand issues.

You must remove or replace any Deutsche Bahn brand and design assets as well as protected characteristics and trademarks. We're even also planning to provide a neutral theme that would make it much easier for you to use our product without the trademarks by Deutsche Bahn.

## Contributions

Contributions are very welcome, please refer to the [contribution guide](https://github.com/db-ui/mono/blob/main/CONTRIBUTING.md).

## Code of conduct

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone – have a look at our [Contributor Covenant Code of Conduct](https://github.com/db-ui/mono/blob/main/CODE-OF-CONDUCT.md).

## License

This project is licensed under [Apache-2.0](LICENSE).
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { build } from 'esbuild';

await build({
entryPoints: ['./scripts/cli.ts'],
entryPoints: ['./src/cli.ts'],
bundle: true,
outfile: './build/index.js',
platform: 'node',
Expand Down
41 changes: 41 additions & 0 deletions packages/migration/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "@db-ui/migration",
"version": "0.0.0",
"type": "module",
"description": "Provides basic tokens and assets based on DB UX Design System Core.",
"repository": {
"type": "git",
"url": "https://github.com/db-ui/mono.git"
},
"license": "DB Design License",
"bin": {
"@db-ui/migration": "build/index.js"
},
"main": "build.js",
"files": [
"build"
],
"scripts": {
"build": "node esbuild.js",
"copy-build": "npm-run-all copy-build:*",
"copy-build:build": "cpr build ../../build-outputs/migration/build -o",
"copy-build:package.json": "cpr package.json ../../build-outputs/migration/package.json -o",
"copy-build:readme": "cpr README.md ../../build-outputs/migration/README.md -o",
"test": "vitest run --config vitest.config.ts",
"test:migration": "tsx src/cli.ts migration --type v005_v006 --src=./scss --dryRun=true"
},
"dependencies": {
"commander": "^12.0.0",
"glob": "^11.0.0",
"replace-in-file": "^8.2.0"
},
"devDependencies": {
"cpr": "3.0.1",
"tsx": "^4.19.2",
"vitest": "^2.1.8"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { globSync } from 'glob';
import { ReplaceInFileConfig, replaceInFileSync } from 'replace-in-file';
import { type ReplaceInFileConfig, replaceInFileSync } from 'replace-in-file';
import type { ReplaceResult } from 'replace-in-file';
import type { OptionsType } from '../types';
import { migrationTypes } from '../data';
Expand All @@ -21,7 +21,10 @@ export const migrate = (
const replacements: ReplaceInFileConfig[] = Object.entries(
migrationTypes
).reduce(
(previousReplacements, [currentKey, currentReplacements]) =>
(
previousReplacements: ReplaceInFileConfig[],
[currentKey, currentReplacements]
) =>
type.includes(currentKey)
? [...previousReplacements, ...currentReplacements]
: previousReplacements,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { v005_v006 } from './migration/v0.0.5-v0.0.6';

export type ProgrammOptionsType = {
name: string;
short?: string;
Expand All @@ -10,6 +12,6 @@ export type ProgrammOptionsType = {

export type OptionsType = {
src: string;
type: (string | 'colorQ32024' | 'iconQ32024')[];
type: (string | 'colorQ32024' | 'iconQ32024' | 'v005_v006')[];
dryRun?: string | boolean;
};
Loading

0 comments on commit 9f170db

Please sign in to comment.