@baloise/ds-styles 0.0.5-nightly.e56f740

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 (117) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +45 -0
  3. package/bin/index.mjs +1333 -0
  4. package/css/all.css +18468 -0
  5. package/css/all.css.map +1 -0
  6. package/css/all.min.css +1 -0
  7. package/css/baloise-design-system.css +18468 -0
  8. package/css/baloise-design-system.css.map +1 -0
  9. package/css/baloise-design-system.min.css +1 -0
  10. package/css/core.css +4423 -0
  11. package/css/core.css.map +1 -0
  12. package/css/core.min.css +1 -0
  13. package/css/font.css +29 -0
  14. package/css/font.css.map +1 -0
  15. package/css/font.min.css +1 -0
  16. package/css/mixins.css +2 -0
  17. package/css/mixins.css.map +1 -0
  18. package/css/mixins.min.css +0 -0
  19. package/css/normalize.css +351 -0
  20. package/css/normalize.css.map +1 -0
  21. package/css/normalize.min.css +1 -0
  22. package/css/structure.css +147 -0
  23. package/css/structure.css.map +1 -0
  24. package/css/structure.min.css +1 -0
  25. package/css/themes/compact.css +30 -0
  26. package/css/themes/compact.css.map +1 -0
  27. package/css/themes/compact.min.css +1 -0
  28. package/css/utilities/all.css +13112 -0
  29. package/css/utilities/all.css.map +1 -0
  30. package/css/utilities/all.min.css +1 -0
  31. package/css/utilities/background.css +1460 -0
  32. package/css/utilities/background.css.map +1 -0
  33. package/css/utilities/background.min.css +1 -0
  34. package/css/utilities/border.css +4697 -0
  35. package/css/utilities/border.css.map +1 -0
  36. package/css/utilities/border.min.css +1 -0
  37. package/css/utilities/elevation.css +317 -0
  38. package/css/utilities/elevation.css.map +1 -0
  39. package/css/utilities/elevation.min.css +1 -0
  40. package/css/utilities/flex.css +969 -0
  41. package/css/utilities/flex.css.map +1 -0
  42. package/css/utilities/flex.min.css +1 -0
  43. package/css/utilities/grid.css +1209 -0
  44. package/css/utilities/grid.css.map +1 -0
  45. package/css/utilities/grid.min.css +1 -0
  46. package/css/utilities/interaction.css +44 -0
  47. package/css/utilities/interaction.css.map +1 -0
  48. package/css/utilities/interaction.min.css +1 -0
  49. package/css/utilities/layout.css +1055 -0
  50. package/css/utilities/layout.css.map +1 -0
  51. package/css/utilities/layout.min.css +1 -0
  52. package/css/utilities/sizing.css +1931 -0
  53. package/css/utilities/sizing.css.map +1 -0
  54. package/css/utilities/sizing.min.css +1 -0
  55. package/css/utilities/spacing.css +1881 -0
  56. package/css/utilities/spacing.css.map +1 -0
  57. package/css/utilities/spacing.min.css +1 -0
  58. package/css/utilities/typography.css +763 -0
  59. package/css/utilities/typography.css.map +1 -0
  60. package/css/utilities/typography.min.css +1 -0
  61. package/package.json +36 -0
  62. package/sass/all.sass +6 -0
  63. package/sass/baloise-design-system.sass +1 -0
  64. package/sass/core.sass +37 -0
  65. package/sass/font.sass +1 -0
  66. package/sass/mixins.sass +3 -0
  67. package/sass/normalize.sass +359 -0
  68. package/sass/structure.sass +113 -0
  69. package/sass/themes/compact.sass +28 -0
  70. package/sass/utilities/all.sass +9 -0
  71. package/sass/utilities/background.sass +5 -0
  72. package/sass/utilities/border.sass +2 -0
  73. package/sass/utilities/elevation.sass +2 -0
  74. package/sass/utilities/flex.sass +2 -0
  75. package/sass/utilities/grid.sass +2 -0
  76. package/sass/utilities/interaction.sass +2 -0
  77. package/sass/utilities/layout.sass +12 -0
  78. package/sass/utilities/sizing.sass +2 -0
  79. package/sass/utilities/spacing.sass +2 -0
  80. package/sass/utilities/typography.sass +127 -0
  81. package/src/core/_all.sass +18 -0
  82. package/src/core/container.sass +23 -0
  83. package/src/core/form/_all.sass +6 -0
  84. package/src/core/form/button.sass +532 -0
  85. package/src/core/form/file.sass +139 -0
  86. package/src/core/form/input-textarea.sass +80 -0
  87. package/src/core/form/select.sass +111 -0
  88. package/src/core/form/shared.sass +69 -0
  89. package/src/core/form/tools.sass +209 -0
  90. package/src/core/grid.sass +477 -0
  91. package/src/core/link.sass +64 -0
  92. package/src/core/list.sass +85 -0
  93. package/src/core/table.sass +134 -0
  94. package/src/core/typography.sass +33 -0
  95. package/src/core/vars/_all.sass +7 -0
  96. package/src/core/vars/button.vars.sass +282 -0
  97. package/src/core/vars/form.vars.sass +137 -0
  98. package/src/core/vars/link.vars.sass +36 -0
  99. package/src/core/vars/list.vars.sass +20 -0
  100. package/src/core/vars/structure.vars.sass +47 -0
  101. package/src/core/vars/table.vars.sass +55 -0
  102. package/src/core/vars/typography.vars.sass +12 -0
  103. package/src/generated/background.sass +1091 -0
  104. package/src/generated/border.sass +3943 -0
  105. package/src/generated/elevation.sass +283 -0
  106. package/src/generated/flex.sass +831 -0
  107. package/src/generated/interaction.sass +26 -0
  108. package/src/generated/layout.sass +948 -0
  109. package/src/generated/sizing.sass +1703 -0
  110. package/src/generated/spacing.sass +1683 -0
  111. package/src/generated/typography.sass +453 -0
  112. package/src/mixins/_all.sass +7 -0
  113. package/src/mixins/bem.mixin.sass +39 -0
  114. package/src/mixins/breakpoint.mixin.sass +67 -0
  115. package/src/mixins/extends.sass +32 -0
  116. package/src/mixins/general.mixin.sass +95 -0
  117. package/src/mixins/svg.mixin.sass +6 -0
package/bin/index.mjs ADDED
@@ -0,0 +1,1333 @@
1
+ #!/usr/bin/env node
2
+
3
+ import prompts from 'prompts'
4
+ import replace from 'replace-in-file'
5
+ import path from 'path'
6
+ import fs from 'fs'
7
+ import fsp from 'fs/promises'
8
+ import { tsquery } from '@phenomnomnominal/tsquery'
9
+ import { load } from 'cheerio'
10
+ import { glob } from 'glob'
11
+
12
+ // ================================================================================
13
+ // MAIN
14
+ // ================================================================================
15
+ const main = async () => {
16
+ const log = logger('Styles Migration')
17
+ const response = await prompts([
18
+ {
19
+ type: 'multiselect',
20
+ name: 'targets',
21
+ message: 'What do you want to migrate',
22
+ choices: [
23
+ {
24
+ title: 'html templates (*.html)',
25
+ value: 'HTML',
26
+ selected: true,
27
+ },
28
+ {
29
+ title: 'Global stylesheet',
30
+ value: 'GLOBAL_STYLES',
31
+ selected: true,
32
+ },
33
+ {
34
+ title: 'inline templates (angular - *.ts)',
35
+ value: 'INLINE',
36
+ selected: true,
37
+ },
38
+ {
39
+ title: 'mixin imports (angular - *.scss)',
40
+ value: 'SCSS',
41
+ selected: true,
42
+ },
43
+ {
44
+ title: 'css variables (*.scss)',
45
+ value: 'CSS_VARIABLES',
46
+ selected: true,
47
+ },
48
+ ],
49
+ instructions: false,
50
+ },
51
+ {
52
+ type: (_prev, { targets }) =>
53
+ targets.includes('HTML') || targets.includes('INLINE') || targets.includes('SCSS') ? 'text' : null,
54
+ name: 'pathToComponentFiles',
55
+ message: 'Where are your html template files located?',
56
+ initial: path.join('src', 'app'),
57
+ },
58
+ {
59
+ type: (_prev, { targets }) => (targets.includes('CSS_VARIABLES') ? 'text' : null),
60
+ name: 'pathToStylesheets',
61
+ message: 'Where are your scss style files located?',
62
+ initial: path.join('src'),
63
+ },
64
+ {
65
+ type: (_prev, { targets }) => (targets.includes('GLOBAL_STYLES') ? 'text' : null),
66
+ name: 'pathGlobalStylesheet',
67
+ message: 'Where is your global stylesheet located, with the imports?',
68
+ initial: path.join('src', 'styles.scss'),
69
+ },
70
+ {
71
+ type: (_prev, { targets }) =>
72
+ targets.includes('GLOBAL_STYLES') || targets.includes('HTML') || targets.includes('INLINE')
73
+ ? 'multiselect'
74
+ : null,
75
+ name: 'utils',
76
+ message: 'Which css utilities do you want to migrate?',
77
+ choices: [
78
+ { value: 'border & radius', selected: true },
79
+ { value: 'color', selected: true },
80
+ { value: 'display', selected: true },
81
+ { value: 'flex', selected: true },
82
+ { value: 'opacity & shadow', selected: true },
83
+ { value: 'spacing', selected: true },
84
+ { value: 'typography', selected: true },
85
+ ],
86
+ instructions: false,
87
+ },
88
+ ])
89
+
90
+ log.info()
91
+ log.start()
92
+ log.info()
93
+
94
+ const { targets, utils, pathGlobalStylesheet, pathToComponentFiles, pathToStylesheets } = response
95
+
96
+ const filePath = path.join(process.cwd(), `${(pathToComponentFiles || 'src/app').trim()}`)
97
+ const globalStyleSheetPath = path.join(process.cwd(), `${(pathGlobalStylesheet || 'src/styles.scss').trim()}`)
98
+
99
+ const isDirectory = await isDirectoryFn({ filePath })
100
+ const directoryPath = isDirectory ? filePath : path.dirname(filePath)
101
+
102
+ let isFile = false
103
+ if ((targets.includes('HTML') || targets.includes('SCSS') || targets.includes('INLINE')) && !isDirectory) {
104
+ try {
105
+ isFile = await isFileFn({ filePath })
106
+ } catch (error) {
107
+ log.fail(`Could not find directory or file at ${filePath}`, error)
108
+ return exit()
109
+ }
110
+ }
111
+
112
+ let doesGlobalStylesheetExist = false
113
+ if (targets.includes('GLOBAL_STYLES')) {
114
+ try {
115
+ doesGlobalStylesheetExist = await isFileFn({
116
+ filePath: globalStyleSheetPath,
117
+ })
118
+ } catch (error) {
119
+ log.info(`Could not find global stylesheet at ${globalStyleSheetPath}`, error)
120
+ }
121
+ }
122
+
123
+ const extension = path.extname(filePath)
124
+ const context = {
125
+ log,
126
+ isDirectory,
127
+ directoryPath,
128
+ isFile,
129
+ filePath,
130
+ extension,
131
+ utils,
132
+ targets,
133
+ globalStyleSheetPath,
134
+ }
135
+
136
+ if (targets.includes('SCSS') && (isDirectory || (isFile && extension === '.scss'))) {
137
+ await migrateComponentStylesSheet(context)
138
+ }
139
+
140
+ if (
141
+ targets.includes('GLOBAL_STYLES') &&
142
+ doesGlobalStylesheetExist &&
143
+ (path.extname(globalStyleSheetPath) === '.scss' || path.extname(globalStyleSheetPath) === '.sass')
144
+ ) {
145
+ await migrateGlobalStyleSheet(context)
146
+ }
147
+
148
+ if (targets.includes('INLINE') || targets.includes('HTML')) {
149
+ const utilReplacers = filterReplacers(context)
150
+
151
+ if (targets.includes('INLINE')) {
152
+ await migrateInlineTemplates({ ...context, utilReplacers })
153
+ }
154
+
155
+ if (targets.includes('HTML')) {
156
+ await migrateHtmlFiles({ ...context, utilReplacers })
157
+ }
158
+ }
159
+
160
+ if (targets.includes('CSS_VARIABLES')) {
161
+ const stylePath = path.join(process.cwd(), `${(pathToStylesheets || 'src').trim()}`)
162
+ const isDirectoryStyle = await isDirectoryFn({ filePath: stylePath })
163
+ const directoryPathStyle = isDirectoryStyle ? stylePath : path.dirname(stylePath)
164
+ await migrateCSSVariables({
165
+ ...context,
166
+ filePath: stylePath,
167
+ isDirectory: isDirectoryStyle,
168
+ directoryPath: directoryPathStyle,
169
+ })
170
+ }
171
+
172
+ log.succeed()
173
+ return done()
174
+ }
175
+
176
+ async function migrateComponentStylesSheet({ log, isDirectory, directoryPath, filePath }) {
177
+ const files = []
178
+ if (isDirectory) {
179
+ files.push(path.join(directoryPath, '**', '*.sass'))
180
+ files.push(path.join(directoryPath, '**', '*.scss'))
181
+ } else {
182
+ files.push(filePath)
183
+ }
184
+
185
+ try {
186
+ const result = await replace({
187
+ files,
188
+ from: [new RegExp(`@baloise/design-system-css/sass/mixins`, 'g')],
189
+ to: ['@baloise/design-system-styles/sass/mixins'],
190
+ })
191
+ printResult({ result, log })
192
+ } catch (error) {
193
+ log.info()
194
+ log.fail(error)
195
+ return Promise.reject()
196
+ } finally {
197
+ return Promise.resolve()
198
+ }
199
+ }
200
+
201
+ async function migrateCSSVariables({ log, isDirectory, directoryPath, filePath }) {
202
+ const files = []
203
+ if (isDirectory) {
204
+ files.push(path.join(directoryPath, '**', '*.sass'))
205
+ files.push(path.join(directoryPath, '**', '*.scss'))
206
+ } else {
207
+ files.push(filePath)
208
+ }
209
+
210
+ try {
211
+ const result = await replace({
212
+ files,
213
+ from: [
214
+ ...replacementsCSSVariablesColors.from,
215
+ ...replacementsCSSVariablesVarious.from,
216
+ ...replacementsCSSVariablesSpace.from,
217
+ ...replacementsCSSVariablesTextSize.from,
218
+ ],
219
+ to: [
220
+ ...replacementsCSSVariablesColors.to,
221
+ ...replacementsCSSVariablesVarious.to,
222
+ ...replacementsCSSVariablesSpace.to,
223
+ ...replacementsCSSVariablesTextSize.to,
224
+ ],
225
+ })
226
+ printResult({ result, log })
227
+ } catch (error) {
228
+ log.info()
229
+ log.fail(error)
230
+ return Promise.reject()
231
+ } finally {
232
+ return Promise.resolve()
233
+ }
234
+ }
235
+
236
+ async function migrateGlobalStyleSheet({ globalStyleSheetPath, log }) {
237
+ const files = globalStyleSheetPath
238
+ try {
239
+ const result = await replace({
240
+ files,
241
+ from: [
242
+ new RegExp(`@baloise/design-system-css/(sass|css)/baloise-design-system.sass`, 'g'),
243
+ new RegExp(`@baloise/design-system-css/(sass|css)/baloise-design-system`, 'g'),
244
+
245
+ new RegExp(`@baloise/design-system-css/sass/mixins`, 'g'),
246
+ new RegExp(`@baloise/design-system-css/(sass|css)/normalize`, 'g'),
247
+ new RegExp(`@baloise/design-system-css/(sass|css)/structure`, 'g'),
248
+ new RegExp(`@baloise/design-system-css/(sass|css)/font`, 'g'),
249
+ new RegExp(`@baloise/design-system-css/(sass|css)/core`, 'g'),
250
+
251
+ `// Deprecated styles will be removed with the next breaking version (optional)`,
252
+ new RegExp(`@import '@baloise/design-system-css/(sass|css)/legacy';`, 'g'), // deprecated
253
+ new RegExp(`@import '@baloise/design-system-css/(sass|css)/grid';`, 'g'), // included in core
254
+
255
+ new RegExp(`@baloise/design-system-css/(sass|css)/display`, 'g'),
256
+ new RegExp(`@baloise/design-system-css/(sass|css)/flex`, 'g'),
257
+ new RegExp(`@baloise/design-system-css/(sass|css)/spacing`, 'g'),
258
+ new RegExp(`@baloise/design-system-css/(sass|css)/typography`, 'g'),
259
+ new RegExp(`@baloise/design-system-css/(sass|css)/color`, 'g'),
260
+ new RegExp(`@baloise/design-system-css/(sass|css)/border`, 'g'),
261
+ new RegExp(`@baloise/design-system-css/(sass|css)/radius`, 'g'),
262
+ new RegExp(`@baloise/design-system-css/(sass|css)/opacity`, 'g'),
263
+ new RegExp(`@baloise/design-system-css/(sass|css)/shadow`, 'g'),
264
+ ],
265
+ to: [
266
+ '@baloise/design-system-styles/sass/all',
267
+ '@baloise/design-system-styles/sass/all',
268
+
269
+ '@baloise/design-system-styles/sass/mixins',
270
+ '@baloise/design-system-styles/css/normalize',
271
+ '@baloise/design-system-styles/css/structure',
272
+ '@baloise/design-system-styles/css/font',
273
+ '@baloise/design-system-styles/css/core',
274
+ '',
275
+ '',
276
+ '',
277
+ '@baloise/design-system-styles/css/utilities/layout',
278
+ '@baloise/design-system-styles/css/utilities/flex',
279
+ '@baloise/design-system-styles/css/utilities/spacing',
280
+ '@baloise/design-system-styles/css/utilities/typography',
281
+ '@baloise/design-system-styles/css/utilities/background',
282
+ '@baloise/design-system-styles/css/utilities/border',
283
+ '@baloise/design-system-styles/css/utilities/border',
284
+ '@baloise/design-system-styles/css/utilities/elevation',
285
+ '@baloise/design-system-styles/css/utilities/elevation',
286
+ ],
287
+ })
288
+ printResult({ result, log })
289
+ let lines = (await fsp.readFile(files, 'utf-8')).split(/\r?\n/)
290
+ lines.push(`@import '@baloise/design-system-styles/css/utilities/interaction';`)
291
+ lines.push(`@import '@baloise/design-system-styles/css/utilities/sizing';`)
292
+ lines = lines.reduce((acc, line) => {
293
+ if (line.length === 0) {
294
+ if (acc[acc.length - 1].length === 0) {
295
+ return acc
296
+ }
297
+ return [...acc, line]
298
+ }
299
+ return acc.indexOf(line) >= 0 ? acc : [...acc, line]
300
+ }, [])
301
+ await fsp.writeFile(files, lines.join('\r\n'))
302
+ } catch (error) {
303
+ log.info()
304
+ log.fail(error)
305
+ return Promise.reject()
306
+ } finally {
307
+ return Promise.resolve()
308
+ }
309
+ }
310
+
311
+ async function migrateInlineTemplates({ filePath, log, utilReplacers }) {
312
+ // check if path is directly one file
313
+ const isFile = filePath.endsWith('.ts')
314
+ let pathToFiles = filePath
315
+ if (!isFile) {
316
+ pathToFiles = path.join(filePath, '**', '*.ts')
317
+ }
318
+
319
+ const files = await glob(pathToFiles)
320
+ const inlineTemplateFiles = []
321
+ for (let index = 0; index < files.length; index++) {
322
+ const file = files[index]
323
+ const content = await fsp.readFile(file, 'utf-8')
324
+ if (content.includes('@Component') && content.includes('template: `')) {
325
+ inlineTemplateFiles.push(file)
326
+ }
327
+ }
328
+
329
+ for (let index = 0; index < inlineTemplateFiles.length; index++) {
330
+ const file = inlineTemplateFiles[index]
331
+ const content = await fsp.readFile(file, 'utf-8')
332
+ let newContent = content
333
+ tsquery.replace(content, 'PropertyAssignment', node => {
334
+ if (node.name.getText() === 'template') {
335
+ const originalTemplate = node.getChildAt(2).getFullText().trim().slice(1, -1)
336
+
337
+ const template = replaceHtml({
338
+ template: originalTemplate,
339
+ from: utilReplacers.from,
340
+ to: utilReplacers.to,
341
+ })
342
+
343
+ if (template !== originalTemplate) {
344
+ newContent = newContent.replace(originalTemplate, template)
345
+ }
346
+ }
347
+
348
+ // return undefined does not replace anything
349
+ return undefined
350
+ })
351
+
352
+ if (content !== newContent) {
353
+ await fsp.writeFile(file, newContent)
354
+ log.list(file.replace(process.cwd(), ''))
355
+ }
356
+ }
357
+ }
358
+
359
+ async function migrateHtmlFiles({ filePath, log, utilReplacers }) {
360
+ // check if path is directly one file
361
+ const isFile = filePath.trim().endsWith('.html')
362
+ let files = filePath
363
+ if (!isFile) {
364
+ files = path.join(`${files}`, '**', '*.html')
365
+ }
366
+
367
+ try {
368
+ const results = [
369
+ await replace({
370
+ files,
371
+ processor: input => {
372
+ const $ = load(input)
373
+ let content = input
374
+ $('[class]').each((index, element) => {
375
+ const classes = $(element).attr('class').split(' ')
376
+
377
+ const modifiedClasses = classes.map(className => {
378
+ for (let index = 0; index < utilReplacers.from.length; index++) {
379
+ const oldClassName = utilReplacers.from[index]
380
+ const replacement = utilReplacers.to[index]
381
+ if (className.match(escapeRegex(oldClassName))) {
382
+ return className.replace(oldClassName, replacement)
383
+ }
384
+ }
385
+ return className
386
+ })
387
+
388
+ content = content.replace(`class="${classes.join(' ')}"`, `class="${modifiedClasses.join(' ')}"`)
389
+ })
390
+
391
+ return content
392
+ },
393
+ }),
394
+ ]
395
+
396
+ let changedFiles = results
397
+ .flat()
398
+ .filter(result => result.hasChanged)
399
+ .map(result => result.file.replace(process.cwd(), ''))
400
+
401
+ changedFiles = changedFiles.filter((item, index) => changedFiles.indexOf(item) === index)
402
+
403
+ if (changedFiles.length > 0) {
404
+ changedFiles.forEach(file => log.list(file))
405
+ } else {
406
+ log.info('No files found to migrate')
407
+ }
408
+ log.info()
409
+ } catch (error) {
410
+ log.info()
411
+ log.fail(error)
412
+ return Promise.reject()
413
+ } finally {
414
+ return Promise.resolve()
415
+ }
416
+ }
417
+
418
+ // ================================================================================
419
+ // UTILITIES
420
+ // ================================================================================
421
+
422
+ function filterReplacers({ utils }) {
423
+ const from = []
424
+ const to = []
425
+
426
+ if (utils.includes('border & radius')) {
427
+ from.push(replacementsBorder.from)
428
+ from.push(replacementsRadius.from)
429
+ to.push(replacementsBorder.to)
430
+ to.push(replacementsRadius.to)
431
+ }
432
+
433
+ if (utils.includes('color')) {
434
+ from.push(replacementsColors.from)
435
+ to.push(replacementsColors.to)
436
+ }
437
+
438
+ if (utils.includes('flex')) {
439
+ from.push(replacementsFlex.from)
440
+ to.push(replacementsFlex.to)
441
+ }
442
+
443
+ if (utils.includes('display')) {
444
+ from.push(replacementsDisplay.from)
445
+ to.push(replacementsDisplay.to)
446
+ }
447
+
448
+ from.push(replacementsGrid.from)
449
+ to.push(replacementsGrid.to)
450
+
451
+ if (utils.includes('opacity & shadow')) {
452
+ from.push(replacementsOpacity.from)
453
+ to.push(replacementsOpacity.to)
454
+ from.push(replacementsShadow.from)
455
+ to.push(replacementsShadow.to)
456
+ }
457
+
458
+ if (utils.includes('spacing')) {
459
+ from.push(replacementsSpacing.from)
460
+ to.push(replacementsSpacing.to)
461
+ }
462
+
463
+ if (utils.includes('typography')) {
464
+ from.push(replacementsTypography.from)
465
+ to.push(replacementsTypography.to)
466
+ }
467
+
468
+ from.push(replacementsCore.from)
469
+ to.push(replacementsCore.to)
470
+ from.push(replacementsZIndex.from)
471
+ to.push(replacementsZIndex.to)
472
+ from.push(replacementsSizing.from)
473
+ to.push(replacementsSizing.to)
474
+
475
+ return { from: from.flat(), to: to.flat() }
476
+ }
477
+
478
+ function replaceHtml({ template, from, to }) {
479
+ const $ = load(template)
480
+ let newTemplate = template
481
+ $('[class]').each((index, element) => {
482
+ const classes = $(element).attr('class').split(' ')
483
+
484
+ const modifiedClasses = classes.map(className => {
485
+ for (let index = 0; index < from.length; index++) {
486
+ const oldClassName = from[index]
487
+ const replacement = to[index]
488
+ if (className.match(escapeRegex(oldClassName))) {
489
+ return className.replace(oldClassName, replacement)
490
+ }
491
+ }
492
+ return className
493
+ })
494
+
495
+ newTemplate = newTemplate.replace(`class="${classes.join(' ')}"`, `class="${modifiedClasses.join(' ')}"`)
496
+ })
497
+
498
+ return newTemplate
499
+ }
500
+
501
+ function printResult({ result, log }) {
502
+ // filter for only change files and return the path
503
+ let changedFiles = result
504
+ .flat()
505
+ .filter(result => result.hasChanged)
506
+ .map(result => result.file.replace(process.cwd(), ''))
507
+
508
+ // remove duplications
509
+ changedFiles = changedFiles.filter((item, index) => changedFiles.indexOf(item) === index)
510
+
511
+ if (changedFiles.length > 0) {
512
+ changedFiles.forEach(file => log.list(file))
513
+ } else {
514
+ log.info('No files found to migrate')
515
+ }
516
+ }
517
+
518
+ async function isDirectoryFn({ filePath }) {
519
+ try {
520
+ const isDirectory = fs.lstatSync(filePath).isDirectory()
521
+ return Promise.resolve(isDirectory)
522
+ } catch (error) {
523
+ return Promise.resolve(false)
524
+ }
525
+ }
526
+
527
+ async function isFileFn({ filePath }) {
528
+ try {
529
+ const isFile = fs.lstatSync(filePath).isFile()
530
+ return Promise.resolve(isFile)
531
+ } catch (error) {
532
+ return Promise.reject(error)
533
+ }
534
+ }
535
+
536
+ function escapeRegex(string) {
537
+ if (typeof string === 'string') {
538
+ return string.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&')
539
+ }
540
+ return string
541
+ }
542
+
543
+ const breakpointClasses = className => ({
544
+ from: allBreakpoints.map(b => new RegExp(`is-${className}${b ? `-${b}` : ''}`, 'g')),
545
+ to: allBreakpoints.map(b => `${b ? `${b}:` : ''}${className}`),
546
+ })
547
+
548
+ const spacingClasses = (oldClassName, newClassName) => ({
549
+ from: allSpacingValues.map(s => new RegExp(`${oldClassName}${s ? `-${s}` : ''}`, 'g')),
550
+ to: allSpacingValues.map(s => `${newClassName}${s ? `-${s}` : ''}`),
551
+ })
552
+
553
+ const exit = () => process.exit(1)
554
+ const done = () => process.exit(0)
555
+ const log = (message, ...args) => console.log(message, ...args)
556
+ const logger = subject => {
557
+ let startTime = new Date()
558
+
559
+ return {
560
+ info: (message, ...args) => {
561
+ console.log(message || '', ...args)
562
+ },
563
+ start: message => {
564
+ startTime = new Date()
565
+ log('⏳ ', `${subject} \x1b[90mstarted ...\x1b[0m`, message || '')
566
+ },
567
+ succeed: message => {
568
+ const endTime = new Date()
569
+ const duration = endTime - startTime
570
+ const seconds = parseFloat(duration / 1000).toFixed(2)
571
+ log('✅ ', `\x1b[32m${subject} \x1b[90mfinished in ${seconds}sec\x1b[0m`, message || '')
572
+ },
573
+ fail: message => {
574
+ const endTime = new Date()
575
+ const duration = endTime - startTime
576
+ const seconds = parseFloat(duration / 1000).toFixed(2)
577
+ log('❌ ', `\x1b[31m${subject} \x1b[90mfailed after ${seconds}sec\x1b[0m`)
578
+ if (message) {
579
+ console.error(message)
580
+ }
581
+ exit()
582
+ },
583
+ list: message => {
584
+ console.log('\x1b[90mUPDATE\x1b[0m', message)
585
+ },
586
+ }
587
+ }
588
+
589
+ // const minBreakpoints = ['', 'mobile', 'tablet', 'desktop', 'widescreen']
590
+
591
+ const allBreakpoints = [
592
+ 'tablet-only',
593
+ 'desktop-only',
594
+ 'high-definition-only',
595
+ 'widescreen-only',
596
+ 'mobile',
597
+ 'tablet',
598
+ 'touch',
599
+ 'desktop',
600
+ 'high-definition',
601
+ 'widescreen',
602
+ 'fullhd',
603
+ '',
604
+ ]
605
+
606
+ const allSpacingValues = [
607
+ 'auto',
608
+ 'none',
609
+ 'xx-small',
610
+ 'x-small',
611
+ 'small',
612
+ 'normal',
613
+ 'medium',
614
+ 'xxxx-large',
615
+ 'xxx-large',
616
+ 'xx-large',
617
+ 'x-large',
618
+ 'large',
619
+ ]
620
+
621
+ // ================================================================================
622
+ // MAPPINGS & REPLACEMENTS
623
+ // ================================================================================
624
+
625
+ const invertedTextWhite = {
626
+ from: [
627
+ /has-text-black-inverted/g,
628
+ /has-text-grey-5-inverted/g,
629
+ /has-text-grey-6-inverted/g,
630
+ /has-text-blue-4-inverted/g,
631
+ /has-text-blue-5-inverted/g,
632
+ /has-text-blue-6-inverted/g,
633
+ /has-text-light-blue-4-inverted/g,
634
+ /has-text-light-blue-5-inverted/g,
635
+ /has-text-light-blue-6-inverted/g,
636
+ /has-text-purple-4-inverted/g,
637
+ /has-text-purple-5-inverted/g,
638
+ /has-text-purple-6-inverted/g,
639
+ /has-text-green-6-inverted/g,
640
+ /has-text-yellow-6-inverted/g,
641
+ /has-text-red-4-inverted/g,
642
+ /has-text-red-5-inverted/g,
643
+ /has-text-red-6-inverted/g,
644
+ /has-text-info-3-inverted/g,
645
+ /has-text-info-4-inverted/g,
646
+ /has-text-info-5-inverted/g,
647
+ /has-text-info-6-inverted/g,
648
+ /has-text-success-3-inverted/g,
649
+ /has-text-success-4-inverted/g,
650
+ /has-text-success-5-inverted/g,
651
+ /has-text-success-6-inverted/g,
652
+ /has-text-danger-3-inverted/g,
653
+ /has-text-danger-4-inverted/g,
654
+ /has-text-danger-5-inverted/g,
655
+ /has-text-danger-6-inverted/g,
656
+ /has-text-primary-4-inverted/g,
657
+ /has-text-primary-5-inverted/g,
658
+ /has-text-primary-6-inverted/g,
659
+ /has-text-primary-inverted/g,
660
+ /has-text-blue-inverted/g,
661
+ /has-text-info-inverted/g,
662
+ /has-text-success-inverted/g,
663
+ /has-text-danger-inverted/g,
664
+ ],
665
+ to: [
666
+ 'text-white',
667
+ 'text-white',
668
+ 'text-white',
669
+ 'text-white',
670
+ 'text-white',
671
+ 'text-white',
672
+ 'text-white',
673
+ 'text-white',
674
+ 'text-white',
675
+ 'text-white',
676
+ 'text-white',
677
+ 'text-white',
678
+ 'text-white',
679
+ 'text-white',
680
+ 'text-white',
681
+ 'text-white',
682
+ 'text-white',
683
+ 'text-white',
684
+ 'text-white',
685
+ 'text-white',
686
+ 'text-white',
687
+ 'text-white',
688
+ 'text-white',
689
+ 'text-white',
690
+ 'text-white',
691
+ 'text-white',
692
+ 'text-white',
693
+ 'text-white',
694
+ 'text-white',
695
+ 'text-white',
696
+ 'text-white',
697
+ 'text-white',
698
+ 'text-white',
699
+ 'text-white',
700
+ 'text-white',
701
+ 'text-white',
702
+ 'text-white',
703
+ ],
704
+ }
705
+
706
+ const invertedTextPrimary = {
707
+ from: [
708
+ /has-text-transparent-inverted/g,
709
+ /has-text-white-inverted/g,
710
+ /has-text-grey-1-inverted/g,
711
+ /has-text-grey-2-inverted/g,
712
+ /has-text-grey-3-inverted/g,
713
+ /has-text-grey-4-inverted/g,
714
+ /has-text-blue-1-inverted/g,
715
+ /has-text-blue-2-inverted/g,
716
+ /has-text-blue-3-inverted/g,
717
+ /has-text-light-blue-1-inverted/g,
718
+ /has-text-light-blue-2-inverted/g,
719
+ /has-text-light-blue-3-inverted/g,
720
+ /has-text-purple-1-inverted/g,
721
+ /has-text-purple-2-inverted/g,
722
+ /has-text-purple-3-inverted/g,
723
+ /has-text-green-1-inverted/g,
724
+ /has-text-green-2-inverted/g,
725
+ /has-text-green-3-inverted/g,
726
+ /has-text-green-4-inverted/g,
727
+ /has-text-green-5-inverted/g,
728
+ /has-text-yellow-1-inverted/g,
729
+ /has-text-yellow-2-inverted/g,
730
+ /has-text-yellow-3-inverted/g,
731
+ /has-text-yellow-4-inverted/g,
732
+ /has-text-yellow-5-inverted/g,
733
+ /has-text-red-1-inverted/g,
734
+ /has-text-red-2-inverted/g,
735
+ /has-text-red-3-inverted/g,
736
+ /has-text-info-1-inverted/g,
737
+ /has-text-info-2-inverted/g,
738
+ /has-text-success-1-inverted/g,
739
+ /has-text-success-2-inverted/g,
740
+ /has-text-warning-1-inverted/g,
741
+ /has-text-warning-2-inverted/g,
742
+ /has-text-warning-3-inverted/g,
743
+ /has-text-warning-4-inverted/g,
744
+ /has-text-warning-5-inverted/g,
745
+ /has-text-warning-6-inverted/g,
746
+ /has-text-danger-1-inverted/g,
747
+ /has-text-danger-2-inverted/g,
748
+ /has-text-primary-1-inverted/g,
749
+ /has-text-primary-2-inverted/g,
750
+ /has-text-primary-3-inverted/g,
751
+ /has-text-grey-inverted/g,
752
+ /has-text-light-blue-inverted/g,
753
+ /has-text-purple-inverted/g,
754
+ /has-text-green-inverted/g,
755
+ /has-text-yellow-inverted/g,
756
+ /has-text-red-inverted/g,
757
+ /has-text-warning-inverted/g,
758
+ ],
759
+ to: [
760
+ 'text-primary',
761
+ 'text-primary',
762
+ 'text-primary',
763
+ 'text-primary',
764
+ 'text-primary',
765
+ 'text-primary',
766
+ 'text-primary',
767
+ 'text-primary',
768
+ 'text-primary',
769
+ 'text-primary',
770
+ 'text-primary',
771
+ 'text-primary',
772
+ 'text-primary',
773
+ 'text-primary',
774
+ 'text-primary',
775
+ 'text-primary',
776
+ 'text-primary',
777
+ 'text-primary',
778
+ 'text-primary',
779
+ 'text-primary',
780
+ 'text-primary',
781
+ 'text-primary',
782
+ 'text-primary',
783
+ 'text-primary',
784
+ 'text-primary',
785
+ 'text-primary',
786
+ 'text-primary',
787
+ 'text-primary',
788
+ 'text-primary',
789
+ 'text-primary',
790
+ 'text-primary',
791
+ 'text-primary',
792
+ 'text-primary',
793
+ 'text-primary',
794
+ 'text-primary',
795
+ 'text-primary',
796
+ 'text-primary',
797
+ 'text-primary',
798
+ 'text-primary',
799
+ 'text-primary',
800
+ 'text-primary',
801
+ 'text-primary',
802
+ 'text-primary',
803
+ 'text-primary',
804
+ 'text-primary',
805
+ 'text-primary',
806
+ 'text-primary',
807
+ 'text-primary',
808
+ 'text-primary',
809
+ 'text-primary',
810
+ ],
811
+ }
812
+
813
+ const textSizeLegacy = {
814
+ from: [
815
+ /is-size-display-2/g,
816
+ /is-size-display/g,
817
+ /is-size-1/g,
818
+ /is-size-2/g,
819
+ /is-size-3/g,
820
+ /is-size-4/g,
821
+ /is-size-5/g,
822
+ /is-size-6/g,
823
+ /is-size-7/g,
824
+ /is-size-8/g,
825
+ ],
826
+ to: [
827
+ 'text-xxxx-large',
828
+ 'text-xxxxx-large',
829
+ 'text-xxx-large',
830
+ 'text-xx-large',
831
+ 'text-x-large',
832
+ 'text-large',
833
+ 'text-medium',
834
+ 'text-normal',
835
+ 'text-small',
836
+ 'text-x-small',
837
+ ],
838
+ }
839
+
840
+ const textAlignment = {
841
+ from: [
842
+ /has-text-centered-desktop/g,
843
+ /has-text-centered-tablet/g,
844
+ /has-text-centered-mobile/g,
845
+ /has-text-centered/g,
846
+ /has-text-justified-desktop/g,
847
+ /has-text-justified-tablet/g,
848
+ /has-text-justified-mobile/g,
849
+ /has-text-justified/g,
850
+ /has-text-left-desktop/g,
851
+ /has-text-left-tablet/g,
852
+ /has-text-left-mobile/g,
853
+ /has-text-left/g,
854
+ /has-text-right-desktop/g,
855
+ /has-text-right-tablet/g,
856
+ /has-text-right-mobile/g,
857
+ /has-text-right/g,
858
+ ],
859
+ to: [
860
+ 'desktop:text-align-center',
861
+ 'tablet:text-align-center',
862
+ 'mobile:text-align-center',
863
+ 'text-align-center',
864
+ 'desktop:text-align-justify',
865
+ 'tablet:text-align-justify',
866
+ 'mobile:text-align-justify',
867
+ 'text-align-justify',
868
+ 'desktop:text-align-left',
869
+ 'tablet:text-align-left',
870
+ 'mobile:text-align-left',
871
+ 'text-align-left',
872
+ 'desktop:text-align-right',
873
+ 'tablet:text-align-right',
874
+ 'mobile:text-align-right',
875
+ 'text-align-right',
876
+ ],
877
+ }
878
+
879
+ const marginAndPadding = () => {
880
+ const props = ['m', 'p']
881
+ const orientation = ['', '', 'x', 'y', 't', 'r', 'b', 'l']
882
+ const sizes = [
883
+ 'none',
884
+ 'xx-small',
885
+ 'x-small',
886
+ 'small',
887
+ 'normal',
888
+ 'medium',
889
+ 'large',
890
+ 'x-large',
891
+ 'xx-large',
892
+ 'xxx-large',
893
+ 'xxxx-large',
894
+ ]
895
+ const fromResults = []
896
+ const toResults = []
897
+ props.forEach(p => {
898
+ orientation.forEach(o => {
899
+ sizes.forEach((s, i) => {
900
+ fromResults.push(new RegExp(`${p}${o ? '-' + o : ''}-${i}`, 'g'))
901
+ toResults.push(`${p}${o ? '-' + o : ''}-${s}`)
902
+ })
903
+ })
904
+ })
905
+ return {
906
+ from: fromResults,
907
+ to: toResults,
908
+ }
909
+ }
910
+
911
+ const ColSizes = [
912
+ 'is-narrow',
913
+ 'is-full',
914
+ 'is-three-quarters',
915
+ 'is-two-thirds',
916
+ 'is-half',
917
+ 'is-one-third',
918
+ 'is-one-quarter',
919
+ 'is-one-fifth',
920
+ 'is-two-fifths',
921
+ 'is-three-fifths',
922
+ 'is-four-fifths',
923
+ 'is-offset-three-quarters',
924
+ 'is-offset-two-thirds',
925
+ 'is-offset-half',
926
+ 'is-offset-one-third',
927
+ 'is-offset-one-quarter',
928
+ 'is-offset-one-fifth',
929
+ 'is-offset-two-fifths',
930
+ 'is-offset-three-fifths',
931
+ 'is-offset-four-fifths',
932
+ 'is-10',
933
+ 'is-offset-10',
934
+ 'is-11',
935
+ 'is-offset-11',
936
+ 'is-12',
937
+ 'is-offset-12',
938
+ 'is-0',
939
+ 'is-offset-0',
940
+ 'is-1',
941
+ 'is-offset-1',
942
+ 'is-2',
943
+ 'is-offset-2',
944
+ 'is-3',
945
+ 'is-offset-3',
946
+ 'is-4',
947
+ 'is-offset-4',
948
+ 'is-5',
949
+ 'is-offset-5',
950
+ 'is-6',
951
+ 'is-offset-6',
952
+ 'is-7',
953
+ 'is-offset-7',
954
+ 'is-8',
955
+ 'is-offset-8',
956
+ 'is-8',
957
+ 'is-offset-9',
958
+ ]
959
+
960
+ const replacementsGrid = {
961
+ from: [
962
+ /(?<!-)columns/g,
963
+ /(?<!-)\bcolumn\b/g,
964
+ ...ColSizes.map(className => new RegExp(`${className}-mobile`, 'g')),
965
+ ...ColSizes.map(className => new RegExp(`${className}-tablet`, 'g')),
966
+ ...ColSizes.map(className => new RegExp(`${className}-touch`, 'g')),
967
+ ...ColSizes.map(className => new RegExp(`${className}-desktop`, 'g')),
968
+ ...ColSizes.map(className => new RegExp(`${className}-widescreen`, 'g')),
969
+ ...ColSizes.map(className => new RegExp(`${className}-fullhd`, 'g')),
970
+ ],
971
+ to: [
972
+ 'grid',
973
+ 'col',
974
+ ...ColSizes.map(className => `mobile:${className}`, 'g'),
975
+ ...ColSizes.map(className => `tablet:${className}`, 'g'),
976
+ ...ColSizes.map(className => `touch:${className}`, 'g'),
977
+ ...ColSizes.map(className => `desktop:${className}`, 'g'),
978
+ ...ColSizes.map(className => `widescreen:${className}`, 'g'),
979
+ ...ColSizes.map(className => `fullhd:${className}`, 'g'),
980
+ ],
981
+ }
982
+
983
+ const replacementsBorder = {
984
+ from: [/has-border-light-blue/g, /has-border-primary-dark/g, /has-border/g],
985
+ to: ['border-primary-hovered', 'border-primary-pressed', 'border'],
986
+ }
987
+
988
+ const replacementsColors = {
989
+ from: [/has-background-blue/g, /has-background/g, ...invertedTextWhite.from, ...invertedTextPrimary.from],
990
+ to: ['bg-primary', 'bg', ...invertedTextWhite.to, ...invertedTextPrimary.to],
991
+ }
992
+
993
+ const replacementsCore = {
994
+ from: [/is-vertical-align/g, /is-clickable/g, /is-list/g],
995
+ to: ['vertical-align', 'cursor-pointer', 'list'],
996
+ }
997
+
998
+ const replacementsDisplay = {
999
+ from: [
1000
+ ...breakpointClasses('inline-block').from,
1001
+ ...breakpointClasses('inline-flex').from,
1002
+ ...breakpointClasses('block').from,
1003
+ ...breakpointClasses('flex').from,
1004
+ ...breakpointClasses('inline').from,
1005
+ ...breakpointClasses('hidden').from,
1006
+ /is-vertical-align-top/g,
1007
+ /is-vertical-align-middle/g,
1008
+ /is-vertical-align-bottom/g,
1009
+ ],
1010
+ to: [
1011
+ ...breakpointClasses('inline-block').to,
1012
+ ...breakpointClasses('inline-flex').to,
1013
+ ...breakpointClasses('block').to,
1014
+ ...breakpointClasses('flex').to,
1015
+ ...breakpointClasses('inline').to,
1016
+ ...breakpointClasses('hidden').to,
1017
+ 'vertical-align-top',
1018
+ 'vertical-align-middle',
1019
+ 'vertical-align-bottom',
1020
+ ],
1021
+ }
1022
+
1023
+ const replacementsFlex = {
1024
+ from: [
1025
+ /is-flex-direction/g,
1026
+ /is-flex-wrap-nowrap/g,
1027
+ /is-flex-wrap-wrap-reverse/g,
1028
+ /is-flex-wrap-wrap/g,
1029
+ /is-justify-content-flex/g,
1030
+ /is-justify-content-left/g,
1031
+ /is-justify-content-right/g,
1032
+ /is-justify-content/g,
1033
+ /is-align-content-flex/g,
1034
+ /is-align-content/g,
1035
+ /is-align-items-flex/g,
1036
+ /is-align-items-self/g,
1037
+ /is-align-items/g,
1038
+ /is-align-self-flex/g,
1039
+ /is-align-self/g,
1040
+ /is-flex-1/g,
1041
+ /is-flex-auto/g,
1042
+ /is-flex-initial/g,
1043
+ /is-flex-none/g,
1044
+ /is-flex-grow-0/g,
1045
+ /is-flex-shrink-0/g,
1046
+ /is-flex-grow-1/g,
1047
+ /is-flex-shrink-1/g,
1048
+ ...spacingClasses('fg', 'gap').from,
1049
+ ],
1050
+ to: [
1051
+ 'flex-direction',
1052
+ 'flex-nowrap',
1053
+ 'flex-wrap-reverse',
1054
+ 'flex-wrap',
1055
+ 'justify-content',
1056
+ 'justify-content-start',
1057
+ 'justify-content-end',
1058
+ 'justify-content',
1059
+ 'align-content',
1060
+ 'align-content',
1061
+ 'align-items',
1062
+ 'align-items',
1063
+ 'align-items',
1064
+ 'align-self',
1065
+ 'align-self',
1066
+ 'flex-1',
1067
+ 'flex-auto',
1068
+ 'flex-initial',
1069
+ 'flex-none',
1070
+ 'flex-initial',
1071
+ 'flex-initial',
1072
+ 'flex-1',
1073
+ 'flex-1',
1074
+ ...spacingClasses('fg', 'gap').to,
1075
+ ],
1076
+ }
1077
+
1078
+ const replacementsOpacity = {
1079
+ from: [/has-opacity-100/g, /has-opacity-10/g, /has-opacity-1/g, /has-opacity/g],
1080
+ to: ['opacity-100', 'opacity-10', 'opacity-100', 'opacity'],
1081
+ }
1082
+
1083
+ const replacementsRadius = {
1084
+ from: [/has-radius/g],
1085
+ to: ['radius'],
1086
+ }
1087
+
1088
+ const replacementsShadow = {
1089
+ from: [/has-shadow/g, /has-text-shadow/g, /has-button-shadow/g],
1090
+ to: ['shadow', 'text-shadow', 'text-shadow-normal'],
1091
+ }
1092
+
1093
+ const replacementsSpacing = {
1094
+ from: [/is-marginless/g, /is-paddingless/g, ...marginAndPadding().from],
1095
+ to: ['m-none', 'p-none', ...marginAndPadding().to],
1096
+ }
1097
+
1098
+ const replacementsTypography = {
1099
+ from: [
1100
+ /has-text-weight/g,
1101
+ /is-white-space-normal/g,
1102
+ /has-no-wrap/g,
1103
+ /is-white-space-nowrap/g,
1104
+ /is-capitalized/g,
1105
+ /is-lowercase/g,
1106
+ /is-uppercase/g,
1107
+ /is-family-text/g,
1108
+ /is-family-title/g,
1109
+ ...textAlignment.from,
1110
+ ...textSizeLegacy.from,
1111
+ /has-text/g,
1112
+ /is-size/g,
1113
+ ],
1114
+ to: [
1115
+ 'font-weight',
1116
+ 'white-space-normal',
1117
+ 'white-space-nowrap',
1118
+ 'white-space-nowrap',
1119
+ 'capitalize',
1120
+ 'lowercase',
1121
+ 'uppercase',
1122
+ 'font-family-text',
1123
+ 'font-family-title',
1124
+ ...textAlignment.to,
1125
+ ...textSizeLegacy.to,
1126
+ 'text',
1127
+ 'text',
1128
+ ],
1129
+ }
1130
+
1131
+ const replacementsZIndex = {
1132
+ from: [/has-z-index/g],
1133
+ to: ['z-index'],
1134
+ }
1135
+
1136
+ const replacementsSizing = {
1137
+ from: [/is-fullheight/g, /is-fullwidth/g],
1138
+ to: ['h-full', 'w-full'],
1139
+ }
1140
+
1141
+ const replacementsCSSVariablesColors = {
1142
+ from: [
1143
+ /var\(--bal-color-border-primary-dark\)/g,
1144
+ /var\(--bal-color-border-light-blue\)/g,
1145
+ /var\(--bal-color-border-danger-dark\)/g,
1146
+ /var\(--bal-color-border-danger-darker\)/g,
1147
+ /var\(--bal-color-blue-1\)/g,
1148
+ /var\(--bal-color-blue-2\)/g,
1149
+ /var\(--bal-color-blue-3\)/g,
1150
+ /var\(--bal-color-blue-4\)/g,
1151
+ /var\(--bal-color-blue-5\)/g,
1152
+ /var\(--bal-color-blue-6\)/g,
1153
+ /var\(--bal-color-blue\)/g,
1154
+ /var\(--bal-color-transparent\)/g,
1155
+ /var\(--bal-color-text-light-blue\)/g,
1156
+ /var\(--bal-color-text-light-blue-light\)/g,
1157
+ /var\(--bal-color-text-info-light\)/g,
1158
+ /var\(--bal-color-text-primary-dark\)/g,
1159
+ /var\(--bal-color-text-danger-light\)/g,
1160
+ /var\(--bal-color-text-danger-dark\)/g,
1161
+ ],
1162
+ to: [
1163
+ 'var(--bal-color-border-primary-pressed)',
1164
+ 'var(--bal-color-border-primary-hovered)',
1165
+ 'var(--bal-color-border-danger-hovered)',
1166
+ 'var(--bal-color-border-danger-pressed)',
1167
+ 'var(--bal-color-primary-1)',
1168
+ 'var(--bal-color-primary-2)',
1169
+ 'var(--bal-color-primary-3)',
1170
+ 'var(--bal-color-primary-4)',
1171
+ 'var(--bal-color-primary-5)',
1172
+ 'var(--bal-color-primary-6)',
1173
+ 'var(--bal-color-primary)',
1174
+ 'transparent',
1175
+ 'var(--bal-color-text-primary-hovered)',
1176
+ 'var(--bal-color-text-inverted-hovered)',
1177
+ 'var(--bal-color-text-inverted-pressed)',
1178
+ 'var(--bal-color-text-primary-pressed)',
1179
+ 'var(--bal-color-text-danger-hovered)',
1180
+ 'var(--bal-color-text-danger-pressed)',
1181
+ ],
1182
+ }
1183
+
1184
+ const replacementsCSSVariablesVarious = {
1185
+ from: [
1186
+ /var\(--bal-border-width-none\)/g,
1187
+ /var\(--bal-container-max-width\)/g,
1188
+ /var\(--bal-weight-bold\)/g,
1189
+ /var\(--bal-weight-regular\)/g,
1190
+ /var\(--bal-weight-light\)/g,
1191
+ /var\(--bal-radius-none\)/g,
1192
+ /var\(--bal-shadow-none\)/g,
1193
+ /var\(--bal-text-shadow-none\)/g,
1194
+ ],
1195
+ to: [
1196
+ '0',
1197
+ 'var(--bal-container-size-normal)',
1198
+ 'var(--bal-font-weight-bold)',
1199
+ 'var(--bal-font-weight-regular)',
1200
+ 'var(--bal-font-weight-light)',
1201
+ '0',
1202
+ 'none',
1203
+ 'none',
1204
+ ],
1205
+ }
1206
+
1207
+ const replacementsCSSVariablesSpace = {
1208
+ from: [
1209
+ /var\(--bal-space-auto\)/g,
1210
+ /var\(--bal-space-tablet-auto\)/g,
1211
+ /var\(--bal-space-desktop-auto\)/g,
1212
+ /var\(--bal-space-none\)/g,
1213
+ /var\(--bal-space-tablet-none\)/g,
1214
+ /var\(--bal-space-desktop-none\)/g,
1215
+ /var\(--bal-space-tablet-xx-small\)/g,
1216
+ /var\(--bal-space-tablet-x-small\)/g,
1217
+ /var\(--bal-space-tablet-small\)/g,
1218
+ /var\(--bal-space-tablet-normal\)/g,
1219
+ /var\(--bal-space-tablet-medium\)/g,
1220
+ /var\(--bal-space-tablet-large\)/g,
1221
+ /var\(--bal-space-tablet-x-large\)/g,
1222
+ /var\(--bal-space-tablet-xx-large\)/g,
1223
+ /var\(--bal-space-tablet-xxx-large\)/g,
1224
+ /var\(--bal-space-tablet-xxxx-large\)/g,
1225
+ /var\(--bal-space-desktop-xx-small\)/g,
1226
+ /var\(--bal-space-desktop-x-small\)/g,
1227
+ /var\(--bal-space-desktop-small\)/g,
1228
+ /var\(--bal-space-desktop-normal\)/g,
1229
+ /var\(--bal-space-desktop-medium\)/g,
1230
+ /var\(--bal-space-desktop-large\)/g,
1231
+ /var\(--bal-space-desktop-x-large\)/g,
1232
+ /var\(--bal-space-desktop-xx-large\)/g,
1233
+ /var\(--bal-space-desktop-xxx-large\)/g,
1234
+ /var\(--bal-space-desktop-xxxx-large\)/g,
1235
+ ],
1236
+ to: [
1237
+ 'auto',
1238
+ 'auto',
1239
+ 'auto',
1240
+ '0',
1241
+ '0',
1242
+ '0',
1243
+ 'var(--bal-space-xx-small-tablet)',
1244
+ 'var(--bal-space-x-small-tablet)',
1245
+ 'var(--bal-space-small-tablet)',
1246
+ 'var(--bal-space-normal-tablet)',
1247
+ 'var(--bal-space-medium-tablet)',
1248
+ 'var(--bal-space-large-tablet)',
1249
+ 'var(--bal-space-x-large-tablet)',
1250
+ 'var(--bal-space-xx-large-tablet)',
1251
+ 'var(--bal-space-xxx-large-tablet)',
1252
+ 'var(--bal-space-xxxx-large-tablet)',
1253
+ 'var(--bal-space-xx-small-desktop)',
1254
+ 'var(--bal-space-x-small-desktop)',
1255
+ 'var(--bal-space-small-desktop)',
1256
+ 'var(--bal-space-normal-desktop)',
1257
+ 'var(--bal-space-medium-desktop)',
1258
+ 'var(--bal-space-large-desktop)',
1259
+ 'var(--bal-space-x-large-desktop)',
1260
+ 'var(--bal-space-xx-large-desktop)',
1261
+ 'var(--bal-space-xxx-large-desktop)',
1262
+ 'var(--bal-space-xxxx-large-desktop)',
1263
+ ],
1264
+ }
1265
+
1266
+ const replacementsCSSVariablesTextSize = {
1267
+ from: [
1268
+ /var\(--bal-size-x-small\)/g,
1269
+ /var\(--bal-size-small\)/g,
1270
+ /var\(--bal-size-normal\)/g,
1271
+ /var\(--bal-size-medium\)/g,
1272
+ /var\(--bal-size-xxxxx-large\)/g,
1273
+ /var\(--bal-size-xxxx-large\)/g,
1274
+ /var\(--bal-size-xxx-large\)/g,
1275
+ /var\(--bal-size-xx-large\)/g,
1276
+ /var\(--bal-size-x-large\)/g,
1277
+ /var\(--bal-size-large\)/g,
1278
+ /var\(--bal-size-tablet-x-small\)/g,
1279
+ /var\(--bal-size-tablet-small\)/g,
1280
+ /var\(--bal-size-tablet-normal\)/g,
1281
+ /var\(--bal-size-tablet-medium\)/g,
1282
+ /var\(--bal-size-tablet-xxxxx-large\)/g,
1283
+ /var\(--bal-size-tablet-xxxx-large\)/g,
1284
+ /var\(--bal-size-tablet-xxx-large\)/g,
1285
+ /var\(--bal-size-tablet-xx-large\)/g,
1286
+ /var\(--bal-size-tablet-x-large\)/g,
1287
+ /var\(--bal-size-tablet-large\)/g,
1288
+ /var\(--bal-size-desktop-x-small\)/g,
1289
+ /var\(--bal-size-desktop-small\)/g,
1290
+ /var\(--bal-size-desktop-normal\)/g,
1291
+ /var\(--bal-size-desktop-medium\)/g,
1292
+ /var\(--bal-size-desktop-xxxxx-large\)/g,
1293
+ /var\(--bal-size-desktop-xxxx-large\)/g,
1294
+ /var\(--bal-size-desktop-xxx-large\)/g,
1295
+ /var\(--bal-size-desktop-xx-large\)/g,
1296
+ /var\(--bal-size-desktop-x-large\)/g,
1297
+ /var\(--bal-size-desktop-large\)/g,
1298
+ ],
1299
+ to: [
1300
+ 'var(--bal-text-size-x-small)',
1301
+ 'var(--bal-text-size-small)',
1302
+ 'var(--bal-text-size-normal)',
1303
+ 'var(--bal-text-size-medium)',
1304
+ 'var(--bal-text-size-xxxxx-large)',
1305
+ 'var(--bal-text-size-xxxx-large)',
1306
+ 'var(--bal-text-size-xxx-large)',
1307
+ 'var(--bal-text-size-xx-large)',
1308
+ 'var(--bal-text-size-x-large)',
1309
+ 'var(--bal-text-size-large)',
1310
+ 'var(--bal-text-size-x-small-tablet)',
1311
+ 'var(--bal-text-size-small-tablet)',
1312
+ 'var(--bal-text-size-normal-tablet)',
1313
+ 'var(--bal-text-size-medium-tablet)',
1314
+ 'var(--bal-text-size-xxxxx-large-tablet)',
1315
+ 'var(--bal-text-size-xxxx-large-tablet)',
1316
+ 'var(--bal-text-size-xxx-large-tablet)',
1317
+ 'var(--bal-text-size-xx-large-tablet)',
1318
+ 'var(--bal-text-size-x-large-tablet)',
1319
+ 'var(--bal-text-size-large-tablet)',
1320
+ 'var(--bal-text-size-x-small-desktop)',
1321
+ 'var(--bal-text-size-small-desktop)',
1322
+ 'var(--bal-text-size-normal-desktop)',
1323
+ 'var(--bal-text-size-medium-desktop)',
1324
+ 'var(--bal-text-size-xxxxx-large-desktop)',
1325
+ 'var(--bal-text-size-xxxx-large-desktop)',
1326
+ 'var(--bal-text-size-xxx-large-desktop)',
1327
+ 'var(--bal-text-size-xx-large-desktop)',
1328
+ 'var(--bal-text-size-x-large-desktop)',
1329
+ 'var(--bal-text-size-large-desktop)',
1330
+ ],
1331
+ }
1332
+
1333
+ main()