From 595f7f51b25795a623316607de7496846edf48e2 Mon Sep 17 00:00:00 2001
From: Nicolas Merget <104347736+nmerget@users.noreply.github.com>
Date: Wed, 11 Dec 2024 15:19:55 +0100
Subject: [PATCH] fix: migration CLI by making packages external (#3582)
* fix: migration cli by making packages external
* chore: move migration to own package
* fix: linting issues
* fix: issue with publishing migration library
* Update README.md
* chore: update package-lock.json
* fix: issues from PR
* fix: issues from PR
* chore: update from main
---------
Co-authored-by: Maximilian Franzke <787658+mfranzke@users.noreply.github.com>
---
.github/scripts/publish-npm.sh | 6 +--
.github/workflows/01-build-outputs.yml | 6 +++
.github/workflows/01-build-packages.yml | 6 +++
.xo-config.cjs | 5 +--
docs/migration/v0.5.x-to-v0.6.x.md | 4 +-
package-lock.json | 42 ++++++++++---------
packages/foundations/README.md | 6 +--
packages/foundations/package.json | 11 +----
.../scripts/local/generate-icon-overview.ts | 2 +
packages/migration/README.md | 34 +++++++++++++++
.../scripts => migration}/esbuild.js | 4 +-
packages/migration/package.json | 41 ++++++++++++++++++
.../scripts => migration/src}/cli.ts | 10 +----
.../scripts => migration/src}/data.ts | 0
.../src}/migration/color-q32024.ts | 0
.../src}/migration/icon-q32024.ts | 0
.../src}/migration/index.ts | 9 ++--
.../src}/migration/v0.0.5-v0.0.6.ts | 9 +++-
.../scripts => migration/src}/program.ts | 0
.../scripts => migration/src}/types.ts | 4 +-
.../test/color-q32024/color-q32024.spec.ts | 6 +--
.../test/color-q32024/has-changes.txt | 0
.../test/color-q32024/no-change.txt | 0
.../test/icon-q32024/has-changes.txt | 0
.../test/icon-q32024/icon-q32024.spec.ts | 6 +--
.../test/icon-q32024/no-change.txt | 0
.../test/v0.0.5-v0.0.6/has-changes.txt | 4 +-
.../test/v0.0.5-v0.0.6/no-change.txt | 3 ++
.../test/v0.0.5-v0.0.6/v005_v006.spec.ts | 6 +--
.../scripts => migration}/tsconfig.json | 0
.../scripts => migration}/vitest.config.ts | 2 +-
scripts/package.json | 6 ++-
32 files changed, 160 insertions(+), 72 deletions(-)
create mode 100644 packages/migration/README.md
rename packages/{foundations/scripts => migration}/esbuild.js (69%)
create mode 100644 packages/migration/package.json
rename packages/{foundations/scripts => migration/src}/cli.ts (55%)
rename packages/{foundations/scripts => migration/src}/data.ts (100%)
rename packages/{foundations/scripts => migration/src}/migration/color-q32024.ts (100%)
rename packages/{foundations/scripts => migration/src}/migration/icon-q32024.ts (100%)
rename packages/{foundations/scripts => migration/src}/migration/index.ts (81%)
rename packages/{foundations/scripts => migration/src}/migration/v0.0.5-v0.0.6.ts (67%)
rename packages/{foundations/scripts => migration/src}/program.ts (100%)
rename packages/{foundations/scripts => migration/src}/types.ts (69%)
rename packages/{foundations/scripts => migration}/test/color-q32024/color-q32024.spec.ts (72%)
rename packages/{foundations/scripts => migration}/test/color-q32024/has-changes.txt (100%)
rename packages/{foundations/scripts => migration}/test/color-q32024/no-change.txt (100%)
rename packages/{foundations/scripts => migration}/test/icon-q32024/has-changes.txt (100%)
rename packages/{foundations/scripts => migration}/test/icon-q32024/icon-q32024.spec.ts (72%)
rename packages/{foundations/scripts => migration}/test/icon-q32024/no-change.txt (100%)
rename packages/{foundations/scripts => migration}/test/v0.0.5-v0.0.6/has-changes.txt (64%)
rename packages/{foundations/scripts => migration}/test/v0.0.5-v0.0.6/no-change.txt (57%)
rename packages/{foundations/scripts => migration}/test/v0.0.5-v0.0.6/v005_v006.spec.ts (72%)
rename packages/{foundations/scripts => migration}/tsconfig.json (100%)
rename packages/{foundations/scripts => migration}/vitest.config.ts (62%)
diff --git a/.github/scripts/publish-npm.sh b/.github/scripts/publish-npm.sh
index d9abdb13c89..118e0e4d56d 100644
--- a/.github/scripts/publish-npm.sh
+++ b/.github/scripts/publish-npm.sh
@@ -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
@@ -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
diff --git a/.github/workflows/01-build-outputs.yml b/.github/workflows/01-build-outputs.yml
index 21a90a90393..df6d128e7c1 100644
--- a/.github/workflows/01-build-outputs.yml
+++ b/.github/workflows/01-build-outputs.yml
@@ -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:
diff --git a/.github/workflows/01-build-packages.yml b/.github/workflows/01-build-packages.yml
index dcbee4cc087..5c8aeae7f58 100644
--- a/.github/workflows/01-build-packages.yml
+++ b/.github/workflows/01-build-packages.yml
@@ -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()
diff --git a/.xo-config.cjs b/.xo-config.cjs
index 03a6afdcdb7..60542fdfc0d 100644
--- a/.xo-config.cjs
+++ b/.xo-config.cjs
@@ -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/**'],
diff --git a/docs/migration/v0.5.x-to-v0.6.x.md b/docs/migration/v0.5.x-to-v0.6.x.md
index da206f41d3b..72216124321 100644
--- a/docs/migration/v0.5.x-to-v0.6.x.md
+++ b/docs/migration/v0.5.x-to-v0.6.x.md
@@ -23,10 +23,10 @@ We changed some properties for components to align with Figma properties:
## Automate migration via CLI
-We provide a cli tool to auto migrate your source code. Use this command in your repository:
+We provide a cli tool to auto migrate your source code (except for `content` to `text` attribute on `Accordion-Item`). Use this command in your repository:
```shell
-npx @db-ui/foundations@v0.6 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.
diff --git a/package-lock.json b/package-lock.json
index eddc6b5db51..2cad6408d0c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4959,6 +4959,10 @@
"resolved": "packages/foundations",
"link": true
},
+ "node_modules/@db-ui/migration": {
+ "resolved": "packages/migration",
+ "link": true
+ },
"node_modules/@db-ui/mono-e2e": {
"resolved": "e2e",
"link": true
@@ -15169,7 +15173,6 @@
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz",
"integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==",
- "dev": true,
"engines": {
"node": "^12.17.0 || ^14.13 || >=16.0.0"
},
@@ -15825,7 +15828,6 @@
"version": "12.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz",
"integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==",
- "dev": true,
"engines": {
"node": ">=18"
}
@@ -20716,7 +20718,6 @@
"version": "11.0.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-11.0.0.tgz",
"integrity": "sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==",
- "dev": true,
"dependencies": {
"foreground-child": "^3.1.0",
"jackspeak": "^4.0.1",
@@ -20757,7 +20758,6 @@
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
- "dev": true,
"dependencies": {
"balanced-match": "^1.0.0"
}
@@ -20766,7 +20766,6 @@
"version": "10.0.1",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz",
"integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==",
- "dev": true,
"dependencies": {
"brace-expansion": "^2.0.1"
},
@@ -23415,7 +23414,6 @@
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.1.tgz",
"integrity": "sha512-cub8rahkh0Q/bw1+GxP7aeSe29hHHn2V4m29nnDlvCdlgU+3UGxkZp7Z53jLUdpX3jdTO0nJZUDl3xvbWc2Xog==",
- "dev": true,
"dependencies": {
"@isaacs/cliui": "^8.0.2"
},
@@ -24974,7 +24972,6 @@
"version": "11.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.0.0.tgz",
"integrity": "sha512-Qv32eSV1RSCfhY3fpPE2GNZ8jgM9X7rdAfemLWqTUxwiyIC4jJ6Sy0fZ8H+oLWevO6i4/bizg7c8d8i6bxrzbA==",
- "dev": true,
"engines": {
"node": "20 || >=22"
}
@@ -30449,7 +30446,6 @@
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz",
"integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==",
- "dev": true,
"dependencies": {
"lru-cache": "^11.0.0",
"minipass": "^7.1.2"
@@ -32880,7 +32876,6 @@
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/replace-in-file/-/replace-in-file-8.2.0.tgz",
"integrity": "sha512-hMsQtdYHwWviQT5ZbNsgfu0WuCiNlcUSnnD+aHAL081kbU9dPkPocDaHlDvAHKydTWWpx1apfcEcmvIyQk3CpQ==",
- "dev": true,
"dependencies": {
"chalk": "^5.3.0",
"glob": "^10.4.2",
@@ -32897,7 +32892,6 @@
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
- "dev": true,
"dependencies": {
"balanced-match": "^1.0.0"
}
@@ -32906,7 +32900,6 @@
"version": "10.4.5",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz",
"integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==",
- "dev": true,
"dependencies": {
"foreground-child": "^3.1.0",
"jackspeak": "^3.1.2",
@@ -32926,7 +32919,6 @@
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz",
"integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==",
- "dev": true,
"dependencies": {
"@isaacs/cliui": "^8.0.2"
},
@@ -32940,14 +32932,12 @@
"node_modules/replace-in-file/node_modules/lru-cache": {
"version": "10.4.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz",
- "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==",
- "dev": true
+ "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="
},
"node_modules/replace-in-file/node_modules/minimatch": {
"version": "9.0.5",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
"integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
- "dev": true,
"dependencies": {
"brace-expansion": "^2.0.1"
},
@@ -32962,7 +32952,6 @@
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz",
"integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==",
- "dev": true,
"dependencies": {
"lru-cache": "^10.2.0",
"minipass": "^5.0.0 || ^6.0.2 || ^7.0.0"
@@ -41302,16 +41291,29 @@
"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",
+ "vite": "^6.0.3"
+ }
+ },
+ "packages/migration": {
+ "version": "0.0.0",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "commander": "^12.0.0",
+ "glob": "^11.0.0",
+ "replace-in-file": "^8.2.0"
+ },
+ "bin": {
+ "migration": "build/index.js"
+ },
+ "devDependencies": {
+ "cpr": "3.0.1",
+ "tsx": "^4.19.2",
"vitest": "^2.1.8"
}
},
diff --git a/packages/foundations/README.md b/packages/foundations/README.md
index 86062325f5c..6a06e100eee 100644
--- a/packages/foundations/README.md
+++ b/packages/foundations/README.md
@@ -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
diff --git a/packages/foundations/package.json b/packages/foundations/package.json
index 3667680b3b2..a62de7dfaed 100644
--- a/packages/foundations/package.json
+++ b/packages/foundations/package.json
@@ -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",
@@ -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/",
diff --git a/packages/foundations/scripts/local/generate-icon-overview.ts b/packages/foundations/scripts/local/generate-icon-overview.ts
index 8353c25f980..d143b47da00 100644
--- a/packages/foundations/scripts/local/generate-icon-overview.ts
+++ b/packages/foundations/scripts/local/generate-icon-overview.ts
@@ -1,3 +1,5 @@
+/* eslint-disable @typescript-eslint/no-unsafe-call */
+
/*
* This script can be used to update the icon overview for foundation testing.
*/
diff --git a/packages/migration/README.md b/packages/migration/README.md
new file mode 100644
index 00000000000..1117b0d2b91
--- /dev/null
+++ b/packages/migration/README.md
@@ -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 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).
diff --git a/packages/foundations/scripts/esbuild.js b/packages/migration/esbuild.js
similarity index 69%
rename from packages/foundations/scripts/esbuild.js
rename to packages/migration/esbuild.js
index 76c1e9b0985..9cb15585713 100644
--- a/packages/foundations/scripts/esbuild.js
+++ b/packages/migration/esbuild.js
@@ -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'
});
diff --git a/packages/migration/package.json b/packages/migration/package.json
new file mode 100644
index 00000000000..bdbac0fe7dd
--- /dev/null
+++ b/packages/migration/package.json
@@ -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"
+ }
+}
diff --git a/packages/foundations/scripts/cli.ts b/packages/migration/src/cli.ts
similarity index 55%
rename from packages/foundations/scripts/cli.ts
rename to packages/migration/src/cli.ts
index a62f94f97b9..0edbe96c95b 100644
--- a/packages/foundations/scripts/cli.ts
+++ b/packages/migration/src/cli.ts
@@ -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(
diff --git a/packages/foundations/scripts/data.ts b/packages/migration/src/data.ts
similarity index 100%
rename from packages/foundations/scripts/data.ts
rename to packages/migration/src/data.ts
diff --git a/packages/foundations/scripts/migration/color-q32024.ts b/packages/migration/src/migration/color-q32024.ts
similarity index 100%
rename from packages/foundations/scripts/migration/color-q32024.ts
rename to packages/migration/src/migration/color-q32024.ts
diff --git a/packages/foundations/scripts/migration/icon-q32024.ts b/packages/migration/src/migration/icon-q32024.ts
similarity index 100%
rename from packages/foundations/scripts/migration/icon-q32024.ts
rename to packages/migration/src/migration/icon-q32024.ts
diff --git a/packages/foundations/scripts/migration/index.ts b/packages/migration/src/migration/index.ts
similarity index 81%
rename from packages/foundations/scripts/migration/index.ts
rename to packages/migration/src/migration/index.ts
index ccb50312499..48700783c02 100644
--- a/packages/foundations/scripts/migration/index.ts
+++ b/packages/migration/src/migration/index.ts
@@ -1,6 +1,6 @@
import { globSync } from 'glob';
-import { ReplaceInFileConfig, replaceInFileSync } from 'replace-in-file';
-import type { ReplaceResult } from 'replace-in-file';
+import type { ReplaceInFileConfig, ReplaceResult } from 'replace-in-file';
+import { replaceInFileSync } from 'replace-in-file';
import type { OptionsType } from '../types';
import { migrationTypes } from '../data';
@@ -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,
diff --git a/packages/foundations/scripts/migration/v0.0.5-v0.0.6.ts b/packages/migration/src/migration/v0.0.5-v0.0.6.ts
similarity index 67%
rename from packages/foundations/scripts/migration/v0.0.5-v0.0.6.ts
rename to packages/migration/src/migration/v0.0.5-v0.0.6.ts
index b551f2f721a..65da2b461e4 100644
--- a/packages/foundations/scripts/migration/v0.0.5-v0.0.6.ts
+++ b/packages/migration/src/migration/v0.0.5-v0.0.6.ts
@@ -4,8 +4,13 @@ export const v005_v006: ReplaceInFileConfig[] = [
// Components
{
files: '',
- from: /behaviour="closable"/g,
- to: 'closable="true"'
+ from: /behaviour="closeable"/g,
+ to: 'closeable="true"'
+ },
+ {
+ files: '',
+ from: /behaviour="permanent"/g,
+ to: 'closeable="false"'
},
{
files: '',
diff --git a/packages/foundations/scripts/program.ts b/packages/migration/src/program.ts
similarity index 100%
rename from packages/foundations/scripts/program.ts
rename to packages/migration/src/program.ts
diff --git a/packages/foundations/scripts/types.ts b/packages/migration/src/types.ts
similarity index 69%
rename from packages/foundations/scripts/types.ts
rename to packages/migration/src/types.ts
index 27b92c6e435..cfd22dc126b 100644
--- a/packages/foundations/scripts/types.ts
+++ b/packages/migration/src/types.ts
@@ -1,3 +1,5 @@
+import { v005_v006 } from './migration/v0.0.5-v0.0.6';
+
export type ProgrammOptionsType = {
name: string;
short?: string;
@@ -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;
};
diff --git a/packages/foundations/scripts/test/color-q32024/color-q32024.spec.ts b/packages/migration/test/color-q32024/color-q32024.spec.ts
similarity index 72%
rename from packages/foundations/scripts/test/color-q32024/color-q32024.spec.ts
rename to packages/migration/test/color-q32024/color-q32024.spec.ts
index 15aff5e9ec8..1bbf59447ea 100644
--- a/packages/foundations/scripts/test/color-q32024/color-q32024.spec.ts
+++ b/packages/migration/test/color-q32024/color-q32024.spec.ts
@@ -1,11 +1,11 @@
import { describe, expect, test } from 'vitest';
-import { migrate } from '../../migration';
-import { ReplaceResult } from 'replace-in-file';
+import { type ReplaceResult } from 'replace-in-file';
+import { migrate } from '../../src/migration';
describe('color-q32024', () => {
test('check if changes are detected', async () => {
const result = migrate({
- src: './scripts/test/color-q32024',
+ src: './test/color-q32024',
type: ['colorQ32024'],
dryRun: true
});
diff --git a/packages/foundations/scripts/test/color-q32024/has-changes.txt b/packages/migration/test/color-q32024/has-changes.txt
similarity index 100%
rename from packages/foundations/scripts/test/color-q32024/has-changes.txt
rename to packages/migration/test/color-q32024/has-changes.txt
diff --git a/packages/foundations/scripts/test/color-q32024/no-change.txt b/packages/migration/test/color-q32024/no-change.txt
similarity index 100%
rename from packages/foundations/scripts/test/color-q32024/no-change.txt
rename to packages/migration/test/color-q32024/no-change.txt
diff --git a/packages/foundations/scripts/test/icon-q32024/has-changes.txt b/packages/migration/test/icon-q32024/has-changes.txt
similarity index 100%
rename from packages/foundations/scripts/test/icon-q32024/has-changes.txt
rename to packages/migration/test/icon-q32024/has-changes.txt
diff --git a/packages/foundations/scripts/test/icon-q32024/icon-q32024.spec.ts b/packages/migration/test/icon-q32024/icon-q32024.spec.ts
similarity index 72%
rename from packages/foundations/scripts/test/icon-q32024/icon-q32024.spec.ts
rename to packages/migration/test/icon-q32024/icon-q32024.spec.ts
index 6f883bb43ae..61e64a73701 100644
--- a/packages/foundations/scripts/test/icon-q32024/icon-q32024.spec.ts
+++ b/packages/migration/test/icon-q32024/icon-q32024.spec.ts
@@ -1,11 +1,11 @@
import { describe, expect, test } from 'vitest';
-import { migrate } from '../../migration';
-import { ReplaceResult } from 'replace-in-file';
+import { type ReplaceResult } from 'replace-in-file';
+import { migrate } from '../../src/migration';
describe('icon-q32024', () => {
test('check if changes are detected', async () => {
const result = migrate({
- src: './scripts/test/icon-q32024',
+ src: './test/icon-q32024',
type: ['iconQ32024'],
dryRun: true
});
diff --git a/packages/foundations/scripts/test/icon-q32024/no-change.txt b/packages/migration/test/icon-q32024/no-change.txt
similarity index 100%
rename from packages/foundations/scripts/test/icon-q32024/no-change.txt
rename to packages/migration/test/icon-q32024/no-change.txt
diff --git a/packages/foundations/scripts/test/v0.0.5-v0.0.6/has-changes.txt b/packages/migration/test/v0.0.5-v0.0.6/has-changes.txt
similarity index 64%
rename from packages/foundations/scripts/test/v0.0.5-v0.0.6/has-changes.txt
rename to packages/migration/test/v0.0.5-v0.0.6/has-changes.txt
index 54a38a3c9e0..e625906bbf2 100644
--- a/packages/foundations/scripts/test/v0.0.5-v0.0.6/has-changes.txt
+++ b/packages/migration/test/v0.0.5-v0.0.6/has-changes.txt
@@ -1,8 +1,10 @@
(close = 'test')}
- behaviour="closable">
+ behaviour="closeable">
Test
+
+
diff --git a/packages/foundations/scripts/test/v0.0.5-v0.0.6/no-change.txt b/packages/migration/test/v0.0.5-v0.0.6/no-change.txt
similarity index 57%
rename from packages/foundations/scripts/test/v0.0.5-v0.0.6/no-change.txt
rename to packages/migration/test/v0.0.5-v0.0.6/no-change.txt
index 663295aed2b..cce284648b9 100644
--- a/packages/foundations/scripts/test/v0.0.5-v0.0.6/no-change.txt
+++ b/packages/migration/test/v0.0.5-v0.0.6/no-change.txt
@@ -6,3 +6,6 @@
+
+
+
diff --git a/packages/foundations/scripts/test/v0.0.5-v0.0.6/v005_v006.spec.ts b/packages/migration/test/v0.0.5-v0.0.6/v005_v006.spec.ts
similarity index 72%
rename from packages/foundations/scripts/test/v0.0.5-v0.0.6/v005_v006.spec.ts
rename to packages/migration/test/v0.0.5-v0.0.6/v005_v006.spec.ts
index a1d84b73172..d85768603cc 100644
--- a/packages/foundations/scripts/test/v0.0.5-v0.0.6/v005_v006.spec.ts
+++ b/packages/migration/test/v0.0.5-v0.0.6/v005_v006.spec.ts
@@ -1,11 +1,11 @@
import { describe, expect, test } from 'vitest';
-import { migrate } from '../../migration';
-import { ReplaceResult } from 'replace-in-file';
+import { type ReplaceResult } from 'replace-in-file';
+import { migrate } from '../../src/migration';
describe('v005_v006', () => {
test('check if changes are detected', async () => {
const result = migrate({
- src: './scripts/test/v0.0.5-v0.0.6',
+ src: './test/v0.0.5-v0.0.6',
type: ['v005_v006'],
dryRun: true
});
diff --git a/packages/foundations/scripts/tsconfig.json b/packages/migration/tsconfig.json
similarity index 100%
rename from packages/foundations/scripts/tsconfig.json
rename to packages/migration/tsconfig.json
diff --git a/packages/foundations/scripts/vitest.config.ts b/packages/migration/vitest.config.ts
similarity index 62%
rename from packages/foundations/scripts/vitest.config.ts
rename to packages/migration/vitest.config.ts
index d3230064db1..08aee380068 100644
--- a/packages/foundations/scripts/vitest.config.ts
+++ b/packages/migration/vitest.config.ts
@@ -2,6 +2,6 @@ import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
- include: ['scripts/**/*.{test,spec}.?(c|m)[jt]s?(x)']
+ include: ['test/**/*.{test,spec}.?(c|m)[jt]s?(x)']
}
});
diff --git a/scripts/package.json b/scripts/package.json
index 252a0e79194..93ab6deb5ae 100644
--- a/scripts/package.json
+++ b/scripts/package.json
@@ -4,10 +4,11 @@
"type": "module",
"description": "contains scripts for monorepo",
"scripts": {
- "build": "npm-run-all build:foundations build:components",
+ "build": "npm-run-all build:foundations build:components build:migration",
"build-outputs": "npm-run-all -p build-outputs:*",
"build-outputs:components": "npm run copy-output --workspace=@db-ui/components",
"build-outputs:foundations": "npm run copy-build --workspace=@db-ui/foundations",
+ "build-outputs:migration": "npm run copy-build --workspace=@db-ui/migration",
"build-outputs:ngx-components": "npm run build --workspace=@db-ui/ngx-components",
"build-outputs:react-components": "npm run build --workspace=@db-ui/react-components",
"build-outputs:stencil-components": "npm run build --workspace=@db-ui/web-components",
@@ -24,6 +25,7 @@
"build-showcases:vue": "npm run build --workspace=vue-showcase",
"build:components": "npm run build --workspace=@db-ui/components",
"build:foundations": "npm run build --workspace=@db-ui/foundations",
+ "build:migration": "npm run build --workspace=@db-ui/migration",
"dev": "tsx dev.js",
"dev:angular-components": "npm run dev:angular --workspace=@db-ui/components",
"dev:plain-html-components": "npm run dev:html --workspace=@db-ui/components",
@@ -60,7 +62,7 @@
"start-showcase:vue": "npm run dev --workspace=vue-showcase",
"start:foundations": "npm run start --workspace=@db-ui/foundations",
"test": "npm-run-all -p test:*",
- "test:foundations-migration": "npm run test --workspace=@db-ui/foundations",
+ "test:migration": "npm run test --workspace=@db-ui/migration",
"update:icon-fonts": "npm-run-all generate:icon-fonts generate:icon-types"
},
"devDependencies": {