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

Commit f382349

Browse files
committed
add checking project
1 parent eb2b7b4 commit f382349

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

src/commands/diff.command.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ export const diffCommand = Command.make("diff", {}, () =>
7272
const localContent = yield* Effect.tryPromise(() => FS.readFile(file, "utf8"))
7373
const remoteContent = yield* HttpClientRequest.get(remoteUrl).pipe(
7474
client.execute,
75+
// @ts-ignore
7576
Effect.flatMap(HttpClientResponse.text),
7677
Effect.catchAll(() => Effect.succeed("")),
7778
)
7879
if (localContent !== remoteContent) {
80+
// @ts-ignore
7981
diffs.push({ file: relative, diff: simpleDiff(localContent, remoteContent) })
8082
}
8183
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import * as FS from "node:fs/promises"
2+
import * as Path from "node:path"
3+
4+
async function exists(p: string): Promise<boolean> {
5+
try {
6+
await FS.stat(p)
7+
return true
8+
} catch {
9+
return false
10+
}
11+
}
12+
13+
export async function isNextWithSrc(dir: string): Promise<boolean> {
14+
const srcDir = Path.join(dir, "src")
15+
if (!(await exists(srcDir))) return false
16+
const hasPages = await exists(Path.join(srcDir, "pages"))
17+
const hasApp = await exists(Path.join(srcDir, "app"))
18+
return hasPages || hasApp
19+
}
20+
21+
export async function isNextWithoutSrc(dir: string): Promise<boolean> {
22+
if (await exists(Path.join(dir, "src"))) return false
23+
const hasPages = await exists(Path.join(dir, "pages"))
24+
const hasApp = await exists(Path.join(dir, "app"))
25+
return hasPages || hasApp
26+
}
27+
28+
export async function isRemix(dir: string): Promise<boolean> {
29+
const pkgPath = Path.join(dir, "package.json")
30+
if (!(await exists(pkgPath))) return false
31+
const pkg = JSON.parse(await FS.readFile(pkgPath, "utf-8"))
32+
const deps = { ...pkg.dependencies, ...pkg.devDependencies }
33+
if (!deps || !("remix" in deps)) return false
34+
return await exists(Path.join(dir, "app"))
35+
}
36+
37+
export async function isLaravel(dir: string): Promise<boolean> {
38+
const hasArtisan = await exists(Path.join(dir, "artisan"))
39+
const hasComposer = await exists(Path.join(dir, "composer.json"))
40+
return hasArtisan && hasComposer
41+
}

0 commit comments

Comments
 (0)