@trpc/upgrade 0.0.0-alpha.9 → 11.0.0-alpha-tmp-query-optoins-codemod.673

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/cli.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- var path = require('path');
2
+ var path = require('node:path');
3
3
  var cli$1 = require('@effect/cli');
4
4
  var platform = require('@effect/platform');
5
5
  var platformNode = require('@effect/platform-node');
@@ -10,26 +10,31 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
10
 
11
11
  var path__default = /*#__PURE__*/_interopDefault(path);
12
12
 
13
- var version = "0.0.0-alpha.8";
13
+ var version = "11.0.0-alpha-tmp-query-optoins-codemod.673+594ff39d4";
14
14
 
15
- const assertCleanGitTree = platform.Command.string(platform.Command.workingDirectory(process.cwd())(platform.Command.make('git', 'status'))).pipe(effect.Effect.filterOrFail(effect.String.includes('nothing to commit'), ()=>'Git tree is not clean, please commit your changes and try again, or run with `--force`'));
15
+ const MakeCommand = (command, ...args)=>{
16
+ return platform.Command.make(command, ...args).pipe(platform.Command.workingDirectory(process.cwd()), platform.Command.runInShell(true));
17
+ };
18
+ const assertCleanGitTree = platform.Command.string(MakeCommand('git', 'status')).pipe().pipe(effect.Effect.filterOrFail(effect.String.includes('nothing to commit'), ()=>'Git tree is not clean, please commit your changes and try again, or run with `--force`'));
16
19
  const getPackageManager = ()=>effect.Match.value(process.env.npm_config_user_agent ?? 'npm').pipe(effect.Match.when(effect.String.startsWith('pnpm'), ()=>'pnpm'), effect.Match.when(effect.String.startsWith('yarn'), ()=>'yarn'), effect.Match.when(effect.String.startsWith('bun'), ()=>'bun'), effect.Match.orElse(()=>'npm'));
17
20
  const installPackage = (packageName)=>{
18
21
  const packageManager = getPackageManager();
19
- return platform.Command.streamLines(platform.Command.workingDirectory(process.cwd())(platform.Command.make(packageManager, 'install', packageName))).pipe(effect.Stream.mapEffect(effect.Console.log), effect.Stream.runDrain);
22
+ return platform.Command.streamLines(MakeCommand(packageManager, 'install', packageName)).pipe(effect.Stream.mapEffect(effect.Console.log), effect.Stream.runDrain);
20
23
  };
21
24
  const uninstallPackage = (packageName)=>{
22
25
  const packageManager = getPackageManager();
23
26
  const uninstallCmd = packageManager === 'yarn' ? 'remove' : 'uninstall';
24
- return platform.Command.streamLines(platform.Command.workingDirectory(process.cwd())(platform.Command.make(packageManager, uninstallCmd, packageName))).pipe(effect.Stream.mapEffect(effect.Console.log), effect.Stream.runDrain);
27
+ return platform.Command.streamLines(MakeCommand(packageManager, uninstallCmd, packageName)).pipe(effect.Stream.mapEffect(effect.Console.log), effect.Stream.runDrain);
25
28
  };
26
29
  const filterIgnored = (files)=>effect.Effect.gen(function*() {
27
- const ignores = yield* platform.Command.string(platform.Command.workingDirectory(process.cwd())(platform.Command.make('git', 'check-ignore', '**/*'))).pipe(effect.Effect.tap(effect.Effect.log), effect.Effect.map((_)=>_.split('\n')));
30
+ const ignores = yield* platform.Command.string(MakeCommand('git', 'check-ignore', '**/*').pipe(platform.Command.runInShell(true))).pipe(effect.Effect.tap((_)=>effect.Effect.logDebug('Ignored files output:', _)), effect.Effect.map((_)=>_.split('\n')));
31
+ yield* effect.Effect.logDebug('cwd:', process.cwd());
28
32
  yield* effect.Effect.logDebug('All files in program:', files.map((_)=>_.fileName));
29
33
  yield* effect.Effect.logDebug('Ignored files:', ignores);
30
34
  // Ignore "common files"
31
35
  const filteredSourcePaths = files.filter((source)=>source.fileName.startsWith(path__default.default.resolve()) && // only look ahead of current directory
32
36
  !source.fileName.includes('/trpc/packages/') && // relative paths when running codemod locally
37
+ !source.fileName.includes('/node_modules/') && // always ignore node_modules
33
38
  !ignores.includes(source.fileName)).map((source)=>source.fileName);
34
39
  yield* effect.Effect.logDebug('Filtered files:', filteredSourcePaths);
35
40
  return filteredSourcePaths;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/upgrade",
3
- "version": "0.0.0-alpha.9",
3
+ "version": "11.0.0-alpha-tmp-query-optoins-codemod.673+594ff39d4",
4
4
  "description": "Upgrade scripts for tRPC",
5
5
  "author": "juliusmarminge",
6
6
  "license": "MIT",
@@ -19,6 +19,10 @@
19
19
  "require": "./dist/transforms/provider.cjs"
20
20
  }
21
21
  },
22
+ "scripts": {
23
+ "build": "bunchee",
24
+ "run": "tsx src/cli.ts"
25
+ },
22
26
  "files": [
23
27
  "dist",
24
28
  "src",
@@ -48,8 +52,5 @@
48
52
  "funding": [
49
53
  "https://trpc.io/sponsor"
50
54
  ],
51
- "scripts": {
52
- "build": "bunchee",
53
- "run": "tsx src/cli.ts"
54
- }
55
- }
55
+ "gitHead": "594ff39d43af4f6b6460549476ffcaddcd244dfd"
56
+ }
package/src/bin/cli.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/unbound-method */
2
- import path from 'path';
2
+ import path from 'node:path';
3
3
  import { Command as CLICommand, Options, Prompt } from '@effect/cli';
4
4
  import { Command } from '@effect/platform';
5
5
  import { NodeContext, NodeRuntime } from '@effect/platform-node';
@@ -26,15 +26,22 @@ import {
26
26
  } from 'typescript';
27
27
  import { version } from '../../package.json';
28
28
 
29
- const assertCleanGitTree = Command.string(
30
- Command.workingDirectory(process.cwd())(Command.make('git', 'status')),
31
- ).pipe(
32
- Effect.filterOrFail(
33
- String.includes('nothing to commit'),
34
- () =>
35
- 'Git tree is not clean, please commit your changes and try again, or run with `--force`',
36
- ),
37
- );
29
+ const MakeCommand = (command: string, ...args: string[]) => {
30
+ return Command.make(command, ...args).pipe(
31
+ Command.workingDirectory(process.cwd()),
32
+ Command.runInShell(true),
33
+ );
34
+ };
35
+
36
+ const assertCleanGitTree = Command.string(MakeCommand('git', 'status'))
37
+ .pipe()
38
+ .pipe(
39
+ Effect.filterOrFail(
40
+ String.includes('nothing to commit'),
41
+ () =>
42
+ 'Git tree is not clean, please commit your changes and try again, or run with `--force`',
43
+ ),
44
+ );
38
45
  const getPackageManager = () =>
39
46
  Match.value(process.env.npm_config_user_agent ?? 'npm').pipe(
40
47
  Match.when(String.startsWith('pnpm'), () => 'pnpm'),
@@ -46,9 +53,7 @@ const getPackageManager = () =>
46
53
  const installPackage = (packageName: string) => {
47
54
  const packageManager = getPackageManager();
48
55
  return Command.streamLines(
49
- Command.workingDirectory(process.cwd())(
50
- Command.make(packageManager, 'install', packageName),
51
- ),
56
+ MakeCommand(packageManager, 'install', packageName),
52
57
  ).pipe(Stream.mapEffect(Console.log), Stream.runDrain);
53
58
  };
54
59
 
@@ -56,23 +61,21 @@ const uninstallPackage = (packageName: string) => {
56
61
  const packageManager = getPackageManager();
57
62
  const uninstallCmd = packageManager === 'yarn' ? 'remove' : 'uninstall';
58
63
  return Command.streamLines(
59
- Command.workingDirectory(process.cwd())(
60
- Command.make(packageManager, uninstallCmd, packageName),
61
- ),
64
+ MakeCommand(packageManager, uninstallCmd, packageName),
62
65
  ).pipe(Stream.mapEffect(Console.log), Stream.runDrain);
63
66
  };
64
67
 
65
68
  const filterIgnored = (files: readonly SourceFile[]) =>
66
69
  Effect.gen(function* () {
67
70
  const ignores = yield* Command.string(
68
- Command.workingDirectory(process.cwd())(
69
- Command.make('git', 'check-ignore', '**/*'),
70
- ),
71
+ MakeCommand('git', 'check-ignore', '**/*').pipe(Command.runInShell(true)),
71
72
  ).pipe(
72
- Effect.tap(Effect.log),
73
+ Effect.tap((_) => Effect.logDebug('Ignored files output:', _)),
73
74
  Effect.map((_) => _.split('\n')),
74
75
  );
75
76
 
77
+ yield* Effect.logDebug('cwd:', process.cwd());
78
+
76
79
  yield* Effect.logDebug(
77
80
  'All files in program:',
78
81
  files.map((_) => _.fileName),
@@ -85,6 +88,7 @@ const filterIgnored = (files: readonly SourceFile[]) =>
85
88
  (source) =>
86
89
  source.fileName.startsWith(path.resolve()) && // only look ahead of current directory
87
90
  !source.fileName.includes('/trpc/packages/') && // relative paths when running codemod locally
91
+ !source.fileName.includes('/node_modules/') && // always ignore node_modules
88
92
  !ignores.includes(source.fileName), // ignored files
89
93
  )
90
94
  .map((source) => source.fileName);