@suspensive/codemods 3.10.0 → 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.
- package/dist/bin/codemods.cjs +4 -6
- package/dist/bin/{transformRunner-BjDyWNWZ.cjs → transformRunner-DsL8D3M_.cjs} +24 -27
- package/dist/bin/transformRunner.cjs +1 -1
- package/dist/transforms/{createParserFromPath-BwU9hgLu.cjs → createParserFromPath-y5rtnS_K.cjs} +8 -7
- package/dist/transforms/migrate-query-client-consumer-props.cjs +1 -1
- package/dist/transforms/migrate-with-api.cjs +2 -3
- package/dist/transforms/remove-networkmode.cjs +1 -1
- package/dist/transforms/tanstack-query-import.cjs +29 -3
- package/package.json +1 -3
package/dist/bin/codemods.cjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_transformRunner = require('./transformRunner-
|
|
3
|
-
|
|
2
|
+
const require_transformRunner = require('./transformRunner-DsL8D3M_.cjs');
|
|
3
|
+
let __commander_js_extra_typings = require("@commander-js/extra-typings");
|
|
4
|
+
__commander_js_extra_typings = require_transformRunner.__toESM(__commander_js_extra_typings);
|
|
4
5
|
|
|
5
6
|
//#region package.json
|
|
6
7
|
var name = "@suspensive/codemods";
|
|
7
|
-
var version = "3.
|
|
8
|
+
var version = "3.11.0";
|
|
8
9
|
var description = "Codemods for @suspensive.";
|
|
9
10
|
var keywords = ["suspensive", "codemods"];
|
|
10
11
|
var homepage = "https://suspensive.org";
|
|
@@ -22,13 +23,10 @@ var bin = "dist/bin/codemods.cjs";
|
|
|
22
23
|
var files = ["dist"];
|
|
23
24
|
var scripts = {
|
|
24
25
|
"build": "tsdown",
|
|
25
|
-
"ci:attw": "attw --pack",
|
|
26
26
|
"ci:eslint": "eslint \"**/*.{ts,tsx,cts,mts}\"",
|
|
27
|
-
"ci:publint": "publint --strict",
|
|
28
27
|
"ci:test": "vitest run",
|
|
29
28
|
"ci:type": "tsc --noEmit",
|
|
30
29
|
"clean": "rimraf ./dist ./coverage ./node_modules",
|
|
31
|
-
"prepack": "pnpm run build",
|
|
32
30
|
"test:ui": "vitest --ui"
|
|
33
31
|
};
|
|
34
32
|
var dependencies = {
|
|
@@ -21,9 +21,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
}) : target, mod));
|
|
22
22
|
|
|
23
23
|
//#endregion
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
let node_path = require("node:path");
|
|
25
|
+
node_path = __toESM(node_path);
|
|
26
|
+
let execa = require("execa");
|
|
27
|
+
execa = __toESM(execa);
|
|
28
|
+
let prompts = require("prompts");
|
|
29
|
+
prompts = __toESM(prompts);
|
|
27
30
|
|
|
28
31
|
//#region src/bin/transformRunner.ts
|
|
29
32
|
const TRANSFORMER_INQUIRER_CHOICES = [
|
|
@@ -57,30 +60,24 @@ async function transformRunner(transform, path, options) {
|
|
|
57
60
|
console.error(TRANSFORMER_INQUIRER_CHOICES.map((x) => `- ${+x.title}`).join("\n"));
|
|
58
61
|
process.exit(1);
|
|
59
62
|
}
|
|
60
|
-
if (!transform) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
name: "path",
|
|
79
|
-
message: "On which files or directory should the codemods be applied?",
|
|
80
|
-
initial: "."
|
|
81
|
-
}, { onCancel });
|
|
82
|
-
directory = res.path;
|
|
83
|
-
}
|
|
63
|
+
if (!transform) transformer = (await (0, prompts.default)({
|
|
64
|
+
type: "select",
|
|
65
|
+
name: "transformer",
|
|
66
|
+
message: "Which transform would you like to apply?",
|
|
67
|
+
choices: TRANSFORMER_INQUIRER_CHOICES.reverse().map(({ title, description }) => {
|
|
68
|
+
return {
|
|
69
|
+
title,
|
|
70
|
+
description,
|
|
71
|
+
value: title
|
|
72
|
+
};
|
|
73
|
+
})
|
|
74
|
+
}, { onCancel })).transformer;
|
|
75
|
+
if (!path) directory = (await (0, prompts.default)({
|
|
76
|
+
type: "text",
|
|
77
|
+
name: "path",
|
|
78
|
+
message: "On which files or directory should the codemods be applied?",
|
|
79
|
+
initial: "."
|
|
80
|
+
}, { onCancel })).path;
|
|
84
81
|
const args = [];
|
|
85
82
|
if (options?.dry) args.push("--dry");
|
|
86
83
|
if (options?.print) args.push("--print");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_transformRunner = require('./transformRunner-
|
|
1
|
+
const require_transformRunner = require('./transformRunner-DsL8D3M_.cjs');
|
|
2
2
|
|
|
3
3
|
exports.jscodeshiftExecutable = require_transformRunner.jscodeshiftExecutable;
|
|
4
4
|
exports.transformRunner = require_transformRunner.transformRunner;
|
package/dist/transforms/{createParserFromPath-BwU9hgLu.cjs → createParserFromPath-y5rtnS_K.cjs}
RENAMED
|
@@ -21,19 +21,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
}) : target, mod));
|
|
22
22
|
|
|
23
23
|
//#endregion
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
let jscodeshift = require("jscodeshift");
|
|
25
|
+
jscodeshift = __toESM(jscodeshift);
|
|
26
|
+
let jscodeshift_parser_babylon = require("jscodeshift/parser/babylon");
|
|
27
|
+
jscodeshift_parser_babylon = __toESM(jscodeshift_parser_babylon);
|
|
28
|
+
let jscodeshift_parser_tsOptions = require("jscodeshift/parser/tsOptions");
|
|
29
|
+
jscodeshift_parser_tsOptions = __toESM(jscodeshift_parser_tsOptions);
|
|
27
30
|
|
|
28
31
|
//#region src/transforms/utils/createParserFromPath.ts
|
|
29
32
|
function createParserFromPath(filePath) {
|
|
30
|
-
|
|
31
|
-
if (isDeclarationFile) return jscodeshift.default.withParser((0, jscodeshift_parser_babylon.default)({
|
|
33
|
+
if (/\.d\.[mc]?ts$/.test(filePath)) return jscodeshift.default.withParser((0, jscodeshift_parser_babylon.default)({
|
|
32
34
|
...jscodeshift_parser_tsOptions.default,
|
|
33
35
|
plugins: [...jscodeshift_parser_tsOptions.default.plugins.filter((plugin) => plugin !== "typescript"), ["typescript", { dts: true }]]
|
|
34
36
|
}));
|
|
35
|
-
|
|
36
|
-
return isTsFile ? jscodeshift.default.withParser("ts") : jscodeshift.default.withParser("tsx");
|
|
37
|
+
return /\.[mc]?ts$/.test(filePath) ? jscodeshift.default.withParser("ts") : jscodeshift.default.withParser("tsx");
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_createParserFromPath = require('./createParserFromPath-
|
|
1
|
+
const require_createParserFromPath = require('./createParserFromPath-y5rtnS_K.cjs');
|
|
2
2
|
|
|
3
3
|
//#region src/transforms/migrate-with-api.ts
|
|
4
4
|
function transformer(file) {
|
|
@@ -26,8 +26,7 @@ function transformer(file) {
|
|
|
26
26
|
});
|
|
27
27
|
current = current.callee.object;
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
if (!isWrapRoot) continue;
|
|
29
|
+
if (!(current.type === "Identifier" && wrapImportNames.includes(current.name) || current.type === "MemberExpression" && current.object.type === "Identifier" && wrapImportNames.includes(current.object.name))) continue;
|
|
31
30
|
const onStage = stages.find((s) => s.name === "on");
|
|
32
31
|
if (!onStage) continue;
|
|
33
32
|
const wrapComponentStages = stages.filter((s) => s.name !== "on");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_createParserFromPath = require('./createParserFromPath-
|
|
1
|
+
const require_createParserFromPath = require('./createParserFromPath-y5rtnS_K.cjs');
|
|
2
2
|
|
|
3
3
|
//#region src/transforms/tanstack-query-import.ts
|
|
4
4
|
const IMPORT_TO_CHANGE = [
|
|
@@ -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
|
-
})
|
|
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.
|
|
3
|
+
"version": "3.11.0",
|
|
4
4
|
"description": "Codemods for @suspensive.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"suspensive",
|
|
@@ -40,9 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "tsdown",
|
|
43
|
-
"ci:attw": "attw --pack",
|
|
44
43
|
"ci:eslint": "eslint \"**/*.{ts,tsx,cts,mts}\"",
|
|
45
|
-
"ci:publint": "publint --strict",
|
|
46
44
|
"ci:test": "vitest run",
|
|
47
45
|
"ci:type": "tsc --noEmit",
|
|
48
46
|
"clean": "rimraf ./dist ./coverage ./node_modules",
|