Skip to content
Merged
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
4 changes: 3 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ BASE APP STRUCTURE:

## Repository Structure Guidance
When scaffolding implementation, use:
- `betterbase/apps/cli` → `bb` CLI project
- `betterbase/packages/cli` → canonical `bb` CLI implementation
- `betterbase/apps/cli` → legacy wrapper/stub (delegates to package CLI)
- `betterbase/apps/dashboard` → dashboard app
- `betterbase/packages/core` → backend/core engine
- `betterbase/packages/client` → `@betterbase/client`
Expand All @@ -60,6 +61,7 @@ When scaffolding implementation, use:
3. Prefer small, composable files and clear package boundaries.
4. Avoid introducing lock-in assumptions that conflict with BetterBase goals.
5. When uncertain, bias toward the blueprint and reuse strategy docs.
6. Ensure new templates follow the persistent project prompt above.

## Quality & Validation
- Run lightweight checks whenever possible (format/lint/typecheck when available).
Expand Down
1 change: 1 addition & 0 deletions betterbase/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ dist
.next
.env
.env.*
Comment thread
coderabbitai[bot] marked this conversation as resolved.
!.env.example
.DS_Store
5 changes: 3 additions & 2 deletions betterbase/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ Initial BetterBase monorepo scaffold with a concrete base template.

## Structure

- `apps/cli` — `bb` CLI
- `apps/cli` — legacy CLI wrapper/stub
- `apps/dashboard` — dashboard/studio app
- `packages/cli` — canonical `@betterbase/cli` implementation
- `packages/core` — core backend engine
- `packages/client` — SDK (`@betterbase/client`)
- `packages/shared` — shared utilities/types
Expand All @@ -20,7 +21,7 @@ Initial BetterBase monorepo scaffold with a concrete base template.

## Base Template Commands

From `betterbase/templates/base`:
From `templates/base`:

- `bun run dev`
- `bun run db:generate`
Expand Down
6 changes: 6 additions & 0 deletions betterbase/apps/cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# @betterbase/cli-legacy

This package is a legacy wrapper placeholder.

- Canonical CLI implementation: `betterbase/packages/cli` (`@betterbase/cli`)
- This package exists only for backwards compatibility and forwards execution.
6 changes: 3 additions & 3 deletions betterbase/apps/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@betterbase/cli",
"name": "@betterbase/cli-legacy",
"version": "0.0.0",
"private": true,
"type": "module",
"bin": {
"bb": "./dist/index.js"
"bb-legacy": "./dist/index.js"
},
"scripts": {
"build": "tsc -p tsconfig.json",
"build": "bun build ./src/index.ts --outfile ./dist/index.js --target bun",
"dev": "bun run src/index.ts",
"typecheck": "tsc -p tsconfig.json --noEmit"
}
Expand Down
14 changes: 13 additions & 1 deletion betterbase/apps/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#!/usr/bin/env node

console.log('BetterBase CLI scaffold: bb');
/**
* Legacy bb wrapper entrypoint.
*
* Forwards execution to the canonical CLI implementation in packages/cli.
*/
export async function runLegacyCli(): Promise<void> {
const cliModule = await import('../../../packages/cli/src/index');
await cliModule.runCli(process.argv);
}

if (import.meta.main) {
await runLegacyCli();
Comment on lines +1 to +14
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Shebang declares node but import.meta.main is Bun-only.

Line 1 uses #!/usr/bin/env node, but import.meta.main (line 13) is a Bun-specific API — Node.js does not set this property, so when invoked via Node the CLI will silently do nothing. Either switch the shebang to bun or add a Node-compatible main-module check as a fallback.

Suggested fix (option A — align shebang with Bun)
-#!/usr/bin/env node
+#!/usr/bin/env bun
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#!/usr/bin/env node
/**
* Legacy bb wrapper entrypoint.
*
* Forwards execution to the canonical CLI implementation in packages/cli.
*/
export async function runLegacyCli(): Promise<void> {
const cliModule = await import('../../../packages/cli/src/index');
await cliModule.runCli(process.argv);
}
if (import.meta.main) {
await runLegacyCli();
#!/usr/bin/env bun
/**
* Legacy bb wrapper entrypoint.
*
* Forwards execution to the canonical CLI implementation in packages/cli.
*/
export async function runLegacyCli(): Promise<void> {
const cliModule = await import('../../../packages/cli/src/index');
await cliModule.runCli(process.argv);
}
if (import.meta.main) {
await runLegacyCli();
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@betterbase/apps/cli/src/index.ts` around lines 1 - 14, The script uses a
Bun-only main check (import.meta.main) while the shebang names node, so Node
invocations will no-op; update the entry-point to detect both Bun and Node by
keeping or changing the shebang and adding a Node-compatible main-module check
alongside import.meta.main (e.g., in the module that defines runLegacyCli(), use
the Node ESM pattern with fileURLToPath(import.meta.url) and compare to
process.argv[1] or require.main equivalently) and then call await runLegacyCli()
when either import.meta.main or the Node check indicates this file is the entry;
reference runLegacyCli and import.meta.main when making the change.

}
155 changes: 155 additions & 0 deletions betterbase/packages/cli/bun.lockb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions betterbase/packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@betterbase/cli",
"version": "0.1.0",
"private": true,
"type": "module",
"bin": {
"bb": "./dist/index.js"
},
"scripts": {
"build": "bun run src/build.ts",
"dev": "bun run src/index.ts",
"test": "bun test",
"typecheck": "tsc -p tsconfig.json --noEmit"
},
"dependencies": {
"chalk": "^5.3.0",
"commander": "^12.1.0",
"inquirer": "^10.2.2",
"zod": "^3.23.8"
},
"devDependencies": {
"@types/bun": "^1.3.9",
"typescript": "^5.6.0"
}
}
24 changes: 24 additions & 0 deletions betterbase/packages/cli/src/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Build the CLI as a standalone bundled executable output.
*/
export async function buildStandaloneCli(): Promise<void> {
const result = await Bun.build({
entrypoints: ['./src/index.ts'],
outdir: './dist',
target: 'bun',
format: 'esm',
minify: false,
sourcemap: 'external',
naming: 'index.js',
});

if (!result.success) {
throw new Error(`Build failed with ${result.logs.length} error(s).`);
}

const outputPath = './dist/index.js';
const compiled = await Bun.file(outputPath).text();
await Bun.write(outputPath, `#!/usr/bin/env bun\n${compiled}`);
}

await buildStandaloneCli();
Loading