Skip to content

Commit edd9205

Browse files
committed
theo review
1 parent 59e18c1 commit edd9205

File tree

13 files changed

+84
-58
lines changed

13 files changed

+84
-58
lines changed

packages/varlock-website/src/content/docs/getting-started/installation.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Installation
3-
description: How to install and set up varlock in your project
3+
description: How to install and set up Varlock in your project
44
---
55

66
import ExecCommandWidget from "@/components/ExecCommandWidget.astro";
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
---
22
title: Introduction
3-
description: Introduction to varlock - declarative schema for your environment variables
3+
description: Introduction to Varlock - declarative schema for your environment variables
44
---
55

6-
Varlock is a framework-agnostic, universal environment variable management tool built on top of the [@env-spec](/env-spec/overview) specification. It provides a comprehensive set of features out of the box that simplify managing, validating, and securing your environment configuration. Whether you need type-safe environment variables, multi-environment management, secure secret handling, or leak prevention, varlock lets you focus on building your application instead of wrestling with configuration.
6+
Varlock is a universal configuration/secrets/environment variable management tool built on top of the [@env-spec](/env-spec/overview/) specification. It provides a comprehensive set of features out of the box that simplify managing, validating, and securing your environment configuration. Whether you need type-safe environment variables, multi-environment management, secure secret handling, or leak prevention, Varlock lets you focus on building your application instead of wrestling with configuration. While it is written in TypeScript, it is language and framework agnostic, and meant to be used in any project that needs configuration at build or boot time, usually passed in via environment variables.
77

88
## Features
99

1010
Varlock aims to be the most comprehensive environment variable management tool. It provides a wide range of features out of the box:
1111

12-
- **[Validation & Type Safety](/reference/data-types)** - Powerful validation capabilities with clear error messages, plus automatic type generation for IntelliSense support
13-
- **[Security](/guides/secrets)** - Automatic log redaction for sensitive values and leak detection in bundled code and server responses
14-
- **[Multi-Environment Management](/guides/environments)** - Flexible environment handling with support for environment-specific files, local overrides, and value composition
15-
- **[Secure Secrets](/guides/secrets)** - Load secrets from external providers like [1Password](/plugins/1password) via [plugins](/plugins/overview) or any CLI tool using [function calls](/reference/functions)
16-
- **[Value Composition](/reference/functions)** - Compose values together using functions, references, and external data sources
17-
- **[Framework Integrations](/integrations/overview)** - Official integrations for Next.js, Vite, Astro, and more, plus support for any language via `varlock run`
18-
- **[Replacement for dotenv](/guides/migrate-from-dotenv)** - Can be used as a direct replacement for `dotenv` in most projects with minimal code changes
19-
- **[AI-Friendly](/guides/ai-tools)** - Built with AI-assisted development in mind, helping prevent accidental secret leaks to AI agents and allowing a schema-driven approach that is easier for AI to understand and remediate.
12+
- **[Validation & Type Safety](/reference/data-types/)** - Powerful validation capabilities with clear error messages, plus automatic type generation for IntelliSense support
13+
- **[Security](/guides/secrets/)** - Automatic log redaction for sensitive values and leak detection in bundled code and server responses
14+
- **[Multi-Environment Management](/guides/environments/)** - Flexible environment handling with support for environment-specific files, local overrides, and value composition
15+
- **[Secure Secrets](/guides/secrets/)** - Load secrets from external providers like [1Password](/plugins/1password/) via [plugins](/plugins/overview/) or any CLI tool using [exec()](/reference/functions/#exec)
16+
- **[Value Composition](/reference/functions/)** - Compose values together using functions, references, and external data sources
17+
- **[Framework Integrations](/integrations/overview/)** - Official integrations for Next.js, Vite, Astro, and more, plus support for any language via `varlock run`
18+
- **[Replacement for dotenv](/guides/migrate-from-dotenv/)** - Can be used as a direct replacement for `dotenv` in most projects with minimal code changes
19+
- **[AI-Friendly](/guides/ai-tools/)** - Built with AI-assisted development in mind, helping prevent accidental secret leaks to AI agents and allowing a schema-driven approach that is easier for AI to understand and remediate
2020

2121
## AI Tooling
2222

2323
### Docs MCP
2424

25-
Varlock provides a Docs MCP server that allows AI tools to search and understand the Varlock documentation. This makes it easier for AI assistants to help you integrate and use varlock in your projects.
25+
Varlock provides a Docs MCP server that allows AI tools to search and understand the Varlock documentation. This makes it easier for AI assistants to help you integrate and use Varlock in your projects.
2626

2727
See the [MCP guide](/guides/mcp/#docs-mcp) for setup instructions for Cursor, Claude, Opencode, VS Code, and other MCP-compatible tools.
2828

@@ -32,5 +32,5 @@ Varlock also provides an `LLMs.txt` file that helps AI models understand how to
3232

3333
## Next Steps
3434

35-
Ready to get started? Check out the [Installation](/getting-started/installation) guide to set up varlock in your project.
35+
Ready to get started? Check out the [Installation](/getting-started/installation/) guide to set up Varlock in your project.
3636

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
11
---
22
title: Migration
3-
description: An overview if you have existing .env files and want to migrate to varlock
3+
description: An overview if you have existing .env files and want to migrate to Varlock
44
---
55

66
import ExecCommandWidget from "@/components/ExecCommandWidget.astro";
77

8-
## From dotenv
8+
## Loading env vars using Varlock
99

10-
In most [Node.js](/integrations/javascript) apps, you can replace `dotenv/config` with `varlock/auto-load` after [installing varlock](/getting-started/installation).
10+
### Migration from dotenv (Node.js)
11+
12+
In a [Node.js](/integrations/javascript/) app if you are already calling `dotenv/config`, you can replace it with `varlock/auto-load`.
1113

1214
```diff title="index.js" lang="js"
13-
// Before (dotenv)
1415
- import 'dotenv/config';
15-
16-
// After (varlock)
1716
+ import 'varlock/auto-load';
1817
```
1918

20-
See our [migrate from dotenv](/guides/migrate-from-dotenv) guide for more information.
19+
In some cases where `dotenv` is being called deep under the hood by another dependency, you may instead want to swap it in as a dependency override. See our [migrate from dotenv](/guides/migrate-from-dotenv/) guide for more information.
20+
21+
### Within a framework
22+
23+
We must replace framework's existing `.env` logic with Varlock. Our [framework integrations](/integrations/overview/) handle most of the work for you. After [installation](/getting-started/installation/), simply follow the instructions in the relevant integration guide to set up Varlock in your project. Usually this involves adding a new plugin to the existing build system or framework's config file.
24+
25+
### Minimal setup
26+
27+
In some cases, a code-level integration may be challenging or impossible. In this case you can use [`varlock run`](/reference/cli-commands/#run) to boot your application with env vars injected from Varlock. For example `varlock run -- your-app`. Sometimes you may need to use this alongside a deeper integration, for example to feed env vars into external tools or additional scripts.
28+
29+
2130

22-
## From specific integrations
31+
## Using `varlock/env`
2332

24-
If you're currently using `import.meta.env` or `process.env`, your code will still work after switching to varlock. However, we recommend using varlock's `ENV` object for better type-safety and improved developer experience.
33+
If you're currently using `import.meta.env` or `process.env`, your code will still work after switching to Varlock. However, we recommend using varlock's `ENV` object for better type-safety and an improved developer experience.
2534

2635
```diff title="index.js" lang="js"
2736
// Before (import.meta.env)
@@ -34,4 +43,4 @@ import { ENV } from 'varlock/env';
3443

3544
![intellisense](../../../assets/demo-images/intellisense.png)
3645

37-
See our [integrations](/integrations/overview) section for more information.
46+
See our [integrations](/integrations/overview/) section for more information.
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
---
22
title: Usage
3-
description: How to use varlock in your project
3+
description: How to use Varlock in your project
44
---
55

66
import ExecCommandWidget from "@/components/ExecCommandWidget.astro";
77

88
## Basics
99

10-
The basic workflow for using varlock is to:
10+
The basic workflow for using Varlock is to:
1111

12-
1. Run `varlock init` to set up your `.env.schema` file(s)
13-
2. Run `varlock load` to validate your environment variables
14-
3. Run `varlock run` to valid and inject your environment variables into your command
12+
1. Run [`varlock init`](/reference/cli-commands/#init) to set up your `.env.schema` file
13+
2. Run [`varlock load`](/reference/cli-commands/#load) to debug and refine your .env file(s)
14+
3. Use Varlock to load, validate, and inject env vars into your application, either:
15+
- Use an [existing framework / tool integration](/integrations/overview/) that automatically calls Varlock under the hood (_recommended_)
16+
- Use `import 'varlock/auto-load'` in a backend JavaScript/TypeScript project
17+
- Boot your command via [`varlock run`](/reference/cli-commands/#run)<br/>(_necessary for non-JS/TS projects, or feeding env vars to external tools_)
1518

1619

17-
:::tip
18-
In most cases, you'll want to use an integration to handle the loading and validation of environment variables for you. See the [Integrations](/integrations/overview) section for more information.
19-
:::
20-
2120
## CLI Commands
2221

2322
### `varlock load`
@@ -26,14 +25,14 @@ In most cases, you'll want to use an integration to handle the loading and valid
2625

2726
Validates your environment variables according to your `.env.schema` and associated `.env.*` files, and prints the results.
2827

29-
Useful for debugging locally, and in CI to print out a summary of env vars, also when you're authoring your `.env.schema` file and want immediate feedback.
28+
Useful for debugging locally, and in CI to print out a summary of env vars, also when you're authoring your `.env.schema` file and want immediate feedback.
3029

3130
:::tip
3231
Our [integrations](/integrations/overview) all use `varlock load` under the hood, so you'll get the same developer experience, but typically they will only let you know if there are errors, rather than the full summary.
3332
:::
3433

3534

36-
See the [`varlock load` CLI Reference](/reference/cli-commands/#varlock-load) for more information.
35+
See the [`varlock load` CLI Reference](/reference/cli-commands/#load) for more information.
3736

3837
### `varlock run`
3938

@@ -42,4 +41,4 @@ See the [`varlock load` CLI Reference](/reference/cli-commands/#varlock-load) fo
4241
Executes a command in a child process, injecting your resolved and validated environment variables. This is useful when a code-level integration is not possible. For example, if you're using a database migration tool, you can use `varlock run` to run the migration tool with the correct environment variables. Or if you're using a non-js/ts language, you can use `varlock run` to run a command and inject validated environment variables.
4342

4443

45-
See the [`varlock run` CLI Reference](/reference/cli-commands/#varlock-run) for more information.
44+
See the [`varlock run` CLI Reference](/reference/cli-commands/#run) for more information.

packages/varlock-website/src/content/docs/getting-started/wrapping-up.mdx

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,65 @@ description: How to get your project ready for production and collaboration
55

66
import ExecCommandWidget from "@/components/ExecCommandWidget.astro";
77

8-
## Repo setup
8+
## Next steps with your schema
9+
10+
With a more flexible env var toolkit, after an initial migration, you may be tempted to take advantage
11+
of Varlock's features to improve your developer experience and security posture.
12+
13+
- Move more configuration constants out of application code and into your `.env` files
14+
- Reduce the number of of env-style checks in your code, favouring individual flags, with a default value set based on the current env
15+
- Add deeper validation, more thorough comments, and additional docs links to each env var within your schema
16+
- Compose values together to keep your configuration DRY
17+
- Use [imports](/guides/import/) to share common configuration across a monorepo, or to break up a large `.env.schema`
18+
- Reduce secret sprawl, by loading secrets from a single source of truth, instead of injecting them from your CI/hosting platform
19+
20+
21+
## Repo setup
922

1023
### `.gitignore`
1124

1225
Depending on your setup you will want to update your `.gitignore` to _not_ ignore your `.env.schema` file and any other `.env.xxx` files that can now be safely committed to your repo if they don't contain secrets (which they shouldn't).
1326

14-
We also recommend that you ignore `env.d.ts` as it is dynamically generated based the hierarchy of env files being loaded on each individual machine.
27+
If using [generated types](/reference/root-decorators/#generatetypes), we also recommend that you ignore the generated file (usually `env.d.ts` in TypeScript) as it is dynamically generated based the hierarchy of env files being loaded on each individual machine.
1528

1629
```diff title=".gitignore"
17-
# Include .env.schema file
18-
+!.env.schema
19-
# Exclude env.d.ts
30+
31+
# Include .env.schema, .env.<dev|preview|prod|...> file
32+
# exclude local overrides
33+
-.env.*
34+
+.env.local
35+
+.env.*.local
36+
37+
# Exclude generated env types file
2038
+env.d.ts
2139
```
2240

2341
:::tip
24-
Depending on the [AI Tools](/guides/ai-tools) you use, you may need to add a similar rule to allow `.env.schema` to be modified. For example, in `.cursorignore`.
42+
Depending on the [AI Tools](/guides/ai-tools/) you use, you may need to add a similar rule to allow `.env.schema` to be modified. For example, in `.cursorignore`.
2543
:::
2644

2745
### Monorepos
2846

29-
Consider how you can reuse and modularize your schema if you have a monorepo or multi-service setup. See the [Imports](/guides/import) guide for more information.
47+
Consider how you can reuse and modularize your schema if you have a monorepo or multi-service setup. See the [Imports](/guides/import/) guide for more information.
3048

3149
## Deployment
3250

3351
### CI/CD platforms
3452

35-
It may be useful to validate your schema in CI/CD pipelines, especially if you want to validate configurations that you don't have access to locally (e.g. Staging or Production). You can do this manually by running `varlock load` in your pipeline. And if you're using GitHub Actions, you can use the [Varlock GitHub Action](/integrations/github-action) to validate your schema automatically.
53+
It may be useful to validate your schema in CI/CD pipelines, especially if you want to validate configurations that you don't have access to locally (e.g. Staging or Production). You can do this manually by running `varlock load` in your pipeline. And if you're using GitHub Actions, you can use the [Varlock GitHub Action](/integrations/github-action/) to validate your schema automatically.
3654

3755
:::tip
38-
Having a well architected multi-environment setup is key to healthy CI/CD workflows. See the [Environments](/guides/environments) guide for more information.
56+
Having a well architected multi-environment setup is key to healthy CI/CD workflows. See the [Environments](/guides/environments/) guide for more information.
3957
:::
4058

4159
### Production deployments
4260

43-
Because varlock supports loading environment variables from the environment itself or via a [function](/reference/functions/) in your `.env.schema`, there are a few different approaches.
61+
Because varlock supports loading environment variables from the environment itself or via a [function](/reference/functions/) in your `.env.schema`, there are a few different approaches.
4462

4563
If you're already using your deployment platform's environment variable management, you may not need to do anything to benefit from varlock's validation and security features. If you have a multi-environment setup, you may need to set the `currentEnv` environment flag to the correct environment.
4664

4765
```bash
4866
APP_ENV=production varlock run -- your-production-command
4967
```
5068

51-
If you're not using your deployment platform's environment variable management, you may consider using one of our [plugins](/plugins/overview) to securely load environment variables from a secret storage system such as [1Password](/plugins/1password/).
69+
If you're not using your deployment platform's environment variable management, you may consider using one of our [plugins](/plugins/overview/) to securely load environment variables from a secret storage system such as [1Password](/plugins/1password/).

packages/varlock-website/src/content/docs/guides/telemetry.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ The anonymous usage data helps us:
6868
- Make informed decisions about future development
6969
- Prioritize bug fixes and new features
7070

71-
If you have any questions about our analytics or privacy practices, please [start a discussion](https://github.com/dmno-dev/varlock/discussions) on GitHub.
71+
If you have any questions about our analytics or privacy practices, please [start a discussion](https://github.com/dmno-dev/varlock/discussions) on GitHub.

packages/varlock-website/src/content/docs/integrations/astro.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ If you find you are not getting type completion on `ENV`, you may need to add yo
9696

9797
Even in a static front-end project, you may have other scripts in your project that rely on sensitive config.
9898

99-
You can use [`varlock run`](/reference/cli-commands/#varlock-run) to inject resolved config into other scripts as regular env vars.
99+
You can use [`varlock run`](/reference/cli-commands/#run) to inject resolved config into other scripts as regular env vars.
100100

101101
<ExecCommandWidget command="varlock run -- node ./script.js" showBinary={false} />
102102

packages/varlock-website/src/content/docs/integrations/javascript.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ If you are using [`dotenv`](https://www.npmjs.com/package/dotenv), or a package
3434

3535
## Boot via `varlock run`
3636

37-
A less invasive way to use varlock with your application is to run your application via [`varlock run`](/reference/cli-commands/#varlock-run).
37+
A less invasive way to use varlock with your application is to run your application via [`varlock run`](/reference/cli-commands/#run).
3838

3939
```bash
4040
varlock run -- <your-command>

packages/varlock-website/src/content/docs/integrations/nextjs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ _you may need to adjust if you don't want to copy certain .local files_
299299

300300

301301
Standalone builds do not copy dependency binaries, and varlock depends on the CLI to load.
302-
So wherever you are booting your standalone server, you will also need to [install the varlock binary](/getting-started/installation/) and boot your server via [`varlock run`](/reference/cli-commands/#varlock-run)
302+
So wherever you are booting your standalone server, you will also need to [install the varlock binary](/getting-started/installation/) and boot your server via [`varlock run`](/reference/cli-commands/#run)
303303

304304
```bash
305305
varlock run -- node .next/standalone/server.js

packages/varlock-website/src/content/docs/integrations/other-languages.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import ExecCommandWidget from "@/components/ExecCommandWidget.astro";
77

88
To use varlock with other languages, you'll likely want to [install the standalone binary](/getting-started/installation/#as-a-binary), rather than using a JS package manager.
99

10-
To use it with your application code, you must use [`varlock run`](/reference/cli-commands/#varlock-run) to load and validate your environment variables, then run the command you provided with those environment variables injected into the process.
10+
To use it with your application code, you must use [`varlock run`](/reference/cli-commands/#run) to load and validate your environment variables, then run the command you provided with those environment variables injected into the process.
1111

1212
```bash
1313
varlock run -- <your-command>

0 commit comments

Comments
 (0)