@db-ux/core-migration 1.0.0-test-13b991d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +34 -0
  2. package/build/index.js +463 -0
  3. package/package.json +42 -0
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # @db-ux/core-migration
2
+
3
+ ![Apache 2.0 license badge](https://img.shields.io/badge/License-Apache_2.0-blue.svg)
4
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
5
+ [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
6
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
7
+
8
+ ## Usage
9
+
10
+ We provide a cli tool to auto migrate your source code. Use this command in your repository:
11
+
12
+ ```shell
13
+ npx @db-ux/core-migration --type=v005_v006 --src=./src
14
+ ```
15
+
16
+ ## Deutsche Bahn brand
17
+
18
+ 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 UX Design System products free to use and release it under the Apache 2.0 license.
19
+ 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.
20
+
21
+ 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.
22
+
23
+ ## Contributions
24
+
25
+ Contributions are very welcome, please refer to the [contribution guide](https://github.com/db-ux-design-system/core-web/blob/main/CONTRIBUTING.md).
26
+
27
+ ## Code of conduct
28
+
29
+ We as members, contributors, and leaders pledge to make participation in our
30
+ community a harassment-free experience for everyone – have a look at our [Contributor Covenant Code of Conduct](https://github.com/db-ux-design-system/core-web/blob/main/CODE-OF-CONDUCT.md).
31
+
32
+ ## License
33
+
34
+ This project is licensed under [Apache-2.0](LICENSE).
package/build/index.js ADDED
@@ -0,0 +1,463 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/program.ts
4
+ import { program } from "commander";
5
+ var startProgram = (name, description, options2, action2) => {
6
+ program.name(name).description(description);
7
+ program.argument(
8
+ "[function]",
9
+ "function of this library you want to use [migration]"
10
+ );
11
+ for (const option of options2) {
12
+ const short = (option.short && (option.short?.startsWith("-") ? option.short : `-${option.short}`)) ?? `-${option.name.charAt(0)}`;
13
+ const long = option.long ?? `--${option.name} ${option.array ? "[" : "<"}${option.name}${option.array ? "s...]" : ">"}`;
14
+ if (option.required) {
15
+ program.requiredOption(
16
+ `${short}, ${long}`,
17
+ option.description ?? "",
18
+ option.defaultValue
19
+ );
20
+ } else {
21
+ program.option(
22
+ `${short}, ${long}`,
23
+ option.description ?? "",
24
+ option.defaultValue
25
+ );
26
+ }
27
+ }
28
+ program.action(action2);
29
+ program.parse();
30
+ };
31
+ var program_default = startProgram;
32
+
33
+ // src/migration/color-q32024.ts
34
+ var colorQ32024 = [
35
+ // Basic backgrounds
36
+ {
37
+ files: "",
38
+ from: /bg-lvl-1/g,
39
+ to: "bg-basic-level-1"
40
+ },
41
+ {
42
+ files: "",
43
+ from: /bg-lvl-2/g,
44
+ to: "bg-basic-level-2"
45
+ },
46
+ {
47
+ files: "",
48
+ from: /bg-lvl-3/g,
49
+ to: "bg-basic-level-3"
50
+ },
51
+ {
52
+ files: "",
53
+ from: /bg-transparent-full/g,
54
+ to: "bg-basic-transparent-full"
55
+ },
56
+ {
57
+ files: "",
58
+ from: /bg-transparent-semi/g,
59
+ to: "bg-basic-transparent-semi"
60
+ },
61
+ {
62
+ files: "",
63
+ from: /bg-transparent-hover/g,
64
+ to: "bg-basic-transparent-hovered"
65
+ },
66
+ {
67
+ files: "",
68
+ from: /bg-transparent-pressed/g,
69
+ to: "bg-basic-transparent-pressed"
70
+ },
71
+ {
72
+ files: "",
73
+ from: /on-bg-enabled/g,
74
+ to: "on-bg-basic-emphasis-100-default"
75
+ },
76
+ {
77
+ files: "",
78
+ from: /on-bg-hover/g,
79
+ to: "on-bg-basic-emphasis-100-hovered"
80
+ },
81
+ {
82
+ files: "",
83
+ from: /on-bg-pressed/g,
84
+ to: "on-bg-basic-emphasis-100-pressed"
85
+ },
86
+ {
87
+ files: "",
88
+ from: /on-bg-weak-enabled/g,
89
+ to: "on-bg-basic-emphasis-90-default"
90
+ },
91
+ {
92
+ files: "",
93
+ from: /on-bg-weak-hover/g,
94
+ to: "on-bg-basic-emphasis-90-hovered"
95
+ },
96
+ {
97
+ files: "",
98
+ from: /on-bg-weak-pressed/g,
99
+ to: "on-bg-basic-emphasis-90-pressed"
100
+ },
101
+ {
102
+ files: "",
103
+ from: /contrast-low-enabled/g,
104
+ to: "on-bg-basic-emphasis-70-default"
105
+ },
106
+ {
107
+ files: "",
108
+ from: /color-border/g,
109
+ // We will replace adaptive-color afterward
110
+ to: "color-on-bg-basic-emphasis-60-default"
111
+ },
112
+ // Contrast -> inverted
113
+ {
114
+ files: "",
115
+ from: /on-contrast-enabled/g,
116
+ to: "on-bg-inverted-default"
117
+ },
118
+ {
119
+ files: "",
120
+ from: /on-contrast-hover/g,
121
+ to: "on-bg-inverted-hovered"
122
+ },
123
+ {
124
+ files: "",
125
+ from: /on-contrast-pressed/g,
126
+ to: "on-bg-inverted-pressed"
127
+ },
128
+ {
129
+ files: "",
130
+ from: /contrast-high-enabled/g,
131
+ to: "bg-inverted-contrast-high-default"
132
+ },
133
+ {
134
+ files: "",
135
+ from: /contrast-high-hover/g,
136
+ to: "bg-inverted-contrast-high-hovered"
137
+ },
138
+ {
139
+ files: "",
140
+ from: /contrast-high-pressed/g,
141
+ to: "bg-inverted-contrast-high-pressed"
142
+ },
143
+ {
144
+ files: "",
145
+ from: /contrast-low-hover/g,
146
+ to: "bg-inverted-contrast-low-hovered"
147
+ },
148
+ {
149
+ files: "",
150
+ from: /contrast-low-pressed/g,
151
+ to: "bg-inverted-contrast-low-pressed"
152
+ },
153
+ // Rest
154
+ {
155
+ files: "",
156
+ from: /-enabled/g,
157
+ to: "-default"
158
+ },
159
+ {
160
+ files: "",
161
+ // Fix issues with double hovered
162
+ from: /-hovereded/g,
163
+ to: "-hovered"
164
+ },
165
+ {
166
+ files: "",
167
+ // Fix all old hover
168
+ from: /-hover/g,
169
+ to: "-hovered"
170
+ },
171
+ {
172
+ files: "",
173
+ // Fix issues with double hovered again
174
+ from: /-hovereded/g,
175
+ to: "-hovered"
176
+ },
177
+ {
178
+ files: "",
179
+ from: /current-color/g,
180
+ to: "adaptive"
181
+ },
182
+ {
183
+ files: "",
184
+ // Fix issues with current color mixin
185
+ from: /set-adaptives/g,
186
+ to: "set-current-colors"
187
+ }
188
+ ];
189
+
190
+ // src/migration/icon-q32024.ts
191
+ var iconQ32024 = [
192
+ // Renamed icons
193
+ {
194
+ files: "",
195
+ from: /swap_vertical/g,
196
+ to: "arrows_vertical"
197
+ },
198
+ {
199
+ files: "",
200
+ from: /swap_horizontal/g,
201
+ to: "arrows_horizontal"
202
+ },
203
+ {
204
+ files: "",
205
+ from: /reload/g,
206
+ to: "circular_arrows"
207
+ },
208
+ {
209
+ files: "",
210
+ from: /volume_off/g,
211
+ to: "volume_silent"
212
+ },
213
+ {
214
+ files: "",
215
+ from: /law/g,
216
+ to: "paragraph_mark"
217
+ },
218
+ {
219
+ files: "",
220
+ from: /users/g,
221
+ to: "persons"
222
+ },
223
+ {
224
+ files: "",
225
+ from: /user/g,
226
+ to: "person"
227
+ },
228
+ {
229
+ files: "",
230
+ from: /wc_men/g,
231
+ to: "toilet_men"
232
+ },
233
+ {
234
+ files: "",
235
+ from: /wc_women/g,
236
+ to: "toilet_women"
237
+ },
238
+ {
239
+ files: "",
240
+ from: /wc/g,
241
+ to: "toilets"
242
+ },
243
+ {
244
+ files: "",
245
+ from: /filter/g,
246
+ to: "sliders_horizontal"
247
+ },
248
+ {
249
+ files: "",
250
+ from: /warning_triangle/g,
251
+ to: "exclamation_mark_triangle"
252
+ },
253
+ {
254
+ files: "",
255
+ from: /visible/g,
256
+ to: "eye"
257
+ },
258
+ {
259
+ files: "",
260
+ from: /visibility_disabled/g,
261
+ to: "eye_disabled"
262
+ },
263
+ {
264
+ files: "",
265
+ from: /flip_horizontal/g,
266
+ to: "arrows_horizontal"
267
+ },
268
+ {
269
+ files: "",
270
+ from: /flip_vertical/g,
271
+ to: "arrows_vertical"
272
+ }
273
+ ];
274
+
275
+ // src/migration/v0.0.5-v0.0.6.ts
276
+ var v005_v006 = [
277
+ // Components
278
+ {
279
+ files: "",
280
+ from: /behaviour="closeable"/g,
281
+ to: 'closeable="true"'
282
+ },
283
+ {
284
+ files: "",
285
+ from: /behaviour="permanent"/g,
286
+ to: 'closeable="false"'
287
+ },
288
+ {
289
+ files: "",
290
+ from: /variant="hidden"/g,
291
+ to: 'showLabel="false"'
292
+ },
293
+ {
294
+ files: "",
295
+ from: /customValidity/g,
296
+ to: "validation"
297
+ }
298
+ ];
299
+
300
+ // src/migration/v0.0.6-v0.0.7.ts
301
+ var v006_v007 = [
302
+ {
303
+ files: "",
304
+ from: /db-ux-42-/g,
305
+ to: ""
306
+ },
307
+ {
308
+ files: "",
309
+ from: /db-ux-42/g,
310
+ to: "relative"
311
+ },
312
+ {
313
+ files: "",
314
+ from: /db-ux-foundations-/g,
315
+ to: ""
316
+ },
317
+ {
318
+ files: "",
319
+ from: /db-ux-foundations/g,
320
+ to: "relative"
321
+ },
322
+ {
323
+ files: "",
324
+ from: /foundations\/build\/css/g,
325
+ to: "foundations/build/styles"
326
+ },
327
+ {
328
+ files: "",
329
+ from: /foundations\/build\/scss/g,
330
+ to: "foundations/build/styles"
331
+ }
332
+ ];
333
+
334
+ // src/migration/v0.0.7-v1.0.0.ts
335
+ var v007_v100 = [
336
+ {
337
+ files: "",
338
+ from: /db-container-color/g,
339
+ to: "db-color"
340
+ },
341
+ {
342
+ files: "",
343
+ from: /data-container-color/g,
344
+ to: "data-color"
345
+ },
346
+ {
347
+ files: "",
348
+ from: /data-color-scheme/g,
349
+ to: "data-mode"
350
+ },
351
+ {
352
+ files: "",
353
+ from: /behaviour=/g,
354
+ to: "behavior="
355
+ },
356
+ {
357
+ files: "",
358
+ from: /behaviour":/g,
359
+ to: 'behavior":'
360
+ },
361
+ {
362
+ files: "",
363
+ from: /behaviour:/g,
364
+ to: "behavior:"
365
+ },
366
+ {
367
+ files: "",
368
+ from: /variant="with arrow"/g,
369
+ to: 'showArrow="true"'
370
+ },
371
+ {
372
+ files: "",
373
+ from: /variant="basic"/g,
374
+ to: 'showArrow="false"'
375
+ }
376
+ ];
377
+
378
+ // src/data.ts
379
+ var migrationTypes = {
380
+ colorQ32024,
381
+ iconQ32024,
382
+ v005_v006,
383
+ v006_v007,
384
+ v007_v100
385
+ };
386
+ var options = [
387
+ {
388
+ name: "type",
389
+ description: `Type of migration (${Object.keys(migrationTypes).join(", ")})`,
390
+ required: true,
391
+ array: true
392
+ },
393
+ {
394
+ name: "src",
395
+ description: "Src folder with all files",
396
+ required: true
397
+ },
398
+ {
399
+ name: "dryRun",
400
+ short: "d",
401
+ description: "prints the output of the command"
402
+ }
403
+ ];
404
+
405
+ // src/migration/index.ts
406
+ import { globSync } from "glob";
407
+ import { replaceInFileSync } from "replace-in-file";
408
+
409
+ // src/migration/additional-information.ts
410
+ var AdditionalInformation = {
411
+ v006_v007: "https://github.com/db-ux-design-system/core-web/blob/main/docs/migration/v0.6.x-to-v0.7.x.md"
412
+ };
413
+
414
+ // src/migration/index.ts
415
+ var migrate = (options2, cli) => {
416
+ if (options2) {
417
+ const { src, type, dryRun } = options2;
418
+ const dry = Boolean(dryRun);
419
+ const paths = `${src}/**`;
420
+ const globPaths = globSync(paths, {
421
+ nodir: true,
422
+ ignore: ["node_modules", "**/*.zip"]
423
+ }).map((path) => path.replaceAll("\\", "/")).filter((path) => path.includes("."));
424
+ const replacements = Object.entries(
425
+ migrationTypes
426
+ ).reduce(
427
+ (previousReplacements, [currentKey, currentReplacements]) => type.includes(currentKey) ? [...previousReplacements, ...currentReplacements] : previousReplacements,
428
+ []
429
+ );
430
+ for (const t of type) {
431
+ const additionalInfo = AdditionalInformation[t];
432
+ if (additionalInfo) {
433
+ console.log(`Find more information here: ${additionalInfo}`);
434
+ }
435
+ }
436
+ for (const update of replacements) {
437
+ const option = {
438
+ ...update,
439
+ files: globPaths,
440
+ dry
441
+ };
442
+ const result = replaceInFileSync(option);
443
+ if (dry) {
444
+ if (cli) {
445
+ console.log(result.filter((res) => res.hasChanged));
446
+ }
447
+ return result;
448
+ }
449
+ }
450
+ }
451
+ return void 0;
452
+ };
453
+
454
+ // src/cli.ts
455
+ var action = async (_, options2) => {
456
+ migrate(options2, true);
457
+ };
458
+ program_default(
459
+ "@db-ux/core-foundations - migration",
460
+ "CLI for DB UX Design System foundations",
461
+ options,
462
+ action
463
+ );
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@db-ux/core-migration",
3
+ "version": "1.0.0-test-13b991d",
4
+ "type": "module",
5
+ "description": "Migration script for changing your code in between DB UX Design System v3 versions regarding BREAKING CHANGES.",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/db-ux-design-system/core-web.git"
9
+ },
10
+ "license": "Apache-2.0",
11
+ "bin": {
12
+ "@db-ux/core-migration": "build/index.js"
13
+ },
14
+ "main": "build.js",
15
+ "files": [
16
+ "build"
17
+ ],
18
+ "scripts": {
19
+ "build": "node esbuild.js",
20
+ "copy-build": "npm-run-all copy-build:*",
21
+ "copy-build:build": "cpr build ../../build-outputs/migration/build -o",
22
+ "copy-build:package.json": "cpr package.json ../../build-outputs/migration/package.json -o",
23
+ "copy-build:readme": "cpr README.md ../../build-outputs/migration/README.md -o",
24
+ "test": "vitest run --config vitest.config.ts",
25
+ "test:migration": "tsx src/cli.ts migration --type v005_v006 --src=./scss --dryRun=true"
26
+ },
27
+ "dependencies": {
28
+ "commander": "^13.1.0",
29
+ "glob": "^11.0.1",
30
+ "replace-in-file": "^8.3.0"
31
+ },
32
+ "devDependencies": {
33
+ "cpr": "3.0.1",
34
+ "esbuild": "0.25.0",
35
+ "tsx": "^4.19.2",
36
+ "vitest": "^3.0.5"
37
+ },
38
+ "publishConfig": {
39
+ "registry": "https://registry.npmjs.org/",
40
+ "access": "public"
41
+ }
42
+ }