Conversation
- Introduced tests for default and named imports of environment variables - Validated error handling for missing environment variables - Ensured consistent behavior between default and named imports
- Added file exclusion settings to the workspace configuration to improve project cleanliness. - Updated import statements in `index.ts` and `quickstart.mdx` to recommend using the default import for better compatibility with VS Code users. - Enhanced README with additional tips for VS Code users regarding the ArkType extension.
- Added an image demonstrating ArkType syntax highlighting in VS Code to improve user experience and guidance.
🦋 Changeset detectedLatest commit: 565aa65 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 16 minutes and 9 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 selected for processing (3)
WalkthroughThe arkenv package changes its default export to the createEnv function (aliased as arkenv), updates re-exports and types, and adds tests to verify parity between default and named imports. Docs, examples, and playground code switch to default-import usage. A new docs page is added; site code gains a “New” badge; workspace settings updated. Changes
Sequence Diagram(s)sequenceDiagram
actor Dev
participant Module as arkenv (package entry)
participant Impl as ./create-env
Dev->>Module: import arkenv from "arkenv"
Note over Module,Impl: Default export is an alias of createEnv
Module->>Impl: re-export default (createEnv)
Dev->>Impl: arkenv(schema)
Impl-->>Dev: env object (validated)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Pre-merge checks (3 passed)✅ Passed checks (3 passed)
Poem
✨ 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 |
- Changed the path of the ArkType syntax highlighting image in the import options documentation to ensure correct rendering.
…de tips - Included a link to the "Import Options & VS Code Integration" guide in the quickstart documentation for better user guidance. - Added a tip for VS Code users regarding syntax highlighting for ArkType schemas to improve the developer experience.
…in import options guide - Updated the syntax highlighting image implementation in the import options documentation to use the Next.js Image component for improved performance and responsiveness.
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/copilot-instructions.md (1)
115-123: Fix env reset pattern in test snippet (copy vs reference, undeclared variable).The snippet both omits the declaration for
originalEnvand assigns by reference, which won’t restore a pristine env. Prefer capturing once and cloning per test.Apply this diff to the snippet:
-import { beforeEach, afterEach, it, expect } from 'vitest'; +import { beforeEach, afterEach, it, expect } from 'vitest'; -let originalEnv; +const ORIGINAL_ENV = process.env; beforeEach(() => { - // Save original env - originalEnv = process.env; + // Reset to a fresh copy before each test + process.env = { ...ORIGINAL_ENV }; }); afterEach(() => { - // Restore original env - process.env = originalEnv; + // Restore the original reference after each test file run + process.env = ORIGINAL_ENV; });
🧹 Nitpick comments (7)
apps/www/lib/source.ts (2)
6-16: Add type + a11y props to the "New!" badge.Type the return to a ReactElement and add an aria-label for screen readers.
-import { createElement } from "react"; +import { createElement, type ReactElement } from "react"; @@ -function createNewElement() { +function createNewElement(): ReactElement { return createElement( "span", { className: "bg-gradient-to-r from-yellow-400 to-yellow-100 text-amber-800 px-1.5 py-0.5 rounded text-xs font-medium", "data-new": "true", + "aria-label": "New", }, "New!", ); }
27-27: Prefer a typed guard for custom icons.If feasible, tighten the icon discriminator to include "New" to catch typos at compile time.
- if (icon === "New") return createNewElement(); + if (icon === "New") return createNewElement(); + // Consider typing `icon: keyof typeof icons | "New"` in the loader callback signature.packages/vite-plugin/src/index.test.ts (2)
7-10: Future-proof the mock by also providing a default export.If the plugin ever switches to default-importing arkenv, the mock will remain compatible.
-vi.mock("arkenv", () => ({ - createEnv: mockCreateEnv, -})); +vi.mock("arkenv", () => ({ + createEnv: mockCreateEnv, + default: Object.assign((...args: unknown[]) => mockCreateEnv(...args), { + createEnv: mockCreateEnv, + }), +}));
77-99: Avoid relying on getMockImplementation; use try/finally and always reset.This is simpler and avoids API differences across Vitest versions.
-const originalMockImplementation = mockCreateEnv.getMockImplementation(); - -// Mock createEnv to throw an error for this specific test -mockCreateEnv.mockImplementation(() => { - throw new Error("VITE_TEST must be a string (was missing)"); -}); - -// ... -// Restore the original mock implementation -if (originalMockImplementation) { - mockCreateEnv.mockImplementation(originalMockImplementation); -} else { - mockCreateEnv.mockReset(); -} +try { + mockCreateEnv.mockImplementation(() => { + throw new Error("VITE_TEST must be a string (was missing)"); + }); + await expect(buildWithPlugin({ VITE_TEST: "string" })).rejects.toThrow( + "VITE_TEST must be a string (was missing)", + ); +} finally { + mockCreateEnv.mockReset(); +}Repeat the same pattern for the "invalid type" test.
-const originalMockImplementation = mockCreateEnv.getMockImplementation(); -mockCreateEnv.mockImplementation(() => { - throw new Error("VITE_NUMBER must be a number (was string)"); -}); -// ... -if (originalMockImplementation) { - mockCreateEnv.mockImplementation(originalMockImplementation); -} else { - mockCreateEnv.mockReset(); -} +try { + mockCreateEnv.mockImplementation(() => { + throw new Error("VITE_NUMBER must be a number (was string)"); + }); + await expect(buildWithPlugin({ VITE_NUMBER: "number" })).rejects.toThrow( + "VITE_NUMBER must be a number (was string)", + ); +} finally { + mockCreateEnv.mockReset(); +}Also applies to: 102-118
arkenv.code-workspace (1)
52-66: Consider excluding heavy dirs from search and file watching.Speeds up search and reduces watcher load in large workspaces.
"settings": { "files.exclude": { @@ "**/.trunk/*plugins/": true }, - "explorerExclude.backup": {} + "explorerExclude.backup": {}, + "search.exclude": { + "**/node_modules": true, + "**/dist": true, + "**/build": true, + "**/coverage": true, + "**/.turbo": true + }, + "files.watcherExclude": { + "**/node_modules/**": true, + "**/dist/**": true, + "**/build/**": true, + "**/coverage/**": true + } }.changeset/vast-bananas-win.md (1)
23-35: Nice migration note; consider adding CJS interop snippet.Many users still on CJS will need this.
Update to: ```ts import arkenv from "arkenv"; const env = arkenv({ ... });
+For CommonJS:
+js +const arkenv = require("arkenv").default; +const env = arkenv({ ... }); +</blockquote></details> <details> <summary>apps/www/content/docs/guides/import-options.mdx (1)</summary><blockquote> `58-67`: **Soften absolute claim about highlighting with named import.** Highlighting behavior may depend on the extension’s heuristics and configuration. Suggest “may not get syntax highlighting”. ```diff -You can also use named imports, though you won't get syntax highlighting: +You can also use named imports, though you may not get syntax highlighting:
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
apps/www/public/dx.pngis excluded by!**/*.pngassets/dx.pngis excluded by!**/*.png
📒 Files selected for processing (14)
.changeset/vast-bananas-win.md(1 hunks).github/copilot-instructions.md(4 hunks)apps/playground/index.ts(1 hunks)apps/www/content/docs/guides/environment-configuration.mdx(3 hunks)apps/www/content/docs/guides/import-options.mdx(1 hunks)apps/www/content/docs/index.mdx(1 hunks)apps/www/content/docs/meta.json(1 hunks)apps/www/content/docs/quickstart.mdx(3 hunks)apps/www/lib/source.ts(2 hunks)arkenv.code-workspace(1 hunks)packages/arkenv/README.md(1 hunks)packages/arkenv/src/index.test.ts(1 hunks)packages/arkenv/src/index.ts(1 hunks)packages/vite-plugin/src/index.test.ts(9 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
packages/**/src/**/*.test.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
packages/**/src/**/*.test.ts: Place tests alongside source files and use the .test.ts suffix for test files
In tests, use Vitest's describe/it structure
Mock process.env in tests to cover different environment scenarios
Save the original process.env before tests and restore it after tests (e.g., in beforeEach/afterEach)
Verify both runtime behavior and TypeScript types in tests
Files:
packages/vite-plugin/src/index.test.tspackages/arkenv/src/index.test.ts
**/README.md
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Document environment requirements in README files
Files:
packages/arkenv/README.md
🧠 Learnings (7)
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Applies to packages/**/src/**/*.test.ts : Mock process.env in tests to cover different environment scenarios
Applied to files:
packages/vite-plugin/src/index.test.tspackages/arkenv/src/index.test.ts.github/copilot-instructions.md
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Applies to packages/**/src/**/*.test.ts : Save the original process.env before tests and restore it after tests (e.g., in beforeEach/afterEach)
Applied to files:
packages/vite-plugin/src/index.test.tspackages/arkenv/src/index.test.ts.github/copilot-instructions.md
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Applies to packages/**/src/**/*.test.ts : In tests, use Vitest's describe/it structure
Applied to files:
packages/vite-plugin/src/index.test.tspackages/arkenv/src/index.test.ts.github/copilot-instructions.md
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Use built-in validators (host, port, url, email) when available when defining environment schemas with createEnv
Applied to files:
apps/www/content/docs/guides/environment-configuration.mdxapps/www/content/docs/quickstart.mdxapps/www/content/docs/index.mdx.github/copilot-instructions.md
📚 Learning: 2025-09-09T17:37:19.650Z
Learnt from: yamcodes
PR: yamcodes/arkenv#132
File: packages/arkenv/README.md:13-14
Timestamp: 2025-09-09T17:37:19.650Z
Learning: For yamcodes/arkenv project: Runtime support documentation should link to specific examples: Node.js (examples/basic), Bun (examples/with-bun), Vite (examples/with-vite-react-ts).
Applied to files:
packages/arkenv/README.md
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Applies to packages/**/src/**/*.test.ts : Verify both runtime behavior and TypeScript types in tests
Applied to files:
packages/arkenv/src/index.test.ts.github/copilot-instructions.md
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Applies to packages/**/src/**/*.test.ts : Place tests alongside source files and use the .test.ts suffix for test files
Applied to files:
.github/copilot-instructions.md
🧬 Code graph analysis (11)
packages/vite-plugin/src/index.test.ts (1)
packages/arkenv/src/create-env.test.ts (4)
createEnv(57-60)env(72-85)it(27-86)process(28-36)
packages/arkenv/src/index.ts (1)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)
.changeset/vast-bananas-win.md (2)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/errors.ts (1)
ArkEnvError(30-38)
apps/www/content/docs/guides/environment-configuration.mdx (3)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/create-env.test.ts (5)
createEnv(57-60)createEnv(39-42)it(27-86)env(72-85)process(28-36)packages/arkenv/src/errors.ts (1)
ArkEnvError(30-38)
packages/arkenv/README.md (2)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/create-env.test.ts (2)
it(27-86)createEnv(57-60)
packages/arkenv/src/index.test.ts (2)
packages/arkenv/src/index.ts (1)
createEnv(6-6)packages/arkenv/src/create-env.test.ts (4)
it(27-86)env(72-85)process(28-36)createEnv(57-60)
apps/www/content/docs/quickstart.mdx (2)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/create-env.test.ts (1)
it(27-86)
apps/www/content/docs/index.mdx (4)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/create-env.test.ts (5)
createEnv(39-42)createEnv(57-60)it(27-86)env(72-85)process(28-36)packages/vite-plugin/src/index.ts (1)
config(9-11)packages/arkenv/src/errors.ts (1)
ArkEnvError(30-38)
apps/playground/index.ts (2)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/create-env.test.ts (5)
createEnv(57-60)createEnv(39-42)it(27-86)env(72-85)process(28-36)
.github/copilot-instructions.md (2)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/create-env.test.ts (4)
createEnv(57-60)it(27-86)process(28-36)env(72-85)
apps/www/content/docs/guides/import-options.mdx (1)
apps/www/app/docs/[[...slug]]/page.tsx (1)
Page(20-71)
🔇 Additional comments (21)
packages/arkenv/README.md (1)
60-63: Quickstart default import looks good.packages/arkenv/src/index.ts (1)
1-6: Ensure built CJS/ESM exports include both default and named exports
package.json exports correctly map"import"→./dist/index.jsand"require"→./dist/index.cjs, but there’s no committeddist/folder to confirm the generated entrypoints. After running the build, verify that bothdist/index.js(ESM) anddist/index.cjs(CJS) re-exportcreateEnvas the default alongside the named exports.apps/playground/index.ts (1)
1-7: Docs/example aligned with new default export. LGTM..github/copilot-instructions.md (5)
57-57: Default export note is clear and accurate.Good call-out that
createEnv(schema)is also the default export (typically imported asarkenv).
63-63: Key files list aligns with the API shift.Pointing to
src/create-env.tsas the core implementation matches the change.
72-80: Updated example to default import looks good.The snippet properly uses
import arkenv from 'arkenv'and built-in validators.
100-100: Tests index is consistent with the rename.Referencing
create-env.test.tsis consistent with the new API docs.
125-129: LGTM on the validation example.Uses the default import and a built-in validator; the expectation matches number parsing.
apps/www/content/docs/meta.json (1)
8-9: Nav entry added in the right place.
"guides/import-options"appears under Guides and matches the new page.apps/www/content/docs/quickstart.mdx (3)
38-41: Default import migration is correct.The quickstart now demonstrates
arkenvdefault import and usage accurately.
56-58: Helpful cross-link.The VS Code integration tip correctly points to
/docs/guides/import-options.
116-120: Next steps card is aligned with new guide.Good addition for discoverability.
apps/www/content/docs/guides/environment-configuration.mdx (3)
180-203: Consistent switch to default import in env.ts snippet.Examples use built-in validators and optional fields properly.
212-231: Config factory uses default import correctly.The pattern is clear and idiomatic.
238-245: Feature flags snippet looks good.Optional booleans with defaults are expressed cleanly.
apps/www/content/docs/index.mdx (1)
33-36: Quick example reflects default import accurately.Matches the public API and built-in validators.
apps/www/content/docs/guides/import-options.mdx (5)
3-3: Verify icon name “New”.Confirm that “New” is a valid icon token in your docs system (e.g., lucide icon set or custom). If not, swap for a supported one (e.g.,
Sparkles).Run to grep allowed icon names in the docs UI, or adjust to a known-good icon.
69-92: Migration section is clear and correct.Before/After examples accurately show parity between default and named imports.
9-15: Extension slug and inline error summaries confirmed
The slugarktypeio.arkdarkis correct, and the extension provides inline error summaries itself (no separate ErrorLens required).
41-46: dx.png asset verified in apps/www/public; requirement satisfied.
1-99: Add CJS/ESM interop note
Add a brief sentence noting that the default export mirrorscreateEnvin both the ESM (dist/index.js) and CJS (dist/index.cjs) builds.
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (11)
apps/www/lib/source.ts (1)
6-16: Consider a11y affordances for the “New!” badge.Add an accessible name so screen readers announce it (e.g., aria-label="New"). Optional: role="note" or visually-hidden text if needed.
function createNewElement() { return createElement( "span", { className: "bg-gradient-to-r from-yellow-400 to-yellow-100 text-amber-800 px-1.5 py-0.5 rounded text-xs font-medium", "data-new": "true", + "aria-label": "New", }, "New!", ); }packages/vite-plugin/src/index.test.ts (1)
102-118: Mirror the same robust restore pattern here.Keep both error‑handling tests consistent and resilient across runner versions.
-const originalMockImplementation = mockCreateEnv.getMockImplementation(); +const originalMockImplementation = + // @ts-expect-error - compatibility with Jest/Vitest + (mockCreateEnv as any).getMockImplementation?.(); ... -if (originalMockImplementation) { - mockCreateEnv.mockImplementation(originalMockImplementation); -} else { - mockCreateEnv.mockReset(); -} +originalMockImplementation + ? mockCreateEnv.mockImplementation(originalMockImplementation) + : mockCreateEnv.mockReset();arkenv.code-workspace (1)
52-66: Tighten exclude globs.The patterns
**/.trunk/*actions/etc. could accidentally match names like “transactions”. Prefer exact subpaths.- "**/.trunk/*actions/": true, - "**/.trunk/*logs/": true, - "**/.trunk/*notifications/": true, - "**/.trunk/*out/": true, - "**/.trunk/*plugins/": true + "**/.trunk/actions/": true, + "**/.trunk/logs/": true, + "**/.trunk/notifications/": true, + "**/.trunk/out/": true, + "**/.trunk/plugins/": truepackages/arkenv/src/index.test.ts (1)
4-60: Add lightweight type assertions.Verify default and named export types match and schema inference works.
it("should export createEnv as default export", () => { expect(arkenv).toBe(createEnv); expect(typeof arkenv).toBe("function"); }); + + it("types: default and named export share the same type", () => { + expectTypeOf<typeof arkenv>().toEqualTypeOf<typeof createEnv>(); + }); + + it("types: schema infers env types", () => { + const env = arkenv({ + FOO: "string", + "BAR?": "number", + }); + expectTypeOf(env.FOO).toEqualTypeOf<string>(); + expectTypeOf(env.BAR).toEqualTypeOf<number | undefined>(); + });apps/www/content/docs/guides/import-options.mdx (3)
41-46: Fix likely broken image pathSite docs elsewhere reference
/assets/dx.png; here it’s/dx.png. Update to avoid a 404.- src="/dx.png" + src="/assets/dx.png"
2-2: Align page title with slug/topicThe file lives at guides/import-options but title is “Integrating with VS Code”. Consider a blended title for nav consistency.
-title: Integrating with VS Code +title: Import options & VS Code integration
58-67: Clarify highlighting behavior with aliasingIf the extension keys off the identifier name, users can keep named imports and alias to
arkenv. Recommend adding this example (verify behavior first).-You can also use named imports, though you won't get syntax highlighting: +You can also use named imports. Without the `arkenv` identifier you won't get syntax highlighting, but you can alias to keep it: ```typescript -import { createEnv } from 'arkenv'; +import { createEnv as arkenv } from 'arkenv'; -const env = createEnv({ +const env = arkenv({ PORT: "number.port", NODE_ENV: "'development' | 'production' | 'test'", });Would you like me to update the other docs sections similarly? </blockquote></details> <details> <summary>packages/arkenv/src/index.ts (1)</summary><blockquote> `1-6`: **Avoid redundant re-export of EnvSchema** `export * from "./create-env"` already re-exports types; the explicit `export type { EnvSchema }` is redundant and can cause re-export conflicts in some TS setups. ```diff -// Type exports -export type { EnvSchema } from "./create-env"; -// Named exports +// Named/type exports export * from "./create-env"; // Export createEnv as the main default export export { createEnv as default } from "./create-env";apps/www/content/docs/guides/environment-configuration.mdx (1)
194-202: Use built-in url validator instead of custom functionKeep docs consistent with provided validators and simplify the snippet.
- // Custom validation - API_URL: (value: string) => { - try { - new URL(value); - return true; - } catch { - return false; - } - } + API_URL: "string.url"packages/arkenv/README.md (1)
78-81: Fix README image pathLeading slash makes the path absolute and breaks on GitHub/npm. Use a relative path.
->  +> .github/copilot-instructions.md (1)
115-123: Correct env mocking pattern in testsAssigning
originalEnv = process.envaliases the same object. Clone before mutate; restore a clone after.-import { beforeEach, afterEach, it, expect } from 'vitest'; - -beforeEach(() => { - // Save original env - originalEnv = process.env; -}); - -afterEach(() => { - // Restore original env - process.env = originalEnv; -}); +import { beforeEach, afterEach, it, expect } from 'vitest'; +let originalEnv: NodeJS.ProcessEnv; +beforeEach(() => { + originalEnv = { ...process.env }; +}); +afterEach(() => { + process.env = { ...originalEnv }; +});
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
apps/www/public/dx.pngis excluded by!**/*.pngassets/dx.pngis excluded by!**/*.png
📒 Files selected for processing (14)
.changeset/vast-bananas-win.md(1 hunks).github/copilot-instructions.md(4 hunks)apps/playground/index.ts(1 hunks)apps/www/content/docs/guides/environment-configuration.mdx(3 hunks)apps/www/content/docs/guides/import-options.mdx(1 hunks)apps/www/content/docs/index.mdx(1 hunks)apps/www/content/docs/meta.json(1 hunks)apps/www/content/docs/quickstart.mdx(3 hunks)apps/www/lib/source.ts(2 hunks)arkenv.code-workspace(1 hunks)packages/arkenv/README.md(1 hunks)packages/arkenv/src/index.test.ts(1 hunks)packages/arkenv/src/index.ts(1 hunks)packages/vite-plugin/src/index.test.ts(9 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
packages/**/src/**/*.test.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
packages/**/src/**/*.test.ts: Place tests alongside source files and use the .test.ts suffix for test files
In tests, use Vitest's describe/it structure
Mock process.env in tests to cover different environment scenarios
Save the original process.env before tests and restore it after tests (e.g., in beforeEach/afterEach)
Verify both runtime behavior and TypeScript types in tests
Files:
packages/vite-plugin/src/index.test.tspackages/arkenv/src/index.test.ts
**/README.md
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Document environment requirements in README files
Files:
packages/arkenv/README.md
🧠 Learnings (7)
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Applies to packages/**/src/**/*.test.ts : Mock process.env in tests to cover different environment scenarios
Applied to files:
packages/vite-plugin/src/index.test.tspackages/arkenv/src/index.test.ts.github/copilot-instructions.md
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Applies to packages/**/src/**/*.test.ts : Save the original process.env before tests and restore it after tests (e.g., in beforeEach/afterEach)
Applied to files:
packages/vite-plugin/src/index.test.tspackages/arkenv/src/index.test.ts.github/copilot-instructions.md
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Applies to packages/**/src/**/*.test.ts : In tests, use Vitest's describe/it structure
Applied to files:
packages/vite-plugin/src/index.test.tspackages/arkenv/src/index.test.ts.github/copilot-instructions.md
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Applies to packages/**/src/**/*.test.ts : Verify both runtime behavior and TypeScript types in tests
Applied to files:
packages/arkenv/src/index.test.ts.github/copilot-instructions.md
📚 Learning: 2025-09-09T17:37:19.650Z
Learnt from: yamcodes
PR: yamcodes/arkenv#132
File: packages/arkenv/README.md:13-14
Timestamp: 2025-09-09T17:37:19.650Z
Learning: For yamcodes/arkenv project: Runtime support documentation should link to specific examples: Node.js (examples/basic), Bun (examples/with-bun), Vite (examples/with-vite-react-ts).
Applied to files:
packages/arkenv/README.md
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Use built-in validators (host, port, url, email) when available when defining environment schemas with createEnv
Applied to files:
apps/www/content/docs/index.mdxapps/www/content/docs/guides/environment-configuration.mdxapps/www/content/docs/quickstart.mdx.github/copilot-instructions.md
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Applies to packages/**/src/**/*.test.ts : Place tests alongside source files and use the .test.ts suffix for test files
Applied to files:
.github/copilot-instructions.md
🧬 Code graph analysis (9)
apps/playground/index.ts (2)
packages/arkenv/src/create-env.test.ts (5)
createEnv(57-60)env(72-85)createEnv(39-42)it(27-86)process(28-36)packages/arkenv/src/create-env.ts (1)
createEnv(24-34)
packages/arkenv/src/index.test.ts (2)
packages/arkenv/src/index.ts (1)
createEnv(6-6)packages/arkenv/src/create-env.test.ts (4)
it(27-86)process(28-36)env(72-85)createEnv(57-60)
packages/arkenv/src/index.ts (1)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)
packages/arkenv/README.md (1)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)
apps/www/content/docs/index.mdx (2)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/create-env.test.ts (5)
createEnv(57-60)it(27-86)env(72-85)createEnv(39-42)process(28-36)
apps/www/content/docs/guides/environment-configuration.mdx (2)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/create-env.test.ts (5)
createEnv(57-60)it(27-86)createEnv(39-42)env(72-85)process(28-36)
apps/www/content/docs/quickstart.mdx (2)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/create-env.test.ts (4)
createEnv(57-60)it(27-86)env(72-85)createEnv(39-42)
.changeset/vast-bananas-win.md (3)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/create-env.test.ts (6)
createEnv(57-60)it(27-86)createEnv(39-42)env(72-85)process(28-36)error(18-22)packages/arkenv/src/errors.test.ts (1)
errors(63-74)
.github/copilot-instructions.md (3)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/create-env.test.ts (4)
createEnv(57-60)it(27-86)env(72-85)process(28-36)packages/arkenv/src/errors.test.ts (1)
errors(63-74)
🔇 Additional comments (14)
apps/www/lib/source.ts (1)
27-29: Good guard placement.Checking for "New" before the lucide map avoids accidental shadowing and keeps the hot path intact.
apps/www/content/docs/meta.json (1)
8-9: Docs nav entry addition looks correct.The new page slug fits the Guides section and matches the links elsewhere.
packages/vite-plugin/src/index.test.ts (2)
146-153: Assertions read well.The expectations validate the integration surface without over‑specifying internals.
Also applies to: 166-173
77-99: Drop the optional chaining guard forgetMockImplementationVitest’s
MockInstancehas exposedgetMockImplementation()since v1, so the fallback is unnecessary. [1][2]Likely an incorrect or invalid review comment.
apps/playground/index.ts (1)
1-7: Switch to default import looks good.Sample remains minimal and aligns with docs and new API.
apps/www/content/docs/quickstart.mdx (2)
38-54: Docs updated to default import correctly.Examples use built‑in validators (host/port) and optional key syntax—nice.
56-58: 👍 Helpful VS Code callouts.Links and messaging are clear; no further changes needed.
Also applies to: 116-120
apps/www/content/docs/index.mdx (1)
33-45: Intro example matches new default export.Concise and consistent with Quickstart.
.changeset/vast-bananas-win.md (1)
23-35: Add manual verification for old API usage
Ripgrep returned no matches but also didn’t search any files—please manually ensure there are no remainingarkenv.createEnv(...)calls in the repo.packages/arkenv/src/index.ts (1)
5-6: LGTM: default now points to createEnvThis aligns the public API with the docs and migration notes.
apps/www/content/docs/guides/environment-configuration.mdx (1)
180-183: LGTM: default import usageExamples correctly migrate to
import arkenv from 'arkenv'andarkenv({...}).Also applies to: 212-216, 238-241
packages/arkenv/README.md (2)
60-67: LGTM: quickstart reflects default exportExamples use built-in validators (
host,port) and the default import.
18-22: Specify minimum Node.js version in README
Add an explicit “Node.js >= X.Y (e.g. >= 18 LTS)” entry under Requirements and ensure your CI matrix orengines.nodefield aligns with that version..github/copilot-instructions.md (1)
57-64: LGTM: default export guidance and examplesDocs consistently position
createEnvas both named and default (arkenv) export.Also applies to: 72-80
- Changed the syntax highlighting image URL in the README to a direct link for improved accessibility and rendering consistency.
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (9)
apps/www/lib/source.ts (2)
6-16: Precompute the badge element to avoid re-creating it; optional a11y hint.Minor perf/readability: build the element once and return the cached node. Adding a title helps with hover/tooltips.
-function createNewElement() { - return createElement( - "span", - { - className: - "bg-gradient-to-r from-yellow-400 to-yellow-100 text-amber-800 px-1.5 py-0.5 rounded text-xs font-medium", - "data-new": "true", - }, - "New!", - ); -} +const NEW_BADGE = createElement( + "span", + { + className: + "bg-gradient-to-r from-yellow-400 to-yellow-100 text-amber-800 px-1.5 py-0.5 rounded text-xs font-medium", + "data-new": "true", + title: "New", + }, + "New!", +); + +function createNewElement() { + return NEW_BADGE; +}Confirm whether the “New!” label should be announced to screen readers. If not, we can add
aria-hidden: true; if yes, current text content is fine.
27-28: Document the reserved icon value.Tiny clarity win: annotate that "New" is a local special-case, not from lucide.
- if (icon === "New") return createNewElement(); + // Special-case local badge not present in lucide-react + if (icon === "New") return createNewElement();arkenv.code-workspace (1)
51-66: VS Code settings: verify excludes and remove non-standard key.
- If the goal is to hide Thumbs.db, set it to true.
- "explorerExclude.backup" isn’t a known VS Code setting; likely a stray key.
Apply:
"files.exclude": { "**/.git": true, "**/.svn": true, "**/.hg": true, "**/.DS_Store": true, - "**/Thumbs.db": false, + "**/Thumbs.db": true, "**/.trunk/*actions/": true, "**/.trunk/*logs/": true, "**/.trunk/*notifications/": true, "**/.trunk/*out/": true, "**/.trunk/*plugins/": true }, - "explorerExclude.backup": {} + // Removed unknown setting "explorerExclude.backup".github/copilot-instructions.md (1)
113-124: Testing snippet: avoid reassigning the same env object; snapshot and restore safely.
Declare the variable and clone env to prevent cross-test leakage.- beforeEach(() => { - // Save original env - originalEnv = process.env; - }); + let originalEnv: NodeJS.ProcessEnv; + beforeEach(() => { + // Snapshot original env + originalEnv = { ...process.env }; + }); - afterEach(() => { - // Restore original env - process.env = originalEnv; - }); + afterEach(() => { + // Restore original env + process.env = originalEnv; + });Also applies to: 125-130
packages/vite-plugin/src/index.test.ts (1)
1-37: Optional: snapshot/restore process.env across the suite. Save and restoreprocess.envinbeforeAll/afterAll; mocking of the namedcreateEnvimport is already correct.
Add near the top ofpackages/vite-plugin/src/index.test.ts:let OLD_ENV: NodeJS.ProcessEnv; beforeAll(() => { OLD_ENV = { ...process.env }; }); afterAll(() => { process.env = OLD_ENV; });apps/www/content/docs/guides/environment-configuration.mdx (1)
194-201: Prefer the built-in URL validator over a custom function.Use ArkEnv’s/ArkType’s built-in
string.urlinstead of hand-rolled parsing.- API_URL: (value: string) => { - try { - new URL(value); - return true; - } catch { - return false; - } - } + API_URL: "string.url"packages/arkenv/README.md (1)
18-22: Clarify runtime requirements (optional).Consider stating supported Node.js versions and ESM/CJS usage notes (e.g., ESM-only vs dual, CommonJS
require('arkenv').createEnv), so users know what to expect.packages/arkenv/src/index.ts (1)
1-4: Remove redundant type re-export (nit).
export * from "./create-env"already re-exports types; the explicitexport type { EnvSchema }is optional.-// Type exports -export type { EnvSchema } from "./create-env"; -// Named exports export * from "./create-env";packages/arkenv/src/index.test.ts (1)
46-59: Optionally assert types to verify TS parity for default vs named imports.Add lightweight compile-time checks with
expectTypeOf.it("should have same behavior for both default and named imports", () => { process.env.COMPARISON_TEST = "same-value"; const envFromDefault = arkenv({ COMPARISON_TEST: "string", }); const envFromNamed = createEnv({ COMPARISON_TEST: "string", }); expect(envFromDefault.COMPARISON_TEST).toBe(envFromNamed.COMPARISON_TEST); expect(envFromDefault.COMPARISON_TEST).toBe("same-value"); }); + + it("should expose correct types for default import", () => { + const env = arkenv({ PORT: "number.port" }); + expectTypeOf(env.PORT).toBeNumber(); + });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
apps/www/public/dx.pngis excluded by!**/*.pngassets/dx.pngis excluded by!**/*.png
📒 Files selected for processing (14)
.changeset/vast-bananas-win.md(1 hunks).github/copilot-instructions.md(4 hunks)apps/playground/index.ts(1 hunks)apps/www/content/docs/guides/environment-configuration.mdx(3 hunks)apps/www/content/docs/guides/import-options.mdx(1 hunks)apps/www/content/docs/index.mdx(1 hunks)apps/www/content/docs/meta.json(1 hunks)apps/www/content/docs/quickstart.mdx(3 hunks)apps/www/lib/source.ts(2 hunks)arkenv.code-workspace(1 hunks)packages/arkenv/README.md(1 hunks)packages/arkenv/src/index.test.ts(1 hunks)packages/arkenv/src/index.ts(1 hunks)packages/vite-plugin/src/index.test.ts(9 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
packages/**/src/**/*.test.ts
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
packages/**/src/**/*.test.ts: Place tests alongside source files and use the .test.ts suffix for test files
In tests, use Vitest's describe/it structure
Mock process.env in tests to cover different environment scenarios
Save the original process.env before tests and restore it after tests (e.g., in beforeEach/afterEach)
Verify both runtime behavior and TypeScript types in tests
Files:
packages/arkenv/src/index.test.tspackages/vite-plugin/src/index.test.ts
**/README.md
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Document environment requirements in README files
Files:
packages/arkenv/README.md
🧠 Learnings (7)
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Applies to packages/**/src/**/*.test.ts : Mock process.env in tests to cover different environment scenarios
Applied to files:
packages/arkenv/src/index.test.ts.github/copilot-instructions.mdpackages/vite-plugin/src/index.test.ts
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Applies to packages/**/src/**/*.test.ts : Save the original process.env before tests and restore it after tests (e.g., in beforeEach/afterEach)
Applied to files:
packages/arkenv/src/index.test.ts.github/copilot-instructions.mdpackages/vite-plugin/src/index.test.ts
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Applies to packages/**/src/**/*.test.ts : In tests, use Vitest's describe/it structure
Applied to files:
packages/arkenv/src/index.test.ts.github/copilot-instructions.mdpackages/vite-plugin/src/index.test.ts
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Use built-in validators (host, port, url, email) when available when defining environment schemas with createEnv
Applied to files:
apps/www/content/docs/quickstart.mdxapps/www/content/docs/guides/environment-configuration.mdxapps/www/content/docs/index.mdx.github/copilot-instructions.md
📚 Learning: 2025-09-09T17:37:19.650Z
Learnt from: yamcodes
PR: yamcodes/arkenv#132
File: packages/arkenv/README.md:13-14
Timestamp: 2025-09-09T17:37:19.650Z
Learning: For yamcodes/arkenv project: Runtime support documentation should link to specific examples: Node.js (examples/basic), Bun (examples/with-bun), Vite (examples/with-vite-react-ts).
Applied to files:
packages/arkenv/README.md
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Applies to packages/**/src/**/*.test.ts : Place tests alongside source files and use the .test.ts suffix for test files
Applied to files:
.github/copilot-instructions.md
📚 Learning: 2025-09-08T18:44:08.779Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-08T18:44:08.779Z
Learning: Applies to packages/**/src/**/*.test.ts : Verify both runtime behavior and TypeScript types in tests
Applied to files:
.github/copilot-instructions.md
🧬 Code graph analysis (10)
packages/arkenv/src/index.test.ts (2)
packages/arkenv/src/index.ts (1)
createEnv(6-6)packages/arkenv/src/create-env.test.ts (4)
it(27-86)process(28-36)env(72-85)createEnv(57-60)
apps/www/content/docs/quickstart.mdx (2)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/errors.ts (1)
ArkEnvError(30-38)
apps/www/content/docs/guides/environment-configuration.mdx (3)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/create-env.test.ts (6)
it(27-86)createEnv(39-42)createEnv(57-60)env(72-85)process(28-36)errors(11-25)packages/vite-plugin/src/index.ts (1)
config(9-11)
apps/www/content/docs/index.mdx (2)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/create-env.test.ts (5)
createEnv(57-60)createEnv(39-42)it(27-86)env(72-85)process(28-36)
packages/arkenv/src/index.ts (2)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/create-env.test.ts (3)
createEnv(57-60)env(72-85)process(28-36)
apps/playground/index.ts (2)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/create-env.test.ts (4)
createEnv(57-60)env(72-85)createEnv(39-42)process(28-36)
packages/arkenv/README.md (1)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)
.changeset/vast-bananas-win.md (2)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/create-env.test.ts (3)
createEnv(57-60)createEnv(39-42)it(27-86)
.github/copilot-instructions.md (3)
packages/arkenv/src/create-env.ts (1)
createEnv(24-34)packages/arkenv/src/create-env.test.ts (5)
createEnv(57-60)it(27-86)env(72-85)process(28-36)createEnv(39-42)packages/arkenv/src/scope.test.ts (1)
envType(33-44)
packages/vite-plugin/src/index.test.ts (1)
packages/arkenv/src/create-env.test.ts (3)
createEnv(57-60)it(27-86)env(72-85)
🔇 Additional comments (13)
.github/copilot-instructions.md (1)
57-61: Docs align with default export — looks good.
The switch to default import (arkenv) and keeping createEnv as named is clear and consistent.Also applies to: 63-64, 72-80
apps/www/content/docs/meta.json (1)
8-9: New guide entry registered correctly.
The import-options page is properly added under Guides.apps/playground/index.ts (1)
1-7: Playground migrated to default import correctly.
Example now mirrors the public API (arkenv as default) and uses built-in validators.packages/vite-plugin/src/index.test.ts (3)
41-42: Good: reset mock state before each test.
Keeps call assertions reliable.
50-55: Assertions validate env plumbing through the plugin.
toHaveBeenCalledWith checks look precise and robust.Also applies to: 61-67, 147-152, 167-172
72-99: Nice defensive restore of mock implementations.
Prevents test pollution when throwing errors.Also applies to: 101-118
apps/www/content/docs/quickstart.mdx (1)
38-41: Quickstart updated to default import — solid.
Examples use built-in validators and point to the new guide; looks consistent.Also applies to: 56-58, 116-120
apps/www/content/docs/index.mdx (1)
33-36: Landing example reflects new default export correctly.
Concise and consistent with the rest of docs.apps/www/content/docs/guides/environment-configuration.mdx (1)
180-183: Default import switch reads well and is consistent.The move to
import arkenv from 'arkenv'and usingarkenv({ ... })across sections is coherent with the new API.Also applies to: 212-216, 238-244
packages/arkenv/README.md (1)
60-67: Quickstart now matches the new default export—LGTM.Importing default
arkenvand calling it directly is clear and concise.apps/www/content/docs/guides/import-options.mdx (2)
28-35: Example clearly demonstrates default import usage—LGTM.
41-46: No action needed –/dx.pngexists inapps/www/public, so thesrcpath is correct.packages/arkenv/src/index.ts (1)
5-6: Default-export alias is correct and minimal—LGTM.
- Added setup and teardown for process.env to ensure isolated test environments. - Included type checks for environment variables in tests for both default and named imports. - Improved validation tests to ensure consistent behavior across import types.
- Refactored test setup to capture and restore process.env for better isolation. - Added type assertions for exported functions in arkenv tests. - Enhanced afterEach cleanup in vite-plugin tests to prevent environment leakage.
- Added __esModule and default export mock for createEnv in the arkenv module to improve test isolation and functionality.
- Improved test setup by resetting modules and cleaning the environment before each test. - Enhanced afterEach cleanup to reset mocks and restore process.env, ensuring better isolation and preventing environment leakage.
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.5.0 ### Minor Changes - #### Export `createEnv` as the default export _[`#136`](#136) [`2b06c4c`](2b06c4c) [@yamcodes](https://github.com/yamcodes)_ You can now import `createEnv` as the default export: ```ts import arkenv from "arkenv"; ``` This enables syntax highlighting along with the [ArkType VS Code extension](https://marketplace.visualstudio.com/items?itemName=arktypeio.arkdark):  Note that named imports still work: ```ts import { createEnv } from "arkenv"; ``` **BREAKING CHANGE:** The default export now directly exports `createEnv` instead of an object containing all exports. If you previously used: ```ts import arkenv from "arkenv"; const env = arkenv.createEnv({ ... }); ``` Update to: ```ts import arkenv from "arkenv"; const env = arkenv({ ... }); ``` ## @arkenv/vite-plugin@0.0.8 ### Patch Changes <details><summary>Updated 1 dependency</summary> <small> [`2b06c4c`](2b06c4c) </small> - `arkenv@0.5.0` </details> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Summary by CodeRabbit
New Features
Documentation
Tests
Chores