@trpc/upgrade 0.0.0-alpha.32 → 0.0.0-alpha.33
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.js +15 -10
- package/package.json +1 -1
- package/src/bin/index.ts +6 -5
- package/src/lib/ast/scanners.ts +2 -2
- package/src/lib/pkgmgr.ts +6 -2
package/dist/bin.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { basename, extname } from 'node:path';
|
|
2
3
|
import { parse } from '@bomb.sh/args';
|
|
3
4
|
import * as p from '@clack/prompts';
|
|
4
5
|
import { intro, log, multiselect, isCancel, outro } from '@clack/prompts';
|
|
@@ -8,15 +9,15 @@ import * as CP from 'node:child_process';
|
|
|
8
9
|
import * as Util from 'node:util';
|
|
9
10
|
import __node_cjsModule from 'node:module';
|
|
10
11
|
|
|
11
|
-
var version = "0.0.0-alpha.
|
|
12
|
+
var version = "0.0.0-alpha.32";
|
|
12
13
|
|
|
13
|
-
function getProgram(
|
|
14
|
+
function getProgram() {
|
|
14
15
|
const configFile = ts.findConfigFile(process.cwd(), (filepath)=>ts.sys.fileExists(filepath));
|
|
15
16
|
if (!configFile) {
|
|
16
17
|
p.log.error('No tsconfig found');
|
|
17
18
|
process.exit(1);
|
|
18
19
|
}
|
|
19
|
-
if (
|
|
20
|
+
if (process.env.VERBOSE) {
|
|
20
21
|
p.log.info(`Using tsconfig: ${configFile}`);
|
|
21
22
|
}
|
|
22
23
|
const { config } = ts.readConfigFile(configFile, (filepath)=>ts.sys.readFile(filepath));
|
|
@@ -136,7 +137,9 @@ async function installPackage(packageName) {
|
|
|
136
137
|
if (stderr) {
|
|
137
138
|
p.log.error(stderr);
|
|
138
139
|
}
|
|
139
|
-
|
|
140
|
+
if (process.env.VERBOSE) {
|
|
141
|
+
p.log.info(stdout);
|
|
142
|
+
}
|
|
140
143
|
}
|
|
141
144
|
async function uninstallPackage(packageName) {
|
|
142
145
|
const packageManager = getPackageManager();
|
|
@@ -145,7 +148,9 @@ async function uninstallPackage(packageName) {
|
|
|
145
148
|
if (stderr) {
|
|
146
149
|
p.log.error(stderr);
|
|
147
150
|
}
|
|
148
|
-
|
|
151
|
+
if (process.env.VERBOSE) {
|
|
152
|
+
p.log.info(stdout);
|
|
153
|
+
}
|
|
149
154
|
}
|
|
150
155
|
|
|
151
156
|
const require = __node_cjsModule.createRequire(import.meta.url);
|
|
@@ -164,6 +169,7 @@ const args = parse(process.argv.slice(2), {
|
|
|
164
169
|
},
|
|
165
170
|
boolean: true
|
|
166
171
|
});
|
|
172
|
+
if (args.verbose) process.env.VERBOSE = '1';
|
|
167
173
|
intro(`tRPC Upgrade CLI v${version}`);
|
|
168
174
|
if (args.help) {
|
|
169
175
|
log.info(`
|
|
@@ -199,22 +205,21 @@ const transforms = await multiselect({
|
|
|
199
205
|
if (isCancel(transforms)) process.exit(0);
|
|
200
206
|
// Make sure provider transform runs first if it's selected
|
|
201
207
|
const sortedTransforms = transforms.sort((a)=>a.includes('provider') ? -1 : 1);
|
|
202
|
-
const program = getProgram(
|
|
208
|
+
const program = getProgram();
|
|
203
209
|
const sourceFiles = program.getSourceFiles();
|
|
204
210
|
const possibleReferences = findTRPCImportReferences(program);
|
|
205
211
|
const trpcFile = possibleReferences.mostUsed.file;
|
|
206
212
|
const trpcImportName = possibleReferences.importName;
|
|
207
213
|
const commitedFiles = await filterIgnored(sourceFiles);
|
|
208
214
|
for (const transform of sortedTransforms){
|
|
209
|
-
log.
|
|
210
|
-
|
|
211
|
-
const { run } = require('jscodeshift/src/Runner.js');
|
|
215
|
+
log.step(`Running transform: ${basename(transform, extname(transform))}`);
|
|
216
|
+
const { run } = await import('jscodeshift/src/Runner.js');
|
|
212
217
|
await run(transform, commitedFiles, {
|
|
213
218
|
...args,
|
|
214
219
|
trpcFile,
|
|
215
220
|
trpcImportName
|
|
216
221
|
});
|
|
217
|
-
log.
|
|
222
|
+
log.success(`Transform completed`);
|
|
218
223
|
}
|
|
219
224
|
if (!args.skipTanstackQuery) {
|
|
220
225
|
log.info('Installing @trpc/tanstack-react-query');
|
package/package.json
CHANGED
package/src/bin/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { basename, extname } from 'node:path';
|
|
2
3
|
import { parse } from '@bomb.sh/args';
|
|
3
4
|
import { intro, isCancel, log, multiselect, outro } from '@clack/prompts';
|
|
4
5
|
import { version } from '../../package.json';
|
|
@@ -20,6 +21,7 @@ const args = parse(process.argv.slice(2), {
|
|
|
20
21
|
},
|
|
21
22
|
boolean: true,
|
|
22
23
|
});
|
|
24
|
+
if (args.verbose) process.env.VERBOSE = '1';
|
|
23
25
|
|
|
24
26
|
intro(`tRPC Upgrade CLI v${version}`);
|
|
25
27
|
|
|
@@ -66,7 +68,7 @@ const sortedTransforms = transforms.sort((a) =>
|
|
|
66
68
|
a.includes('provider') ? -1 : 1,
|
|
67
69
|
);
|
|
68
70
|
|
|
69
|
-
const program = getProgram(
|
|
71
|
+
const program = getProgram();
|
|
70
72
|
const sourceFiles = program.getSourceFiles();
|
|
71
73
|
const possibleReferences = findTRPCImportReferences(program);
|
|
72
74
|
const trpcFile = possibleReferences.mostUsed.file;
|
|
@@ -75,15 +77,14 @@ const trpcImportName = possibleReferences.importName;
|
|
|
75
77
|
const commitedFiles = await filterIgnored(sourceFiles);
|
|
76
78
|
|
|
77
79
|
for (const transform of sortedTransforms) {
|
|
78
|
-
log.
|
|
79
|
-
|
|
80
|
-
const { run } = require('jscodeshift/src/Runner.js');
|
|
80
|
+
log.step(`Running transform: ${basename(transform, extname(transform))}`);
|
|
81
|
+
const { run } = await import('jscodeshift/src/Runner.js');
|
|
81
82
|
await run(transform, commitedFiles, {
|
|
82
83
|
...args,
|
|
83
84
|
trpcFile,
|
|
84
85
|
trpcImportName,
|
|
85
86
|
});
|
|
86
|
-
log.
|
|
87
|
+
log.success(`Transform completed`);
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
if (!args.skipTanstackQuery) {
|
package/src/lib/ast/scanners.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as p from '@clack/prompts';
|
|
2
2
|
import * as ts from 'typescript';
|
|
3
3
|
|
|
4
|
-
export function getProgram(
|
|
4
|
+
export function getProgram() {
|
|
5
5
|
const configFile = ts.findConfigFile(process.cwd(), (filepath) =>
|
|
6
6
|
ts.sys.fileExists(filepath),
|
|
7
7
|
);
|
|
@@ -10,7 +10,7 @@ export function getProgram(args: Record<string, unknown>) {
|
|
|
10
10
|
process.exit(1);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
if (
|
|
13
|
+
if (process.env.VERBOSE) {
|
|
14
14
|
p.log.info(`Using tsconfig: ${configFile}`);
|
|
15
15
|
}
|
|
16
16
|
|
package/src/lib/pkgmgr.ts
CHANGED
|
@@ -18,7 +18,9 @@ export async function installPackage(packageName: string) {
|
|
|
18
18
|
if (stderr) {
|
|
19
19
|
p.log.error(stderr);
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
if (process.env.VERBOSE) {
|
|
22
|
+
p.log.info(stdout);
|
|
23
|
+
}
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
export async function uninstallPackage(packageName: string) {
|
|
@@ -30,5 +32,7 @@ export async function uninstallPackage(packageName: string) {
|
|
|
30
32
|
if (stderr) {
|
|
31
33
|
p.log.error(stderr);
|
|
32
34
|
}
|
|
33
|
-
|
|
35
|
+
if (process.env.VERBOSE) {
|
|
36
|
+
p.log.info(stdout);
|
|
37
|
+
}
|
|
34
38
|
}
|