Add boolean type conversion support for environment variables#144
Add boolean type conversion support for environment variables#144
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Co-authored-by: yamcodes <2014360+yamcodes@users.noreply.github.com>
examples/basic/package.json
Outdated
| }, | ||
| "dependencies": { | ||
| "arkenv": "^0.5.0", | ||
| "arkenv": "workspace:*", |
There was a problem hiding this comment.
This should be numbered not workspace:*, for workspace dependencies we have a playground folder. @copilot
There was a problem hiding this comment.
I understand the preference for numbered versions in examples, but there's a circular dependency issue: the basic example now demonstrates the new string.boolean functionality I added in this PR, which isn't published yet (still in version 0.6.0).
Should I:
- Remove the boolean example from the basic example and use numbered versions
- Keep workspace:* for examples that demonstrate new unpublished features
- Create separate examples for published vs unpublished features
Which approach would you prefer?
examples/with-bun/package.json
Outdated
| }, | ||
| "dependencies": { | ||
| "arkenv": "^0.5.0", | ||
| "arkenv": "workspace:*", |
There was a problem hiding this comment.
This should be numbered not workspace:*, for workspace dependencies we have a playground folder. @copilot
There was a problem hiding this comment.
Fixed in 8d4df91. Reverted to numbered versions (arkenv@0.6.0) and moved new boolean functionality demo to playground folder.
| "dependencies": { | ||
| "@arkenv/vite-plugin": "^0.0.8", | ||
| "arkenv": "^0.5.0", | ||
| "@arkenv/vite-plugin": "workspace:*", | ||
| "arkenv": "workspace:*", |
There was a problem hiding this comment.
This should be numbered not workspace:*, for workspace dependencies we have a playground folder. @copilot
There was a problem hiding this comment.
Fixed in 8d4df91. Reverted to numbered versions (arkenv@0.6.0, @arkenv/vite-plugin@0.0.9) and moved new boolean functionality demo to playground folder.
pnpm-workspace.yaml
Outdated
| packages: | ||
| - 'packages/*' | ||
| - 'apps/*' | ||
| - 'examples/*' |
There was a problem hiding this comment.
Fixed in 8d4df91. Removed examples from pnpm-workspace.yaml as requested.
Co-authored-by: yamcodes <2014360+yamcodes@users.noreply.github.com>
packages/arkenv/src/scope.ts
Outdated
| string: type.module({ | ||
| ...type.keywords.string, | ||
| host, | ||
| boolean, |
There was a problem hiding this comment.
I'd probably just export it in the boolean module, so that we can use:
import arkenv from "arkenv";
const env = arkenv({
HOST: "string.host",
PORT: "number.port",
NODE_ENV: "'development' | 'production' | 'test' = 'development'",
SOME_FLAG: "boolean",
});
// Automatically validate and parse process.env
// TypeScript knows the ✨exact✨ types!
console.log(env.HOST); // (property) HOST: string
console.log(env.PORT); // (property) PORT: number
console.log(env.NODE_ENV); // (property) NODE_ENV: "development" | "production" | "test"
console.log(env.SOME_FLAG); // (property) SOME_FLAG: boolean
export default env;And in an options we should be able to turn off this coercion behvaior (morphed by default)
@copilot
There was a problem hiding this comment.
Implemented in 85a643a. The boolean type is now exported directly in the scope, so you can use both:
const env = arkenv({
SOME_FLAG: "boolean", // Direct usage
DEBUG_MODE: "string.boolean", // Still available
});Both approaches provide the same boolean coercion functionality (accepting "true", "false", "1", "0", "yes", "no", "on", "off"). Added comprehensive test coverage and updated the playground to demonstrate both usage patterns.
There was a problem hiding this comment.
We don't need "string.boolean" @copilot
There was a problem hiding this comment.
Removed string.boolean support as requested. Now only direct "boolean" usage is available. All tests updated and passing (2d8f698).
…ew features to playground Co-authored-by: yamcodes <2014360+yamcodes@users.noreply.github.com>
Co-authored-by: yamcodes <2014360+yamcodes@users.noreply.github.com>
Co-authored-by: yamcodes <2014360+yamcodes@users.noreply.github.com>
Co-authored-by: yamcodes <2014360+yamcodes@users.noreply.github.com>
Co-authored-by: yamcodes <2014360+yamcodes@users.noreply.github.com>
|
Closed in favor of #218. |
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.