Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Commit 899e8d9

Browse files
committed
feat: auto-detect ui path
1 parent f382349 commit 899e8d9

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

src/commands/diff.command.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import { Command } from "@effect/cli"
44
import { HttpClient, HttpClientRequest, HttpClientResponse } from "@effect/platform"
55
import { Console, Effect } from "effect"
66
import { app } from "~/lib/app"
7+
import {
8+
isLaravel,
9+
isNextWithSrc,
10+
isNextWithoutSrc,
11+
isRemix,
12+
} from "~/lib/check-current-user-project"
713

814
const 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

Comments
 (0)