diff --git a/README.md b/README.md deleted file mode 100644 index ebf005eb0..000000000 --- a/README.md +++ /dev/null @@ -1,90 +0,0 @@ -

- - arkenv - Typesafe Environment Variables - -
- Tests Status - Bundle Size - Total Downloads - Dependency Count - Powered By ArkType -

- -## Installation - -
-npm - -```sh -npm install arkenv arktype -``` -
- -
-pnpm - -```sh -pnpm add arkenv arktype -``` -
- -
-Yarn - -```sh -yarn add arkenv arktype -``` -
- -
-Bun - -```sh -bun add arkenv arktype -``` -
- -## Quickstart - -> [!TIP] -> Find more examples in the [examples](https://github.com/yamcodes/arkenv/tree/main/examples) directory. - -```ts -import { createEnv } from 'arkenv'; - -const env = createEnv({ - HOST: "string.host", // valid IP address or localhost - PORT: "number.port", // valid port number (0-65535) - NODE_ENV: "'development' | 'production' | 'test'", -}); - -// 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" -``` - -## Features - -- 🔒 **Typesafe**: Full TypeScript support with inferred types -- 🚀 **Runtime validation**: Catch missing or invalid environment variables early -- 💪 **Powered by ArkType**: Leverage ArkType's powerful type system -- 🪶 **Lightweight**: Only a single dependency ([5.6 kB](https://bundlephobia.com/package/chalk@5.4.1)) -- ⚡ **Fast**: Optimized for performance with minimal overhead - -## Documentation - -For detailed documentation and examples, please visit our [documentation site](https://arkenv.js.org/docs). - -## Plugins - -- [@arkenv/vite-plugin](https://github.com/yamcodes/arkenv/tree/main/packages/vite-plugin): [Vite](https://vite.dev/) plugin to validate environment variables at build time - -## Contributing - -Contributions are welcome! Please see [CONTRIBUTING.md](https://github.com/yamcodes/arkenv/blob/main/CONTRIBUTING.md) for more information. - -## Thanks / Inspiration - -Find projects and people who helped or inspired the creation of ArkEnv in [THANKS.md](https://github.com/yamcodes/arkenv/blob/main/THANKS.md). Thank you 🙏 diff --git a/README.md b/README.md new file mode 120000 index 000000000..ad59d6197 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +packages/arkenv/README.md \ No newline at end of file diff --git a/apps/www/app/styles/components/github-alerts.css b/apps/www/app/styles/components/github-alerts.css index d9d72465c..35b7b17e3 100644 --- a/apps/www/app/styles/components/github-alerts.css +++ b/apps/www/app/styles/components/github-alerts.css @@ -93,6 +93,7 @@ .octicon { margin-right: calc(var(--rehype-github-alerts-default-space) / 2); display: inline-block; + /* biome-ignore lint/complexity/noImportantStyles: it just works */ overflow: visible !important; vertical-align: text-bottom; } diff --git a/apps/www/source.config.ts b/apps/www/source.config.ts index 2bf682678..e078b3b9d 100644 --- a/apps/www/source.config.ts +++ b/apps/www/source.config.ts @@ -1,4 +1,4 @@ -import { remarkInstall } from "fumadocs-docgen"; +import { remarkNpm } from "fumadocs-core/mdx-plugins"; import { defineConfig, defineDocs } from "fumadocs-mdx/config"; import { rehypeGithubAlerts } from "rehype-github-alerts"; import remarkGemoji from "remark-gemoji"; @@ -13,6 +13,6 @@ export const docs = defineDocs({ export default defineConfig({ mdxOptions: { rehypePlugins: [rehypeGithubAlerts], - remarkPlugins: [remarkGemoji, remarkInstall], + remarkPlugins: [remarkGemoji, remarkNpm], }, }); diff --git a/biome.jsonc b/biome.jsonc index 1288f60fd..cb0b02d67 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -39,7 +39,8 @@ "noUnusedImports": "warn" }, "suspicious": { - "noConsole": "warn" + "noConsole": "warn", + "noUnknownAtRules": "off" }, "style": { "noParameterAssign": "error", diff --git a/package.json b/package.json index 0c1bf6a8a..d781dea20 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "typecheck": "turbo run typecheck", "docs": "turbo run dev --filter=www", "www": "turbo run dev --filter=www", - "release": "mv README.md packages/arkenv && pnpm run build:packages && changeset publish", + "release": "pnpm run build:packages && changeset publish", "fix": "biome check --write .", "check": "biome check", "check:errors": "biome check --diagnostic-level=error", diff --git a/packages/arkenv/README.md b/packages/arkenv/README.md index 23534965f..ebf005eb0 100644 --- a/packages/arkenv/README.md +++ b/packages/arkenv/README.md @@ -1,7 +1,90 @@ -# `arkenv` +

+ + arkenv - Typesafe Environment Variables + +
+ Tests Status + Bundle Size + Total Downloads + Dependency Count + Powered By ArkType +

-Hello, developers! Welcome to the `arkenv` package codebase. This directory contains the core implementation of ArkEnv, providing typesafe environment variable parsing and validation for Node.js. +## Installation -For more information, please refer to the [README](../../README.md) in the monorepo root. +
+npm -Happy coding! +```sh +npm install arkenv arktype +``` +
+ +
+pnpm + +```sh +pnpm add arkenv arktype +``` +
+ +
+Yarn + +```sh +yarn add arkenv arktype +``` +
+ +
+Bun + +```sh +bun add arkenv arktype +``` +
+ +## Quickstart + +> [!TIP] +> Find more examples in the [examples](https://github.com/yamcodes/arkenv/tree/main/examples) directory. + +```ts +import { createEnv } from 'arkenv'; + +const env = createEnv({ + HOST: "string.host", // valid IP address or localhost + PORT: "number.port", // valid port number (0-65535) + NODE_ENV: "'development' | 'production' | 'test'", +}); + +// 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" +``` + +## Features + +- 🔒 **Typesafe**: Full TypeScript support with inferred types +- 🚀 **Runtime validation**: Catch missing or invalid environment variables early +- 💪 **Powered by ArkType**: Leverage ArkType's powerful type system +- 🪶 **Lightweight**: Only a single dependency ([5.6 kB](https://bundlephobia.com/package/chalk@5.4.1)) +- ⚡ **Fast**: Optimized for performance with minimal overhead + +## Documentation + +For detailed documentation and examples, please visit our [documentation site](https://arkenv.js.org/docs). + +## Plugins + +- [@arkenv/vite-plugin](https://github.com/yamcodes/arkenv/tree/main/packages/vite-plugin): [Vite](https://vite.dev/) plugin to validate environment variables at build time + +## Contributing + +Contributions are welcome! Please see [CONTRIBUTING.md](https://github.com/yamcodes/arkenv/blob/main/CONTRIBUTING.md) for more information. + +## Thanks / Inspiration + +Find projects and people who helped or inspired the creation of ArkEnv in [THANKS.md](https://github.com/yamcodes/arkenv/blob/main/THANKS.md). Thank you 🙏 diff --git a/packages/arkenv/src/types.ts b/packages/arkenv/src/types.ts index 1ece162fc..d205b9727 100644 --- a/packages/arkenv/src/types.ts +++ b/packages/arkenv/src/types.ts @@ -4,7 +4,7 @@ import { type } from "arktype"; * A `string` that can be parsed into a number between 0 and 65535 */ export const port = type("string", "=>", (data, ctx) => { - const asNumber = Number.parseInt(data); + const asNumber = Number.parseInt(data, 10); const isInteger = Number.isInteger(asNumber); const isBetween = 0 <= asNumber && asNumber <= 65535; if (!isInteger || !isBetween) {