Conversation
This commit introduces a new playground application within the 'apps' directory, allowing users to experiment with ArkEnv. The playground includes TypeScript configuration, a README, and example usage of environment variable validation. Additionally, dependencies have been updated to support the new app.
This commit updates the `index.ts` file by removing the export of types, streamlining the default export to only include environment-related functionalities. This change simplifies the module's interface and focuses on core features.
🦋 Changeset detectedLatest commit: ae9d0e1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded@yamcodes has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 36 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (22)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This commit updates the `biome.jsonc` file to include the `playground` directory in the linter's includes, enhancing the linting coverage for example files within the playground.
This commit updates the ArkType peer dependency in the pnpm-lock.yaml and package.json files to version ^2.1.22 for compatibility with the latest version of ArkEnv. Additionally, the index.ts file has been refactored to streamline type imports.
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (6)
examples/basic/package.json (1)
6-7: Scripts update looks good; consider adding a .env.exampleUsing
tsx --env-file .envis correct. To improve DX, include a minimal.env.exampleinexamples/basicso users know expected keys.apps/playground/README.md (1)
1-6: Add quick-start commandsConsider adding run commands for clarity:
pnpm -w --filter playground devpnpm -w --filter playground startpackages/arkenv/src/scope.test.ts (2)
17-20: Use an unambiguously invalid host for the failure test."invalid-host" could be a valid single-label hostname. Prefer an obviously invalid value.
- expect(() => hostType.assert({ HOST: "invalid-host" })).toThrow(); + expect(() => hostType.assert({ HOST: "256.256.256.256" })).toThrow();
28-31: Add boundary tests for ports.Cover 0 and 65535 (valid) and a negative (invalid).
it("should throw for invalid port", () => { const portType = $.type({ PORT: "number.port" }); expect(() => portType.assert({ PORT: "99999" })).toThrow(); }); + + it("should accept boundary ports", () => { + const t = $.type({ PORT: "number.port" }); + expect(t.assert({ PORT: "0" }).PORT).toBe(0); + expect(t.assert({ PORT: "65535" }).PORT).toBe(65535); + }); + + it("should reject negative ports", () => { + const t = $.type({ PORT: "number.port" }); + expect(() => t.assert({ PORT: "-1" })).toThrow(); + });packages/arkenv/src/scope.ts (1)
4-4: Prefer durable docs over ephemeral links.Consider summarizing the
$naming rationale inline or linking to repo docs instead of a Discord message.packages/arkenv/src/create-env.ts (1)
10-15: Tighten JSDoc wording.Return is the validated environment object, not “schema.”
- * @returns The validated environment variable schema + * @returns The validated environment object
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (14)
.changeset/dull-socks-return.md(1 hunks)apps/playground/README.md(1 hunks)apps/playground/index.ts(1 hunks)apps/playground/package.json(1 hunks)apps/playground/tsconfig.json(1 hunks)arkenv.code-workspace(1 hunks)biome.jsonc(1 hunks)examples/basic/package.json(1 hunks)packages/arkenv/package.json(2 hunks)packages/arkenv/src/create-env.ts(1 hunks)packages/arkenv/src/index.ts(1 hunks)packages/arkenv/src/scope.test.ts(1 hunks)packages/arkenv/src/scope.ts(1 hunks)packages/arkenv/tsconfig.json(0 hunks)
💤 Files with no reviewable changes (1)
- packages/arkenv/tsconfig.json
🧰 Additional context used
📓 Path-based instructions (1)
**/*.test.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.test.ts: Name test files with the .test.ts suffix and colocate them alongside the source files they cover
Use Vitest's describe/it structure in tests
Mock process.env in tests that depend on environment variables and restore the original environment in setup/teardown
Test both success and failure cases for environment validation and validators
Verify both runtime behavior and TypeScript types in tests (e.g., with type assertions)
Files:
packages/arkenv/src/scope.test.ts
🪛 markdownlint-cli2 (0.17.2)
.changeset/dull-socks-return.md
5-5: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
11-11: Unordered list indentation
Expected: 0; Actual: 2
(MD007, ul-indent)
12-12: Unordered list indentation
Expected: 0; Actual: 2
(MD007, ul-indent)
45-45: Unordered list indentation
Expected: 0; Actual: 2
(MD007, ul-indent)
🔇 Additional comments (11)
packages/arkenv/package.json (2)
49-49: Peer dep bump to ArkType ^2.1.22 makes senseMatches the new scope/token usage.
20-22: Workspace “fix” script correctly delegates to the root and won’t recurse
The root package.json defines"fix": "biome check --write .";pnpm -w run fixinvokes that root script, not this package’s own, so there’s no recursion.biome.jsonc (1)
65-65: Include playground in override — LGTMExtending the override to
**/playground/**/*is appropriate for relaxed console rules there.arkenv.code-workspace (1)
23-26: Workspace folder addition — LGTMPlayground entry aligns with repo structure.
packages/arkenv/src/scope.test.ts (2)
5-15: LGTM: happy-path host validation looks solid.
22-26: LGTM: port coercion and assertion behave as expected.apps/playground/index.ts (2)
3-7: LGTM: schema uses the new string.host/number.port tokens.
6-6: Defaultable union default syntax is supported.
ArkType allows= 'value'defaults on string union properties in object schemas, so the existingNODE_ENVline is valid.packages/arkenv/src/scope.ts (1)
9-18: LGTM: clean composition of root scope with string.host and number.port.packages/arkenv/src/create-env.ts (2)
16-24: Overload design reads well and preserves inference.
24-34: Error guard: confirm instanceof works across bundlers.Some setups can break instanceof checks on cross-bundle classes. If issues arise, consider a predicate from arktype (if available) or shape-checking.
This commit modifies the examples in the README and various documentation files to replace the usage of `host` and `port` with string literals for `HOST` and `PORT`. This change enhances clarity by providing explicit example values, improving the overall understanding of environment variable configuration in ArkEnv.
This commit introduces the `tsx` dependency at version ^4.20.5 in the `playground` app's package.json and updates the pnpm-lock.yaml file accordingly. This addition enhances the TypeScript experience in the project.
This commit updates the TypeScript target version to ES2020 and changes the module system to ESNext in the playground's tsconfig.json. Additionally, a new script for fixing issues has been added to package.json, enhancing the development workflow.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## arkenv@0.4.0 ### Minor Changes - ## Improved type inference and scope-based validation _[`#129`](#129) [`dd15b60`](dd15b60) [@yamcodes](https://github.com/yamcodes)_ The `createEnv` function got a facelift with better TypeScript inference and introduced a new scope-based validation system. **Key improvements:** - **Better ecosystem integration**: Use `string.host` and `number.port` in your schemas, as if they were native ArkType keywords - **Cleaner API**: No need to awkwardly import `host` and `port` types anymore ### Before: `host` and `port` had to be manually imported from the `arkenv` package, and used as arguments to the `createEnv` function. ```ts import { createEnv, host, port } from "arkenv"; const env = createEnv({ HOST: host, // Validates IP addresses or "localhost" PORT: port, // Validates port numbers (0-65535) NODE_ENV: "string", // Standard string validation }); ``` ### After: Now you can use `string.host` and `number.port` in your schemas, in a way that is much more natural and idiomatic within the ArkType ecosystem. ```ts import { createEnv } from "arkenv"; const env = createEnv({ HOST: "string.host", // Validates IP addresses or "localhost" PORT: "number.port", // Validates port numbers (0-65535) NODE_ENV: "string", // Standard string validation }); ``` ### BREAKING CHANGE: - We are no longer exporting `host` and `port` types. Use `string.host` and `number.port` instead. ## @arkenv/vite-plugin@0.0.7 ### Patch Changes - Upgraded ArkType peer dependency from `^2.0.0` to `^2.1.22` for compatibility with the latest version of ArkEnv _[`#129`](#129) [`dd15b60`](dd15b60) [@yamcodes](https://github.com/yamcodes)_ <details><summary>Updated 1 dependency</summary> <small> [`dd15b60`](dd15b60) </small> - `arkenv@0.4.0` </details> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Improved type inference and scope-based validation
The
createEnvfunction got a facelift with better TypeScript inference and introduced a new scope-based validation system.Key improvements:
string.hostandnumber.portin your schemas, as if they were native ArkType keywordshostandporttypes anymoreBefore:
hostandporthad to be manually imported from thearkenvpackage, and used as arguments to thecreateEnvfunction.After:
Now you can use
string.hostandnumber.portin your schemas, in a way that is much more natural and idiomatic within the ArkType ecosystem.BREAKING CHANGE:
hostandporttypes. Usestring.hostandnumber.portinstead.Summary by CodeRabbit
New Features
Breaking Changes
Documentation
Examples
Tests
Chores