-
Notifications
You must be signed in to change notification settings - Fork 5
Export createEnv as the default export
#136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c019ea8
test: add unit tests for createEnv and createEnvDefault functions
yamcodes 2c680da
chore: update workspace settings and documentation
yamcodes 4d7547a
docs: enhance README with syntax highlighting image for VS Code users
yamcodes 61dbedf
docs: update syntax highlighting image path in import options guide
yamcodes 4adb541
docs: add import options guide link and enhance quickstart with VS Co…
yamcodes 189f591
docs: replace syntax highlighting image with Next.js Image component …
yamcodes 7c9cf81
docs: update syntax highlighting image URL in README for VS Code users
yamcodes 12e158c
test: enhance unit tests for arkenv and createEnv
yamcodes ebdc463
test: improve unit tests for arkenv and vite-plugin
yamcodes 5b98d78
test: mock arkenv module in vite-plugin tests
yamcodes 565aa65
test: enhance environment management in vite-plugin tests
yamcodes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| --- | ||
| "arkenv": minor | ||
| --- | ||
yamcodes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| #### Export `createEnv` as the default export | ||
|
|
||
| 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({ ... }); | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| --- | ||
| title: Integrating with VS Code | ||
| icon: New | ||
| description: Get syntax highlighting and enhanced developer experience with the ArkType VS Code extension | ||
| --- | ||
|
|
||
| ## ArkType VS Code Extension | ||
|
|
||
| The [ArkType VS Code extension](https://marketplace.visualstudio.com/items?itemName=arktypeio.arkdark) provides syntax highlighting and inline error summaries for ArkType definitions, making your development experience with ArkEnv much more pleasant. | ||
|
|
||
| <Card | ||
| title="Install ArkType VS Code Extension" | ||
| href="https://marketplace.visualstudio.com/items?itemName=arktypeio.arkdark" | ||
| description="Get syntax highlighting and inline error summaries for ArkType functions" | ||
| /> | ||
|
|
||
| ### Installation | ||
|
|
||
| 1. Open VS Code | ||
| 2. Go to Extensions (Ctrl+Shift+X) | ||
| 3. Search for "ArkType" | ||
| 4. Install the extension by arktypeio | ||
|
|
||
| ## Getting Syntax Highlighting | ||
|
|
||
| To get syntax highlighting for your ArkEnv schemas, use the **default import** and name it `arkenv`: | ||
|
|
||
| ```typescript | ||
| import arkenv from 'arkenv'; | ||
|
|
||
| const env = arkenv({ | ||
| PORT: "number.port", | ||
| NODE_ENV: "'development' | 'production' | 'test'", | ||
| }); | ||
| ``` | ||
|
|
||
| ### Example with Syntax Highlighting | ||
|
|
||
| import Image from "next/image"; | ||
|
|
||
| <Image | ||
| src="/dx.png" | ||
| alt="ArkType syntax highlighting in VS Code" | ||
| width={600} | ||
| height={338} | ||
| /> | ||
|
|
||
| ### Benefits | ||
|
|
||
| When you use the default import (`import arkenv from 'arkenv'`) and have the ArkType extension installed, you get: | ||
|
|
||
| - **Syntax highlighting** for ArkType definitions in your schema | ||
| - **Inline error summaries** via ErrorLens integration | ||
| - **Better developer experience** with visual feedback | ||
|
|
||
| ## Alternative Import Styles | ||
|
|
||
| You can also use named imports, though you won't get syntax highlighting: | ||
|
|
||
| ```typescript | ||
| import { createEnv } from 'arkenv'; | ||
|
|
||
| const env = createEnv({ | ||
| PORT: "number.port", | ||
| NODE_ENV: "'development' | 'production' | 'test'", | ||
| }); | ||
| ``` | ||
|
|
||
| ## Migration Guide | ||
|
|
||
| If you're currently using named imports and want to switch to default imports for better VS Code support: | ||
|
|
||
| ### Before | ||
| ```typescript | ||
| import { createEnv } from 'arkenv'; | ||
|
|
||
| const env = createEnv({ | ||
| PORT: "number.port", | ||
| }); | ||
| ``` | ||
|
|
||
| ### After | ||
| ```typescript | ||
| import arkenv from 'arkenv'; | ||
|
|
||
| const env = arkenv({ | ||
| PORT: "number.port", | ||
| }); | ||
| ``` | ||
|
|
||
| The functionality is identical - only the import style changes! | ||
|
|
||
| ## Best Practices | ||
|
|
||
| - **Use default import** if you're using VS Code and want enhanced syntax highlighting | ||
| - **Use named import** if you prefer explicit imports or are using other editors | ||
| - **Be consistent** within your project - choose one style and stick with it | ||
| - **Install the ArkType extension** for the best development experience |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| "quickstart", | ||
| "examples", | ||
| "---Guides---", | ||
| "guides/import-options", | ||
| "guides/environment-configuration" | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.