@wise/wds-codemods 1.0.0-experimental-ac14bc8 → 1.0.0-experimental-e09ad51

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.
@@ -1,383 +0,0 @@
1
- const require_chunk = require('./chunk-CInkuQNp.js');
2
- let node_child_process = require("node:child_process");
3
- let node_path = require("node:path");
4
- let ora = require("ora");
5
- ora = require_chunk.__toESM(ora);
6
- let node_fs = require("node:fs");
7
- let __anthropic_ai_claude_agent_sdk = require("@anthropic-ai/claude-agent-sdk");
8
- let node_https = require("node:https");
9
- node_https = require_chunk.__toESM(node_https);
10
-
11
- //#region src/constants.ts
12
- const CONSOLE_ICONS = {
13
- info: "\x1B[34mℹ\x1B[0m",
14
- focus: "\x1B[34m➙\x1B[0m",
15
- success: "\x1B[32m✔\x1B[0m",
16
- warning: "\x1B[33m⚠\x1B[0m",
17
- error: "\x1B[31m✖\x1B[0m"
18
- };
19
-
20
- //#endregion
21
- //#region src/transforms/list-item/constants.ts
22
- const DEPRECATED_COMPONENT_NAMES = [
23
- "ActionOption",
24
- "NavigationOption",
25
- "NavigationOptionsList",
26
- "Summary",
27
- "SwitchOption",
28
- "CheckboxOption",
29
- "RadioOption"
30
- ];
31
- const MIGRATION_RULES = `Migration rules:
32
- # Legacy Component → ListItem Migration Guide
33
-
34
- ## Universal Rules
35
-
36
- 1. \`title\` → \`title\` (direct)
37
- 2. \`content\` or \`description\` → \`subtitle\`
38
- 3. \`disabled\` stays on \`ListItem\` (not controls)
39
- 4. Keep HTML attributes (\`id\`, \`name\`, \`aria-label\`), remove: \`as\`, \`complex\`, \`showMediaAtAllSizes\`, \`showMediaCircle\`, \`isContainerAligned\`
40
- 5. In strings, don't convert \`\`to\`'\`or\`"\`. Preserve what is there.
41
-
42
- ---
43
-
44
- ## ActionOption → ListItem.Button
45
-
46
- - \`action\` → Button children
47
- - \`onClick\` → Button \`onClick\`
48
- - Priority: default/\`"primary"\` → \`"primary"\`, \`"secondary"\` → \`"secondary-neutral"\`, \`"secondary-send"\` → \`"secondary"\`, \`"tertiary"\` → \`"tertiary"\`
49
-
50
- \`\`\`tsx
51
- <ActionOption title="Title" content="Text" action="Click" priority="secondary" onClick={fn} />
52
-
53
- <ListItem title="Title" subtitle="Text" control={<ListItem.Button priority="secondary-neutral" onClick={fn}>Click</ListItem.Button>} />
54
- \`\`\`
55
-
56
- ---
57
-
58
- ## CheckboxOption → ListItem.Checkbox
59
-
60
- - \`onChange\`: \`(checked: boolean)\` → \`(event: ChangeEvent)\` use \`event.target.checked\`
61
- - \`name\` move to Checkbox
62
- - Don't move \`id\` to Checkbox
63
-
64
- \`\`\`tsx
65
- <CheckboxOption id="x" name="y" title="Title" content="Text" checked={v} onChange={(c) => set(c)} />
66
-
67
- <ListItem title="Title" subtitle="Text" control={<ListItem.Checkbox name="y" checked={v} onChange={(e) => set(e.target.checked)} />} />
68
- \`\`\`
69
-
70
- ---
71
-
72
- ## RadioOption → ListItem.Radio
73
-
74
- - \`name\`, \`value\`, \`checked\`, \`onChange\` move to Radio
75
- - Don't move \`id\` to Radio
76
-
77
- \`\`\`tsx
78
- <RadioOption id="x" name="y" value="v" title="Title" content="Text" checked={v==='v'} onChange={set} />
79
-
80
- <ListItem title="Title" subtitle="Text" control={<ListItem.Radio name="y" value="v" checked={v==='v'} onChange={set} />} />
81
- \`\`\`
82
-
83
- ---
84
-
85
- ## SwitchOption → ListItem.Switch
86
-
87
- - \`onChange\` → \`onClick\`, toggle manually
88
- - \`aria-label\` moves to Switch
89
-
90
- \`\`\`tsx
91
- <SwitchOption title="Title" content="Text" checked={v} aria-label="Toggle" onChange={set} />
92
-
93
- <ListItem title="Title" subtitle="Text" control={<ListItem.Switch checked={v} aria-label="Toggle" onClick={() => set(!v)} />} />
94
- \`\`\`
95
-
96
- ---
97
-
98
- ## NavigationOption → ListItem.Navigation
99
-
100
- - \`onClick\` or \`href\` move to Navigation
101
-
102
- \`\`\`tsx
103
- <NavigationOption title="Title" content="Text" onClick={fn} />
104
-
105
- <ListItem title="Title" subtitle="Text" control={<ListItem.Navigation onClick={fn} />} />
106
- \`\`\`
107
-
108
- ---
109
-
110
- ## Option → ListItem
111
-
112
- - Wrap \`media\` in \`ListItem.AvatarView\`
113
-
114
- \`\`\`tsx
115
- <Option media={<Icon />} title="Title" />
116
-
117
- <ListItem title="Title" media={<ListItem.AvatarView><Icon /></ListItem.AvatarView>} />
118
- \`\`\`
119
-
120
- ---
121
-
122
- ## Summary → ListItem
123
-
124
- **Basic:**
125
-
126
- - \`icon\` → wrap in \`ListItem.AvatarView\` with \`size={32}\` as \`media\`
127
- - Remove \`size\` from child \`<Icon />\`
128
-
129
- **Status:**
130
-
131
- - \`Status.DONE\` → \`badge={{ status: 'positive' }}\`
132
- - \`Status.PENDING\` → \`badge={{ status: 'pending' }}\`
133
- - \`Status.NOT_DONE\` → no badge
134
-
135
- **Action:**
136
-
137
- - \`action.text\` → \`action.label\` in \`ListItem.AdditionalInfo\` as \`additionalInfo\`
138
-
139
- **Info (requires state):**
140
-
141
- - \`MODAL\` → \`ListItem.IconButton partiallyInteractive\` + \`<Modal>\` in \`control\`
142
- - \`POPOVER\` → \`<Popover>\` wrapping \`ListItem.IconButton partiallyInteractive\` in \`control\`
143
- - Use \`QuestionMarkCircle\` icon (import from \`@transferwise/icons\`)
144
-
145
- \`\`\`tsx
146
- // Basic
147
- <Summary title="T" description="D" icon={<Icon />} />
148
-
149
- <ListItem title="T" subtitle="D" media={<ListItem.AvatarView size={32}><Icon /></ListItem.AvatarView>} />
150
-
151
- // Status
152
- <Summary title="T" description="D" icon={<Icon />} status={Status.DONE} />
153
-
154
- <ListItem title="T" subtitle="D" media={<ListItem.AvatarView size={32} badge={{status:'positive'}}><Icon /></ListItem.AvatarView>} />
155
-
156
- // Action
157
- <Summary title="T" description="D" icon={<Icon />} action={{text:'Go', href:'/go'}} />
158
-
159
- <ListItem title="T" subtitle="D" media={<ListItem.AvatarView size={32}><Icon /></ListItem.AvatarView>} additionalInfo={<ListItem.AdditionalInfo action={{label:'Go', href:'/go'}} />} />
160
-
161
- // Modal (add: const [open, setOpen] = useState(false))
162
- <Summary title="T" description="D" icon={<Icon />} info={{title:'Help', content:'Text', presentation:'MODAL', 'aria-label':'Info'}} />
163
-
164
- <ListItem title="T" subtitle="D" media={<ListItem.AvatarView size={32}><Icon /></ListItem.AvatarView>} control={<ListItem.IconButton partiallyInteractive aria-label="Info" onClick={()=>setOpen(!open)}><QuestionMarkCircle /><Modal open={open} title="Help" body="Text" onClose={()=>setOpen(false)} /></ListItem.IconButton>} />
165
-
166
- // Popover
167
- <Summary title="T" description="D" icon={<Icon />} info={{title:'Help', content:'Text', presentation:'POPOVER', 'aria-label':'Info'}} />
168
-
169
- <ListItem title="T" subtitle="D" media={<ListItem.AvatarView size={32}><Icon /></ListItem.AvatarView>} control={<Popover title="Help" content="Text" onClose={()=>setOpen(false)}><ListItem.IconButton partiallyInteractive aria-label="Info"><QuestionMarkCircle /></ListItem.IconButton></Popover>} />
170
- \`\`\`
171
-
172
- ---
173
-
174
- ## DefinitionList → Multiple ListItem
175
-
176
- - Array → individual \`ListItem\`s
177
- - \`value\` → \`subtitle\`
178
- - \`key\` → React \`key\` prop
179
- - Action type: "Edit"/"Update"/"View" → \`ListItem.Button priority="secondary-neutral"\`, "Change"/"Password" → \`ListItem.Navigation\`, "Copy" → \`ListItem.IconButton\`
180
-
181
- \`\`\`tsx
182
- <DefinitionList definitions={[
183
- {title:'T1', value:'V1', key:'k1'},
184
- {title:'T2', value:'V2', key:'k2', action:{label:'Edit', onClick:fn}}
185
- ]} />
186
-
187
-
188
- <ListItem key="k1" title="T1" subtitle="V1" />
189
- <ListItem key="k2" title="T2" subtitle="V2" control={<ListItem.Button priority="secondary-neutral" onClick={fn}>Edit</ListItem.Button>} />
190
-
191
- \`\`\`
192
- `;
193
- 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'.
194
-
195
- Read and transform each file individually, instead of reading them all at the start. Only make a single edit or write per file, once you've fully processed it.
196
-
197
- Rules:
198
- 1. Ignore any files that do not contain deprecated WDS components, unless they are necessary for context.
199
- 2. Migrate components per provided migration rules
200
- 3. Maintain TypeScript type safety and update types to match new API
201
- 4. Map props: handle renamed, deprecated, new required, and changed types
202
- 5. Update imports to new WDS components and types
203
- 6. Preserve code style, formatting, and calculated logic
204
- 7. Handle conditional rendering, spread props, and complex expressions
205
- 8. Note: New components may lack feature parity with legacy versions
206
- 9. Only modify code requiring changes per migration rules, and any impacted surrounding code for context.
207
- 10. Provide only the transformed code as output, without explanations or additional text
208
- 11. Do not summarise the initial user request in a response.
209
- 12. Use glob or grep tool usage to find the files with deprecated components.
210
- 13. Final result response should just be whether the migration was successful overall, or if any errors were encountered
211
-
212
- Make the necessary updates to the files and do not respond with any explanations or reasoning.
213
-
214
- You'll receive:
215
- - File paths/directories to search in individual queries
216
- - Deprecated component names at the end of this prompt
217
- - Migration context and rules for each deprecated component
218
-
219
- Deprecated components: ${DEPRECATED_COMPONENT_NAMES.join(", ")}.
220
-
221
- ${MIGRATION_RULES}`;
222
-
223
- //#endregion
224
- //#region src/transforms/list-item/helpers.ts
225
- /** Split the path to get the relative path after the directory, and wrap with ANSI color codes */
226
- function formatPathOutput(directory, path) {
227
- return `\x1b[32m${path ? path.split(directory)[1] ?? path : directory}\x1b[0m`;
228
- }
229
- /** Generates a formatted string representing the total elapsed time since the given start time */
230
- function generateElapsedTime(startTime) {
231
- const endTime = Date.now();
232
- const elapsedTime = Math.floor((endTime - startTime) / 1e3);
233
- const hours = Math.floor(elapsedTime / 3600);
234
- const minutes = Math.floor(elapsedTime % 3600 / 60);
235
- const seconds = elapsedTime % 60;
236
- return `${hours ? `${hours}h ` : ""}${minutes ? `${minutes}m ` : ""}${seconds ? `${seconds}s` : ""}`;
237
- }
238
-
239
- //#endregion
240
- //#region src/transforms/list-item/claude.ts
241
- const CLAUDE_SETTINGS_FILE = ".claude/settings.json";
242
- async function checkVPN(baseUrl) {
243
- if (baseUrl) {
244
- const vpnSpinner = (0, ora.default)("Checking VPN connection...").start();
245
- const checkOnce = async () => await new Promise((resolveCheck) => {
246
- const url = new URL("/health", baseUrl);
247
- const req = node_https.default.get(url, {
248
- timeout: 2e3,
249
- rejectUnauthorized: false
250
- }, (res) => {
251
- const ok = !!(res.statusCode && res.statusCode >= 200 && res.statusCode < 400);
252
- res.resume();
253
- resolveCheck(ok);
254
- });
255
- req.on("timeout", () => {
256
- req.destroy(/* @__PURE__ */ new Error("timeout"));
257
- });
258
- req.on("error", () => resolveCheck(false));
259
- });
260
- while (true) {
261
- if (await checkOnce()) {
262
- vpnSpinner.succeed("Connected to VPN");
263
- break;
264
- }
265
- vpnSpinner.text = "Please connect to VPN... retrying in 3s";
266
- await new Promise((response) => {
267
- setTimeout(response, 3e3);
268
- });
269
- }
270
- }
271
- return true;
272
- }
273
- function getQueryOptions(sessionId, isDebug) {
274
- const claudeSettingsPath = (0, node_path.resolve)(process.env.HOME || "", CLAUDE_SETTINGS_FILE);
275
- const settings = JSON.parse((0, node_fs.readFileSync)(claudeSettingsPath, "utf-8"));
276
- let apiKey;
277
- try {
278
- apiKey = (0, node_child_process.execSync)(`bash ${settings.apiKeyHelper}`, { encoding: "utf-8" }).trim();
279
- } catch {}
280
- 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");
281
- const envVars = {
282
- ANTHROPIC_AUTH_TOKEN: apiKey,
283
- ANTHROPIC_BASE_URL: settings?.env?.ANTHROPIC_BASE_URL,
284
- ANTHROPIC_CUSTOM_HEADERS: settings?.env?.ANTHROPIC_CUSTOM_HEADERS,
285
- ANTHROPIC_DEFAULT_SONNET_MODEL: settings.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,
286
- ANTHROPIC_DEFAULT_HAIKU_MODEL: settings.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,
287
- ANTHROPIC_DEFAULT_OPUS_MODEL: settings.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,
288
- API_TIMEOUT_MS: settings.env?.API_TIMEOUT_MS,
289
- PATH: process.env.PATH
290
- };
291
- if (isDebug) {
292
- const { ANTHROPIC_AUTH_TOKEN, ...restVars } = envVars;
293
- console.log(`${CONSOLE_ICONS.info} Claude configuration environment variables:`, JSON.stringify(restVars));
294
- }
295
- return {
296
- resume: sessionId,
297
- env: envVars,
298
- permissionMode: "acceptEdits",
299
- systemPrompt: {
300
- type: "preset",
301
- preset: "claude_code",
302
- append: SYSTEM_PROMPT
303
- },
304
- settingSources: [
305
- "local",
306
- "project",
307
- "user"
308
- ]
309
- };
310
- }
311
- /** Initiate a new Claude session/conversation and return reusable options */
312
- async function initiateClaudeSessionOptions(isDebug = false) {
313
- const options = getQueryOptions(void 0, isDebug);
314
- await checkVPN(options.env?.ANTHROPIC_BASE_URL);
315
- const claudeSessionSpinner = (0, ora.default)("Starting Claude instance - your browser may open for Okta authentication if required.").start();
316
- const result = (0, __anthropic_ai_claude_agent_sdk.query)({
317
- options,
318
- prompt: `You'll be given directories in additional individual queries to search in for files using deprecated Wise Design System (WDS) components. Migrate the code per the provided migration rules.`
319
- });
320
- for await (const message of result) switch (message.type) {
321
- case "system":
322
- if (message.subtype === "init" && !options.resume) {
323
- claudeSessionSpinner.succeed("Successfully initialised Claude instance");
324
- options.resume = message.session_id;
325
- }
326
- break;
327
- default: if (message.type === "result" && message.subtype !== "success") claudeSessionSpinner.fail(`Claude encountered an error: ${message.errors.join("\n")}`);
328
- }
329
- return options;
330
- }
331
- async function queryClaude(path, options, isDebug = false) {
332
- const result = (0, __anthropic_ai_claude_agent_sdk.query)({
333
- options,
334
- prompt: path
335
- });
336
- const modifiedFiles = [];
337
- for await (const message of result) switch (message.type) {
338
- case "assistant":
339
- for (const msg of message.message.content) switch (msg.type) {
340
- case "tool_use":
341
- if (msg.name === "Glob" || msg.name === "Grep") console.log(`${CONSOLE_ICONS.focus} Processing directory: ${formatPathOutput(path)}...`);
342
- else if (msg.name === "Read") console.log(`${CONSOLE_ICONS.info} Reading ${formatPathOutput(path, msg.input.file_path)}`);
343
- else if ((msg.name === "Write" || msg.name === "Edit") && !modifiedFiles.includes(msg.input.file_path)) {
344
- modifiedFiles.push(msg.input.file_path);
345
- console.log(`${CONSOLE_ICONS.info} Migrated ${formatPathOutput(path, msg.input.file_path)}`);
346
- }
347
- break;
348
- default:
349
- }
350
- break;
351
- case "result":
352
- if (message.subtype === "success") console.log(`${CONSOLE_ICONS.success} Migrated all applicable files in ${formatPathOutput(path)}`);
353
- else console.log(`${CONSOLE_ICONS.error} Claude encountered an error: ${message.errors.join("\n").trim()}`);
354
- break;
355
- default:
356
- }
357
- }
358
-
359
- //#endregion
360
- //#region src/transforms/list-item/transformer.ts
361
- const transformer = async (targetPaths, isDebug = false) => {
362
- const startTime = Date.now();
363
- const queryOptions = await initiateClaudeSessionOptions(isDebug);
364
- console.log(`${CONSOLE_ICONS.info} Analysing targetted paths - this may take a while...`);
365
- for (const directory of targetPaths) await queryClaude(directory, queryOptions, isDebug);
366
- console.log(`${CONSOLE_ICONS.success} Finished migrating - elapsed time: \x1b[1m${generateElapsedTime(startTime)}\x1b[0m`);
367
- };
368
- var transformer_default = transformer;
369
-
370
- //#endregion
371
- Object.defineProperty(exports, 'CONSOLE_ICONS', {
372
- enumerable: true,
373
- get: function () {
374
- return CONSOLE_ICONS;
375
- }
376
- });
377
- Object.defineProperty(exports, 'transformer_default', {
378
- enumerable: true,
379
- get: function () {
380
- return transformer_default;
381
- }
382
- });
383
- //# sourceMappingURL=transformer-Bmoi_ztn.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transformer-Bmoi_ztn.js","names":["https","modifiedFiles: string[]"],"sources":["../src/constants.ts","../src/transforms/list-item/constants.ts","../src/transforms/list-item/helpers.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\nconst MIGRATION_RULES = `Migration rules:\n# Legacy Component → ListItem Migration Guide\n\n## Universal Rules\n\n1. \\`title\\` → \\`title\\` (direct)\n2. \\`content\\` or \\`description\\` → \\`subtitle\\`\n3. \\`disabled\\` stays on \\`ListItem\\` (not controls)\n4. Keep HTML attributes (\\`id\\`, \\`name\\`, \\`aria-label\\`), remove: \\`as\\`, \\`complex\\`, \\`showMediaAtAllSizes\\`, \\`showMediaCircle\\`, \\`isContainerAligned\\`\n5. In strings, don't convert \\`\\`to\\`'\\`or\\`\"\\`. Preserve what is there.\n\n---\n\n## ActionOption → ListItem.Button\n\n- \\`action\\` → Button children\n- \\`onClick\\` → Button \\`onClick\\`\n- Priority: default/\\`\"primary\"\\` → \\`\"primary\"\\`, \\`\"secondary\"\\` → \\`\"secondary-neutral\"\\`, \\`\"secondary-send\"\\` → \\`\"secondary\"\\`, \\`\"tertiary\"\\` → \\`\"tertiary\"\\`\n\n\\`\\`\\`tsx\n<ActionOption title=\"Title\" content=\"Text\" action=\"Click\" priority=\"secondary\" onClick={fn} />\n→\n<ListItem title=\"Title\" subtitle=\"Text\" control={<ListItem.Button priority=\"secondary-neutral\" onClick={fn}>Click</ListItem.Button>} />\n\\`\\`\\`\n\n---\n\n## CheckboxOption → ListItem.Checkbox\n\n- \\`onChange\\`: \\`(checked: boolean)\\` → \\`(event: ChangeEvent)\\` use \\`event.target.checked\\`\n- \\`name\\` move to Checkbox\n- Don't move \\`id\\` to Checkbox\n\n\\`\\`\\`tsx\n<CheckboxOption id=\"x\" name=\"y\" title=\"Title\" content=\"Text\" checked={v} onChange={(c) => set(c)} />\n→\n<ListItem title=\"Title\" subtitle=\"Text\" control={<ListItem.Checkbox name=\"y\" checked={v} onChange={(e) => set(e.target.checked)} />} />\n\\`\\`\\`\n\n---\n\n## RadioOption → ListItem.Radio\n\n- \\`name\\`, \\`value\\`, \\`checked\\`, \\`onChange\\` move to Radio\n- Don't move \\`id\\` to Radio\n\n\\`\\`\\`tsx\n<RadioOption id=\"x\" name=\"y\" value=\"v\" title=\"Title\" content=\"Text\" checked={v==='v'} onChange={set} />\n→\n<ListItem title=\"Title\" subtitle=\"Text\" control={<ListItem.Radio name=\"y\" value=\"v\" checked={v==='v'} onChange={set} />} />\n\\`\\`\\`\n\n---\n\n## SwitchOption → ListItem.Switch\n\n- \\`onChange\\` → \\`onClick\\`, toggle manually\n- \\`aria-label\\` moves to Switch\n\n\\`\\`\\`tsx\n<SwitchOption title=\"Title\" content=\"Text\" checked={v} aria-label=\"Toggle\" onChange={set} />\n→\n<ListItem title=\"Title\" subtitle=\"Text\" control={<ListItem.Switch checked={v} aria-label=\"Toggle\" onClick={() => set(!v)} />} />\n\\`\\`\\`\n\n---\n\n## NavigationOption → ListItem.Navigation\n\n- \\`onClick\\` or \\`href\\` move to Navigation\n\n\\`\\`\\`tsx\n<NavigationOption title=\"Title\" content=\"Text\" onClick={fn} />\n→\n<ListItem title=\"Title\" subtitle=\"Text\" control={<ListItem.Navigation onClick={fn} />} />\n\\`\\`\\`\n\n---\n\n## Option → ListItem\n\n- Wrap \\`media\\` in \\`ListItem.AvatarView\\`\n\n\\`\\`\\`tsx\n<Option media={<Icon />} title=\"Title\" />\n→\n<ListItem title=\"Title\" media={<ListItem.AvatarView><Icon /></ListItem.AvatarView>} />\n\\`\\`\\`\n\n---\n\n## Summary → ListItem\n\n**Basic:**\n\n- \\`icon\\` → wrap in \\`ListItem.AvatarView\\` with \\`size={32}\\` as \\`media\\`\n- Remove \\`size\\` from child \\`<Icon />\\`\n\n**Status:**\n\n- \\`Status.DONE\\` → \\`badge={{ status: 'positive' }}\\`\n- \\`Status.PENDING\\` → \\`badge={{ status: 'pending' }}\\`\n- \\`Status.NOT_DONE\\` → no badge\n\n**Action:**\n\n- \\`action.text\\` → \\`action.label\\` in \\`ListItem.AdditionalInfo\\` as \\`additionalInfo\\`\n\n**Info (requires state):**\n\n- \\`MODAL\\` → \\`ListItem.IconButton partiallyInteractive\\` + \\`<Modal>\\` in \\`control\\`\n- \\`POPOVER\\` → \\`<Popover>\\` wrapping \\`ListItem.IconButton partiallyInteractive\\` in \\`control\\`\n- Use \\`QuestionMarkCircle\\` icon (import from \\`@transferwise/icons\\`)\n\n\\`\\`\\`tsx\n// Basic\n<Summary title=\"T\" description=\"D\" icon={<Icon />} />\n→\n<ListItem title=\"T\" subtitle=\"D\" media={<ListItem.AvatarView size={32}><Icon /></ListItem.AvatarView>} />\n\n// Status\n<Summary title=\"T\" description=\"D\" icon={<Icon />} status={Status.DONE} />\n→\n<ListItem title=\"T\" subtitle=\"D\" media={<ListItem.AvatarView size={32} badge={{status:'positive'}}><Icon /></ListItem.AvatarView>} />\n\n// Action\n<Summary title=\"T\" description=\"D\" icon={<Icon />} action={{text:'Go', href:'/go'}} />\n→\n<ListItem title=\"T\" subtitle=\"D\" media={<ListItem.AvatarView size={32}><Icon /></ListItem.AvatarView>} additionalInfo={<ListItem.AdditionalInfo action={{label:'Go', href:'/go'}} />} />\n\n// Modal (add: const [open, setOpen] = useState(false))\n<Summary title=\"T\" description=\"D\" icon={<Icon />} info={{title:'Help', content:'Text', presentation:'MODAL', 'aria-label':'Info'}} />\n→\n<ListItem title=\"T\" subtitle=\"D\" media={<ListItem.AvatarView size={32}><Icon /></ListItem.AvatarView>} control={<ListItem.IconButton partiallyInteractive aria-label=\"Info\" onClick={()=>setOpen(!open)}><QuestionMarkCircle /><Modal open={open} title=\"Help\" body=\"Text\" onClose={()=>setOpen(false)} /></ListItem.IconButton>} />\n\n// Popover\n<Summary title=\"T\" description=\"D\" icon={<Icon />} info={{title:'Help', content:'Text', presentation:'POPOVER', 'aria-label':'Info'}} />\n→\n<ListItem title=\"T\" subtitle=\"D\" media={<ListItem.AvatarView size={32}><Icon /></ListItem.AvatarView>} control={<Popover title=\"Help\" content=\"Text\" onClose={()=>setOpen(false)}><ListItem.IconButton partiallyInteractive aria-label=\"Info\"><QuestionMarkCircle /></ListItem.IconButton></Popover>} />\n\\`\\`\\`\n\n---\n\n## DefinitionList → Multiple ListItem\n\n- Array → individual \\`ListItem\\`s\n- \\`value\\` → \\`subtitle\\`\n- \\`key\\` → React \\`key\\` prop\n- Action type: \"Edit\"/\"Update\"/\"View\" → \\`ListItem.Button priority=\"secondary-neutral\"\\`, \"Change\"/\"Password\" → \\`ListItem.Navigation\\`, \"Copy\" → \\`ListItem.IconButton\\`\n\n\\`\\`\\`tsx\n<DefinitionList definitions={[\n {title:'T1', value:'V1', key:'k1'},\n {title:'T2', value:'V2', key:'k2', action:{label:'Edit', onClick:fn}}\n]} />\n→\n\n <ListItem key=\"k1\" title=\"T1\" subtitle=\"V1\" />\n <ListItem key=\"k2\" title=\"T2\" subtitle=\"V2\" control={<ListItem.Button priority=\"secondary-neutral\" onClick={fn}>Edit</ListItem.Button>} />\n\n\\`\\`\\`\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\nRead and transform each file individually, instead of reading them all at the start. Only make a single edit or write per file, once you've fully processed it.\n\nRules:\n1. Ignore any files that do not contain deprecated WDS components, unless they are necessary for context.\n2. Migrate components per provided migration rules\n3. Maintain TypeScript type safety and update types to match new API\n4. Map props: handle renamed, deprecated, new required, and changed types\n5. Update imports to new WDS components and types\n6. Preserve code style, formatting, and calculated logic\n7. Handle conditional rendering, spread props, and complex expressions\n8. Note: New components may lack feature parity with legacy versions\n9. Only modify code requiring changes per migration rules, and any impacted surrounding code for context.\n10. Provide only the transformed code as output, without explanations or additional text\n11. Do not summarise the initial user request in a response.\n12. Use glob or grep tool usage to find the files with deprecated components.\n13. Final result response should just be whether the migration was successful overall, or if any errors were encountered\n\nMake the necessary updates to the files and do not respond with any explanations or reasoning. \n\nYou'll receive:\n- File paths/directories to search in individual queries\n- Deprecated component names at the end of this prompt\n- Migration context and rules for each deprecated component\n\nDeprecated components: ${DEPRECATED_COMPONENT_NAMES.join(', ')}.\n\n${MIGRATION_RULES}`;\n","/** Split the path to get the relative path after the directory, and wrap with ANSI color codes */\nexport function formatPathOutput(directory: string, path?: string): string {\n return `\\x1b[32m${path ? (path.split(directory)[1] ?? path) : directory}\\x1b[0m`;\n}\n\n/** Generates a formatted string representing the total elapsed time since the given start time */\nexport function generateElapsedTime(startTime: number): string {\n const endTime = Date.now();\n const elapsedTime = Math.floor((endTime - startTime) / 1000);\n const hours = Math.floor(elapsedTime / 3600);\n const minutes = Math.floor((elapsedTime % 3600) / 60);\n const seconds = elapsedTime % 60;\n\n return `${hours ? `${hours}h ` : ''}${minutes ? `${minutes}m ` : ''}${seconds ? `${seconds}s` : ''}`;\n}\n","import { type Options, query } from '@anthropic-ai/claude-agent-sdk';\nimport { execSync } from 'child_process';\nimport { readFileSync } from 'fs';\nimport https from 'node:https';\nimport ora from 'ora';\nimport { resolve } from 'path';\n\nimport { CONSOLE_ICONS } from '../../constants';\nimport { SYSTEM_PROMPT } from './constants';\nimport { formatPathOutput } from './helpers';\nimport type { ClaudeResponseToolUse, ClaudeSettings } from './types';\n\nconst CLAUDE_SETTINGS_FILE = '.claude/settings.json';\n\nasync function checkVPN(baseUrl?: string): Promise<boolean> {\n if (baseUrl) {\n const vpnSpinner = ora('Checking VPN connection...').start();\n const checkOnce = async (): Promise<boolean> =>\n await new Promise<boolean>((resolveCheck) => {\n const url = new URL('/health', baseUrl);\n const req = https.get(url, { timeout: 2000, rejectUnauthorized: false }, (res) => {\n const ok = !!(res.statusCode && res.statusCode >= 200 && res.statusCode < 400);\n res.resume();\n resolveCheck(ok);\n });\n req.on('timeout', () => {\n req.destroy(new Error('timeout'));\n });\n req.on('error', () => resolveCheck(false));\n });\n\n while (true) {\n const ok = await checkOnce();\n if (ok) {\n vpnSpinner.succeed('Connected to VPN');\n break;\n }\n vpnSpinner.text = 'Please connect to VPN... retrying in 3s';\n await new Promise<void>((response) => {\n setTimeout(response, 3000);\n });\n }\n }\n return true;\n}\n\nexport function getQueryOptions(sessionId?: string, isDebug?: boolean): 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 // Not logging the auth token for security reasons\n const { ANTHROPIC_AUTH_TOKEN, ...restVars } = envVars;\n console.log(\n `${CONSOLE_ICONS.info} Claude configuration environment variables:`,\n JSON.stringify(restVars),\n );\n }\n\n return {\n resume: sessionId,\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\n/** Initiate a new Claude session/conversation and return reusable options */\nexport async function initiateClaudeSessionOptions(isDebug = false): Promise<Options> {\n const options = getQueryOptions(undefined, isDebug);\n await checkVPN(options.env?.ANTHROPIC_BASE_URL as string | undefined);\n\n const claudeSessionSpinner = ora(\n 'Starting Claude instance - your browser may open for Okta authentication if required.',\n ).start();\n\n const result = query({\n options,\n prompt: `You'll be given directories in additional individual queries to search in for files using deprecated Wise Design System (WDS) components. Migrate the code per the provided migration rules.`,\n });\n\n for await (const message of result) {\n switch (message.type) {\n case 'system':\n if (message.subtype === 'init' && !options.resume) {\n claudeSessionSpinner.succeed('Successfully initialised Claude instance');\n\n // Set the session ID to resume the conversation in future queries\n options.resume = message.session_id;\n }\n break;\n default:\n if (message.type === 'result' && message.subtype !== 'success') {\n claudeSessionSpinner.fail(`Claude encountered an error: ${message.errors.join('\\n')}`);\n }\n }\n }\n\n return options;\n}\n\nexport async function queryClaude(path: string, options: Options, isDebug = false) {\n const result = query({\n options,\n prompt: path,\n });\n const modifiedFiles: string[] = [];\n\n for await (const message of result) {\n switch (message.type) {\n case 'assistant':\n for (const msg of message.message.content) {\n switch (msg.type) {\n // Handles logging of tool uses to determine key stages of the migration ()\n case 'tool_use':\n if (msg.name === 'Glob' || msg.name === 'Grep') {\n console.log(\n `${CONSOLE_ICONS.focus} Processing directory: ${formatPathOutput(path)}...`,\n );\n // NOTE: Possibly want to only log reading files when in debug mode, to reduce noise\n } else if (msg.name === 'Read') {\n console.log(\n `${CONSOLE_ICONS.info} Reading ${formatPathOutput(path, (msg as ClaudeResponseToolUse).input.file_path)}`,\n );\n } else if (\n (msg.name === 'Write' || msg.name === 'Edit') &&\n !modifiedFiles.includes((msg as ClaudeResponseToolUse).input.file_path) // Safeguard against duplicate logs, where Claude may write multiple times to the same file\n ) {\n modifiedFiles.push((msg as ClaudeResponseToolUse).input.file_path);\n console.log(\n `${CONSOLE_ICONS.info} Migrated ${formatPathOutput(path, (msg as ClaudeResponseToolUse).input.file_path)}`,\n );\n }\n break;\n default:\n }\n }\n break;\n case 'result':\n if (message.subtype === 'success') {\n // TODO: Handle case where migration failed for some files?\n console.log(\n `${CONSOLE_ICONS.success} Migrated all applicable files in ${formatPathOutput(path)}`,\n );\n } else {\n console.log(\n `${CONSOLE_ICONS.error} Claude encountered an error: ${message.errors.join('\\n').trim()}`,\n );\n }\n break;\n default:\n }\n }\n}\n","import { CONSOLE_ICONS } from '../../constants';\nimport { initiateClaudeSessionOptions, queryClaude } from './claude';\nimport { generateElapsedTime } from './helpers';\n\nconst transformer = async (targetPaths: string[], isDebug = false) => {\n const startTime = Date.now();\n\n // TODO: We need to check whether the user is connected to the VPN\n\n const queryOptions = await initiateClaudeSessionOptions(isDebug);\n\n console.log(`${CONSOLE_ICONS.info} Analysing targetted paths - this may take a while...`);\n\n for (const directory of targetPaths) {\n await queryClaude(directory, queryOptions, isDebug);\n }\n\n console.log(\n `${CONSOLE_ICONS.success} Finished migrating - elapsed time: \\x1b[1m${generateElapsedTime(startTime)}\\x1b[0m`,\n );\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,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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M,aAAa,YACtB,OAAM,YAAY,WAAW,cAAc,QAAQ;AAGrD,SAAQ,IACN,GAAG,cAAc,QAAQ,6CAA6C,oBAAoB,UAAU,CAAC,SACtG;;AAGH,0BAAe"}
@@ -1,6 +0,0 @@
1
- {
2
- "type": "claude",
3
- "prerequisites": {
4
- "@transferwise/components": ">=46.107.0"
5
- }
6
- }
@@ -1,3 +0,0 @@
1
- const require_transformer = require('../../transformer-Bmoi_ztn.js');
2
-
3
- module.exports = require_transformer.transformer_default;