ProductEnv for VS Code
See which ProductEnv environments define the environment variables your code reads, without
leaving the editor. The extension only works with key names; secret values are fetched only
when you explicitly pull a .env file or copy one value, and they never appear in hovers, the
tree view, notifications or logs.
Requirements
- A workspace folder linked to a ProductEnv project: a
.productenv.json at the folder root,
created by productenv init (the ProductEnv CLI).
- Credentials, either:
- your CLI login: run ProductEnv: Sign in (it runs
productenv login in a terminal). The
extension reads the session the CLI saves in ~/.productenv/config.json, or
- a project service token (
pe_st_…): run ProductEnv: Use service token. It is kept in
VS Code's secret storage, takes precedence over the CLI login for that project, and only reads
its own environment.
A token is only ever sent to the API it belongs to.
Features
Hover on process.env.X, process.env["X"], import.meta.env.X, Deno.env.get("X")
(JavaScript, TypeScript, JSX, TSX), os.environ["X"], os.environ.get("X"), os.getenv("X")
(Python), ENV["X"], ENV.fetch("X") (Ruby), and on keys in .env files: ✓/✗ per
environment, protected and locked markers, and the key's schema type and description.
Diagnostics: a Warning when a key your code reads is defined in no environment, and an
Information when a required schema key is missing from an environment.
ProductEnv view in the activity bar: environments → key names (values masked), with the
required keys an environment is missing.
Commands (Command Palette, category "ProductEnv"):
| Command |
What it does |
| Refresh |
Reloads keys (they are cached for 5 minutes per workspace folder). |
| Pull .env |
Writes an environment's secrets to .env, .env.local, .env.<environment> or a file you choose (mode 0600) and warns when the file is not git-ignored. |
| Generate .env.example |
Saves an environment's .env.example (key names, placeholders, comments; no values). |
| Open in dashboard |
Opens the linked project's environment in the ProductEnv dashboard. |
| Copy value |
Copies one value to the clipboard after a confirmation. VS Code cannot clear the clipboard for you: clear it when you are done. |
| Validate required keys |
Lists the required schema keys each environment is missing. |
| Use service token / Clear service token |
Stores or removes a service token for the linked project. |
| Sign in |
Runs productenv login in a terminal. |
Settings
| Setting |
Default |
|
productenv.apiUrl |
(empty) |
API URL. Empty: the API of your CLI login, else https://api.product-env.com. |
productenv.webUrl |
(empty) |
Dashboard URL for Open in dashboard. Empty: the CLI's saved one, else https://app.product-env.com. |
productenv.cliCommand |
productenv |
Command used by Sign in, e.g. npx productenv. |
productenv.diagnostics.enabled |
true |
Turns the diagnostics on or off. |
productenv.diagnostics.ignoredKeys |
["NODE_ENV"] |
Keys never reported. |
The URL and CLI settings are user settings only: a workspace cannot redirect your token or change
the command that runs.
Development
pnpm --filter productenv-vscode build # dist/extension.js (CommonJS bundle)
pnpm --filter productenv-vscode test # unit tests of the parsers and formatting
pnpm --filter productenv-vscode package # productenv-vscode-<version>.vsix
Install the .vsix with Extensions: Install from VSIX….
| |