@wise/wds-codemods 0.0.1-experimental-4bee5c0 → 0.0.1-experimental-865b7df

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 (60) hide show
  1. package/dist/{index.cjs → index.js} +2 -2
  2. package/dist/index.js.map +1 -0
  3. package/dist/{reportManualReview-BfeMigw4.cjs → reportManualReview-DQ00-OKx.js} +1 -1
  4. package/dist/reportManualReview-DQ00-OKx.js.map +1 -0
  5. package/dist/transforms/button/{transformer.cjs → transformer.js} +2 -2
  6. package/dist/transforms/button/transformer.js.map +1 -0
  7. package/package.json +6 -1
  8. package/.changeset/better-impalas-drop.md +0 -5
  9. package/.changeset/config.json +0 -13
  10. package/.changeset/quick-mails-joke.md +0 -128
  11. package/.github/CODEOWNERS +0 -1
  12. package/.github/actions/bootstrap/action.yml +0 -49
  13. package/.github/actions/commitlint/action.yml +0 -27
  14. package/.github/actions/test/action.yml +0 -23
  15. package/.github/workflows/cd-cd.yml +0 -150
  16. package/.github/workflows/renovate.yml +0 -16
  17. package/.husky/commit-msg +0 -1
  18. package/.husky/pre-commit +0 -1
  19. package/.nvmrc +0 -1
  20. package/.prettierignore +0 -1
  21. package/.prettierrc.js +0 -5
  22. package/DEVELOPER.md +0 -783
  23. package/babel.config.js +0 -28
  24. package/commitlint.config.js +0 -3
  25. package/dist/index.cjs.map +0 -1
  26. package/dist/reportManualReview-BfeMigw4.cjs.map +0 -1
  27. package/dist/transforms/button/transformer.cjs.map +0 -1
  28. package/eslint.config.js +0 -15
  29. package/jest.config.js +0 -9
  30. package/mkdocs.yml +0 -4
  31. package/renovate.json +0 -9
  32. package/src/__tests__/runCodemod.test.ts +0 -96
  33. package/src/index.ts +0 -4
  34. package/src/runCodemod.ts +0 -88
  35. package/src/transforms/button/__tests__/button.test.tsx +0 -153
  36. package/src/transforms/button/transformer.ts +0 -418
  37. package/src/transforms/helpers/__tests__/createTestTransform.test.ts +0 -27
  38. package/src/transforms/helpers/__tests__/hasImport.test.ts +0 -52
  39. package/src/transforms/helpers/__tests__/iconUtils.test.ts +0 -207
  40. package/src/transforms/helpers/__tests__/jsxElementUtils.test.ts +0 -130
  41. package/src/transforms/helpers/__tests__/jsxReportingUtils.test.ts +0 -265
  42. package/src/transforms/helpers/createTestTransform.ts +0 -18
  43. package/src/transforms/helpers/hasImport.ts +0 -60
  44. package/src/transforms/helpers/iconUtils.ts +0 -87
  45. package/src/transforms/helpers/index.ts +0 -5
  46. package/src/transforms/helpers/jsxElementUtils.ts +0 -67
  47. package/src/transforms/helpers/jsxReportingUtils.ts +0 -224
  48. package/src/utils/__tests__/getOptions.test.ts +0 -170
  49. package/src/utils/__tests__/handleError.test.ts +0 -18
  50. package/src/utils/__tests__/loadTransformModules.test.ts +0 -51
  51. package/src/utils/__tests__/reportManualReview.test.ts +0 -42
  52. package/src/utils/getOptions.ts +0 -63
  53. package/src/utils/handleError.ts +0 -6
  54. package/src/utils/index.ts +0 -4
  55. package/src/utils/loadTransformModules.ts +0 -28
  56. package/src/utils/reportManualReview.ts +0 -17
  57. package/test-button.tsx +0 -230
  58. package/test-file.js +0 -2
  59. package/tsconfig.json +0 -14
  60. package/tsdown.config.js +0 -13
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const require_reportManualReview = require('./reportManualReview-BfeMigw4.cjs');
2
+ const require_reportManualReview = require('./reportManualReview-DQ00-OKx.js');
3
3
  const node_fs_promises = require_reportManualReview.__toESM(require("node:fs/promises"));
4
4
  const node_child_process = require_reportManualReview.__toESM(require("node:child_process"));
5
5
  const node_path = require_reportManualReview.__toESM(require("node:path"));
@@ -142,4 +142,4 @@ async function runCodemod(transformsDir) {
142
142
  runCodemod();
143
143
 
144
144
  //#endregion
145
- //# sourceMappingURL=index.cjs.map
145
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["transformFile","targetPath","dry","print","ignorePattern: string | undefined","gitignore","transformModules: Record<string, unknown>","fs","path","path","fs","error: unknown"],"sources":["../src/utils/getOptions.ts","../src/utils/loadTransformModules.ts","../src/runCodemod.ts","../src/index.ts"],"sourcesContent":["import { confirm, input, select as list } from '@inquirer/prompts';\n\nasync function getOptions(transformFiles: string[]) {\n const args = process.argv.slice(2);\n if (args.length > 0) {\n const [transformFile, targetPath] = args;\n const dry = args.includes('--dry') || args.includes('--dry-run');\n const print = args.includes('--print');\n const ignorePatternIndex = args.findIndex((arg) => arg === '--ignore-pattern');\n let ignorePattern: string | undefined;\n if (ignorePatternIndex !== -1 && args.length > ignorePatternIndex + 1) {\n ignorePattern = args[ignorePatternIndex + 1];\n }\n const gitignore = args.includes('--gitignore');\n const noGitignore = args.includes('--no-gitignore');\n\n if (!transformFile || !transformFiles.includes(transformFile)) {\n throw new Error('Invalid transform file specified.');\n }\n if (!targetPath) {\n throw new Error('Target path cannot be empty.');\n }\n\n // If both --gitignore and --no-gitignore are specified, prioritize --gitignore\n const useGitignore = !!(gitignore || (!gitignore && !noGitignore));\n\n return { transformFile, targetPath, dry, print, ignorePattern, gitignore: useGitignore };\n }\n\n const transformFile = await list({\n message: 'Select a codemod transform to run:',\n choices: transformFiles.map((file) => ({ name: file, value: file })),\n });\n\n const targetPath = await input({\n message: 'Enter the target directory or file path to run codemod on:',\n validate: (value) => value.trim() !== '' || 'Target path cannot be empty',\n });\n\n const dry = await confirm({\n message: 'Run in dry mode (no changes written to files)?',\n default: true,\n });\n\n const print = await confirm({\n message: 'Print transformed source to console?',\n default: false,\n });\n\n const ignorePattern = await input({\n message: 'Enter ignore pattern(s) (comma separated) or leave empty:',\n validate: (value) => true,\n });\n\n const gitignore = await confirm({\n message: 'Respect .gitignore files?',\n default: true,\n });\n\n return { transformFile, targetPath, dry, print, ignorePattern, gitignore };\n}\n\nexport default getOptions;\n","import { promises as fs } from 'fs';\nimport path from 'path';\n\ninterface TransformModule {\n default: {\n default: unknown;\n };\n}\n\nasync function loadTransformModules(transformsDir: string) {\n let transformModules: Record<string, unknown> = {};\n\n const files = await fs.readdir(transformsDir);\n const transformFiles = await Promise.all(\n files\n .filter((file) => file.endsWith('.js'))\n .map(async (file) => {\n const transformPath = path.join(transformsDir, file);\n const transformModule = (await import(transformPath)) as TransformModule;\n transformModules = { ...transformModules, [file]: transformModule.default.default };\n return file.replace('.js', '');\n }),\n );\n\n return { transformModules, transformFiles };\n}\n\nexport default loadTransformModules;\n","#!/usr/bin/env node\n\nimport fs from 'node:fs/promises';\n\nimport { execSync } from 'child_process';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nimport { getOptions, handleError, loadTransformModules } from './utils';\n\nconst currentFilePath = fileURLToPath(import.meta.url);\nconst currentDirPath = path.dirname(currentFilePath);\n\nasync function runCodemod(transformsDir?: string) {\n try {\n const resolvedTransformsDir =\n transformsDir ?? path.resolve(currentDirPath, '../dist/transforms');\n console.debug(`Resolved transforms directory: ${resolvedTransformsDir}`);\n\n const { transformFiles } = await loadTransformModules(resolvedTransformsDir);\n\n if (transformFiles.length === 0) {\n throw new Error(`No transform scripts found in directory: ${resolvedTransformsDir}`);\n }\n\n const resolvedTransformFiles = await Promise.all(transformFiles);\n const options = await getOptions(resolvedTransformFiles);\n\n const codemodPath = path.resolve(resolvedTransformsDir, `${options.transformFile}.js`);\n console.debug(`Resolved codemod path: ${codemodPath}`);\n\n const args = [\n '-t',\n codemodPath,\n options.targetPath,\n options.dry ? '--dry' : '',\n options.print ? '--print' : '',\n options.ignorePattern\n ? options.ignorePattern\n .split(',')\n .map((pattern) => `--ignore-pattern=${pattern.trim()}`)\n .join(' ')\n : '',\n options.gitignore ? '--gitignore' : '',\n ].filter(Boolean);\n\n const command = `npx jscodeshift ${args.join(' ')}`;\n\n console.debug(`Running: ${command}`);\n\n const reportPath = path.resolve(process.cwd(), 'codemod-report.txt');\n\n try {\n await fs.access(reportPath);\n await fs.rm(reportPath);\n console.debug(`Removed existing report file: ${reportPath}`);\n } catch {\n console.debug(`No existing report file to remove: ${reportPath}`);\n }\n\n execSync(command, { stdio: 'inherit' });\n\n try {\n const reportContent = await fs.readFile(reportPath, 'utf8');\n const lines = reportContent.split('\\n').filter(Boolean);\n if (lines.length) {\n console.log(\n `\\n⚠️ ${lines.length} manual review${lines.length > 1 ? 's are' : ' is'} required. See ${reportPath} for details.`,\n );\n } else {\n console.debug(`Report file exists but is empty: ${reportPath}`);\n }\n } catch {\n console.debug(`No report file generated - no manual reviews needed`);\n }\n } catch (error: unknown) {\n if (error instanceof Error) {\n console.error('Error running codemod:', error.message);\n } else {\n console.error('Error running codemod:', error);\n }\n if (process.env.NODE_ENV !== 'test') {\n process.exit(1);\n }\n }\n}\n\nexport { runCodemod };\n","#!/usr/bin/env node\nimport { runCodemod } from './runCodemod';\n\nvoid runCodemod();\n"],"mappings":";;;;;;;;;;AAEA,eAAe,WAAW,gBAA0B;CAClD,MAAM,OAAO,QAAQ,KAAK,MAAM;AAChC,KAAI,KAAK,SAAS,GAAG;EACnB,MAAM,CAACA,iBAAeC,aAAW,GAAG;EACpC,MAAMC,QAAM,KAAK,SAAS,YAAY,KAAK,SAAS;EACpD,MAAMC,UAAQ,KAAK,SAAS;EAC5B,MAAM,qBAAqB,KAAK,WAAW,QAAQ,QAAQ;EAC3D,IAAIC;AACJ,MAAI,uBAAuB,MAAM,KAAK,SAAS,qBAAqB,EAClE,mBAAgB,KAAK,qBAAqB;EAE5C,MAAMC,cAAY,KAAK,SAAS;EAChC,MAAM,cAAc,KAAK,SAAS;AAElC,MAAI,CAACL,mBAAiB,CAAC,eAAe,SAASA,iBAC7C,OAAM,IAAI,MAAM;AAElB,MAAI,CAACC,aACH,OAAM,IAAI,MAAM;EAIlB,MAAM,eAAe,CAAC,EAAEI,eAAc,CAACA,eAAa,CAAC;AAErD,SAAO;GAAE;GAAe;GAAY;GAAK;GAAO;GAAe,WAAW;GAAc;CACzF;CAED,MAAM,gBAAgB,qCAAW;EAC/B,SAAS;EACT,SAAS,eAAe,KAAK,UAAU;GAAE,MAAM;GAAM,OAAO;GA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O;GACX;GACA;GACA,QAAQ;GACR,QAAQ,MAAM,UAAU;GACxB,QAAQ,QAAQ,YAAY;GAC5B,QAAQ,gBACJ,QAAQ,cACL,MAAM,KACN,KAAK,YAAY,oBAAoB,QAAQ,UAC7C,KAAK,OACR;GACJ,QAAQ,YAAY,gBAAgB;GACrC,CAAC,OAAO;EAET,MAAM,UAAU,mBAAmB,KAAK,KAAK;AAE7C,UAAQ,MAAM,YAAY;EAE1B,MAAM,aAAaA,kBAAK,QAAQ,QAAQ,OAAO;AAE/C,MAAI;AACF,SAAMC,yBAAG,OAAO;AAChB,SAAMA,yBAAG,GAAG;AACZ,WAAQ,MAAM,iCAAiC;EAChD,QAAO;AACN,WAAQ,MAAM,sCAAsC;EACrD;AAED,mCAAS,SAAS,EAAE,OAAO,WAAW;AAEtC,MAAI;GACF,MAAM,gBAAgB,MAAMA,yBAAG,SAAS,YAAY;GACpD,MAAM,QAAQ,cAAc,MAAM,MAAM,OAAO;AAC/C,OAAI,MAAM,OACR,SAAQ,IACN,SAAS,MAAM,OAAO,gBAAgB,MAAM,SAAS,IAAI,UAAU,MAAM,iBAAiB,WAAW;OAGvG,SAAQ,MAAM,oCAAoC;EAErD,QAAO;AACN,WAAQ,MAAM;EACf;CACF,SAAQC,OAAgB;AACvB,MAAI,iBAAiB,MACnB,SAAQ,MAAM,0BAA0B,MAAM;MAE9C,SAAQ,MAAM,0BAA0B;AAE1C,MAAI,QAAQ,IAAI,aAAa,OAC3B,SAAQ,KAAK;CAEhB;AACF;;;;AClFI"}
@@ -47,4 +47,4 @@ Object.defineProperty(exports, 'reportManualReview', {
47
47
  return reportManualReview;
48
48
  }
49
49
  });
50
- //# sourceMappingURL=reportManualReview-BfeMigw4.cjs.map
50
+ //# sourceMappingURL=reportManualReview-DQ00-OKx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reportManualReview-DQ00-OKx.js","names":["path","fs"],"sources":["../src/utils/reportManualReview.ts"],"sourcesContent":["import fs from 'node:fs/promises';\n\nimport path from 'path';\n\nconst REPORT_PATH = path.resolve(process.cwd(), 'codemod-report.txt');\n\nconst reportManualReview = async (filePath: string, message: string): Promise<void> => {\n const lineMatch = /at line (\\d+)/u.exec(message);\n const lineNumber = lineMatch?.[1];\n\n const cleanMessage = message.replace(/ at line \\d+/u, '');\n const lineInfo = lineNumber ? `:${lineNumber}` : '';\n\n await fs.appendFile(REPORT_PATH, `[${filePath}${lineInfo}] ${cleanMessage}\\n`, 'utf8');\n};\n\nexport default reportManualReview;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,cAAcA,kBAAK,QAAQ,QAAQ,OAAO;AAEhD,MAAM,qBAAqB,OAAO,UAAkB,YAAmC;CACrF,MAAM,YAAY,iBAAiB,KAAK;CACxC,MAAM,aAAa,YAAY;CAE/B,MAAM,eAAe,QAAQ,QAAQ,iBAAiB;CACtD,MAAM,WAAW,aAAa,IAAI,eAAe;AAEjD,OAAMC,yBAAG,WAAW,aAAa,IAAI,WAAW,SAAS,IAAI,aAAa,KAAK;AAChF"}
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- const require_reportManualReview = require('../../reportManualReview-BfeMigw4.cjs');
2
+ const require_reportManualReview = require('../../reportManualReview-DQ00-OKx.js');
3
3
 
4
4
  //#region src/transforms/helpers/hasImport.ts
5
5
  /**
@@ -513,4 +513,4 @@ const transformer = (file, api, options) => {
513
513
  //#endregion
514
514
  exports.default = transformer;
515
515
  exports.parser = parser;
516
- //# sourceMappingURL=transformer.cjs.map
516
+ //# sourceMappingURL=transformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformer.js","names":["priorityMapping: Record<string, Record<string, string>>","sizeMap: Record<string, string>","enumMapping: Record<string, string>","j: JSCodeshift","manualReviewIssues: string[]","legacyProps: LegacyProps","asValue: string | null","reportManualReview"],"sources":["../../../src/transforms/helpers/hasImport.ts","../../../src/transforms/helpers/iconUtils.ts","../../../src/transforms/helpers/jsxElementUtils.ts","../../../src/transforms/helpers/jsxReportingUtils.ts","../../../src/transforms/button/transformer.ts"],"sourcesContent":["import type { Collection, JSCodeshift } from 'jscodeshift';\n\n/**\n * Checks if a specific import exists in the given root collection and provides\n * a method to remove it if found.\n */\nfunction hasImport(\n root: Collection,\n sourceValue: string,\n importName: string,\n j: JSCodeshift,\n): { exists: boolean; remove: () => void } {\n const importDeclarations = root.find(j.ImportDeclaration, {\n source: { value: sourceValue },\n });\n\n if (importDeclarations.size() === 0) {\n return {\n exists: false,\n remove: () => {},\n };\n }\n\n const namedImport = importDeclarations.find(j.ImportSpecifier, {\n imported: { name: importName },\n });\n\n const defaultImport = importDeclarations.find(j.ImportDefaultSpecifier, {\n local: { name: importName },\n });\n\n const exists = namedImport.size() > 0 || defaultImport.size() > 0;\n\n const remove = () => {\n importDeclarations.forEach((path) => {\n const filteredSpecifiers =\n path.node.specifiers?.filter((specifier) => {\n if (specifier.type === 'ImportSpecifier' && specifier.imported.name === importName) {\n return false;\n }\n if (specifier.type === 'ImportDefaultSpecifier' && specifier.local?.name === importName) {\n return false;\n }\n return true;\n }) ?? [];\n\n if (filteredSpecifiers.length === 0) {\n path.prune();\n } else {\n j(path).replaceWith(\n j.importDeclaration(filteredSpecifiers, path.node.source, path.node.importKind),\n );\n }\n });\n };\n\n return { exists, remove };\n}\n\nexport default hasImport;\n","import type { JSCodeshift, JSXElement, JSXExpressionContainer } from 'jscodeshift';\n\n/**\n * Process children of a JSX element to detect icon components and add iconStart or iconEnd attributes accordingly.\n * This is specific to icon handling but can be reused in codemods dealing with icon children.\n */\nconst processIconChildren = (\n j: JSCodeshift,\n children: (JSXElement | JSXExpressionContainer | unknown)[] | undefined,\n iconImports: Set<string>,\n openingElement: JSXElement['openingElement'],\n) => {\n if (!children || !openingElement.attributes) return;\n\n const unwrapJsxElement = (node: unknown): JSXElement | unknown => {\n if (\n typeof node === 'object' &&\n node !== null &&\n 'type' in node &&\n node.type === 'JSXExpressionContainer' &&\n j.JSXElement.check((node as JSXExpressionContainer).expression)\n ) {\n return (node as JSXExpressionContainer).expression;\n }\n return node;\n };\n\n const totalChildren = children.length;\n\n // Find index of icon child\n const iconChildIndex = children.findIndex((child) => {\n const unwrapped = unwrapJsxElement(child);\n return (\n j.JSXElement.check(unwrapped) &&\n unwrapped.openingElement.name.type === 'JSXIdentifier' &&\n iconImports.has(unwrapped.openingElement.name.name)\n );\n });\n\n if (iconChildIndex === -1) return;\n\n const iconChild = unwrapJsxElement(children[iconChildIndex]) as JSXElement;\n\n if (!iconChild || iconChild.openingElement.name.type !== 'JSXIdentifier') return;\n\n const iconName = iconChild.openingElement.name.name;\n\n // Determine if icon is closer to start or end\n const distanceToStart = iconChildIndex;\n const distanceToEnd = totalChildren - 1 - iconChildIndex;\n const iconPropName = distanceToStart <= distanceToEnd ? 'addonStart' : 'addonEnd';\n\n // Build: { type: 'icon', value: <IconName /> }\n const iconObject = j.objectExpression([\n j.property('init', j.identifier('type'), j.literal('icon')),\n j.property('init', j.identifier('value'), iconChild),\n ]);\n const iconProp = j.jsxAttribute(\n j.jsxIdentifier(iconPropName),\n j.jsxExpressionContainer(iconObject),\n );\n\n openingElement.attributes.push(iconProp);\n\n // Remove the icon child\n children.splice(iconChildIndex, 1);\n\n // Helper to check if a child is whitespace-only JSXText\n const isWhitespaceJsxText = (node: unknown): boolean => {\n return (\n typeof node === 'object' &&\n node !== null &&\n (node as { type?: unknown }).type === 'JSXText' &&\n typeof (node as { value?: string }).value === 'string' &&\n (node as { value?: string }).value!.trim() === ''\n );\n };\n\n // Remove adjacent whitespace-only JSXText node if any\n if (iconChildIndex - 1 >= 0 && isWhitespaceJsxText(children[iconChildIndex - 1])) {\n children.splice(iconChildIndex - 1, 1);\n } else if (isWhitespaceJsxText(children[iconChildIndex])) {\n children.splice(iconChildIndex, 1);\n }\n};\n\nexport default processIconChildren;\n","import type {\n JSCodeshift,\n JSXAttribute,\n JSXElement,\n JSXIdentifier,\n JSXMemberExpression,\n JSXNamespacedName,\n JSXSpreadAttribute,\n} from 'jscodeshift';\n\n/**\n * Rename a JSX element name if it is a JSXIdentifier.\n */\nexport const setNameIfJSXIdentifier = (\n elementName: JSXIdentifier | JSXNamespacedName | JSXMemberExpression | undefined,\n newName: string,\n): JSXIdentifier | JSXNamespacedName | JSXMemberExpression | undefined => {\n if (elementName && elementName.type === 'JSXIdentifier') {\n return { ...elementName, name: newName };\n }\n return elementName;\n};\n\n/**\n * Check if a list of attributes contains a specific attribute by name.\n */\nexport const hasAttribute = (\n attributes: (JSXAttribute | JSXSpreadAttribute)[] | undefined,\n attributeName: string,\n): boolean => {\n return (\n Array.isArray(attributes) &&\n attributes.some(\n (attr): attr is JSXAttribute =>\n attr.type === 'JSXAttribute' &&\n attr.name.type === 'JSXIdentifier' &&\n attr.name.name === attributeName,\n )\n );\n};\n\n/**\n * Check if a JSX element's openingElement has a specific attribute.\n */\nexport const hasAttributeOnElement = (\n element: JSXElement['openingElement'],\n attributeName: string,\n): boolean => {\n return hasAttribute(element.attributes, attributeName);\n};\n\n/**\n * Add specified attributes to a JSX element's openingElement if they are not already present.\n */\nexport const addAttributesIfMissing = (\n j: JSCodeshift,\n openingElement: JSXElement['openingElement'],\n attributesToAdd: { attribute: JSXAttribute; name: string }[],\n) => {\n if (!Array.isArray(openingElement.attributes)) return;\n const attrs = openingElement.attributes;\n attributesToAdd.forEach(({ attribute, name }) => {\n if (!hasAttributeOnElement(openingElement, name)) {\n attrs.push(attribute);\n }\n });\n};\n","import type { ASTPath, JSCodeshift, JSXAttribute, JSXElement, Node } from 'jscodeshift';\n\nexport interface ReporterOptions {\n jscodeshift: JSCodeshift;\n issues: string[];\n}\n\n/**\n * CodemodReporter is a utility class for reporting issues found during codemod transformations.\n * It provides methods to report issues related to JSX elements, props, and attributes.\n *\n * @example\n * ```typescript\n * const issues: string[] = [];\n * const reporter = createReporter(j, issues);\n *\n * // Report a deprecated prop\n * reporter.reportDeprecatedProp(buttonElement, 'flat', 'variant=\"text\"');\n *\n * // Report complex expression that needs review\n * reporter.reportAmbiguousExpression(element, 'size');\n *\n * // Auto-detect common issues\n * reporter.reportAttributeIssues(element);\n * ```\n */\nexport class CodemodReporter {\n private readonly j: JSCodeshift;\n private readonly issues: string[];\n\n constructor(options: ReporterOptions) {\n this.j = options.jscodeshift;\n this.issues = options.issues;\n }\n\n /**\n * Reports an issue with a JSX element\n */\n reportElement(element: JSXElement | ASTPath<JSXElement>, reason: string): void {\n const node = this.getNode(element);\n const componentName = this.getComponentName(node);\n const line = this.getLineNumber(node);\n\n this.addIssue(`Manual review required: <${componentName}> at line ${line} ${reason}.`);\n }\n\n /**\n * Reports an issue with a specific prop\n */\n reportProp(element: JSXElement | ASTPath<JSXElement>, propName: string, reason: string): void {\n const node = this.getNode(element);\n const componentName = this.getComponentName(node);\n const line = this.getLineNumber(node);\n\n this.addIssue(\n `Manual review required: prop \"${propName}\" on <${componentName}> at line ${line} ${reason}.`,\n );\n }\n\n /**\n * Reports an issue with a JSX attribute directly\n */\n reportAttribute(\n attr: JSXAttribute,\n element: JSXElement | ASTPath<JSXElement>,\n reason?: string,\n ): void {\n const node = this.getNode(element);\n const componentName = this.getComponentName(node);\n const propName = this.getAttributeName(attr);\n const line = this.getLineNumber(attr) || this.getLineNumber(node);\n\n const defaultReason = this.getAttributeReason(attr);\n const finalReason = reason || defaultReason;\n\n this.addIssue(\n `Manual review required: prop \"${propName}\" on <${componentName}> at line ${line} ${finalReason}.`,\n );\n }\n\n /**\n * Reports spread props on an element\n */\n reportSpreadProps(element: JSXElement | ASTPath<JSXElement>): void {\n this.reportElement(element, 'contains spread props that need manual review');\n }\n\n /**\n * Reports conflicting prop and children\n */\n reportPropWithChildren(element: JSXElement | ASTPath<JSXElement>, propName: string): void {\n this.reportProp(\n element,\n propName,\n `conflicts with children - both \"${propName}\" prop and children are present`,\n );\n }\n\n /**\n * Reports unsupported prop value\n */\n reportUnsupportedValue(\n element: JSXElement | ASTPath<JSXElement>,\n propName: string,\n value: string,\n ): void {\n this.reportProp(element, propName, `has unsupported value \"${value}\"`);\n }\n\n /**\n * Reports ambiguous expression in prop\n */\n reportAmbiguousExpression(element: JSXElement | ASTPath<JSXElement>, propName: string): void {\n this.reportProp(element, propName, 'contains a complex expression that needs manual review');\n }\n\n /**\n * Reports ambiguous children (like dynamic icons)\n */\n reportAmbiguousChildren(element: JSXElement | ASTPath<JSXElement>, childType = 'content'): void {\n this.reportElement(element, `contains ambiguous ${childType} that needs manual review`);\n }\n\n /**\n * Reports deprecated prop usage\n */\n reportDeprecatedProp(\n element: JSXElement | ASTPath<JSXElement>,\n propName: string,\n alternative?: string,\n ): void {\n const suggestion = alternative ? ` Use ${alternative} instead` : '';\n this.reportProp(element, propName, `is deprecated${suggestion}`);\n }\n\n /**\n * Reports missing required prop\n */\n reportMissingRequiredProp(element: JSXElement | ASTPath<JSXElement>, propName: string): void {\n this.reportProp(element, propName, 'is required but missing');\n }\n\n /**\n * Reports conflicting props\n */\n reportConflictingProps(element: JSXElement | ASTPath<JSXElement>, propNames: string[]): void {\n const propList = propNames.map((name) => `\"${name}\"`).join(', ');\n this.reportElement(element, `has conflicting props: ${propList} cannot be used together`);\n }\n\n /**\n * Auto-detects and reports common attribute issues\n */\n reportAttributeIssues(element: JSXElement | ASTPath<JSXElement>): void {\n const node = this.getNode(element);\n const { attributes } = node.openingElement;\n\n if (!attributes) return;\n\n // Check for spread props\n if (attributes.some((attr) => attr.type === 'JSXSpreadAttribute')) {\n this.reportSpreadProps(element);\n }\n\n // Check for complex expressions in attributes\n attributes.forEach((attr) => {\n if (attr.type === 'JSXAttribute' && attr.value?.type === 'JSXExpressionContainer') {\n this.reportAttribute(attr, element);\n }\n });\n }\n\n // Private helper methods\n private getNode(element: JSXElement | ASTPath<JSXElement>): JSXElement {\n return 'node' in element ? element.node : element;\n }\n\n private getComponentName(node: JSXElement): string {\n const { name } = node.openingElement;\n if (name.type === 'JSXIdentifier') {\n return name.name;\n }\n // Handle JSXMemberExpression, JSXNamespacedName, etc.\n return this.j(name).toSource();\n }\n\n private getLineNumber(node: JSXElement | JSXAttribute | Node): string {\n return node.loc?.start.line?.toString() || 'unknown';\n }\n\n private getAttributeName(attr: JSXAttribute): string {\n if (attr.name.type === 'JSXIdentifier') {\n return attr.name.name;\n }\n return this.j(attr.name).toSource();\n }\n\n private getAttributeReason(attr: JSXAttribute): string {\n if (!attr.value) return 'has no value';\n\n if (attr.value.type === 'JSXExpressionContainer') {\n const expr = attr.value.expression;\n const expressionType = expr.type.replace('Expression', '').toLowerCase();\n\n // Show actual value for simple cases\n if (expr.type === 'Identifier' || expr.type === 'MemberExpression') {\n const valueText = this.j(expr).toSource();\n return `contains a ${expressionType} (${valueText})`;\n }\n\n return `contains a complex ${expressionType} expression`;\n }\n\n return 'needs manual review';\n }\n\n private addIssue(message: string): void {\n this.issues.push(message);\n }\n}\n\nexport const createReporter = (j: JSCodeshift, issues: string[]): CodemodReporter => {\n return new CodemodReporter({ jscodeshift: j, issues });\n};\n","import type { API, FileInfo, JSCodeshift, JSXIdentifier, Options } from 'jscodeshift';\n\nimport reportManualReview from '../../utils/reportManualReview';\nimport hasImport from '../helpers/hasImport';\nimport processIconChildren from '../helpers/iconUtils';\nimport {\n addAttributesIfMissing,\n hasAttributeOnElement,\n setNameIfJSXIdentifier,\n} from '../helpers/jsxElementUtils';\nimport { createReporter } from '../helpers/jsxReportingUtils';\n\nexport const parser = 'tsx';\n\ninterface LegacyProps {\n priority?: string;\n size?: string;\n type?: string;\n htmlType?: string;\n sentiment?: string;\n [key: string]: unknown;\n}\n\nconst priorityMapping: Record<string, Record<string, string>> = {\n accent: {\n primary: 'primary',\n secondary: 'secondary-neutral',\n tertiary: 'tertiary',\n },\n positive: {\n primary: 'primary',\n secondary: 'secondary-neutral',\n tertiary: 'secondary-neutral',\n },\n negative: {\n primary: 'primary',\n secondary: 'secondary',\n tertiary: 'secondary',\n },\n};\n\nconst sizeMap: Record<string, string> = {\n EXTRA_SMALL: 'xs',\n SMALL: 'sm',\n MEDIUM: 'md',\n LARGE: 'lg',\n EXTRA_LARGE: 'xl',\n xs: 'sm',\n sm: 'sm',\n md: 'md',\n lg: 'lg',\n xl: 'xl',\n};\n\nconst resolveSize = (size?: string): string | undefined => {\n if (!size) return size;\n const match = /^Size\\.(EXTRA_SMALL|SMALL|MEDIUM|LARGE|EXTRA_LARGE)$/u.exec(size);\n if (match) {\n return sizeMap[match[1]];\n }\n return sizeMap[size] || size;\n};\n\nconst resolvePriority = (type?: string, priority?: string): string | undefined => {\n if (type && priority) {\n return priorityMapping[type]?.[priority] || priority;\n }\n return priority;\n};\n\nconst resolveType = (type?: string, htmlType?: string): string | null => {\n if (htmlType) {\n return htmlType;\n }\n\n const legacyButtonTypes = [\n 'accent',\n 'negative',\n 'positive',\n 'primary',\n 'pay',\n 'secondary',\n 'danger',\n 'link',\n ];\n return type && legacyButtonTypes.includes(type) ? type : null;\n};\n\nconst convertEnumValue = (value?: string): string | undefined => {\n if (!value) return value;\n const strippedValue = value.replace(/^['\"]|['\"]$/gu, '');\n const enumMapping: Record<string, string> = {\n 'Priority.SECONDARY': 'secondary',\n 'Priority.PRIMARY': 'primary',\n 'Priority.TERTIARY': 'tertiary',\n 'ControlType.NEGATIVE': 'negative',\n 'ControlType.POSITIVE': 'positive',\n 'ControlType.ACCENT': 'accent',\n };\n return enumMapping[strippedValue] || strippedValue;\n};\n\n/**\n * This transform function modifies the Button and ActionButton components from the @transferwise/components library.\n * It updates the ActionButton component to use the Button component with specific attributes and mappings.\n * It also processes icon children and removes legacy props.\n *\n * @param {FileInfo} file - The file information object.\n * @param {API} api - The API object for jscodeshift.\n * @param {Options} options - The options object for jscodeshift.\n * @returns {string} - The transformed source code.\n */\nconst transformer = (file: FileInfo, api: API, options: Options) => {\n const j: JSCodeshift = api.jscodeshift;\n const root = j(file.source);\n const manualReviewIssues: string[] = [];\n\n // Create reporter instance\n const reporter = createReporter(j, manualReviewIssues);\n\n const { exists: hasButtonImport } = hasImport(root, '@transferwise/components', 'Button', j);\n const { exists: hasActionButtonImport, remove: removeActionButtonImport } = hasImport(\n root,\n '@transferwise/components',\n 'ActionButton',\n j,\n );\n\n const iconImports = new Set<string>();\n root.find(j.ImportDeclaration, { source: { value: '@transferwise/icons' } }).forEach((path) => {\n path.node.specifiers?.forEach((specifier) => {\n if (\n (specifier.type === 'ImportDefaultSpecifier' || specifier.type === 'ImportSpecifier') &&\n specifier.local\n ) {\n const localName = (specifier.local as { name: string }).name;\n iconImports.add(localName);\n }\n });\n });\n\n if (hasActionButtonImport) {\n root.findJSXElements('ActionButton').forEach((path) => {\n const { openingElement, closingElement } = path.node;\n\n openingElement.name = setNameIfJSXIdentifier(openingElement.name, 'Button')!;\n if (closingElement) {\n closingElement.name = setNameIfJSXIdentifier(closingElement.name, 'Button')!;\n }\n\n addAttributesIfMissing(j, openingElement, [\n { attribute: j.jsxAttribute(j.jsxIdentifier('v2')), name: 'v2' },\n { attribute: j.jsxAttribute(j.jsxIdentifier('size'), j.literal('sm')), name: 'size' },\n ]);\n\n processIconChildren(j, path.node.children, iconImports, openingElement);\n\n if ((openingElement.attributes ?? []).some((attr) => attr.type === 'JSXSpreadAttribute')) {\n reporter.reportSpreadProps(path);\n }\n\n const legacyPropNames = ['priority', 'text'];\n const legacyProps: LegacyProps = {};\n\n openingElement.attributes?.forEach((attr) => {\n if (attr.type === 'JSXAttribute' && attr.name && attr.name.type === 'JSXIdentifier') {\n const { name } = attr.name;\n if (legacyPropNames.includes(name)) {\n if (attr.value) {\n if (attr.value.type === 'StringLiteral') {\n legacyProps[name] = attr.value.value;\n } else if (attr.value.type === 'JSXExpressionContainer') {\n reporter.reportAttribute(attr, path);\n }\n }\n }\n }\n });\n\n const hasTextProp = openingElement.attributes?.some(\n (attr) =>\n attr.type === 'JSXAttribute' &&\n attr.name.type === 'JSXIdentifier' &&\n attr.name.name === 'text',\n );\n const hasChildren = path.node.children?.some(\n (child) =>\n (child.type === 'JSXText' && child.value.trim() !== '') ||\n child.type === 'JSXElement' ||\n child.type === 'JSXExpressionContainer',\n );\n\n if (hasTextProp && hasChildren) {\n reporter.reportPropWithChildren(path, 'text');\n }\n\n (path.node.children || []).forEach((child) => {\n if (child.type === 'JSXExpressionContainer') {\n const expr = child.expression;\n if (\n expr.type === 'ConditionalExpression' ||\n expr.type === 'CallExpression' ||\n expr.type === 'Identifier' ||\n expr.type === 'MemberExpression'\n ) {\n reporter.reportAmbiguousChildren(path, 'icon');\n }\n }\n });\n });\n\n removeActionButtonImport();\n }\n\n if (hasButtonImport) {\n root.findJSXElements('Button').forEach((path) => {\n const { openingElement } = path.node;\n\n if (hasAttributeOnElement(openingElement, 'v2')) return;\n\n addAttributesIfMissing(j, openingElement, [\n { attribute: j.jsxAttribute(j.jsxIdentifier('v2')), name: 'v2' },\n ]);\n processIconChildren(j, path.node.children, iconImports, openingElement);\n\n const legacyProps: LegacyProps = {};\n const legacyPropNames = ['priority', 'size', 'type', 'htmlType', 'sentiment'];\n\n openingElement.attributes?.forEach((attr) => {\n if (attr.type === 'JSXAttribute' && attr.name && attr.name.type === 'JSXIdentifier') {\n const { name } = attr.name;\n if (legacyPropNames.includes(name)) {\n if (attr.value) {\n if (attr.value.type === 'StringLiteral') {\n legacyProps[name] = attr.value.value;\n } else if (attr.value.type === 'JSXExpressionContainer') {\n legacyProps[name] = convertEnumValue(String(j(attr.value.expression).toSource()));\n }\n } else {\n legacyProps[name] = undefined;\n }\n }\n }\n });\n\n if (openingElement.attributes) {\n openingElement.attributes = openingElement.attributes.filter(\n (attr) =>\n !(\n attr.type === 'JSXAttribute' &&\n attr.name &&\n legacyPropNames.includes((attr.name as JSXIdentifier).name)\n ),\n );\n }\n\n if ('size' in legacyProps) {\n const rawValue = legacyProps.size;\n const resolved = resolveSize(rawValue);\n const supportedSizes = ['xs', 'sm', 'md', 'lg', 'xl'];\n\n if (\n typeof rawValue === 'string' &&\n typeof resolved === 'string' &&\n supportedSizes.includes(resolved)\n ) {\n openingElement.attributes?.push(\n j.jsxAttribute(j.jsxIdentifier('size'), j.literal(resolved)),\n );\n } else if (typeof rawValue === 'string') {\n reporter.reportUnsupportedValue(path, 'size', rawValue);\n } else if (rawValue !== undefined) {\n reporter.reportAmbiguousExpression(path, 'size');\n }\n }\n\n if ('priority' in legacyProps) {\n const rawValue = legacyProps.priority;\n const converted = convertEnumValue(rawValue);\n const mapped = resolvePriority(legacyProps.type, converted);\n const supportedPriorities = ['primary', 'secondary', 'tertiary', 'secondary-neutral'];\n\n if (\n typeof rawValue === 'string' &&\n typeof mapped === 'string' &&\n supportedPriorities.includes(mapped)\n ) {\n openingElement.attributes?.push(\n j.jsxAttribute(j.jsxIdentifier('priority'), j.literal(mapped)),\n );\n } else if (typeof rawValue === 'string') {\n reporter.reportUnsupportedValue(path, 'priority', rawValue);\n } else if (rawValue !== undefined) {\n reporter.reportAmbiguousExpression(path, 'priority');\n }\n }\n\n if ('type' in legacyProps || 'htmlType' in legacyProps) {\n const rawType = legacyProps.type;\n const rawHtmlType = legacyProps.htmlType;\n\n const resolvedType =\n typeof rawType === 'string'\n ? rawType\n : rawType && typeof rawType === 'object'\n ? convertEnumValue(j(rawType).toSource())\n : undefined;\n\n const resolved = resolveType(resolvedType, rawHtmlType);\n\n const supportedTypes = [\n 'accent',\n 'negative',\n 'positive',\n 'primary',\n 'pay',\n 'secondary',\n 'danger',\n 'link',\n 'submit',\n 'button',\n 'reset',\n ];\n\n if (typeof resolved === 'string' && supportedTypes.includes(resolved)) {\n openingElement.attributes?.push(\n j.jsxAttribute(j.jsxIdentifier('type'), j.literal(resolved)),\n );\n\n if (resolved === 'negative') {\n openingElement.attributes?.push(\n j.jsxAttribute(j.jsxIdentifier('sentiment'), j.literal('negative')),\n );\n }\n } else if (typeof rawType === 'string' || typeof rawHtmlType === 'string') {\n reporter.reportUnsupportedValue(path, 'type', rawType ?? rawHtmlType ?? '');\n } else if (rawType !== undefined || rawHtmlType !== undefined) {\n reporter.reportAmbiguousExpression(path, 'type');\n }\n }\n\n if ('sentiment' in legacyProps) {\n const rawValue = legacyProps.sentiment;\n if (rawValue === 'negative') {\n openingElement.attributes?.push(\n j.jsxAttribute(j.jsxIdentifier('sentiment'), j.literal('negative')),\n );\n } else if (typeof rawValue === 'string') {\n reporter.reportUnsupportedValue(path, 'sentiment', rawValue);\n } else if (rawValue !== undefined) {\n reporter.reportAmbiguousExpression(path, 'sentiment');\n }\n }\n\n let asIndex = -1;\n let asValue: string | null = null;\n let hrefExists = false;\n let asAmbiguous = false;\n let hrefAmbiguous = false;\n\n openingElement.attributes?.forEach((attr, index) => {\n if (attr.type === 'JSXAttribute' && attr.name) {\n if (attr.name.name === 'as') {\n if (attr.value) {\n if (attr.value.type === 'StringLiteral') {\n asValue = attr.value.value;\n } else if (attr.value.type === 'JSXExpressionContainer') {\n asAmbiguous = true;\n reporter.reportAttribute(attr, path);\n }\n }\n asIndex = index;\n }\n\n if (attr.name.name === 'href') {\n hrefExists = true;\n if (attr.value && attr.value.type !== 'StringLiteral') {\n hrefAmbiguous = true;\n reporter.reportAttribute(attr, path);\n }\n }\n }\n });\n\n if (asValue && asValue !== 'a') {\n reporter.reportUnsupportedValue(path, 'as', asValue);\n }\n\n if (asValue === 'a') {\n if (asIndex !== -1) {\n openingElement.attributes = openingElement.attributes?.filter(\n (_, idx) => idx !== asIndex,\n );\n }\n if (!hrefExists) {\n openingElement.attributes = [\n ...(openingElement.attributes ?? []),\n j.jsxAttribute(j.jsxIdentifier('href'), j.literal('#')),\n ];\n }\n }\n\n if ((openingElement.attributes ?? []).some((attr) => attr.type === 'JSXSpreadAttribute')) {\n reporter.reportSpreadProps(path);\n }\n });\n }\n\n if (manualReviewIssues.length > 0) {\n manualReviewIssues.forEach(async (issue) => {\n await reportManualReview(file.path, issue);\n });\n }\n\n return root.toSource();\n};\n\nexport default transformer;\n"],"mappings":";;;;;;;;AAMA,SAAS,UACP,MACA,aACA,YACA,GACyC;CACzC,MAAM,qBAAqB,KAAK,KAAK,EAAE,mBAAmB,EACxD,QAAQ,EAAE,OAA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AM,SAAS,yBAE7B,UAAS,gBAAgB,MAAM;KAChC;AAEH,eAAU;IACX;AAED,QAAI,KAAK,KAAK,SAAS,QAAQ;AAC7B,kBAAa;AACb,SAAI,KAAK,SAAS,KAAK,MAAM,SAAS,gBAEpC,UAAS,gBAAgB,MAAM;IAElC;GACF;EACF;AAED,MAAI,WAAW,YAAY,IACzB,UAAS,uBAAuB,MAAM,MAAM;AAG9C,MAAI,YAAY,KAAK;AACnB,OAAI,YAAY,GACd,gBAAe,aAAa,eAAe,YAAY,QACpD,GAAG,QAAQ,QAAQ;AAGxB,OAAI,CAAC,WACH,gBAAe,aAAa,CAC1B,GAAI,eAAe,cAAc,EAAE,EACnC,EAAE,aAAa,EAAE,cAAc,SAAS,EAAE,QAAQ,MACnD;EAEJ;AAED,OAAK,eAAe,cAAc,EAAE,EAAE,MAAM,SAAS,KAAK,SAAS,sBACjE,UAAS,kBAAkB;CAE9B;AAGH,KAAI,mBAAmB,SAAS,EAC9B,oBAAmB,QAAQ,OAAO,UAAU;AAC1C,QAAMC,8CAAmB,KAAK,MAAM;CACrC;AAGH,QAAO,KAAK;AACb"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/wds-codemods",
3
- "version": "0.0.1-experimental-4bee5c0",
3
+ "version": "0.0.1-experimental-865b7df",
4
4
  "license": "UNLICENSED",
5
5
  "author": "Wise Payments Ltd.",
6
6
  "type": "module",
@@ -14,6 +14,11 @@
14
14
  "bin": {
15
15
  "wds-codemods": "dist/index.cjs"
16
16
  },
17
+ "files": [
18
+ "dist/",
19
+ "README.md",
20
+ "package.json"
21
+ ],
17
22
  "scripts": {
18
23
  "build": "tsdown",
19
24
  "changeset": "changeset",
@@ -1,5 +0,0 @@
1
- ---
2
- '@wise/wds-codemods': patch
3
- ---
4
-
5
- NPM release setup
@@ -1,13 +0,0 @@
1
- {
2
- "$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
3
- "changelog": ["@changesets/changelog-github", { "repo": "transferwise/wds-codemods" }],
4
- "commit": false,
5
- "fixed": [],
6
- "linked": [],
7
- "access": "public",
8
- "baseBranch": "main",
9
- "updateInternalDependencies": "minor",
10
- "___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
11
- "onlyUpdatePeerDependentsWhenOutOfRange": true
12
- }
13
- }
@@ -1,128 +0,0 @@
1
- ---
2
- '@wise/wds-codemods': major
3
- ---
4
-
5
- # 🎉 @wise/wds-codemods@1.0.0 - Initial Release
6
-
7
- Welcome to the first major release of WDS Codemods! This comprehensive toolkit provides automated migration support for Wise Design System components, making it easy to upgrade your codebase to the latest component versions.
8
-
9
- ## ✨ Core Features
10
-
11
- ### 🔧 Transform Engine
12
-
13
- - **Interactive CLI**: Choose transforms and configure options with an intuitive command-line interface
14
- - **Dry Run Mode**: Preview changes before applying them to your codebase
15
- - **Monorepo Support**: Built-in support for monorepo package structures with automatic package detection
16
- - **Smart Package Detection**: Automatically detects package versions in both `package.json` dependencies and `node_modules`
17
- - **Comprehensive Reporting**: Generates detailed reports for manual review items that require developer attention
18
-
19
- ### 🎯 Button Component Transform
20
-
21
- - **ActionButton Migration**: Automatically converts deprecated `ActionButton` components to modern `Button` with `v2` prop
22
- - **Legacy Prop Migration**: Transforms legacy props (`priority`, `size`, `type`, `htmlType`, `sentiment`) to new API
23
- - **Enum Value Conversion**: Converts enum values (e.g., `Priority.PRIMARY`, `Size.LARGE`) to string literals
24
- - **Icon Integration**: Intelligently processes icon children and converts them to `addonStart`/`addonEnd` props
25
- - **Link Button Handling**: Properly migrates `as="a"` usage with automatic `href` management
26
- - **Smart Size Mapping**: Maps legacy size values to new design tokens (`xs`, `sm`, `md`, `lg`, `xl`)
27
-
28
- ### 🛡️ Robust Validation & Safety
29
-
30
- - **Package Version Validation**: Ensures transforms only run when target packages are present and meet version requirements
31
- - **TypeScript & JSX Support**: Full support for TypeScript and JSX syntax parsing
32
- - **Expression Analysis**: Handles complex expressions, conditionals, and dynamic values with appropriate fallbacks
33
- - **Gitignore Integration**: Respects `.gitignore` patterns to avoid processing unnecessary files
34
- - **Caching System**: Intelligent caching for package version checks to improve performance
35
-
36
- ### 📊 Advanced Reporting
37
-
38
- - **Manual Review Detection**: Identifies code patterns that require human attention
39
- - **Line-by-Line Reporting**: Precise location reporting for manual review items
40
- - **Issue Classification**: Categorizes issues by type (deprecated props, unsupported values, ambiguous expressions)
41
- - **Batch Processing**: Handles multiple files and provides comprehensive summary reports
42
-
43
- ## 🚀 Usage Examples
44
-
45
- ### Basic Usage
46
-
47
- ```bash
48
- npx @wise/wds-codemods
49
- ```
50
-
51
- ### Advanced Usage
52
-
53
- ```bash
54
- # Run specific transform on a directory
55
- npx @wise/wds-codemods button ./src --dry
56
-
57
- # Target monorepo packages
58
- npx @wise/wds-codemods button ./packages --monorepo
59
-
60
- # Custom ignore patterns
61
- npx @wise/wds-codemods button ./src --ignore-pattern "**/*.test.tsx,**/stories/**"
62
- ```
63
-
64
- ## 📋 Supported Transforms
65
-
66
- ### Button Transform (`button`)
67
-
68
- Migrates Button and ActionButton components from `@transferwise/components` v46.5.0+
69
-
70
- **Transformations include:**
71
-
72
- - ✅ `ActionButton` → `Button` with `v2` prop
73
- - ✅ Legacy prop migrations (`priority`, `size`, `type`, etc.)
74
- - ✅ Enum value conversions
75
- - ✅ Icon children processing
76
- - ✅ Link button handling (`as="a"` → proper href management)
77
- - ✅ Sentiment mapping (`type="negative"` → `sentiment="negative"`)
78
-
79
- ## 🏗️ Architecture Highlights
80
-
81
- ### Modular Design
82
-
83
- - **Transform System**: Extensible architecture for adding new component transforms
84
- - **Helper Utilities**: Reusable utilities for JSX manipulation, reporting, and validation
85
- - **Package Detection**: Multi-strategy package version detection (dependencies + node_modules)
86
- - **Test Infrastructure**: Comprehensive testing utilities for transform development
87
-
88
- ### Developer Experience
89
-
90
- - **Type Safety**: Full TypeScript support with proper type definitions
91
- - **Error Handling**: Graceful error handling with helpful error messages
92
- - **Debug Support**: Extensive debug logging for troubleshooting
93
- - **Extensible**: Easy to add new transforms and extend existing functionality
94
-
95
- ## 🧪 Quality Assurance
96
-
97
- This release includes:
98
-
99
- - ✅ **100% Test Coverage** for core utilities and transforms
100
- - ✅ **End-to-End Testing** with real-world code examples
101
- - ✅ **Edge Case Handling** for complex expressions and unusual patterns
102
- - ✅ **Performance Optimization** with intelligent caching and batching
103
- - ✅ **Memory Management** for large codebases
104
-
105
- ## 🔮 What's Next?
106
-
107
- This foundation enables:
108
-
109
- - 🎯 Additional component transforms (Forms, Navigation, etc.)
110
- - 🚀 Enhanced reporting and analytics
111
- - 🔧 IDE integrations and tooling
112
- - 📱 Support for additional package managers
113
- - 🌍 Community contributions and extensibility
114
-
115
- ## 🙏 Getting Started
116
-
117
- 1. Install the package: `npm install -D @wise/wds-codemods`
118
- 2. Run your first transform: `npx @wise/wds-codemods`
119
- 3. Review the generated `codemod-report.txt` for any manual review items
120
- 4. Commit your changes and enjoy your modernized codebase!
121
-
122
- ---
123
-
124
- **Breaking Changes**: This is the initial release, so no breaking changes from previous versions.
125
-
126
- **Migration Guide**: See our documentation for detailed migration examples and best practices.
127
-
128
- Ready to modernize your Wise Design System components? Let's go! 🚀
@@ -1 +0,0 @@
1
- * @transferwise/design-system-web
@@ -1,49 +0,0 @@
1
- name: 'Bootstrap'
2
- description: 'Set up Node.js and install dependencies'
3
-
4
- inputs:
5
- github-token:
6
- description: 'GitHub token for authentication'
7
- required: true
8
- npm-token-automation:
9
- description: 'NPM token for authentication'
10
- required: false
11
-
12
- runs:
13
- using: 'composite'
14
- steps:
15
- - name: Setup Node.js
16
- uses: actions/setup-node@v4
17
- with:
18
- node-version-file: '.nvmrc'
19
- registry-url: 'https://registry.npmjs.org'
20
-
21
- - name: Setup pnpm
22
- uses: pnpm/action-setup@v4
23
-
24
- - name: Configure npm registry
25
- shell: bash
26
- run: |
27
- echo "registry=https://registry.npmjs.org/" > .npmrc
28
- echo "//registry.npmjs.org/:_authToken=${{ inputs.npm-token-automation }}" >> .npmrc
29
- env:
30
- NODE_AUTH_TOKEN: ${{ inputs.npm-token-automation }}
31
-
32
- - name: Get pnpm store directory
33
- shell: bash
34
- run: |
35
- echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
36
-
37
- - name: Setup pnpm cache
38
- uses: actions/cache@v4
39
- with:
40
- path: ${{ env.STORE_PATH }}
41
- key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
42
- restore-keys: |
43
- ${{ runner.os }}-pnpm-store-
44
-
45
- - name: Install dependencies
46
- shell: bash
47
- run: pnpm install --frozen-lockfile
48
- env:
49
- NODE_AUTH_TOKEN: ${{ inputs.npm-token-automation }}
@@ -1,27 +0,0 @@
1
- name: Commitlint
2
- description: 'Lint all commit messages for the project'
3
-
4
- inputs:
5
- github-token:
6
- required: true
7
- description: 'secrets.GITHUB_TOKEN'
8
-
9
- runs:
10
- using: composite
11
- steps:
12
- - name: 🔐 Mark repo directory as safe for git # https://github.blog/2022-04-12-git-security-vulnerability-announced/
13
- run: git config --global --add safe.directory $GITHUB_WORKSPACE
14
- shell: bash
15
-
16
- - name: 🛠️ Bootstrap dependencies
17
- uses: ./.github/actions/bootstrap
18
- with:
19
- github-token: ${{ inputs.github-token }}
20
-
21
- - name: Fetch full commit history
22
- run: git fetch --unshallow
23
- shell: bash
24
-
25
- - name: Run Commitlint
26
- run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
27
- shell: bash
@@ -1,23 +0,0 @@
1
- name: Test
2
- description: 'Run all tests for the project'
3
-
4
- inputs:
5
- github-token:
6
- required: true
7
- description: 'secrets.GITHUB_TOKEN'
8
-
9
- runs:
10
- using: composite
11
- steps:
12
- - name: 🔐 Mark repo directory as safe for git # https://github.blog/2022-04-12-git-security-vulnerability-announced/
13
- run: git config --global --add safe.directory $GITHUB_WORKSPACE
14
- shell: bash
15
-
16
- - name: 🛠️ Bootstrap dependencies
17
- uses: ./.github/actions/bootstrap
18
- with:
19
- github-token: ${{ inputs.github-token }}
20
-
21
- - name: 🧪 Run tests
22
- run: pnpm run test
23
- shell: bash
@@ -1,150 +0,0 @@
1
- name: '🚀 CI/CD'
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- pull_request:
8
-
9
- concurrency:
10
- group: ${{ github.workflow }}-${{ github.ref }}
11
- cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
12
-
13
- env:
14
- DO_NOT_TRACK: 1
15
-
16
- jobs:
17
- pipeline:
18
- name: '🚀 Build, Lint & Test'
19
- runs-on: ubuntu-latest
20
-
21
- steps:
22
- - name: 🛒 Check out repository
23
- uses: actions/checkout@v5
24
-
25
- - name: ⚙️ Bootstrap
26
- uses: ./.github/actions/bootstrap
27
- with:
28
- github-token: ${{ secrets.GITHUB_TOKEN }}
29
- npm-token-automation: ${{ secrets.NPM_TOKEN_AUTOMATION }}
30
-
31
- - name: 📝 Lint
32
- run: pnpm run lint
33
-
34
- - name: 🧪 Run Tests
35
- run: pnpm test
36
-
37
- - name: 🏗️ Build
38
- run: pnpm run build
39
-
40
- publish-branch:
41
- name: 🚀 Publish experimental packages
42
- if: ${{ github.event_name == 'pull_request' && !startsWith(github.head_ref, 'changeset-release/') }}
43
- runs-on: ubuntu-latest
44
- timeout-minutes: 10
45
- needs: [pipeline]
46
-
47
- steps:
48
- - name: 🛒 Check out repository
49
- uses: actions/checkout@v5
50
- with:
51
- token: ${{ secrets.GH_ACCESS_TOKEN }}
52
-
53
- - name: ⚙️ Bootstrap
54
- uses: ./.github/actions/bootstrap
55
- with:
56
- github-token: ${{ secrets.GITHUB_TOKEN }}
57
- npm-token-automation: ${{ secrets.NPM_TOKEN_AUTOMATION }}
58
-
59
- - name: 🏗️ Build
60
- run: pnpm run build
61
-
62
- - name: Setup npm token
63
- run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN_AUTOMATION }}" >> ~/.npmrc
64
- shell: bash
65
-
66
- - name: Publish snapshot release on npm
67
- id: publish-experimental
68
- run: |
69
- # Get current version from package.json
70
- CURRENT_VERSION=$(node -p "require('./package.json').version")
71
- EXPERIMENTAL_VERSION="${CURRENT_VERSION}-experimental-${GITHUB_SHA:0:7}"
72
-
73
- # Update package.json version directly
74
- npm version $EXPERIMENTAL_VERSION --no-git-tag-version
75
-
76
- # Publish the experimental version and capture output
77
- PUBLISH_OUTPUT=$(npm publish --tag experimental 2>&1)
78
- echo "$PUBLISH_OUTPUT"
79
-
80
- # Extract the published package name and version from npm output
81
- PUBLISHED_PACKAGE=$(echo "$PUBLISH_OUTPUT" | grep -o '@wise/wds-codemods@[^[:space:]]*' | head -1)
82
- echo "published_package=$PUBLISHED_PACKAGE" >> $GITHUB_OUTPUT
83
- env:
84
- GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
85
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_AUTOMATION }}
86
-
87
- - name: Update job status with build ID
88
- uses: actions/github-script@v7
89
- with:
90
- github-token: ${{ secrets.GH_ACCESS_TOKEN }}
91
- script: |
92
- const publishedPackage = '${{ steps.publish-experimental.outputs.published_package }}';
93
-
94
- await github.rest.repos.createCommitStatus({
95
- owner: context.repo.owner,
96
- repo: context.repo.repo,
97
- sha: context.sha,
98
- state: 'success',
99
- target_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
100
- description: publishedPackage,
101
- context: 'Experimental build'
102
- });
103
-
104
- publish:
105
- name: 🚀 Publish stable packages
106
- if: ${{ github.ref == 'refs/heads/main' }}
107
- runs-on: ubuntu-latest
108
- needs: [pipeline]
109
-
110
- steps:
111
- - name: 🛒 Check out repository
112
- uses: actions/checkout@v5
113
- with:
114
- token: ${{ secrets.GH_ACCESS_TOKEN }}
115
-
116
- - name: ⚙️ Bootstrap
117
- uses: ./.github/actions/bootstrap
118
- with:
119
- github-token: ${{ secrets.GITHUB_TOKEN }}
120
- npm-token-automation: ${{ secrets.NPM_TOKEN_AUTOMATION }}
121
-
122
- - name: 🏗️ Build
123
- run: pnpm run build
124
-
125
- - name: 👩‍💻 Set GitHub credentials
126
- run: |
127
- mkdir -p ~/.ssh
128
- ssh-keyscan github.com >> ~/.ssh/known_hosts
129
- git config --global user.name "tw-actions"
130
- git config --global user.email circle@circle.tw.ee
131
-
132
- - name: 🔐 Set up commit signing
133
- uses: crazy-max/ghaction-import-gpg@v6
134
- with:
135
- gpg_private_key: ${{ secrets.GPG_SIGN_KEY }}
136
- git_config_global: true
137
- git_user_signingkey: true
138
- git_commit_gpgsign: true
139
-
140
- - name: Create changesets release PR
141
- id: changesets
142
- uses: changesets/action@v1
143
- with:
144
- publish: pnpm release
145
- commit: 'chore: release'
146
- title: 'chore: release new version and update changelog'
147
- setupGitUser: false
148
- env:
149
- GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
150
- NPM_TOKEN: ${{ secrets.NPM_TOKEN_AUTOMATION }}
@@ -1,16 +0,0 @@
1
- name: Renovate
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- paths:
8
- - pnpm-lock.yaml
9
- schedule:
10
- - cron: '0 2 * * 1' # Run every Monday at 2AM
11
- workflow_dispatch:
12
-
13
- jobs:
14
- renovate:
15
- uses: transferwise/renovate-workflows/.github/workflows/run.yaml@v1
16
- secrets: inherit
package/.husky/commit-msg DELETED
@@ -1 +0,0 @@
1
- npx --no -- commitlint --edit $1
package/.husky/pre-commit DELETED
@@ -1 +0,0 @@
1
- pnpm lint
package/.nvmrc DELETED
@@ -1 +0,0 @@
1
- lts/*
package/.prettierignore DELETED
@@ -1 +0,0 @@
1
- pnpm-lock.yaml
package/.prettierrc.js DELETED
@@ -1,5 +0,0 @@
1
- export default {
2
- printWidth: 100,
3
- singleQuote: true,
4
- trailingComma: 'all',
5
- };