Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: migration CLI by making packages external #3582

Merged
merged 20 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 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 Expand Up @@ -58,7 +58,7 @@ for REGISTRY in 'GITHUB' 'NPM'; do
fi

# 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 "⤴ Publish $PACKAGE with tag $TAG to $REGISTRY"
# https://docs.npmjs.com/generating-provenance-statements#example-github-actions-workflow
npm publish --tag "$TAG" db-ui-"$PACKAGE"-"$VALID_SEMVER_VERSION".tgz --provenance
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
2 changes: 1 addition & 1 deletion docs/migration/v0.5.x-to-v0.6.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ We changed some properties for components to align with Figma properties:
We provide a cli tool to auto migrate your source code. Use this command in your repository:

```shell
npx @db-ui/[email protected] migration --type=v005_v006 --src=./src
npx @db-ui/migration --type=v005_v006 --src=./src
```

Please check the changes made in your codebase afterwards, as this is mainly a simple search & replace and there might be unexpected changes of similar wordings to our icon names for any other methods, or further code occurrences that don't even refer to icons.
42 changes: 22 additions & 20 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.7",
"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
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
mfranzke marked this conversation as resolved.
Show resolved Hide resolved

/*
* This script can be used to update the icon overview for foundation testing.
*/
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/migration --type=v005_v006 --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,10 +1,10 @@
import { build } from 'esbuild';

await build({
entryPoints: ['./scripts/cli.ts'],
entryPoints: ['./src/cli.ts'],
bundle: true,
outfile: './build/index.js',
platform: 'node',
format: 'esm',
external: ['chalk']
packages: 'external'
});
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": "Migration script for changing your code in between DB UX Design System v3 versions regarding BREAKING CHANGES.",
"repository": {
"type": "git",
"url": "https://github.com/db-ui/mono.git"
},
"license": "Apache-2.0",
"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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ import startProgram from './program';
import { options } from './data';
import { migrate } from './migration';

const action = async (functionName: string, options: OptionsType) => {
if (functionName === 'migration') {
migrate(options, true);
} else {
console.error(
`There is no function for this library named ${functionName}`
);
}
const action = async (_: unknown, options: OptionsType) => {
migrate(options, true);
};

startProgram(
Expand Down
File renamed without changes.
Loading
Loading