This commit is contained in:
2026-08-14 16:03:47 +01:00
parent fd53e3f4fb
commit dfdc3b2840
2463 changed files with 186456 additions and 111315 deletions
+62 -89
View File
@@ -1,118 +1,91 @@
# std-env
[![npm](https://img.shields.io/npm/dm/std-env.svg?style=flat-square)](http://npmjs.com/package/std-env)
[![npm](https://img.shields.io/npm/v/std-env.svg?style=flat-square)](http://npmjs.com/package/std-env)
[![bundlephobia](https://img.shields.io/bundlephobia/min/std-env/latest.svg?style=flat-square)](https://bundlephobia.com/result?p=std-env)
[![npm version](https://img.shields.io/npm/v/std-env.svg?style=flat-square)](http://npmjs.com/package/std-env)
[![npm downloads](https://img.shields.io/npm/dm/std-env.svg?style=flat-square)](http://npmjs.com/package/std-env)
[![bundle size](https://img.shields.io/bundlephobia/min/std-env/latest.svg?style=flat-square)](https://bundlephobia.com/result?p=std-env)
> Runtime agnostic JS utils
## Installation
```sh
# Using npm
npm i std-env
# Using pnpm
pnpm i std-env
# Using yarn
yarn add std-env
```
## Usage
```js
// ESM
import { env, isDevelopment, isProduction } from "std-env";
// CommonJS
const { env, isDevelopment, isProduction } = require("std-env");
```
## Flags
- `hasTTY`
- `hasWindow`
- `isDebug`
- `isDevelopment`
- `isLinux`
- `isMacOS`
- `isMinimal`
- `isProduction`
- `isTest`
- `isWindows`
- `platform`
- `isColorSupported`
- `nodeVersion`
- `nodeMajorVersion`
You can read more about how each flag works from [./src/flags.ts](./src/flags.ts).
## Provider Detection
`std-env` can automatically detect the current runtime provider based on environment variables.
You can use `isCI` and `platform` exports to detect it:
```ts
import { isCI, provider, providerInfo } from "std-env";
console.log({
isCI, // true
provider, // "github_actions"
providerInfo, // { name: "github_actions", isCI: true }
});
```
List of well known providers can be found from [./src/providers.ts](./src/providers.ts).
Runtime-agnostic JS utils for detecting environments, runtimes, CI providers, and AI coding agents.
## Runtime Detection
`std-env` can automatically detect the current JavaScript runtime based on global variables, following the [WinterCG Runtime Keys proposal](https://runtime-keys.proposal.wintercg.org/):
Detects the current JavaScript runtime based on global variables, following the [WinterCG Runtime Keys proposal](https://runtime-keys.proposal.wintercg.org/).
```ts
import { runtime, runtimeInfo } from "std-env";
// "" | "node" | "deno" | "bun" | "workerd" ...
console.log(runtime);
// { name: "node" }
console.log(runtimeInfo);
console.log(runtime); // "" | "node" | "deno" | "bun" | "workerd" ...
console.log(runtimeInfo); // { name: "node" }
```
You can also use individual named exports for each runtime detection:
Individual named exports: `isNode`, `isBun`, `isDeno`, `isNetlify`, `isEdgeLight`, `isWorkerd`, `isFastly`
> [!NOTE]
> When running code in Bun and Deno with Node.js compatibility mode, `isNode` flag will be also `true`, indicating running in a Node.js compatible runtime.
>
> Use `runtime === "node"` if you need strict check for Node.js runtime.
> `isNode` is also `true` in Bun/Deno with Node.js compatibility mode. Use `runtime === "node"` for strict checks.
- `isNode`
- `isBun`
- `isDeno`
- `isNetlify`
- `isEdgeLight`
- `isWorkerd`
- `isFastly`
See [./src/runtimes.ts](./src/runtimes.ts) for the full list.
List of well known providers can be found from [./src/runtimes.ts](./src/runtimes.ts).
## Provider Detection
## Platform-Agnostic `env`
`std-env` provides a lightweight proxy to access environment variables in a platform agnostic way.
Detects the current CI/CD provider based on environment variables.
```ts
import { env } from "std-env";
import { isCI, provider, providerInfo } from "std-env";
console.log({ isCI, provider, providerInfo });
// { isCI: true, provider: "github_actions", providerInfo: { name: "github_actions", ci: true } }
```
## Platform-Agnostic `process`
Use `detectProvider()` to re-run detection. See [./src/providers.ts](./src/providers.ts) for the full list.
`std-env` provides a lightweight proxy to access [`process`](https://nodejs.org/api/process.html) object in a platform agnostic way.
## Agent Detection
Detects if the environment is running inside an AI coding agent.
```ts
import { process } from "std-env";
import { isAgent, agent, agentInfo } from "std-env";
console.log({ isAgent, agent, agentInfo });
// { isAgent: true, agent: "claude", agentInfo: { name: "claude" } }
```
Set the `AI_AGENT` env var to explicitly specify the agent name. Use `detectAgent()` to re-run detection.
Supported agents: `cursor`, `claude`, `devin`, `replit`, `gemini`, `codex`, `auggie`, `opencode`, `kiro`, `goose`, `pi`
## Flags
```js
import { env, isDevelopment, isProduction } from "std-env";
```
| Export | Description |
| ------------------ | ------------------------------------------------------------ |
| `hasTTY` | stdout TTY is available |
| `hasWindow` | Global `window` is available |
| `isCI` | Running in CI |
| `isColorSupported` | Terminal color output supported |
| `isDebug` | `DEBUG` env var is set |
| `isDevelopment` | `NODE_ENV` is `dev`/`development` or `MODE` is `development` |
| `isLinux` | Linux platform |
| `isMacOS` | macOS (darwin) platform |
| `isMinimal` | `MINIMAL` env is set, CI, test, or no TTY |
| `isProduction` | `NODE_ENV` or `MODE` is `production` |
| `isTest` | `NODE_ENV` is `test` or `TEST` env is set |
| `isWindows` | Windows platform |
| `platform` | Value of `process.platform` |
| `nodeVersion` | Node.js version string (e.g. `"22.0.0"`) |
| `nodeMajorVersion` | Node.js major version number (e.g. `22`) |
See [./src/flags.ts](./src/flags.ts) for details.
## Environment
| Export | Description |
| --------- | ---------------------------------------------------- |
| `env` | Universal `process.env` (works across all runtimes) |
| `process` | Universal `process` shim (works across all runtimes) |
| `nodeENV` | Current `NODE_ENV` value (undefined if unset) |
## License
MIT
-1
View File
File diff suppressed because one or more lines are too long
-92
View File
@@ -1,92 +0,0 @@
type EnvObject = Record<string, string | undefined>;
declare const env: EnvObject;
declare const nodeENV: string;
/** Value of process.platform */
declare const platform: string;
/** Detect if `CI` environment variable is set or a provider CI detected */
declare const isCI: boolean;
/** Detect if stdout.TTY is available */
declare const hasTTY: boolean;
/** Detect if global `window` object is available */
declare const hasWindow: boolean;
/** Detect if `DEBUG` environment variable is set */
declare const isDebug: boolean;
/** Detect if `NODE_ENV` environment variable is `test` */
declare const isTest: boolean;
/** Detect if `NODE_ENV` environment variable is `production` */
declare const isProduction: boolean;
/** Detect if `NODE_ENV` environment variable is `dev` or `development` */
declare const isDevelopment: boolean;
/** Detect if MINIMAL environment variable is set, running in CI or test or TTY is unavailable */
declare const isMinimal: boolean;
/** Detect if process.platform is Windows */
declare const isWindows: boolean;
/** Detect if process.platform is Linux */
declare const isLinux: boolean;
/** Detect if process.platform is macOS (darwin kernel) */
declare const isMacOS: boolean;
/** Color Support */
declare const isColorSupported: boolean;
/** Node.js versions */
declare const nodeVersion: string | null;
declare const nodeMajorVersion: number | null;
interface Process extends Partial<Omit<typeof globalThis.process, "versions">> {
env: EnvObject;
versions: Record<string, string>;
}
declare const process: Process;
type ProviderName = "" | "appveyor" | "aws_amplify" | "azure_pipelines" | "azure_static" | "appcircle" | "bamboo" | "bitbucket" | "bitrise" | "buddy" | "buildkite" | "circle" | "cirrus" | "cloudflare_pages" | "cloudflare_workers" | "codebuild" | "codefresh" | "drone" | "drone" | "dsari" | "github_actions" | "gitlab" | "gocd" | "layerci" | "hudson" | "jenkins" | "magnum" | "netlify" | "nevercode" | "render" | "sail" | "semaphore" | "screwdriver" | "shippable" | "solano" | "strider" | "teamcity" | "travis" | "vercel" | "appcenter" | "codesandbox" | "stackblitz" | "stormkit" | "cleavr" | "zeabur" | "codesphere" | "railway" | "deno-deploy" | "firebase_app_hosting";
type ProviderInfo = {
name: ProviderName;
ci?: boolean;
[meta: string]: any;
};
/** Current provider info */
declare const providerInfo: ProviderInfo;
declare const provider: ProviderName;
type RuntimeName = "workerd" | "deno" | "netlify" | "node" | "bun" | "edge-light" | "fastly" | "";
type RuntimeInfo = {
name: RuntimeName;
};
/**
* Indicates if running in Node.js or a Node.js compatible runtime.
*
* **Note:** When running code in Bun and Deno with Node.js compatibility mode, `isNode` flag will be also `true`, indicating running in a Node.js compatible runtime.
*
* Use `runtime === "node"` if you need strict check for Node.js runtime.
*/
declare const isNode: boolean;
/**
* Indicates if running in Bun runtime.
*/
declare const isBun: boolean;
/**
* Indicates if running in Deno runtime.
*/
declare const isDeno: boolean;
/**
* Indicates if running in Fastly runtime.
*/
declare const isFastly: boolean;
/**
* Indicates if running in Netlify runtime.
*/
declare const isNetlify: boolean;
/**
*
* Indicates if running in EdgeLight (Vercel Edge) runtime.
*/
declare const isEdgeLight: boolean;
/**
* Indicates if running in Cloudflare Workers runtime.
*/
declare const isWorkerd: boolean;
declare const runtimeInfo: RuntimeInfo | undefined;
declare const runtime: RuntimeName;
export { env, hasTTY, hasWindow, isBun, isCI, isColorSupported, isDebug, isDeno, isDevelopment, isEdgeLight, isFastly, isLinux, isMacOS, isMinimal, isNetlify, isNode, isProduction, isTest, isWindows, isWorkerd, nodeENV, nodeMajorVersion, nodeVersion, platform, process, provider, providerInfo, runtime, runtimeInfo };
export type { EnvObject, Process, ProviderInfo, ProviderName, RuntimeInfo, RuntimeName };
+140 -50
View File
@@ -1,7 +1,60 @@
type EnvObject = Record<string, string | undefined>;
declare const env: EnvObject;
declare const nodeENV: string;
//#region src/agents.d.ts
/**
* Represents the name of an AI coding agent.
*/
type AgentName = (string & {}) | "cursor" | "claude" | "devin" | "replit" | "gemini" | "codex" | "auggie" | "opencode" | "kiro" | "goose" | "pi";
/**
* Provides information about an AI coding agent.
*/
type AgentInfo = {
/**
* The name of the AI coding agent. See {@link AgentName} for possible values.
*/
name?: AgentName;
};
/**
* Detects the current AI coding agent from environment variables.
*
* Supported agents: `cursor`, `claude`, `devin`, `replit`, `gemini`, `codex`, `auggie`, `opencode`, `kiro`, `goose`, `pi`
*
* You can also set the `AI_AGENT` environment variable to explicitly specify the agent name.
*/
declare function detectAgent(): AgentInfo;
/**
* The detected agent information for the current execution context.
* This value is evaluated once at module initialisation.
*/
declare const agentInfo: AgentInfo;
/**
* Name of the detected agent.
*/
declare const agent: AgentName | undefined;
/**
* A boolean flag indicating whether the current environment is running inside an AI coding agent.
*/
declare const isAgent: boolean;
//#endregion
//#region src/env.d.ts
/**
* Runtime-agnostic reference to environment variables.
*
* Resolves to `globalThis.process.env` when available, otherwise an empty object.
*/
declare const env: Record<string, string | undefined>;
/**
* Runtime-agnostic reference to the `process` global.
*
* Resolves to `globalThis.process` when available, otherwise a minimal shim containing only `env`.
*/
declare const process: Partial<typeof globalThis.process>;
/**
* Current value of the `NODE_ENV` environment variable (or static value if replaced during build).
*
* If `NODE_ENV` is not set, this will be undefined.
*/
declare const nodeENV: string | undefined;
//#endregion
//#region src/flags.d.ts
/** Value of process.platform */
declare const platform: string;
/** Detect if `CI` environment variable is set or a provider CI detected */
@@ -12,11 +65,11 @@ declare const hasTTY: boolean;
declare const hasWindow: boolean;
/** Detect if `DEBUG` environment variable is set */
declare const isDebug: boolean;
/** Detect if `NODE_ENV` environment variable is `test` */
/** Detect if `NODE_ENV` environment variable is `test` or `TEST` environment variable is set */
declare const isTest: boolean;
/** Detect if `NODE_ENV` environment variable is `production` */
/** Detect if `NODE_ENV` or `MODE` environment variable is `production` */
declare const isProduction: boolean;
/** Detect if `NODE_ENV` environment variable is `dev` or `development` */
/** Detect if `NODE_ENV` environment variable is `dev` or `development`, or if `MODE` environment variable is `development` */
declare const isDevelopment: boolean;
/** Detect if MINIMAL environment variable is set, running in CI or test or TTY is unavailable */
declare const isMinimal: boolean;
@@ -26,67 +79,104 @@ declare const isWindows: boolean;
declare const isLinux: boolean;
/** Detect if process.platform is macOS (darwin kernel) */
declare const isMacOS: boolean;
/** Color Support */
/** Detect if terminal color output is supported based on `NO_COLOR`, `FORCE_COLOR`, TTY, and CI environment */
declare const isColorSupported: boolean;
/** Node.js versions */
/** Node.js version string (e.g. `"20.11.0"`), or `null` if not running in Node.js */
declare const nodeVersion: string | null;
/** Node.js major version number (e.g. `20`), or `null` if not running in Node.js */
declare const nodeMajorVersion: number | null;
interface Process extends Partial<Omit<typeof globalThis.process, "versions">> {
env: EnvObject;
versions: Record<string, string>;
}
declare const process: Process;
type ProviderName = "" | "appveyor" | "aws_amplify" | "azure_pipelines" | "azure_static" | "appcircle" | "bamboo" | "bitbucket" | "bitrise" | "buddy" | "buildkite" | "circle" | "cirrus" | "cloudflare_pages" | "cloudflare_workers" | "codebuild" | "codefresh" | "drone" | "drone" | "dsari" | "github_actions" | "gitlab" | "gocd" | "layerci" | "hudson" | "jenkins" | "magnum" | "netlify" | "nevercode" | "render" | "sail" | "semaphore" | "screwdriver" | "shippable" | "solano" | "strider" | "teamcity" | "travis" | "vercel" | "appcenter" | "codesandbox" | "stackblitz" | "stormkit" | "cleavr" | "zeabur" | "codesphere" | "railway" | "deno-deploy" | "firebase_app_hosting";
//#endregion
//#region src/providers.d.ts
/**
* Represents the name of a CI/CD or Deployment provider.
*/
type ProviderName = (string & {}) | "appveyor" | "aws_amplify" | "azure_pipelines" | "azure_static" | "appcircle" | "bamboo" | "bitbucket" | "bitrise" | "buddy" | "buildkite" | "circle" | "cirrus" | "cloudflare_pages" | "cloudflare_workers" | "google_cloudrun" | "google_cloudrun_job" | "codebuild" | "codefresh" | "drone" | "drone" | "dsari" | "github_actions" | "gitlab" | "gocd" | "layerci" | "hudson" | "jenkins" | "magnum" | "netlify" | "nevercode" | "render" | "sail" | "semaphore" | "screwdriver" | "shippable" | "solano" | "strider" | "teamcity" | "travis" | "vercel" | "appcenter" | "codesandbox" | "stackblitz" | "stormkit" | "cleavr" | "zeabur" | "codesphere" | "railway" | "deno-deploy" | "firebase_app_hosting" | "edgeone_pages";
/**
* Provides information about a CI/CD or Deployment provider, including its name and possibly other metadata.
*/
type ProviderInfo = {
name: ProviderName;
ci?: boolean;
[meta: string]: any;
};
/** Current provider info */
declare const providerInfo: ProviderInfo;
declare const provider: ProviderName;
type RuntimeName = "workerd" | "deno" | "netlify" | "node" | "bun" | "edge-light" | "fastly" | "";
type RuntimeInfo = {
name: RuntimeName;
/**
* The name of the CI/CD or Deployment provider. See {@link ProviderName} for possible values.
*/
name: ProviderName;
/**
* If is set to `true`, the environment is recognised as a CI/CD provider.
*/
ci?: boolean;
/**
* Arbitrary metadata associated with the provider.
*/
[meta: string]: any;
};
/**
* Indicates if running in Node.js or a Node.js compatible runtime.
*
* **Note:** When running code in Bun and Deno with Node.js compatibility mode, `isNode` flag will be also `true`, indicating running in a Node.js compatible runtime.
*
* Use `runtime === "node"` if you need strict check for Node.js runtime.
*/
* Detects the current CI/CD or Deployment provider from environment variables.
*/
declare function detectProvider(): ProviderInfo;
/**
* The detected provider information for the current execution context.
* This value is evaluated once at module initialisation.
*/
declare const providerInfo: ProviderInfo;
/**
* Name of the detected provider, defaults to an empty string if no provider is detected.
*/
declare const provider: ProviderName;
//#endregion
//#region src/runtimes.d.ts
/**
* Represents the name of a JavaScript runtime.
*
* @see https://runtime-keys.proposal.wintercg.org/
*/
type RuntimeName = (string & {}) | "workerd" | "deno" | "netlify" | "node" | "bun" | "edge-light" | "fastly";
type RuntimeInfo = {
/**
* The name of the detected runtime.
*/
name: RuntimeName;
};
/**
* Indicates if running in Node.js or a Node.js compatible runtime.
*
* **Note:** When running code in Bun and Deno with Node.js compatibility mode, `isNode` flag will be also `true`, indicating running in a Node.js compatible runtime.
*
* Use `runtime === "node"` if you need strict check for Node.js runtime.
*/
declare const isNode: boolean;
/**
* Indicates if running in Bun runtime.
*/
* Indicates if running in Bun runtime.
*/
declare const isBun: boolean;
/**
* Indicates if running in Deno runtime.
*/
* Indicates if running in Deno runtime.
*/
declare const isDeno: boolean;
/**
* Indicates if running in Fastly runtime.
*/
* Indicates if running in Fastly runtime.
*/
declare const isFastly: boolean;
/**
* Indicates if running in Netlify runtime.
*/
* Indicates if running in Netlify runtime.
*/
declare const isNetlify: boolean;
/**
*
* Indicates if running in EdgeLight (Vercel Edge) runtime.
*/
* Indicates if running in EdgeLight (Vercel Edge) runtime.
*/
declare const isEdgeLight: boolean;
/**
* Indicates if running in Cloudflare Workers runtime.
*/
* Indicates if running in Cloudflare Workers runtime.
*
* https://developers.cloudflare.com/workers/runtime-apis/web-standards/#navigatoruseragent
*/
declare const isWorkerd: boolean;
/**
* Contains information about the detected runtime, if any.
*/
declare const runtimeInfo: RuntimeInfo | undefined;
/**
* A convenience constant that returns the name of the detected runtime,
* defaults to an empty string if no runtime is detected.
*/
declare const runtime: RuntimeName;
export { env, hasTTY, hasWindow, isBun, isCI, isColorSupported, isDebug, isDeno, isDevelopment, isEdgeLight, isFastly, isLinux, isMacOS, isMinimal, isNetlify, isNode, isProduction, isTest, isWindows, isWorkerd, nodeENV, nodeMajorVersion, nodeVersion, platform, process, provider, providerInfo, runtime, runtimeInfo };
export type { EnvObject, Process, ProviderInfo, ProviderName, RuntimeInfo, RuntimeName };
//#endregion
export { type AgentInfo, type AgentName, type ProviderInfo, type ProviderName, type RuntimeInfo, type RuntimeName, agent, agentInfo, detectAgent, detectProvider, env, hasTTY, hasWindow, isAgent, isBun, isCI, isColorSupported, isDebug, isDeno, isDevelopment, isEdgeLight, isFastly, isLinux, isMacOS, isMinimal, isNetlify, isNode, isProduction, isTest, isWindows, isWorkerd, nodeENV, nodeMajorVersion, nodeVersion, platform, process, provider, providerInfo, runtime, runtimeInfo };
-92
View File
@@ -1,92 +0,0 @@
type EnvObject = Record<string, string | undefined>;
declare const env: EnvObject;
declare const nodeENV: string;
/** Value of process.platform */
declare const platform: string;
/** Detect if `CI` environment variable is set or a provider CI detected */
declare const isCI: boolean;
/** Detect if stdout.TTY is available */
declare const hasTTY: boolean;
/** Detect if global `window` object is available */
declare const hasWindow: boolean;
/** Detect if `DEBUG` environment variable is set */
declare const isDebug: boolean;
/** Detect if `NODE_ENV` environment variable is `test` */
declare const isTest: boolean;
/** Detect if `NODE_ENV` environment variable is `production` */
declare const isProduction: boolean;
/** Detect if `NODE_ENV` environment variable is `dev` or `development` */
declare const isDevelopment: boolean;
/** Detect if MINIMAL environment variable is set, running in CI or test or TTY is unavailable */
declare const isMinimal: boolean;
/** Detect if process.platform is Windows */
declare const isWindows: boolean;
/** Detect if process.platform is Linux */
declare const isLinux: boolean;
/** Detect if process.platform is macOS (darwin kernel) */
declare const isMacOS: boolean;
/** Color Support */
declare const isColorSupported: boolean;
/** Node.js versions */
declare const nodeVersion: string | null;
declare const nodeMajorVersion: number | null;
interface Process extends Partial<Omit<typeof globalThis.process, "versions">> {
env: EnvObject;
versions: Record<string, string>;
}
declare const process: Process;
type ProviderName = "" | "appveyor" | "aws_amplify" | "azure_pipelines" | "azure_static" | "appcircle" | "bamboo" | "bitbucket" | "bitrise" | "buddy" | "buildkite" | "circle" | "cirrus" | "cloudflare_pages" | "cloudflare_workers" | "codebuild" | "codefresh" | "drone" | "drone" | "dsari" | "github_actions" | "gitlab" | "gocd" | "layerci" | "hudson" | "jenkins" | "magnum" | "netlify" | "nevercode" | "render" | "sail" | "semaphore" | "screwdriver" | "shippable" | "solano" | "strider" | "teamcity" | "travis" | "vercel" | "appcenter" | "codesandbox" | "stackblitz" | "stormkit" | "cleavr" | "zeabur" | "codesphere" | "railway" | "deno-deploy" | "firebase_app_hosting";
type ProviderInfo = {
name: ProviderName;
ci?: boolean;
[meta: string]: any;
};
/** Current provider info */
declare const providerInfo: ProviderInfo;
declare const provider: ProviderName;
type RuntimeName = "workerd" | "deno" | "netlify" | "node" | "bun" | "edge-light" | "fastly" | "";
type RuntimeInfo = {
name: RuntimeName;
};
/**
* Indicates if running in Node.js or a Node.js compatible runtime.
*
* **Note:** When running code in Bun and Deno with Node.js compatibility mode, `isNode` flag will be also `true`, indicating running in a Node.js compatible runtime.
*
* Use `runtime === "node"` if you need strict check for Node.js runtime.
*/
declare const isNode: boolean;
/**
* Indicates if running in Bun runtime.
*/
declare const isBun: boolean;
/**
* Indicates if running in Deno runtime.
*/
declare const isDeno: boolean;
/**
* Indicates if running in Fastly runtime.
*/
declare const isFastly: boolean;
/**
* Indicates if running in Netlify runtime.
*/
declare const isNetlify: boolean;
/**
*
* Indicates if running in EdgeLight (Vercel Edge) runtime.
*/
declare const isEdgeLight: boolean;
/**
* Indicates if running in Cloudflare Workers runtime.
*/
declare const isWorkerd: boolean;
declare const runtimeInfo: RuntimeInfo | undefined;
declare const runtime: RuntimeName;
export { env, hasTTY, hasWindow, isBun, isCI, isColorSupported, isDebug, isDeno, isDevelopment, isEdgeLight, isFastly, isLinux, isMacOS, isMinimal, isNetlify, isNode, isProduction, isTest, isWindows, isWorkerd, nodeENV, nodeMajorVersion, nodeVersion, platform, process, provider, providerInfo, runtime, runtimeInfo };
export type { EnvObject, Process, ProviderInfo, ProviderName, RuntimeInfo, RuntimeName };
+1 -1
View File
@@ -1 +1 @@
const r=Object.create(null),i=e=>globalThis.process?.env||import.meta.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?r:globalThis),o=new Proxy(r,{get(e,s){return i()[s]??r[s]},has(e,s){const E=i();return s in E||s in r},set(e,s,E){const B=i(!0);return B[s]=E,!0},deleteProperty(e,s){if(!s)return!1;const E=i(!0);return delete E[s],!0},ownKeys(){const e=i(!0);return Object.keys(e)}}),t=typeof process<"u"&&process.env&&process.env.NODE_ENV||"",f=[["APPVEYOR"],["AWS_AMPLIFY","AWS_APP_ID",{ci:!0}],["AZURE_PIPELINES","SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],["AZURE_STATIC","INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],["APPCIRCLE","AC_APPCIRCLE"],["BAMBOO","bamboo_planKey"],["BITBUCKET","BITBUCKET_COMMIT"],["BITRISE","BITRISE_IO"],["BUDDY","BUDDY_WORKSPACE_ID"],["BUILDKITE"],["CIRCLE","CIRCLECI"],["CIRRUS","CIRRUS_CI"],["CLOUDFLARE_PAGES","CF_PAGES",{ci:!0}],["CLOUDFLARE_WORKERS","WORKERS_CI",{ci:!0}],["CODEBUILD","CODEBUILD_BUILD_ARN"],["CODEFRESH","CF_BUILD_ID"],["DRONE"],["DRONE","DRONE_BUILD_EVENT"],["DSARI"],["GITHUB_ACTIONS"],["GITLAB","GITLAB_CI"],["GITLAB","CI_MERGE_REQUEST_ID"],["GOCD","GO_PIPELINE_LABEL"],["LAYERCI"],["HUDSON","HUDSON_URL"],["JENKINS","JENKINS_URL"],["MAGNUM"],["NETLIFY"],["NETLIFY","NETLIFY_LOCAL",{ci:!1}],["NEVERCODE"],["RENDER"],["SAIL","SAILCI"],["SEMAPHORE"],["SCREWDRIVER"],["SHIPPABLE"],["SOLANO","TDDIUM"],["STRIDER"],["TEAMCITY","TEAMCITY_VERSION"],["TRAVIS"],["VERCEL","NOW_BUILDER"],["VERCEL","VERCEL",{ci:!1}],["VERCEL","VERCEL_ENV",{ci:!1}],["APPCENTER","APPCENTER_BUILD_ID"],["CODESANDBOX","CODESANDBOX_SSE",{ci:!1}],["CODESANDBOX","CODESANDBOX_HOST",{ci:!1}],["STACKBLITZ"],["STORMKIT"],["CLEAVR"],["ZEABUR"],["CODESPHERE","CODESPHERE_APP_ID",{ci:!0}],["RAILWAY","RAILWAY_PROJECT_ID"],["RAILWAY","RAILWAY_SERVICE_ID"],["DENO-DEPLOY","DENO_DEPLOYMENT_ID"],["FIREBASE_APP_HOSTING","FIREBASE_APP_HOSTING",{ci:!0}]];function b(){if(globalThis.process?.env)for(const e of f){const s=e[1]||e[0];if(globalThis.process?.env[s])return{name:e[0].toLowerCase(),...e[2]}}return globalThis.process?.env?.SHELL==="/bin/jsh"&&globalThis.process?.versions?.webcontainer?{name:"stackblitz",ci:!1}:{name:"",ci:!1}}const l=b(),p=l.name;function n(e){return e?e!=="false":!1}const I=globalThis.process?.platform||"",T=n(o.CI)||l.ci!==!1,R=n(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY),U=typeof window<"u",d=n(o.DEBUG),a=t==="test"||n(o.TEST),g=t==="production",h=t==="dev"||t==="development",v=n(o.MINIMAL)||T||a||!R,A=/^win/i.test(I),M=/^linux/i.test(I),m=/^darwin/i.test(I),Y=!n(o.NO_COLOR)&&(n(o.FORCE_COLOR)||(R||A)&&o.TERM!=="dumb"||T),C=(globalThis.process?.versions?.node||"").replace(/^v/,"")||null,V=Number(C?.split(".")[0])||null,W=globalThis.process||Object.create(null),_={versions:{}},y=new Proxy(W,{get(e,s){if(s==="env")return o;if(s in e)return e[s];if(s in _)return _[s]}}),O=globalThis.process?.release?.name==="node",c=!!globalThis.Bun||!!globalThis.process?.versions?.bun,D=!!globalThis.Deno,L=!!globalThis.fastly,S=!!globalThis.Netlify,u=!!globalThis.EdgeRuntime,N=globalThis.navigator?.userAgent==="Cloudflare-Workers",F=[[S,"netlify"],[u,"edge-light"],[N,"workerd"],[L,"fastly"],[D,"deno"],[c,"bun"],[O,"node"]];function G(){const e=F.find(s=>s[0]);if(e)return{name:e[1]}}const P=G(),K=P?.name||"";export{o as env,R as hasTTY,U as hasWindow,c as isBun,T as isCI,Y as isColorSupported,d as isDebug,D as isDeno,h as isDevelopment,u as isEdgeLight,L as isFastly,M as isLinux,m as isMacOS,v as isMinimal,S as isNetlify,O as isNode,g as isProduction,a as isTest,A as isWindows,N as isWorkerd,t as nodeENV,V as nodeMajorVersion,C as nodeVersion,I as platform,y as process,p as provider,l as providerInfo,K as runtime,P as runtimeInfo};
const e=globalThis.process?.env||Object.create(null),t=globalThis.process||{env:e},n=t!==void 0&&t.env&&t.env.NODE_ENV||void 0,r=[[`claude`,[`CLAUDECODE`,`CLAUDE_CODE`]],[`replit`,[`REPL_ID`]],[`gemini`,[`GEMINI_CLI`]],[`codex`,[`CODEX_SANDBOX`,`CODEX_THREAD_ID`]],[`opencode`,[`OPENCODE`]],[`pi`,[i(`PATH`,/\.pi[\\/]agent/)]],[`auggie`,[`AUGMENT_AGENT`]],[`goose`,[`GOOSE_PROVIDER`]],[`devin`,[i(`EDITOR`,/devin/)]],[`cursor`,[`CURSOR_AGENT`]],[`kiro`,[i(`TERM_PROGRAM`,/kiro/)]]];function i(t,n){return()=>{let r=e[t];return r?n.test(r):!1}}function a(){let t=e.AI_AGENT;if(t)return{name:t.toLowerCase()};for(let[t,n]of r)for(let r of n)if(typeof r==`string`?e[r]:r())return{name:t};return{}}const o=a(),s=o.name,c=!!o.name,l=[[`APPVEYOR`],[`AWS_AMPLIFY`,`AWS_APP_ID`,{ci:!0}],[`AZURE_PIPELINES`,`SYSTEM_TEAMFOUNDATIONCOLLECTIONURI`],[`AZURE_STATIC`,`INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN`],[`APPCIRCLE`,`AC_APPCIRCLE`],[`BAMBOO`,`bamboo_planKey`],[`BITBUCKET`,`BITBUCKET_COMMIT`],[`BITRISE`,`BITRISE_IO`],[`BUDDY`,`BUDDY_WORKSPACE_ID`],[`BUILDKITE`],[`CIRCLE`,`CIRCLECI`],[`CIRRUS`,`CIRRUS_CI`],[`CLOUDFLARE_PAGES`,`CF_PAGES`,{ci:!0}],[`CLOUDFLARE_WORKERS`,`WORKERS_CI`,{ci:!0}],[`GOOGLE_CLOUDRUN`,`K_SERVICE`],[`GOOGLE_CLOUDRUN_JOB`,`CLOUD_RUN_JOB`],[`CODEBUILD`,`CODEBUILD_BUILD_ARN`],[`CODEFRESH`,`CF_BUILD_ID`],[`DRONE`],[`DRONE`,`DRONE_BUILD_EVENT`],[`DSARI`],[`GITHUB_ACTIONS`],[`GITLAB`,`GITLAB_CI`],[`GITLAB`,`CI_MERGE_REQUEST_ID`],[`GOCD`,`GO_PIPELINE_LABEL`],[`LAYERCI`],[`JENKINS`,`JENKINS_URL`],[`HUDSON`,`HUDSON_URL`],[`MAGNUM`],[`NETLIFY`],[`NETLIFY`,`NETLIFY_LOCAL`,{ci:!1}],[`NEVERCODE`],[`RENDER`],[`SAIL`,`SAILCI`],[`SEMAPHORE`],[`SCREWDRIVER`],[`SHIPPABLE`],[`SOLANO`,`TDDIUM`],[`STRIDER`],[`TEAMCITY`,`TEAMCITY_VERSION`],[`TRAVIS`],[`VERCEL`,`NOW_BUILDER`],[`VERCEL`,`VERCEL`,{ci:!1}],[`VERCEL`,`VERCEL_ENV`,{ci:!1}],[`APPCENTER`,`APPCENTER_BUILD_ID`],[`CODESANDBOX`,`CODESANDBOX_SSE`,{ci:!1}],[`CODESANDBOX`,`CODESANDBOX_HOST`,{ci:!1}],[`STACKBLITZ`],[`STORMKIT`],[`CLEAVR`],[`ZEABUR`],[`CODESPHERE`,`CODESPHERE_APP_ID`,{ci:!0}],[`RAILWAY`,`RAILWAY_PROJECT_ID`],[`RAILWAY`,`RAILWAY_SERVICE_ID`],[`DENO-DEPLOY`,`DENO_DEPLOY`],[`DENO-DEPLOY`,`DENO_DEPLOYMENT_ID`],[`FIREBASE_APP_HOSTING`,`FIREBASE_APP_HOSTING`,{ci:!0}],[`EDGEONE_PAGES`,`EO_PAGES_CI`,{ci:!0}]];function u(){for(let t of l)if(e[t[1]||t[0]])return{name:t[0].toLowerCase(),...t[2]};return e.SHELL===`/bin/jsh`&&t.versions?.webcontainer?{name:`stackblitz`,ci:!1}:{name:``,ci:!1}}const d=u(),f=d.name,p=t.platform||``,m=!!e.CI||d.ci!==!1,h=!!t.stdout?.isTTY,g=typeof window<`u`,_=!!e.DEBUG,v=n===`test`||!!e.TEST,y=n===`production`||e.MODE===`production`,b=n===`dev`||n===`development`||e.MODE===`development`,x=!!e.MINIMAL||m||v||!h,S=/^win/i.test(p),C=/^linux/i.test(p),w=/^darwin/i.test(p),T=!e.NO_COLOR&&(!!e.FORCE_COLOR||(h||S)&&e.TERM!==`dumb`||m),E=(t.versions?.node||``).replace(/^v/,``)||null,D=Number(E?.split(`.`)[0])||null,O=!!t?.versions?.node,k=`Bun`in globalThis,A=`Deno`in globalThis,j=`fastly`in globalThis,M=`Netlify`in globalThis,N=`EdgeRuntime`in globalThis,P=globalThis.navigator?.userAgent===`Cloudflare-Workers`,F=[[M,`netlify`],[N,`edge-light`],[P,`workerd`],[j,`fastly`],[A,`deno`],[k,`bun`],[O,`node`]];function I(){let e=F.find(e=>e[0]);if(e)return{name:e[1]}}const L=I(),R=L?.name||``;export{s as agent,o as agentInfo,a as detectAgent,u as detectProvider,e as env,h as hasTTY,g as hasWindow,c as isAgent,k as isBun,m as isCI,T as isColorSupported,_ as isDebug,A as isDeno,b as isDevelopment,N as isEdgeLight,j as isFastly,C as isLinux,w as isMacOS,x as isMinimal,M as isNetlify,O as isNode,y as isProduction,v as isTest,S as isWindows,P as isWorkerd,n as nodeENV,D as nodeMajorVersion,E as nodeVersion,p as platform,t as process,f as provider,d as providerInfo,R as runtime,L as runtimeInfo};
+26 -30
View File
@@ -1,46 +1,42 @@
{
"name": "std-env",
"version": "3.10.0",
"version": "4.1.0",
"description": "Runtime agnostic JS utils",
"repository": "unjs/std-env",
"license": "MIT",
"sideEffects": false,
"type": "module",
"exports": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
},
"main": "./dist/index.cjs",
"types": "./dist/index.d.ts",
"repository": "unjs/std-env",
"files": [
"dist"
],
"type": "module",
"sideEffects": false,
"main": "./dist/index.mjs",
"types": "./dist/index.d.mts",
"exports": {
".": "./dist/index.mjs"
},
"scripts": {
"build": "unbuild",
"build": "obuild",
"dev": "vitest",
"lint": "eslint . && prettier -c src test",
"lint:fix": "eslint --fix . && prettier -w src test",
"prepack": "unbuild",
"play:bun": "bun playground/bun.ts",
"play:deno": "pnpm build && deno run -A playground/deno.ts",
"play:node": "pnpm build && node playground/node.mjs",
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
"lint": "oxlint . && oxfmt",
"lint:fix": "oxlint --fix . && oxfmt",
"prepack": "obuild",
"release": "pnpm test && pnpm build && changelogen --release --publish && git push --follow-tags",
"test": "pnpm lint && pnpm typecheck && vitest run --coverage",
"typecheck": "tsc --noEmit"
"typecheck": "tsgo --noEmit"
},
"devDependencies": {
"@types/node": "^24.7.2",
"@vitest/coverage-v8": "^3.2.4",
"@types/node": "^25.2.3",
"@typescript/native-preview": "^7.0.0-dev.20260217.1",
"@vitest/coverage-v8": "^4.0.18",
"changelogen": "^0.6.2",
"esbuild": "^0.25.10",
"eslint": "^9.37.0",
"eslint-config-unjs": "^0.5.0",
"prettier": "^3.6.2",
"rollup": "^4.52.4",
"esbuild": "^0.27.3",
"mitata": "^1.0.34",
"obuild": "^0.4.28",
"oxfmt": "^0.33.0",
"oxlint": "^1.48.0",
"rollup": "^4.57.1",
"typescript": "^5.9.3",
"unbuild": "^3.6.1",
"vitest": "^3.2.4"
"vitest": "^4.0.18"
},
"packageManager": "pnpm@10.18.2"
"packageManager": "pnpm@10.30.0"
}