@@ -4,6 +4,12 @@ import { Command } from "@effect/cli"
44import { HttpClient , HttpClientRequest , HttpClientResponse } from "@effect/platform"
55import { Console , Effect } from "effect"
66import { app } from "~/lib/app"
7+ import {
8+ isLaravel ,
9+ isNextWithSrc ,
10+ isNextWithoutSrc ,
11+ isRemix ,
12+ } from "~/lib/check-current-user-project"
713
814const REMOTE_BASE = app . repo . ui
915
@@ -51,7 +57,21 @@ export const diffCommand = Command.make("diff", {}, () =>
5157 return
5258 }
5359
54- const alias : string = config . aliases ?. ui ?? "components/ui"
60+ let alias : string | undefined = config . aliases ?. ui
61+
62+ if ( ! alias ) {
63+ const nextWithSrc = yield * Effect . tryPromise ( ( ) => isNextWithSrc ( cwd ) )
64+ const nextWithoutSrc = yield * Effect . tryPromise ( ( ) => isNextWithoutSrc ( cwd ) )
65+ const remix = yield * Effect . tryPromise ( ( ) => isRemix ( cwd ) )
66+ const laravel = yield * Effect . tryPromise ( ( ) => isLaravel ( cwd ) )
67+
68+ if ( nextWithSrc ) alias = "src/components/ui"
69+ else if ( nextWithoutSrc ) alias = "components/ui"
70+ else if ( remix ) alias = "app/components/ui"
71+ else if ( laravel ) alias = "resources/components/ui"
72+ else alias = "components/ui"
73+ }
74+
5575 const uiPath = Path . isAbsolute ( alias . replace ( / ^ @ \/ / , "" ) )
5676 ? alias . replace ( / ^ @ \/ / , "" )
5777 : Path . join ( cwd , alias . replace ( / ^ @ \/ / , "" ) )
@@ -72,12 +92,10 @@ export const diffCommand = Command.make("diff", {}, () =>
7292 const localContent = yield * Effect . tryPromise ( ( ) => FS . readFile ( file , "utf8" ) )
7393 const remoteContent = yield * HttpClientRequest . get ( remoteUrl ) . pipe (
7494 client . execute ,
75- // @ts -ignore
7695 Effect . flatMap ( HttpClientResponse . text ) ,
7796 Effect . catchAll ( ( ) => Effect . succeed ( "" ) ) ,
7897 )
7998 if ( localContent !== remoteContent ) {
80- // @ts -ignore
8199 diffs . push ( { file : relative , diff : simpleDiff ( localContent , remoteContent ) } )
82100 }
83101 }
0 commit comments