clawnify 0.4.0 → 0.5.0
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/{chunk-UUTFIFKJ.js → chunk-3HQ3VZOS.js} +26 -9
- package/dist/chunk-3HQ3VZOS.js.map +1 -0
- package/dist/{cli-5KZ7W67B.js → cli-XYGLEX6Q.js} +115 -53
- package/dist/cli-XYGLEX6Q.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/{mcp-W3X7BY7G.js → mcp-3XFY2UOF.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-UUTFIFKJ.js.map +0 -1
- package/dist/cli-5KZ7W67B.js.map +0 -1
- /package/dist/{mcp-W3X7BY7G.js.map → mcp-3XFY2UOF.js.map} +0 -0
|
@@ -258,29 +258,46 @@ function createTarHeader(filename, size) {
|
|
|
258
258
|
header.write(checksum.toString(8).padStart(6, "0") + "\0 ", 148, 8, "utf-8");
|
|
259
259
|
return header;
|
|
260
260
|
}
|
|
261
|
+
function collectDrizzleMigrations(dir) {
|
|
262
|
+
const drizzleDir = path2.join(dir, ".clawnify", "drizzle");
|
|
263
|
+
if (!fs2.existsSync(drizzleDir)) return [];
|
|
264
|
+
try {
|
|
265
|
+
return fs2.readdirSync(drizzleDir).filter((name) => name.endsWith(".sql")).sort().map((name) => ({
|
|
266
|
+
src: path2.join(drizzleDir, name),
|
|
267
|
+
tarName: `drizzle/${name}`
|
|
268
|
+
}));
|
|
269
|
+
} catch {
|
|
270
|
+
return [];
|
|
271
|
+
}
|
|
272
|
+
}
|
|
261
273
|
function createArchive(dir) {
|
|
262
274
|
const files = listFiles(dir);
|
|
263
275
|
const parts = [];
|
|
264
276
|
const includedFiles = [];
|
|
265
|
-
|
|
266
|
-
const fullPath = path2.join(dir, file);
|
|
277
|
+
function addEntry(absPath, tarName) {
|
|
267
278
|
let stat;
|
|
268
279
|
try {
|
|
269
|
-
stat = fs2.statSync(
|
|
280
|
+
stat = fs2.statSync(absPath);
|
|
270
281
|
} catch {
|
|
271
|
-
|
|
282
|
+
return;
|
|
272
283
|
}
|
|
273
|
-
if (!stat.isFile())
|
|
274
|
-
const content = fs2.readFileSync(
|
|
275
|
-
const header = createTarHeader(
|
|
284
|
+
if (!stat.isFile()) return;
|
|
285
|
+
const content = fs2.readFileSync(absPath);
|
|
286
|
+
const header = createTarHeader(tarName, content.length);
|
|
276
287
|
parts.push(header);
|
|
277
288
|
parts.push(content);
|
|
278
|
-
includedFiles.push(
|
|
289
|
+
includedFiles.push(tarName);
|
|
279
290
|
const remainder = content.length % 512;
|
|
280
291
|
if (remainder > 0) {
|
|
281
292
|
parts.push(Buffer.alloc(512 - remainder));
|
|
282
293
|
}
|
|
283
294
|
}
|
|
295
|
+
for (const file of files) {
|
|
296
|
+
addEntry(path2.join(dir, file), file);
|
|
297
|
+
}
|
|
298
|
+
for (const m of collectDrizzleMigrations(dir)) {
|
|
299
|
+
addEntry(m.src, m.tarName);
|
|
300
|
+
}
|
|
284
301
|
parts.push(Buffer.alloc(1024));
|
|
285
302
|
const tar = Buffer.concat(parts);
|
|
286
303
|
const gzipped = gzipSync(tar);
|
|
@@ -397,4 +414,4 @@ export {
|
|
|
397
414
|
saveProject,
|
|
398
415
|
pollUntilReady
|
|
399
416
|
};
|
|
400
|
-
//# sourceMappingURL=chunk-
|
|
417
|
+
//# sourceMappingURL=chunk-3HQ3VZOS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/auth.ts","../src/lib/api.ts","../src/lib/archive.ts","../src/lib/config.ts","../src/lib/poll.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport crypto from \"node:crypto\";\nimport { homedir } from \"node:os\";\n\nconst SUPABASE_URL = \"https://auth.clawnify.com\";\nconst SUPABASE_ANON_KEY =\n \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imh0a3l4Zm1pbXlkeG5iemd4aGZ6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzgzNDk5MjEsImV4cCI6MjA1MzkyNTkyMX0.wopxB_gQSbNMPuxLUNK0BrGXE_0JxJqzMYFPeXFV1GE\";\nexport const OAUTH_CLIENT_ID = \"3defc0e6-80de-4e7a-aa36-0b501c06b697\";\nexport const OAUTH_AUTHORIZE_URL = `${SUPABASE_URL}/auth/v1/oauth/authorize`;\nexport const OAUTH_TOKEN_URL = `${SUPABASE_URL}/auth/v1/oauth/token`;\n\nconst AUTH_DIR = path.join(homedir(), \".clawnify\");\nconst AUTH_FILE = path.join(AUTH_DIR, \"auth.json\");\n\nexport interface AuthData {\n access_token: string;\n refresh_token: string;\n expires_at: number;\n org_id?: string;\n}\n\nexport function loadAuth(): AuthData | null {\n try {\n const data = fs.readFileSync(AUTH_FILE, \"utf-8\");\n return JSON.parse(data) as AuthData;\n } catch {\n return null;\n }\n}\n\nexport function saveAuth(data: AuthData): void {\n fs.mkdirSync(AUTH_DIR, { recursive: true, mode: 0o700 });\n fs.writeFileSync(AUTH_FILE, JSON.stringify(data, null, 2), { mode: 0o600 });\n}\n\nexport function clearAuth(): void {\n try {\n fs.unlinkSync(AUTH_FILE);\n } catch {\n // ignore if not exists\n }\n}\n\nexport async function getValidToken(): Promise<string | null> {\n const auth = loadAuth();\n if (!auth) return null;\n\n const now = Math.floor(Date.now() / 1000);\n if (auth.expires_at - 60 > now) {\n return auth.access_token;\n }\n\n // Token expired, refresh via OAuth token endpoint\n const res = await fetch(OAUTH_TOKEN_URL, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n body: new URLSearchParams({\n grant_type: \"refresh_token\",\n refresh_token: auth.refresh_token,\n client_id: OAUTH_CLIENT_ID,\n }),\n });\n\n if (!res.ok) {\n clearAuth();\n return null;\n }\n\n const tokens = (await res.json()) as {\n access_token: string;\n refresh_token: string;\n expires_in: number;\n };\n\n const newAuth: AuthData = {\n ...auth,\n access_token: tokens.access_token,\n refresh_token: tokens.refresh_token,\n expires_at: Math.floor(Date.now() / 1000) + tokens.expires_in,\n };\n\n saveAuth(newAuth);\n return tokens.access_token;\n}\n\nexport async function requireAuth(): Promise<AuthData> {\n const token = await getValidToken();\n if (!token) {\n console.error(\"Not logged in. Run `clawnify login` first.\");\n process.exit(1);\n }\n return loadAuth()!;\n}\n\n/** Parse email from Supabase JWT claims (base64url-decoded payload) */\nexport function getEmailFromToken(token: string): string | null {\n try {\n const payload = token.split(\".\")[1]!;\n const decoded = JSON.parse(\n Buffer.from(payload, \"base64url\").toString(\"utf-8\")\n );\n return decoded.email ?? null;\n } catch {\n return null;\n }\n}\n\n/** Generate PKCE code_verifier and code_challenge */\nexport function generatePkce(): {\n codeVerifier: string;\n codeChallenge: string;\n} {\n const codeVerifier = crypto.randomBytes(32).toString(\"base64url\");\n const codeChallenge = crypto\n .createHash(\"sha256\")\n .update(codeVerifier)\n .digest(\"base64url\");\n return { codeVerifier, codeChallenge };\n}\n","import { requireAuth, loadAuth, saveAuth, type AuthData } from \"./auth.js\";\nimport readline from \"node:readline\";\n\nconst API_BASE = \"https://provision.clawnify.com\";\n\nasync function apiRequest(\n method: string,\n path: string,\n options?: {\n body?: unknown;\n formData?: FormData;\n token?: string;\n orgId?: string;\n }\n): Promise<Response> {\n const headers: Record<string, string> = {};\n\n if (options?.token) {\n headers[\"Authorization\"] = `Bearer ${options.token}`;\n }\n if (options?.orgId) {\n headers[\"x-org-id\"] = options.orgId;\n }\n\n let body: BodyInit | undefined;\n if (options?.formData) {\n body = options.formData;\n } else if (options?.body) {\n headers[\"Content-Type\"] = \"application/json\";\n body = JSON.stringify(options.body);\n }\n\n const res = await fetch(`${API_BASE}${path}`, { method, headers, body });\n\n if (res.status === 401) {\n console.error(\"Session expired. Run `clawnify login` again.\");\n process.exit(1);\n }\n\n return res;\n}\n\nasync function ensureOrg(auth: AuthData): Promise<AuthData> {\n if (auth.org_id) return auth;\n\n // Fetch orgs and prompt\n const orgsRes = await apiRequest(\"GET\", \"/v1/orgs\", { token: auth.access_token });\n if (!orgsRes.ok) return auth;\n\n const { orgs } = (await orgsRes.json()) as {\n orgs: Array<{ id: string; name: string; slug: string; role: string }>;\n };\n\n if (orgs.length === 0) return auth;\n\n let orgId: string;\n if (orgs.length === 1) {\n orgId = orgs[0].id;\n } else {\n console.log(\"\\nSelect an organization:\\n\");\n orgs.forEach((org, i) => {\n console.log(` ${i + 1}) ${org.name} (${org.role})`);\n });\n console.log();\n\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n const choice = await new Promise<string>((resolve) => {\n rl.question(\"Enter number: \", (answer) => {\n rl.close();\n resolve(answer.trim());\n });\n });\n\n const index = parseInt(choice, 10) - 1;\n orgId = (index >= 0 && index < orgs.length) ? orgs[index].id : orgs[0].id;\n console.log(`Selected: ${orgs[index >= 0 && index < orgs.length ? index : 0].name}\\n`);\n }\n\n const updated = { ...auth, org_id: orgId };\n saveAuth(updated);\n return updated;\n}\n\nasync function authedRequest(\n method: string,\n path: string,\n options?: { body?: unknown; formData?: FormData; orgId?: string }\n): Promise<Response> {\n let auth = await requireAuth();\n let orgId = options?.orgId;\n if (!orgId) {\n auth = await ensureOrg(auth);\n orgId = auth.org_id;\n }\n return apiRequest(method, path, {\n ...options,\n token: auth.access_token,\n orgId,\n });\n}\n\nexport interface Org {\n id: string;\n name: string;\n slug: string;\n role: string;\n}\n\n/** List every org the authenticated user belongs to, bypassing org selection. */\nexport async function listMyOrgs(): Promise<Org[]> {\n const auth = await requireAuth();\n const res = await apiRequest(\"GET\", \"/v1/orgs\", { token: auth.access_token });\n if (!res.ok) return [];\n const { orgs } = (await res.json()) as { orgs: Org[] };\n return orgs ?? [];\n}\n\nexport const api = {\n get: (path: string, opts?: { orgId?: string }) =>\n authedRequest(\"GET\", path, opts),\n post: (path: string, body?: unknown, opts?: { orgId?: string }) =>\n authedRequest(\"POST\", path, { body, ...opts }),\n postForm: (path: string, formData: FormData, opts?: { orgId?: string }) =>\n authedRequest(\"POST\", path, { formData, ...opts }),\n del: (path: string, opts?: { orgId?: string }) =>\n authedRequest(\"DELETE\", path, opts),\n request: apiRequest,\n};\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { execSync } from \"node:child_process\";\nimport { gzipSync } from \"node:zlib\";\n\nconst EXCLUDE_DIRS = new Set([\n \"node_modules\",\n \".git\",\n \"dist\",\n \".next\",\n \".clawnify\",\n \"build\",\n]);\n\nconst MAX_SIZE = 20 * 1024 * 1024; // 20MB\n\nfunction runGit(args: string[], dir: string): string | null {\n try {\n return execSync(`git ${args.join(\" \")}`, {\n cwd: dir,\n encoding: \"utf-8\",\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n });\n } catch {\n return null;\n }\n}\n\n/**\n * Collect every file `git add .` would stage: tracked files plus untracked\n * files that aren't ignored. Returns null if the directory isn't a git repo,\n * so the caller falls back to walkDir.\n *\n * The previous implementation used only `git ls-files`, which silently\n * excluded brand-new untracked files — a common foot-gun when an agent\n * (or human) creates a file but forgets to `git add` it.\n */\nfunction getGitFiles(dir: string): string[] | null {\n const tracked = runGit([\"ls-files\", \"-z\"], dir);\n if (tracked === null) return null;\n const untracked = runGit([\"ls-files\", \"-z\", \"--others\", \"--exclude-standard\"], dir) ?? \"\";\n const merged = new Set<string>();\n for (const f of tracked.split(\"\\0\")) if (f) merged.add(f);\n for (const f of untracked.split(\"\\0\")) if (f) merged.add(f);\n return [...merged];\n}\n\nfunction walkDir(dir: string, base: string = \"\"): string[] {\n const files: string[] = [];\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (EXCLUDE_DIRS.has(entry.name)) continue;\n const rel = base ? `${base}/${entry.name}` : entry.name;\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n files.push(...walkDir(full, rel));\n } else if (entry.isFile()) {\n files.push(rel);\n }\n }\n return files;\n}\n\n/**\n * A repo-root `manifest.json` is not part of the clawnify contract\n * (clawnify.json is). Some templates leave a Preact-style manifest behind;\n * users see \"manifest\" and assume it controls something. Warn so they know\n * it's being uploaded as a dumb file.\n */\nfunction warnOnStaleManifest(dir: string, files: string[]) {\n if (!files.includes(\"manifest.json\")) return;\n try {\n const raw = fs.readFileSync(path.join(dir, \"manifest.json\"), \"utf-8\");\n const parsed = JSON.parse(raw) as Record<string, unknown>;\n if (parsed && typeof parsed === \"object\" && \"framework\" in parsed && \"files\" in parsed) {\n console.warn(\n ` warning: manifest.json looks like a stale auto-generated file. ` +\n `Clawnify uses clawnify.json — manifest.json is ignored.`,\n );\n }\n } catch {\n // not JSON, not our concern\n }\n}\n\nfunction listFiles(dir: string): string[] {\n const fromGit = getGitFiles(dir);\n const files = fromGit ?? walkDir(dir);\n warnOnStaleManifest(dir, files);\n return files;\n}\n\n/** Public helper for `clawnify deploy --dry-run`. */\nexport function listArchiveFiles(dir: string): string[] {\n return listFiles(dir);\n}\n\nfunction createTarHeader(filename: string, size: number): Buffer {\n const header = Buffer.alloc(512);\n header.write(filename, 0, Math.min(filename.length, 100), \"utf-8\");\n header.write(\"0000644\\0\", 100, 8, \"utf-8\");\n header.write(\"0000000\\0\", 108, 8, \"utf-8\");\n header.write(\"0000000\\0\", 116, 8, \"utf-8\");\n header.write(size.toString(8).padStart(11, \"0\") + \"\\0\", 124, 12, \"utf-8\");\n const mtime = Math.floor(Date.now() / 1000);\n header.write(mtime.toString(8).padStart(11, \"0\") + \"\\0\", 136, 12, \"utf-8\");\n header.write(\"0\", 156, 1, \"utf-8\");\n header.write(\"ustar\\0\", 257, 6, \"utf-8\");\n header.write(\"00\", 263, 2, \"utf-8\");\n header.write(\" \", 148, 8, \"utf-8\");\n let checksum = 0;\n for (let i = 0; i < 512; i++) {\n checksum += header[i]!;\n }\n header.write(checksum.toString(8).padStart(6, \"0\") + \"\\0 \", 148, 8, \"utf-8\");\n return header;\n}\n\n/**\n * Drizzle migrations live under `.clawnify/drizzle/<NNNN>_<name>.sql`\n * locally (gitignored, regenerated by the CLI on dev/deploy). The\n * deploy pipeline (PR #444) scans R2's `drizzle/` prefix on each\n * deploy. We remap on upload — the user's repo stays clean, the\n * pipeline contract is unchanged.\n *\n * Only top-level `*.sql` files come along; drizzle's `meta/` snapshot\n * dir is local-only state.\n */\nfunction collectDrizzleMigrations(\n dir: string,\n): { src: string; tarName: string }[] {\n const drizzleDir = path.join(dir, \".clawnify\", \"drizzle\");\n if (!fs.existsSync(drizzleDir)) return [];\n try {\n return fs\n .readdirSync(drizzleDir)\n .filter((name) => name.endsWith(\".sql\"))\n .sort()\n .map((name) => ({\n src: path.join(drizzleDir, name),\n tarName: `drizzle/${name}`,\n }));\n } catch {\n return [];\n }\n}\n\nexport function createArchive(dir: string): { archive: Buffer; files: string[] } {\n const files = listFiles(dir);\n const parts: Buffer[] = [];\n const includedFiles: string[] = [];\n\n function addEntry(absPath: string, tarName: string): void {\n let stat: fs.Stats;\n try {\n stat = fs.statSync(absPath);\n } catch {\n return;\n }\n if (!stat.isFile()) return;\n\n const content = fs.readFileSync(absPath);\n const header = createTarHeader(tarName, content.length);\n parts.push(header);\n parts.push(content);\n includedFiles.push(tarName);\n\n const remainder = content.length % 512;\n if (remainder > 0) {\n parts.push(Buffer.alloc(512 - remainder));\n }\n }\n\n for (const file of files) {\n addEntry(path.join(dir, file), file);\n }\n\n for (const m of collectDrizzleMigrations(dir)) {\n addEntry(m.src, m.tarName);\n }\n\n parts.push(Buffer.alloc(1024));\n\n const tar = Buffer.concat(parts);\n const gzipped = gzipSync(tar);\n\n if (gzipped.length > MAX_SIZE) {\n throw new Error(\n `Archive too large (${(gzipped.length / 1024 / 1024).toFixed(1)}MB). Maximum is 20MB.`,\n );\n }\n\n return { archive: gzipped, files: includedFiles };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\n\nexport interface ClawnifyAppConfig {\n framework: string;\n database?: boolean;\n storage?: boolean;\n}\n\nexport interface ClawnifyWebsiteConfig {\n framework: string;\n}\n\nexport interface ClawnifyManifest {\n name: string;\n description?: string;\n app?: ClawnifyAppConfig;\n website?: ClawnifyWebsiteConfig;\n}\n\nexport type ManifestKind = \"app\" | \"website\";\n\nexport interface ProjectConfig {\n kind?: ManifestKind;\n org_id?: string;\n app_id?: string;\n app_token?: string;\n website_id?: string;\n slug?: string;\n}\n\nexport function readManifest(dir: string = process.cwd()): ClawnifyManifest | null {\n try {\n const data = fs.readFileSync(path.join(dir, \"clawnify.json\"), \"utf-8\");\n const manifest = JSON.parse(data) as ClawnifyManifest;\n if (!manifest.name) return null;\n if (!manifest.app && !manifest.website) return null;\n return manifest;\n } catch {\n return null;\n }\n}\n\n/**\n * Returns the manifest kind, or throws with a clear message when neither or\n * both blocks are present. Callers should run this before dispatching deploy.\n */\nexport function manifestKind(manifest: ClawnifyManifest): ManifestKind {\n const hasApp = Boolean(manifest.app);\n const hasWebsite = Boolean(manifest.website);\n if (hasApp && hasWebsite) {\n throw new Error(\n \"clawnify.json declares both `app` and `website` — pick one (a project is either an app or a website, not both).\",\n );\n }\n if (!hasApp && !hasWebsite) {\n throw new Error(\n \"clawnify.json must declare either an `app` or a `website` block.\",\n );\n }\n return hasApp ? \"app\" : \"website\";\n}\n\nexport function readProject(dir: string = process.cwd()): ProjectConfig | null {\n try {\n const data = fs.readFileSync(\n path.join(dir, \".clawnify\", \"project.json\"),\n \"utf-8\"\n );\n return JSON.parse(data) as ProjectConfig;\n } catch {\n return null;\n }\n}\n\nexport function saveProject(dir: string, data: ProjectConfig): void {\n const projDir = path.join(dir, \".clawnify\");\n fs.mkdirSync(projDir, { recursive: true });\n fs.writeFileSync(\n path.join(projDir, \"project.json\"),\n JSON.stringify(data, null, 2)\n );\n}\n","import { api } from \"./api.js\";\n\nconst SPINNER_FRAMES = [\"⠋\", \"⠙\", \"⠹\", \"⠸\", \"⠼\", \"⠴\", \"⠦\", \"⠧\", \"⠇\", \"⠏\"];\n\nexport interface AppStatus {\n status: string;\n status_message?: string;\n url?: string;\n error?: string;\n}\n\n// Status values that mean we're done — apps use \"live\"/\"error\", websites\n// use \"live\"/\"failed\". Pollers stop on any of these.\nconst TERMINAL_STATUSES = new Set([\"live\", \"ready\", \"error\", \"failed\"]);\nconst FAILURE_STATUSES = new Set([\"error\", \"failed\"]);\n\nexport async function pollUntilReady(\n resourceId: string,\n options: {\n interval?: number;\n timeout?: number;\n kind?: \"app\" | \"website\";\n orgId?: string;\n } = {},\n): Promise<AppStatus> {\n const interval = options.interval ?? 3000;\n const timeout = options.timeout ?? 300000;\n const kind = options.kind ?? \"app\";\n const basePath = kind === \"website\" ? \"/v1/websites\" : \"/v1/apps\";\n const start = Date.now();\n let frame = 0;\n const isTTY = Boolean(process.stdout.isTTY);\n let lastMessage = \"\";\n\n while (Date.now() - start < timeout) {\n const res = await api.get(`${basePath}/${resourceId}`, { orgId: options.orgId });\n const data = (await res.json()) as AppStatus;\n const message = data.status_message || data.status;\n\n if (isTTY) {\n const spinner = SPINNER_FRAMES[frame % SPINNER_FRAMES.length];\n process.stdout.write(`\\r${spinner} ${message}`);\n } else if (message !== lastMessage) {\n // Non-TTY (CI logs, background tasks): write whole lines so the\n // output survives in pipes and files instead of being mangled by\n // cursor escapes from the spinner.\n console.log(`status: ${message}`);\n lastMessage = message;\n }\n frame++;\n\n if (TERMINAL_STATUSES.has(data.status)) {\n if (isTTY) process.stdout.write(\"\\r\\x1b[K\");\n // Normalize \"failed\" to \"error\" so downstream callers only branch\n // on one terminal-failure value.\n if (FAILURE_STATUSES.has(data.status)) {\n return { ...data, status: \"error\" };\n }\n return data;\n }\n\n await new Promise((r) => setTimeout(r, interval));\n }\n\n if (isTTY) process.stdout.write(\"\\r\\x1b[K\");\n throw new Error(\"Timed out waiting for deployment\");\n}\n"],"mappings":";;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,YAAY;AACnB,SAAS,eAAe;AAExB,IAAM,eAAe;AAGd,IAAM,kBAAkB;AACxB,IAAM,sBAAsB,GAAG,YAAY;AAC3C,IAAM,kBAAkB,GAAG,YAAY;AAE9C,IAAM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
18
18
|
saveProject
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-3HQ3VZOS.js";
|
|
20
20
|
|
|
21
21
|
// src/cli.ts
|
|
22
22
|
import { Command } from "commander";
|
|
@@ -171,8 +171,10 @@ async function loginCommand() {
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
// src/commands/deploy.ts
|
|
174
|
+
import fs2 from "fs";
|
|
174
175
|
import path2 from "path";
|
|
175
176
|
import readline2 from "readline";
|
|
177
|
+
import { spawn } from "child_process";
|
|
176
178
|
|
|
177
179
|
// src/lib/sync-schema.ts
|
|
178
180
|
import fs from "fs/promises";
|
|
@@ -532,6 +534,7 @@ async function deployCommand(dir, options = {}) {
|
|
|
532
534
|
const baseName = options.name || manifest?.name || path2.basename(resolvedDir);
|
|
533
535
|
const framework = manifest?.app?.framework || "vite-preact";
|
|
534
536
|
const linkedProject = readProject(resolvedDir);
|
|
537
|
+
await regenerateDrizzleMigrations(resolvedDir);
|
|
535
538
|
const { archive, files } = createArchive(resolvedDir);
|
|
536
539
|
const orgId = await resolveOrgId(options, linkedProject);
|
|
537
540
|
if (options.dryRun) {
|
|
@@ -643,6 +646,31 @@ async function deployCommand(dir, options = {}) {
|
|
|
643
646
|
}
|
|
644
647
|
}
|
|
645
648
|
}
|
|
649
|
+
async function regenerateDrizzleMigrations(resolvedDir) {
|
|
650
|
+
const schemaTs = path2.join(resolvedDir, "src/server/schema.ts");
|
|
651
|
+
const drizzleConfig = path2.join(resolvedDir, "drizzle.config.ts");
|
|
652
|
+
if (!fs2.existsSync(schemaTs) || !fs2.existsSync(drizzleConfig)) return;
|
|
653
|
+
await new Promise((resolve) => {
|
|
654
|
+
const proc = spawn("npx", ["drizzle-kit", "generate"], {
|
|
655
|
+
cwd: resolvedDir,
|
|
656
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
657
|
+
env: { ...process.env }
|
|
658
|
+
});
|
|
659
|
+
let stderr = "";
|
|
660
|
+
proc.stderr?.on("data", (d) => {
|
|
661
|
+
stderr += d.toString();
|
|
662
|
+
});
|
|
663
|
+
proc.on("exit", (code) => {
|
|
664
|
+
if (code !== 0) {
|
|
665
|
+
console.warn(
|
|
666
|
+
` warning: drizzle-kit generate failed (${stderr.trim().slice(0, 200)}). Continuing with existing .clawnify/drizzle/ contents.`
|
|
667
|
+
);
|
|
668
|
+
}
|
|
669
|
+
resolve();
|
|
670
|
+
});
|
|
671
|
+
proc.on("error", () => resolve());
|
|
672
|
+
});
|
|
673
|
+
}
|
|
646
674
|
|
|
647
675
|
// src/commands/ls.ts
|
|
648
676
|
async function lsCommand() {
|
|
@@ -761,7 +789,7 @@ async function whoamiCommand() {
|
|
|
761
789
|
}
|
|
762
790
|
|
|
763
791
|
// src/commands/init.ts
|
|
764
|
-
import
|
|
792
|
+
import fs3 from "fs";
|
|
765
793
|
import path3 from "path";
|
|
766
794
|
import readline4 from "readline";
|
|
767
795
|
function ask2(question) {
|
|
@@ -828,13 +856,12 @@ async function initApp(dir, opts) {
|
|
|
828
856
|
const templateChoice = await ask2("Template [1]: ") || "1";
|
|
829
857
|
template = templateChoice === "2" ? "crud" : "blank";
|
|
830
858
|
}
|
|
831
|
-
if (
|
|
859
|
+
if (fs3.existsSync(targetDir) && fs3.readdirSync(targetDir).length > 0) {
|
|
832
860
|
console.error(`Directory ${targetDir} is not empty.`);
|
|
833
861
|
process.exit(1);
|
|
834
862
|
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
fs2.mkdirSync(path3.join(targetDir, "drizzle"), { recursive: true });
|
|
863
|
+
fs3.mkdirSync(path3.join(targetDir, "src/server"), { recursive: true });
|
|
864
|
+
fs3.mkdirSync(path3.join(targetDir, "src/client"), { recursive: true });
|
|
838
865
|
let storage;
|
|
839
866
|
if (opts?.storage !== void 0) {
|
|
840
867
|
storage = opts.storage;
|
|
@@ -870,11 +897,10 @@ async function initApp(dir, opts) {
|
|
|
870
897
|
scripts: {
|
|
871
898
|
dev: "clawnify dev",
|
|
872
899
|
build: "vite build",
|
|
873
|
-
deploy: "clawnify deploy"
|
|
874
|
-
"db:generate": "drizzle-kit generate"
|
|
900
|
+
deploy: "clawnify deploy"
|
|
875
901
|
},
|
|
876
902
|
dependencies: {
|
|
877
|
-
"@clawnify/db": "^0.4.
|
|
903
|
+
"@clawnify/db": "^0.4.1",
|
|
878
904
|
"@hono/zod-openapi": "^0.19.0",
|
|
879
905
|
hono: "^4.0.0",
|
|
880
906
|
react: "^19.0.0",
|
|
@@ -966,15 +992,9 @@ export const items = sqliteTable("items", {
|
|
|
966
992
|
|
|
967
993
|
export default defineConfig({
|
|
968
994
|
schema: "./src/server/schema.ts",
|
|
969
|
-
out: "
|
|
995
|
+
out: "./.clawnify/drizzle",
|
|
970
996
|
dialect: "sqlite",
|
|
971
997
|
});
|
|
972
|
-
`);
|
|
973
|
-
write(targetDir, "drizzle/0000_init.sql", `CREATE TABLE \`items\` (
|
|
974
|
-
\`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
975
|
-
\`name\` text NOT NULL,
|
|
976
|
-
\`created_at\` text NOT NULL
|
|
977
|
-
);
|
|
978
998
|
`);
|
|
979
999
|
if (storage) {
|
|
980
1000
|
write(targetDir, "src/server/index.ts", `import { OpenAPIHono } from "@hono/zod-openapi";
|
|
@@ -1091,11 +1111,11 @@ async function initWebsite(dir, opts) {
|
|
|
1091
1111
|
const name = opts?.name || await ask2("Site name: ") || "my-site";
|
|
1092
1112
|
const slug = slugify(name);
|
|
1093
1113
|
const targetDir = dir ? path3.resolve(dir) : path3.resolve(slug);
|
|
1094
|
-
if (
|
|
1114
|
+
if (fs3.existsSync(targetDir) && fs3.readdirSync(targetDir).length > 0) {
|
|
1095
1115
|
console.error(`Directory ${targetDir} is not empty.`);
|
|
1096
1116
|
process.exit(1);
|
|
1097
1117
|
}
|
|
1098
|
-
|
|
1118
|
+
fs3.mkdirSync(targetDir, { recursive: true });
|
|
1099
1119
|
write(targetDir, "clawnify.json", JSON.stringify({
|
|
1100
1120
|
$schema: "https://app.clawnify.com/schema/v1/clawnify.json",
|
|
1101
1121
|
version: 1,
|
|
@@ -1302,13 +1322,6 @@ export const items = sqliteTable("items", {
|
|
|
1302
1322
|
status: text("status").notNull().default("active"),
|
|
1303
1323
|
createdAt: text("created_at").notNull().$default(() => new Date().toISOString()),
|
|
1304
1324
|
});
|
|
1305
|
-
`);
|
|
1306
|
-
write(dir, "drizzle/0000_init.sql", `CREATE TABLE \`items\` (
|
|
1307
|
-
\`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
1308
|
-
\`title\` text NOT NULL,
|
|
1309
|
-
\`status\` text DEFAULT 'active' NOT NULL,
|
|
1310
|
-
\`created_at\` text NOT NULL
|
|
1311
|
-
);
|
|
1312
1325
|
`);
|
|
1313
1326
|
write(dir, "src/server/routes.ts", `import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
1314
1327
|
import { getDB, eq, desc } from "@clawnify/db";
|
|
@@ -1521,14 +1534,14 @@ export function App() {
|
|
|
1521
1534
|
}
|
|
1522
1535
|
function write(dir, file, content) {
|
|
1523
1536
|
const fullPath = path3.join(dir, file);
|
|
1524
|
-
|
|
1525
|
-
|
|
1537
|
+
fs3.mkdirSync(path3.dirname(fullPath), { recursive: true });
|
|
1538
|
+
fs3.writeFileSync(fullPath, content);
|
|
1526
1539
|
}
|
|
1527
1540
|
|
|
1528
1541
|
// src/commands/dev.ts
|
|
1529
|
-
import
|
|
1542
|
+
import fs4 from "fs";
|
|
1530
1543
|
import path4 from "path";
|
|
1531
|
-
import { spawn } from "child_process";
|
|
1544
|
+
import { spawn as spawn2 } from "child_process";
|
|
1532
1545
|
function slugify2(name) {
|
|
1533
1546
|
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 30);
|
|
1534
1547
|
}
|
|
@@ -1589,24 +1602,32 @@ async function devCommand(dir, options) {
|
|
|
1589
1602
|
const storage = manifest.app.storage === true;
|
|
1590
1603
|
const apiPort = options?.port || "8787";
|
|
1591
1604
|
const clawnifyDir = path4.join(resolvedDir, ".clawnify");
|
|
1592
|
-
|
|
1605
|
+
fs4.mkdirSync(clawnifyDir, { recursive: true });
|
|
1593
1606
|
const wranglerPath = path4.join(clawnifyDir, "wrangler.toml");
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
path4.join(resolvedDir, "schema.
|
|
1597
|
-
path4.join(resolvedDir, "
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1607
|
+
fs4.writeFileSync(wranglerPath, generateWranglerToml(slug, { database, storage }));
|
|
1608
|
+
if (database) {
|
|
1609
|
+
const schemaTsPath = path4.join(resolvedDir, "src/server/schema.ts");
|
|
1610
|
+
const drizzleConfigPath = path4.join(resolvedDir, "drizzle.config.ts");
|
|
1611
|
+
if (fs4.existsSync(schemaTsPath) && fs4.existsSync(drizzleConfigPath)) {
|
|
1612
|
+
await syncDrizzleToLocalD1(resolvedDir, clawnifyDir, slug, wranglerPath);
|
|
1613
|
+
} else {
|
|
1614
|
+
const schemaCandidates = [
|
|
1615
|
+
path4.join(resolvedDir, "schema.sql"),
|
|
1616
|
+
path4.join(resolvedDir, "src/server/schema.sql")
|
|
1617
|
+
];
|
|
1618
|
+
const schemaPath = schemaCandidates.find((p) => fs4.existsSync(p));
|
|
1619
|
+
if (schemaPath) {
|
|
1620
|
+
await runQuiet(resolvedDir, "npx", [
|
|
1621
|
+
"wrangler",
|
|
1622
|
+
"d1",
|
|
1623
|
+
"execute",
|
|
1624
|
+
`${slug}-db`,
|
|
1625
|
+
"--local",
|
|
1626
|
+
`--file=${schemaPath}`,
|
|
1627
|
+
`--config=${wranglerPath}`
|
|
1628
|
+
]);
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1610
1631
|
}
|
|
1611
1632
|
console.log();
|
|
1612
1633
|
console.log(` ${manifest.name} dev server`);
|
|
@@ -1614,12 +1635,12 @@ async function devCommand(dir, options) {
|
|
|
1614
1635
|
console.log(` UI: http://localhost:5173`);
|
|
1615
1636
|
console.log(` API: http://localhost:${apiPort}`);
|
|
1616
1637
|
console.log();
|
|
1617
|
-
const vite =
|
|
1638
|
+
const vite = spawn2("npx", ["vite"], {
|
|
1618
1639
|
cwd: resolvedDir,
|
|
1619
1640
|
stdio: ["ignore", "pipe", "pipe"],
|
|
1620
1641
|
env: { ...process.env }
|
|
1621
1642
|
});
|
|
1622
|
-
const wrangler =
|
|
1643
|
+
const wrangler = spawn2("npx", [
|
|
1623
1644
|
"wrangler",
|
|
1624
1645
|
"dev",
|
|
1625
1646
|
`--port=${apiPort}`,
|
|
@@ -1678,7 +1699,7 @@ function createFilter(label) {
|
|
|
1678
1699
|
}
|
|
1679
1700
|
function runQuiet(cwd, cmd, args) {
|
|
1680
1701
|
return new Promise((resolve, reject) => {
|
|
1681
|
-
const proc =
|
|
1702
|
+
const proc = spawn2(cmd, args, {
|
|
1682
1703
|
cwd,
|
|
1683
1704
|
stdio: ["ignore", "pipe", "pipe"],
|
|
1684
1705
|
env: { ...process.env }
|
|
@@ -1696,6 +1717,47 @@ function runQuiet(cwd, cmd, args) {
|
|
|
1696
1717
|
});
|
|
1697
1718
|
});
|
|
1698
1719
|
}
|
|
1720
|
+
async function syncDrizzleToLocalD1(resolvedDir, clawnifyDir, slug, wranglerPath) {
|
|
1721
|
+
try {
|
|
1722
|
+
await runQuiet(resolvedDir, "npx", ["drizzle-kit", "generate"]);
|
|
1723
|
+
} catch (err) {
|
|
1724
|
+
console.error(
|
|
1725
|
+
` drizzle-kit generate failed. Is \`drizzle-kit\` in devDependencies?
|
|
1726
|
+
${err.message}`
|
|
1727
|
+
);
|
|
1728
|
+
throw err;
|
|
1729
|
+
}
|
|
1730
|
+
const drizzleDir = path4.join(clawnifyDir, "drizzle");
|
|
1731
|
+
if (!fs4.existsSync(drizzleDir)) return;
|
|
1732
|
+
const sqlFiles = fs4.readdirSync(drizzleDir).filter((name) => name.endsWith(".sql")).sort();
|
|
1733
|
+
if (sqlFiles.length === 0) return;
|
|
1734
|
+
const appliedPath = path4.join(clawnifyDir, "applied-migrations.json");
|
|
1735
|
+
let applied = [];
|
|
1736
|
+
if (fs4.existsSync(appliedPath)) {
|
|
1737
|
+
try {
|
|
1738
|
+
applied = JSON.parse(fs4.readFileSync(appliedPath, "utf8"));
|
|
1739
|
+
if (!Array.isArray(applied)) applied = [];
|
|
1740
|
+
} catch {
|
|
1741
|
+
applied = [];
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
const appliedSet = new Set(applied);
|
|
1745
|
+
for (const file of sqlFiles) {
|
|
1746
|
+
if (appliedSet.has(file)) continue;
|
|
1747
|
+
const filePath = path4.join(drizzleDir, file);
|
|
1748
|
+
await runQuiet(resolvedDir, "npx", [
|
|
1749
|
+
"wrangler",
|
|
1750
|
+
"d1",
|
|
1751
|
+
"execute",
|
|
1752
|
+
`${slug}-db`,
|
|
1753
|
+
"--local",
|
|
1754
|
+
`--file=${filePath}`,
|
|
1755
|
+
`--config=${wranglerPath}`
|
|
1756
|
+
]);
|
|
1757
|
+
applied.push(file);
|
|
1758
|
+
}
|
|
1759
|
+
fs4.writeFileSync(appliedPath, JSON.stringify(applied, null, 2) + "\n");
|
|
1760
|
+
}
|
|
1699
1761
|
|
|
1700
1762
|
// src/commands/link.ts
|
|
1701
1763
|
import path5 from "path";
|
|
@@ -1856,7 +1918,7 @@ async function orgUseCommand(slugOrId) {
|
|
|
1856
1918
|
}
|
|
1857
1919
|
|
|
1858
1920
|
// src/commands/execute.ts
|
|
1859
|
-
import
|
|
1921
|
+
import fs5 from "fs";
|
|
1860
1922
|
|
|
1861
1923
|
// src/lib/mcp-client.ts
|
|
1862
1924
|
var MCP_URL = "https://mcp.clawnify.com/mcp";
|
|
@@ -1906,7 +1968,7 @@ async function executeCommand(file, options) {
|
|
|
1906
1968
|
code = options.code;
|
|
1907
1969
|
} else if (file) {
|
|
1908
1970
|
try {
|
|
1909
|
-
code =
|
|
1971
|
+
code = fs5.readFileSync(file, "utf-8");
|
|
1910
1972
|
} catch (err) {
|
|
1911
1973
|
process.stderr.write(`Failed to read ${file}: ${String(err)}
|
|
1912
1974
|
`);
|
|
@@ -2043,7 +2105,7 @@ async function sdkInstallCommand() {
|
|
|
2043
2105
|
}
|
|
2044
2106
|
|
|
2045
2107
|
// src/lib/skills/content.gen.ts
|
|
2046
|
-
var CLI_VERSION = "0.
|
|
2108
|
+
var CLI_VERSION = "0.5.0";
|
|
2047
2109
|
var BUNDLED_SKILLS = [
|
|
2048
2110
|
{
|
|
2049
2111
|
name: "build-a-clawnify-app",
|
|
@@ -2410,4 +2472,4 @@ function runCli() {
|
|
|
2410
2472
|
export {
|
|
2411
2473
|
runCli
|
|
2412
2474
|
};
|
|
2413
|
-
//# sourceMappingURL=cli-
|
|
2475
|
+
//# sourceMappingURL=cli-XYGLEX6Q.js.map
|