@codebakers/cli 1.3.0 → 1.4.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/commands/generate.d.ts +9 -0
- package/dist/commands/generate.js +653 -0
- package/dist/commands/scaffold.js +94 -22
- package/dist/index.js +6 -0
- package/package.json +1 -1
- package/src/commands/generate.ts +702 -0
- package/src/commands/scaffold.ts +97 -23
- package/src/index.ts +7 -0
package/src/commands/scaffold.ts
CHANGED
|
@@ -52,11 +52,40 @@ export async function scaffold(): Promise<void> {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
//
|
|
55
|
+
// Ask about experience level
|
|
56
|
+
console.log(chalk.white('\n What\'s your experience level?\n'));
|
|
57
|
+
console.log(chalk.gray(' 1. ') + chalk.cyan('Beginner') + chalk.gray(' - New to coding, explain everything'));
|
|
58
|
+
console.log(chalk.gray(' 2. ') + chalk.cyan('Intermediate') + chalk.gray(' - Know some coding, brief explanations'));
|
|
59
|
+
console.log(chalk.gray(' 3. ') + chalk.cyan('Advanced') + chalk.gray(' - Skip explanations, just build\n'));
|
|
60
|
+
|
|
61
|
+
let experienceLevel = '';
|
|
62
|
+
while (!['1', '2', '3'].includes(experienceLevel)) {
|
|
63
|
+
experienceLevel = await prompt(' Enter 1, 2, or 3: ');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const isBeginnerMode = experienceLevel === '1';
|
|
67
|
+
const showBriefExplanations = experienceLevel === '2';
|
|
68
|
+
|
|
69
|
+
// Select stack with explanations for beginners
|
|
56
70
|
console.log(chalk.white('\n Select your stack:\n'));
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
71
|
+
|
|
72
|
+
if (isBeginnerMode) {
|
|
73
|
+
console.log(chalk.gray(' 1. ') + chalk.cyan('Next.js + Supabase + Drizzle') + chalk.green(' (Recommended)'));
|
|
74
|
+
console.log(chalk.gray(' ') + chalk.dim('Next.js = Framework for building websites with React'));
|
|
75
|
+
console.log(chalk.gray(' ') + chalk.dim('Supabase = Database + user login (like Firebase, but open source)'));
|
|
76
|
+
console.log(chalk.gray(' ') + chalk.dim('Drizzle = Tool to talk to your database safely'));
|
|
77
|
+
console.log('');
|
|
78
|
+
console.log(chalk.gray(' 2. ') + chalk.cyan('Next.js + Prisma') + chalk.gray(' (Coming soon)'));
|
|
79
|
+
console.log(chalk.gray(' ') + chalk.dim('Prisma = Another database tool, more popular but heavier'));
|
|
80
|
+
console.log('');
|
|
81
|
+
console.log(chalk.gray(' 3. ') + chalk.cyan('Express API') + chalk.gray(' (Coming soon)'));
|
|
82
|
+
console.log(chalk.gray(' ') + chalk.dim('Express = Lightweight server, good for APIs without a frontend'));
|
|
83
|
+
console.log('');
|
|
84
|
+
} else {
|
|
85
|
+
console.log(chalk.gray(' 1. ') + chalk.cyan('Next.js + Supabase + Drizzle') + chalk.gray(' (Recommended)'));
|
|
86
|
+
console.log(chalk.gray(' 2. ') + chalk.cyan('Next.js + Prisma') + chalk.gray(' (Coming soon)'));
|
|
87
|
+
console.log(chalk.gray(' 3. ') + chalk.cyan('Express API') + chalk.gray(' (Coming soon)\n'));
|
|
88
|
+
}
|
|
60
89
|
|
|
61
90
|
let stackChoice = '';
|
|
62
91
|
while (!['1', '2', '3'].includes(stackChoice)) {
|
|
@@ -68,6 +97,23 @@ export async function scaffold(): Promise<void> {
|
|
|
68
97
|
stackChoice = '1';
|
|
69
98
|
}
|
|
70
99
|
|
|
100
|
+
// Explain what we're about to create for beginners
|
|
101
|
+
if (isBeginnerMode) {
|
|
102
|
+
console.log(chalk.blue('\n ═══════════════════════════════════════════════════════════'));
|
|
103
|
+
console.log(chalk.white.bold(' 📚 What we\'re creating:'));
|
|
104
|
+
console.log(chalk.blue(' ═══════════════════════════════════════════════════════════\n'));
|
|
105
|
+
console.log(chalk.gray(' This will create a complete web application with:'));
|
|
106
|
+
console.log(chalk.gray(' • A website users can visit (Next.js)'));
|
|
107
|
+
console.log(chalk.gray(' • User signup/login system (Supabase Auth)'));
|
|
108
|
+
console.log(chalk.gray(' • A database to store data (PostgreSQL via Supabase)'));
|
|
109
|
+
console.log(chalk.gray(' • Beautiful styling system (Tailwind CSS)'));
|
|
110
|
+
console.log(chalk.gray(' • Type safety to prevent bugs (TypeScript)\n'));
|
|
111
|
+
console.log(chalk.gray(' Think of it like a house:'));
|
|
112
|
+
console.log(chalk.gray(' • Next.js is the structure (walls, roof)'));
|
|
113
|
+
console.log(chalk.gray(' • Supabase is the utilities (electricity, plumbing)'));
|
|
114
|
+
console.log(chalk.gray(' • Tailwind is the interior design (paint, furniture)\n'));
|
|
115
|
+
}
|
|
116
|
+
|
|
71
117
|
// Get project name
|
|
72
118
|
const defaultName = cwd.split(/[\\/]/).pop() || 'my-project';
|
|
73
119
|
const projectName = await prompt(` Project name (${defaultName}): `) || defaultName;
|
|
@@ -164,28 +210,56 @@ export async function scaffold(): Promise<void> {
|
|
|
164
210
|
`));
|
|
165
211
|
|
|
166
212
|
console.log(chalk.white(' Project structure:\n'));
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
213
|
+
if (isBeginnerMode) {
|
|
214
|
+
console.log(chalk.gray(' src/'));
|
|
215
|
+
console.log(chalk.gray(' ├── app/ ') + chalk.cyan('← Your pages (what users see)'));
|
|
216
|
+
console.log(chalk.gray(' ├── components/ ') + chalk.cyan('← Reusable UI pieces (buttons, forms)'));
|
|
217
|
+
console.log(chalk.gray(' ├── lib/ ') + chalk.cyan('← Helper code & connections'));
|
|
218
|
+
console.log(chalk.gray(' │ └── supabase/ ') + chalk.cyan('← Login & database connection'));
|
|
219
|
+
console.log(chalk.gray(' ├── db/ ') + chalk.cyan('← Database structure (tables)'));
|
|
220
|
+
console.log(chalk.gray(' ├── services/ ') + chalk.cyan('← Core app logic (what your app does)'));
|
|
221
|
+
console.log(chalk.gray(' └── types/ ') + chalk.cyan('← Data shape definitions'));
|
|
222
|
+
} else {
|
|
223
|
+
console.log(chalk.gray(' src/'));
|
|
224
|
+
console.log(chalk.gray(' ├── app/ ') + chalk.cyan('← Pages & layouts'));
|
|
225
|
+
console.log(chalk.gray(' ├── components/ ') + chalk.cyan('← React components'));
|
|
226
|
+
console.log(chalk.gray(' ├── lib/ ') + chalk.cyan('← Utilities & clients'));
|
|
227
|
+
console.log(chalk.gray(' │ └── supabase/ ') + chalk.cyan('← Supabase clients (ready!)'));
|
|
228
|
+
console.log(chalk.gray(' ├── db/ ') + chalk.cyan('← Database schema & queries'));
|
|
229
|
+
console.log(chalk.gray(' ├── services/ ') + chalk.cyan('← Business logic'));
|
|
230
|
+
console.log(chalk.gray(' └── types/ ') + chalk.cyan('← TypeScript types'));
|
|
231
|
+
}
|
|
175
232
|
console.log('');
|
|
176
233
|
|
|
177
234
|
console.log(chalk.white(' Next steps:\n'));
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
235
|
+
if (isBeginnerMode) {
|
|
236
|
+
console.log(chalk.cyan(' 1. ') + chalk.white('Set up Supabase (free database + login):'));
|
|
237
|
+
console.log(chalk.gray(' Go to https://supabase.com → Create free account → New Project'));
|
|
238
|
+
console.log('');
|
|
239
|
+
console.log(chalk.cyan(' 2. ') + chalk.white('Connect your project:'));
|
|
240
|
+
console.log(chalk.gray(' Open .env.local file and paste your Supabase credentials'));
|
|
241
|
+
console.log(chalk.gray(' (Found in Supabase: Settings → API)'));
|
|
242
|
+
console.log('');
|
|
243
|
+
console.log(chalk.cyan(' 3. ') + chalk.white('Start your app:'));
|
|
244
|
+
console.log(chalk.gray(' Run: npm run dev'));
|
|
245
|
+
console.log(chalk.gray(' Open: http://localhost:3000 in your browser'));
|
|
246
|
+
console.log('');
|
|
247
|
+
console.log(chalk.cyan(' 4. ') + chalk.white('Add AI superpowers:'));
|
|
248
|
+
console.log(chalk.gray(' Run: codebakers init'));
|
|
249
|
+
console.log(chalk.gray(' Now AI will follow professional coding patterns!\n'));
|
|
250
|
+
} else {
|
|
251
|
+
console.log(chalk.cyan(' 1. ') + chalk.gray('Update .env.local with your Supabase credentials'));
|
|
252
|
+
console.log(chalk.cyan(' 2. ') + chalk.gray('Run `npm run dev` to start development'));
|
|
253
|
+
console.log(chalk.cyan(' 3. ') + chalk.gray('Run `codebakers init` to add CodeBakers patterns'));
|
|
254
|
+
console.log(chalk.cyan(' 4. ') + chalk.gray('Start building with AI assistance!\n'));
|
|
255
|
+
|
|
256
|
+
console.log(chalk.white(' Supabase setup:\n'));
|
|
257
|
+
console.log(chalk.gray(' 1. Create a project at https://supabase.com'));
|
|
258
|
+
console.log(chalk.gray(' 2. Go to Settings → API'));
|
|
259
|
+
console.log(chalk.gray(' 3. Copy URL and anon key to .env.local'));
|
|
260
|
+
console.log(chalk.gray(' 4. Go to Settings → Database → Connection string'));
|
|
261
|
+
console.log(chalk.gray(' 5. Copy DATABASE_URL to .env.local\n'));
|
|
262
|
+
}
|
|
189
263
|
|
|
190
264
|
} catch (error) {
|
|
191
265
|
spinner.fail('Project scaffolding failed');
|
package/src/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { serve } from './commands/serve.js';
|
|
|
12
12
|
import { mcpConfig, mcpUninstall } from './commands/mcp-config.js';
|
|
13
13
|
import { setup } from './commands/setup.js';
|
|
14
14
|
import { scaffold } from './commands/scaffold.js';
|
|
15
|
+
import { generate } from './commands/generate.js';
|
|
15
16
|
|
|
16
17
|
const program = new Command();
|
|
17
18
|
|
|
@@ -37,6 +38,12 @@ program
|
|
|
37
38
|
.description('Create a new project with full stack scaffolding (Next.js + Supabase + Drizzle)')
|
|
38
39
|
.action(scaffold);
|
|
39
40
|
|
|
41
|
+
program
|
|
42
|
+
.command('generate [type] [name]')
|
|
43
|
+
.alias('g')
|
|
44
|
+
.description('Generate code from templates (component, api, service, hook, page, schema, form)')
|
|
45
|
+
.action((type, name) => generate({ type, name }));
|
|
46
|
+
|
|
40
47
|
program
|
|
41
48
|
.command('login')
|
|
42
49
|
.description('Login with your API key')
|