Skip to content

Commit

Permalink
build: include codemods in build
Browse files Browse the repository at this point in the history
  • Loading branch information
martimalek committed Aug 25, 2023
1 parent 99e23eb commit 698dae9
Show file tree
Hide file tree
Showing 20 changed files with 19 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ assets/
fixtures/

src/icons/

src/codemods/

This file was deleted.

2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
roots: ['<rootDir>/src', '<rootDir>/codemods'],
roots: ['<rootDir>/src'],
transform: {
'^.+\\.tsx?$': 'ts-jest',
'^.+\\.svg$': '<rootDir>/svgTransform.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { CloseIcon } from '@freenow/wave';

export const CloseIconWrapper = () => (
<CloseIcon data-testid="dismissBanner" color="var(--wave-b-color-white)" cursor="pointer" size={18} />
);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const GhostIcon = () => (
<svg fill="none" viewBox="0 0 16 16" width="100%">
<path d="M1 6v9h1v1h2v-1h1v-1h1v1h1v1h2v-1h1v-1h1v1h1v1h2v-1h1V6h-1V3h-1V2h-1V1h-2V0H6v1H4v1H3v1H2v3H1z" />
<path fill={'var(--wave-b-color-blue-primary-1100)'} d="M5 7h1v3H5zm5 0h1v3h-1z" />
<path fill={'var(--wave-b-color-white)'} d="M5 6h1v1H5zm5 0h1v1h-1z" />
<path fill="var(--wave-b-color-blue-primary-1100)" d="M5 7h1v3H5zm5 0h1v3h-1z" />
<path fill="var(--wave-b-color-white)" d="M5 6h1v1H5zm5 0h1v1h-1z" />
</svg>
);
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// import { defineTest } from 'jscodeshift/dist/testUtils'

jest.autoMockOff();
const { defineTest } = require('jscodeshift/dist/testUtils');

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { API, FileInfo, Identifier, JSCodeshift, MemberExpression, TemplateLiteral } from 'jscodeshift';
import { API, FileInfo, Identifier, JSCodeshift, TemplateLiteral } from 'jscodeshift';
import { Options } from 'recast';

const ColorsToCssVariablesMap = {
Expand Down Expand Up @@ -40,8 +40,8 @@ const replaceColorsForCssVarsInTemplateLiterals = (
localColorNames: string[],
templateLiteral: TemplateLiteral
) => {
const quasis = templateLiteral.quasis;
const expressions = templateLiteral.expressions;
const { quasis } = templateLiteral;
const { expressions } = templateLiteral;

const expressionsToRemoveIndexes: number[] = [];
const quasisToRemoveIndexes: number[] = [];
Expand All @@ -61,15 +61,15 @@ const replaceColorsForCssVarsInTemplateLiterals = (

// Check if the expression is a MemberExpression (regular object property access)
if (expressionAfterQuasis && expressionAfterQuasis.type === 'MemberExpression') {
const expressionObject = (expressionAfterQuasis as MemberExpression).object as Identifier;
const expressionObject = expressionAfterQuasis.object as Identifier;

// Identify if it's a usage of Colors
const isColorsExpression = localColorNames.includes(expressionObject.name);

if (isColorsExpression) {
// Find the color being used
const color = ((expressionAfterQuasis as MemberExpression).property as Identifier).name;
const cssVar = ColorsToCssVariablesMap[color];
const color = (expressionAfterQuasis.property as Identifier).name;
const cssVar: string = ColorsToCssVariablesMap[color];

if (!cssVar) return;

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
]
},
"include": ["src/**/*"],
"exclude": ["src/**/docs", "**/node_modules"]
"exclude": ["src/**/docs", "**/node_modules", "src/codemods/__*"]
}

0 comments on commit 698dae9

Please sign in to comment.