@volue/wave-codemod__react 0.2.11-next.1 → 0.3.0-next.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.
package/dist/index.cjs CHANGED
@@ -130,7 +130,7 @@ function renameLabelDot(j, ast) {
130
130
  });
131
131
  }
132
132
 
133
- function transformer$1(file, api, options) {
133
+ function transformer$2(file, api, options) {
134
134
  const { jscodeshift: j } = api;
135
135
  const ast = j(file.source);
136
136
  if (!utils.hasImportDeclaration(j, ast, "@volue/wave-react")) {
@@ -175,7 +175,7 @@ function renameAppFrame(j, ast) {
175
175
  });
176
176
  }
177
177
 
178
- function transformer(file, api, options) {
178
+ function transformer$1(file, api, options) {
179
179
  const { jscodeshift: j } = api;
180
180
  const ast = j(file.source);
181
181
  if (!utils.hasImportDeclaration(j, ast, "@volue/wave-react")) {
@@ -185,10 +185,92 @@ function transformer(file, api, options) {
185
185
  return ast.toSource(options.printOptions);
186
186
  }
187
187
 
188
+ function renameLogoInSidebarHeader(j, ast) {
189
+ const waveImports = ast.find(j.ImportDeclaration, {
190
+ source: { value: "@volue/wave-react" }
191
+ });
192
+ const logoImports = waveImports.find(j.ImportSpecifier, {
193
+ imported: { name: "Logo" }
194
+ });
195
+ if (logoImports.size() === 0) {
196
+ return;
197
+ }
198
+ let transformed = false;
199
+ ast.find(j.JSXElement, {
200
+ openingElement: {
201
+ name: {
202
+ type: "JSXMemberExpression",
203
+ object: {
204
+ type: "JSXIdentifier",
205
+ name: "SidebarNavigation"
206
+ },
207
+ property: {
208
+ type: "JSXIdentifier",
209
+ name: "Header"
210
+ }
211
+ }
212
+ }
213
+ }).forEach((headerPath) => {
214
+ headerPath.node.children?.forEach((child) => {
215
+ if (child.type !== "JSXElement" || child.openingElement.name.type !== "JSXIdentifier" || child.openingElement.name.name !== "Logo") {
216
+ return;
217
+ }
218
+ child.openingElement.name = j.jsxMemberExpression(
219
+ j.jsxIdentifier("SidebarNavigation"),
220
+ j.jsxIdentifier("Logo")
221
+ );
222
+ if (child.closingElement) {
223
+ child.closingElement.name = j.jsxMemberExpression(
224
+ j.jsxIdentifier("SidebarNavigation"),
225
+ j.jsxIdentifier("Logo")
226
+ );
227
+ }
228
+ child.openingElement.attributes = child.openingElement.attributes?.filter(
229
+ (attr) => !(attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === "variant")
230
+ );
231
+ transformed = true;
232
+ });
233
+ });
234
+ if (!transformed) {
235
+ return;
236
+ }
237
+ const remainingLogoUsages = ast.find(j.JSXOpeningElement, {
238
+ name: {
239
+ type: "JSXIdentifier",
240
+ name: "Logo"
241
+ }
242
+ });
243
+ if (remainingLogoUsages.size() > 0) {
244
+ return;
245
+ }
246
+ waveImports.forEach((declPath) => {
247
+ if (!declPath.node.specifiers) {
248
+ return;
249
+ }
250
+ declPath.node.specifiers = declPath.node.specifiers.filter(
251
+ (spec) => !(spec.type === "ImportSpecifier" && spec.imported.type === "Identifier" && spec.imported.name === "Logo")
252
+ );
253
+ if (declPath.node.specifiers.length === 0) {
254
+ j(declPath).remove();
255
+ }
256
+ });
257
+ }
258
+
259
+ function transformer(file, api, options) {
260
+ const { jscodeshift: j } = api;
261
+ const ast = j(file.source);
262
+ if (!utils.hasImportDeclaration(j, ast, "@volue/wave-react")) {
263
+ return file.source;
264
+ }
265
+ utils.applyMotions(j, ast, [renameLogoInSidebarHeader]);
266
+ return ast.toSource(options.printOptions);
267
+ }
268
+
188
269
  var index = {
189
270
  transforms: {
190
- "1.0.0": transformer$1,
191
- "1.1.0": transformer
271
+ "1.0.0": transformer$2,
272
+ "1.1.0": transformer$1,
273
+ "1.9.0": transformer
192
274
  }
193
275
  };
194
276
 
package/dist/index.d.cts CHANGED
@@ -1,13 +1,16 @@
1
1
  import { FileInfo, API, Options } from 'jscodeshift';
2
2
 
3
+ declare function transformer$2(file: FileInfo, api: API, options: Options): string;
4
+
3
5
  declare function transformer$1(file: FileInfo, api: API, options: Options): string;
4
6
 
5
7
  declare function transformer(file: FileInfo, api: API, options: Options): string;
6
8
 
7
9
  declare const _default: {
8
10
  transforms: {
9
- '1.0.0': typeof transformer$1;
10
- '1.1.0': typeof transformer;
11
+ '1.0.0': typeof transformer$2;
12
+ '1.1.0': typeof transformer$1;
13
+ '1.9.0': typeof transformer;
11
14
  };
12
15
  };
13
16
 
package/dist/index.d.mts CHANGED
@@ -1,13 +1,16 @@
1
1
  import { FileInfo, API, Options } from 'jscodeshift';
2
2
 
3
+ declare function transformer$2(file: FileInfo, api: API, options: Options): string;
4
+
3
5
  declare function transformer$1(file: FileInfo, api: API, options: Options): string;
4
6
 
5
7
  declare function transformer(file: FileInfo, api: API, options: Options): string;
6
8
 
7
9
  declare const _default: {
8
10
  transforms: {
9
- '1.0.0': typeof transformer$1;
10
- '1.1.0': typeof transformer;
11
+ '1.0.0': typeof transformer$2;
12
+ '1.1.0': typeof transformer$1;
13
+ '1.9.0': typeof transformer;
11
14
  };
12
15
  };
13
16
 
package/dist/index.mjs CHANGED
@@ -128,7 +128,7 @@ function renameLabelDot(j, ast) {
128
128
  });
129
129
  }
130
130
 
131
- function transformer$1(file, api, options) {
131
+ function transformer$2(file, api, options) {
132
132
  const { jscodeshift: j } = api;
133
133
  const ast = j(file.source);
134
134
  if (!hasImportDeclaration(j, ast, "@volue/wave-react")) {
@@ -173,7 +173,7 @@ function renameAppFrame(j, ast) {
173
173
  });
174
174
  }
175
175
 
176
- function transformer(file, api, options) {
176
+ function transformer$1(file, api, options) {
177
177
  const { jscodeshift: j } = api;
178
178
  const ast = j(file.source);
179
179
  if (!hasImportDeclaration(j, ast, "@volue/wave-react")) {
@@ -183,10 +183,92 @@ function transformer(file, api, options) {
183
183
  return ast.toSource(options.printOptions);
184
184
  }
185
185
 
186
+ function renameLogoInSidebarHeader(j, ast) {
187
+ const waveImports = ast.find(j.ImportDeclaration, {
188
+ source: { value: "@volue/wave-react" }
189
+ });
190
+ const logoImports = waveImports.find(j.ImportSpecifier, {
191
+ imported: { name: "Logo" }
192
+ });
193
+ if (logoImports.size() === 0) {
194
+ return;
195
+ }
196
+ let transformed = false;
197
+ ast.find(j.JSXElement, {
198
+ openingElement: {
199
+ name: {
200
+ type: "JSXMemberExpression",
201
+ object: {
202
+ type: "JSXIdentifier",
203
+ name: "SidebarNavigation"
204
+ },
205
+ property: {
206
+ type: "JSXIdentifier",
207
+ name: "Header"
208
+ }
209
+ }
210
+ }
211
+ }).forEach((headerPath) => {
212
+ headerPath.node.children?.forEach((child) => {
213
+ if (child.type !== "JSXElement" || child.openingElement.name.type !== "JSXIdentifier" || child.openingElement.name.name !== "Logo") {
214
+ return;
215
+ }
216
+ child.openingElement.name = j.jsxMemberExpression(
217
+ j.jsxIdentifier("SidebarNavigation"),
218
+ j.jsxIdentifier("Logo")
219
+ );
220
+ if (child.closingElement) {
221
+ child.closingElement.name = j.jsxMemberExpression(
222
+ j.jsxIdentifier("SidebarNavigation"),
223
+ j.jsxIdentifier("Logo")
224
+ );
225
+ }
226
+ child.openingElement.attributes = child.openingElement.attributes?.filter(
227
+ (attr) => !(attr.type === "JSXAttribute" && attr.name.type === "JSXIdentifier" && attr.name.name === "variant")
228
+ );
229
+ transformed = true;
230
+ });
231
+ });
232
+ if (!transformed) {
233
+ return;
234
+ }
235
+ const remainingLogoUsages = ast.find(j.JSXOpeningElement, {
236
+ name: {
237
+ type: "JSXIdentifier",
238
+ name: "Logo"
239
+ }
240
+ });
241
+ if (remainingLogoUsages.size() > 0) {
242
+ return;
243
+ }
244
+ waveImports.forEach((declPath) => {
245
+ if (!declPath.node.specifiers) {
246
+ return;
247
+ }
248
+ declPath.node.specifiers = declPath.node.specifiers.filter(
249
+ (spec) => !(spec.type === "ImportSpecifier" && spec.imported.type === "Identifier" && spec.imported.name === "Logo")
250
+ );
251
+ if (declPath.node.specifiers.length === 0) {
252
+ j(declPath).remove();
253
+ }
254
+ });
255
+ }
256
+
257
+ function transformer(file, api, options) {
258
+ const { jscodeshift: j } = api;
259
+ const ast = j(file.source);
260
+ if (!hasImportDeclaration(j, ast, "@volue/wave-react")) {
261
+ return file.source;
262
+ }
263
+ applyMotions(j, ast, [renameLogoInSidebarHeader]);
264
+ return ast.toSource(options.printOptions);
265
+ }
266
+
186
267
  var index = {
187
268
  transforms: {
188
- "1.0.0": transformer$1,
189
- "1.1.0": transformer
269
+ "1.0.0": transformer$2,
270
+ "1.1.0": transformer$1,
271
+ "1.9.0": transformer
190
272
  }
191
273
  };
192
274
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volue/wave-codemod__react",
3
- "version": "0.2.11-next.1",
3
+ "version": "0.3.0-next.0",
4
4
  "description": "Codemods for Wave React library",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {