Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stacksjs/bunfig
💡 Lightweight & smart Bun configuration loader.
https://github.com/stacksjs/bunfig
bun config library loader typescript
Last synced: 1 day ago
JSON representation
💡 Lightweight & smart Bun configuration loader.
- Host: GitHub
- URL: https://github.com/stacksjs/bunfig
- Owner: stacksjs
- License: mit
- Created: 2024-10-19T20:32:45.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-12-20T15:30:55.000Z (7 days ago)
- Last Synced: 2024-12-20T16:28:47.532Z (7 days ago)
- Topics: bun, config, library, loader, typescript
- Language: TypeScript
- Homepage: https://bunfig.netlify.app
- Size: 897 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
[![npm version][npm-version-src]][npm-version-href]
[![GitHub Actions][github-actions-src]][github-actions-href]
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)## Features
- Smart configuration loader
- Lightweight & zero-dependency
- Fully typed## Install
```bash
bun install -d bun-config
```## Get Started
If you are building any sort of Bun project, you can use the `loadConfig` function to load your configuration.
```ts
import type { Config } from 'bunfig'
import { loadConfig } from 'bunfig'interface MyLibraryConfig {
port: number
host: string
}const options: Config = {
name: 'my-app', // required
cwd: './', // default: process.cwd()
defaults: { // default: {}
port: 3000,
host: 'localhost',
},
}const resolvedConfig = await loadConfig(options)
console.log(resolvedConfig) // { port: 3000, host: 'localhost' }, unless a config file is found
```> [!TIP]
> If your process.cwd() includes a `$name.config.{ts,js,mjs,cjs}` file, it will be loaded and merged with the defaults, with file config file values taking precedence.## Testing
```bash
bun test
```## Changelog
Please see our [releases](https://github.com/stacksjs/stacks/releases) page for more information on what has changed recently.
## Contributing
Please review the [Contributing Guide](https://github.com/stacksjs/contributing) for details.
## Community
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
[Discussions on GitHub](https://github.com/stacksjs/stacks/discussions)
For casual chit-chat with others using this package:
[Join the Stacks Discord Server](https://discord.gg/stacksjs)
## Postcardware
Two things are true: Stacks OSS will always stay open-source, and we do love to receive postcards from wherever Stacks is used! 🌍 _We also publish them on our website. And thank you, Spatie_
Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094
## Sponsors
We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.
- [JetBrains](https://www.jetbrains.com/)
- [The Solana Foundation](https://solana.com/)## Credits
- [Chris Breuer](https://github.com/chrisbbreuer)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/bun-config/tree/main/LICENSE.md) for more information.
Made with 💙
[npm-version-src]: https://img.shields.io/npm/v/bun-config?style=flat-square
[npm-version-href]: https://npmjs.com/package/bun-config
[github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/bun-config/ci.yml?style=flat-square&branch=main
[github-actions-href]: https://github.com/stacksjs/bun-config/actions?query=workflow%3Aci