@sanity/ui-codemod 1.0.0-alpha.7 → 1.0.0-alpha.9

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.
@@ -30,54 +30,54 @@ const GRID_MODS = {
30
30
  name: "gridTemplateColumns",
31
31
  mapping: {
32
32
  0: "0px",
33
- 1: "repeat(1, 1fr)",
34
- 2: "repeat(2, 1fr)",
35
- 3: "repeat(3, 1fr)",
36
- 4: "repeat(4, 1fr)",
37
- 5: "repeat(5, 1fr)",
38
- 6: "repeat(6, 1fr)",
39
- 7: "repeat(7, 1fr)",
40
- 8: "repeat(8, 1fr)",
41
- 9: "repeat(9, 1fr)",
42
- 10: "repeat(10, 1fr)",
43
- 11: "repeat(11, 1fr)",
44
- 12: "repeat(12, 1fr)"
33
+ 1: "repeat(1, minmax(0, 1fr))",
34
+ 2: "repeat(2, minmax(0, 1fr))",
35
+ 3: "repeat(3, minmax(0, 1fr))",
36
+ 4: "repeat(4, minmax(0, 1fr))",
37
+ 5: "repeat(5, minmax(0, 1fr))",
38
+ 6: "repeat(6, minmax(0, 1fr))",
39
+ 7: "repeat(7, minmax(0, 1fr))",
40
+ 8: "repeat(8, minmax(0, 1fr))",
41
+ 9: "repeat(9, minmax(0, 1fr))",
42
+ 10: "repeat(10, minmax(0, 1fr))",
43
+ 11: "repeat(11, minmax(0, 1fr))",
44
+ 12: "repeat(12, minmax(0, 1fr))"
45
45
  }
46
46
  },
47
47
  gridTemplateColumns: {
48
48
  type: "mapped-only",
49
49
  mapping: {
50
50
  0: "0px",
51
- 1: "repeat(1, 1fr)",
52
- 2: "repeat(2, 1fr)",
53
- 3: "repeat(3, 1fr)",
54
- 4: "repeat(4, 1fr)",
55
- 5: "repeat(5, 1fr)",
56
- 6: "repeat(6, 1fr)",
57
- 7: "repeat(7, 1fr)",
58
- 8: "repeat(8, 1fr)",
59
- 9: "repeat(9, 1fr)",
60
- 10: "repeat(10, 1fr)",
61
- 11: "repeat(11, 1fr)",
62
- 12: "repeat(12, 1fr)"
51
+ 1: "repeat(1, minmax(0, 1fr))",
52
+ 2: "repeat(2, minmax(0, 1fr))",
53
+ 3: "repeat(3, minmax(0, 1fr))",
54
+ 4: "repeat(4, minmax(0, 1fr))",
55
+ 5: "repeat(5, minmax(0, 1fr))",
56
+ 6: "repeat(6, minmax(0, 1fr))",
57
+ 7: "repeat(7, minmax(0, 1fr))",
58
+ 8: "repeat(8, minmax(0, 1fr))",
59
+ 9: "repeat(9, minmax(0, 1fr))",
60
+ 10: "repeat(10, minmax(0, 1fr))",
61
+ 11: "repeat(11, minmax(0, 1fr))",
62
+ 12: "repeat(12, minmax(0, 1fr))"
63
63
  }
64
64
  },
65
65
  gridTemplateRows: {
66
66
  type: "mapped-only",
67
67
  mapping: {
68
68
  0: "0px",
69
- 1: "repeat(1, 1fr)",
70
- 2: "repeat(2, 1fr)",
71
- 3: "repeat(3, 1fr)",
72
- 4: "repeat(4, 1fr)",
73
- 5: "repeat(5, 1fr)",
74
- 6: "repeat(6, 1fr)",
75
- 7: "repeat(7, 1fr)",
76
- 8: "repeat(8, 1fr)",
77
- 9: "repeat(9, 1fr)",
78
- 10: "repeat(10, 1fr)",
79
- 11: "repeat(11, 1fr)",
80
- 12: "repeat(12, 1fr)"
69
+ 1: "repeat(1, minmax(0, 1fr))",
70
+ 2: "repeat(2, minmax(0, 1fr))",
71
+ 3: "repeat(3, minmax(0, 1fr))",
72
+ 4: "repeat(4, minmax(0, 1fr))",
73
+ 5: "repeat(5, minmax(0, 1fr))",
74
+ 6: "repeat(6, minmax(0, 1fr))",
75
+ 7: "repeat(7, minmax(0, 1fr))",
76
+ 8: "repeat(8, minmax(0, 1fr))",
77
+ 9: "repeat(9, minmax(0, 1fr))",
78
+ 10: "repeat(10, minmax(0, 1fr))",
79
+ 11: "repeat(11, minmax(0, 1fr))",
80
+ 12: "repeat(12, minmax(0, 1fr))"
81
81
  }
82
82
  },
83
83
  justifyContent: {
@@ -89,18 +89,18 @@ const GRID_MODS = {
89
89
  name: "gridTemplateRows",
90
90
  mapping: {
91
91
  0: "0px",
92
- 1: "repeat(1, 1fr)",
93
- 2: "repeat(2, 1fr)",
94
- 3: "repeat(3, 1fr)",
95
- 4: "repeat(4, 1fr)",
96
- 5: "repeat(5, 1fr)",
97
- 6: "repeat(6, 1fr)",
98
- 7: "repeat(7, 1fr)",
99
- 8: "repeat(8, 1fr)",
100
- 9: "repeat(9, 1fr)",
101
- 10: "repeat(10, 1fr)",
102
- 11: "repeat(11, 1fr)",
103
- 12: "repeat(12, 1fr)"
92
+ 1: "repeat(1, minmax(0, 1fr))",
93
+ 2: "repeat(2, minmax(0, 1fr))",
94
+ 3: "repeat(3, minmax(0, 1fr))",
95
+ 4: "repeat(4, minmax(0, 1fr))",
96
+ 5: "repeat(5, minmax(0, 1fr))",
97
+ 6: "repeat(6, minmax(0, 1fr))",
98
+ 7: "repeat(7, minmax(0, 1fr))",
99
+ 8: "repeat(8, minmax(0, 1fr))",
100
+ 9: "repeat(9, minmax(0, 1fr))",
101
+ 10: "repeat(10, minmax(0, 1fr))",
102
+ 11: "repeat(11, minmax(0, 1fr))",
103
+ 12: "repeat(12, minmax(0, 1fr))"
104
104
  }
105
105
  }
106
106
  };
@@ -1 +1 @@
1
- {"version":3,"file":"grid.mods.js","sources":["../../src/transforms/latest/grid/grid.mods.ts"],"sourcesContent":["import {LAYOUT_MODS} from '../../../constants/latest/layout-mods'\nimport type {AttributeMods} from '../../../types/AttributeMods'\n\n/** @internal */\nexport const GRID_MODS: AttributeMods = {\n ...LAYOUT_MODS,\n alignItems: {\n type: 'style-only',\n style: 'alignItems',\n },\n autoCols: {\n type: 'rename-only',\n name: 'gridAutoColumns',\n },\n autoFlow: {\n type: 'rename-only',\n name: 'gridAutoFlow',\n },\n autoRows: {\n type: 'rename-only',\n name: 'gridAutoRows',\n },\n flexDirection: {\n type: 'style-only',\n style: 'flexDirection',\n },\n flexWrap: {\n type: 'style-only',\n style: 'flexWrap',\n },\n columns: {\n type: 'rename-mapped',\n name: 'gridTemplateColumns',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, 1fr)',\n 2: 'repeat(2, 1fr)',\n 3: 'repeat(3, 1fr)',\n 4: 'repeat(4, 1fr)',\n 5: 'repeat(5, 1fr)',\n 6: 'repeat(6, 1fr)',\n 7: 'repeat(7, 1fr)',\n 8: 'repeat(8, 1fr)',\n 9: 'repeat(9, 1fr)',\n 10: 'repeat(10, 1fr)',\n 11: 'repeat(11, 1fr)',\n 12: 'repeat(12, 1fr)',\n },\n },\n gridTemplateColumns: {\n type: 'mapped-only',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, 1fr)',\n 2: 'repeat(2, 1fr)',\n 3: 'repeat(3, 1fr)',\n 4: 'repeat(4, 1fr)',\n 5: 'repeat(5, 1fr)',\n 6: 'repeat(6, 1fr)',\n 7: 'repeat(7, 1fr)',\n 8: 'repeat(8, 1fr)',\n 9: 'repeat(9, 1fr)',\n 10: 'repeat(10, 1fr)',\n 11: 'repeat(11, 1fr)',\n 12: 'repeat(12, 1fr)',\n },\n },\n gridTemplateRows: {\n type: 'mapped-only',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, 1fr)',\n 2: 'repeat(2, 1fr)',\n 3: 'repeat(3, 1fr)',\n 4: 'repeat(4, 1fr)',\n 5: 'repeat(5, 1fr)',\n 6: 'repeat(6, 1fr)',\n 7: 'repeat(7, 1fr)',\n 8: 'repeat(8, 1fr)',\n 9: 'repeat(9, 1fr)',\n 10: 'repeat(10, 1fr)',\n 11: 'repeat(11, 1fr)',\n 12: 'repeat(12, 1fr)',\n },\n },\n justifyContent: {\n type: 'style-only',\n style: 'justifyContent',\n },\n rows: {\n type: 'rename-mapped',\n name: 'gridTemplateRows',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, 1fr)',\n 2: 'repeat(2, 1fr)',\n 3: 'repeat(3, 1fr)',\n 4: 'repeat(4, 1fr)',\n 5: 'repeat(5, 1fr)',\n 6: 'repeat(6, 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M;AAAA,IACN,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAAA,EAEF,gBAAgB;AAAA,IACd,MAAM;AAAA,IACN,OAAO;AAAA,EAAA;AAAA,EAET,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAEJ;"}
1
+ {"version":3,"file":"grid.mods.js","sources":["../../src/transforms/latest/grid/grid.mods.ts"],"sourcesContent":["import {LAYOUT_MODS} from '../../../constants/latest/layout-mods'\nimport type {AttributeMods} from '../../../types/AttributeMods'\n\n/** @internal */\nexport const GRID_MODS: AttributeMods = {\n ...LAYOUT_MODS,\n alignItems: {\n type: 'style-only',\n style: 'alignItems',\n },\n autoCols: {\n type: 'rename-only',\n name: 'gridAutoColumns',\n },\n autoFlow: {\n type: 'rename-only',\n name: 'gridAutoFlow',\n },\n autoRows: {\n type: 'rename-only',\n name: 'gridAutoRows',\n },\n flexDirection: {\n type: 'style-only',\n style: 'flexDirection',\n },\n flexWrap: {\n type: 'style-only',\n style: 'flexWrap',\n },\n columns: {\n type: 'rename-mapped',\n name: 'gridTemplateColumns',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, minmax(0, 1fr))',\n 2: 'repeat(2, minmax(0, 1fr))',\n 3: 'repeat(3, minmax(0, 1fr))',\n 4: 'repeat(4, minmax(0, 1fr))',\n 5: 'repeat(5, minmax(0, 1fr))',\n 6: 'repeat(6, minmax(0, 1fr))',\n 7: 'repeat(7, minmax(0, 1fr))',\n 8: 'repeat(8, minmax(0, 1fr))',\n 9: 'repeat(9, minmax(0, 1fr))',\n 10: 'repeat(10, minmax(0, 1fr))',\n 11: 'repeat(11, minmax(0, 1fr))',\n 12: 'repeat(12, minmax(0, 1fr))',\n },\n },\n gridTemplateColumns: {\n type: 'mapped-only',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, minmax(0, 1fr))',\n 2: 'repeat(2, minmax(0, 1fr))',\n 3: 'repeat(3, minmax(0, 1fr))',\n 4: 'repeat(4, minmax(0, 1fr))',\n 5: 'repeat(5, minmax(0, 1fr))',\n 6: 'repeat(6, minmax(0, 1fr))',\n 7: 'repeat(7, minmax(0, 1fr))',\n 8: 'repeat(8, minmax(0, 1fr))',\n 9: 'repeat(9, minmax(0, 1fr))',\n 10: 'repeat(10, minmax(0, 1fr))',\n 11: 'repeat(11, minmax(0, 1fr))',\n 12: 'repeat(12, minmax(0, 1fr))',\n },\n },\n gridTemplateRows: {\n type: 'mapped-only',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, minmax(0, 1fr))',\n 2: 'repeat(2, minmax(0, 1fr))',\n 3: 'repeat(3, minmax(0, 1fr))',\n 4: 'repeat(4, minmax(0, 1fr))',\n 5: 'repeat(5, minmax(0, 1fr))',\n 6: 'repeat(6, minmax(0, 1fr))',\n 7: 'repeat(7, minmax(0, 1fr))',\n 8: 'repeat(8, minmax(0, 1fr))',\n 9: 'repeat(9, minmax(0, 1fr))',\n 10: 'repeat(10, minmax(0, 1fr))',\n 11: 'repeat(11, minmax(0, 1fr))',\n 12: 'repeat(12, minmax(0, 1fr))',\n },\n },\n justifyContent: {\n type: 'style-only',\n style: 'justifyContent',\n },\n rows: {\n type: 'rename-mapped',\n name: 'gridTemplateRows',\n mapping: {\n 0: '0px',\n 1: 'repeat(1, minmax(0, 1fr))',\n 2: 'repeat(2, minmax(0, 1fr))',\n 3: 'repeat(3, minmax(0, 1fr))',\n 4: 'repeat(4, minmax(0, 1fr))',\n 5: 'repeat(5, minmax(0, 1fr))',\n 6: 'repeat(6, minmax(0, 1fr))',\n 7: 'repeat(7, minmax(0, 1fr))',\n 8: 'repeat(8, minmax(0, 1fr))',\n 9: 'repeat(9, minmax(0, 1fr))',\n 10: 'repeat(10, minmax(0, 1fr))',\n 11: 'repeat(11, minmax(0, 1fr))',\n 12: 'repeat(12, minmax(0, 1fr))',\n },\n },\n}\n"],"names":[],"mappings":";AAIO,MAAM,YAA2B;AAAA,EACtC,GAAG;AAAA,EACH,YAAY;AAAA,IACV,MAAM;AAAA,IACN,OAAO;AAAA,EAAA;AAAA,EAET,UAAU;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,EAAA;AAAA,EAER,UAAU;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,EAAA;AAAA,EAER,UAAU;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,EAAA;AAAA,EAER,eAAe;AAAA,IACb,MAAM;AAAA,IACN,OAAO;AAAA,EAAA;AAAA,EAET,UAAU;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,EAAA;AAAA,EAET,SAAS;AAAA,IACP,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAAA,EAEF,qBAAqB;AAAA,IACnB,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAAA,EAEF,kBAAkB;AAAA,IAChB,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAAA,EAEF,gBAAgB;AAAA,IACd,MAAM;AAAA,IACN,OAAO;AAAA,EAAA;AAAA,EAET,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAEJ;"}
@@ -1,6 +1,13 @@
1
1
  import { readFileSync, existsSync } from "node:fs";
2
2
  import { resolve, dirname, join } from "node:path";
3
3
  import "jscodeshift";
4
+ function getAttribute(attrs, name) {
5
+ if (attrs) {
6
+ for (const attr of attrs)
7
+ if (attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === name)
8
+ return attr;
9
+ }
10
+ }
4
11
  function getClonedImportSpecifiers(j, specifiers = []) {
5
12
  return specifiers.map((spec) => {
6
13
  if (spec.type === "ImportSpecifier") {
@@ -86,58 +93,6 @@ function getComponentLocalNames(j, root, componentName, options) {
86
93
  }
87
94
  }), importedNames.size > 0 ? importedNames : hasOtherPackageImport ? /* @__PURE__ */ new Set() : root.find(j.JSXOpeningElement).some(({ node }) => node.name.type === "JSXIdentifier" && node.name.name === componentName) ? /* @__PURE__ */ new Set([componentName]) : /* @__PURE__ */ new Set();
88
95
  }
89
- function getAttribute(attrs, name) {
90
- if (attrs) {
91
- for (const attr of attrs)
92
- if (attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === name)
93
- return attr;
94
- }
95
- }
96
- function getAttributeExpression(attr, j) {
97
- return attr.value ? attr.value.type === "StringLiteral" || attr.value.type === "Literal" ? attr.value : attr.value.type === "JSXExpressionContainer" ? attr.value.expression : null : j.booleanLiteral(!0);
98
- }
99
- function getStaticPrimitive(expr) {
100
- if (expr.type === "StringLiteral" || expr.type === "NumericLiteral" || expr.type === "BooleanLiteral" || expr.type === "Literal") {
101
- const { value } = expr;
102
- if (typeof value == "string" || typeof value == "number" || typeof value == "boolean")
103
- return value;
104
- }
105
- }
106
- function getStaticAttributeExpression(j, attrs, name) {
107
- const attr = getAttribute(attrs, name);
108
- if (!attr)
109
- return null;
110
- const expr = getAttributeExpression(attr, j);
111
- if (!expr)
112
- return null;
113
- const primitive = getStaticPrimitive(expr);
114
- if (primitive !== void 0)
115
- return primitive;
116
- if (expr.type !== "ArrayExpression")
117
- return null;
118
- const elements = expr.elements, values = [];
119
- for (const element of elements) {
120
- if (element === null || element.type === "NullLiteral") {
121
- values.push(null);
122
- continue;
123
- }
124
- if (element.type === "SpreadElement")
125
- return null;
126
- if (element.type === "Literal" && element.value === null) {
127
- values.push(null);
128
- continue;
129
- }
130
- if (element.type === "Identifier" && element.name === "undefined") {
131
- values.push(void 0);
132
- continue;
133
- }
134
- const elementValue = getStaticPrimitive(element);
135
- if (elementValue === void 0)
136
- return null;
137
- values.push(elementValue);
138
- }
139
- return values;
140
- }
141
96
  const parseCache = /* @__PURE__ */ new Map();
142
97
  function parseModule(j, filePath) {
143
98
  const cached = parseCache.get(filePath);
@@ -282,6 +237,51 @@ function shouldTransformComponent(j, root, componentName, localNames, options, s
282
237
  return componentSpecs.length > 0;
283
238
  });
284
239
  }
240
+ function getAttributeExpression(attr, j) {
241
+ return attr.value ? attr.value.type === "StringLiteral" || attr.value.type === "Literal" ? attr.value : attr.value.type === "JSXExpressionContainer" ? attr.value.expression : null : j.booleanLiteral(!0);
242
+ }
243
+ function getStaticPrimitive(expr) {
244
+ if (expr.type === "StringLiteral" || expr.type === "NumericLiteral" || expr.type === "BooleanLiteral" || expr.type === "Literal") {
245
+ const { value } = expr;
246
+ if (typeof value == "string" || typeof value == "number" || typeof value == "boolean")
247
+ return value;
248
+ }
249
+ }
250
+ function getStaticAttributeExpression(j, attrs, name) {
251
+ const attr = getAttribute(attrs, name);
252
+ if (!attr)
253
+ return null;
254
+ const expr = getAttributeExpression(attr, j);
255
+ if (!expr)
256
+ return null;
257
+ const primitive = getStaticPrimitive(expr);
258
+ if (primitive !== void 0)
259
+ return primitive;
260
+ if (expr.type !== "ArrayExpression")
261
+ return null;
262
+ const elements = expr.elements, values = [];
263
+ for (const element of elements) {
264
+ if (element === null || element.type === "NullLiteral") {
265
+ values.push(null);
266
+ continue;
267
+ }
268
+ if (element.type === "SpreadElement")
269
+ return null;
270
+ if (element.type === "Literal" && element.value === null) {
271
+ values.push(null);
272
+ continue;
273
+ }
274
+ if (element.type === "Identifier" && element.name === "undefined") {
275
+ values.push(void 0);
276
+ continue;
277
+ }
278
+ const elementValue = getStaticPrimitive(element);
279
+ if (elementValue === void 0)
280
+ return null;
281
+ values.push(elementValue);
282
+ }
283
+ return values;
284
+ }
285
285
  function getCompositeAttrValue(j, attrs, mapping) {
286
286
  let compositeAttrValue = null;
287
287
  for (const compositeKey of Object.keys(mapping)) {
@@ -1 +1 @@
1
- {"version":3,"file":"transformStyledComponents.js","sources":["../../src/utils/getClonedImportSpecifiers.ts","../../src/utils/getSplitImportSpecifiers.ts","../../src/utils/transformImport.ts","../../src/utils/getComponentLocalNames.ts","../../src/utils/getAttribute.ts","../../src/utils/getAttributeExpression.ts","../../src/utils/getStaticAttributeExpression.ts","../../src/utils/parseModule.ts","../../src/utils/resolveRelativeModulePath.ts","../../src/utils/getNamedExportInit.ts","../../src/utils/getStyledComponentName.ts","../../src/utils/getStyledComponentAliases.ts","../../src/utils/insertTodoWarning.ts","../../src/utils/shouldTransformComponent.ts","../../src/utils/getCompositeAttrValue.ts","../../src/utils/getMappingExpression.ts","../../src/utils/getMappingValue.ts","../../src/utils/getMappingArray.ts","../../src/utils/getShorthandAttributes.ts","../../src/utils/getStyleExpression.ts","../../src/utils/isValidStyleType.ts","../../src/utils/mergeStyle.ts","../../src/utils/transformAttributes.ts","../../src/utils/transformComponent.ts","../../src/utils/transformStyledComponents.ts"],"sourcesContent":["import type {API, ImportDefaultSpecifier, ImportSpecifier} from 'jscodeshift'\n\nexport function getClonedImportSpecifiers(\n j: API['jscodeshift'],\n specifiers: (ImportSpecifier | ImportDefaultSpecifier)[] = [],\n) {\n return specifiers.map((spec) => {\n if (spec.type === 'ImportSpecifier') {\n if (spec.imported.type !== 'Identifier' || spec.local?.type !== 'Identifier') {\n return spec\n }\n\n const clone = j.importSpecifier(\n j.identifier(spec.imported.name),\n j.identifier(spec.local.name),\n )\n\n if ('importKind' in spec && spec.importKind === 'type') {\n Object.assign(clone, {importKind: 'type'})\n }\n\n return clone\n } else {\n return j.importDefaultSpecifier(\n j.identifier((spec as ImportDefaultSpecifier).local?.name as string),\n )\n }\n })\n}\n","import type {ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier} from 'jscodeshift'\n\nexport function getSplitImportSpecifiers(\n specifiers: (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[] = [],\n componentName: string,\n) {\n const componentNames = new Set([componentName, `${componentName}Props`])\n const specs = {\n componentSpecs: [] as (ImportSpecifier | ImportDefaultSpecifier)[],\n restSpecs: [] as (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[],\n }\n\n for (const spec of specifiers) {\n if (spec.type === 'ImportNamespaceSpecifier') {\n specs.restSpecs.push(spec)\n continue\n }\n\n if (spec.type === 'ImportSpecifier' || spec.type === 'ImportDefaultSpecifier') {\n let local\n\n if (spec.type === 'ImportSpecifier') {\n const loc = spec.local ?? spec.imported\n local = loc.type === 'Identifier' ? loc.name : null\n }\n\n if (spec.type === 'ImportDefaultSpecifier') {\n local = spec.local?.type === 'Identifier' ? spec.local.name : null\n }\n\n if (local && componentNames.has(local)) {\n specs.componentSpecs.push(spec)\n } else {\n specs.restSpecs.push(spec)\n }\n }\n }\n\n return specs\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport {getClonedImportSpecifiers} from './getClonedImportSpecifiers'\nimport {getSplitImportSpecifiers} from './getSplitImportSpecifiers'\n\nexport const DEFAULT_UI_PACKAGE = '@sanity/ui'\n\n/**\n * Rewrites imports from `fromPackage` to `toPackage`, splitting imports if needed.\n * Returns whether the AST was updated.\n */\nexport function transformImport(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n fromPackage: string = DEFAULT_UI_PACKAGE,\n toPackage: string = DEFAULT_UI_PACKAGE,\n): boolean {\n if (fromPackage === toPackage) {\n return false\n }\n\n let hasChanges = false\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const node = path.node\n\n if (node.source.value !== fromPackage) {\n return\n }\n\n const {componentSpecs, restSpecs} = getSplitImportSpecifiers(node.specifiers, componentName)\n\n if (componentSpecs.length === 0) {\n return\n }\n\n if (restSpecs.length === 0) {\n if (node.source && typeof node.source === 'object' && 'value' in node.source) {\n const sourceLiteral = node.source as {value: string}\n sourceLiteral.value = toPackage\n }\n\n hasChanges = true\n return\n }\n\n path.node.specifiers = restSpecs\n const clonedImportSpecifiers = getClonedImportSpecifiers(j, componentSpecs)\n path.insertAfter(j.importDeclaration(clonedImportSpecifiers, j.stringLiteral(toPackage)))\n hasChanges = true\n })\n\n return hasChanges\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport type {BaseOptions} from '../types/BaseOptions'\nimport {DEFAULT_UI_PACKAGE} from './transformImport'\n\nexport function getComponentLocalNames(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n options?: BaseOptions,\n): Set<string> {\n const importedNames = new Set<string>()\n const packages = new Set([\n options?.fromPackage ?? DEFAULT_UI_PACKAGE,\n options?.toPackage ?? DEFAULT_UI_PACKAGE,\n ])\n let hasOtherPackageImport = false\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const node = path.node\n\n if ('importKind' in node && node.importKind === 'type') {\n return\n }\n\n const matchesPackage = packages.has(node.source.value as string)\n\n for (const spec of node.specifiers ?? []) {\n if (spec.type !== 'ImportSpecifier') {\n continue\n }\n\n if ('importKind' in spec && spec.importKind === 'type') {\n continue\n }\n\n if (spec.imported.type !== 'Identifier' || spec.imported.name !== componentName) {\n continue\n }\n\n const local = spec.local?.type === 'Identifier' ? spec.local.name : spec.imported.name\n\n if (!matchesPackage) {\n hasOtherPackageImport = true\n continue\n }\n\n importedNames.add(local)\n }\n })\n\n if (importedNames.size > 0) {\n return importedNames\n }\n\n if (hasOtherPackageImport) {\n return new Set()\n }\n\n const usesComponentInJsx = root.find(j.JSXOpeningElement).some(({node}) => {\n return node.name.type === 'JSXIdentifier' && node.name.name === componentName\n })\n\n if (usesComponentInJsx) {\n return new Set([componentName])\n }\n\n return new Set()\n}\n","import type {JSXAttribute, JSXElement} from 'jscodeshift'\n\nexport function getAttribute(\n attrs: JSXElement['openingElement']['attributes'],\n name: string,\n): JSXAttribute | undefined {\n if (!attrs) {\n return undefined\n }\n\n for (const attr of attrs) {\n if (\n attr.type === 'JSXAttribute' &&\n attr.name.type === 'JSXIdentifier' &&\n attr.name.name === name\n ) {\n return attr\n }\n }\n\n return undefined\n}\n","import {type API, type JSXAttribute} from 'jscodeshift'\n\nimport {type AnyExpression} from '../types/AnyExpression'\n\nexport function getAttributeExpression(\n attr: JSXAttribute,\n j: API['jscodeshift'],\n): AnyExpression | null {\n if (!attr.value) {\n return j.booleanLiteral(true)\n }\n\n if (attr.value.type === 'StringLiteral' || attr.value.type === 'Literal') {\n return attr.value\n }\n\n if (attr.value.type === 'JSXExpressionContainer') {\n return attr.value.expression\n }\n\n return null\n}\n","import type {API, JSXAttribute, JSXSpreadAttribute} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\nimport {getAttribute} from './getAttribute'\nimport {getAttributeExpression} from './getAttributeExpression'\n\nexport type CompositePrimitive = string | number | boolean\n\nexport type StaticAttributeValue = CompositePrimitive | (CompositePrimitive | null | undefined)[]\n\nfunction getStaticPrimitive(expr: AnyExpression): CompositePrimitive | undefined {\n if (\n expr.type === 'StringLiteral' ||\n expr.type === 'NumericLiteral' ||\n expr.type === 'BooleanLiteral' ||\n expr.type === 'Literal'\n ) {\n const {value} = expr\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n return value\n }\n }\n\n return undefined\n}\n\nexport function getStaticAttributeExpression(\n j: API['jscodeshift'],\n attrs: (JSXAttribute | JSXSpreadAttribute)[],\n name: string,\n): StaticAttributeValue | null {\n const attr = getAttribute(attrs, name)\n\n if (!attr) {\n return null\n }\n\n const expr = getAttributeExpression(attr, j)\n\n if (!expr) {\n return null\n }\n\n const primitive = getStaticPrimitive(expr as AnyExpression)\n\n if (primitive !== undefined) {\n return primitive\n }\n\n if (expr.type !== 'ArrayExpression') {\n return null\n }\n\n const elements = expr.elements as ((AnyExpression & {name?: string}) | null)[]\n const values: (CompositePrimitive | null | undefined)[] = []\n\n for (const element of elements) {\n if (element === null || element.type === 'NullLiteral') {\n values.push(null)\n continue\n }\n\n if (element.type === 'SpreadElement') {\n return null\n }\n\n if (element.type === 'Literal' && element.value === null) {\n values.push(null)\n continue\n }\n\n if (element.type === 'Identifier' && element.name === 'undefined') {\n values.push(undefined)\n continue\n }\n\n const elementValue = getStaticPrimitive(element)\n\n if (elementValue === undefined) {\n return null\n }\n\n values.push(elementValue)\n }\n\n return values\n}\n","import {readFileSync} from 'node:fs'\n\nimport type {API, Collection} from 'jscodeshift'\n\nconst parseCache = new Map<string, Collection>()\n\nexport function parseModule(j: API['jscodeshift'], filePath: string): Collection | null {\n const cached = parseCache.get(filePath)\n\n if (cached) {\n return cached\n }\n\n try {\n const source = readFileSync(filePath, 'utf8')\n const root = j(source)\n\n parseCache.set(filePath, root)\n\n return root\n } catch {\n return null\n }\n}\n\n/** @internal */\nexport function clearModuleParseCache(): void {\n parseCache.clear()\n}\n","import {existsSync} from 'node:fs'\nimport {dirname, join, resolve} from 'node:path'\n\nconst EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js'] as const\n\nexport function resolveRelativeModulePath(\n fromFilePath: string,\n moduleSpecifier: string,\n): string | null {\n if (!moduleSpecifier.startsWith('.')) {\n return null\n }\n\n const base = resolve(dirname(fromFilePath), moduleSpecifier)\n\n for (const ext of EXTENSIONS) {\n const filePath = `${base}${ext}`\n\n if (existsSync(filePath)) {\n return filePath\n }\n }\n\n for (const ext of EXTENSIONS) {\n const indexPath = join(base, `index${ext}`)\n\n if (existsSync(indexPath)) {\n return indexPath\n }\n }\n\n if (existsSync(base)) {\n return base\n }\n\n return null\n}\n","import type {API, Expression, ExportSpecifier} from 'jscodeshift'\n\nimport {parseModule} from './parseModule'\nimport {resolveRelativeModulePath} from './resolveRelativeModulePath'\n\nexport type NamedExportInit = {\n init: Expression\n modulePath: string\n}\n\nfunction findVariableInit(\n j: API['jscodeshift'],\n root: ReturnType<API['jscodeshift']>,\n name: string,\n): Expression | null {\n let init: Expression | null = null\n\n root.find(j.VariableDeclarator).forEach((path) => {\n const {id} = path.node\n\n if (id.type === 'Identifier' && id.name === name && path.node.init) {\n init = path.node.init\n }\n })\n\n return init\n}\n\nfunction getExportSpecifierName(exported: ExportSpecifier['exported']): string | null {\n if (exported.type === 'Identifier' || exported.type === 'JSXIdentifier') {\n return exported.name\n }\n\n return null\n}\n\nexport function getNamedExportInit(\n j: API['jscodeshift'],\n exportName: string,\n filePath: string,\n visited: Set<string> = new Set(),\n): NamedExportInit | null {\n if (visited.has(filePath)) {\n return null\n }\n\n visited.add(filePath)\n\n const root = parseModule(j, filePath)\n\n if (!root) {\n return null\n }\n\n for (const path of root.find(j.ExportNamedDeclaration).paths()) {\n const {declaration, specifiers, source} = path.node\n const reexportSource = typeof source?.value === 'string' ? source.value : null\n\n if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.type !== 'VariableDeclarator') {\n continue\n }\n\n if (\n declarator.id.type === 'Identifier' &&\n declarator.id.name === exportName &&\n declarator.init\n ) {\n return {init: declarator.init, modulePath: filePath}\n }\n }\n }\n\n for (const spec of specifiers ?? []) {\n if (spec.type !== 'ExportSpecifier') {\n continue\n }\n\n const exported = getExportSpecifierName(spec.exported)\n\n if (!exported || exported !== exportName) {\n continue\n }\n\n const local = spec.local?.type === 'Identifier' ? spec.local.name : exported\n\n if (reexportSource) {\n const resolvedPath = resolveRelativeModulePath(filePath, reexportSource)\n\n if (resolvedPath) {\n const followed = getNamedExportInit(j, local, resolvedPath, visited)\n\n if (followed) {\n return followed\n }\n }\n\n continue\n }\n\n const init = findVariableInit(j, root, local)\n\n if (init) {\n return {init, modulePath: filePath}\n }\n }\n }\n\n return null\n}\n","export function getStyledComponentName(node: unknown): string | null {\n if (!node || typeof node !== 'object' || !('type' in node)) {\n return null\n }\n\n const current = node as {\n type: string\n callee?: unknown\n tag?: unknown\n object?: unknown\n arguments?: unknown[]\n }\n\n if (current.type === 'TaggedTemplateExpression') {\n return getStyledComponentName(current.tag)\n }\n\n if (current.type === 'CallExpression') {\n const callee = current.callee\n\n if (\n callee &&\n typeof callee === 'object' &&\n 'type' in callee &&\n callee.type === 'Identifier' &&\n 'name' in callee &&\n callee.name === 'styled'\n ) {\n const arg = current.arguments?.[0]\n\n if (\n arg &&\n typeof arg === 'object' &&\n 'type' in arg &&\n arg.type === 'Identifier' &&\n 'name' in arg\n ) {\n return arg.name as string\n }\n\n return null\n }\n\n return getStyledComponentName(callee)\n }\n\n if (current.type === 'MemberExpression' && current.object) {\n return getStyledComponentName(current.object)\n }\n\n return null\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport type {BaseOptions} from '../types/BaseOptions'\nimport {getComponentLocalNames} from './getComponentLocalNames'\nimport {getNamedExportInit} from './getNamedExportInit'\nimport {getStyledComponentName} from './getStyledComponentName'\nimport {parseModule} from './parseModule'\nimport {resolveRelativeModulePath} from './resolveRelativeModulePath'\n\nexport function getSameFileStyledComponentAliases(\n j: API['jscodeshift'],\n root: Collection,\n localNames: Iterable<string>,\n): Set<string> {\n const aliases = new Set<string>()\n const names = new Set(localNames)\n\n root.find(j.VariableDeclarator).forEach((path) => {\n const {id, init} = path.node\n\n if (!init || id.type !== 'Identifier') {\n return\n }\n\n const baseComponent = getStyledComponentName(init)\n\n if (baseComponent && names.has(baseComponent)) {\n aliases.add(id.name)\n }\n })\n\n return aliases\n}\n\nexport function getImportedStyledComponentAliases(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n filePath: string | undefined,\n options?: BaseOptions,\n): Set<string> {\n const aliases = new Set<string>()\n\n if (!filePath) {\n return aliases\n }\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const source = path.node.source.value\n\n if (typeof source !== 'string') {\n return\n }\n\n const resolvedPath = resolveRelativeModulePath(filePath, source)\n\n if (!resolvedPath) {\n return\n }\n\n for (const spec of path.node.specifiers ?? []) {\n if (spec.type !== 'ImportSpecifier') {\n continue\n }\n\n if ('importKind' in spec && spec.importKind === 'type') {\n continue\n }\n\n if (spec.imported.type !== 'Identifier') {\n continue\n }\n\n const exportName = spec.imported.name\n const localName = spec.local?.type === 'Identifier' ? spec.local.name : exportName\n const namedExport = getNamedExportInit(j, exportName, resolvedPath)\n\n if (!namedExport) {\n continue\n }\n\n const sourceRoot = parseModule(j, namedExport.modulePath)\n\n if (!sourceRoot) {\n continue\n }\n\n const exportLocalNames = getComponentLocalNames(j, sourceRoot, componentName, options)\n const baseComponent = getStyledComponentName(namedExport.init)\n\n if (baseComponent && exportLocalNames.has(baseComponent)) {\n aliases.add(localName)\n }\n }\n })\n\n return aliases\n}\n\nexport function getStyledComponentAliases(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n filePath: string | undefined,\n localNames: Set<string>,\n options?: BaseOptions,\n): Set<string> {\n const sameFile = getSameFileStyledComponentAliases(j, root, localNames)\n const imported = getImportedStyledComponentAliases(j, root, componentName, filePath, options)\n\n return new Set([...sameFile, ...imported])\n}\n","import {type API, type ASTPath, type ImportDeclaration, type JSXOpeningElement} from 'jscodeshift'\n\ntype CommentableNode = {\n comments?: {type: string; value: string; leading?: boolean}[] | null\n}\n\n/**\n * Inserts a `UI-CODEMOD TODO` comment.\n * Returns whether the AST was updated.\n */\nexport function insertTodoWarning(\n j: API['jscodeshift'],\n path: ASTPath<JSXOpeningElement | ImportDeclaration>,\n warning: string,\n): boolean {\n let target: CommentableNode | null = null\n\n if (path.node.type === 'ImportDeclaration') {\n target = path.node\n } else if (path.parent?.node.type === 'JSXElement') {\n target = path.parent.node\n }\n\n if (!target) {\n return false\n }\n\n target.comments ??= []\n\n if (target.comments.some((comment) => comment.value.includes(warning))) {\n return false\n }\n\n target.comments.unshift(j.commentLine(` UI-CODEMOD TODO: ${warning}`, true))\n return true\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport type {BaseOptions} from '../types/BaseOptions'\nimport {getSplitImportSpecifiers} from './getSplitImportSpecifiers'\nimport {DEFAULT_UI_PACKAGE} from './transformImport'\n\n/**\n * Returns whether a component transform should run on this file, based on local\n * usage or a pending import rewrite.\n */\nexport function shouldTransformComponent(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n localNames: Set<string>,\n options?: BaseOptions,\n styledAliases?: Set<string>,\n): boolean {\n if (localNames.size > 0) {\n return true\n }\n\n if (styledAliases && styledAliases.size > 0) {\n return true\n }\n\n const fromPackage = options?.fromPackage ?? DEFAULT_UI_PACKAGE\n const toPackage = options?.toPackage ?? DEFAULT_UI_PACKAGE\n\n if (fromPackage === toPackage) {\n return false\n }\n\n return root.find(j.ImportDeclaration).some((path) => {\n const node = path.node\n\n if (node.source.value !== fromPackage) {\n return false\n }\n\n const {componentSpecs} = getSplitImportSpecifiers(node.specifiers, componentName)\n\n return componentSpecs.length > 0\n })\n}\n","import type {API, JSXAttribute, JSXSpreadAttribute} from 'jscodeshift'\n\nimport type {CompositeAttributeMapping} from '../types/AttributeMods'\nimport {getStaticAttributeExpression} from './getStaticAttributeExpression'\n\nexport function getCompositeAttrValue(\n j: API['jscodeshift'],\n attrs: (JSXAttribute | JSXSpreadAttribute)[],\n mapping: CompositeAttributeMapping,\n) {\n let compositeAttrValue: string | null = null\n\n for (const compositeKey of Object.keys(mapping)) {\n const compositeMapping = mapping[compositeKey]\n\n if (!compositeMapping) {\n continue\n }\n\n let hasMatchingValues = true\n\n for (const propName of Object.keys(compositeMapping)) {\n const mappingValue = compositeMapping[propName]\n const attrValue = getStaticAttributeExpression(j, attrs, propName)\n\n if (mappingValue === undefined || attrValue !== mappingValue) {\n hasMatchingValues = false\n break\n }\n }\n\n if (hasMatchingValues) {\n compositeAttrValue = compositeKey\n break\n }\n }\n\n return compositeAttrValue\n}\n","import {type API} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\n\nexport function getMappingExpression(\n j: API['jscodeshift'],\n val: string | boolean | number | undefined,\n): AnyExpression {\n if (val === undefined) {\n return j.identifier('undefined')\n }\n\n if (typeof val === 'boolean') {\n return j.booleanLiteral(val)\n }\n\n if (typeof val === 'number') {\n return j.numericLiteral(val)\n }\n\n return j.stringLiteral(val)\n}\n","import type {AnyExpression} from '../types/AnyExpression'\nimport type {AttributeMapping} from '../types/AttributeMods'\n\nexport function getMappingValue(mapping: AttributeMapping, expr: AnyExpression) {\n let key\n\n if (\n expr.type === 'NumericLiteral' ||\n expr.type === 'BooleanLiteral' ||\n expr.type === 'StringLiteral' ||\n expr.type === 'Literal'\n ) {\n key = String(expr.value)\n }\n\n if (expr.type === 'TemplateLiteral') {\n const expressions = expr.expressions as unknown[]\n const quasis = expr.quasis as {value: {cooked: string | null}}[]\n\n if (expressions.length === 0 && quasis.length === 1) {\n key = quasis[0]?.value.cooked ?? null\n }\n }\n\n if (key) {\n if (Object.prototype.hasOwnProperty.call(mapping, key)) {\n return mapping[key]\n }\n\n const number = Number(key)\n\n if (!Number.isNaN(number) && Object.prototype.hasOwnProperty.call(mapping, number)) {\n return mapping[number]\n }\n }\n\n if (\n expr.type === 'BooleanLiteral' ||\n (expr.type === 'Literal' && typeof expr.value === 'boolean')\n ) {\n for (const val in mapping) {\n if (expr.value === mapping[val]) {\n return mapping[val]\n }\n }\n }\n\n return\n}\n","import {type API, type ArrayExpression} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\nimport type {AttributeMapping} from '../types/AttributeMods'\nimport {getMappingExpression} from './getMappingExpression'\nimport {getMappingValue} from './getMappingValue'\n\nexport function getMappingArray(\n j: API['jscodeshift'],\n arr: AnyExpression,\n mapping: AttributeMapping,\n allowUndefined?: boolean,\n): ArrayExpression | null {\n if (arr.type !== 'ArrayExpression') {\n return null\n }\n\n const elements = arr.elements as (AnyExpression | null)[]\n const output: AnyExpression[] = []\n\n for (const el of elements) {\n if (el == null || el.type === 'SpreadElement') {\n return null\n }\n\n const mappingValue = getMappingValue(mapping, el)\n\n if (!mappingValue && !allowUndefined) {\n return null\n }\n\n output.push(getMappingExpression(j, mappingValue))\n }\n\n return j.arrayExpression(output as never[])\n}\n","import type {API, JSXAttribute} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\nimport type {AttributeMod} from '../types/AttributeMods'\nimport {getMappingArray} from './getMappingArray'\nimport {getMappingExpression} from './getMappingExpression'\nimport {getMappingValue} from './getMappingValue'\n\nexport function getShorthandAttributes(\n j: API['jscodeshift'],\n expr: AnyExpression,\n mod: AttributeMod,\n) {\n const attributes: JSXAttribute[] = []\n\n if (!('props' in mod)) {\n return []\n }\n\n if (expr.type === 'ArrayExpression') {\n for (const prop of mod.props) {\n const styleArray = getMappingArray(j, expr, prop.mapping, true)\n\n if (!styleArray) {\n continue\n }\n\n attributes.push(\n j.jsxAttribute(j.jsxIdentifier(prop.name), j.jsxExpressionContainer(styleArray)),\n )\n }\n }\n\n for (const prop of mod.props) {\n const styleValue = getMappingValue(prop.mapping, expr)\n\n if (styleValue === undefined) {\n continue\n }\n\n if (typeof styleValue === 'string') {\n attributes.push(j.jsxAttribute(j.jsxIdentifier(prop.name), j.stringLiteral(styleValue)))\n } else {\n attributes.push(\n j.jsxAttribute(\n j.jsxIdentifier(prop.name),\n j.jsxExpressionContainer(getMappingExpression(j, styleValue) as never),\n ),\n )\n }\n }\n\n return attributes\n}\n","import {type API} from 'jscodeshift'\n\nimport {type AnyExpression} from '../types/AnyExpression'\n\nexport function getStyleExpression(j: API['jscodeshift'], expr: AnyExpression): AnyExpression {\n if (expr.type === 'Literal') {\n if (expr.value === null) {\n return j.literal(null)\n }\n\n if (typeof expr.value === 'boolean') {\n return j.booleanLiteral(expr.value)\n }\n\n if (typeof expr.value === 'number') {\n return j.numericLiteral(expr.value)\n }\n\n if (typeof expr.value === 'string') {\n return j.stringLiteral(expr.value)\n }\n }\n\n if (expr.type === 'BooleanLiteral') {\n return j.booleanLiteral(expr.value as boolean)\n }\n\n if (expr.type === 'NumericLiteral') {\n return j.numericLiteral(expr.value as number)\n }\n\n if (expr.type === 'StringLiteral') {\n return j.stringLiteral(expr.value as string)\n }\n\n return expr\n}\n","import {type AnyExpression} from '../types/AnyExpression'\n\nexport function isValidStyleType(expr: AnyExpression) {\n if (expr.type === 'TemplateLiteral') {\n const expressions = expr.expressions as unknown[]\n const quasis = expr.quasis as {value: {cooked: string | null}}[]\n return expressions.length === 0 && quasis.length === 1\n }\n\n if (\n expr.type === 'StringLiteral' ||\n expr.type === 'Literal' ||\n expr.type === 'NumericLiteral' ||\n expr.type === 'BooleanLiteral' ||\n expr.type === 'NullLiteral'\n ) {\n return true\n }\n\n return false\n}\n","import {type API, type JSXAttribute, type JSXSpreadAttribute} from 'jscodeshift'\n\nimport {type AnyExpression} from '../types/AnyExpression'\n\nexport function mergeStyle(\n j: API['jscodeshift'],\n attrs: (JSXAttribute | JSXSpreadAttribute)[],\n styleKey: string,\n styleExpression: AnyExpression,\n) {\n const styleProp = j.objectProperty(j.identifier(styleKey), styleExpression as never)\n\n const styleIndex = attrs.findIndex(\n (a): a is JSXAttribute =>\n a.type === 'JSXAttribute' && a.name.type === 'JSXIdentifier' && a.name.name === 'style',\n )\n\n if (styleIndex === -1) {\n attrs.push(\n j.jsxAttribute(\n j.jsxIdentifier('style'),\n j.jsxExpressionContainer(j.objectExpression([styleProp])),\n ),\n )\n\n return true\n }\n\n const styleAttr = attrs[styleIndex] as JSXAttribute\n\n if (styleAttr.value?.type !== 'JSXExpressionContainer') {\n return false\n }\n\n const expr = styleAttr.value.expression\n\n if (expr.type === 'ObjectExpression') {\n expr.properties = expr.properties.filter((prop) => {\n if (prop.type !== 'ObjectProperty' && prop.type !== 'Property') {\n return true\n }\n\n const key = prop.key\n\n const name =\n key.type === 'Identifier'\n ? key.name\n : key.type === 'StringLiteral' || key.type === 'Literal'\n ? String(key.value)\n : null\n\n return name !== styleKey\n })\n\n expr.properties.push(styleProp)\n return true\n }\n\n styleAttr.value = j.jsxExpressionContainer(\n j.objectExpression([j.spreadElement(expr as never), styleProp]),\n )\n\n return true\n}\n","import {type API, type ASTPath, type JSXOpeningElement} from 'jscodeshift'\n\nimport {type AttributeMods} from '../types/AttributeMods'\nimport {getAttribute} from './getAttribute'\nimport {getAttributeExpression} from './getAttributeExpression'\nimport {getCompositeAttrValue} from './getCompositeAttrValue'\nimport {getMappingArray} from './getMappingArray'\nimport {getMappingExpression} from './getMappingExpression'\nimport {getMappingValue} from './getMappingValue'\nimport {getShorthandAttributes} from './getShorthandAttributes'\nimport {getStyleExpression} from './getStyleExpression'\nimport {insertTodoWarning} from './insertTodoWarning'\nimport {isValidStyleType} from './isValidStyleType'\nimport {mergeStyle} from './mergeStyle'\n\n/**\n * Applies attribute migration rules to a JSX opening element.\n * Returns whether the AST was updated.\n */\nexport function transformAttributes(\n j: API['jscodeshift'],\n path: ASTPath<JSXOpeningElement>,\n mods: AttributeMods,\n todoWarning: string,\n): boolean {\n if (!path.node.attributes) {\n return false\n }\n\n let hasChanges = false\n const attrs = path.node.attributes\n const removeIdxs: number[] = []\n\n for (const [attrName, mod] of Object.entries(mods)) {\n if (mod?.type !== 'warn-missing') {\n continue\n }\n\n if (getAttribute(attrs, attrName)) {\n continue\n }\n\n if (insertTodoWarning(j, path, mod.warning || todoWarning)) {\n hasChanges = true\n }\n }\n\n for (let i = 0; i < attrs.length; i++) {\n const attr = attrs[i]\n\n if (!attr || attr.type !== 'JSXAttribute' || attr.name.type !== 'JSXIdentifier') {\n continue\n }\n\n const mod = mods[attr.name.name]\n const expr = getAttributeExpression(attr, j)\n\n if (!mod || !expr) {\n continue\n }\n\n if (mod.type === 'remove') {\n removeIdxs.push(i)\n }\n\n if (mod.type === 'warn-only') {\n if (insertTodoWarning(j, path, mod.warning || todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'rename-only') {\n if (attr.name.type === 'JSXIdentifier') {\n attr.name.name = mod.name\n hasChanges = true\n }\n }\n\n if (mod.type === 'style-only') {\n if (!expr || !isValidStyleType(expr)) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const merged = mergeStyle(j, attrs, mod.style, getStyleExpression(j, expr))\n\n if (merged) {\n removeIdxs.push(i)\n } else if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'style-mapped') {\n if (!expr || !isValidStyleType(expr)) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const styleValue = getMappingValue(mod.mapping, expr)\n\n if (styleValue === undefined) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const merged = mergeStyle(j, attrs, mod.style, getMappingExpression(j, styleValue))\n\n if (merged) {\n removeIdxs.push(i)\n } else if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'shorthand-mapped') {\n if (expr.type === 'ConditionalExpression' || expr.type === 'Identifier') {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const shorthandAttrs = getShorthandAttributes(j, expr, mod)\n\n if (shorthandAttrs.length) {\n attrs.splice(i + 1, 0, ...shorthandAttrs)\n removeIdxs.push(i)\n } else if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'composite') {\n const triggerName = attr.name.name\n const compositeValue = getCompositeAttrValue(j, attrs, mod.mapping)\n\n if (!compositeValue) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (attr.name.type === 'JSXIdentifier') {\n attr.name.name = mod.name\n }\n\n attr.value = j.stringLiteral(compositeValue)\n\n for (const attrName of Object.keys(mod.mapping[compositeValue] || {})) {\n if (attrName === triggerName) {\n continue\n }\n\n const otherAttr = getAttribute(attrs, attrName)\n\n if (otherAttr) {\n const k = attrs.indexOf(otherAttr)\n\n if (k !== -1) {\n removeIdxs.push(k)\n }\n }\n }\n\n hasChanges = true\n }\n\n if (mod.type === 'mapped-only' || mod.type === 'rename-mapped') {\n if (mod.type === 'rename-mapped') {\n if (attr.name.type === 'JSXIdentifier') {\n attr.name.name = mod.name\n }\n }\n\n if (expr.type === 'ConditionalExpression' || expr.type === 'Identifier') {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (expr.type === 'ArrayExpression') {\n const styleArray = getMappingArray(j, expr, mod.mapping)\n\n if (!styleArray) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (attr.value?.type === 'JSXExpressionContainer') {\n attr.value.expression = styleArray\n } else {\n attr.value = j.jsxExpressionContainer(styleArray)\n }\n\n hasChanges = true\n continue\n }\n\n const styleValue = getMappingValue(mod.mapping, expr)\n\n if (styleValue === undefined) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (typeof styleValue === 'string') {\n attr.value = j.stringLiteral(styleValue)\n } else {\n attr.value = j.jsxExpressionContainer(getMappingExpression(j, styleValue) as never)\n }\n\n hasChanges = true\n }\n }\n\n const idxsToRemove = [...new Set(removeIdxs)].sort((a, b) => b - a)\n\n if (idxsToRemove.length > 0) {\n hasChanges = true\n\n for (const i of idxsToRemove) {\n attrs.splice(i, 1)\n }\n }\n\n return hasChanges\n}\n","import type {API, Collection, FileInfo} from 'jscodeshift'\n\nexport type TransformContext = {\n j: API['jscodeshift']\n root: Collection\n markChanged: () => void\n}\n\n/**\n * Runs a component transform on a file and only calls `toSource()` when\n * `markChanged()` was invoked. Returns `undefined` for no-op files.\n */\nexport function transformComponent(\n fileInfo: FileInfo,\n api: API,\n fn: (ctx: TransformContext) => void,\n): string | undefined {\n const j = api.jscodeshift\n const root = j(fileInfo.source)\n let hasChanges = false\n\n fn({\n j,\n root,\n markChanged: () => {\n hasChanges = true\n },\n })\n\n return hasChanges ? root.toSource() : undefined\n}\n","import type {API, ASTPath, JSXAttribute, JSXOpeningElement, JSXSpreadAttribute} from 'jscodeshift'\n\nimport {insertTodoWarning} from './insertTodoWarning'\n\nconst DEFAULT_WARNING = 'Please double check styled-component migration below'\n\n/**\n * Runs callback on JSX styled-component if `filter` passes. Otherwise, adds\n * a TODO on the component JSX instance when manual review is needed.\n * Returns whether the AST was updated.\n */\nexport function transformStyledComponents(\n j: API['jscodeshift'],\n root: ReturnType<API['jscodeshift']>,\n aliases: Iterable<string>,\n filter: (attrs: (JSXAttribute | JSXSpreadAttribute)[]) => boolean,\n options: {\n callback?: (path: ASTPath<JSXOpeningElement>) => boolean | void\n warning?: string\n } = {},\n): boolean {\n const names = new Set(aliases)\n const {callback, warning = DEFAULT_WARNING} = options\n let hasChanges = false\n\n root.find(j.JSXOpeningElement).forEach((path) => {\n const name = path.node.name\n\n if (name.type !== 'JSXIdentifier' || !names.has(name.name)) {\n return\n }\n\n const attrs = path.node.attributes ?? []\n\n if (!filter(attrs)) {\n if (insertTodoWarning(j, path, warning)) {\n hasChanges = true\n }\n\n return\n }\n\n if (callback?.(path)) {\n hasChanges = true\n }\n })\n\n return hasChanges\n}\n"],"names":[],"mappings":";;;AAEO,SAAS,0BACd,GACA,aAA2D,IAC3D;AACA,SAAO,WAAW,IAAI,CAAC,SAAS;AAC9B,QAAI,KAAK,SAAS,mBAAmB;AACnC,UAAI,KAAK,SAAS,SAAS,gBAAgB,KAAK,OAAO,SAAS;AAC9D,eAAO;AAGT,YAAM,QAAQ,EAAE;AAAA,QACd,EAAE,WAAW,KAAK,SAAS,IAAI;AAAA,QAC/B,EAAE,WAAW,KAAK,MAAM,IAAI;AAAA,MAAA;AAG9B,aAAI,gBAAgB,QAAQ,KAAK,eAAe,UAC9C,OAAO,OAAO,OAAO,EAAC,YAAY,OAAA,CAAO,GAGpC;AAAA,IACT;AACE,aAAO,EAAE;AAAA,QACP,EAAE,WAAY,KAAgC,OAAO,IAAc;AAAA,MAAA;AAAA,EAGzE,CAAC;AACH;AC1BO,SAAS,yBACd,aAAsF,CAAA,GACtF,eACA;AACA,QAAM,iBAAiB,oBAAI,IAAI,CAAC,eAAe,GAAG,aAAa,OAAO,CAAC,GACjE,QAAQ;AAAA,IACZ,gBAAgB,CAAA;AAAA,IAChB,WAAW,CAAA;AAAA,EAAC;AAGd,aAAW,QAAQ,YAAY;AAC7B,QAAI,KAAK,SAAS,4BAA4B;AAC5C,YAAM,UAAU,KAAK,IAAI;AACzB;AAAA,IACF;AAEA,QAAI,KAAK,SAAS,qBAAqB,KAAK,SAAS,0BAA0B;AAC7E,UAAI;AAEJ,UAAI,KAAK,SAAS,mBAAmB;AACnC,cAA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AAa;AACxC;AC1BA,MAAM,kBAAkB;AAOjB,SAAS,0BACd,GACA,MACA,SACA,QACA,UAGI,IACK;AACT,QAAM,QAAQ,IAAI,IAAI,OAAO,GACvB,EAAC,UAAU,UAAU,gBAAA,IAAmB;AAC9C,MAAI,aAAa;AAEjB,SAAA,KAAK,KAAK,EAAE,iBAAiB,EAAE,QAAQ,CAAC,SAAS;AAC/C,UAAM,OAAO,KAAK,KAAK;AAEvB,QAAI,KAAK,SAAS,mBAAmB,CAAC,MAAM,IAAI,KAAK,IAAI;AACvD;AAGF,UAAM,QAAQ,KAAK,KAAK,cAAc,CAAA;AAEtC,QAAI,CAAC,OAAO,KAAK,GAAG;AACd,wBAAkB,GAAG,MAAM,OAAO,MACpC,aAAa;AAGf;AAAA,IACF;AAEI,eAAW,IAAI,MACjB,aAAa;AAAA,EAEjB,CAAC,GAEM;AACT;"}
1
+ {"version":3,"file":"transformStyledComponents.js","sources":["../../src/utils/getAttribute.ts","../../src/utils/getClonedImportSpecifiers.ts","../../src/utils/getSplitImportSpecifiers.ts","../../src/utils/transformImport.ts","../../src/utils/getComponentLocalNames.ts","../../src/utils/parseModule.ts","../../src/utils/resolveRelativeModulePath.ts","../../src/utils/getNamedExportInit.ts","../../src/utils/getStyledComponentName.ts","../../src/utils/getStyledComponentAliases.ts","../../src/utils/insertTodoWarning.ts","../../src/utils/shouldTransformComponent.ts","../../src/utils/getAttributeExpression.ts","../../src/utils/getStaticAttributeExpression.ts","../../src/utils/getCompositeAttrValue.ts","../../src/utils/getMappingExpression.ts","../../src/utils/getMappingValue.ts","../../src/utils/getMappingArray.ts","../../src/utils/getShorthandAttributes.ts","../../src/utils/getStyleExpression.ts","../../src/utils/isValidStyleType.ts","../../src/utils/mergeStyle.ts","../../src/utils/transformAttributes.ts","../../src/utils/transformComponent.ts","../../src/utils/transformStyledComponents.ts"],"sourcesContent":["import type {JSXAttribute, JSXElement} from 'jscodeshift'\n\nexport function getAttribute(\n attrs: JSXElement['openingElement']['attributes'],\n name: string,\n): JSXAttribute | undefined {\n if (!attrs) {\n return undefined\n }\n\n for (const attr of attrs) {\n if (\n attr.type === 'JSXAttribute' &&\n attr.name.type === 'JSXIdentifier' &&\n attr.name.name === name\n ) {\n return attr\n }\n }\n\n return undefined\n}\n","import type {API, ImportDefaultSpecifier, ImportSpecifier} from 'jscodeshift'\n\nexport function getClonedImportSpecifiers(\n j: API['jscodeshift'],\n specifiers: (ImportSpecifier | ImportDefaultSpecifier)[] = [],\n) {\n return specifiers.map((spec) => {\n if (spec.type === 'ImportSpecifier') {\n if (spec.imported.type !== 'Identifier' || spec.local?.type !== 'Identifier') {\n return spec\n }\n\n const clone = j.importSpecifier(\n j.identifier(spec.imported.name),\n j.identifier(spec.local.name),\n )\n\n if ('importKind' in spec && spec.importKind === 'type') {\n Object.assign(clone, {importKind: 'type'})\n }\n\n return clone\n } else {\n return j.importDefaultSpecifier(\n j.identifier((spec as ImportDefaultSpecifier).local?.name as string),\n )\n }\n })\n}\n","import type {ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier} from 'jscodeshift'\n\nexport function getSplitImportSpecifiers(\n specifiers: (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[] = [],\n componentName: string,\n) {\n const componentNames = new Set([componentName, `${componentName}Props`])\n const specs = {\n componentSpecs: [] as (ImportSpecifier | ImportDefaultSpecifier)[],\n restSpecs: [] as (ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier)[],\n }\n\n for (const spec of specifiers) {\n if (spec.type === 'ImportNamespaceSpecifier') {\n specs.restSpecs.push(spec)\n continue\n }\n\n if (spec.type === 'ImportSpecifier' || spec.type === 'ImportDefaultSpecifier') {\n let local\n\n if (spec.type === 'ImportSpecifier') {\n const loc = spec.local ?? spec.imported\n local = loc.type === 'Identifier' ? loc.name : null\n }\n\n if (spec.type === 'ImportDefaultSpecifier') {\n local = spec.local?.type === 'Identifier' ? spec.local.name : null\n }\n\n if (local && componentNames.has(local)) {\n specs.componentSpecs.push(spec)\n } else {\n specs.restSpecs.push(spec)\n }\n }\n }\n\n return specs\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport {getClonedImportSpecifiers} from './getClonedImportSpecifiers'\nimport {getSplitImportSpecifiers} from './getSplitImportSpecifiers'\n\nexport const DEFAULT_UI_PACKAGE = '@sanity/ui'\n\n/**\n * Rewrites imports from `fromPackage` to `toPackage`, splitting imports if needed.\n * Returns whether the AST was updated.\n */\nexport function transformImport(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n fromPackage: string = DEFAULT_UI_PACKAGE,\n toPackage: string = DEFAULT_UI_PACKAGE,\n): boolean {\n if (fromPackage === toPackage) {\n return false\n }\n\n let hasChanges = false\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const node = path.node\n\n if (node.source.value !== fromPackage) {\n return\n }\n\n const {componentSpecs, restSpecs} = getSplitImportSpecifiers(node.specifiers, componentName)\n\n if (componentSpecs.length === 0) {\n return\n }\n\n if (restSpecs.length === 0) {\n if (node.source && typeof node.source === 'object' && 'value' in node.source) {\n const sourceLiteral = node.source as {value: string}\n sourceLiteral.value = toPackage\n }\n\n hasChanges = true\n return\n }\n\n path.node.specifiers = restSpecs\n const clonedImportSpecifiers = getClonedImportSpecifiers(j, componentSpecs)\n path.insertAfter(j.importDeclaration(clonedImportSpecifiers, j.stringLiteral(toPackage)))\n hasChanges = true\n })\n\n return hasChanges\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport type {BaseOptions} from '../types/BaseOptions'\nimport {DEFAULT_UI_PACKAGE} from './transformImport'\n\nexport function getComponentLocalNames(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n options?: BaseOptions,\n): Set<string> {\n const importedNames = new Set<string>()\n const packages = new Set([\n options?.fromPackage ?? DEFAULT_UI_PACKAGE,\n options?.toPackage ?? DEFAULT_UI_PACKAGE,\n ])\n let hasOtherPackageImport = false\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const node = path.node\n\n if ('importKind' in node && node.importKind === 'type') {\n return\n }\n\n const matchesPackage = packages.has(node.source.value as string)\n\n for (const spec of node.specifiers ?? []) {\n if (spec.type !== 'ImportSpecifier') {\n continue\n }\n\n if ('importKind' in spec && spec.importKind === 'type') {\n continue\n }\n\n if (spec.imported.type !== 'Identifier' || spec.imported.name !== componentName) {\n continue\n }\n\n const local = spec.local?.type === 'Identifier' ? spec.local.name : spec.imported.name\n\n if (!matchesPackage) {\n hasOtherPackageImport = true\n continue\n }\n\n importedNames.add(local)\n }\n })\n\n if (importedNames.size > 0) {\n return importedNames\n }\n\n if (hasOtherPackageImport) {\n return new Set()\n }\n\n const usesComponentInJsx = root.find(j.JSXOpeningElement).some(({node}) => {\n return node.name.type === 'JSXIdentifier' && node.name.name === componentName\n })\n\n if (usesComponentInJsx) {\n return new Set([componentName])\n }\n\n return new Set()\n}\n","import {readFileSync} from 'node:fs'\n\nimport type {API, Collection} from 'jscodeshift'\n\nconst parseCache = new Map<string, Collection>()\n\nexport function parseModule(j: API['jscodeshift'], filePath: string): Collection | null {\n const cached = parseCache.get(filePath)\n\n if (cached) {\n return cached\n }\n\n try {\n const source = readFileSync(filePath, 'utf8')\n const root = j(source)\n\n parseCache.set(filePath, root)\n\n return root\n } catch {\n return null\n }\n}\n\n/** @internal */\nexport function clearModuleParseCache(): void {\n parseCache.clear()\n}\n","import {existsSync} from 'node:fs'\nimport {dirname, join, resolve} from 'node:path'\n\nconst EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js'] as const\n\nexport function resolveRelativeModulePath(\n fromFilePath: string,\n moduleSpecifier: string,\n): string | null {\n if (!moduleSpecifier.startsWith('.')) {\n return null\n }\n\n const base = resolve(dirname(fromFilePath), moduleSpecifier)\n\n for (const ext of EXTENSIONS) {\n const filePath = `${base}${ext}`\n\n if (existsSync(filePath)) {\n return filePath\n }\n }\n\n for (const ext of EXTENSIONS) {\n const indexPath = join(base, `index${ext}`)\n\n if (existsSync(indexPath)) {\n return indexPath\n }\n }\n\n if (existsSync(base)) {\n return base\n }\n\n return null\n}\n","import type {API, Expression, ExportSpecifier} from 'jscodeshift'\n\nimport {parseModule} from './parseModule'\nimport {resolveRelativeModulePath} from './resolveRelativeModulePath'\n\nexport type NamedExportInit = {\n init: Expression\n modulePath: string\n}\n\nfunction findVariableInit(\n j: API['jscodeshift'],\n root: ReturnType<API['jscodeshift']>,\n name: string,\n): Expression | null {\n let init: Expression | null = null\n\n root.find(j.VariableDeclarator).forEach((path) => {\n const {id} = path.node\n\n if (id.type === 'Identifier' && id.name === name && path.node.init) {\n init = path.node.init\n }\n })\n\n return init\n}\n\nfunction getExportSpecifierName(exported: ExportSpecifier['exported']): string | null {\n if (exported.type === 'Identifier' || exported.type === 'JSXIdentifier') {\n return exported.name\n }\n\n return null\n}\n\nexport function getNamedExportInit(\n j: API['jscodeshift'],\n exportName: string,\n filePath: string,\n visited: Set<string> = new Set(),\n): NamedExportInit | null {\n if (visited.has(filePath)) {\n return null\n }\n\n visited.add(filePath)\n\n const root = parseModule(j, filePath)\n\n if (!root) {\n return null\n }\n\n for (const path of root.find(j.ExportNamedDeclaration).paths()) {\n const {declaration, specifiers, source} = path.node\n const reexportSource = typeof source?.value === 'string' ? source.value : null\n\n if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.type !== 'VariableDeclarator') {\n continue\n }\n\n if (\n declarator.id.type === 'Identifier' &&\n declarator.id.name === exportName &&\n declarator.init\n ) {\n return {init: declarator.init, modulePath: filePath}\n }\n }\n }\n\n for (const spec of specifiers ?? []) {\n if (spec.type !== 'ExportSpecifier') {\n continue\n }\n\n const exported = getExportSpecifierName(spec.exported)\n\n if (!exported || exported !== exportName) {\n continue\n }\n\n const local = spec.local?.type === 'Identifier' ? spec.local.name : exported\n\n if (reexportSource) {\n const resolvedPath = resolveRelativeModulePath(filePath, reexportSource)\n\n if (resolvedPath) {\n const followed = getNamedExportInit(j, local, resolvedPath, visited)\n\n if (followed) {\n return followed\n }\n }\n\n continue\n }\n\n const init = findVariableInit(j, root, local)\n\n if (init) {\n return {init, modulePath: filePath}\n }\n }\n }\n\n return null\n}\n","export function getStyledComponentName(node: unknown): string | null {\n if (!node || typeof node !== 'object' || !('type' in node)) {\n return null\n }\n\n const current = node as {\n type: string\n callee?: unknown\n tag?: unknown\n object?: unknown\n arguments?: unknown[]\n }\n\n if (current.type === 'TaggedTemplateExpression') {\n return getStyledComponentName(current.tag)\n }\n\n if (current.type === 'CallExpression') {\n const callee = current.callee\n\n if (\n callee &&\n typeof callee === 'object' &&\n 'type' in callee &&\n callee.type === 'Identifier' &&\n 'name' in callee &&\n callee.name === 'styled'\n ) {\n const arg = current.arguments?.[0]\n\n if (\n arg &&\n typeof arg === 'object' &&\n 'type' in arg &&\n arg.type === 'Identifier' &&\n 'name' in arg\n ) {\n return arg.name as string\n }\n\n return null\n }\n\n return getStyledComponentName(callee)\n }\n\n if (current.type === 'MemberExpression' && current.object) {\n return getStyledComponentName(current.object)\n }\n\n return null\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport type {BaseOptions} from '../types/BaseOptions'\nimport {getComponentLocalNames} from './getComponentLocalNames'\nimport {getNamedExportInit} from './getNamedExportInit'\nimport {getStyledComponentName} from './getStyledComponentName'\nimport {parseModule} from './parseModule'\nimport {resolveRelativeModulePath} from './resolveRelativeModulePath'\n\nexport function getSameFileStyledComponentAliases(\n j: API['jscodeshift'],\n root: Collection,\n localNames: Iterable<string>,\n): Set<string> {\n const aliases = new Set<string>()\n const names = new Set(localNames)\n\n root.find(j.VariableDeclarator).forEach((path) => {\n const {id, init} = path.node\n\n if (!init || id.type !== 'Identifier') {\n return\n }\n\n const baseComponent = getStyledComponentName(init)\n\n if (baseComponent && names.has(baseComponent)) {\n aliases.add(id.name)\n }\n })\n\n return aliases\n}\n\nexport function getImportedStyledComponentAliases(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n filePath: string | undefined,\n options?: BaseOptions,\n): Set<string> {\n const aliases = new Set<string>()\n\n if (!filePath) {\n return aliases\n }\n\n root.find(j.ImportDeclaration).forEach((path) => {\n const source = path.node.source.value\n\n if (typeof source !== 'string') {\n return\n }\n\n const resolvedPath = resolveRelativeModulePath(filePath, source)\n\n if (!resolvedPath) {\n return\n }\n\n for (const spec of path.node.specifiers ?? []) {\n if (spec.type !== 'ImportSpecifier') {\n continue\n }\n\n if ('importKind' in spec && spec.importKind === 'type') {\n continue\n }\n\n if (spec.imported.type !== 'Identifier') {\n continue\n }\n\n const exportName = spec.imported.name\n const localName = spec.local?.type === 'Identifier' ? spec.local.name : exportName\n const namedExport = getNamedExportInit(j, exportName, resolvedPath)\n\n if (!namedExport) {\n continue\n }\n\n const sourceRoot = parseModule(j, namedExport.modulePath)\n\n if (!sourceRoot) {\n continue\n }\n\n const exportLocalNames = getComponentLocalNames(j, sourceRoot, componentName, options)\n const baseComponent = getStyledComponentName(namedExport.init)\n\n if (baseComponent && exportLocalNames.has(baseComponent)) {\n aliases.add(localName)\n }\n }\n })\n\n return aliases\n}\n\nexport function getStyledComponentAliases(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n filePath: string | undefined,\n localNames: Set<string>,\n options?: BaseOptions,\n): Set<string> {\n const sameFile = getSameFileStyledComponentAliases(j, root, localNames)\n const imported = getImportedStyledComponentAliases(j, root, componentName, filePath, options)\n\n return new Set([...sameFile, ...imported])\n}\n","import {type API, type ASTPath, type ImportDeclaration, type JSXOpeningElement} from 'jscodeshift'\n\ntype CommentableNode = {\n comments?: {type: string; value: string; leading?: boolean}[] | null\n}\n\n/**\n * Inserts a `UI-CODEMOD TODO` comment.\n * Returns whether the AST was updated.\n */\nexport function insertTodoWarning(\n j: API['jscodeshift'],\n path: ASTPath<JSXOpeningElement | ImportDeclaration>,\n warning: string,\n): boolean {\n let target: CommentableNode | null = null\n\n if (path.node.type === 'ImportDeclaration') {\n target = path.node\n } else if (path.parent?.node.type === 'JSXElement') {\n target = path.parent.node\n }\n\n if (!target) {\n return false\n }\n\n target.comments ??= []\n\n if (target.comments.some((comment) => comment.value.includes(warning))) {\n return false\n }\n\n target.comments.unshift(j.commentLine(` UI-CODEMOD TODO: ${warning}`, true))\n return true\n}\n","import type {API, Collection} from 'jscodeshift'\n\nimport type {BaseOptions} from '../types/BaseOptions'\nimport {getSplitImportSpecifiers} from './getSplitImportSpecifiers'\nimport {DEFAULT_UI_PACKAGE} from './transformImport'\n\n/**\n * Returns whether a component transform should run on this file, based on local\n * usage or a pending import rewrite.\n */\nexport function shouldTransformComponent(\n j: API['jscodeshift'],\n root: Collection,\n componentName: string,\n localNames: Set<string>,\n options?: BaseOptions,\n styledAliases?: Set<string>,\n): boolean {\n if (localNames.size > 0) {\n return true\n }\n\n if (styledAliases && styledAliases.size > 0) {\n return true\n }\n\n const fromPackage = options?.fromPackage ?? DEFAULT_UI_PACKAGE\n const toPackage = options?.toPackage ?? DEFAULT_UI_PACKAGE\n\n if (fromPackage === toPackage) {\n return false\n }\n\n return root.find(j.ImportDeclaration).some((path) => {\n const node = path.node\n\n if (node.source.value !== fromPackage) {\n return false\n }\n\n const {componentSpecs} = getSplitImportSpecifiers(node.specifiers, componentName)\n\n return componentSpecs.length > 0\n })\n}\n","import {type API, type JSXAttribute} from 'jscodeshift'\n\nimport {type AnyExpression} from '../types/AnyExpression'\n\nexport function getAttributeExpression(\n attr: JSXAttribute,\n j: API['jscodeshift'],\n): AnyExpression | null {\n if (!attr.value) {\n return j.booleanLiteral(true)\n }\n\n if (attr.value.type === 'StringLiteral' || attr.value.type === 'Literal') {\n return attr.value\n }\n\n if (attr.value.type === 'JSXExpressionContainer') {\n return attr.value.expression\n }\n\n return null\n}\n","import type {API, JSXAttribute, JSXSpreadAttribute} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\nimport {getAttribute} from './getAttribute'\nimport {getAttributeExpression} from './getAttributeExpression'\n\nexport type CompositePrimitive = string | number | boolean\n\nexport type StaticAttributeValue = CompositePrimitive | (CompositePrimitive | null | undefined)[]\n\nfunction getStaticPrimitive(expr: AnyExpression): CompositePrimitive | undefined {\n if (\n expr.type === 'StringLiteral' ||\n expr.type === 'NumericLiteral' ||\n expr.type === 'BooleanLiteral' ||\n expr.type === 'Literal'\n ) {\n const {value} = expr\n\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n return value\n }\n }\n\n return undefined\n}\n\nexport function getStaticAttributeExpression(\n j: API['jscodeshift'],\n attrs: (JSXAttribute | JSXSpreadAttribute)[],\n name: string,\n): StaticAttributeValue | null {\n const attr = getAttribute(attrs, name)\n\n if (!attr) {\n return null\n }\n\n const expr = getAttributeExpression(attr, j)\n\n if (!expr) {\n return null\n }\n\n const primitive = getStaticPrimitive(expr as AnyExpression)\n\n if (primitive !== undefined) {\n return primitive\n }\n\n if (expr.type !== 'ArrayExpression') {\n return null\n }\n\n const elements = expr.elements as ((AnyExpression & {name?: string}) | null)[]\n const values: (CompositePrimitive | null | undefined)[] = []\n\n for (const element of elements) {\n if (element === null || element.type === 'NullLiteral') {\n values.push(null)\n continue\n }\n\n if (element.type === 'SpreadElement') {\n return null\n }\n\n if (element.type === 'Literal' && element.value === null) {\n values.push(null)\n continue\n }\n\n if (element.type === 'Identifier' && element.name === 'undefined') {\n values.push(undefined)\n continue\n }\n\n const elementValue = getStaticPrimitive(element)\n\n if (elementValue === undefined) {\n return null\n }\n\n values.push(elementValue)\n }\n\n return values\n}\n","import type {API, JSXAttribute, JSXSpreadAttribute} from 'jscodeshift'\n\nimport type {CompositeAttributeMapping} from '../types/AttributeMods'\nimport {getStaticAttributeExpression} from './getStaticAttributeExpression'\n\nexport function getCompositeAttrValue(\n j: API['jscodeshift'],\n attrs: (JSXAttribute | JSXSpreadAttribute)[],\n mapping: CompositeAttributeMapping,\n) {\n let compositeAttrValue: string | null = null\n\n for (const compositeKey of Object.keys(mapping)) {\n const compositeMapping = mapping[compositeKey]\n\n if (!compositeMapping) {\n continue\n }\n\n let hasMatchingValues = true\n\n for (const propName of Object.keys(compositeMapping)) {\n const mappingValue = compositeMapping[propName]\n const attrValue = getStaticAttributeExpression(j, attrs, propName)\n\n if (mappingValue === undefined || attrValue !== mappingValue) {\n hasMatchingValues = false\n break\n }\n }\n\n if (hasMatchingValues) {\n compositeAttrValue = compositeKey\n break\n }\n }\n\n return compositeAttrValue\n}\n","import {type API} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\n\nexport function getMappingExpression(\n j: API['jscodeshift'],\n val: string | boolean | number | undefined,\n): AnyExpression {\n if (val === undefined) {\n return j.identifier('undefined')\n }\n\n if (typeof val === 'boolean') {\n return j.booleanLiteral(val)\n }\n\n if (typeof val === 'number') {\n return j.numericLiteral(val)\n }\n\n return j.stringLiteral(val)\n}\n","import type {AnyExpression} from '../types/AnyExpression'\nimport type {AttributeMapping} from '../types/AttributeMods'\n\nexport function getMappingValue(mapping: AttributeMapping, expr: AnyExpression) {\n let key\n\n if (\n expr.type === 'NumericLiteral' ||\n expr.type === 'BooleanLiteral' ||\n expr.type === 'StringLiteral' ||\n expr.type === 'Literal'\n ) {\n key = String(expr.value)\n }\n\n if (expr.type === 'TemplateLiteral') {\n const expressions = expr.expressions as unknown[]\n const quasis = expr.quasis as {value: {cooked: string | null}}[]\n\n if (expressions.length === 0 && quasis.length === 1) {\n key = quasis[0]?.value.cooked ?? null\n }\n }\n\n if (key) {\n if (Object.prototype.hasOwnProperty.call(mapping, key)) {\n return mapping[key]\n }\n\n const number = Number(key)\n\n if (!Number.isNaN(number) && Object.prototype.hasOwnProperty.call(mapping, number)) {\n return mapping[number]\n }\n }\n\n if (\n expr.type === 'BooleanLiteral' ||\n (expr.type === 'Literal' && typeof expr.value === 'boolean')\n ) {\n for (const val in mapping) {\n if (expr.value === mapping[val]) {\n return mapping[val]\n }\n }\n }\n\n return\n}\n","import {type API, type ArrayExpression} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\nimport type {AttributeMapping} from '../types/AttributeMods'\nimport {getMappingExpression} from './getMappingExpression'\nimport {getMappingValue} from './getMappingValue'\n\nexport function getMappingArray(\n j: API['jscodeshift'],\n arr: AnyExpression,\n mapping: AttributeMapping,\n allowUndefined?: boolean,\n): ArrayExpression | null {\n if (arr.type !== 'ArrayExpression') {\n return null\n }\n\n const elements = arr.elements as (AnyExpression | null)[]\n const output: AnyExpression[] = []\n\n for (const el of elements) {\n if (el == null || el.type === 'SpreadElement') {\n return null\n }\n\n const mappingValue = getMappingValue(mapping, el)\n\n if (!mappingValue && !allowUndefined) {\n return null\n }\n\n output.push(getMappingExpression(j, mappingValue))\n }\n\n return j.arrayExpression(output as never[])\n}\n","import type {API, JSXAttribute} from 'jscodeshift'\n\nimport type {AnyExpression} from '../types/AnyExpression'\nimport type {AttributeMod} from '../types/AttributeMods'\nimport {getMappingArray} from './getMappingArray'\nimport {getMappingExpression} from './getMappingExpression'\nimport {getMappingValue} from './getMappingValue'\n\nexport function getShorthandAttributes(\n j: API['jscodeshift'],\n expr: AnyExpression,\n mod: AttributeMod,\n) {\n const attributes: JSXAttribute[] = []\n\n if (!('props' in mod)) {\n return []\n }\n\n if (expr.type === 'ArrayExpression') {\n for (const prop of mod.props) {\n const styleArray = getMappingArray(j, expr, prop.mapping, true)\n\n if (!styleArray) {\n continue\n }\n\n attributes.push(\n j.jsxAttribute(j.jsxIdentifier(prop.name), j.jsxExpressionContainer(styleArray)),\n )\n }\n }\n\n for (const prop of mod.props) {\n const styleValue = getMappingValue(prop.mapping, expr)\n\n if (styleValue === undefined) {\n continue\n }\n\n if (typeof styleValue === 'string') {\n attributes.push(j.jsxAttribute(j.jsxIdentifier(prop.name), j.stringLiteral(styleValue)))\n } else {\n attributes.push(\n j.jsxAttribute(\n j.jsxIdentifier(prop.name),\n j.jsxExpressionContainer(getMappingExpression(j, styleValue) as never),\n ),\n )\n }\n }\n\n return attributes\n}\n","import {type API} from 'jscodeshift'\n\nimport {type AnyExpression} from '../types/AnyExpression'\n\nexport function getStyleExpression(j: API['jscodeshift'], expr: AnyExpression): AnyExpression {\n if (expr.type === 'Literal') {\n if (expr.value === null) {\n return j.literal(null)\n }\n\n if (typeof expr.value === 'boolean') {\n return j.booleanLiteral(expr.value)\n }\n\n if (typeof expr.value === 'number') {\n return j.numericLiteral(expr.value)\n }\n\n if (typeof expr.value === 'string') {\n return j.stringLiteral(expr.value)\n }\n }\n\n if (expr.type === 'BooleanLiteral') {\n return j.booleanLiteral(expr.value as boolean)\n }\n\n if (expr.type === 'NumericLiteral') {\n return j.numericLiteral(expr.value as number)\n }\n\n if (expr.type === 'StringLiteral') {\n return j.stringLiteral(expr.value as string)\n }\n\n return expr\n}\n","import {type AnyExpression} from '../types/AnyExpression'\n\nexport function isValidStyleType(expr: AnyExpression) {\n if (expr.type === 'TemplateLiteral') {\n const expressions = expr.expressions as unknown[]\n const quasis = expr.quasis as {value: {cooked: string | null}}[]\n return expressions.length === 0 && quasis.length === 1\n }\n\n if (\n expr.type === 'StringLiteral' ||\n expr.type === 'Literal' ||\n expr.type === 'NumericLiteral' ||\n expr.type === 'BooleanLiteral' ||\n expr.type === 'NullLiteral'\n ) {\n return true\n }\n\n return false\n}\n","import {type API, type JSXAttribute, type JSXSpreadAttribute} from 'jscodeshift'\n\nimport {type AnyExpression} from '../types/AnyExpression'\n\nexport function mergeStyle(\n j: API['jscodeshift'],\n attrs: (JSXAttribute | JSXSpreadAttribute)[],\n styleKey: string,\n styleExpression: AnyExpression,\n) {\n const styleProp = j.objectProperty(j.identifier(styleKey), styleExpression as never)\n\n const styleIndex = attrs.findIndex(\n (a): a is JSXAttribute =>\n a.type === 'JSXAttribute' && a.name.type === 'JSXIdentifier' && a.name.name === 'style',\n )\n\n if (styleIndex === -1) {\n attrs.push(\n j.jsxAttribute(\n j.jsxIdentifier('style'),\n j.jsxExpressionContainer(j.objectExpression([styleProp])),\n ),\n )\n\n return true\n }\n\n const styleAttr = attrs[styleIndex] as JSXAttribute\n\n if (styleAttr.value?.type !== 'JSXExpressionContainer') {\n return false\n }\n\n const expr = styleAttr.value.expression\n\n if (expr.type === 'ObjectExpression') {\n expr.properties = expr.properties.filter((prop) => {\n if (prop.type !== 'ObjectProperty' && prop.type !== 'Property') {\n return true\n }\n\n const key = prop.key\n\n const name =\n key.type === 'Identifier'\n ? key.name\n : key.type === 'StringLiteral' || key.type === 'Literal'\n ? String(key.value)\n : null\n\n return name !== styleKey\n })\n\n expr.properties.push(styleProp)\n return true\n }\n\n styleAttr.value = j.jsxExpressionContainer(\n j.objectExpression([j.spreadElement(expr as never), styleProp]),\n )\n\n return true\n}\n","import {type API, type ASTPath, type JSXOpeningElement} from 'jscodeshift'\n\nimport {type AttributeMods} from '../types/AttributeMods'\nimport {getAttribute} from './getAttribute'\nimport {getAttributeExpression} from './getAttributeExpression'\nimport {getCompositeAttrValue} from './getCompositeAttrValue'\nimport {getMappingArray} from './getMappingArray'\nimport {getMappingExpression} from './getMappingExpression'\nimport {getMappingValue} from './getMappingValue'\nimport {getShorthandAttributes} from './getShorthandAttributes'\nimport {getStyleExpression} from './getStyleExpression'\nimport {insertTodoWarning} from './insertTodoWarning'\nimport {isValidStyleType} from './isValidStyleType'\nimport {mergeStyle} from './mergeStyle'\n\n/**\n * Applies attribute migration rules to a JSX opening element.\n * Returns whether the AST was updated.\n */\nexport function transformAttributes(\n j: API['jscodeshift'],\n path: ASTPath<JSXOpeningElement>,\n mods: AttributeMods,\n todoWarning: string,\n): boolean {\n if (!path.node.attributes) {\n return false\n }\n\n let hasChanges = false\n const attrs = path.node.attributes\n const removeIdxs: number[] = []\n\n for (const [attrName, mod] of Object.entries(mods)) {\n if (mod?.type !== 'warn-missing') {\n continue\n }\n\n if (getAttribute(attrs, attrName)) {\n continue\n }\n\n if (insertTodoWarning(j, path, mod.warning || todoWarning)) {\n hasChanges = true\n }\n }\n\n for (let i = 0; i < attrs.length; i++) {\n const attr = attrs[i]\n\n if (!attr || attr.type !== 'JSXAttribute' || attr.name.type !== 'JSXIdentifier') {\n continue\n }\n\n const mod = mods[attr.name.name]\n const expr = getAttributeExpression(attr, j)\n\n if (!mod || !expr) {\n continue\n }\n\n if (mod.type === 'remove') {\n removeIdxs.push(i)\n }\n\n if (mod.type === 'warn-only') {\n if (insertTodoWarning(j, path, mod.warning || todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'rename-only') {\n if (attr.name.type === 'JSXIdentifier') {\n attr.name.name = mod.name\n hasChanges = true\n }\n }\n\n if (mod.type === 'style-only') {\n if (!expr || !isValidStyleType(expr)) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const merged = mergeStyle(j, attrs, mod.style, getStyleExpression(j, expr))\n\n if (merged) {\n removeIdxs.push(i)\n } else if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'style-mapped') {\n if (!expr || !isValidStyleType(expr)) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const styleValue = getMappingValue(mod.mapping, expr)\n\n if (styleValue === undefined) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const merged = mergeStyle(j, attrs, mod.style, getMappingExpression(j, styleValue))\n\n if (merged) {\n removeIdxs.push(i)\n } else if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'shorthand-mapped') {\n if (expr.type === 'ConditionalExpression' || expr.type === 'Identifier') {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n const shorthandAttrs = getShorthandAttributes(j, expr, mod)\n\n if (shorthandAttrs.length) {\n attrs.splice(i + 1, 0, ...shorthandAttrs)\n removeIdxs.push(i)\n } else if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n }\n\n if (mod.type === 'composite') {\n const triggerName = attr.name.name\n const compositeValue = getCompositeAttrValue(j, attrs, mod.mapping)\n\n if (!compositeValue) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (attr.name.type === 'JSXIdentifier') {\n attr.name.name = mod.name\n }\n\n attr.value = j.stringLiteral(compositeValue)\n\n for (const attrName of Object.keys(mod.mapping[compositeValue] || {})) {\n if (attrName === triggerName) {\n continue\n }\n\n const otherAttr = getAttribute(attrs, attrName)\n\n if (otherAttr) {\n const k = attrs.indexOf(otherAttr)\n\n if (k !== -1) {\n removeIdxs.push(k)\n }\n }\n }\n\n hasChanges = true\n }\n\n if (mod.type === 'mapped-only' || mod.type === 'rename-mapped') {\n if (mod.type === 'rename-mapped') {\n if (attr.name.type === 'JSXIdentifier') {\n attr.name.name = mod.name\n }\n }\n\n if (expr.type === 'ConditionalExpression' || expr.type === 'Identifier') {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (expr.type === 'ArrayExpression') {\n const styleArray = getMappingArray(j, expr, mod.mapping)\n\n if (!styleArray) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (attr.value?.type === 'JSXExpressionContainer') {\n attr.value.expression = styleArray\n } else {\n attr.value = j.jsxExpressionContainer(styleArray)\n }\n\n hasChanges = true\n continue\n }\n\n const styleValue = getMappingValue(mod.mapping, expr)\n\n if (styleValue === undefined) {\n if (insertTodoWarning(j, path, todoWarning)) {\n hasChanges = true\n }\n\n continue\n }\n\n if (typeof styleValue === 'string') {\n attr.value = j.stringLiteral(styleValue)\n } else {\n attr.value = j.jsxExpressionContainer(getMappingExpression(j, styleValue) as never)\n }\n\n hasChanges = true\n }\n }\n\n const idxsToRemove = [...new Set(removeIdxs)].sort((a, b) => b - a)\n\n if (idxsToRemove.length > 0) {\n hasChanges = true\n\n for (const i of idxsToRemove) {\n attrs.splice(i, 1)\n }\n }\n\n return hasChanges\n}\n","import type {API, Collection, FileInfo} from 'jscodeshift'\n\nexport type TransformContext = {\n j: API['jscodeshift']\n root: Collection\n markChanged: () => void\n}\n\n/**\n * Runs a component transform on a file and only calls `toSource()` when\n * `markChanged()` was invoked. Returns `undefined` for no-op files.\n */\nexport function transformComponent(\n fileInfo: FileInfo,\n api: API,\n fn: (ctx: TransformContext) => void,\n): string | undefined {\n const j = api.jscodeshift\n const root = j(fileInfo.source)\n let hasChanges = false\n\n fn({\n j,\n root,\n markChanged: () => {\n hasChanges = true\n },\n })\n\n return hasChanges ? root.toSource() : undefined\n}\n","import type {API, ASTPath, JSXAttribute, JSXOpeningElement, JSXSpreadAttribute} from 'jscodeshift'\n\nimport {insertTodoWarning} from './insertTodoWarning'\n\nconst DEFAULT_WARNING = 'Please double check styled-component migration below'\n\n/**\n * Runs callback on JSX styled-component if `filter` passes. Otherwise, adds\n * a TODO on the component JSX instance when manual review is needed.\n * Returns whether the AST was updated.\n */\nexport function transformStyledComponents(\n j: API['jscodeshift'],\n root: ReturnType<API['jscodeshift']>,\n aliases: Iterable<string>,\n filter: (attrs: (JSXAttribute | JSXSpreadAttribute)[]) => boolean,\n options: {\n callback?: (path: ASTPath<JSXOpeningElement>) => boolean | void\n warning?: string\n } = {},\n): boolean {\n const names = new Set(aliases)\n const {callback, warning = DEFAULT_WARNING} = options\n let hasChanges = false\n\n root.find(j.JSXOpeningElement).forEach((path) => {\n const name = path.node.name\n\n if (name.type !== 'JSXIdentifier' || !names.has(name.name)) {\n return\n }\n\n const attrs = path.node.attributes ?? []\n\n if (!filter(attrs)) {\n if (insertTodoWarning(j, path, warning)) {\n hasChanges = true\n }\n\n return\n }\n\n if (callback?.(path)) {\n hasChanges = true\n }\n })\n\n return hasChanges\n}\n"],"names":[],"mappings":";;;AAEO,SAAS,aACd,OACA,MAC0B;AAC1B,MAAK;AAIL,eAAW,QAAQ;AACjB,UACE,KAAK,SAAS,kBACd,KAAK,KAAK,SAAS,mBACnB,KAAK,KAAK,SAAS;AAEnB,eAAO;AAAA;AAKb;ACnBO,SAAS,0BACd,GACA,aAA2D,IAC3D;AACA,SAAO,WAAW,IAAI,CAAC,SAAS;AAC9B,QAAI,KAAK,SA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if/core";
2
+ import { Interfaces } from "@oclif/core";
3
+
4
+ declare type Args<T extends typeof Command> = Interfaces.InferredArgs<
5
+ T["args"]
6
+ >;
7
+
8
+ /** @public */
9
+ declare class Badge extends BaseCommand<typeof Badge> {
10
+ static description: string;
11
+ run(): Promise<void>;
12
+ }
13
+ export default Badge;
14
+
15
+ declare abstract class BaseCommand<T extends typeof Command> extends Command {
16
+ static baseFlags: {
17
+ paths: Interfaces.OptionFlag<string[], Interfaces.CustomOptions>;
18
+ fromPackage: Interfaces.OptionFlag<
19
+ string | undefined,
20
+ Interfaces.CustomOptions
21
+ >;
22
+ toPackage: Interfaces.OptionFlag<
23
+ string | undefined,
24
+ Interfaces.CustomOptions
25
+ >;
26
+ extensions: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
27
+ dry: Interfaces.BooleanFlag<boolean>;
28
+ print: Interfaces.BooleanFlag<boolean>;
29
+ verbose: Interfaces.OptionFlag<number, Interfaces.CustomOptions>;
30
+ };
31
+ protected flags: Flags<T>;
32
+ protected args: Args<T>;
33
+ static examples: string[];
34
+ init(): Promise<void>;
35
+ protected catch(
36
+ err: Error & {
37
+ exitCode?: number;
38
+ },
39
+ ): Promise<unknown>;
40
+ protected finally(_: Error | undefined): Promise<unknown>;
41
+ }
42
+
43
+ declare type Flags<T extends typeof Command> = Interfaces.InferredFlags<
44
+ (typeof BaseCommand)["baseFlags"] & T["flags"]
45
+ >;
46
+
47
+ export {};
@@ -0,0 +1,17 @@
1
+ import { run } from "jscodeshift/src/Runner.js";
2
+ import { BaseCommand, getTransformPath } from "../../_chunks-es/getTransformPath.js";
3
+ class Badge extends BaseCommand {
4
+ static description = "Transform Badge component";
5
+ async run() {
6
+ const { flags } = await this.parse(Badge), { paths, ...restFlags } = flags, transformPath = getTransformPath(this.config.root, "latest", "badge");
7
+ await run(transformPath, paths, {
8
+ babel: !0,
9
+ parser: "tsx",
10
+ ...restFlags
11
+ });
12
+ }
13
+ }
14
+ export {
15
+ Badge as default
16
+ };
17
+ //# sourceMappingURL=badge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"badge.js","sources":["../../../src/commands/latest/badge.ts"],"sourcesContent":["import {run} from 'jscodeshift/src/Runner.js'\n\nimport {BaseCommand} from '../../baseCommand'\nimport {getTransformPath} from '../../utils/getTransformPath'\n\n/** @public */\nexport default class Badge extends BaseCommand<typeof Badge> {\n static override description = 'Transform Badge component'\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(Badge)\n const {paths, ...restFlags} = flags\n const transformPath = getTransformPath(this.config.root, 'latest', 'badge')\n\n await run(transformPath, paths, {\n babel: true,\n parser: 'tsx',\n ...restFlags,\n })\n }\n}\n"],"names":[],"mappings":";;AAMA,MAAqB,cAAc,YAA0B;AAAA,EAC3D,OAAgB,cAAc;AAAA,EAE9B,MAAa,MAAqB;AAChC,UAAM,EAAC,UAAS,MAAM,KAAK,MAAM,KAAK,GAChC,EAAC,OAAO,GAAG,UAAA,IAAa,OACxB,gBAAgB,iBAAiB,KAAK,OAAO,MAAM,UAAU,OAAO;AAE1E,UAAM,IAAI,eAAe,OAAO;AAAA,MAC9B,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,GAAG;AAAA,IAAA,CACJ;AAAA,EACH;AACF;"}
@@ -0,0 +1,18 @@
1
+ import { API } from "jscodeshift";
2
+ import { FileInfo } from "jscodeshift";
3
+ import type { Options } from "jscodeshift";
4
+
5
+ declare interface BaseOptions extends Options {
6
+ fromPackage?: string;
7
+ toPackage?: string;
8
+ }
9
+
10
+ /** @internal */
11
+ declare function transform(
12
+ fileInfo: FileInfo,
13
+ api: API,
14
+ options: BaseOptions,
15
+ ): string | undefined;
16
+ export default transform;
17
+
18
+ export {};