@stryke/env 0.18.13 → 0.19.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.
|
@@ -4,43 +4,57 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isDevelopment = exports.isDebug = exports.isColorSupported = exports.hasTTY = void 0;
|
|
7
|
+
exports.isDevelopmentMode = isDevelopmentMode;
|
|
7
8
|
exports.isHyperlinkSupported = isHyperlinkSupported;
|
|
8
|
-
exports.
|
|
9
|
+
exports.isProduction = exports.isMinimal = exports.isMacOS = exports.isLinux = void 0;
|
|
10
|
+
exports.isProductionMode = isProductionMode;
|
|
11
|
+
exports.isTest = exports.isStaging = void 0;
|
|
12
|
+
exports.isTestMode = isTestMode;
|
|
13
|
+
exports.platform = exports.nodeVersion = exports.nodeMajorVersion = exports.isWindows = void 0;
|
|
9
14
|
var _ciChecks = require("./ci-checks.cjs");
|
|
10
15
|
const platform = exports.platform = process?.platform || "",
|
|
11
16
|
hasTTY = exports.hasTTY = !!(process?.stdout && process?.stdout.isTTY),
|
|
12
17
|
isDebug = exports.isDebug = !!process.env.DEBUG;
|
|
13
18
|
const o = process.env.STORM_MODE || process.env.NEXT_PUBLIC_VERCEL_ENV || process.env.NODE_ENV || "production";
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
const isStaging = exports.isStaging = ["stg", "stage", "staging"].includes(o?.toLowerCase());
|
|
20
|
+
function isProductionMode(r) {
|
|
21
|
+
return ["prd", "prod", "production", "preprod", "preproduction", "uat"].includes(r?.toLowerCase()?.replace(/[\s\-_]/g, ""));
|
|
22
|
+
}
|
|
23
|
+
const isProduction = exports.isProduction = isProductionMode(o);
|
|
24
|
+
function isTestMode(r) {
|
|
25
|
+
return ["tst", "test", "testing", "stg", "stage", "staging", "qa", "qualityassurance"].includes(r?.toLowerCase()?.replace(/[\s\-_]/g, ""));
|
|
26
|
+
}
|
|
27
|
+
const isTest = exports.isTest = isTestMode(o) || isStaging || !!process.env.TEST;
|
|
28
|
+
function isDevelopmentMode(r) {
|
|
29
|
+
return ["dev", "development", "int", "integration"].includes(r?.toLowerCase()?.replace(/[\s\-_]/g, ""));
|
|
30
|
+
}
|
|
31
|
+
const isDevelopment = exports.isDevelopment = isDevelopmentMode(o) || isDebug,
|
|
18
32
|
isMinimal = exports.isMinimal = !!process.env.MINIMAL || (0, _ciChecks.isCI)() || isTest || !hasTTY,
|
|
19
33
|
isWindows = exports.isWindows = /^win/i.test(platform),
|
|
20
34
|
isLinux = exports.isLinux = /^linux/i.test(platform),
|
|
21
35
|
isMacOS = exports.isMacOS = /^darwin/i.test(platform),
|
|
22
36
|
isColorSupported = exports.isColorSupported = !process.env.NO_COLOR && (!!process.env.FORCE_COLOR || (hasTTY || isWindows) && process.env.TERM !== "dumb" || (0, _ciChecks.isCI)());
|
|
23
|
-
function t(
|
|
24
|
-
if (/^\d{3,4}$/.test(
|
|
25
|
-
const
|
|
37
|
+
function t(r = "") {
|
|
38
|
+
if (/^\d{3,4}$/.test(r)) {
|
|
39
|
+
const s = /(\d{1,2})(\d{2})/.exec(r) ?? [];
|
|
26
40
|
return {
|
|
27
41
|
major: 0,
|
|
28
|
-
minor: Number.parseInt(
|
|
29
|
-
patch: Number.parseInt(
|
|
42
|
+
minor: Number.parseInt(s[1], 10),
|
|
43
|
+
patch: Number.parseInt(s[2], 10)
|
|
30
44
|
};
|
|
31
45
|
}
|
|
32
|
-
const e = (
|
|
46
|
+
const e = (r ?? "").split(".").map(s => Number.parseInt(s, 10));
|
|
33
47
|
return {
|
|
34
48
|
major: e[0],
|
|
35
49
|
minor: e[1],
|
|
36
50
|
patch: e[2]
|
|
37
51
|
};
|
|
38
52
|
}
|
|
39
|
-
function isHyperlinkSupported(
|
|
53
|
+
function isHyperlinkSupported(r = process.stdout) {
|
|
40
54
|
if (process.env.FORCE_HYPERLINK) return !(process.env.FORCE_HYPERLINK.length > 0 && Number.parseInt(process.env.FORCE_HYPERLINK, 10) === 0);
|
|
41
55
|
if (process.env.NETLIFY) return !0;
|
|
42
56
|
if (isColorSupported) {
|
|
43
|
-
if (
|
|
57
|
+
if (r && !r.isTTY) return !1;
|
|
44
58
|
if ("WT_SESSION" in process.env) return !0;
|
|
45
59
|
if (process.platform === "win32") return !1;
|
|
46
60
|
if ((0, _ciChecks.isCI)()) return !1;
|
|
@@ -4,14 +4,35 @@ export declare const platform: NodeJS.Platform;
|
|
|
4
4
|
export declare const hasTTY: boolean;
|
|
5
5
|
/** Detect if `DEBUG` environment variable is set */
|
|
6
6
|
export declare const isDebug: boolean;
|
|
7
|
+
/** Detect if the application is running in a staging environment */
|
|
8
|
+
export declare const isStaging: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Check if the current environment is production.
|
|
11
|
+
*
|
|
12
|
+
* @param mode - The mode string to check.
|
|
13
|
+
* @returns Whether the environment is production
|
|
14
|
+
*/
|
|
15
|
+
export declare function isProductionMode(mode: string): boolean;
|
|
7
16
|
/** Detect if `NODE_ENV` environment variable is `production` */
|
|
8
17
|
export declare const isProduction: boolean;
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Check if the current environment is test.
|
|
20
|
+
*
|
|
21
|
+
* @param mode - The mode string to check.
|
|
22
|
+
* @returns Whether the environment is test
|
|
23
|
+
*/
|
|
24
|
+
export declare function isTestMode(mode: string): boolean;
|
|
13
25
|
/** Detect if `NODE_ENV` environment variable is `test` */
|
|
14
26
|
export declare const isTest: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Check if the current environment is development.
|
|
29
|
+
*
|
|
30
|
+
* @param mode - The mode string to check.
|
|
31
|
+
* @returns Whether the environment is development
|
|
32
|
+
*/
|
|
33
|
+
export declare function isDevelopmentMode(mode: string): boolean;
|
|
34
|
+
/** Detect if `NODE_ENV` environment variable is `dev` or `development` */
|
|
35
|
+
export declare const isDevelopment: boolean;
|
|
15
36
|
/** Detect if MINIMAL environment variable is set, running in CI or test or TTY is unavailable */
|
|
16
37
|
export declare const isMinimal: boolean;
|
|
17
38
|
/** Detect if process.platform is Windows */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isCI as n}from"./ci-checks";export const platform=process?.platform||"",hasTTY=!!(process?.stdout&&process?.stdout.isTTY),isDebug=!!process.env.DEBUG;const o=process.env.STORM_MODE||process.env.NEXT_PUBLIC_VERCEL_ENV||process.env.NODE_ENV||"production";export const
|
|
1
|
+
import{isCI as n}from"./ci-checks";export const platform=process?.platform||"",hasTTY=!!(process?.stdout&&process?.stdout.isTTY),isDebug=!!process.env.DEBUG;const o=process.env.STORM_MODE||process.env.NEXT_PUBLIC_VERCEL_ENV||process.env.NODE_ENV||"production";export const isStaging=["stg","stage","staging"].includes(o?.toLowerCase());export function isProductionMode(r){return["prd","prod","production","preprod","preproduction","uat"].includes(r?.toLowerCase()?.replace(/[\s\-_]/g,""))}export const isProduction=isProductionMode(o);export function isTestMode(r){return["tst","test","testing","stg","stage","staging","qa","qualityassurance"].includes(r?.toLowerCase()?.replace(/[\s\-_]/g,""))}export const isTest=isTestMode(o)||isStaging||!!process.env.TEST;export function isDevelopmentMode(r){return["dev","development","int","integration"].includes(r?.toLowerCase()?.replace(/[\s\-_]/g,""))}export const isDevelopment=isDevelopmentMode(o)||isDebug,isMinimal=!!process.env.MINIMAL||n()||isTest||!hasTTY,isWindows=/^win/i.test(platform),isLinux=/^linux/i.test(platform),isMacOS=/^darwin/i.test(platform),isColorSupported=!process.env.NO_COLOR&&(!!process.env.FORCE_COLOR||(hasTTY||isWindows)&&process.env.TERM!=="dumb"||n());function t(r=""){if(/^\d{3,4}$/.test(r)){const s=/(\d{1,2})(\d{2})/.exec(r)??[];return{major:0,minor:Number.parseInt(s[1],10),patch:Number.parseInt(s[2],10)}}const e=(r??"").split(".").map(s=>Number.parseInt(s,10));return{major:e[0],minor:e[1],patch:e[2]}}export function isHyperlinkSupported(r=process.stdout){if(process.env.FORCE_HYPERLINK)return!(process.env.FORCE_HYPERLINK.length>0&&Number.parseInt(process.env.FORCE_HYPERLINK,10)===0);if(process.env.NETLIFY)return!0;if(isColorSupported){if(r&&!r.isTTY)return!1;if("WT_SESSION"in process.env)return!0;if(process.platform==="win32")return!1;if(n())return!1;if(process.env.TEAMCITY_VERSION)return!1;if(process.env.TERM_PROGRAM){const e=t(process.env.TERM_PROGRAM_VERSION);switch(process.env.TERM_PROGRAM){case"iTerm.app":return e.major===3?e.minor!==void 0&&e.minor>=1:e.major!==void 0&&e.major>3;case"WezTerm":return e.major!==void 0&&e.major>=20200620;case"vscode":return process.env.CURSOR_TRACE_ID?!0:e.minor!==void 0&&e.major!==void 0&&(e.major>1||e.major===1&&e.minor>=72);case"ghostty":return!0}}}else return!1;if(process.env.VTE_VERSION){if(process.env.VTE_VERSION==="0.50.0")return!1;const e=t(process.env.VTE_VERSION);return e.major!==void 0&&e.major>0||e.minor!==void 0&&e.minor>=50}return process.env.TERM==="alacritty"}export const nodeVersion=(process?.versions?.node||"").replace(/^v/,"")||null,nodeMajorVersion=Number(nodeVersion?.split(".")[0])||null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/env",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing utility functions to handle environment specific processes",
|
|
6
6
|
"repository": {
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@dotenvx/dotenvx": "1.35.0",
|
|
14
14
|
"@stryke/convert": "^0.6.0",
|
|
15
|
-
"@stryke/fs": "^0.28.
|
|
15
|
+
"@stryke/fs": "^0.28.7",
|
|
16
16
|
"@stryke/path": "^0.15.2",
|
|
17
|
-
"@stryke/string-format": "^0.
|
|
17
|
+
"@stryke/string-format": "^0.12.0",
|
|
18
18
|
"defu": "^6.1.4"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": { "@types/node": "^22.14.0" },
|
|
@@ -175,5 +175,5 @@
|
|
|
175
175
|
"main": "./dist/index.cjs",
|
|
176
176
|
"module": "./dist/index.mjs",
|
|
177
177
|
"types": "./dist/index.d.ts",
|
|
178
|
-
"gitHead": "
|
|
178
|
+
"gitHead": "f49dba31218c591b8b0d358b6e83f09be4a2175b"
|
|
179
179
|
}
|