@razorpay/blade 11.34.1 → 11.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/build/lib/native/components/Box/BaseBox/types/propsTypes.js.map +1 -1
  2. package/build/lib/native/components/Card/Card.js.map +1 -1
  3. package/build/lib/native/components/Icons/Battery100PercentIcon/Battery100PercentIcon.js +12 -0
  4. package/build/lib/native/components/Icons/Battery100PercentIcon/Battery100PercentIcon.js.map +1 -0
  5. package/build/lib/native/components/Icons/Battery20PercentIcon/Battery20PercentIcon.js +12 -0
  6. package/build/lib/native/components/Icons/Battery20PercentIcon/Battery20PercentIcon.js.map +1 -0
  7. package/build/lib/native/components/Icons/Battery40PercentIcon/Battery40PercentIcon.js +12 -0
  8. package/build/lib/native/components/Icons/Battery40PercentIcon/Battery40PercentIcon.js.map +1 -0
  9. package/build/lib/native/components/Icons/Battery60PercentIcon/Battery60PercentIcon.js +12 -0
  10. package/build/lib/native/components/Icons/Battery60PercentIcon/Battery60PercentIcon.js.map +1 -0
  11. package/build/lib/native/components/Icons/Battery80PercentIcon/Battery80PercentIcon.js +12 -0
  12. package/build/lib/native/components/Icons/Battery80PercentIcon/Battery80PercentIcon.js.map +1 -0
  13. package/build/lib/native/components/Icons/BillMeIcon/BillMeIcon.js +12 -0
  14. package/build/lib/native/components/Icons/BillMeIcon/BillMeIcon.js.map +1 -0
  15. package/build/lib/native/components/Icons/NoSignalIcon/NoSignalIcon.js +12 -0
  16. package/build/lib/native/components/Icons/NoSignalIcon/NoSignalIcon.js.map +1 -0
  17. package/build/lib/native/components/Icons/Signal1BarIcon/Signal1BarIcon.js +12 -0
  18. package/build/lib/native/components/Icons/Signal1BarIcon/Signal1BarIcon.js.map +1 -0
  19. package/build/lib/native/components/Icons/Signal2BarIcon/Signal2BarIcon.js +12 -0
  20. package/build/lib/native/components/Icons/Signal2BarIcon/Signal2BarIcon.js.map +1 -0
  21. package/build/lib/native/components/Icons/Signal3BarIcon/Signal3BarIcon.js +12 -0
  22. package/build/lib/native/components/Icons/Signal3BarIcon/Signal3BarIcon.js.map +1 -0
  23. package/build/lib/native/components/Icons/Signal4BarIcon/Signal4BarIcon.js +12 -0
  24. package/build/lib/native/components/Icons/Signal4BarIcon/Signal4BarIcon.js.map +1 -0
  25. package/build/lib/native/components/Icons/SignalIcon/SignalIcon.js +12 -0
  26. package/build/lib/native/components/Icons/SignalIcon/SignalIcon.js.map +1 -0
  27. package/build/lib/native/components/Icons/SimCardIcon/SimCardIcon.js +12 -0
  28. package/build/lib/native/components/Icons/SimCardIcon/SimCardIcon.js.map +1 -0
  29. package/build/lib/native/components/Icons/TwitterIcon/TwitterIcon.js +1 -1
  30. package/build/lib/native/components/Icons/TwitterIcon/TwitterIcon.js.map +1 -1
  31. package/build/lib/native/components/Icons/UpiIcon/UpiIcon.js +12 -0
  32. package/build/lib/native/components/Icons/UpiIcon/UpiIcon.js.map +1 -0
  33. package/build/lib/native/components/Icons/YoutubeIcon/YoutubeIcon.js +12 -0
  34. package/build/lib/native/components/Icons/YoutubeIcon/YoutubeIcon.js.map +1 -0
  35. package/build/lib/native/components/Input/TextInput/TextInput.js.map +1 -1
  36. package/build/lib/native/components/index.js +15 -0
  37. package/build/lib/native/components/index.js.map +1 -1
  38. package/build/lib/native/utils/useCallbackRef.js +6 -0
  39. package/build/lib/native/utils/useCallbackRef.js.map +1 -0
  40. package/build/lib/native/utils/useControllable.js +2 -1
  41. package/build/lib/native/utils/useControllable.js.map +1 -1
  42. package/build/lib/web/development/components/Box/BaseBox/types/propsTypes.js.map +1 -1
  43. package/build/lib/web/development/components/Card/Card.js.map +1 -1
  44. package/build/lib/web/development/components/Carousel/Carousel.web.js +65 -57
  45. package/build/lib/web/development/components/Carousel/Carousel.web.js.map +1 -1
  46. package/build/lib/web/development/components/Icons/Battery100PercentIcon/Battery100PercentIcon.js +57 -0
  47. package/build/lib/web/development/components/Icons/Battery100PercentIcon/Battery100PercentIcon.js.map +1 -0
  48. package/build/lib/web/development/components/Icons/Battery100PercentIcon/index.js +2 -0
  49. package/build/lib/web/development/components/Icons/Battery100PercentIcon/index.js.map +1 -0
  50. package/build/lib/web/development/components/Icons/Battery20PercentIcon/Battery20PercentIcon.js +45 -0
  51. package/build/lib/web/development/components/Icons/Battery20PercentIcon/Battery20PercentIcon.js.map +1 -0
  52. package/build/lib/web/development/components/Icons/Battery20PercentIcon/index.js +2 -0
  53. package/build/lib/web/development/components/Icons/Battery20PercentIcon/index.js.map +1 -0
  54. package/build/lib/web/development/components/Icons/Battery40PercentIcon/Battery40PercentIcon.js +48 -0
  55. package/build/lib/web/development/components/Icons/Battery40PercentIcon/Battery40PercentIcon.js.map +1 -0
  56. package/build/lib/web/development/components/Icons/Battery40PercentIcon/index.js +2 -0
  57. package/build/lib/web/development/components/Icons/Battery40PercentIcon/index.js.map +1 -0
  58. package/build/lib/web/development/components/Icons/Battery60PercentIcon/Battery60PercentIcon.js +51 -0
  59. package/build/lib/web/development/components/Icons/Battery60PercentIcon/Battery60PercentIcon.js.map +1 -0
  60. package/build/lib/web/development/components/Icons/Battery60PercentIcon/index.js +2 -0
  61. package/build/lib/web/development/components/Icons/Battery60PercentIcon/index.js.map +1 -0
  62. package/build/lib/web/development/components/Icons/Battery80PercentIcon/Battery80PercentIcon.js +54 -0
  63. package/build/lib/web/development/components/Icons/Battery80PercentIcon/Battery80PercentIcon.js.map +1 -0
  64. package/build/lib/web/development/components/Icons/Battery80PercentIcon/index.js +2 -0
  65. package/build/lib/web/development/components/Icons/Battery80PercentIcon/index.js.map +1 -0
  66. package/build/lib/web/development/components/Icons/BillMeIcon/BillMeIcon.js +51 -0
  67. package/build/lib/web/development/components/Icons/BillMeIcon/BillMeIcon.js.map +1 -0
  68. package/build/lib/web/development/components/Icons/BillMeIcon/index.js +2 -0
  69. package/build/lib/web/development/components/Icons/BillMeIcon/index.js.map +1 -0
  70. package/build/lib/web/development/components/Icons/NoSignalIcon/NoSignalIcon.js +37 -0
  71. package/build/lib/web/development/components/Icons/NoSignalIcon/NoSignalIcon.js.map +1 -0
  72. package/build/lib/web/development/components/Icons/NoSignalIcon/index.js +2 -0
  73. package/build/lib/web/development/components/Icons/NoSignalIcon/index.js.map +1 -0
  74. package/build/lib/web/development/components/Icons/Signal1BarIcon/Signal1BarIcon.js +37 -0
  75. package/build/lib/web/development/components/Icons/Signal1BarIcon/Signal1BarIcon.js.map +1 -0
  76. package/build/lib/web/development/components/Icons/Signal1BarIcon/index.js +2 -0
  77. package/build/lib/web/development/components/Icons/Signal1BarIcon/index.js.map +1 -0
  78. package/build/lib/web/development/components/Icons/Signal2BarIcon/Signal2BarIcon.js +37 -0
  79. package/build/lib/web/development/components/Icons/Signal2BarIcon/Signal2BarIcon.js.map +1 -0
  80. package/build/lib/web/development/components/Icons/Signal2BarIcon/index.js +2 -0
  81. package/build/lib/web/development/components/Icons/Signal2BarIcon/index.js.map +1 -0
  82. package/build/lib/web/development/components/Icons/Signal3BarIcon/Signal3BarIcon.js +37 -0
  83. package/build/lib/web/development/components/Icons/Signal3BarIcon/Signal3BarIcon.js.map +1 -0
  84. package/build/lib/web/development/components/Icons/Signal3BarIcon/index.js +2 -0
  85. package/build/lib/web/development/components/Icons/Signal3BarIcon/index.js.map +1 -0
  86. package/build/lib/web/development/components/Icons/Signal4BarIcon/Signal4BarIcon.js +37 -0
  87. package/build/lib/web/development/components/Icons/Signal4BarIcon/Signal4BarIcon.js.map +1 -0
  88. package/build/lib/web/development/components/Icons/Signal4BarIcon/index.js +2 -0
  89. package/build/lib/web/development/components/Icons/Signal4BarIcon/index.js.map +1 -0
  90. package/build/lib/web/development/components/Icons/SignalIcon/SignalIcon.js +37 -0
  91. package/build/lib/web/development/components/Icons/SignalIcon/SignalIcon.js.map +1 -0
  92. package/build/lib/web/development/components/Icons/SignalIcon/index.js +2 -0
  93. package/build/lib/web/development/components/Icons/SignalIcon/index.js.map +1 -0
  94. package/build/lib/web/development/components/Icons/SimCardIcon/SimCardIcon.js +57 -0
  95. package/build/lib/web/development/components/Icons/SimCardIcon/SimCardIcon.js.map +1 -0
  96. package/build/lib/web/development/components/Icons/SimCardIcon/index.js +2 -0
  97. package/build/lib/web/development/components/Icons/SimCardIcon/index.js.map +1 -0
  98. package/build/lib/web/development/components/Icons/TwitterIcon/TwitterIcon.js +1 -1
  99. package/build/lib/web/development/components/Icons/TwitterIcon/TwitterIcon.js.map +1 -1
  100. package/build/lib/web/development/components/Icons/UpiIcon/UpiIcon.js +39 -0
  101. package/build/lib/web/development/components/Icons/UpiIcon/UpiIcon.js.map +1 -0
  102. package/build/lib/web/development/components/Icons/UpiIcon/index.js +2 -0
  103. package/build/lib/web/development/components/Icons/UpiIcon/index.js.map +1 -0
  104. package/build/lib/web/development/components/Icons/YoutubeIcon/YoutubeIcon.js +44 -0
  105. package/build/lib/web/development/components/Icons/YoutubeIcon/YoutubeIcon.js.map +1 -0
  106. package/build/lib/web/development/components/Icons/YoutubeIcon/index.js +2 -0
  107. package/build/lib/web/development/components/Icons/YoutubeIcon/index.js.map +1 -0
  108. package/build/lib/web/development/components/Icons/index.js +15 -0
  109. package/build/lib/web/development/components/Icons/index.js.map +1 -1
  110. package/build/lib/web/development/components/Input/TextInput/TextInput.js.map +1 -1
  111. package/build/lib/web/development/components/Modal/ModalBody.web.js.map +1 -1
  112. package/build/lib/web/development/components/index.js +15 -0
  113. package/build/lib/web/development/components/index.js.map +1 -1
  114. package/build/lib/web/development/utils/useCallbackRef.js +31 -0
  115. package/build/lib/web/development/utils/useCallbackRef.js.map +1 -0
  116. package/build/lib/web/development/utils/useControllable.js +13 -5
  117. package/build/lib/web/development/utils/useControllable.js.map +1 -1
  118. package/build/lib/web/production/components/Box/BaseBox/types/propsTypes.js.map +1 -1
  119. package/build/lib/web/production/components/Card/Card.js.map +1 -1
  120. package/build/lib/web/production/components/Carousel/Carousel.web.js +65 -57
  121. package/build/lib/web/production/components/Carousel/Carousel.web.js.map +1 -1
  122. package/build/lib/web/production/components/Icons/Battery100PercentIcon/Battery100PercentIcon.js +57 -0
  123. package/build/lib/web/production/components/Icons/Battery100PercentIcon/Battery100PercentIcon.js.map +1 -0
  124. package/build/lib/web/production/components/Icons/Battery100PercentIcon/index.js +2 -0
  125. package/build/lib/web/production/components/Icons/Battery100PercentIcon/index.js.map +1 -0
  126. package/build/lib/web/production/components/Icons/Battery20PercentIcon/Battery20PercentIcon.js +45 -0
  127. package/build/lib/web/production/components/Icons/Battery20PercentIcon/Battery20PercentIcon.js.map +1 -0
  128. package/build/lib/web/production/components/Icons/Battery20PercentIcon/index.js +2 -0
  129. package/build/lib/web/production/components/Icons/Battery20PercentIcon/index.js.map +1 -0
  130. package/build/lib/web/production/components/Icons/Battery40PercentIcon/Battery40PercentIcon.js +48 -0
  131. package/build/lib/web/production/components/Icons/Battery40PercentIcon/Battery40PercentIcon.js.map +1 -0
  132. package/build/lib/web/production/components/Icons/Battery40PercentIcon/index.js +2 -0
  133. package/build/lib/web/production/components/Icons/Battery40PercentIcon/index.js.map +1 -0
  134. package/build/lib/web/production/components/Icons/Battery60PercentIcon/Battery60PercentIcon.js +51 -0
  135. package/build/lib/web/production/components/Icons/Battery60PercentIcon/Battery60PercentIcon.js.map +1 -0
  136. package/build/lib/web/production/components/Icons/Battery60PercentIcon/index.js +2 -0
  137. package/build/lib/web/production/components/Icons/Battery60PercentIcon/index.js.map +1 -0
  138. package/build/lib/web/production/components/Icons/Battery80PercentIcon/Battery80PercentIcon.js +54 -0
  139. package/build/lib/web/production/components/Icons/Battery80PercentIcon/Battery80PercentIcon.js.map +1 -0
  140. package/build/lib/web/production/components/Icons/Battery80PercentIcon/index.js +2 -0
  141. package/build/lib/web/production/components/Icons/Battery80PercentIcon/index.js.map +1 -0
  142. package/build/lib/web/production/components/Icons/BillMeIcon/BillMeIcon.js +51 -0
  143. package/build/lib/web/production/components/Icons/BillMeIcon/BillMeIcon.js.map +1 -0
  144. package/build/lib/web/production/components/Icons/BillMeIcon/index.js +2 -0
  145. package/build/lib/web/production/components/Icons/BillMeIcon/index.js.map +1 -0
  146. package/build/lib/web/production/components/Icons/NoSignalIcon/NoSignalIcon.js +37 -0
  147. package/build/lib/web/production/components/Icons/NoSignalIcon/NoSignalIcon.js.map +1 -0
  148. package/build/lib/web/production/components/Icons/NoSignalIcon/index.js +2 -0
  149. package/build/lib/web/production/components/Icons/NoSignalIcon/index.js.map +1 -0
  150. package/build/lib/web/production/components/Icons/Signal1BarIcon/Signal1BarIcon.js +37 -0
  151. package/build/lib/web/production/components/Icons/Signal1BarIcon/Signal1BarIcon.js.map +1 -0
  152. package/build/lib/web/production/components/Icons/Signal1BarIcon/index.js +2 -0
  153. package/build/lib/web/production/components/Icons/Signal1BarIcon/index.js.map +1 -0
  154. package/build/lib/web/production/components/Icons/Signal2BarIcon/Signal2BarIcon.js +37 -0
  155. package/build/lib/web/production/components/Icons/Signal2BarIcon/Signal2BarIcon.js.map +1 -0
  156. package/build/lib/web/production/components/Icons/Signal2BarIcon/index.js +2 -0
  157. package/build/lib/web/production/components/Icons/Signal2BarIcon/index.js.map +1 -0
  158. package/build/lib/web/production/components/Icons/Signal3BarIcon/Signal3BarIcon.js +37 -0
  159. package/build/lib/web/production/components/Icons/Signal3BarIcon/Signal3BarIcon.js.map +1 -0
  160. package/build/lib/web/production/components/Icons/Signal3BarIcon/index.js +2 -0
  161. package/build/lib/web/production/components/Icons/Signal3BarIcon/index.js.map +1 -0
  162. package/build/lib/web/production/components/Icons/Signal4BarIcon/Signal4BarIcon.js +37 -0
  163. package/build/lib/web/production/components/Icons/Signal4BarIcon/Signal4BarIcon.js.map +1 -0
  164. package/build/lib/web/production/components/Icons/Signal4BarIcon/index.js +2 -0
  165. package/build/lib/web/production/components/Icons/Signal4BarIcon/index.js.map +1 -0
  166. package/build/lib/web/production/components/Icons/SignalIcon/SignalIcon.js +37 -0
  167. package/build/lib/web/production/components/Icons/SignalIcon/SignalIcon.js.map +1 -0
  168. package/build/lib/web/production/components/Icons/SignalIcon/index.js +2 -0
  169. package/build/lib/web/production/components/Icons/SignalIcon/index.js.map +1 -0
  170. package/build/lib/web/production/components/Icons/SimCardIcon/SimCardIcon.js +57 -0
  171. package/build/lib/web/production/components/Icons/SimCardIcon/SimCardIcon.js.map +1 -0
  172. package/build/lib/web/production/components/Icons/SimCardIcon/index.js +2 -0
  173. package/build/lib/web/production/components/Icons/SimCardIcon/index.js.map +1 -0
  174. package/build/lib/web/production/components/Icons/TwitterIcon/TwitterIcon.js +1 -1
  175. package/build/lib/web/production/components/Icons/TwitterIcon/TwitterIcon.js.map +1 -1
  176. package/build/lib/web/production/components/Icons/UpiIcon/UpiIcon.js +39 -0
  177. package/build/lib/web/production/components/Icons/UpiIcon/UpiIcon.js.map +1 -0
  178. package/build/lib/web/production/components/Icons/UpiIcon/index.js +2 -0
  179. package/build/lib/web/production/components/Icons/UpiIcon/index.js.map +1 -0
  180. package/build/lib/web/production/components/Icons/YoutubeIcon/YoutubeIcon.js +44 -0
  181. package/build/lib/web/production/components/Icons/YoutubeIcon/YoutubeIcon.js.map +1 -0
  182. package/build/lib/web/production/components/Icons/YoutubeIcon/index.js +2 -0
  183. package/build/lib/web/production/components/Icons/YoutubeIcon/index.js.map +1 -0
  184. package/build/lib/web/production/components/Icons/index.js +15 -0
  185. package/build/lib/web/production/components/Icons/index.js.map +1 -1
  186. package/build/lib/web/production/components/Input/TextInput/TextInput.js.map +1 -1
  187. package/build/lib/web/production/components/Modal/ModalBody.web.js.map +1 -1
  188. package/build/lib/web/production/components/index.js +15 -0
  189. package/build/lib/web/production/components/index.js.map +1 -1
  190. package/build/lib/web/production/utils/useCallbackRef.js +31 -0
  191. package/build/lib/web/production/utils/useCallbackRef.js.map +1 -0
  192. package/build/lib/web/production/utils/useControllable.js +13 -5
  193. package/build/lib/web/production/utils/useControllable.js.map +1 -1
  194. package/build/types/components/index.d.ts +64 -23
  195. package/build/types/components/index.native.d.ts +62 -21
  196. package/codemods/aicodemod/README.md +26 -0
  197. package/codemods/aicodemod/bin.mjs +128 -0
  198. package/codemods/aicodemod/knowledge/Table.md +596 -0
  199. package/codemods/aicodemod/knowledge/presets/dashboard/table-pattern-1.md +319 -0
  200. package/package.json +4 -2
@@ -0,0 +1,26 @@
1
+ # Blade AI Codemod
2
+
3
+ ## 1. Install Blade Globally
4
+
5
+ ```sh
6
+ npm install -g @razorpay/blade
7
+ ```
8
+
9
+ ## 2. Run `aicodemod` Command to Migrate
10
+
11
+ ```sh
12
+ aicodemod <path-to-migrate>
13
+ --code-knowledge presets/dashboard/table-pattern-1
14
+ ```
15
+
16
+ `--code-knowledge`: The AI needs some info about existing codebase and some patterns on how to migrate. We currently have created a preset knowledge for migrating one of the patterns in table.
17
+
18
+ ## 3. Fix any visual or syntax issues if there
19
+
20
+ AI Codemod is there to help you get going with migration. You might still have 10% work left to review if the code logic is in place and visually things are looking as expected.
21
+
22
+ > [!NOTE]
23
+ >
24
+ > **POC Limitations**
25
+ >
26
+ > As currently its just POC, its optimized to only migrate to Blade Table component. It can also
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+
5
+ const getFlagValue = (flag) => {
6
+ const flagIndex = process.argv.indexOf(flag);
7
+ if (flagIndex < 0) {
8
+ return undefined;
9
+ }
10
+
11
+ return process.argv[flagIndex + 1];
12
+ };
13
+
14
+ // This is for passing ngrok instance URL
15
+ const BASE_URL = 'https://blade-chat.dev.razorpay.in';
16
+ const SERVER_ENDPOINT = '/chat';
17
+
18
+ const preset = getFlagValue('--code-knowledge') ?? 'presets/dashboard/table-pattern-1';
19
+
20
+ const getChatCompletionFromServer = async (messages) => {
21
+ const url = BASE_URL + SERVER_ENDPOINT;
22
+
23
+ // Define the fetch options
24
+ const options = {
25
+ method: 'POST',
26
+ headers: {
27
+ 'Content-Type': 'application/json',
28
+ 'rzpctx-dev-serve-user': 'base',
29
+ },
30
+ body: JSON.stringify({ input: messages }),
31
+ };
32
+
33
+ try {
34
+ // Make the fetch call
35
+ const response = await fetch(url, options);
36
+ return response.text();
37
+ } catch (err) {
38
+ throw err;
39
+ }
40
+ };
41
+
42
+ const __dirname = new URL('.', import.meta.url).pathname;
43
+ const cwd = process.cwd();
44
+
45
+ let codeKnowledge;
46
+ const consumerPresetPath = path.join(cwd, preset);
47
+ const predefinedPresetPath = path.join(__dirname, 'knowledge', `${preset}.md`);
48
+
49
+ if (fs.existsSync(consumerPresetPath)) {
50
+ codeKnowledge = fs.readFileSync(consumerPresetPath, 'utf-8');
51
+ } else {
52
+ codeKnowledge = fs.readFileSync(predefinedPresetPath, 'utf-8');
53
+ }
54
+
55
+ const bladeKnowledge = fs.readFileSync(path.resolve(__dirname, './knowledge/Table.md'), 'utf-8');
56
+
57
+ const usageFileArg = process.argv[2];
58
+ const usageFilePath = path.join(cwd, usageFileArg);
59
+ const usage = fs.readFileSync(usageFilePath, 'utf-8');
60
+
61
+ const ultimatePrompt = `
62
+ I want you to migrate our old codebase code from custom implementation, to use our design-system component called Blade.
63
+
64
+ You will find code snippets of these things below-
65
+
66
+ 1. Blade's Table Documentation: Documentation of our design-system table
67
+ 2. Custom Component Definitions: Custom component implementations to help figure out what some of the internally used components do
68
+ 3. Migration Example: A reference example of migration. How the output migrated code would look like on given certain input.
69
+ 4. Code to Migrate: Migrate this code to use our design-system components
70
+
71
+ Return Format:
72
+ - Refer to Blade's Table documentation and Custom Component Definitons and Migration Example and return the migrated code snippet of usage using Blade
73
+ - Return raw migrated code without additional text
74
+ - Don't change unrelated code and imports
75
+ - If something existed in previous code, but does not map to anything in new code. Add a TODO comment describing what needs to be done
76
+ - Remove unused variables, functions, and imports
77
+ - Make sure Blade's Header and Footer are also used wherever needed.
78
+ - Ignore the code related to mobile responsiveness as Blade components are responsive by default
79
+
80
+ ## 1. Blade's Table Documentation
81
+ ${bladeKnowledge}
82
+
83
+ ${codeKnowledge}
84
+
85
+ ## 4. Code to Migrate
86
+ \`\`\`jsx
87
+ ${usage}
88
+ \`\`\`
89
+ `;
90
+
91
+ const messages = [
92
+ {
93
+ role: 'system',
94
+ content: [
95
+ {
96
+ type: 'text',
97
+ text:
98
+ 'You are an AI assistant that helps in migrating codebase from old custom implementation to our internal design-system components',
99
+ },
100
+ ],
101
+ },
102
+ {
103
+ role: 'user',
104
+ content: [
105
+ {
106
+ type: 'text',
107
+ text: ultimatePrompt,
108
+ },
109
+ ],
110
+ },
111
+ ];
112
+
113
+ const answer = await getChatCompletionFromServer(messages);
114
+
115
+ if (answer) {
116
+ console.log('USAGE STATS', {
117
+ inputLength: JSON.stringify(messages).length,
118
+ });
119
+
120
+ const cleanOut = answer.startsWith('```jsx')
121
+ ? answer.slice(`\`\`\`jsx`.length + 1, -('```'.length + 1))
122
+ : answer;
123
+ fs.writeFileSync(usageFilePath, cleanOut);
124
+ } else {
125
+ console.log(
126
+ "Something's not right. The server didn't respond correctly. Hopefully there are more helpful logs above ^^",
127
+ );
128
+ }