std-env 4.0.0-rc.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -22
- package/dist/index.d.mts +21 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ Detects the current CI/CD provider based on environment variables.
|
|
|
32
32
|
import { isCI, provider, providerInfo } from "std-env";
|
|
33
33
|
|
|
34
34
|
console.log({ isCI, provider, providerInfo });
|
|
35
|
-
// { isCI: true, provider: "github_actions", providerInfo: { name: "github_actions",
|
|
35
|
+
// { isCI: true, provider: "github_actions", providerInfo: { name: "github_actions", ci: true } }
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
Use `detectProvider()` to re-run detection. See [./src/providers.ts](./src/providers.ts) for the full list.
|
|
@@ -58,32 +58,33 @@ Supported agents: `cursor`, `claude`, `devin`, `replit`, `gemini`, `codex`, `aug
|
|
|
58
58
|
import { env, isDevelopment, isProduction } from "std-env";
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
| Export | Description
|
|
62
|
-
| ------------------ |
|
|
63
|
-
| `hasTTY` | stdout TTY is available
|
|
64
|
-
| `hasWindow` | Global `window` is available
|
|
65
|
-
| `isCI` | Running in CI
|
|
66
|
-
| `isColorSupported` | Terminal color output supported
|
|
67
|
-
| `isDebug` | `DEBUG` env var is set
|
|
68
|
-
| `isDevelopment` | `NODE_ENV` is `dev` or `development`
|
|
69
|
-
| `isLinux` | Linux platform
|
|
70
|
-
| `isMacOS` | macOS (darwin) platform
|
|
71
|
-
| `isMinimal` |
|
|
72
|
-
| `isProduction` | `NODE_ENV` is `production`
|
|
73
|
-
| `isTest` | `NODE_ENV` is `test`
|
|
74
|
-
| `isWindows` | Windows platform
|
|
75
|
-
| `platform` | Value of `process.platform`
|
|
76
|
-
| `nodeVersion` | Node.js version string (e.g. `"22.0.0"`)
|
|
77
|
-
| `nodeMajorVersion` | Node.js major version number (e.g. `22`)
|
|
61
|
+
| Export | Description |
|
|
62
|
+
| ------------------ | ------------------------------------------------------------ |
|
|
63
|
+
| `hasTTY` | stdout TTY is available |
|
|
64
|
+
| `hasWindow` | Global `window` is available |
|
|
65
|
+
| `isCI` | Running in CI |
|
|
66
|
+
| `isColorSupported` | Terminal color output supported |
|
|
67
|
+
| `isDebug` | `DEBUG` env var is set |
|
|
68
|
+
| `isDevelopment` | `NODE_ENV` is `dev`/`development` or `MODE` is `development` |
|
|
69
|
+
| `isLinux` | Linux platform |
|
|
70
|
+
| `isMacOS` | macOS (darwin) platform |
|
|
71
|
+
| `isMinimal` | `MINIMAL` env is set, CI, test, or no TTY |
|
|
72
|
+
| `isProduction` | `NODE_ENV` or `MODE` is `production` |
|
|
73
|
+
| `isTest` | `NODE_ENV` is `test` or `TEST` env is set |
|
|
74
|
+
| `isWindows` | Windows platform |
|
|
75
|
+
| `platform` | Value of `process.platform` |
|
|
76
|
+
| `nodeVersion` | Node.js version string (e.g. `"22.0.0"`) |
|
|
77
|
+
| `nodeMajorVersion` | Node.js major version number (e.g. `22`) |
|
|
78
78
|
|
|
79
79
|
See [./src/flags.ts](./src/flags.ts) for details.
|
|
80
80
|
|
|
81
81
|
## Environment
|
|
82
82
|
|
|
83
|
-
| Export | Description
|
|
84
|
-
| --------- |
|
|
85
|
-
| `env` | Universal `process.env` (works across all runtimes)
|
|
86
|
-
| `
|
|
83
|
+
| Export | Description |
|
|
84
|
+
| --------- | ---------------------------------------------------- |
|
|
85
|
+
| `env` | Universal `process.env` (works across all runtimes) |
|
|
86
|
+
| `process` | Universal `process` shim (works across all runtimes) |
|
|
87
|
+
| `nodeENV` | Current `NODE_ENV` value (undefined if unset) |
|
|
87
88
|
|
|
88
89
|
## License
|
|
89
90
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
//#region src/agents.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Represents the name of an AI coding agent.
|
|
4
|
+
*/
|
|
2
5
|
type AgentName = (string & {}) | "cursor" | "claude" | "devin" | "replit" | "gemini" | "codex" | "auggie" | "opencode" | "kiro" | "goose" | "pi";
|
|
3
6
|
/**
|
|
4
7
|
* Provides information about an AI coding agent.
|
|
@@ -32,7 +35,17 @@ declare const agent: AgentName | undefined;
|
|
|
32
35
|
declare const isAgent: boolean;
|
|
33
36
|
//#endregion
|
|
34
37
|
//#region src/env.d.ts
|
|
38
|
+
/**
|
|
39
|
+
* Runtime-agnostic reference to environment variables.
|
|
40
|
+
*
|
|
41
|
+
* Resolves to `globalThis.process.env` when available, otherwise an empty object.
|
|
42
|
+
*/
|
|
35
43
|
declare const env: Record<string, string | undefined>;
|
|
44
|
+
/**
|
|
45
|
+
* Runtime-agnostic reference to the `process` global.
|
|
46
|
+
*
|
|
47
|
+
* Resolves to `globalThis.process` when available, otherwise a minimal shim containing only `env`.
|
|
48
|
+
*/
|
|
36
49
|
declare const process: Partial<typeof globalThis.process>;
|
|
37
50
|
/**
|
|
38
51
|
* Current value of the `NODE_ENV` environment variable (or static value if replaced during build).
|
|
@@ -66,10 +79,11 @@ declare const isWindows: boolean;
|
|
|
66
79
|
declare const isLinux: boolean;
|
|
67
80
|
/** Detect if process.platform is macOS (darwin kernel) */
|
|
68
81
|
declare const isMacOS: boolean;
|
|
69
|
-
/**
|
|
82
|
+
/** Detect if terminal color output is supported based on `NO_COLOR`, `FORCE_COLOR`, TTY, and CI environment */
|
|
70
83
|
declare const isColorSupported: boolean;
|
|
71
|
-
/** Node.js
|
|
84
|
+
/** Node.js version string (e.g. `"20.11.0"`), or `null` if not running in Node.js */
|
|
72
85
|
declare const nodeVersion: string | null;
|
|
86
|
+
/** Node.js major version number (e.g. `20`), or `null` if not running in Node.js */
|
|
73
87
|
declare const nodeMajorVersion: number | null;
|
|
74
88
|
//#endregion
|
|
75
89
|
//#region src/providers.d.ts
|
|
@@ -109,6 +123,11 @@ declare const providerInfo: ProviderInfo;
|
|
|
109
123
|
declare const provider: ProviderName;
|
|
110
124
|
//#endregion
|
|
111
125
|
//#region src/runtimes.d.ts
|
|
126
|
+
/**
|
|
127
|
+
* Represents the name of a JavaScript runtime.
|
|
128
|
+
*
|
|
129
|
+
* @see https://runtime-keys.proposal.wintercg.org/
|
|
130
|
+
*/
|
|
112
131
|
type RuntimeName = (string & {}) | "workerd" | "deno" | "netlify" | "node" | "bun" | "edge-light" | "fastly";
|
|
113
132
|
type RuntimeInfo = {
|
|
114
133
|
/**
|
|
@@ -141,7 +160,6 @@ declare const isFastly: boolean;
|
|
|
141
160
|
*/
|
|
142
161
|
declare const isNetlify: boolean;
|
|
143
162
|
/**
|
|
144
|
-
*
|
|
145
163
|
* Indicates if running in EdgeLight (Vercel Edge) runtime.
|
|
146
164
|
*/
|
|
147
165
|
declare const isEdgeLight: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "std-env",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Runtime agnostic JS utils",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "unjs/std-env",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"lint": "oxlint . && oxfmt",
|
|
21
21
|
"lint:fix": "oxlint --fix . && oxfmt",
|
|
22
22
|
"prepack": "obuild",
|
|
23
|
-
"release": "pnpm test && pnpm build && changelogen --release --
|
|
23
|
+
"release": "pnpm test && pnpm build && changelogen --release --publish && git push --follow-tags",
|
|
24
24
|
"test": "pnpm lint && pnpm typecheck && vitest run --coverage",
|
|
25
25
|
"typecheck": "tsgo --noEmit"
|
|
26
26
|
},
|