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

Next #25

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/commands/init.command.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Command } from "@effect/cli"
import { Console, Effect } from "effect"
import { Command as RawCommand, FileSystem } from "@effect/platform"
import { FileSystem, Command as RawCommand } from "@effect/platform"
import { NodeFileSystem } from "@effect/platform-node"
import { Console, Effect } from "effect"

import { REGISTRY_URL } from "~/consts"

Expand Down Expand Up @@ -61,7 +61,6 @@ export const initCommand = Command.make("init", {}, () =>
const patched = lines.join("\n")

yield* fileSytem.writeFileString(cssPath, patched)

}).pipe(
Effect.scoped,
Effect.provide(NodeCommandExecutor.layer),
Expand Down
6 changes: 1 addition & 5 deletions src/commands/login.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ const generateNanoid = Effect.sync(() => nanoid())

const openUrl = (urlToOpen: string) => {
const openCommand =
process.platform === "darwin"
? "open"
: process.platform === "win32"
? "start"
: "xdg-open"
process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open"

return Effect.try({
try: () =>
Expand Down
9 changes: 9 additions & 0 deletions src/lib/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const app = {
repo: {
base: "irsyadadl/intentui",
branch: "2.x",
get ui() {
return `https://raw.githubusercontent.com/${this.base}/${this.branch}/components/ui`
},
},
}
41 changes: 41 additions & 0 deletions src/lib/check-current-user-project.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as FS from "node:fs/promises"
import * as Path from "node:path"

async function exists(p: string): Promise<boolean> {
try {
await FS.stat(p)
return true
} catch {
return false
}
}

export async function isNextWithSrc(dir: string): Promise<boolean> {
const srcDir = Path.join(dir, "src")
if (!(await exists(srcDir))) return false
const hasPages = await exists(Path.join(srcDir, "pages"))
const hasApp = await exists(Path.join(srcDir, "app"))
return hasPages || hasApp
}

export async function isNextWithoutSrc(dir: string): Promise<boolean> {
if (await exists(Path.join(dir, "src"))) return false
const hasPages = await exists(Path.join(dir, "pages"))
const hasApp = await exists(Path.join(dir, "app"))
return hasPages || hasApp
}

export async function isRemix(dir: string): Promise<boolean> {
const pkgPath = Path.join(dir, "package.json")
if (!(await exists(pkgPath))) return false
const pkg = JSON.parse(await FS.readFile(pkgPath, "utf-8"))
const deps = { ...pkg.dependencies, ...pkg.devDependencies }
if (!deps || !("remix" in deps)) return false
return await exists(Path.join(dir, "app"))
}

export async function isLaravel(dir: string): Promise<boolean> {
const hasArtisan = await exists(Path.join(dir, "artisan"))
const hasComposer = await exists(Path.join(dir, "composer.json"))
return hasArtisan && hasComposer
}