@suspensive/codemods 3.10.1 → 3.11.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.
@@ -5,7 +5,7 @@ __commander_js_extra_typings = require_transformRunner.__toESM(__commander_js_ex
5
5
 
6
6
  //#region package.json
7
7
  var name = "@suspensive/codemods";
8
- var version = "3.10.1";
8
+ var version = "3.11.0";
9
9
  var description = "Codemods for @suspensive.";
10
10
  var keywords = ["suspensive", "codemods"];
11
11
  var homepage = "https://suspensive.org";
@@ -15,13 +15,19 @@ const IMPORT_TO_CHANGE = [
15
15
  "queryOptions",
16
16
  "infiniteQueryOption"
17
17
  ];
18
+ const REMOVE_DEPRECATED_IMPORTS = [
19
+ "SelectedInfiniteOptions",
20
+ "UnSelectedInfiniteOptions",
21
+ "SelectedQueryOptions",
22
+ "UnSelectedQueryOptions"
23
+ ];
18
24
  function transform(file) {
19
25
  const j = require_createParserFromPath.createParserFromPath(file.path);
20
26
  const root = j(file.source);
21
27
  root.find(j.ImportDeclaration, { source: { value: (v) => /^@suspensive\/react-query(-\d+)?$/.test(v) } }).forEach((path) => {
22
28
  const importSpecifiers = path.node.specifiers || [];
23
29
  const importNamesToChange = importSpecifiers.filter((specifier) => IMPORT_TO_CHANGE.includes(specifier.local?.name ?? ""));
24
- const importsNamesRemained = importSpecifiers.filter((specifier) => !IMPORT_TO_CHANGE.includes(specifier.local?.name ?? ""));
30
+ const importsNamesRemained = importSpecifiers.filter((specifier) => !IMPORT_TO_CHANGE.includes(specifier.local?.name ?? "") && !REMOVE_DEPRECATED_IMPORTS.includes(specifier.local?.name ?? ""));
25
31
  if (importNamesToChange.length > 0) {
26
32
  const newImportStatement = j.importDeclaration(importNamesToChange, j.stringLiteral("@tanstack/react-query"));
27
33
  path.insertBefore(newImportStatement);
@@ -32,7 +38,27 @@ function transform(file) {
32
38
  path.insertBefore(suspensiveRemainImportsStatement);
33
39
  }
34
40
  j(path).remove();
35
- }).toSource();
41
+ });
42
+ root.find(j.ExportNamedDeclaration).forEach((path) => {
43
+ if (path.node.specifiers) {
44
+ const exportSpecifiers = path.node.specifiers;
45
+ const exportNamesToChange = exportSpecifiers.filter((specifier) => IMPORT_TO_CHANGE.includes(specifier.local?.name ?? ""));
46
+ const exportNamesRemained = exportSpecifiers.filter((specifier) => !IMPORT_TO_CHANGE.includes(specifier.local?.name ?? "") && !REMOVE_DEPRECATED_IMPORTS.includes(specifier.local?.name ?? ""));
47
+ if (exportNamesToChange.length > 0) {
48
+ const newExportStatement = j.exportNamedDeclaration(null, exportNamesToChange);
49
+ path.insertBefore(newExportStatement);
50
+ }
51
+ if (exportNamesRemained.length > 0) {
52
+ const remainingExportStatement = j.exportNamedDeclaration(null, exportNamesRemained);
53
+ path.insertBefore(remainingExportStatement);
54
+ }
55
+ j(path).remove();
56
+ }
57
+ });
58
+ REMOVE_DEPRECATED_IMPORTS.forEach((deprecatedType) => {
59
+ root.find(j.TSTypeReference, { typeName: { name: deprecatedType } }).remove();
60
+ root.find(j.Identifier, { name: deprecatedType }).remove();
61
+ });
36
62
  return root.toSource();
37
63
  }
38
64
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suspensive/codemods",
3
- "version": "3.10.1",
3
+ "version": "3.11.0",
4
4
  "description": "Codemods for @suspensive.",
5
5
  "keywords": [
6
6
  "suspensive",