@codebakers/cli 1.2.1 → 1.3.1
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/install-hook.js +42 -68
- package/dist/commands/scaffold.d.ts +4 -0
- package/dist/commands/scaffold.js +277 -0
- package/dist/index.js +6 -0
- package/dist/mcp/server.js +211 -0
- package/dist/templates/nextjs-supabase.d.ts +81 -0
- package/dist/templates/nextjs-supabase.js +356 -0
- package/package.json +1 -1
- package/src/commands/install-hook.ts +44 -68
- package/src/commands/scaffold.ts +270 -0
- package/src/index.ts +7 -0
- package/src/mcp/server.ts +244 -0
- package/src/templates/nextjs-supabase.ts +371 -0
|
@@ -11,70 +11,38 @@ const ora_1 = __importDefault(require("ora"));
|
|
|
11
11
|
const fs_1 = require("fs");
|
|
12
12
|
const path_1 = require("path");
|
|
13
13
|
const os_1 = require("os");
|
|
14
|
-
// Enhanced hook with
|
|
14
|
+
// Enhanced hook with visible feedback and concise instructions
|
|
15
15
|
const HOOK_TEMPLATE = {
|
|
16
16
|
hooks: {
|
|
17
17
|
UserPromptSubmit: [
|
|
18
18
|
{
|
|
19
19
|
type: "command",
|
|
20
|
-
command: `echo '
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- CLAUDE.md → Router & module instructions
|
|
29
|
-
- PRD.md → What we are building (requirements!)
|
|
30
|
-
- PROJECT-CONTEXT.md → Codebase knowledge
|
|
31
|
-
- PROJECT-STATE.md → What is in progress
|
|
32
|
-
- DECISIONS.md → Past architectural choices
|
|
33
|
-
|
|
34
|
-
▸ PHASE 2: PRE-FLIGHT CHECK (before writing code)
|
|
35
|
-
□ What existing code does this touch?
|
|
36
|
-
□ Is similar code in the codebase? (copy that pattern!)
|
|
37
|
-
□ Whats the data model?
|
|
38
|
-
□ What are the error cases?
|
|
39
|
-
□ Is someone else working on this? (check In Progress)
|
|
40
|
-
|
|
41
|
-
If PROJECT-CONTEXT.md is empty/stale, SCAN PROJECT FIRST:
|
|
42
|
-
- Read package.json
|
|
43
|
-
- Check file structure
|
|
44
|
-
- Find existing patterns
|
|
45
|
-
- Update PROJECT-CONTEXT.md
|
|
46
|
-
|
|
47
|
-
▸ PHASE 3: ACKNOWLEDGE & EXECUTE
|
|
48
|
-
Output: 📋 CodeBakers | [Type] | Modules: [list]
|
|
49
|
-
Then: Follow patterns from .claude/ folder EXACTLY
|
|
50
|
-
|
|
51
|
-
▸ PHASE 4: SELF-REVIEW (before saying done)
|
|
52
|
-
□ TypeScript compiles? (npx tsc --noEmit)
|
|
53
|
-
□ Imports resolve?
|
|
54
|
-
□ Error handling exists?
|
|
55
|
-
□ Matches existing patterns?
|
|
56
|
-
□ Tests written?
|
|
57
|
-
|
|
58
|
-
If ANY fails → FIX before responding
|
|
59
|
-
|
|
60
|
-
▸ PHASE 5: UPDATE STATE
|
|
61
|
-
- Update PROJECT-STATE.md (move to Completed)
|
|
62
|
-
- Add to DECISIONS.md if architectural choice made
|
|
63
|
-
|
|
64
|
-
════════════════════════════════════════════════════════════════
|
|
65
|
-
🔄 MULTI-AGENT MODE
|
|
66
|
-
════════════════════════════════════════════════════════════════
|
|
67
|
-
- Check PROJECT-STATE.md "In Progress" - dont duplicate work
|
|
68
|
-
- Add YOUR task to In Progress when starting
|
|
69
|
-
- If conflict → STOP and ask user
|
|
70
|
-
|
|
71
|
-
════════════════════════════════════════════════════════════════
|
|
72
|
-
💡 REMEMBER: Check existing code FIRST. Copy patterns. Validate.
|
|
73
|
-
════════════════════════════════════════════════════════════════'`
|
|
20
|
+
command: `echo '[CodeBakers] Loading project context...'`
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
PostToolUse: [
|
|
24
|
+
{
|
|
25
|
+
type: "command",
|
|
26
|
+
matcher: "Write|Edit",
|
|
27
|
+
command: `echo '[CodeBakers] Code written - remember to self-review before marking done'`
|
|
74
28
|
}
|
|
75
29
|
]
|
|
76
30
|
}
|
|
77
31
|
};
|
|
32
|
+
// Instructions that get injected into the system prompt
|
|
33
|
+
const CODEBAKERS_INSTRUCTIONS = `
|
|
34
|
+
<user-prompt-submit-hook>
|
|
35
|
+
[CodeBakers] Active - Follow these steps for EVERY request:
|
|
36
|
+
|
|
37
|
+
1. CONTEXT: Read CLAUDE.md, PROJECT-CONTEXT.md, PROJECT-STATE.md
|
|
38
|
+
2. PRE-FLIGHT: Check existing code patterns before writing new code
|
|
39
|
+
3. EXECUTE: Use patterns from .claude/ folder
|
|
40
|
+
4. SELF-REVIEW: Verify TypeScript compiles, imports resolve, error handling exists
|
|
41
|
+
5. UPDATE: Mark tasks complete in PROJECT-STATE.md
|
|
42
|
+
|
|
43
|
+
Output format: "[CodeBakers] Building [feature] using [patterns]"
|
|
44
|
+
</user-prompt-submit-hook>
|
|
45
|
+
`;
|
|
78
46
|
/**
|
|
79
47
|
* Install the CodeBakers hook into ~/.claude/settings.json
|
|
80
48
|
*/
|
|
@@ -117,20 +85,21 @@ async function installHook() {
|
|
|
117
85
|
console.log(chalk_1.default.yellow(' It will be replaced with the CodeBakers hook.\n'));
|
|
118
86
|
}
|
|
119
87
|
}
|
|
120
|
-
// Merge
|
|
88
|
+
// Merge hooks into settings
|
|
121
89
|
settings.hooks = settings.hooks || {};
|
|
122
90
|
settings.hooks.UserPromptSubmit = HOOK_TEMPLATE.hooks.UserPromptSubmit;
|
|
91
|
+
settings.hooks.PostToolUse = HOOK_TEMPLATE.hooks.PostToolUse;
|
|
123
92
|
// Write back
|
|
124
93
|
(0, fs_1.writeFileSync)(settingsPath, JSON.stringify(settings, null, 2));
|
|
125
94
|
spinner.succeed('Hook installed successfully!');
|
|
126
|
-
console.log(chalk_1.default.white('\n
|
|
127
|
-
console.log(chalk_1.default.
|
|
128
|
-
console.log(chalk_1.default.
|
|
129
|
-
console.log(chalk_1.default.
|
|
130
|
-
console.log(chalk_1.default.gray(' ✓
|
|
131
|
-
console.log(chalk_1.default.gray(' ✓
|
|
132
|
-
console.log(chalk_1.default.gray(' ✓
|
|
133
|
-
console.log(chalk_1.default.gray(' ✓
|
|
95
|
+
console.log(chalk_1.default.white('\n You\'ll see [CodeBakers] feedback in terminal:\n'));
|
|
96
|
+
console.log(chalk_1.default.cyan(' [CodeBakers] Loading project context...'));
|
|
97
|
+
console.log(chalk_1.default.cyan(' [CodeBakers] Code written - remember to self-review\n'));
|
|
98
|
+
console.log(chalk_1.default.white(' What happens automatically:\n'));
|
|
99
|
+
console.log(chalk_1.default.gray(' ✓ Loads project context before every response'));
|
|
100
|
+
console.log(chalk_1.default.gray(' ✓ Pre-flight checks before writing code'));
|
|
101
|
+
console.log(chalk_1.default.gray(' ✓ Self-review reminders after code changes'));
|
|
102
|
+
console.log(chalk_1.default.gray(' ✓ Pattern-based development from .claude/ folder\n'));
|
|
134
103
|
console.log(chalk_1.default.yellow(' ⚠️ Restart Claude Code for changes to take effect.\n'));
|
|
135
104
|
}
|
|
136
105
|
catch (error) {
|
|
@@ -153,12 +122,17 @@ async function uninstallHook() {
|
|
|
153
122
|
return;
|
|
154
123
|
}
|
|
155
124
|
const settings = JSON.parse((0, fs_1.readFileSync)(settingsPath, 'utf-8'));
|
|
156
|
-
if (!settings.hooks?.UserPromptSubmit) {
|
|
157
|
-
spinner.info('No
|
|
125
|
+
if (!settings.hooks?.UserPromptSubmit && !settings.hooks?.PostToolUse) {
|
|
126
|
+
spinner.info('No CodeBakers hooks found. Nothing to remove.');
|
|
158
127
|
return;
|
|
159
128
|
}
|
|
160
|
-
// Remove
|
|
161
|
-
|
|
129
|
+
// Remove both hooks
|
|
130
|
+
if (settings.hooks?.UserPromptSubmit) {
|
|
131
|
+
delete settings.hooks.UserPromptSubmit;
|
|
132
|
+
}
|
|
133
|
+
if (settings.hooks?.PostToolUse) {
|
|
134
|
+
delete settings.hooks.PostToolUse;
|
|
135
|
+
}
|
|
162
136
|
// Clean up empty hooks object
|
|
163
137
|
if (Object.keys(settings.hooks).length === 0) {
|
|
164
138
|
delete settings.hooks;
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.scaffold = scaffold;
|
|
40
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
41
|
+
const ora_1 = __importDefault(require("ora"));
|
|
42
|
+
const readline_1 = require("readline");
|
|
43
|
+
const fs_1 = require("fs");
|
|
44
|
+
const path_1 = require("path");
|
|
45
|
+
const child_process_1 = require("child_process");
|
|
46
|
+
const templates = __importStar(require("../templates/nextjs-supabase.js"));
|
|
47
|
+
async function prompt(question) {
|
|
48
|
+
const rl = (0, readline_1.createInterface)({
|
|
49
|
+
input: process.stdin,
|
|
50
|
+
output: process.stdout,
|
|
51
|
+
});
|
|
52
|
+
return new Promise((resolve) => {
|
|
53
|
+
rl.question(question, (answer) => {
|
|
54
|
+
rl.close();
|
|
55
|
+
resolve(answer.trim());
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async function confirm(question) {
|
|
60
|
+
const answer = await prompt(`${question} (Y/n): `);
|
|
61
|
+
return answer.toLowerCase() !== 'n';
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Scaffold a new project with full structure
|
|
65
|
+
*/
|
|
66
|
+
async function scaffold() {
|
|
67
|
+
console.log(chalk_1.default.blue(`
|
|
68
|
+
╔═══════════════════════════════════════════════════════════╗
|
|
69
|
+
║ ║
|
|
70
|
+
║ ${chalk_1.default.bold('CodeBakers Project Scaffolding')} ║
|
|
71
|
+
║ ║
|
|
72
|
+
║ Create a production-ready project in seconds ║
|
|
73
|
+
║ ║
|
|
74
|
+
╚═══════════════════════════════════════════════════════════╝
|
|
75
|
+
`));
|
|
76
|
+
const cwd = process.cwd();
|
|
77
|
+
const files = (0, fs_1.readdirSync)(cwd);
|
|
78
|
+
const hasFiles = files.filter(f => !f.startsWith('.')).length > 0;
|
|
79
|
+
if (hasFiles) {
|
|
80
|
+
console.log(chalk_1.default.yellow(' ⚠️ This directory is not empty.\n'));
|
|
81
|
+
const proceed = await confirm(' Continue anyway? (Existing files may be overwritten)');
|
|
82
|
+
if (!proceed) {
|
|
83
|
+
console.log(chalk_1.default.gray('\n Run this command in an empty directory.\n'));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Ask about experience level
|
|
88
|
+
console.log(chalk_1.default.white('\n What\'s your experience level?\n'));
|
|
89
|
+
console.log(chalk_1.default.gray(' 1. ') + chalk_1.default.cyan('Beginner') + chalk_1.default.gray(' - New to coding, explain everything'));
|
|
90
|
+
console.log(chalk_1.default.gray(' 2. ') + chalk_1.default.cyan('Intermediate') + chalk_1.default.gray(' - Know some coding, brief explanations'));
|
|
91
|
+
console.log(chalk_1.default.gray(' 3. ') + chalk_1.default.cyan('Advanced') + chalk_1.default.gray(' - Skip explanations, just build\n'));
|
|
92
|
+
let experienceLevel = '';
|
|
93
|
+
while (!['1', '2', '3'].includes(experienceLevel)) {
|
|
94
|
+
experienceLevel = await prompt(' Enter 1, 2, or 3: ');
|
|
95
|
+
}
|
|
96
|
+
const isBeginnerMode = experienceLevel === '1';
|
|
97
|
+
const showBriefExplanations = experienceLevel === '2';
|
|
98
|
+
// Select stack with explanations for beginners
|
|
99
|
+
console.log(chalk_1.default.white('\n Select your stack:\n'));
|
|
100
|
+
if (isBeginnerMode) {
|
|
101
|
+
console.log(chalk_1.default.gray(' 1. ') + chalk_1.default.cyan('Next.js + Supabase + Drizzle') + chalk_1.default.green(' (Recommended)'));
|
|
102
|
+
console.log(chalk_1.default.gray(' ') + chalk_1.default.dim('Next.js = Framework for building websites with React'));
|
|
103
|
+
console.log(chalk_1.default.gray(' ') + chalk_1.default.dim('Supabase = Database + user login (like Firebase, but open source)'));
|
|
104
|
+
console.log(chalk_1.default.gray(' ') + chalk_1.default.dim('Drizzle = Tool to talk to your database safely'));
|
|
105
|
+
console.log('');
|
|
106
|
+
console.log(chalk_1.default.gray(' 2. ') + chalk_1.default.cyan('Next.js + Prisma') + chalk_1.default.gray(' (Coming soon)'));
|
|
107
|
+
console.log(chalk_1.default.gray(' ') + chalk_1.default.dim('Prisma = Another database tool, more popular but heavier'));
|
|
108
|
+
console.log('');
|
|
109
|
+
console.log(chalk_1.default.gray(' 3. ') + chalk_1.default.cyan('Express API') + chalk_1.default.gray(' (Coming soon)'));
|
|
110
|
+
console.log(chalk_1.default.gray(' ') + chalk_1.default.dim('Express = Lightweight server, good for APIs without a frontend'));
|
|
111
|
+
console.log('');
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
console.log(chalk_1.default.gray(' 1. ') + chalk_1.default.cyan('Next.js + Supabase + Drizzle') + chalk_1.default.gray(' (Recommended)'));
|
|
115
|
+
console.log(chalk_1.default.gray(' 2. ') + chalk_1.default.cyan('Next.js + Prisma') + chalk_1.default.gray(' (Coming soon)'));
|
|
116
|
+
console.log(chalk_1.default.gray(' 3. ') + chalk_1.default.cyan('Express API') + chalk_1.default.gray(' (Coming soon)\n'));
|
|
117
|
+
}
|
|
118
|
+
let stackChoice = '';
|
|
119
|
+
while (!['1', '2', '3'].includes(stackChoice)) {
|
|
120
|
+
stackChoice = await prompt(' Enter 1, 2, or 3: ');
|
|
121
|
+
}
|
|
122
|
+
if (stackChoice !== '1') {
|
|
123
|
+
console.log(chalk_1.default.yellow('\n That stack is coming soon! Using Next.js + Supabase + Drizzle.\n'));
|
|
124
|
+
stackChoice = '1';
|
|
125
|
+
}
|
|
126
|
+
// Explain what we're about to create for beginners
|
|
127
|
+
if (isBeginnerMode) {
|
|
128
|
+
console.log(chalk_1.default.blue('\n ═══════════════════════════════════════════════════════════'));
|
|
129
|
+
console.log(chalk_1.default.white.bold(' 📚 What we\'re creating:'));
|
|
130
|
+
console.log(chalk_1.default.blue(' ═══════════════════════════════════════════════════════════\n'));
|
|
131
|
+
console.log(chalk_1.default.gray(' This will create a complete web application with:'));
|
|
132
|
+
console.log(chalk_1.default.gray(' • A website users can visit (Next.js)'));
|
|
133
|
+
console.log(chalk_1.default.gray(' • User signup/login system (Supabase Auth)'));
|
|
134
|
+
console.log(chalk_1.default.gray(' • A database to store data (PostgreSQL via Supabase)'));
|
|
135
|
+
console.log(chalk_1.default.gray(' • Beautiful styling system (Tailwind CSS)'));
|
|
136
|
+
console.log(chalk_1.default.gray(' • Type safety to prevent bugs (TypeScript)\n'));
|
|
137
|
+
console.log(chalk_1.default.gray(' Think of it like a house:'));
|
|
138
|
+
console.log(chalk_1.default.gray(' • Next.js is the structure (walls, roof)'));
|
|
139
|
+
console.log(chalk_1.default.gray(' • Supabase is the utilities (electricity, plumbing)'));
|
|
140
|
+
console.log(chalk_1.default.gray(' • Tailwind is the interior design (paint, furniture)\n'));
|
|
141
|
+
}
|
|
142
|
+
// Get project name
|
|
143
|
+
const defaultName = cwd.split(/[\\/]/).pop() || 'my-project';
|
|
144
|
+
const projectName = await prompt(` Project name (${defaultName}): `) || defaultName;
|
|
145
|
+
console.log(chalk_1.default.green(`\n Creating ${projectName} with Next.js + Supabase + Drizzle...\n`));
|
|
146
|
+
// Create project structure
|
|
147
|
+
const spinner = (0, ora_1.default)(' Creating project structure...').start();
|
|
148
|
+
try {
|
|
149
|
+
// Create directories
|
|
150
|
+
const dirs = [
|
|
151
|
+
'src/app',
|
|
152
|
+
'src/components',
|
|
153
|
+
'src/lib/supabase',
|
|
154
|
+
'src/db',
|
|
155
|
+
'src/db/migrations',
|
|
156
|
+
'src/services',
|
|
157
|
+
'src/types',
|
|
158
|
+
'public',
|
|
159
|
+
];
|
|
160
|
+
for (const dir of dirs) {
|
|
161
|
+
const dirPath = (0, path_1.join)(cwd, dir);
|
|
162
|
+
if (!(0, fs_1.existsSync)(dirPath)) {
|
|
163
|
+
(0, fs_1.mkdirSync)(dirPath, { recursive: true });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
spinner.text = ' Writing configuration files...';
|
|
167
|
+
// Write package.json
|
|
168
|
+
const packageJson = { ...templates.PACKAGE_JSON, name: projectName };
|
|
169
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
170
|
+
// Write .env.example
|
|
171
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, '.env.example'), templates.ENV_EXAMPLE);
|
|
172
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, '.env.local'), templates.ENV_EXAMPLE);
|
|
173
|
+
// Write config files
|
|
174
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'drizzle.config.ts'), templates.DRIZZLE_CONFIG);
|
|
175
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'tailwind.config.ts'), templates.TAILWIND_CONFIG);
|
|
176
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'postcss.config.mjs'), templates.POSTCSS_CONFIG);
|
|
177
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'tsconfig.json'), JSON.stringify(templates.TSCONFIG, null, 2));
|
|
178
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'next.config.ts'), templates.NEXT_CONFIG);
|
|
179
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, '.gitignore'), templates.GITIGNORE);
|
|
180
|
+
spinner.text = ' Writing source files...';
|
|
181
|
+
// Write Supabase files
|
|
182
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'src/lib/supabase/server.ts'), templates.SUPABASE_SERVER);
|
|
183
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'src/lib/supabase/client.ts'), templates.SUPABASE_CLIENT);
|
|
184
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'src/lib/supabase/middleware.ts'), templates.SUPABASE_MIDDLEWARE);
|
|
185
|
+
// Write middleware
|
|
186
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'middleware.ts'), templates.MIDDLEWARE);
|
|
187
|
+
// Write database files
|
|
188
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'src/db/schema.ts'), templates.DB_SCHEMA);
|
|
189
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'src/db/index.ts'), templates.DB_INDEX);
|
|
190
|
+
// Write app files
|
|
191
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'src/app/globals.css'), templates.GLOBALS_CSS);
|
|
192
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'src/app/layout.tsx'), templates.LAYOUT_TSX);
|
|
193
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'src/app/page.tsx'), templates.PAGE_TSX);
|
|
194
|
+
// Write utils
|
|
195
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(cwd, 'src/lib/utils.ts'), templates.UTILS_CN);
|
|
196
|
+
spinner.succeed('Project structure created!');
|
|
197
|
+
// Ask about installing dependencies
|
|
198
|
+
console.log('');
|
|
199
|
+
const installDeps = await confirm(' Install dependencies with npm?');
|
|
200
|
+
if (installDeps) {
|
|
201
|
+
const installSpinner = (0, ora_1.default)(' Installing dependencies (this may take a minute)...').start();
|
|
202
|
+
try {
|
|
203
|
+
(0, child_process_1.execSync)('npm install', { cwd, stdio: 'pipe' });
|
|
204
|
+
installSpinner.succeed('Dependencies installed!');
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
installSpinner.warn('Could not install dependencies automatically');
|
|
208
|
+
console.log(chalk_1.default.gray(' Run `npm install` manually.\n'));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// Success message
|
|
212
|
+
console.log(chalk_1.default.green(`
|
|
213
|
+
╔═══════════════════════════════════════════════════════════╗
|
|
214
|
+
║ ║
|
|
215
|
+
║ ${chalk_1.default.bold('✓ Project scaffolded successfully!')} ║
|
|
216
|
+
║ ║
|
|
217
|
+
╚═══════════════════════════════════════════════════════════╝
|
|
218
|
+
`));
|
|
219
|
+
console.log(chalk_1.default.white(' Project structure:\n'));
|
|
220
|
+
if (isBeginnerMode) {
|
|
221
|
+
console.log(chalk_1.default.gray(' src/'));
|
|
222
|
+
console.log(chalk_1.default.gray(' ├── app/ ') + chalk_1.default.cyan('← Your pages (what users see)'));
|
|
223
|
+
console.log(chalk_1.default.gray(' ├── components/ ') + chalk_1.default.cyan('← Reusable UI pieces (buttons, forms)'));
|
|
224
|
+
console.log(chalk_1.default.gray(' ├── lib/ ') + chalk_1.default.cyan('← Helper code & connections'));
|
|
225
|
+
console.log(chalk_1.default.gray(' │ └── supabase/ ') + chalk_1.default.cyan('← Login & database connection'));
|
|
226
|
+
console.log(chalk_1.default.gray(' ├── db/ ') + chalk_1.default.cyan('← Database structure (tables)'));
|
|
227
|
+
console.log(chalk_1.default.gray(' ├── services/ ') + chalk_1.default.cyan('← Core app logic (what your app does)'));
|
|
228
|
+
console.log(chalk_1.default.gray(' └── types/ ') + chalk_1.default.cyan('← Data shape definitions'));
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
console.log(chalk_1.default.gray(' src/'));
|
|
232
|
+
console.log(chalk_1.default.gray(' ├── app/ ') + chalk_1.default.cyan('← Pages & layouts'));
|
|
233
|
+
console.log(chalk_1.default.gray(' ├── components/ ') + chalk_1.default.cyan('← React components'));
|
|
234
|
+
console.log(chalk_1.default.gray(' ├── lib/ ') + chalk_1.default.cyan('← Utilities & clients'));
|
|
235
|
+
console.log(chalk_1.default.gray(' │ └── supabase/ ') + chalk_1.default.cyan('← Supabase clients (ready!)'));
|
|
236
|
+
console.log(chalk_1.default.gray(' ├── db/ ') + chalk_1.default.cyan('← Database schema & queries'));
|
|
237
|
+
console.log(chalk_1.default.gray(' ├── services/ ') + chalk_1.default.cyan('← Business logic'));
|
|
238
|
+
console.log(chalk_1.default.gray(' └── types/ ') + chalk_1.default.cyan('← TypeScript types'));
|
|
239
|
+
}
|
|
240
|
+
console.log('');
|
|
241
|
+
console.log(chalk_1.default.white(' Next steps:\n'));
|
|
242
|
+
if (isBeginnerMode) {
|
|
243
|
+
console.log(chalk_1.default.cyan(' 1. ') + chalk_1.default.white('Set up Supabase (free database + login):'));
|
|
244
|
+
console.log(chalk_1.default.gray(' Go to https://supabase.com → Create free account → New Project'));
|
|
245
|
+
console.log('');
|
|
246
|
+
console.log(chalk_1.default.cyan(' 2. ') + chalk_1.default.white('Connect your project:'));
|
|
247
|
+
console.log(chalk_1.default.gray(' Open .env.local file and paste your Supabase credentials'));
|
|
248
|
+
console.log(chalk_1.default.gray(' (Found in Supabase: Settings → API)'));
|
|
249
|
+
console.log('');
|
|
250
|
+
console.log(chalk_1.default.cyan(' 3. ') + chalk_1.default.white('Start your app:'));
|
|
251
|
+
console.log(chalk_1.default.gray(' Run: npm run dev'));
|
|
252
|
+
console.log(chalk_1.default.gray(' Open: http://localhost:3000 in your browser'));
|
|
253
|
+
console.log('');
|
|
254
|
+
console.log(chalk_1.default.cyan(' 4. ') + chalk_1.default.white('Add AI superpowers:'));
|
|
255
|
+
console.log(chalk_1.default.gray(' Run: codebakers init'));
|
|
256
|
+
console.log(chalk_1.default.gray(' Now AI will follow professional coding patterns!\n'));
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
console.log(chalk_1.default.cyan(' 1. ') + chalk_1.default.gray('Update .env.local with your Supabase credentials'));
|
|
260
|
+
console.log(chalk_1.default.cyan(' 2. ') + chalk_1.default.gray('Run `npm run dev` to start development'));
|
|
261
|
+
console.log(chalk_1.default.cyan(' 3. ') + chalk_1.default.gray('Run `codebakers init` to add CodeBakers patterns'));
|
|
262
|
+
console.log(chalk_1.default.cyan(' 4. ') + chalk_1.default.gray('Start building with AI assistance!\n'));
|
|
263
|
+
console.log(chalk_1.default.white(' Supabase setup:\n'));
|
|
264
|
+
console.log(chalk_1.default.gray(' 1. Create a project at https://supabase.com'));
|
|
265
|
+
console.log(chalk_1.default.gray(' 2. Go to Settings → API'));
|
|
266
|
+
console.log(chalk_1.default.gray(' 3. Copy URL and anon key to .env.local'));
|
|
267
|
+
console.log(chalk_1.default.gray(' 4. Go to Settings → Database → Connection string'));
|
|
268
|
+
console.log(chalk_1.default.gray(' 5. Copy DATABASE_URL to .env.local\n'));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
catch (error) {
|
|
272
|
+
spinner.fail('Project scaffolding failed');
|
|
273
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
274
|
+
console.log(chalk_1.default.red(`\n Error: ${message}\n`));
|
|
275
|
+
process.exit(1);
|
|
276
|
+
}
|
|
277
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ const init_js_1 = require("./commands/init.js");
|
|
|
12
12
|
const serve_js_1 = require("./commands/serve.js");
|
|
13
13
|
const mcp_config_js_1 = require("./commands/mcp-config.js");
|
|
14
14
|
const setup_js_1 = require("./commands/setup.js");
|
|
15
|
+
const scaffold_js_1 = require("./commands/scaffold.js");
|
|
15
16
|
const program = new commander_1.Command();
|
|
16
17
|
program
|
|
17
18
|
.name('codebakers')
|
|
@@ -26,6 +27,11 @@ program
|
|
|
26
27
|
.command('init')
|
|
27
28
|
.description('Interactive project setup wizard')
|
|
28
29
|
.action(init_js_1.init);
|
|
30
|
+
program
|
|
31
|
+
.command('scaffold')
|
|
32
|
+
.alias('new')
|
|
33
|
+
.description('Create a new project with full stack scaffolding (Next.js + Supabase + Drizzle)')
|
|
34
|
+
.action(scaffold_js_1.scaffold);
|
|
29
35
|
program
|
|
30
36
|
.command('login')
|
|
31
37
|
.description('Login with your API key')
|