@wise/wds-codemods 0.0.1-experimental-e9ff92f → 1.0.0-experimental-f15e55a
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.
- package/dist/{helpers-auDAwIcO.js → helpers-RWhTD5Is.js} +23 -38
- package/dist/helpers-RWhTD5Is.js.map +1 -0
- package/dist/index.js +24 -32
- package/dist/index.js.map +1 -1
- package/dist/transformer-BjW09YOV.js +124 -0
- package/dist/transformer-BjW09YOV.js.map +1 -0
- package/dist/transforms/button/transformer.js +3 -8
- package/dist/transforms/button/transformer.js.map +1 -1
- package/dist/transforms/list-item/config.json +6 -0
- package/dist/transforms/list-item/transformer.js +3 -0
- package/package.json +3 -1
- package/dist/helpers-auDAwIcO.js.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["path","fs","findPackages","findProjectRoot","loadTransformModules","
|
|
1
|
+
{"version":3,"file":"index.js","names":["path","fs","CONSOLE_ICONS","logToInquirer","findPackages","findProjectRoot","loadTransformModules","transformFile: string","runTransformPrompts","getOptions","transformer","assessPrerequisites","error: unknown"],"sources":["../src/controller/index.ts","../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { execSync } from 'node:child_process';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport { select as list } from '@inquirer/prompts';\n\nimport { CONSOLE_ICONS } from '../constants';\nimport transformer from '../transforms/list-item/transformer';\nimport {\n assessPrerequisites,\n findPackages,\n findProjectRoot,\n getOptions,\n loadTransformModules,\n logToInquirer,\n runTransformPrompts,\n} from './helpers';\n\nlet isDebug = false;\nconst currentFilePath = fileURLToPath(import.meta.url);\nconst currentDirPath = path.dirname(currentFilePath);\n\nconst resetReportFile = async (reportPath: string) => {\n try {\n await fs.access(reportPath);\n await fs.rm(reportPath);\n console.debug(\n `${CONSOLE_ICONS.info} Removed existing report file${isDebug ? `: ${reportPath}` : '.'}`,\n );\n } catch {\n console.debug(\n `${CONSOLE_ICONS.info} No existing report file to remove${isDebug ? `: ${reportPath}` : '.'}`,\n );\n }\n};\n\nconst summariseReportFile = async (reportPath: string) => {\n try {\n const reportContent = await fs.readFile(reportPath, 'utf8');\n const lines = reportContent.split('\\n').filter(Boolean);\n if (lines.length) {\n console.debug(\n `\\n${CONSOLE_ICONS.warning} ${lines.length} manual review${lines.length > 1 ? 's are' : ' is'} required. See ${reportPath} for details.`,\n );\n } else {\n console.debug(\n `${CONSOLE_ICONS.info} Report file exists but is empty${isDebug ? `: ${reportPath}` : '.'}`,\n );\n }\n } catch {\n console.debug(`${CONSOLE_ICONS.info} No report file generated - no manual reviews needed`);\n }\n};\n\nconst log = (label: string, value?: string): void => {\n if (typeof logToInquirer === 'function') {\n logToInquirer(label, value || '');\n } else {\n console.info(label, value || '');\n }\n};\n\nasync function runCodemod(transformsDir?: string) {\n const args = process.argv.slice(2);\n const candidate = args[0];\n isDebug = args.includes('--debug');\n\n try {\n const packages = findPackages();\n const reportPath = path.resolve(findProjectRoot(), 'codemod-report.txt');\n const resolvedTransformsDir =\n transformsDir ?? path.resolve(currentDirPath, '../dist/transforms');\n\n if (isDebug) {\n console.debug(\n `${CONSOLE_ICONS.info} Resolved transforms directory: ${resolvedTransformsDir}`,\n );\n }\n\n await resetReportFile(reportPath);\n\n const { transformFiles } = await loadTransformModules(resolvedTransformsDir);\n\n const resolvedTransformNames = await Promise.all(transformFiles);\n if (resolvedTransformNames.length === 0) {\n throw new Error(\n `${CONSOLE_ICONS.error} No transform scripts found${isDebug ? ` in: ${resolvedTransformsDir}` : '.'}`,\n );\n }\n\n let transformFile: string;\n\n if (candidate && resolvedTransformNames.includes(candidate)) {\n log('Select codemod to run:', candidate);\n transformFile = candidate;\n } else {\n transformFile = await list({\n message: 'Select codemod to run:',\n choices: resolvedTransformNames.map((name) => ({ name, value: name })),\n });\n log('Selected codemod:', transformFile);\n }\n\n const codemodPath = path.resolve(resolvedTransformsDir, transformFile, 'transformer.js');\n if (isDebug) {\n console.debug(`${CONSOLE_ICONS.info} Resolved codemod path: ${codemodPath}`);\n }\n\n const promptAnswers = await runTransformPrompts(codemodPath);\n\n const options = await getOptions({\n packages,\n root: findProjectRoot(),\n transformFiles: resolvedTransformNames,\n preselectedTransformFile: transformFile,\n });\n\n // Handle ListItem transform differently as it uses Claude, not jscodeshift\n if (transformFile === 'list-item') {\n // TODO: Handle ALL args and options properly - isDry, isPrint, ignorePatterns, useGitIgnore, etc\n await transformer(options.targetPaths, isDebug);\n } else {\n await Promise.all(\n options.targetPaths.map(async (targetPath) => {\n console.info(\n `${CONSOLE_ICONS.focus} \\x1b[1mProcessing:\\x1b[0m \\x1b[32m${targetPath}\\x1b[0m`,\n );\n\n const isCompliant = assessPrerequisites(targetPath, codemodPath);\n if (isCompliant) {\n const answerArgs = Object.entries(promptAnswers).map(\n ([promptName, answerValue]) => `--${promptName}=${String(answerValue)}`,\n );\n\n const argsList = [\n '-t',\n codemodPath,\n targetPath,\n options.isDry ? '--dry' : '',\n options.isPrint ? '--print' : '',\n options.ignorePatterns\n ? options.ignorePatterns\n .split(',')\n .map((pattern) => `--ignore-pattern=${pattern.trim()}`)\n .join(' ')\n : '',\n options.useGitIgnore ? '--gitignore' : '',\n ...answerArgs,\n ].filter(Boolean);\n const command = `npx jscodeshift ${argsList.join(' ')}`;\n\n if (isDebug) {\n console.debug(`${CONSOLE_ICONS.info} Running: ${command}`);\n }\n\n return execSync(command, { stdio: 'inherit' });\n }\n return undefined;\n }),\n );\n }\n\n await summariseReportFile(reportPath);\n } catch (error: unknown) {\n if (error instanceof Error) {\n console.error(`${CONSOLE_ICONS.error} Error running ${candidate} codemod:`, error.message);\n } else {\n console.error(`${CONSOLE_ICONS.error} Error running ${candidate} 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 './controller';\n\n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AAK,YAAY,oBAAoB,QAAQ,MAAM,GAAG,CACtD,KAAK,IAAI,GACZ;KACJ,QAAQ,eAAe,gBAAgB;KACvC,GAAG;KACJ,CAAC,OAAO,QAAQ,CAC2B,KAAK,IAAI;AAErD,QAAI,QACF,SAAQ,MAAM,GAAGT,kCAAc,KAAK,YAAY,UAAU;AAG5D,4CAAgB,SAAS,EAAE,OAAO,WAAW,CAAC;;IAGhD,CACH;AAGH,QAAM,oBAAoB,WAAW;UAC9BU,OAAgB;AACvB,MAAI,iBAAiB,MACnB,SAAQ,MAAM,GAAGV,kCAAc,MAAM,iBAAiB,UAAU,YAAY,MAAM,QAAQ;MAE1F,SAAQ,MAAM,GAAGA,kCAAc,MAAM,iBAAiB,UAAU,YAAY,MAAM;AAEpF,MAAI,QAAQ,IAAI,aAAa,OAC3B,SAAQ,KAAK,EAAE;;;;;;AC1KhB,YAAY"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
const require_helpers = require('./helpers-RWhTD5Is.js');
|
|
2
|
+
let node_child_process = require("node:child_process");
|
|
3
|
+
let node_path = require("node:path");
|
|
4
|
+
let __anthropic_ai_claude_agent_sdk = require("@anthropic-ai/claude-agent-sdk");
|
|
5
|
+
let node_fs = require("node:fs");
|
|
6
|
+
|
|
7
|
+
//#region src/constants.ts
|
|
8
|
+
const CONSOLE_ICONS = {
|
|
9
|
+
info: "\x1B[34mℹ\x1B[0m",
|
|
10
|
+
focus: "\x1B[34m➙\x1B[0m",
|
|
11
|
+
success: "\x1B[32m✔\x1B[0m",
|
|
12
|
+
warning: "\x1B[33m⚠\x1B[0m",
|
|
13
|
+
error: "\x1B[31m✖\x1B[0m"
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/transforms/list-item/constants.ts
|
|
18
|
+
const DEPRECATED_COMPONENT_NAMES = [
|
|
19
|
+
"ActionOption",
|
|
20
|
+
"NavigationOption",
|
|
21
|
+
"NavigationOptionsList",
|
|
22
|
+
"Summary",
|
|
23
|
+
"SwitchOption",
|
|
24
|
+
"CheckboxOption",
|
|
25
|
+
"RadioOption"
|
|
26
|
+
];
|
|
27
|
+
const SYSTEM_PROMPT = `Transform TypeScript/JSX code from legacy Wise Design System (WDS) components to the new ListItem component and ListItem subcomponents from '@transferwise/components'.
|
|
28
|
+
|
|
29
|
+
Rules:
|
|
30
|
+
1. Migrate components per provided migration rules
|
|
31
|
+
2. Maintain TypeScript type safety and update types to match new API
|
|
32
|
+
3. Map props: handle renamed, deprecated, new required, and changed types
|
|
33
|
+
4. Update imports to new WDS components and types
|
|
34
|
+
5. Preserve code style, formatting, and calculated logic
|
|
35
|
+
6. Handle conditional rendering, spread props, and complex expressions
|
|
36
|
+
7. Note: New components may lack feature parity with legacy versions
|
|
37
|
+
|
|
38
|
+
You'll receive:
|
|
39
|
+
- File paths/directories to search
|
|
40
|
+
- Deprecated component names at the end of this prompt
|
|
41
|
+
|
|
42
|
+
Migration context and rules can be found in the MAPPINGS.md file.
|
|
43
|
+
|
|
44
|
+
Only modify code requiring changes per migration rules. Make the necessary updates to the files and do not respond with any explanations or reasoning.
|
|
45
|
+
|
|
46
|
+
Deprecated components: ${DEPRECATED_COMPONENT_NAMES.join(", ")}.`;
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/transforms/list-item/claude.ts
|
|
50
|
+
const CLAUDE_SETTINGS_FILE = ".claude/settings.json";
|
|
51
|
+
function getQueryOptions(isDebug = false) {
|
|
52
|
+
const claudeSettingsPath = (0, node_path.resolve)(process.env.HOME || "", CLAUDE_SETTINGS_FILE);
|
|
53
|
+
const settings = JSON.parse((0, node_fs.readFileSync)(claudeSettingsPath, "utf-8"));
|
|
54
|
+
let apiKey;
|
|
55
|
+
try {
|
|
56
|
+
apiKey = (0, node_child_process.execSync)(`bash ${settings.apiKeyHelper}`, { encoding: "utf-8" }).trim();
|
|
57
|
+
} catch {}
|
|
58
|
+
if (!apiKey) throw new Error("Failed to retrieve Anthropic API key. Please check your Claude Code x LLM Gateway configuration - https://transferwise.atlassian.net/wiki/x/_YUe3Q");
|
|
59
|
+
return {
|
|
60
|
+
env: {
|
|
61
|
+
ANTHROPIC_AUTH_TOKEN: apiKey,
|
|
62
|
+
ANTHROPIC_BASE_URL: settings?.env?.ANTHROPIC_BASE_URL,
|
|
63
|
+
ANTHROPIC_CUSTOM_HEADERS: settings?.env?.ANTHROPIC_CUSTOM_HEADERS,
|
|
64
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL: settings.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,
|
|
65
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL: settings.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,
|
|
66
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL: settings.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,
|
|
67
|
+
API_TIMEOUT_MS: settings.env?.API_TIMEOUT_MS,
|
|
68
|
+
PATH: process.env.PATH
|
|
69
|
+
},
|
|
70
|
+
permissionMode: "acceptEdits",
|
|
71
|
+
systemPrompt: {
|
|
72
|
+
type: "preset",
|
|
73
|
+
preset: "claude_code",
|
|
74
|
+
append: SYSTEM_PROMPT
|
|
75
|
+
},
|
|
76
|
+
settingSources: [
|
|
77
|
+
"local",
|
|
78
|
+
"project",
|
|
79
|
+
"user"
|
|
80
|
+
]
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/transforms/list-item/transformer.ts
|
|
86
|
+
const transformer = async (targetPaths, isDebug = false) => {
|
|
87
|
+
console.log(`${CONSOLE_ICONS.info} Starting Claude instance...`);
|
|
88
|
+
const result = (0, __anthropic_ai_claude_agent_sdk.query)({
|
|
89
|
+
options: getQueryOptions(isDebug),
|
|
90
|
+
prompt: `Here are the directories to search in: ${targetPaths.join(", ")}.
|
|
91
|
+
In addition to making the required file changes for every relevant file, only respond with the file path/name and number of lines changed per file - e.g. "<directory/filename> - 5 lines changed".
|
|
92
|
+
If no changes are made for a file, respond with "<directory/filename> - No changes required". If all files require no changes, return only the same format still with nothing else.`
|
|
93
|
+
});
|
|
94
|
+
for await (const message of result) switch (message.type) {
|
|
95
|
+
case "system":
|
|
96
|
+
if (message.subtype === "init") {
|
|
97
|
+
console.log(`${CONSOLE_ICONS.success} Initialised Claude instance`);
|
|
98
|
+
console.log(`${CONSOLE_ICONS.info} Claude is processing the files... This may take a while.`);
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
101
|
+
case "result":
|
|
102
|
+
if (message.subtype === "success") console.log(`${CONSOLE_ICONS.success} ${message.result.split("\n").join(`\n${CONSOLE_ICONS.success} `)}`);
|
|
103
|
+
else console.log(`${CONSOLE_ICONS.error} Claude encountered an error: ${message.errors.join("\n")}`);
|
|
104
|
+
break;
|
|
105
|
+
default: break;
|
|
106
|
+
}
|
|
107
|
+
console.log(`${CONSOLE_ICONS.success} Finished receiving messages from Claude.`);
|
|
108
|
+
};
|
|
109
|
+
var transformer_default = transformer;
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
Object.defineProperty(exports, 'CONSOLE_ICONS', {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function () {
|
|
115
|
+
return CONSOLE_ICONS;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
Object.defineProperty(exports, 'transformer_default', {
|
|
119
|
+
enumerable: true,
|
|
120
|
+
get: function () {
|
|
121
|
+
return transformer_default;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
//# sourceMappingURL=transformer-BjW09YOV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformer-BjW09YOV.js","names":[],"sources":["../src/constants.ts","../src/transforms/list-item/constants.ts","../src/transforms/list-item/claude.ts","../src/transforms/list-item/transformer.ts"],"sourcesContent":["export const CONSOLE_ICONS = {\n info: '\\x1b[34mℹ\\x1b[0m', // Blue info icon\n focus: '\\x1b[34m➙\\x1b[0m', // Blue arrow icon\n success: '\\x1b[32m✔\\x1b[0m', // Green checkmark\n warning: '\\x1b[33m⚠\\x1b[0m', // Yellow warning icon\n error: '\\x1b[31m✖\\x1b[0m', // Red cross icon\n};\n","const DEPRECATED_COMPONENT_NAMES = [\n 'ActionOption',\n 'NavigationOption',\n 'NavigationOptionsList',\n 'Summary',\n 'SwitchOption',\n 'CheckboxOption',\n 'RadioOption',\n];\n\nexport const SYSTEM_PROMPT = `Transform TypeScript/JSX code from legacy Wise Design System (WDS) components to the new ListItem component and ListItem subcomponents from '@transferwise/components'.\n\nRules:\n1. Migrate components per provided migration rules\n2. Maintain TypeScript type safety and update types to match new API\n3. Map props: handle renamed, deprecated, new required, and changed types\n4. Update imports to new WDS components and types\n5. Preserve code style, formatting, and calculated logic\n6. Handle conditional rendering, spread props, and complex expressions\n7. Note: New components may lack feature parity with legacy versions\n\nYou'll receive:\n- File paths/directories to search\n- Deprecated component names at the end of this prompt\n\nMigration context and rules can be found in the MAPPINGS.md file.\n\nOnly modify code requiring changes per migration rules. Make the necessary updates to the files and do not respond with any explanations or reasoning.\n\nDeprecated components: ${DEPRECATED_COMPONENT_NAMES.join(', ')}.`;\n","import type { Options } from '@anthropic-ai/claude-agent-sdk';\nimport { execSync } from 'child_process';\nimport { readFileSync } from 'fs';\nimport { resolve } from 'path';\n\nimport { SYSTEM_PROMPT } from './constants';\n\ninterface ClaudeSettings {\n apiKeyHelper?: string;\n env?: {\n ANTHROPIC_BASE_URL?: string;\n ANTHROPIC_CUSTOM_HEADERS?: string;\n ANTHROPIC_DEFAULT_SONNET_MODEL?: string;\n ANTHROPIC_DEFAULT_HAIKU_MODEL?: string;\n ANTHROPIC_DEFAULT_OPUS_MODEL?: string;\n API_TIMEOUT_MS?: string;\n [key: string]: unknown;\n };\n [key: string]: unknown;\n}\n\nconst CLAUDE_SETTINGS_FILE = '.claude/settings.json';\n\nexport function getQueryOptions(isDebug = false): Options {\n // Read settings from ~/.claude/settings.json to get headers and apiKeyHelper\n const claudeSettingsPath = resolve(process.env.HOME || '', CLAUDE_SETTINGS_FILE);\n const settings = JSON.parse(readFileSync(claudeSettingsPath, 'utf-8')) as ClaudeSettings;\n\n // Get API key by executing the apiKeyHelper script, for authenticating with Okta via LLM Gateway\n let apiKey;\n try {\n apiKey = execSync(`bash ${settings.apiKeyHelper}`, {\n encoding: 'utf-8',\n }).trim();\n } catch {}\n\n if (!apiKey) {\n throw new Error(\n 'Failed to retrieve Anthropic API key. Please check your Claude Code x LLM Gateway configuration - https://transferwise.atlassian.net/wiki/x/_YUe3Q',\n );\n }\n\n const envVars = {\n ANTHROPIC_AUTH_TOKEN: apiKey,\n ANTHROPIC_BASE_URL: settings?.env?.ANTHROPIC_BASE_URL,\n ANTHROPIC_CUSTOM_HEADERS: settings?.env?.ANTHROPIC_CUSTOM_HEADERS,\n ANTHROPIC_DEFAULT_SONNET_MODEL: settings.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,\n ANTHROPIC_DEFAULT_HAIKU_MODEL: settings.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,\n ANTHROPIC_DEFAULT_OPUS_MODEL: settings.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,\n API_TIMEOUT_MS: settings.env?.API_TIMEOUT_MS,\n PATH: process.env.PATH, // Specifying PATH as Claude Agent SDK seems to struggle consuming the actual environment PATH\n };\n\n // if (isDebug) {\n // console.debug(`${CONSOLE_ICONS.info} Resolved Claude environment variables:`, JSON.stringify(envVars));\n // }\n\n return {\n env: envVars,\n permissionMode: 'acceptEdits',\n systemPrompt: {\n type: 'preset',\n preset: 'claude_code',\n append: SYSTEM_PROMPT,\n },\n settingSources: ['local', 'project', 'user'],\n };\n}\n","import { query } from '@anthropic-ai/claude-agent-sdk';\n\nimport { CONSOLE_ICONS } from '../../constants';\nimport { getQueryOptions } from './claude';\n\nconst transformer = async (targetPaths: string[], isDebug = false) => {\n // TODO: We need to confirm you're connected to the VPN\n console.log(`${CONSOLE_ICONS.info} Starting Claude instance...`);\n\n const result = query({\n options: getQueryOptions(isDebug),\n prompt: `Here are the directories to search in: ${targetPaths.join(', ')}.\n In addition to making the required file changes for every relevant file, only respond with the file path/name and number of lines changed per file - e.g. \"<directory/filename> - 5 lines changed\".\n If no changes are made for a file, respond with \"<directory/filename> - No changes required\". If all files require no changes, return only the same format still with nothing else.`,\n });\n\n // TODO: Ensure we're handling all potential types of messages here.\n for await (const message of result) {\n switch (message.type) {\n case 'system':\n if (message.subtype === 'init') {\n console.log(`${CONSOLE_ICONS.success} Initialised Claude instance`);\n console.log(\n `${CONSOLE_ICONS.info} Claude is processing the files... This may take a while.`,\n );\n }\n break;\n\n case 'result':\n if (message.subtype === 'success') {\n console.log(\n `${CONSOLE_ICONS.success} ${message.result.split('\\n').join(`\\n${CONSOLE_ICONS.success} `)}`,\n );\n } else {\n console.log(\n `${CONSOLE_ICONS.error} Claude encountered an error: ${message.errors.join('\\n')}`,\n );\n }\n\n break;\n default:\n // console.log(JSON.stringify(message));\n break;\n }\n }\n\n console.log(`${CONSOLE_ICONS.success} Finished receiving messages from Claude.`);\n};\n\nexport default transformer;\n"],"mappings":";;;;;;;AAAA,MAAa,gBAAgB;CAC3B,MAAM;CACN,OAAO;CACP,SAAS;CACT,SAAS;CACT,OAAO;CACR;;;;ACND,MAAM,6BAA6B;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,gBAAgB;;;;;;;;;;;;;;;;;;;yBAmBJ,2BAA2B,KAAK,KAAK,CAAC;;;;ACR/D,MAAM,uBAAuB;AAE7B,SAAgB,gBAAgB,UAAU,OAAgB;CAExD,MAAM,4CAA6B,QAAQ,IAAI,QAAQ,IAAI,qBAAqB;CAChF,MAAM,WAAW,KAAK,gCAAmB,oBAAoB,QAAQ,CAAC;CAGtE,IAAI;AACJ,KAAI;AACF,4CAAkB,QAAQ,SAAS,gBAAgB,EACjD,UAAU,SACX,CAAC,CAAC,MAAM;SACH;AAER,KAAI,CAAC,OACH,OAAM,IAAI,MACR,qJACD;AAkBH,QAAO;EACL,KAhBc;GACd,sBAAsB;GACtB,oBAAoB,UAAU,KAAK;GACnC,0BAA0B,UAAU,KAAK;GACzC,gCAAgC,SAAS,KAAK;GAC9C,+BAA+B,SAAS,KAAK;GAC7C,8BAA8B,SAAS,KAAK;GAC5C,gBAAgB,SAAS,KAAK;GAC9B,MAAM,QAAQ,IAAI;GACnB;EAQC,gBAAgB;EAChB,cAAc;GACZ,MAAM;GACN,QAAQ;GACR,QAAQ;GACT;EACD,gBAAgB;GAAC;GAAS;GAAW;GAAO;EAC7C;;;;;AC7DH,MAAM,cAAc,OAAO,aAAuB,UAAU,UAAU;AAEpE,SAAQ,IAAI,GAAG,cAAc,KAAK,8BAA8B;CAEhE,MAAM,oDAAe;EACnB,SAAS,gBAAgB,QAAQ;EACjC,QAAQ,0CAA0C,YAAY,KAAK,KAAK,CAAC;;;EAG1E,CAAC;AAGF,YAAW,MAAM,WAAW,OAC1B,SAAQ,QAAQ,MAAhB;EACE,KAAK;AACH,OAAI,QAAQ,YAAY,QAAQ;AAC9B,YAAQ,IAAI,GAAG,cAAc,QAAQ,8BAA8B;AACnE,YAAQ,IACN,GAAG,cAAc,KAAK,2DACvB;;AAEH;EAEF,KAAK;AACH,OAAI,QAAQ,YAAY,UACtB,SAAQ,IACN,GAAG,cAAc,QAAQ,GAAG,QAAQ,OAAO,MAAM,KAAK,CAAC,KAAK,KAAK,cAAc,QAAQ,GAAG,GAC3F;OAED,SAAQ,IACN,GAAG,cAAc,MAAM,gCAAgC,QAAQ,OAAO,KAAK,KAAK,GACjF;AAGH;EACF,QAEE;;AAIN,SAAQ,IAAI,GAAG,cAAc,QAAQ,2CAA2C;;AAGlF,0BAAe"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
const require_helpers = require('../../helpers-
|
|
2
|
+
const require_helpers = require('../../helpers-RWhTD5Is.js');
|
|
3
3
|
|
|
4
4
|
//#region src/helpers/addImport.ts
|
|
5
5
|
/**
|
|
@@ -106,9 +106,7 @@ const processIconChildren = (j, children, iconImports, openingElement) => {
|
|
|
106
106
|
const iconChild = unwrapJsxElement(children[iconChildIndex]);
|
|
107
107
|
if (!iconChild || iconChild.openingElement.name.type !== "JSXIdentifier") return;
|
|
108
108
|
iconChild.openingElement.name.name;
|
|
109
|
-
const
|
|
110
|
-
const distanceToEnd = totalChildren - 1 - iconChildIndex;
|
|
111
|
-
const iconPropName = distanceToStart <= distanceToEnd ? "addonStart" : "addonEnd";
|
|
109
|
+
const iconPropName = iconChildIndex <= totalChildren - 1 - iconChildIndex ? "addonStart" : "addonEnd";
|
|
112
110
|
const iconObject = j.objectExpression([j.property("init", j.identifier("type"), j.literal("icon")), j.property("init", j.identifier("value"), iconChild)]);
|
|
113
111
|
const iconProp = j.jsxAttribute(j.jsxIdentifier(iconPropName), j.jsxExpressionContainer(iconObject));
|
|
114
112
|
openingElement.attributes.push(iconProp);
|
|
@@ -333,10 +331,7 @@ var CodemodReporter = class {
|
|
|
333
331
|
if (attr.value.type === "JSXExpressionContainer") {
|
|
334
332
|
const expr = attr.value.expression;
|
|
335
333
|
const expressionType = expr.type.replace("Expression", "").toLowerCase();
|
|
336
|
-
if (expr.type === "Identifier" || expr.type === "MemberExpression") {
|
|
337
|
-
const valueText = this.j(expr).toSource();
|
|
338
|
-
return `contains a ${expressionType} (${valueText})`;
|
|
339
|
-
}
|
|
334
|
+
if (expr.type === "Identifier" || expr.type === "MemberExpression") return `contains a ${expressionType} (${this.j(expr).toSource()})`;
|
|
340
335
|
return `contains a complex ${expressionType} expression`;
|
|
341
336
|
}
|
|
342
337
|
return "needs manual review";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformer.js","names":["result: ImportSpecifier[]","sizeMap: Record<string, string>","j: JSCodeshift","manualReviewIssues: string[]","hasImport","legacyProps: LegacyProps","resolvedType: string | undefined","typeValue: string | undefined","asValue: string | null","reportManualReview"],"sources":["../../../src/helpers/addImport.ts","../../../src/helpers/hasImport.ts","../../../src/helpers/iconUtils.ts","../../../src/helpers/jsxElementUtils.ts","../../../src/helpers/jsxReportingUtils.ts","../../../src/transforms/button/transformer.ts"],"sourcesContent":["import type { Collection, JSCodeshift } from 'jscodeshift';\n\n/**\n * Adds a named import if it doesn't already exist.\n */\nfunction addImport(\n root: Collection,\n sourceValue: string,\n importName: string,\n j: JSCodeshift,\n): void {\n const existingImports = root.find(j.ImportDeclaration, {\n source: { value: sourceValue },\n });\n\n if (existingImports.size() > 0) {\n const namedImport = existingImports.find(j.ImportSpecifier, {\n imported: { name: importName },\n });\n\n if (namedImport.size() > 0) {\n return;\n }\n\n existingImports.forEach((path) => {\n if (path.node.specifiers) {\n path.node.specifiers.push(j.importSpecifier(j.identifier(importName)));\n }\n });\n } else {\n const newImport = j.importDeclaration(\n [j.importSpecifier(j.identifier(importName))],\n j.literal(sourceValue),\n );\n\n const firstImport = root.find(j.ImportDeclaration).at(0);\n if (firstImport.size() > 0) {\n firstImport.insertBefore(newImport);\n } else {\n // Insert at the beginning of the program\n const program = root.find(j.Program);\n if (program.size() > 0) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access\n program.get('body', 0).insertBefore(newImport);\n }\n }\n }\n}\n\nexport default addImport;\n","import type { ASTPath, Collection, ImportSpecifier, 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): {\n exists: boolean;\n remove: () => void;\n aliases?: Collection<ImportSpecifier>;\n resolvedName: string;\n conflictingImports: ImportSpecifier[];\n} {\n const importDeclarations = root.find(j.ImportDeclaration, {\n source: { value: sourceValue },\n });\n\n /**\n * Finds all ImportSpecifier nodes that expose `importName` but\n * from a different source than `sourceValue`.\n */\n const conflictingImports = ((): ImportSpecifier[] => {\n const result: ImportSpecifier[] = [];\n root\n .find(j.ImportDeclaration)\n .filter((path) => path.node.source.value !== sourceValue)\n .forEach((path) => {\n for (const specifier of path.node.specifiers ?? []) {\n if (\n specifier.type === 'ImportSpecifier' &&\n specifier.imported.name === importName &&\n specifier.local?.name === importName\n ) {\n result.push(specifier);\n }\n }\n });\n return result;\n })();\n\n if (importDeclarations.size() === 0) {\n return {\n exists: false,\n remove: () => {},\n resolvedName: importName,\n conflictingImports,\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 aliasImport = importDeclarations.find(j.ImportSpecifier).filter((path) => {\n return (\n path.node.imported.name === importName && path.node.imported.name !== path.node.local?.name\n );\n });\n\n const exists = namedImport.size() > 0 || defaultImport.size() > 0;\n\n const resolveName = (): string => {\n if (aliasImport.size() > 0) {\n const importPath = aliasImport.get(0) as ASTPath<ImportSpecifier>;\n const localName = importPath.node.local?.name;\n\n if (typeof localName === 'string') {\n return localName;\n }\n\n if (\n localName &&\n typeof localName === 'object' &&\n 'name' in localName &&\n typeof localName.name === 'string'\n ) {\n return localName.name;\n }\n\n return importName;\n }\n\n return importName;\n };\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 {\n exists,\n remove,\n aliases: aliasImport,\n resolvedName: resolveName(),\n conflictingImports,\n };\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 Collection,\n ImportSpecifier,\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\n/**\n * Returns a collection of JSX elements that match the specified\n * exported name or names of the found aliases.\n */\nexport const findJSXElementsByName =\n (root: Collection, j: JSCodeshift) =>\n (exportedName: string, aliases?: Collection<ImportSpecifier>) => {\n const aliasNames = aliases?.size()\n ? aliases.paths().map((path) => path.node.local?.name as string)\n : [];\n\n return root.find(j.JSXElement).filter((path) => {\n const { name } = path.node.openingElement;\n return (\n name.type === 'JSXIdentifier' &&\n (name.name === exportedName || aliasNames.includes(name.name))\n );\n });\n };\n\n/**\n * Removes an attribute by name from a JSX element's openingElement.\n */\nexport const removeAttributeByName = (\n j: JSCodeshift,\n openingElement: JSXElement['openingElement'],\n attributeName: string,\n) => {\n if (!Array.isArray(openingElement.attributes)) return;\n // eslint-disable-next-line no-param-reassign\n openingElement.attributes = openingElement.attributes.filter((attr) => {\n return !(\n attr.type === 'JSXAttribute' &&\n attr.name.type === 'JSXIdentifier' &&\n attr.name.name === attributeName\n );\n });\n};\n","import type {\n ASTPath,\n ImportSpecifier,\n JSCodeshift,\n JSXAttribute,\n JSXElement,\n Node,\n} 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 /**\n * Finds and reports instances of components that are under an alias (imported with a different name)\n */\n reportAliases(element: JSXElement | ASTPath<JSXElement>): void {\n this.reportElement(element, 'is used via an import alias and needs manual review');\n }\n\n /**\n * Finds and reports instances of non-DS import declarations that conflict with the component name\n */\n reportConflictingImports(node: ImportSpecifier): void {\n this.addIssue(\n `Manual review required: Non-WDS package resulting in an import conflict at line ${this.getLineNumber(node)}.`,\n );\n }\n\n /**\n * Reports enum usage for future conversion tracking\n */\n reportEnumUsage(\n element: JSXElement | ASTPath<JSXElement>,\n propName: string,\n enumValue: string,\n ): void {\n this.reportProp(\n element,\n propName,\n `uses enum value \"${enumValue}\" which has been preserved but should be migrated to a string literal in the future`,\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 '../../controller/helpers';\nimport {\n addAttributesIfMissing,\n addImport,\n createReporter,\n findJSXElementsByName,\n hasAttributeOnElement,\n hasImport,\n processIconChildren,\n removeAttributeByName,\n setNameIfJSXIdentifier,\n} from '../../helpers';\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\ninterface ExtendedOptions extends Options {\n accentSecondaryMapping?: string;\n positiveSecondaryMapping?: string;\n}\n\ntype PriorityMapping = Record<string, Record<string, string>>;\n\nconst buildPriorityMapping = (opts: Options): PriorityMapping => {\n const extendedOpts = opts as ExtendedOptions;\n const accentSecondary = extendedOpts.accentSecondaryMapping || 'secondary-neutral';\n const positiveSecondary = extendedOpts.positiveSecondaryMapping || 'secondary-neutral';\n return {\n accent: {\n primary: 'primary',\n secondary: accentSecondary,\n tertiary: 'tertiary',\n },\n positive: {\n primary: 'primary',\n secondary: positiveSecondary,\n tertiary: positiveSecondary,\n },\n negative: {\n primary: 'primary',\n secondary: 'secondary',\n tertiary: 'secondary',\n },\n primary: {\n primary: 'primary',\n secondary: accentSecondary,\n tertiary: 'tertiary',\n },\n pay: {\n primary: 'primary',\n secondary: accentSecondary,\n tertiary: accentSecondary,\n },\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 legacyButtonTypes = [\n 'accent',\n 'negative',\n 'positive',\n 'primary',\n 'pay',\n 'secondary',\n 'danger',\n 'link',\n];\n\nconst getConsistentTypeConversions = (\n type?: string,\n): { priority?: string; sentiment?: string } | null => {\n const consistentTypeConversions: Record<string, { priority?: string; sentiment?: string }> = {\n secondary: { priority: 'secondary-neutral' },\n link: { priority: 'tertiary' },\n danger: { priority: 'secondary', sentiment: 'negative' },\n };\n\n return consistentTypeConversions[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 * Detects if a value is an enum pattern (e.g., Priority.PRIMARY, ControlType.ACCENT, Size.LARGE, Type.PRIMARY)\n */\nconst isEnumValue = (value: string): boolean => {\n const enumPatterns = [\n /^Priority\\.(PRIMARY|SECONDARY|TERTIARY|SECONDARY_NEUTRAL)$/u,\n /^ControlType\\.(ACCENT|NEGATIVE|POSITIVE)$/u,\n /^Size\\.(EXTRA_SMALL|SMALL|MEDIUM|LARGE|EXTRA_LARGE)$/u,\n /^Type\\.(PRIMARY|SECONDARY|TERTIARY|PAY|DANGER|LINK|ACCENT|POSITIVE|NEGATIVE)$/u,\n ];\n return enumPatterns.some((pattern) => pattern.test(value));\n};\n\n/**\n * Maps enum values to their expected string equivalents for validation purposes\n * This is ONLY used to validate the enum maps to a supported value\n */\nconst getEnumEquivalent = (value: string): string | undefined => {\n const enumMapping: Record<string, string> = {\n 'Priority.PRIMARY': 'primary',\n 'Priority.SECONDARY': 'secondary',\n 'Priority.TERTIARY': 'tertiary',\n 'Priority.SECONDARY_NEUTRAL': 'secondary-neutral',\n 'ControlType.NEGATIVE': 'negative',\n 'ControlType.POSITIVE': 'positive',\n 'ControlType.ACCENT': 'accent',\n 'Size.EXTRA_SMALL': 'sm',\n 'Size.SMALL': 'sm',\n 'Size.MEDIUM': 'md',\n 'Size.LARGE': 'lg',\n 'Size.EXTRA_LARGE': 'xl',\n };\n return enumMapping[value];\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 const priorityMapping = buildPriorityMapping(options);\n\n const resolvePriority = (type?: string, priority?: string): string | undefined => {\n if (type && priority) {\n return priorityMapping[type]?.[priority] || priority;\n }\n return priority;\n };\n\n // Create reporter instance\n const reporter = createReporter(j, manualReviewIssues);\n\n const {\n exists: hasButtonImport,\n aliases: buttonAliases,\n resolvedName: buttonName,\n conflictingImports: conflictingButtonImport,\n } = hasImport(root, '@transferwise/components', 'Button', j);\n\n if (conflictingButtonImport.length) {\n conflictingButtonImport.forEach((node) => reporter.reportConflictingImports(node));\n }\n\n const {\n exists: hasActionButtonImport,\n remove: removeActionButtonImport,\n aliases: actionButtonAliases,\n } = hasImport(root, '@transferwise/components', 'ActionButton', j);\n\n if (!hasButtonImport && !hasActionButtonImport) {\n return file.source;\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 if (!hasButtonImport) {\n addImport(root, '@transferwise/components', 'Button', j);\n }\n\n const instances = findJSXElementsByName(root, j)('ActionButton', actionButtonAliases);\n\n instances.forEach((path) => {\n const { openingElement, closingElement } = path.node;\n\n openingElement.name = setNameIfJSXIdentifier(openingElement.name, buttonName)!;\n if (closingElement) {\n closingElement.name = setNameIfJSXIdentifier(closingElement.name, buttonName)!;\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', 'size'];\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 legacyProps[name] = convertEnumValue(String(j(attr.value.expression).toSource()));\n }\n }\n }\n }\n });\n\n const hasTextProp = 'text' in legacyProps;\n const hasChildren =\n path.node.children?.some(\n (child) =>\n (child.type === 'JSXText' && child.value.trim() !== '') ||\n child.type === 'JSXElement' ||\n child.type === 'JSXExpressionContainer',\n ) ||\n (path.node.children && path.node.children?.length > 0);\n\n if (hasTextProp && hasChildren) {\n reporter.reportPropWithChildren(path, 'text');\n } else if (hasTextProp && !hasChildren && openingElement.selfClosing) {\n // Self-closing tag with text prop but no children, so we can convert to a normal element with children\n path.replace(\n j.jsxElement(\n j.jsxOpeningElement(openingElement.name, openingElement.attributes),\n j.jsxClosingElement(openingElement.name),\n [j.jsxText((legacyProps.text as string) || '')],\n ),\n );\n }\n\n addAttributesIfMissing(j, path.node.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 (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 const instances = findJSXElementsByName(root, j)('Button', buttonAliases);\n\n instances.forEach((path) => {\n const { openingElement } = path.node;\n\n if (hasAttributeOnElement(openingElement, 'v2')) return;\n\n const hasJSXChildren = path.node.children?.some(\n (child) =>\n (child.type === 'JSXText' && child.value.trim() !== '') ||\n child.type === 'JSXElement' ||\n (child.type === 'JSXFragment' && child.children && child.children.length > 0) ||\n (child.type === 'JSXExpressionContainer' &&\n child.expression.type !== 'JSXEmptyExpression'),\n );\n const hasChildrenAsProp = openingElement.attributes?.some(\n (attr) =>\n attr.type === 'JSXAttribute' &&\n attr.name?.type === 'JSXIdentifier' &&\n attr.name.name === 'children',\n );\n if (!hasJSXChildren && !hasChildrenAsProp) 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 const expressionSource = String(j(attr.value.expression).toSource());\n legacyProps[name] = expressionSource;\n }\n } else {\n legacyProps[name] = undefined;\n }\n }\n }\n });\n\n if ('size' in legacyProps) {\n const rawValue = legacyProps.size;\n\n if (typeof rawValue === 'string' && isEnumValue(rawValue)) {\n const equivalent = getEnumEquivalent(rawValue);\n const supportedSizes = ['sm', 'md', 'lg', 'xl'];\n\n if (equivalent && supportedSizes.includes(equivalent)) {\n } else {\n reporter.reportUnsupportedValue(path, 'size', rawValue);\n }\n } else {\n const resolved = resolveSize(rawValue);\n const supportedSizes = ['sm', 'md', 'lg', 'xl'];\n if (\n typeof rawValue === 'string' &&\n typeof resolved === 'string' &&\n supportedSizes.includes(resolved)\n ) {\n removeAttributeByName(j, openingElement, 'size');\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\n if ('priority' in legacyProps) {\n const rawValue = legacyProps.priority;\n\n if (typeof rawValue === 'string' && isEnumValue(rawValue)) {\n const equivalent = getEnumEquivalent(rawValue);\n const supportedPriorities = ['primary', 'secondary', 'tertiary', 'secondary-neutral'];\n\n if (equivalent && supportedPriorities.includes(equivalent)) {\n } else {\n reporter.reportUnsupportedValue(path, 'priority', rawValue);\n }\n } else {\n const converted = convertEnumValue(rawValue);\n const mapped = resolvePriority(legacyProps.type, converted);\n const supportedPriorities = ['primary', 'secondary', 'tertiary', 'secondary-neutral'];\n if (\n typeof rawValue === 'string' &&\n typeof mapped === 'string' &&\n supportedPriorities.includes(mapped)\n ) {\n removeAttributeByName(j, openingElement, 'priority');\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\n if ('type' in legacyProps || 'htmlType' in legacyProps) {\n const rawType = legacyProps.type;\n const rawHtmlType = legacyProps.htmlType;\n\n let resolvedType: string | undefined;\n let isTypeEnum = false;\n let isControlTypeEnum = false;\n\n if (typeof rawType === 'string' && isEnumValue(rawType)) {\n isTypeEnum = true;\n const equivalent = getEnumEquivalent(rawType);\n resolvedType = equivalent;\n isControlTypeEnum = rawType.startsWith('ControlType.');\n\n if (!isControlTypeEnum) {\n reporter.reportUnsupportedValue(path, 'type', rawType);\n }\n } else {\n let typeValue: string | undefined;\n if (typeof rawType === 'string') {\n typeValue = rawType;\n } else if (rawType && typeof rawType === 'object') {\n typeValue = convertEnumValue(j(rawType).toSource());\n }\n resolvedType = typeValue;\n }\n\n let finalHtmlType = null;\n if (resolvedType && !legacyButtonTypes.includes(resolvedType)) {\n finalHtmlType = resolvedType;\n }\n\n if (rawHtmlType) {\n finalHtmlType = rawHtmlType;\n }\n\n const htmlTypes = ['submit', 'button', 'reset'];\n\n if (resolvedType === 'negative' && isControlTypeEnum) {\n removeAttributeByName(j, openingElement, 'type');\n\n if (hasAttributeOnElement(openingElement, 'sentiment')) {\n removeAttributeByName(j, openingElement, 'sentiment');\n }\n\n addAttributesIfMissing(j, openingElement, [\n {\n attribute: j.jsxAttribute(j.jsxIdentifier('priority'), j.literal('primary')),\n name: 'priority',\n },\n ]);\n\n // Keep as enum\n if (rawType) {\n openingElement.attributes?.push(\n j.jsxAttribute(\n j.jsxIdentifier('sentiment'),\n j.jsxExpressionContainer(j.identifier(rawType)),\n ),\n );\n }\n } else if (resolvedType === 'negative' && !isTypeEnum) {\n // String literal 'negative'\n removeAttributeByName(j, openingElement, 'type');\n\n if (hasAttributeOnElement(openingElement, 'sentiment')) {\n removeAttributeByName(j, openingElement, 'sentiment');\n }\n\n openingElement.attributes?.push(\n j.jsxAttribute(j.jsxIdentifier('sentiment'), j.literal('negative')),\n );\n } else if (\n isControlTypeEnum &&\n resolvedType &&\n ['positive', 'accent'].includes(resolvedType)\n ) {\n removeAttributeByName(j, openingElement, 'type');\n addAttributesIfMissing(j, openingElement, [\n {\n attribute: j.jsxAttribute(j.jsxIdentifier('priority'), j.literal('primary')),\n name: 'priority',\n },\n ]);\n }\n\n if (\n resolvedType &&\n typeof resolvedType === 'string' &&\n legacyButtonTypes.includes(resolvedType) &&\n !isTypeEnum // Don't convert if it's an enum\n ) {\n const consistentConversion = getConsistentTypeConversions(resolvedType);\n\n if (consistentConversion) {\n removeAttributeByName(j, openingElement, 'type');\n removeAttributeByName(j, openingElement, 'priority');\n removeAttributeByName(j, openingElement, 'sentiment');\n\n if (consistentConversion.priority) {\n openingElement.attributes?.push(\n j.jsxAttribute(\n j.jsxIdentifier('priority'),\n j.literal(consistentConversion.priority),\n ),\n );\n }\n if (consistentConversion.sentiment) {\n openingElement.attributes?.push(\n j.jsxAttribute(\n j.jsxIdentifier('sentiment'),\n j.literal(consistentConversion.sentiment),\n ),\n );\n }\n } else {\n // if priority is present, then type is already handled. if not, add priority. always remove legacy type\n removeAttributeByName(j, openingElement, 'type');\n addAttributesIfMissing(j, openingElement, [\n {\n attribute: j.jsxAttribute(j.jsxIdentifier('priority'), j.literal('primary')),\n name: 'priority',\n },\n ]);\n }\n } else if (isTypeEnum) {\n // Enum value that isn't a supported control type - keep it as-is (already reported above)\n // Don't modify the attribute\n }\n\n // Handle htmlType conversion to type\n if (typeof finalHtmlType === 'string' && htmlTypes.includes(finalHtmlType)) {\n removeAttributeByName(j, openingElement, 'htmlType');\n openingElement.attributes?.push(\n j.jsxAttribute(j.jsxIdentifier('type'), j.literal(finalHtmlType)),\n );\n } else if (typeof rawType === 'string' || typeof rawHtmlType === 'string') {\n const valueToCheck = rawType ?? rawHtmlType ?? '';\n const legacyTypes = [\n 'accent',\n 'positive',\n 'negative',\n 'primary',\n 'secondary',\n 'danger',\n 'link',\n ];\n\n if (!legacyTypes.includes(valueToCheck)) {\n reporter.reportUnsupportedValue(path, 'type', valueToCheck);\n }\n } else if (rawType !== undefined || rawHtmlType !== undefined) {\n // Report ambiguous if we cannot determine the value\n reporter.reportAmbiguousExpression(\n path,\n typeof rawType === 'string' ? 'type' : 'htmlType',\n );\n }\n }\n\n // Handle sentiment prop\n if ('sentiment' in legacyProps) {\n const hasSentimentAttribute = openingElement.attributes?.some(\n (attr) => attr.type === 'JSXAttribute' && attr.name && attr.name.name === 'sentiment',\n );\n\n if (!hasSentimentAttribute) {\n const rawValue = legacyProps.sentiment;\n\n if (rawValue === 'negative') {\n removeAttributeByName(j, openingElement, 'sentiment');\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\n // Handle as prop and href\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 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 === 'a') {\n if (asIndex !== -1) {\n openingElement.attributes = openingElement.attributes?.filter(\n (_attr, 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":";;;;;;;AAKA,SAAS,UACP,MACA,aACA,YACA,GACM;CACN,MAAM,kBAAkB,KAAK,KAAK,EAAE,mBAAmB,EACrD,QAAQ,EAAE,OAAO,aAAa,EAC/B,CAAC;AAEF,KAAI,gBAAgB,MAAM,GAAG,GAAG;AAK9B,MAJoB,gBAAgB,KAAK,EAAE,iBAAiB,EAC1D,UAAU,EAAE,MAAM,YAAY,EAC/B,CAAC,CAEc,MAAM,GAAG,EACvB;AAGF,kBAAgB,SAAS,SAAS;AAChC,OAAI,KAAK,KAAK,WACZ,MAAK,KAAK,WAAW,KAAK,EAAE,gBAAgB,EAAE,WAAW,WAAW,CAAC,CAAC;IAExE;QACG;EACL,MAAM,YAAY,EAAE,kBAClB,CAAC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ReviewIssues: string[]","hasImport","legacyProps: LegacyProps","resolvedType: string | undefined","typeValue: string | undefined","asValue: string | null","reportManualReview"],"sources":["../../../src/helpers/addImport.ts","../../../src/helpers/hasImport.ts","../../../src/helpers/iconUtils.ts","../../../src/helpers/jsxElementUtils.ts","../../../src/helpers/jsxReportingUtils.ts","../../../src/transforms/button/transformer.ts"],"sourcesContent":["import type { Collection, JSCodeshift } from 'jscodeshift';\n\n/**\n * Adds a named import if it doesn't already exist.\n */\nfunction addImport(\n root: Collection,\n sourceValue: string,\n importName: string,\n j: JSCodeshift,\n): void {\n const existingImports = root.find(j.ImportDeclaration, {\n source: { value: sourceValue },\n });\n\n if (existingImports.size() > 0) {\n const namedImport = existingImports.find(j.ImportSpecifier, {\n imported: { name: importName },\n });\n\n if (namedImport.size() > 0) {\n return;\n }\n\n existingImports.forEach((path) => {\n if (path.node.specifiers) {\n path.node.specifiers.push(j.importSpecifier(j.identifier(importName)));\n }\n });\n } else {\n const newImport = j.importDeclaration(\n [j.importSpecifier(j.identifier(importName))],\n j.literal(sourceValue),\n );\n\n const firstImport = root.find(j.ImportDeclaration).at(0);\n if (firstImport.size() > 0) {\n firstImport.insertBefore(newImport);\n } else {\n // Insert at the beginning of the program\n const program = root.find(j.Program);\n if (program.size() > 0) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access\n program.get('body', 0).insertBefore(newImport);\n }\n }\n }\n}\n\nexport default addImport;\n","import type { ASTPath, Collection, ImportSpecifier, 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): {\n exists: boolean;\n remove: () => void;\n aliases?: Collection<ImportSpecifier>;\n resolvedName: string;\n conflictingImports: ImportSpecifier[];\n} {\n const importDeclarations = root.find(j.ImportDeclaration, {\n source: { value: sourceValue },\n });\n\n /**\n * Finds all ImportSpecifier nodes that expose `importName` but\n * from a different source than `sourceValue`.\n */\n const conflictingImports = ((): ImportSpecifier[] => {\n const result: ImportSpecifier[] = [];\n root\n .find(j.ImportDeclaration)\n .filter((path) => path.node.source.value !== sourceValue)\n .forEach((path) => {\n for (const specifier of path.node.specifiers ?? []) {\n if (\n specifier.type === 'ImportSpecifier' &&\n specifier.imported.name === importName &&\n specifier.local?.name === importName\n ) {\n result.push(specifier);\n }\n }\n });\n return result;\n })();\n\n if (importDeclarations.size() === 0) {\n return {\n exists: false,\n remove: () => {},\n resolvedName: importName,\n conflictingImports,\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 aliasImport = importDeclarations.find(j.ImportSpecifier).filter((path) => {\n return (\n path.node.imported.name === importName && path.node.imported.name !== path.node.local?.name\n );\n });\n\n const exists = namedImport.size() > 0 || defaultImport.size() > 0;\n\n const resolveName = (): string => {\n if (aliasImport.size() > 0) {\n const importPath = aliasImport.get(0) as ASTPath<ImportSpecifier>;\n const localName = importPath.node.local?.name;\n\n if (typeof localName === 'string') {\n return localName;\n }\n\n if (\n localName &&\n typeof localName === 'object' &&\n 'name' in localName &&\n typeof localName.name === 'string'\n ) {\n return localName.name;\n }\n\n return importName;\n }\n\n return importName;\n };\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 {\n exists,\n remove,\n aliases: aliasImport,\n resolvedName: resolveName(),\n conflictingImports,\n };\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 Collection,\n ImportSpecifier,\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\n/**\n * Returns a collection of JSX elements that match the specified\n * exported name or names of the found aliases.\n */\nexport const findJSXElementsByName =\n (root: Collection, j: JSCodeshift) =>\n (exportedName: string, aliases?: Collection<ImportSpecifier>) => {\n const aliasNames = aliases?.size()\n ? aliases.paths().map((path) => path.node.local?.name as string)\n : [];\n\n return root.find(j.JSXElement).filter((path) => {\n const { name } = path.node.openingElement;\n return (\n name.type === 'JSXIdentifier' &&\n (name.name === exportedName || aliasNames.includes(name.name))\n );\n });\n };\n\n/**\n * Removes an attribute by name from a JSX element's openingElement.\n */\nexport const removeAttributeByName = (\n j: JSCodeshift,\n openingElement: JSXElement['openingElement'],\n attributeName: string,\n) => {\n if (!Array.isArray(openingElement.attributes)) return;\n // eslint-disable-next-line no-param-reassign\n openingElement.attributes = openingElement.attributes.filter((attr) => {\n return !(\n attr.type === 'JSXAttribute' &&\n attr.name.type === 'JSXIdentifier' &&\n attr.name.name === attributeName\n );\n });\n};\n","import type {\n ASTPath,\n ImportSpecifier,\n JSCodeshift,\n JSXAttribute,\n JSXElement,\n Node,\n} 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 /**\n * Finds and reports instances of components that are under an alias (imported with a different name)\n */\n reportAliases(element: JSXElement | ASTPath<JSXElement>): void {\n this.reportElement(element, 'is used via an import alias and needs manual review');\n }\n\n /**\n * Finds and reports instances of non-DS import declarations that conflict with the component name\n */\n reportConflictingImports(node: ImportSpecifier): void {\n this.addIssue(\n `Manual review required: Non-WDS package resulting in an import conflict at line ${this.getLineNumber(node)}.`,\n );\n }\n\n /**\n * Reports enum usage for future conversion tracking\n */\n reportEnumUsage(\n element: JSXElement | ASTPath<JSXElement>,\n propName: string,\n enumValue: string,\n ): void {\n this.reportProp(\n element,\n propName,\n `uses enum value \"${enumValue}\" which has been preserved but should be migrated to a string literal in the future`,\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 '../../controller/helpers';\nimport {\n addAttributesIfMissing,\n addImport,\n createReporter,\n findJSXElementsByName,\n hasAttributeOnElement,\n hasImport,\n processIconChildren,\n removeAttributeByName,\n setNameIfJSXIdentifier,\n} from '../../helpers';\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\ninterface ExtendedOptions extends Options {\n accentSecondaryMapping?: string;\n positiveSecondaryMapping?: string;\n}\n\ntype PriorityMapping = Record<string, Record<string, string>>;\n\nconst buildPriorityMapping = (opts: Options): PriorityMapping => {\n const extendedOpts = opts as ExtendedOptions;\n const accentSecondary = extendedOpts.accentSecondaryMapping || 'secondary-neutral';\n const positiveSecondary = extendedOpts.positiveSecondaryMapping || 'secondary-neutral';\n return {\n accent: {\n primary: 'primary',\n secondary: accentSecondary,\n tertiary: 'tertiary',\n },\n positive: {\n primary: 'primary',\n secondary: positiveSecondary,\n tertiary: positiveSecondary,\n },\n negative: {\n primary: 'primary',\n secondary: 'secondary',\n tertiary: 'secondary',\n },\n primary: {\n primary: 'primary',\n secondary: accentSecondary,\n tertiary: 'tertiary',\n },\n pay: {\n primary: 'primary',\n secondary: accentSecondary,\n tertiary: accentSecondary,\n },\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 legacyButtonTypes = [\n 'accent',\n 'negative',\n 'positive',\n 'primary',\n 'pay',\n 'secondary',\n 'danger',\n 'link',\n];\n\nconst getConsistentTypeConversions = (\n type?: string,\n): { priority?: string; sentiment?: string } | null => {\n const consistentTypeConversions: Record<string, { priority?: string; sentiment?: string }> = {\n secondary: { priority: 'secondary-neutral' },\n link: { priority: 'tertiary' },\n danger: { priority: 'secondary', sentiment: 'negative' },\n };\n\n return consistentTypeConversions[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 * Detects if a value is an enum pattern (e.g., Priority.PRIMARY, ControlType.ACCENT, Size.LARGE, Type.PRIMARY)\n */\nconst isEnumValue = (value: string): boolean => {\n const enumPatterns = [\n /^Priority\\.(PRIMARY|SECONDARY|TERTIARY|SECONDARY_NEUTRAL)$/u,\n /^ControlType\\.(ACCENT|NEGATIVE|POSITIVE)$/u,\n /^Size\\.(EXTRA_SMALL|SMALL|MEDIUM|LARGE|EXTRA_LARGE)$/u,\n /^Type\\.(PRIMARY|SECONDARY|TERTIARY|PAY|DANGER|LINK|ACCENT|POSITIVE|NEGATIVE)$/u,\n ];\n return enumPatterns.some((pattern) => pattern.test(value));\n};\n\n/**\n * Maps enum values to their expected string equivalents for validation purposes\n * This is ONLY used to validate the enum maps to a supported value\n */\nconst getEnumEquivalent = (value: string): string | undefined => {\n const enumMapping: Record<string, string> = {\n 'Priority.PRIMARY': 'primary',\n 'Priority.SECONDARY': 'secondary',\n 'Priority.TERTIARY': 'tertiary',\n 'Priority.SECONDARY_NEUTRAL': 'secondary-neutral',\n 'ControlType.NEGATIVE': 'negative',\n 'ControlType.POSITIVE': 'positive',\n 'ControlType.ACCENT': 'accent',\n 'Size.EXTRA_SMALL': 'sm',\n 'Size.SMALL': 'sm',\n 'Size.MEDIUM': 'md',\n 'Size.LARGE': 'lg',\n 'Size.EXTRA_LARGE': 'xl',\n };\n return enumMapping[value];\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 const priorityMapping = buildPriorityMapping(options);\n\n const resolvePriority = (type?: string, priority?: string): string | undefined => {\n if (type && priority) {\n return priorityMapping[type]?.[priority] || priority;\n }\n return priority;\n };\n\n // Create reporter instance\n const reporter = createReporter(j, manualReviewIssues);\n\n const {\n exists: hasButtonImport,\n aliases: buttonAliases,\n resolvedName: buttonName,\n conflictingImports: conflictingButtonImport,\n } = hasImport(root, '@transferwise/components', 'Button', j);\n\n if (conflictingButtonImport.length) {\n conflictingButtonImport.forEach((node) => reporter.reportConflictingImports(node));\n }\n\n const {\n exists: hasActionButtonImport,\n remove: removeActionButtonImport,\n aliases: actionButtonAliases,\n } = hasImport(root, '@transferwise/components', 'ActionButton', j);\n\n if (!hasButtonImport && !hasActionButtonImport) {\n return file.source;\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 if (!hasButtonImport) {\n addImport(root, '@transferwise/components', 'Button', j);\n }\n\n const instances = findJSXElementsByName(root, j)('ActionButton', actionButtonAliases);\n\n instances.forEach((path) => {\n const { openingElement, closingElement } = path.node;\n\n openingElement.name = setNameIfJSXIdentifier(openingElement.name, buttonName)!;\n if (closingElement) {\n closingElement.name = setNameIfJSXIdentifier(closingElement.name, buttonName)!;\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', 'size'];\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 legacyProps[name] = convertEnumValue(String(j(attr.value.expression).toSource()));\n }\n }\n }\n }\n });\n\n const hasTextProp = 'text' in legacyProps;\n const hasChildren =\n path.node.children?.some(\n (child) =>\n (child.type === 'JSXText' && child.value.trim() !== '') ||\n child.type === 'JSXElement' ||\n child.type === 'JSXExpressionContainer',\n ) ||\n (path.node.children && path.node.children?.length > 0);\n\n if (hasTextProp && hasChildren) {\n reporter.reportPropWithChildren(path, 'text');\n } else if (hasTextProp && !hasChildren && openingElement.selfClosing) {\n // Self-closing tag with text prop but no children, so we can convert to a normal element with children\n path.replace(\n j.jsxElement(\n j.jsxOpeningElement(openingElement.name, openingElement.attributes),\n j.jsxClosingElement(openingElement.name),\n [j.jsxText((legacyProps.text as string) || '')],\n ),\n );\n }\n\n addAttributesIfMissing(j, path.node.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 (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 const instances = findJSXElementsByName(root, j)('Button', buttonAliases);\n\n instances.forEach((path) => {\n const { openingElement } = path.node;\n\n if (hasAttributeOnElement(openingElement, 'v2')) return;\n\n const hasJSXChildren = path.node.children?.some(\n (child) =>\n (child.type === 'JSXText' && child.value.trim() !== '') ||\n child.type === 'JSXElement' ||\n (child.type === 'JSXFragment' && child.children && child.children.length > 0) ||\n (child.type === 'JSXExpressionContainer' &&\n child.expression.type !== 'JSXEmptyExpression'),\n );\n const hasChildrenAsProp = openingElement.attributes?.some(\n (attr) =>\n attr.type === 'JSXAttribute' &&\n attr.name?.type === 'JSXIdentifier' &&\n attr.name.name === 'children',\n );\n if (!hasJSXChildren && !hasChildrenAsProp) 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 const expressionSource = String(j(attr.value.expression).toSource());\n legacyProps[name] = expressionSource;\n }\n } else {\n legacyProps[name] = undefined;\n }\n }\n }\n });\n\n if ('size' in legacyProps) {\n const rawValue = legacyProps.size;\n\n if (typeof rawValue === 'string' && isEnumValue(rawValue)) {\n const equivalent = getEnumEquivalent(rawValue);\n const supportedSizes = ['sm', 'md', 'lg', 'xl'];\n\n if (equivalent && supportedSizes.includes(equivalent)) {\n } else {\n reporter.reportUnsupportedValue(path, 'size', rawValue);\n }\n } else {\n const resolved = resolveSize(rawValue);\n const supportedSizes = ['sm', 'md', 'lg', 'xl'];\n if (\n typeof rawValue === 'string' &&\n typeof resolved === 'string' &&\n supportedSizes.includes(resolved)\n ) {\n removeAttributeByName(j, openingElement, 'size');\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\n if ('priority' in legacyProps) {\n const rawValue = legacyProps.priority;\n\n if (typeof rawValue === 'string' && isEnumValue(rawValue)) {\n const equivalent = getEnumEquivalent(rawValue);\n const supportedPriorities = ['primary', 'secondary', 'tertiary', 'secondary-neutral'];\n\n if (equivalent && supportedPriorities.includes(equivalent)) {\n } else {\n reporter.reportUnsupportedValue(path, 'priority', rawValue);\n }\n } else {\n const converted = convertEnumValue(rawValue);\n const mapped = resolvePriority(legacyProps.type, converted);\n const supportedPriorities = ['primary', 'secondary', 'tertiary', 'secondary-neutral'];\n if (\n typeof rawValue === 'string' &&\n typeof mapped === 'string' &&\n supportedPriorities.includes(mapped)\n ) {\n removeAttributeByName(j, openingElement, 'priority');\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\n if ('type' in legacyProps || 'htmlType' in legacyProps) {\n const rawType = legacyProps.type;\n const rawHtmlType = legacyProps.htmlType;\n\n let resolvedType: string | undefined;\n let isTypeEnum = false;\n let isControlTypeEnum = false;\n\n if (typeof rawType === 'string' && isEnumValue(rawType)) {\n isTypeEnum = true;\n const equivalent = getEnumEquivalent(rawType);\n resolvedType = equivalent;\n isControlTypeEnum = rawType.startsWith('ControlType.');\n\n if (!isControlTypeEnum) {\n reporter.reportUnsupportedValue(path, 'type', rawType);\n }\n } else {\n let typeValue: string | undefined;\n if (typeof rawType === 'string') {\n typeValue = rawType;\n } else if (rawType && typeof rawType === 'object') {\n typeValue = convertEnumValue(j(rawType).toSource());\n }\n resolvedType = typeValue;\n }\n\n let finalHtmlType = null;\n if (resolvedType && !legacyButtonTypes.includes(resolvedType)) {\n finalHtmlType = resolvedType;\n }\n\n if (rawHtmlType) {\n finalHtmlType = rawHtmlType;\n }\n\n const htmlTypes = ['submit', 'button', 'reset'];\n\n if (resolvedType === 'negative' && isControlTypeEnum) {\n removeAttributeByName(j, openingElement, 'type');\n\n if (hasAttributeOnElement(openingElement, 'sentiment')) {\n removeAttributeByName(j, openingElement, 'sentiment');\n }\n\n addAttributesIfMissing(j, openingElement, [\n {\n attribute: j.jsxAttribute(j.jsxIdentifier('priority'), j.literal('primary')),\n name: 'priority',\n },\n ]);\n\n // Keep as enum\n if (rawType) {\n openingElement.attributes?.push(\n j.jsxAttribute(\n j.jsxIdentifier('sentiment'),\n j.jsxExpressionContainer(j.identifier(rawType)),\n ),\n );\n }\n } else if (resolvedType === 'negative' && !isTypeEnum) {\n // String literal 'negative'\n removeAttributeByName(j, openingElement, 'type');\n\n if (hasAttributeOnElement(openingElement, 'sentiment')) {\n removeAttributeByName(j, openingElement, 'sentiment');\n }\n\n openingElement.attributes?.push(\n j.jsxAttribute(j.jsxIdentifier('sentiment'), j.literal('negative')),\n );\n } else if (\n isControlTypeEnum &&\n resolvedType &&\n ['positive', 'accent'].includes(resolvedType)\n ) {\n removeAttributeByName(j, openingElement, 'type');\n addAttributesIfMissing(j, openingElement, [\n {\n attribute: j.jsxAttribute(j.jsxIdentifier('priority'), j.literal('primary')),\n name: 'priority',\n },\n ]);\n }\n\n if (\n resolvedType &&\n typeof resolvedType === 'string' &&\n legacyButtonTypes.includes(resolvedType) &&\n !isTypeEnum // Don't convert if it's an enum\n ) {\n const consistentConversion = getConsistentTypeConversions(resolvedType);\n\n if (consistentConversion) {\n removeAttributeByName(j, openingElement, 'type');\n removeAttributeByName(j, openingElement, 'priority');\n removeAttributeByName(j, openingElement, 'sentiment');\n\n if (consistentConversion.priority) {\n openingElement.attributes?.push(\n j.jsxAttribute(\n j.jsxIdentifier('priority'),\n j.literal(consistentConversion.priority),\n ),\n );\n }\n if (consistentConversion.sentiment) {\n openingElement.attributes?.push(\n j.jsxAttribute(\n j.jsxIdentifier('sentiment'),\n j.literal(consistentConversion.sentiment),\n ),\n );\n }\n } else {\n // if priority is present, then type is already handled. if not, add priority. always remove legacy type\n removeAttributeByName(j, openingElement, 'type');\n addAttributesIfMissing(j, openingElement, [\n {\n attribute: j.jsxAttribute(j.jsxIdentifier('priority'), j.literal('primary')),\n name: 'priority',\n },\n ]);\n }\n } else if (isTypeEnum) {\n // Enum value that isn't a supported control type - keep it as-is (already reported above)\n // Don't modify the attribute\n }\n\n // Handle htmlType conversion to type\n if (typeof finalHtmlType === 'string' && htmlTypes.includes(finalHtmlType)) {\n removeAttributeByName(j, openingElement, 'htmlType');\n openingElement.attributes?.push(\n j.jsxAttribute(j.jsxIdentifier('type'), j.literal(finalHtmlType)),\n );\n } else if (typeof rawType === 'string' || typeof rawHtmlType === 'string') {\n const valueToCheck = rawType ?? rawHtmlType ?? '';\n const legacyTypes = [\n 'accent',\n 'positive',\n 'negative',\n 'primary',\n 'secondary',\n 'danger',\n 'link',\n ];\n\n if (!legacyTypes.includes(valueToCheck)) {\n reporter.reportUnsupportedValue(path, 'type', valueToCheck);\n }\n } else if (rawType !== undefined || rawHtmlType !== undefined) {\n // Report ambiguous if we cannot determine the value\n reporter.reportAmbiguousExpression(\n path,\n typeof rawType === 'string' ? 'type' : 'htmlType',\n );\n }\n }\n\n // Handle sentiment prop\n if ('sentiment' in legacyProps) {\n const hasSentimentAttribute = openingElement.attributes?.some(\n (attr) => attr.type === 'JSXAttribute' && attr.name && attr.name.name === 'sentiment',\n );\n\n if (!hasSentimentAttribute) {\n const rawValue = legacyProps.sentiment;\n\n if (rawValue === 'negative') {\n removeAttributeByName(j, openingElement, 'sentiment');\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\n // Handle as prop and href\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 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 === 'a') {\n if (asIndex !== -1) {\n openingElement.attributes = openingElement.attributes?.filter(\n (_attr, 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":";;;;;;;AAKA,SAAS,UACP,MACA,aACA,YACA,GACM;CACN,MAAM,kBAAkB,KAAK,KAAK,EAAE,mBAAmB,EACrD,QAAQ,EAAE,OAAO,aAAa,EAC/B,CAAC;AAEF,KAAI,gBAAgB,MAAM,GAAG,GAAG;AAK9B,MAJoB,gBAAgB,KAAK,EAAE,iBAAiB,EAC1D,UAAU,EAAE,MAAM,YAAY,EAC/B,CAAC,CAEc,MAAM,GAAG,EACvB;AAGF,kBAAgB,SAAS,SAAS;AAChC,OAAI,KAAK,KAAK,WACZ,MAAK,KAAK,WAAW,KAAK,EAAE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name": "@wise/wds-codemods",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0-experimental-f15e55a",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "Wise Payments Ltd.",
|
|
6
6
|
"repository": {
|
|
@@ -34,10 +34,12 @@
|
|
|
34
34
|
"test:watch": "jest --watch"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
+
"@anthropic-ai/claude-agent-sdk": "^0.1.30",
|
|
37
38
|
"@inquirer/prompts": "^7.8.6",
|
|
38
39
|
"jscodeshift": "^17.3"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
42
|
+
"@anthropic-ai/sdk": "^0.68.0",
|
|
41
43
|
"@babel/core": "^7.28.4",
|
|
42
44
|
"@babel/plugin-syntax-import-meta": "^7.10.4",
|
|
43
45
|
"@babel/preset-env": "^7.28.3",
|