@suspensive/codemods 3.5.0 → 3.7.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.
@@ -1,194 +1,75 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
- // If the importer is in node compatibility mode or this is not an ESM
19
- // file that has been converted to a CommonJS file using a Babel-
20
- // compatible transform (i.e. "__esModule" has not been set), then set
21
- // "default" to the CommonJS "module.exports" for node compatibility.
22
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
- mod
24
- ));
25
-
26
- // src/bin/codemods.ts
27
- var import_extra_typings = require("@commander-js/extra-typings");
2
+ const require_transformRunner = require('./transformRunner-BjDyWNWZ.cjs');
3
+ const __commander_js_extra_typings = require_transformRunner.__toESM(require("@commander-js/extra-typings"));
28
4
 
29
- // package.json
5
+ //#region package.json
6
+ var name = "@suspensive/codemods";
7
+ var version = "3.7.0";
8
+ var description = "Codemods for @suspensive.";
9
+ var keywords = ["suspensive", "codemods"];
10
+ var homepage = "https://suspensive.org";
11
+ var bugs = "https://github.com/toss/suspensive/issues";
12
+ var repository = {
13
+ "type": "git",
14
+ "url": "git+https://github.com/toss/suspensive.git",
15
+ "directory": "packages/codemods"
16
+ };
17
+ var license = "MIT";
18
+ var author = "Gwansik Kim <gwansik.kim@gwansik.dev>";
19
+ var sideEffects = false;
20
+ var type = "module";
21
+ var bin = "dist/bin/codemods.cjs";
22
+ var files = ["dist"];
23
+ var scripts = {
24
+ "build": "tsdown",
25
+ "ci:attw": "attw --pack",
26
+ "ci:eslint": "eslint \"**/*.{ts,tsx,cts,mts}\"",
27
+ "ci:publint": "publint --strict",
28
+ "ci:test": "vitest run",
29
+ "ci:type": "tsc --noEmit",
30
+ "clean": "rimraf ./dist ./coverage ./node_modules",
31
+ "prepack": "pnpm run build",
32
+ "test:ui": "vitest --ui"
33
+ };
34
+ var dependencies = {
35
+ "@commander-js/extra-typings": "^13.0.0",
36
+ "commander": "^13.0.0",
37
+ "execa": "^5.1.1",
38
+ "jscodeshift": "^17.0.0",
39
+ "prompts": "^2.4.2"
40
+ };
41
+ var devDependencies = {
42
+ "@suspensive/eslint-config": "workspace:*",
43
+ "@suspensive/tsconfig": "workspace:*",
44
+ "@suspensive/tsdown": "workspace:*",
45
+ "@types/jscodeshift": "^0.12.0",
46
+ "@types/prompts": "^2.4.9"
47
+ };
48
+ var publishConfig = { "access": "public" };
30
49
  var package_default = {
31
- name: "@suspensive/codemods",
32
- version: "3.5.0",
33
- description: "Codemods for @suspensive.",
34
- keywords: [
35
- "suspensive",
36
- "codemods"
37
- ],
38
- homepage: "https://suspensive.org",
39
- bugs: "https://github.com/toss/suspensive/issues",
40
- repository: {
41
- type: "git",
42
- url: "git+https://github.com/toss/suspensive.git",
43
- directory: "packages/codemods"
44
- },
45
- license: "MIT",
46
- author: "Gwansik Kim <gwansik.kim@gwansik.dev>",
47
- sideEffects: false,
48
- type: "module",
49
- bin: "dist/bin/codemods.cjs",
50
- files: [
51
- "dist"
52
- ],
53
- scripts: {
54
- build: "tsup",
55
- "ci:attw": "attw --pack",
56
- "ci:eslint": 'eslint "**/*.{ts,tsx,cts,mts}"',
57
- "ci:publint": "publint --strict",
58
- "ci:test": "vitest run",
59
- "ci:type": "tsc --noEmit",
60
- clean: "rimraf ./dist ./coverage ./node_modules",
61
- prepack: "pnpm run build",
62
- "test:ui": "vitest --ui"
63
- },
64
- dependencies: {
65
- "@commander-js/extra-typings": "^13.0.0",
66
- commander: "^13.0.0",
67
- execa: "^5.1.1",
68
- jscodeshift: "^17.0.0",
69
- prompts: "^2.4.2"
70
- },
71
- devDependencies: {
72
- "@suspensive/eslint-config": "workspace:*",
73
- "@suspensive/tsconfig": "workspace:*",
74
- "@suspensive/tsup": "workspace:*",
75
- "@types/jscodeshift": "^0.12.0",
76
- "@types/prompts": "^2.4.9"
77
- },
78
- publishConfig: {
79
- access: "public"
80
- }
50
+ name,
51
+ version,
52
+ description,
53
+ keywords,
54
+ homepage,
55
+ bugs,
56
+ repository,
57
+ license,
58
+ author,
59
+ sideEffects,
60
+ type,
61
+ bin,
62
+ files,
63
+ scripts,
64
+ dependencies,
65
+ devDependencies,
66
+ publishConfig
81
67
  };
82
68
 
83
- // src/bin/transformRunner.ts
84
- var import_node_path = require("path");
85
- var import_execa = __toESM(require("execa"), 1);
86
- var import_prompts = __toESM(require("prompts"), 1);
87
- var TRANSFORMER_INQUIRER_CHOICES = [
88
- {
89
- title: "tanstack-query-import",
90
- description: "Migrate imports to @tanstack/react-query in @suspensive/react-query"
91
- },
92
- {
93
- title: "migrate-query-client-consumer-props",
94
- description: "Migrate QueryClientConsumer context prop to queryClient"
95
- },
96
- {
97
- title: "migrate-with-api",
98
- description: "Migrate wrap API to with API for Suspensive v3"
99
- },
100
- {
101
- title: "remove-networkmode",
102
- description: "Remove networkMode from Suspense API"
103
- }
104
- ];
105
- function onCancel() {
106
- process.exit(1);
107
- }
108
- var jscodeshiftExecutable = require.resolve(".bin/jscodeshift");
109
- var transformerDirectory = (0, import_node_path.join)(__dirname, "../", "../", "dist", "transforms");
110
- async function transformRunner(transform, path, options) {
111
- let transformer = transform ?? "";
112
- let directory = path ?? "";
113
- if (transform && !TRANSFORMER_INQUIRER_CHOICES.find((x) => x.title === transform)) {
114
- console.error("Invalid transform choice, pick one of:");
115
- console.error(TRANSFORMER_INQUIRER_CHOICES.map((x) => `- ${+x.title}`).join("\n"));
116
- process.exit(1);
117
- }
118
- if (!transform) {
119
- const res = await (0, import_prompts.default)(
120
- {
121
- type: "select",
122
- name: "transformer",
123
- message: "Which transform would you like to apply?",
124
- choices: TRANSFORMER_INQUIRER_CHOICES.reverse().map(({ title, description }) => {
125
- return {
126
- title,
127
- description,
128
- value: title
129
- };
130
- })
131
- },
132
- { onCancel }
133
- );
134
- transformer = res.transformer;
135
- }
136
- if (!path) {
137
- const res = await (0, import_prompts.default)(
138
- {
139
- type: "text",
140
- name: "path",
141
- message: "On which files or directory should the codemods be applied?",
142
- initial: "."
143
- },
144
- { onCancel }
145
- );
146
- directory = res.path;
147
- }
148
- const args = [];
149
- if (options?.dry) {
150
- args.push("--dry");
151
- }
152
- if (options?.print) {
153
- args.push("--print");
154
- }
155
- args.push("--no-babel");
156
- args.push("--ignore-pattern=**/node_modules/**");
157
- args.push("--ignore-pattern=**/.next/**");
158
- args.push("--extensions=tsx,ts,jsx,js");
159
- args.push("--transform", (0, import_node_path.join)(transformerDirectory, `${transformer}.cjs`));
160
- args.push(directory);
161
- console.log(`Executing command: jscodeshift ${args.join(" ")}`);
162
- const execaChildProcess = (0, import_execa.default)(jscodeshiftExecutable, args, {
163
- env: process.stdout.isTTY ? { FORCE_COLOR: "true" } : {}
164
- });
165
- let lastThreeLineBreaks = "";
166
- if (execaChildProcess.stdout) {
167
- execaChildProcess.stdout.pipe(process.stdout);
168
- execaChildProcess.stderr?.pipe(process.stderr);
169
- execaChildProcess.stdout.on("data", (chunk) => {
170
- lastThreeLineBreaks += chunk.toString("utf-8");
171
- let cutoff = lastThreeLineBreaks.length;
172
- for (let i = 0; i < 3; i++) {
173
- cutoff = lastThreeLineBreaks.lastIndexOf("\n", cutoff) - 1;
174
- }
175
- if (cutoff > 0 && cutoff < lastThreeLineBreaks.length) {
176
- lastThreeLineBreaks = lastThreeLineBreaks.slice(cutoff + 1);
177
- }
178
- });
179
- }
180
- try {
181
- const result = await execaChildProcess;
182
- if (result.failed) {
183
- throw new Error(`jscodeshift exited with code ${result.exitCode}`);
184
- }
185
- } catch (error) {
186
- console.error(error);
187
- process.exit(1);
188
- }
189
- }
190
-
191
- // src/bin/codemods.ts
192
- var program = new import_extra_typings.Command(package_default.name);
193
- program.description(package_default.description).version(package_default.version, "-v, --version", "Output the current version of @suspensive/codemods.").argument("[codemod]", 'Codemod slug to run. See "https://suspensive.org/docs/codemods/motivation"').argument("[path]", "Path to source directory.").usage("[codemod] [path]").helpOption("-h, --help", "Display this help message.").option("-d, --dry", "Dry run (no changes are made to files)").option("-p, --print", "Print transformed files to stdout, useful for development").action(transformRunner);
69
+ //#endregion
70
+ //#region src/bin/codemods.ts
71
+ const program = new __commander_js_extra_typings.Command(package_default.name);
72
+ program.description(package_default.description).version(package_default.version, "-v, --version", "Output the current version of @suspensive/codemods.").argument("[codemod]", "Codemod slug to run. See \"https://suspensive.org/docs/codemods/motivation\"").argument("[path]", "Path to source directory.").usage("[codemod] [path]").helpOption("-h, --help", "Display this help message.").option("-d, --dry", "Dry run (no changes are made to files)").option("-p, --print", "Print transformed files to stdout, useful for development").action(require_transformRunner.transformRunner);
194
73
  program.parse(process.argv);
74
+
75
+ //#endregion
@@ -0,0 +1,139 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+ const node_path = __toESM(require("node:path"));
25
+ const execa = __toESM(require("execa"));
26
+ const prompts = __toESM(require("prompts"));
27
+
28
+ //#region src/bin/transformRunner.ts
29
+ const TRANSFORMER_INQUIRER_CHOICES = [
30
+ {
31
+ title: "tanstack-query-import",
32
+ description: "Migrate imports to @tanstack/react-query in @suspensive/react-query"
33
+ },
34
+ {
35
+ title: "migrate-query-client-consumer-props",
36
+ description: "Migrate QueryClientConsumer context prop to queryClient"
37
+ },
38
+ {
39
+ title: "migrate-with-api",
40
+ description: "Migrate wrap API to with API for Suspensive v3"
41
+ },
42
+ {
43
+ title: "remove-networkmode",
44
+ description: "Remove networkMode from Suspense API"
45
+ }
46
+ ];
47
+ function onCancel() {
48
+ process.exit(1);
49
+ }
50
+ const jscodeshiftExecutable = require.resolve(".bin/jscodeshift");
51
+ const transformerDirectory = (0, node_path.join)(__dirname, "../", "../", "dist", "transforms");
52
+ async function transformRunner(transform, path, options) {
53
+ let transformer = transform ?? "";
54
+ let directory = path ?? "";
55
+ if (transform && !TRANSFORMER_INQUIRER_CHOICES.find((x) => x.title === transform)) {
56
+ console.error("Invalid transform choice, pick one of:");
57
+ console.error(TRANSFORMER_INQUIRER_CHOICES.map((x) => `- ${+x.title}`).join("\n"));
58
+ process.exit(1);
59
+ }
60
+ if (!transform) {
61
+ const res = await (0, prompts.default)({
62
+ type: "select",
63
+ name: "transformer",
64
+ message: "Which transform would you like to apply?",
65
+ choices: TRANSFORMER_INQUIRER_CHOICES.reverse().map(({ title, description }) => {
66
+ return {
67
+ title,
68
+ description,
69
+ value: title
70
+ };
71
+ })
72
+ }, { onCancel });
73
+ transformer = res.transformer;
74
+ }
75
+ if (!path) {
76
+ const res = await (0, prompts.default)({
77
+ type: "text",
78
+ name: "path",
79
+ message: "On which files or directory should the codemods be applied?",
80
+ initial: "."
81
+ }, { onCancel });
82
+ directory = res.path;
83
+ }
84
+ const args = [];
85
+ if (options?.dry) args.push("--dry");
86
+ if (options?.print) args.push("--print");
87
+ args.push("--no-babel");
88
+ args.push("--ignore-pattern=**/node_modules/**");
89
+ args.push("--ignore-pattern=**/.next/**");
90
+ args.push("--extensions=tsx,ts,jsx,js");
91
+ args.push("--transform", (0, node_path.join)(transformerDirectory, `${transformer}.cjs`));
92
+ args.push(directory);
93
+ console.log(`Executing command: jscodeshift ${args.join(" ")}`);
94
+ const execaChildProcess = (0, execa.default)(jscodeshiftExecutable, args, { env: process.stdout.isTTY ? { FORCE_COLOR: "true" } : {} });
95
+ let lastThreeLineBreaks = "";
96
+ if (execaChildProcess.stdout) {
97
+ execaChildProcess.stdout.pipe(process.stdout);
98
+ execaChildProcess.stderr?.pipe(process.stderr);
99
+ execaChildProcess.stdout.on("data", (chunk) => {
100
+ lastThreeLineBreaks += chunk.toString("utf-8");
101
+ let cutoff = lastThreeLineBreaks.length;
102
+ for (let i = 0; i < 3; i++) cutoff = lastThreeLineBreaks.lastIndexOf("\n", cutoff) - 1;
103
+ if (cutoff > 0 && cutoff < lastThreeLineBreaks.length) lastThreeLineBreaks = lastThreeLineBreaks.slice(cutoff + 1);
104
+ });
105
+ }
106
+ try {
107
+ const result = await execaChildProcess;
108
+ if (result.failed) throw new Error(`jscodeshift exited with code ${result.exitCode}`);
109
+ } catch (error) {
110
+ console.error(error);
111
+ process.exit(1);
112
+ }
113
+ }
114
+
115
+ //#endregion
116
+ Object.defineProperty(exports, '__toESM', {
117
+ enumerable: true,
118
+ get: function () {
119
+ return __toESM;
120
+ }
121
+ });
122
+ Object.defineProperty(exports, 'jscodeshiftExecutable', {
123
+ enumerable: true,
124
+ get: function () {
125
+ return jscodeshiftExecutable;
126
+ }
127
+ });
128
+ Object.defineProperty(exports, 'transformRunner', {
129
+ enumerable: true,
130
+ get: function () {
131
+ return transformRunner;
132
+ }
133
+ });
134
+ Object.defineProperty(exports, 'transformerDirectory', {
135
+ enumerable: true,
136
+ get: function () {
137
+ return transformerDirectory;
138
+ }
139
+ });
@@ -1,149 +1,5 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ const require_transformRunner = require('./transformRunner-BjDyWNWZ.cjs');
29
2
 
30
- // src/bin/transformRunner.ts
31
- var transformRunner_exports = {};
32
- __export(transformRunner_exports, {
33
- jscodeshiftExecutable: () => jscodeshiftExecutable,
34
- transformRunner: () => transformRunner,
35
- transformerDirectory: () => transformerDirectory
36
- });
37
- module.exports = __toCommonJS(transformRunner_exports);
38
- var import_node_path = require("path");
39
- var import_execa = __toESM(require("execa"), 1);
40
- var import_prompts = __toESM(require("prompts"), 1);
41
- var TRANSFORMER_INQUIRER_CHOICES = [
42
- {
43
- title: "tanstack-query-import",
44
- description: "Migrate imports to @tanstack/react-query in @suspensive/react-query"
45
- },
46
- {
47
- title: "migrate-query-client-consumer-props",
48
- description: "Migrate QueryClientConsumer context prop to queryClient"
49
- },
50
- {
51
- title: "migrate-with-api",
52
- description: "Migrate wrap API to with API for Suspensive v3"
53
- },
54
- {
55
- title: "remove-networkmode",
56
- description: "Remove networkMode from Suspense API"
57
- }
58
- ];
59
- function onCancel() {
60
- process.exit(1);
61
- }
62
- var jscodeshiftExecutable = require.resolve(".bin/jscodeshift");
63
- var transformerDirectory = (0, import_node_path.join)(__dirname, "../", "../", "dist", "transforms");
64
- async function transformRunner(transform, path, options) {
65
- let transformer = transform ?? "";
66
- let directory = path ?? "";
67
- if (transform && !TRANSFORMER_INQUIRER_CHOICES.find((x) => x.title === transform)) {
68
- console.error("Invalid transform choice, pick one of:");
69
- console.error(TRANSFORMER_INQUIRER_CHOICES.map((x) => `- ${+x.title}`).join("\n"));
70
- process.exit(1);
71
- }
72
- if (!transform) {
73
- const res = await (0, import_prompts.default)(
74
- {
75
- type: "select",
76
- name: "transformer",
77
- message: "Which transform would you like to apply?",
78
- choices: TRANSFORMER_INQUIRER_CHOICES.reverse().map(({ title, description }) => {
79
- return {
80
- title,
81
- description,
82
- value: title
83
- };
84
- })
85
- },
86
- { onCancel }
87
- );
88
- transformer = res.transformer;
89
- }
90
- if (!path) {
91
- const res = await (0, import_prompts.default)(
92
- {
93
- type: "text",
94
- name: "path",
95
- message: "On which files or directory should the codemods be applied?",
96
- initial: "."
97
- },
98
- { onCancel }
99
- );
100
- directory = res.path;
101
- }
102
- const args = [];
103
- if (options?.dry) {
104
- args.push("--dry");
105
- }
106
- if (options?.print) {
107
- args.push("--print");
108
- }
109
- args.push("--no-babel");
110
- args.push("--ignore-pattern=**/node_modules/**");
111
- args.push("--ignore-pattern=**/.next/**");
112
- args.push("--extensions=tsx,ts,jsx,js");
113
- args.push("--transform", (0, import_node_path.join)(transformerDirectory, `${transformer}.cjs`));
114
- args.push(directory);
115
- console.log(`Executing command: jscodeshift ${args.join(" ")}`);
116
- const execaChildProcess = (0, import_execa.default)(jscodeshiftExecutable, args, {
117
- env: process.stdout.isTTY ? { FORCE_COLOR: "true" } : {}
118
- });
119
- let lastThreeLineBreaks = "";
120
- if (execaChildProcess.stdout) {
121
- execaChildProcess.stdout.pipe(process.stdout);
122
- execaChildProcess.stderr?.pipe(process.stderr);
123
- execaChildProcess.stdout.on("data", (chunk) => {
124
- lastThreeLineBreaks += chunk.toString("utf-8");
125
- let cutoff = lastThreeLineBreaks.length;
126
- for (let i = 0; i < 3; i++) {
127
- cutoff = lastThreeLineBreaks.lastIndexOf("\n", cutoff) - 1;
128
- }
129
- if (cutoff > 0 && cutoff < lastThreeLineBreaks.length) {
130
- lastThreeLineBreaks = lastThreeLineBreaks.slice(cutoff + 1);
131
- }
132
- });
133
- }
134
- try {
135
- const result = await execaChildProcess;
136
- if (result.failed) {
137
- throw new Error(`jscodeshift exited with code ${result.exitCode}`);
138
- }
139
- } catch (error) {
140
- console.error(error);
141
- process.exit(1);
142
- }
143
- }
144
- // Annotate the CommonJS export names for ESM import in node:
145
- 0 && (module.exports = {
146
- jscodeshiftExecutable,
147
- transformRunner,
148
- transformerDirectory
149
- });
3
+ exports.jscodeshiftExecutable = require_transformRunner.jscodeshiftExecutable;
4
+ exports.transformRunner = require_transformRunner.transformRunner;
5
+ exports.transformerDirectory = require_transformRunner.transformerDirectory;
@@ -0,0 +1,45 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+ const jscodeshift = __toESM(require("jscodeshift"));
25
+ const jscodeshift_parser_babylon = __toESM(require("jscodeshift/parser/babylon"));
26
+ const jscodeshift_parser_tsOptions = __toESM(require("jscodeshift/parser/tsOptions"));
27
+
28
+ //#region src/transforms/utils/createParserFromPath.ts
29
+ function createParserFromPath(filePath) {
30
+ const isDeclarationFile = /\.d\.[mc]?ts$/.test(filePath);
31
+ if (isDeclarationFile) return jscodeshift.default.withParser((0, jscodeshift_parser_babylon.default)({
32
+ ...jscodeshift_parser_tsOptions.default,
33
+ plugins: [...jscodeshift_parser_tsOptions.default.plugins.filter((plugin) => plugin !== "typescript"), ["typescript", { dts: true }]]
34
+ }));
35
+ const isTsFile = /\.[mc]?ts$/.test(filePath);
36
+ return isTsFile ? jscodeshift.default.withParser("ts") : jscodeshift.default.withParser("tsx");
37
+ }
38
+
39
+ //#endregion
40
+ Object.defineProperty(exports, 'createParserFromPath', {
41
+ enumerable: true,
42
+ get: function () {
43
+ return createParserFromPath;
44
+ }
45
+ });
@@ -1,81 +1,20 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ const require_createParserFromPath = require('./createParserFromPath-BwU9hgLu.cjs');
29
2
 
30
- // src/transforms/migrate-query-client-consumer-props.ts
31
- var migrate_query_client_consumer_props_exports = {};
32
- __export(migrate_query_client_consumer_props_exports, {
33
- default: () => transform
34
- });
35
- module.exports = __toCommonJS(migrate_query_client_consumer_props_exports);
36
-
37
- // src/transforms/utils/createParserFromPath.ts
38
- var import_jscodeshift = __toESM(require("jscodeshift"), 1);
39
- var import_babylon = __toESM(require("jscodeshift/parser/babylon"), 1);
40
- var import_tsOptions = __toESM(require("jscodeshift/parser/tsOptions"), 1);
41
- function createParserFromPath(filePath) {
42
- const isDeclarationFile = /\.d\.[mc]?ts$/.test(filePath);
43
- if (isDeclarationFile) {
44
- return import_jscodeshift.default.withParser(
45
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
46
- (0, import_babylon.default)({
47
- ...import_tsOptions.default,
48
- plugins: [
49
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
50
- ...import_tsOptions.default.plugins.filter((plugin) => plugin !== "typescript"),
51
- ["typescript", { dts: true }]
52
- ]
53
- })
54
- );
55
- }
56
- const isTsFile = /\.[mc]?ts$/.test(filePath);
57
- return isTsFile ? import_jscodeshift.default.withParser("ts") : import_jscodeshift.default.withParser("tsx");
58
- }
59
-
60
- // src/transforms/migrate-query-client-consumer-props.ts
3
+ //#region src/transforms/migrate-query-client-consumer-props.ts
61
4
  function transform(file) {
62
- const j2 = createParserFromPath(file.path);
63
- const root = j2(file.source);
64
- root.find(j2.JSXElement, {
65
- openingElement: {
66
- name: { name: "QueryClientConsumer" }
67
- }
68
- }).forEach((path) => {
69
- const attributes = path.node.openingElement.attributes || [];
70
- const contextIndex = attributes.findIndex((attr) => attr.type === "JSXAttribute" && attr.name.name === "context");
71
- if (contextIndex !== -1) {
72
- attributes.splice(contextIndex, 1);
73
- const newAttr = j2.jsxAttribute(
74
- j2.jsxIdentifier("queryClient"),
75
- j2.jsxExpressionContainer(j2.identifier("queryClient"))
76
- );
77
- attributes.push(newAttr);
78
- }
79
- });
80
- return root.toSource();
5
+ const j = require_createParserFromPath.createParserFromPath(file.path);
6
+ const root = j(file.source);
7
+ root.find(j.JSXElement, { openingElement: { name: { name: "QueryClientConsumer" } } }).forEach((path) => {
8
+ const attributes = path.node.openingElement.attributes || [];
9
+ const contextIndex = attributes.findIndex((attr) => attr.type === "JSXAttribute" && attr.name.name === "context");
10
+ if (contextIndex !== -1) {
11
+ attributes.splice(contextIndex, 1);
12
+ const newAttr = j.jsxAttribute(j.jsxIdentifier("queryClient"), j.jsxExpressionContainer(j.identifier("queryClient")));
13
+ attributes.push(newAttr);
14
+ }
15
+ });
16
+ return root.toSource();
81
17
  }
18
+
19
+ //#endregion
20
+ module.exports = transform;
@@ -1,129 +1,55 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ const require_createParserFromPath = require('./createParserFromPath-BwU9hgLu.cjs');
29
2
 
30
- // src/transforms/migrate-with-api.ts
31
- var migrate_with_api_exports = {};
32
- __export(migrate_with_api_exports, {
33
- default: () => transformer
34
- });
35
- module.exports = __toCommonJS(migrate_with_api_exports);
36
-
37
- // src/transforms/utils/createParserFromPath.ts
38
- var import_jscodeshift = __toESM(require("jscodeshift"), 1);
39
- var import_babylon = __toESM(require("jscodeshift/parser/babylon"), 1);
40
- var import_tsOptions = __toESM(require("jscodeshift/parser/tsOptions"), 1);
41
- function createParserFromPath(filePath) {
42
- const isDeclarationFile = /\.d\.[mc]?ts$/.test(filePath);
43
- if (isDeclarationFile) {
44
- return import_jscodeshift.default.withParser(
45
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
46
- (0, import_babylon.default)({
47
- ...import_tsOptions.default,
48
- plugins: [
49
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
50
- ...import_tsOptions.default.plugins.filter((plugin) => plugin !== "typescript"),
51
- ["typescript", { dts: true }]
52
- ]
53
- })
54
- );
55
- }
56
- const isTsFile = /\.[mc]?ts$/.test(filePath);
57
- return isTsFile ? import_jscodeshift.default.withParser("ts") : import_jscodeshift.default.withParser("tsx");
58
- }
59
-
60
- // src/transforms/migrate-with-api.ts
3
+ //#region src/transforms/migrate-with-api.ts
61
4
  function transformer(file) {
62
- const j2 = createParserFromPath(file.path);
63
- const root = j2(file.source);
64
- const usedSuspensiveAPIs = /* @__PURE__ */ new Set();
65
- const wrapImportNodes = root.find(j2.ImportDeclaration, { source: { value: "@suspensive/react" } });
66
- const wrapImportNames = wrapImportNodes.find(j2.ImportSpecifier, { imported: { name: "wrap" } }).nodes().map((spec) => spec.local?.name ?? "wrap");
67
- for (const path of wrapImportNodes.nodes()) {
68
- path.specifiers = path.specifiers?.filter(
69
- (spec) => !(spec.type === "ImportSpecifier" && spec.imported.name === "wrap")
70
- );
71
- }
72
- const callPaths = root.find(j2.CallExpression, {
73
- callee: {
74
- type: "MemberExpression",
75
- property: { type: "Identifier", name: "on" }
76
- }
77
- }).paths();
78
- for (const path of callPaths) {
79
- let current = path.node;
80
- const stages = [];
81
- while (current.type === "CallExpression" && current.callee.type === "MemberExpression") {
82
- const prop = current.callee.property;
83
- if (prop.type === "Identifier") {
84
- stages.unshift({ name: prop.name, args: current.arguments });
85
- }
86
- current = current.callee.object;
87
- }
88
- const isWrapRoot = current.type === "Identifier" && wrapImportNames.includes(current.name) || current.type === "MemberExpression" && current.object.type === "Identifier" && wrapImportNames.includes(current.object.name);
89
- if (!isWrapRoot) continue;
90
- const onStage = stages.find((s) => s.name === "on");
91
- if (!onStage) continue;
92
- const wrapComponentStages = stages.filter((s) => s.name !== "on");
93
- for (const stage of wrapComponentStages) {
94
- usedSuspensiveAPIs.add(stage.name);
95
- }
96
- let withNode = onStage.args[0];
97
- for (let i = wrapComponentStages.length - 1; i >= 0; i--) {
98
- const { name, args } = wrapComponentStages[i];
99
- const options = args[0] ?? j2.objectExpression([]);
100
- withNode = j2.callExpression(j2.memberExpression(j2.identifier(name), j2.identifier("with")), [options, withNode]);
101
- }
102
- j2(path).replaceWith(withNode);
103
- }
104
- if (usedSuspensiveAPIs.size > 0) {
105
- const suspensiveReactImport = root.find(j2.ImportDeclaration, { source: { value: "@suspensive/react" } });
106
- if (suspensiveReactImport.size() > 0) {
107
- for (const path of suspensiveReactImport.nodes()) {
108
- const existing = path.specifiers?.map(
109
- (spec) => spec.type === "ImportSpecifier" ? spec.imported.name : spec.local?.name
110
- );
111
- for (const name of Array.from(usedSuspensiveAPIs)) {
112
- if (!existing?.includes(name)) {
113
- path.specifiers?.push(j2.importSpecifier(j2.identifier(name)));
114
- }
115
- }
116
- }
117
- } else {
118
- for (const path of root.find(j2.Program).nodes()) {
119
- path.body.unshift(
120
- j2.importDeclaration(
121
- Array.from(usedSuspensiveAPIs).map((name) => j2.importSpecifier(j2.identifier(name))),
122
- j2.literal("@suspensive/react")
123
- )
124
- );
125
- }
126
- }
127
- return root.toSource();
128
- }
5
+ const j = require_createParserFromPath.createParserFromPath(file.path);
6
+ const root = j(file.source);
7
+ const usedSuspensiveAPIs = /* @__PURE__ */ new Set();
8
+ const wrapImportNodes = root.find(j.ImportDeclaration, { source: { value: "@suspensive/react" } });
9
+ const wrapImportNames = wrapImportNodes.find(j.ImportSpecifier, { imported: { name: "wrap" } }).nodes().map((spec) => spec.local?.name ?? "wrap");
10
+ for (const path of wrapImportNodes.nodes()) path.specifiers = path.specifiers?.filter((spec) => !(spec.type === "ImportSpecifier" && spec.imported.name === "wrap"));
11
+ const callPaths = root.find(j.CallExpression, { callee: {
12
+ type: "MemberExpression",
13
+ property: {
14
+ type: "Identifier",
15
+ name: "on"
16
+ }
17
+ } }).paths();
18
+ for (const path of callPaths) {
19
+ let current = path.node;
20
+ const stages = [];
21
+ while (current.type === "CallExpression" && current.callee.type === "MemberExpression") {
22
+ const prop = current.callee.property;
23
+ if (prop.type === "Identifier") stages.unshift({
24
+ name: prop.name,
25
+ args: current.arguments
26
+ });
27
+ current = current.callee.object;
28
+ }
29
+ const isWrapRoot = current.type === "Identifier" && wrapImportNames.includes(current.name) || current.type === "MemberExpression" && current.object.type === "Identifier" && wrapImportNames.includes(current.object.name);
30
+ if (!isWrapRoot) continue;
31
+ const onStage = stages.find((s) => s.name === "on");
32
+ if (!onStage) continue;
33
+ const wrapComponentStages = stages.filter((s) => s.name !== "on");
34
+ for (const stage of wrapComponentStages) usedSuspensiveAPIs.add(stage.name);
35
+ let withNode = onStage.args[0];
36
+ for (let i = wrapComponentStages.length - 1; i >= 0; i--) {
37
+ const { name, args } = wrapComponentStages[i];
38
+ const options = args[0] ?? j.objectExpression([]);
39
+ withNode = j.callExpression(j.memberExpression(j.identifier(name), j.identifier("with")), [options, withNode]);
40
+ }
41
+ j(path).replaceWith(withNode);
42
+ }
43
+ if (usedSuspensiveAPIs.size > 0) {
44
+ const suspensiveReactImport = root.find(j.ImportDeclaration, { source: { value: "@suspensive/react" } });
45
+ if (suspensiveReactImport.size() > 0) for (const path of suspensiveReactImport.nodes()) {
46
+ const existing = path.specifiers?.map((spec) => spec.type === "ImportSpecifier" ? spec.imported.name : spec.local?.name);
47
+ for (const name of Array.from(usedSuspensiveAPIs)) if (!existing?.includes(name)) path.specifiers?.push(j.importSpecifier(j.identifier(name)));
48
+ }
49
+ else for (const path of root.find(j.Program).nodes()) path.body.unshift(j.importDeclaration(Array.from(usedSuspensiveAPIs).map((name) => j.importSpecifier(j.identifier(name))), j.literal("@suspensive/react")));
50
+ return root.toSource();
51
+ }
129
52
  }
53
+
54
+ //#endregion
55
+ module.exports = transformer;
@@ -1,106 +1,36 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ const require_createParserFromPath = require('./createParserFromPath-BwU9hgLu.cjs');
29
2
 
30
- // src/transforms/remove-networkmode.ts
31
- var remove_networkmode_exports = {};
32
- __export(remove_networkmode_exports, {
33
- default: () => transform
34
- });
35
- module.exports = __toCommonJS(remove_networkmode_exports);
36
-
37
- // src/transforms/utils/createParserFromPath.ts
38
- var import_jscodeshift = __toESM(require("jscodeshift"), 1);
39
- var import_babylon = __toESM(require("jscodeshift/parser/babylon"), 1);
40
- var import_tsOptions = __toESM(require("jscodeshift/parser/tsOptions"), 1);
41
- function createParserFromPath(filePath) {
42
- const isDeclarationFile = /\.d\.[mc]?ts$/.test(filePath);
43
- if (isDeclarationFile) {
44
- return import_jscodeshift.default.withParser(
45
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
46
- (0, import_babylon.default)({
47
- ...import_tsOptions.default,
48
- plugins: [
49
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
50
- ...import_tsOptions.default.plugins.filter((plugin) => plugin !== "typescript"),
51
- ["typescript", { dts: true }]
52
- ]
53
- })
54
- );
55
- }
56
- const isTsFile = /\.[mc]?ts$/.test(filePath);
57
- return isTsFile ? import_jscodeshift.default.withParser("ts") : import_jscodeshift.default.withParser("tsx");
58
- }
59
-
60
- // src/transforms/remove-networkmode.ts
61
- var TARGET_FUNCTIONS = /* @__PURE__ */ new Set([
62
- "queryOptions",
63
- "infiniteQueryOptions",
64
- "useSuspenseQuery",
65
- "useSuspenseInfiniteQuery",
66
- "SuspenseQuery",
67
- "SuspenseInfiniteQuery"
3
+ //#region src/transforms/remove-networkmode.ts
4
+ const TARGET_FUNCTIONS = new Set([
5
+ "queryOptions",
6
+ "infiniteQueryOptions",
7
+ "useSuspenseQuery",
8
+ "useSuspenseInfiniteQuery",
9
+ "SuspenseQuery",
10
+ "SuspenseInfiniteQuery"
68
11
  ]);
69
12
  function transform(file) {
70
- const j2 = createParserFromPath(file.path);
71
- const root = j2(file.source);
72
- root.find(j2.CallExpression, {
73
- callee: {
74
- type: "Identifier"
75
- }
76
- }).forEach((path) => {
77
- if (path.node.callee.type !== "Identifier") {
78
- return;
79
- }
80
- const calleeName = path.node.callee.name;
81
- if (!TARGET_FUNCTIONS.has(calleeName)) {
82
- return;
83
- }
84
- const args = path.node.arguments;
85
- if (args.length === 0) {
86
- return;
87
- }
88
- const firstArg = args[0];
89
- if (firstArg.type !== "ObjectExpression") {
90
- return;
91
- }
92
- const properties = firstArg.properties;
93
- const networkModeIndex = properties.findIndex((prop) => {
94
- if (prop.type === "ObjectProperty" && prop.key.type === "Identifier" && prop.key.name === "networkMode") {
95
- if (prop.value.type === "StringLiteral" && prop.value.value === "always") {
96
- return true;
97
- }
98
- }
99
- return false;
100
- });
101
- if (networkModeIndex !== -1) {
102
- properties.splice(networkModeIndex, 1);
103
- }
104
- });
105
- return root.toSource();
13
+ const j = require_createParserFromPath.createParserFromPath(file.path);
14
+ const root = j(file.source);
15
+ root.find(j.CallExpression, { callee: { type: "Identifier" } }).forEach((path) => {
16
+ if (path.node.callee.type !== "Identifier") return;
17
+ const calleeName = path.node.callee.name;
18
+ if (!TARGET_FUNCTIONS.has(calleeName)) return;
19
+ const args = path.node.arguments;
20
+ if (args.length === 0) return;
21
+ const firstArg = args[0];
22
+ if (firstArg.type !== "ObjectExpression") return;
23
+ const properties = firstArg.properties;
24
+ const networkModeIndex = properties.findIndex((prop) => {
25
+ if (prop.type === "ObjectProperty" && prop.key.type === "Identifier" && prop.key.name === "networkMode") {
26
+ if (prop.value.type === "StringLiteral" && prop.value.value === "always") return true;
27
+ }
28
+ return false;
29
+ });
30
+ if (networkModeIndex !== -1) properties.splice(networkModeIndex, 1);
31
+ });
32
+ return root.toSource();
106
33
  }
34
+
35
+ //#endregion
36
+ module.exports = transform;
@@ -1,107 +1,40 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ const require_createParserFromPath = require('./createParserFromPath-BwU9hgLu.cjs');
29
2
 
30
- // src/transforms/tanstack-query-import.ts
31
- var tanstack_query_import_exports = {};
32
- __export(tanstack_query_import_exports, {
33
- default: () => transform
34
- });
35
- module.exports = __toCommonJS(tanstack_query_import_exports);
36
-
37
- // src/transforms/utils/createParserFromPath.ts
38
- var import_jscodeshift = __toESM(require("jscodeshift"), 1);
39
- var import_babylon = __toESM(require("jscodeshift/parser/babylon"), 1);
40
- var import_tsOptions = __toESM(require("jscodeshift/parser/tsOptions"), 1);
41
- function createParserFromPath(filePath) {
42
- const isDeclarationFile = /\.d\.[mc]?ts$/.test(filePath);
43
- if (isDeclarationFile) {
44
- return import_jscodeshift.default.withParser(
45
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
46
- (0, import_babylon.default)({
47
- ...import_tsOptions.default,
48
- plugins: [
49
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
50
- ...import_tsOptions.default.plugins.filter((plugin) => plugin !== "typescript"),
51
- ["typescript", { dts: true }]
52
- ]
53
- })
54
- );
55
- }
56
- const isTsFile = /\.[mc]?ts$/.test(filePath);
57
- return isTsFile ? import_jscodeshift.default.withParser("ts") : import_jscodeshift.default.withParser("tsx");
58
- }
59
-
60
- // src/transforms/tanstack-query-import.ts
61
- var IMPORT_TO_CHANGE = [
62
- "useSuspenseQuery",
63
- "UseSuspenseQueryResult",
64
- "UseSuspenseQueryOptions",
65
- "useSuspenseQueries",
66
- "SuspenseQueriesResults",
67
- "SuspenseQueriesOptions",
68
- "useSuspenseInfiniteQuery",
69
- "UseSuspenseInfiniteQueryResult",
70
- "UseSuspenseInfiniteQueryOptions",
71
- "usePrefetchQuery",
72
- "queryOptions",
73
- "infiniteQueryOption"
3
+ //#region src/transforms/tanstack-query-import.ts
4
+ const IMPORT_TO_CHANGE = [
5
+ "useSuspenseQuery",
6
+ "UseSuspenseQueryResult",
7
+ "UseSuspenseQueryOptions",
8
+ "useSuspenseQueries",
9
+ "SuspenseQueriesResults",
10
+ "SuspenseQueriesOptions",
11
+ "useSuspenseInfiniteQuery",
12
+ "UseSuspenseInfiniteQueryResult",
13
+ "UseSuspenseInfiniteQueryOptions",
14
+ "usePrefetchQuery",
15
+ "queryOptions",
16
+ "infiniteQueryOption"
74
17
  ];
75
18
  function transform(file) {
76
- const j2 = createParserFromPath(file.path);
77
- const root = j2(file.source);
78
- root.find(j2.ImportDeclaration, {
79
- source: {
80
- value: (v) => /^@suspensive\/react-query(-\d+)?$/.test(v)
81
- }
82
- }).forEach((path) => {
83
- const importSpecifiers = path.node.specifiers || [];
84
- const importNamesToChange = importSpecifiers.filter(
85
- (specifier) => IMPORT_TO_CHANGE.includes(specifier.local?.name ?? "")
86
- );
87
- const importsNamesRemained = importSpecifiers.filter(
88
- (specifier) => !IMPORT_TO_CHANGE.includes(specifier.local?.name ?? "")
89
- );
90
- if (importNamesToChange.length > 0) {
91
- const newImportStatement = j2.importDeclaration(importNamesToChange, j2.stringLiteral("@tanstack/react-query"));
92
- path.insertBefore(newImportStatement);
93
- }
94
- if (importsNamesRemained.length > 0) {
95
- const remainingSpecifiers = importSpecifiers.filter(
96
- (specifier) => !IMPORT_TO_CHANGE.includes(specifier.local?.name ?? "")
97
- );
98
- const suspensiveRemainImportsStatement = j2.importDeclaration(
99
- remainingSpecifiers,
100
- j2.stringLiteral(path.node.source.value || "@suspensive/react-query")
101
- );
102
- path.insertBefore(suspensiveRemainImportsStatement);
103
- }
104
- j2(path).remove();
105
- }).toSource();
106
- return root.toSource();
19
+ const j = require_createParserFromPath.createParserFromPath(file.path);
20
+ const root = j(file.source);
21
+ root.find(j.ImportDeclaration, { source: { value: (v) => /^@suspensive\/react-query(-\d+)?$/.test(v) } }).forEach((path) => {
22
+ const importSpecifiers = path.node.specifiers || [];
23
+ 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 ?? ""));
25
+ if (importNamesToChange.length > 0) {
26
+ const newImportStatement = j.importDeclaration(importNamesToChange, j.stringLiteral("@tanstack/react-query"));
27
+ path.insertBefore(newImportStatement);
28
+ }
29
+ if (importsNamesRemained.length > 0) {
30
+ const remainingSpecifiers = importSpecifiers.filter((specifier) => !IMPORT_TO_CHANGE.includes(specifier.local?.name ?? ""));
31
+ const suspensiveRemainImportsStatement = j.importDeclaration(remainingSpecifiers, j.stringLiteral(path.node.source.value || "@suspensive/react-query"));
32
+ path.insertBefore(suspensiveRemainImportsStatement);
33
+ }
34
+ j(path).remove();
35
+ }).toSource();
36
+ return root.toSource();
107
37
  }
38
+
39
+ //#endregion
40
+ module.exports = transform;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suspensive/codemods",
3
- "version": "3.5.0",
3
+ "version": "3.7.0",
4
4
  "description": "Codemods for @suspensive.",
5
5
  "keywords": [
6
6
  "suspensive",
@@ -33,13 +33,13 @@
33
33
  "@types/prompts": "^2.4.9",
34
34
  "@suspensive/eslint-config": "0.0.1",
35
35
  "@suspensive/tsconfig": "0.0.0-development",
36
- "@suspensive/tsup": "0.0.0"
36
+ "@suspensive/tsdown": "0.0.0"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
41
  "scripts": {
42
- "build": "tsup",
42
+ "build": "tsdown",
43
43
  "ci:attw": "attw --pack",
44
44
  "ci:eslint": "eslint \"**/*.{ts,tsx,cts,mts}\"",
45
45
  "ci:publint": "publint --strict",