Skip to content

make appConfig not global and migrate to bun tests#278

Open
kfirstri wants to merge 5 commits intomainfrom
migrate-to-bun-test
Open

make appConfig not global and migrate to bun tests#278
kfirstri wants to merge 5 commits intomainfrom
migrate-to-bun-test

Conversation

@kfirstri
Copy link
Collaborator

@kfirstri kfirstri commented Feb 19, 2026

Note

Description

Migrates the test runner from Vitest to Bun's native bun:test, removing the Vitest dependency entirely. Also refactors the global appConfig cache pattern into a scoped withAppConfig() helper, eliminating mutable module-level state and making app config accessible via context.appConfig in CLIContext.

Related Issue

None

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe): Test runner migration (Vitest → Bun Test) + app config state refactor + Bun compatibility fixes

Changes Made

  • Test runner migration: Replaced Vitest with Bun's native bun:test across all test files; removed vitest devDependency and vitest.config.ts; added bunfig.toml for test timeout config; updated package.json scripts (bun run testbun test)
  • App config state refactor: Replaced global mutable setAppConfig()/initAppConfig() cache with a scoped withAppConfig(config, fn) helper that restores previous state after execution; renamed initAppConfig() to resolveAppConfig() (pure, no caching); added appConfig?: AppConfig to CLIContext so commands access it via context rather than a global
  • Schema rename: AppConfigSchema/AppConfig (file schema) renamed to AppConfigFileSchema/AppConfigFile to avoid collision with the new exported AppConfig type ({ id, projectRoot })
  • getDashboardUrl signature change: Now requires an explicit projectId argument instead of optionally falling back to the global app config cache
  • Bun stream compatibility fix: downloadProject now uses arrayBuffer() + Readable.from(buffer) instead of Readable.fromWeb(), fixing tar extraction failures under Bun
  • homedir() fix: getBase44GlobalDir now reads process.env.HOME directly before falling back to os.homedir(), working around Bun's cached homedir() value
  • Test infrastructure: Removed vi.resetModules() per test; CLI module is now loaded once and cached (loadProgram()); updated vi.mock() calls to use factory functions compatible with bun:test
  • README/docs: Added connectors pull/push, eject, and types generate to the command table; updated testing docs to reference bun test

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (npm test)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated docs/ (AGENTS.md) if I made architectural changes

Additional Notes

The withAppConfig() scoped pattern is safer than the previous global cache because it automatically restores the previous config when the callback completes or throws, preventing state leakage between tests. The CLITestkit no longer calls vi.resetModules() on each test run, instead reusing a single cached module import — this is both faster and required since bun:test does not support vi.resetModules() the same way Vitest did.


🤖 Generated by Claude | 2026-02-19 14:48 UTC

@kfirstri kfirstri self-assigned this Feb 19, 2026
@claude
Copy link

claude bot commented Feb 19, 2026

README check ran. 4 issue(s) found and applied: added missing connectors pull, connectors push, and types generate commands to the command table; uncommented and corrected the eject entry (description was inaccurate). README.md has been updated in this branch.

@kfirstri kfirstri force-pushed the migrate-to-bun-test branch from 2b91601 to 5aaca3d Compare February 19, 2026 14:32
@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.0.33-pr.278.bb8cb20

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.0.33-pr.278.bb8cb20"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.0.33-pr.278.bb8cb20"
  }
}

Preview published to npm registry — try new features instantly!

@claude
Copy link

claude bot commented Feb 19, 2026

README check ran. 3 issue(s) found and applied: added missing connectors pull and connectors push rows, added missing types generate row, uncommented and corrected description for eject. README.md has been updated in this branch.

@claude
Copy link

claude bot commented Feb 19, 2026

README check ran. No issues found — all commands, descriptions, installation info, and quick start examples are accurate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments