firth 0.0.1 → 0.0.3

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/cli.js DELETED
@@ -1,183 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/cli.ts
4
- import { defineCommand as defineCommand2, runMain } from "citty";
5
-
6
- // src/commands/init.ts
7
- import { defineCommand } from "citty";
8
- import * as p from "@clack/prompts";
9
- import { writeFile, mkdir } from "fs/promises";
10
- import { existsSync } from "fs";
11
- import { resolve, basename } from "path";
12
- var initCommand = defineCommand({
13
- meta: {
14
- name: "init",
15
- description: "Scaffold Firth project files (firth.config.ts + firth.lock.json) in the target directory."
16
- },
17
- args: {
18
- name: {
19
- type: "positional",
20
- description: "Project directory (use '.' for current directory)",
21
- required: false,
22
- default: "."
23
- },
24
- yes: {
25
- type: "boolean",
26
- alias: "y",
27
- description: "Skip all prompts; use defaults (Next.js + Hono + Neon + Vercel + Railway). Safe for non-interactive agent runs.",
28
- default: false
29
- },
30
- frontend: {
31
- type: "string",
32
- description: "Frontend framework override (nextjs)"
33
- },
34
- backend: {
35
- type: "string",
36
- description: "Backend framework override (hono | express | none)"
37
- },
38
- db: {
39
- type: "string",
40
- description: "Database provider override (neon | none)"
41
- },
42
- "frontend-host": {
43
- type: "string",
44
- description: "Frontend host override (vercel | none)"
45
- },
46
- "backend-host": {
47
- type: "string",
48
- description: "Backend host override (railway | none)"
49
- }
50
- },
51
- async run({ args }) {
52
- const rawName = String(args.name);
53
- const targetDir = resolve(process.cwd(), rawName);
54
- const projectName = rawName === "." ? basename(targetDir) : basename(targetDir);
55
- p.intro("firth init");
56
- const configPath = resolve(targetDir, "firth.config.ts");
57
- if (existsSync(configPath)) {
58
- p.cancel(
59
- [
60
- "ERROR: firth.config.ts already exists.",
61
- `LOCATION: ${configPath}`,
62
- "SUGGESTED ACTIONS:",
63
- " 1. Edit firth.config.ts by hand to change the stack.",
64
- " 2. Or delete firth.config.ts and re-run `firth init`."
65
- ].join("\n")
66
- );
67
- process.exit(1);
68
- }
69
- const stack = args.yes ? defaultStack() : await promptStack(args);
70
- if (!stack) {
71
- p.cancel("Cancelled.");
72
- process.exit(0);
73
- }
74
- const config = { project: projectName, stack };
75
- const lock = { version: 1, resources: {} };
76
- if (!existsSync(targetDir)) {
77
- await mkdir(targetDir, { recursive: true });
78
- }
79
- await writeFile(configPath, renderConfig(config), "utf8");
80
- await writeFile(
81
- resolve(targetDir, "firth.lock.json"),
82
- JSON.stringify(lock, null, 2) + "\n",
83
- "utf8"
84
- );
85
- p.outro(
86
- [
87
- `OK: wrote firth.config.ts and firth.lock.json to ${targetDir}`,
88
- "",
89
- "NEXT STEPS:",
90
- " 1. Review firth.config.ts and adjust the stack if needed.",
91
- " 2. Run `firth deploy` to provision and ship (coming soon)."
92
- ].join("\n")
93
- );
94
- }
95
- });
96
- function defaultStack() {
97
- return {
98
- frontend: "nextjs",
99
- backend: "hono",
100
- db: "neon",
101
- frontendHost: "vercel",
102
- backendHost: "railway"
103
- };
104
- }
105
- async function promptStack(args) {
106
- const frontend = args.frontend ?? await p.select({
107
- message: "Frontend framework?",
108
- options: [{ value: "nextjs", label: "Next.js" }],
109
- initialValue: "nextjs"
110
- });
111
- if (p.isCancel(frontend)) return null;
112
- const backend = args.backend ?? await p.select({
113
- message: "Backend framework?",
114
- options: [
115
- { value: "hono", label: "Hono (recommended)" },
116
- { value: "express", label: "Express" },
117
- { value: "none", label: "None (frontend-only)" }
118
- ],
119
- initialValue: "hono"
120
- });
121
- if (p.isCancel(backend)) return null;
122
- const db = args.db ?? await p.select({
123
- message: "Database?",
124
- options: [
125
- { value: "neon", label: "Neon Postgres" },
126
- { value: "none", label: "None" }
127
- ],
128
- initialValue: "neon"
129
- });
130
- if (p.isCancel(db)) return null;
131
- const frontendHost = args["frontend-host"] ?? await p.select({
132
- message: "Frontend hosting?",
133
- options: [
134
- { value: "vercel", label: "Vercel" },
135
- { value: "none", label: "Not yet" }
136
- ],
137
- initialValue: "vercel"
138
- });
139
- if (p.isCancel(frontendHost)) return null;
140
- let backendHost;
141
- if (backend === "none") {
142
- backendHost = "none";
143
- } else {
144
- const result = args["backend-host"] ?? await p.select({
145
- message: "Backend hosting?",
146
- options: [
147
- { value: "railway", label: "Railway" },
148
- { value: "none", label: "Not yet" }
149
- ],
150
- initialValue: "railway"
151
- });
152
- if (p.isCancel(result)) return null;
153
- backendHost = String(result);
154
- }
155
- return {
156
- frontend: String(frontend),
157
- backend: String(backend),
158
- db: String(db),
159
- frontendHost: String(frontendHost),
160
- backendHost
161
- };
162
- }
163
- function renderConfig(config) {
164
- return `// firth.config.ts
165
- // Generated by \`firth init\`. Source-of-truth for this project's stack.
166
- // Hand-edit, then run \`firth deploy\` to apply changes.
167
-
168
- export default ${JSON.stringify(config, null, 2)};
169
- `;
170
- }
171
-
172
- // src/cli.ts
173
- var main = defineCommand2({
174
- meta: {
175
- name: "firth",
176
- version: "0.0.1",
177
- description: "Cloud platform SDK for AI coding agents."
178
- },
179
- subCommands: {
180
- init: initCommand
181
- }
182
- });
183
- runMain(main);