bun
dev_tool.services.bun
__all__ = ['BunService', 'BunWatcherRunner']
module-attribute
BunWatcherRunner
Bases: BaseProcessRunner
A class for running a Bun build watcher.
This class handles starting, monitoring, and stopping a Bun watch process in both local and containerized environments.
Source code in dev_tool/services/runner/base.py
BunService
Bases: BaseService
A service class for Bun/JavaScript operations.
This class provides methods for managing JavaScript packages, running tests, linting, and type checking.
The constructor for the BunService class.
Parameters:
-
runner(CommandRunnerProtocol) –The command runner for executing commands.
-
config(dict[str, Any] | None, default:None) –The configuration dictionary for Bun settings.
Source code in dev_tool/services/bun/service.py
runner = runner
instance-attribute
config = config or {}
instance-attribute
test_directories = self.config.get('test_directories', ['tests/js'])
instance-attribute
source_directories = self.config.get('source_directories', ['static/js'])
instance-attribute
build
A method that builds JavaScript bundles.
Raises:
-
BunBuildError–If the build fails.
Source code in dev_tool/services/bun/service.py
create_runner
A method that creates a Bun watcher runner.
Returns:
-
BunWatcherRunner | None–A watcher runner if a dev script exists, None otherwise.
Source code in dev_tool/services/bun/service.py
format_code
A method that formats JavaScript/TypeScript code.
Parameters:
-
check_only(bool, default:False) –Whether to only check formatting without making changes.
Source code in dev_tool/services/bun/service.py
install_dependencies
A method that installs JavaScript dependencies.
Parameters:
-
frozen(bool, default:False) –Whether to use frozen lockfile (for CI).
Raises:
-
BunInstallError–If installation fails.
Source code in dev_tool/services/bun/service.py
install_package
A method that installs a single JavaScript package.
Parameters:
-
package(str) –The name of the package to install.
-
dev(bool, default:False) –Whether to install as a dev dependency.
Raises:
-
BunInstallError–If installation fails.
Source code in dev_tool/services/bun/service.py
is_available
A method that checks if Bun is available.
Returns:
-
bool–True if Bun is available, False otherwise.
lint
A method that runs the linter on JavaScript/TypeScript code.
Parameters:
-
fix(bool, default:False) –Whether to automatically fix linting issues.
Raises:
-
BunLintError–If linting fails with errors.
Source code in dev_tool/services/bun/service.py
outdated
A method that checks for outdated packages.
Source code in dev_tool/services/bun/service.py
run_tests
A method that runs JavaScript tests using Bun's test runner.
Parameters:
-
watch(bool, default:False) –Whether to run tests in watch mode.
-
coverage(bool, default:False) –Whether to collect coverage.
-
bail(bool, default:False) –Whether to stop on first failure.
Raises:
-
BunTestError–If tests fail.
Source code in dev_tool/services/bun/service.py
uninstall_package
A method that uninstalls a JavaScript package.
Parameters:
-
package(str) –The name of the package to uninstall.
Source code in dev_tool/services/bun/service.py
upgrade_packages
A method that upgrades all JavaScript packages to their latest versions.