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
13 changes: 6 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
node-version-file: ".node-version"
cache: "npm"
bun-version: latest

- name: Install dependencies
run: npm ci
run: bun install --frozen-lockfile

- name: Run ESLint
run: npm run lint
- name: Run Biome
run: bun run lint
12 changes: 7 additions & 5 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ jobs:
cache: "npm"
registry-url: "https://registry.npmjs.org"

- name: Update npm
run: npm install -g npm@latest
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install dependencies
run: npm ci
run: bun install --frozen-lockfile

- name: Check if version needs to be bumped
id: check-version
Expand Down Expand Up @@ -143,7 +145,7 @@ jobs:
--allowedTools Bash(git log:*),Bash(gh pr:*),Read(*),Edit(CHANGELOG.md)

- name: Build package
run: npm run build
run: bun run build

- name: Show package info
run: |
Expand Down Expand Up @@ -171,7 +173,7 @@ jobs:
git config --local user.name "GitHub Action"
# Re-configure git remote to use the App token for push
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git"
git add package.json package-lock.json
git add package.json
# Add CHANGELOG.md only if changelog update was requested
if [[ "${{ github.event.inputs.update_changelog }}" == "true" ]]; then
git add CHANGELOG.md
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/preview-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ jobs:
cache: "npm"
registry-url: "https://registry.npmjs.org"

- name: Update npm
run: npm install -g npm@latest
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install dependencies
run: npm install
run: bun install --frozen-lockfile

- name: Build package
run: npm run build
run: bun run build

- name: Generate preview package name and version
id: preview_info
Expand Down
17 changes: 7 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
node-version-file: ".node-version"
cache: "npm"
bun-version: latest
cache: true

# We need to install again to get correct binary dependencies for github actions
- name: Install dependencies
run: |
rm -f package-lock.json
npm install
run: bun install --frozen-lockfile

- name: Build
run: npm run build
run: bun run build

- name: Run tests
run: npm test
run: bun run test

12 changes: 6 additions & 6 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
node-version-file: ".node-version"
cache: "npm"
bun-version: latest
cache: true

- name: Install dependencies
run: npm ci
run: bun install --frozen-lockfile

- name: Run typecheck
run: npm run typecheck
run: bun run typecheck
42 changes: 24 additions & 18 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ The Base44 CLI is a TypeScript-based command-line tool built with:
- **Zod** - Schema validation for API responses, config files, and user inputs
- **JSON5** - Parsing JSONC/JSON5 config files (supports comments and trailing commas)
- **TypeScript** - Primary language
- **tsdown** - Bundler (powered by Rolldown, the Rust-based Rollup successor)
- **Bun** - Runtime, bundler, and package manager
- **Biome** - Linting and formatting (fast, replaces ESLint)
- **Vitest** - Test runner

### Distribution Strategy
The CLI is distributed as a **zero-dependency package**. All runtime dependencies are bundled into JavaScript files. This means:
The CLI is distributed as a **zero-dependency npm package**. All runtime dependencies are bundled into JavaScript files. This means:
- Users only download the bundled code (`dist/` and `bin/` directories)
- No dependency resolution or node_modules installation
- Faster install times and no version conflicts
Expand All @@ -33,7 +35,7 @@ The CLI is distributed as a **zero-dependency package**. All runtime dependencie
cli/
├── bin/ # Entry point scripts
│ ├── run.js # Production entry (imports dist/index.js)
│ └── dev.js # Development entry (uses tsx for TypeScript)
│ └── dev.ts # Development entry (Bun runs TypeScript directly)
├── src/
│ ├── core/
│ │ ├── api/ # HTTP clients
Expand Down Expand Up @@ -645,7 +647,7 @@ Set the environment variable: `BASE44_DISABLE_TELEMETRY=1`

## Important Rules

1. **npm only** - Never use yarn
1. **Bun for development** - Use `bun` commands (not npm/yarn) for install, test, build during development
2. **Zod validation** - Required for all external data (API responses, config files)
3. **@clack/prompts** - For all user interaction (prompts, spinners, logs)
4. **ES Modules** - Use `.js` extensions in imports
Expand All @@ -666,12 +668,14 @@ Set the environment variable: `BASE44_DISABLE_TELEMETRY=1`
## Development

```bash
npm run build # tsdown - bundles to dist/index.js
npm run typecheck # tsc --noEmit - type checking only
npm run dev # runs ./bin/dev.js (tsx for direct TypeScript execution)
npm run start # runs ./bin/run.js (production, requires build first)
npm test # vitest
npm run lint # eslint
bun install # Install dependencies
bun run build # bun build - bundles to dist/index.js + copies templates
bun run typecheck # tsc --noEmit - type checking only
bun run dev # runs ./bin/dev.ts (Bun runs TypeScript directly)
bun run start # runs ./bin/run.js (production, requires build first)
bun run test # Run tests with vitest (note: use `bun run test`, not `bun test`)
bun run lint # Biome - linting, formatting, and import organization
bun run lint:fix # Biome - auto-fix lint and format issues
```

### Debugging
Expand All @@ -688,12 +692,13 @@ The CLI uses a split architecture for better development experience:

**Production** (`./bin/run.js`):
- Used when installed via npm (`base44` command)
- Uses `#!/usr/bin/env node` shebang for Node.js compatibility
- Imports from bundled `dist/index.js`
- Requires `npm run build` first
- Requires `bun run build` first

**Development** (`./bin/dev.js`):
- Used during development (`npm run dev`)
- Uses `tsx` shebang to run TypeScript directly from `src/cli/index.ts`
**Development** (`./bin/dev.ts`):
- Used during development (`bun run dev`)
- Uses `#!/usr/bin/env bun` shebang to run TypeScript directly
- No build step required - changes are reflected immediately

**CLI Module** (`src/cli/`):
Expand All @@ -712,9 +717,10 @@ The CLI uses a split architecture for better development experience:
6. Telemetry can be disabled via `BASE44_DISABLE_TELEMETRY=1` environment variable
7. Telemetry includes `error_code` and `is_user_error` properties for all errors

### Node.js Version
### Prerequisites

This project requires Node.js >= 20.19.0. A `.node-version` file is provided for fnm/nodenv.
- **Bun**: Install via `curl -fsSL https://bun.sh/install | bash`
- **Node.js >= 20.19.0**: Still needed for npm publishing (`.node-version` file provided)

### CLI Utilities

Expand All @@ -739,7 +745,7 @@ await runTask("Installing...", async () => {

## Testing

**Build before testing**: Tests import the bundled `dist/index.js`, so run `npm run build && npm test`.
**Build before testing**: Tests import the bundled `dist/index.js`, so run `bun run build && bun run test`.

### Test Structure

Expand Down Expand Up @@ -843,7 +849,7 @@ t.api.mockSiteDeployError({ status: 413, body: { error: "..." } });

### Testing Rules

1. **Build first** - Run `npm run build` before `npm test`
1. **Build first** - Run `bun run build` before `bun test`
2. **Use fixtures** - Don't create project structures in tests
3. **Fixtures need `.app.jsonc`** - Add `base44/.app.jsonc` with `{ "id": "test-app-id" }`
4. **Interactive prompts can't be tested** - Only test via non-interactive flags
2 changes: 1 addition & 1 deletion bin/dev.js → bin/dev.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env tsx
#!/usr/bin/env bun
import { runCLI } from "../src/cli/index.ts";

// Disable Clack spinners and animations in non-interactive environments.
Expand Down
67 changes: 67 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"$schema": "https://biomejs.dev/schemas/2.3.13/schema.json",
"assist": {
"actions": {
"source": {
"organizeImports": {
"level": "on",
"options": {
"groups": [":NODE:", ":PACKAGE:", ":ALIAS:", ":PATH:"]
}
}
}
}
},
"files": {
"includes": ["**", "!**/dist/**", "!**/node_modules/**", "!**/tests/fixtures/**", "!**/*.d.ts"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 80
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"complexity": {
"noUselessUndefinedInitialization": "error",
"useLiteralKeys": "error",
"useOptionalChain": "error",
"noUselessStringRaw": "error"
},
"correctness": {
"noUnusedImports": "error",
"noUnusedVariables": "warn"
},
"style": {
"useConst": "error",
"useTemplate": "error",
"useShorthandAssign": "error",
"useImportType": "error",
"useExportType": "error",
"useSingleVarDeclarator": "error",
"noUselessElse": "error",
"useNodejsImportProtocol": "error",
"noNonNullAssertion": "off",
"useArrayLiterals": "error",
"useConsistentArrayType": { "level": "error", "options": { "syntax": "shorthand" } }
},
"suspicious": {
"noExplicitAny": "warn",
"noVar": "error",
"noConsole": { "level": "off", "options": { "allow": ["log"] } },
"noIrregularWhitespace": "error"
},
"nursery": {}
}
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"trailingCommas": "es5",
"semicolons": "always"
}
}
}
Loading
Loading