@js-utils-kit/env 1.4.0 → 1.6.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/dist/index.cjs +1 -1
- package/dist/index.d.cts +83 -1
- package/dist/index.d.mts +83 -1
- package/dist/index.mjs +1 -1
- package/package.json +15 -15
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e=require(`@js-utils-kit/types`),t=require(`node:process`);function n(){switch(process.env.NODE_ENV){case e.Environment.PROD:return e.Environment.PROD;case e.Environment.DEV:return e.Environment.DEV;case e.Environment.TEST:return e.Environment.TEST;default:return e.Environment.UNKNOWN}}const r=`AC_APPCIRCLE.AGOLA_GIT_REF.APPCENTER_BUILD_ID.APPVEYOR.bamboo_planKey.BITBUCKET_COMMIT.BITRISE_IO.BUDDY_WORKSPACE_ID.BUILD_ID.BUILD_NUMBER.BUILDER_OUTPUT.BUILDKITE.CF_BUILD_ID.CF_PAGES.CI_XCODE_PROJECT.CIRCLECI.CIRRUS_CI.CM_BUILD_ID.CODEBUILD_BUILD_ARN.DRONE.DSARI.EARTHLY_CI.EAS_BUILD.GERRIT_PROJECT.GITEA_ACTIONS.GITHUB_ACTIONS.GITLAB_CI.GO_PIPELINE_LABEL.HARNESS_BUILD_ID.HUDSON_URL.JENKINS_URL.LAYERCI.MAGNUM.NETLIFY.NEVERCODE.NOW_BUILDER.PROW_JOB_ID.RELEASE_BUILD_ID.RENDER.RUN_ID.SAILCI.SCREWDRIVER.SEMAPHORE.STRIDER.TASK_ID.TEAMCITY_VERSION.TF_BUILD.TRAVIS.VELA.VERCEL.WORKERS_CI.XCS`.split(`.`),i=[`CI`,`CONTINUOUS_INTEGRATION`],a=[`codeship`,`sourcehut`,`woodpecker`],o=e=>{let n=t.env[e]??t.env[e.toUpperCase()]??t.env[e.toLowerCase()];return n!=null&&n!==`0`&&n.toLowerCase()!==`false`},s=r.some(o),c=s||i.some(o)&&(s||typeof t.env.CI_NAME==`string`&&a.includes(t.env.CI_NAME.toLowerCase()));exports.getRunTimeEnvironment=n,exports.isCI=c;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@js-utils-kit/types`),t=require(`node:process`);function n(){switch(process.env.NODE_ENV){case e.Environment.PROD:return e.Environment.PROD;case e.Environment.DEV:return e.Environment.DEV;case e.Environment.TEST:return e.Environment.TEST;default:return e.Environment.UNKNOWN}}const r=`AC_APPCIRCLE.AGOLA_GIT_REF.APPCENTER_BUILD_ID.APPVEYOR.bamboo_planKey.BITBUCKET_COMMIT.BITRISE_IO.BUDDY_WORKSPACE_ID.BUILD_ID.BUILD_NUMBER.BUILDER_OUTPUT.BUILDKITE.CF_BUILD_ID.CF_PAGES.CI_XCODE_PROJECT.CIRCLECI.CIRRUS_CI.CM_BUILD_ID.CODEBUILD_BUILD_ARN.DRONE.DSARI.EARTHLY_CI.EAS_BUILD.GERRIT_PROJECT.GITEA_ACTIONS.GITHUB_ACTIONS.GITLAB_CI.GO_PIPELINE_LABEL.HARNESS_BUILD_ID.HUDSON_URL.JENKINS_URL.LAYERCI.MAGNUM.NETLIFY.NEVERCODE.NOW_BUILDER.PROW_JOB_ID.RELEASE_BUILD_ID.RENDER.RUN_ID.SAILCI.SCREWDRIVER.SEMAPHORE.STRIDER.TASK_ID.TEAMCITY_VERSION.TF_BUILD.TRAVIS.VELA.VERCEL.WORKERS_CI.XCS`.split(`.`),i=[`CI`,`CONTINUOUS_INTEGRATION`],a=[`codeship`,`sourcehut`,`woodpecker`],o=e=>{let n=t.env[e]??t.env[e.toUpperCase()]??t.env[e.toLowerCase()];return n!=null&&n!==`0`&&n.toLowerCase()!==`false`},s=r.some(o),c=s||i.some(o)&&(s||typeof t.env.CI_NAME==`string`&&a.includes(t.env.CI_NAME.toLowerCase())),l=typeof window<`u`&&window.document!==void 0,u=typeof process<`u`&&process.env.NODE_ENV===e.Environment.DEV,d=typeof process<`u`&&process.env.NODE_ENV===e.Environment.PROD,f=typeof process<`u`&&process.env.NODE_ENV===e.Environment.TEST,p=typeof process<`u`&&process.versions!=null&&process.versions.node!=null;exports.getRunTimeEnvironment=n,exports.isBrowser=l,exports.isCI=c,exports.isDev=u,exports.isNode=p,exports.isProd=d,exports.isTest=f;
|
package/dist/index.d.cts
CHANGED
|
@@ -42,4 +42,86 @@ declare function getRunTimeEnvironment(): Environment;
|
|
|
42
42
|
*/
|
|
43
43
|
declare const isCI: boolean;
|
|
44
44
|
//#endregion
|
|
45
|
-
|
|
45
|
+
//#region src/runtime.d.ts
|
|
46
|
+
/**
|
|
47
|
+
* Checks if the current runtime environment is a browser.
|
|
48
|
+
*
|
|
49
|
+
* This function helps detect whether code is executing in a web browser
|
|
50
|
+
* by confirming the existence of the global `window` and `document` objects.
|
|
51
|
+
*
|
|
52
|
+
* @returns `true` if running in a browser, otherwise `false`.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* if (isBrowser) {
|
|
57
|
+
* console.log('Running in a browser environment');
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
declare const isBrowser: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Checks if the current environment is development.
|
|
64
|
+
*
|
|
65
|
+
* This is determined by comparing `process.env.NODE_ENV` with `'development'`.
|
|
66
|
+
*
|
|
67
|
+
* @returns `true` if `NODE_ENV` is set to development.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* if (isDev) {
|
|
72
|
+
* console.log('Dev mode enabled');
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare const isDev: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Checks if the current environment is production.
|
|
79
|
+
*
|
|
80
|
+
* This is determined by comparing `process.env.NODE_ENV` with `'production'`.
|
|
81
|
+
*
|
|
82
|
+
* @returns `true` if `NODE_ENV` is set to production.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* if (isProd) {
|
|
87
|
+
* enableAnalytics();
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
declare const isProd: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Checks if the current environment is testing.
|
|
94
|
+
*
|
|
95
|
+
* This is determined by comparing `process.env.NODE_ENV` with `'test'`.
|
|
96
|
+
*
|
|
97
|
+
* @returns `true` if `NODE_ENV` is set to test.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* if (isTest) {
|
|
102
|
+
* mockDatabase();
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
declare const isTest: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Checks if the current runtime environment is Node.js.
|
|
109
|
+
*
|
|
110
|
+
* @remarks
|
|
111
|
+
* - It is useful to conditionally execute server-side logic.
|
|
112
|
+
* - It detects the Node.js environment by verifying the presence of the global `process` object and its `versions.node` property.
|
|
113
|
+
*
|
|
114
|
+
* @returns `true` if running in Node.js, otherwise `false`.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* if (isNode) {
|
|
119
|
+
* console.log('Running in Node.js environment');
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @see {@link https://nodejs.org/api/process.html | Node.js process documentation}
|
|
124
|
+
*/
|
|
125
|
+
declare const isNode: boolean;
|
|
126
|
+
//#endregion
|
|
127
|
+
export { getRunTimeEnvironment, isBrowser, isCI, isDev, isNode, isProd, isTest };
|
package/dist/index.d.mts
CHANGED
|
@@ -42,4 +42,86 @@ declare function getRunTimeEnvironment(): Environment;
|
|
|
42
42
|
*/
|
|
43
43
|
declare const isCI: boolean;
|
|
44
44
|
//#endregion
|
|
45
|
-
|
|
45
|
+
//#region src/runtime.d.ts
|
|
46
|
+
/**
|
|
47
|
+
* Checks if the current runtime environment is a browser.
|
|
48
|
+
*
|
|
49
|
+
* This function helps detect whether code is executing in a web browser
|
|
50
|
+
* by confirming the existence of the global `window` and `document` objects.
|
|
51
|
+
*
|
|
52
|
+
* @returns `true` if running in a browser, otherwise `false`.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* if (isBrowser) {
|
|
57
|
+
* console.log('Running in a browser environment');
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
declare const isBrowser: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Checks if the current environment is development.
|
|
64
|
+
*
|
|
65
|
+
* This is determined by comparing `process.env.NODE_ENV` with `'development'`.
|
|
66
|
+
*
|
|
67
|
+
* @returns `true` if `NODE_ENV` is set to development.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* if (isDev) {
|
|
72
|
+
* console.log('Dev mode enabled');
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare const isDev: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Checks if the current environment is production.
|
|
79
|
+
*
|
|
80
|
+
* This is determined by comparing `process.env.NODE_ENV` with `'production'`.
|
|
81
|
+
*
|
|
82
|
+
* @returns `true` if `NODE_ENV` is set to production.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* if (isProd) {
|
|
87
|
+
* enableAnalytics();
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
declare const isProd: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Checks if the current environment is testing.
|
|
94
|
+
*
|
|
95
|
+
* This is determined by comparing `process.env.NODE_ENV` with `'test'`.
|
|
96
|
+
*
|
|
97
|
+
* @returns `true` if `NODE_ENV` is set to test.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* if (isTest) {
|
|
102
|
+
* mockDatabase();
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
declare const isTest: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Checks if the current runtime environment is Node.js.
|
|
109
|
+
*
|
|
110
|
+
* @remarks
|
|
111
|
+
* - It is useful to conditionally execute server-side logic.
|
|
112
|
+
* - It detects the Node.js environment by verifying the presence of the global `process` object and its `versions.node` property.
|
|
113
|
+
*
|
|
114
|
+
* @returns `true` if running in Node.js, otherwise `false`.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* if (isNode) {
|
|
119
|
+
* console.log('Running in Node.js environment');
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @see {@link https://nodejs.org/api/process.html | Node.js process documentation}
|
|
124
|
+
*/
|
|
125
|
+
declare const isNode: boolean;
|
|
126
|
+
//#endregion
|
|
127
|
+
export { getRunTimeEnvironment, isBrowser, isCI, isDev, isNode, isProd, isTest };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Environment as e}from"@js-utils-kit/types";import{env as t}from"node:process";function n(){switch(process.env.NODE_ENV){case e.PROD:return e.PROD;case e.DEV:return e.DEV;case e.TEST:return e.TEST;default:return e.UNKNOWN}}const r=`AC_APPCIRCLE.AGOLA_GIT_REF.APPCENTER_BUILD_ID.APPVEYOR.bamboo_planKey.BITBUCKET_COMMIT.BITRISE_IO.BUDDY_WORKSPACE_ID.BUILD_ID.BUILD_NUMBER.BUILDER_OUTPUT.BUILDKITE.CF_BUILD_ID.CF_PAGES.CI_XCODE_PROJECT.CIRCLECI.CIRRUS_CI.CM_BUILD_ID.CODEBUILD_BUILD_ARN.DRONE.DSARI.EARTHLY_CI.EAS_BUILD.GERRIT_PROJECT.GITEA_ACTIONS.GITHUB_ACTIONS.GITLAB_CI.GO_PIPELINE_LABEL.HARNESS_BUILD_ID.HUDSON_URL.JENKINS_URL.LAYERCI.MAGNUM.NETLIFY.NEVERCODE.NOW_BUILDER.PROW_JOB_ID.RELEASE_BUILD_ID.RENDER.RUN_ID.SAILCI.SCREWDRIVER.SEMAPHORE.STRIDER.TASK_ID.TEAMCITY_VERSION.TF_BUILD.TRAVIS.VELA.VERCEL.WORKERS_CI.XCS`.split(`.`),i=[`CI`,`CONTINUOUS_INTEGRATION`],a=[`codeship`,`sourcehut`,`woodpecker`],o=e=>{let n=t[e]??t[e.toUpperCase()]??t[e.toLowerCase()];return n!=null&&n!==`0`&&n.toLowerCase()!==`false`},s=r.some(o),c=s||i.some(o)&&(s||typeof t.CI_NAME==`string`&&a.includes(t.CI_NAME.toLowerCase()));export{n as getRunTimeEnvironment,c as isCI};
|
|
1
|
+
import{Environment as e}from"@js-utils-kit/types";import{env as t}from"node:process";function n(){switch(process.env.NODE_ENV){case e.PROD:return e.PROD;case e.DEV:return e.DEV;case e.TEST:return e.TEST;default:return e.UNKNOWN}}const r=`AC_APPCIRCLE.AGOLA_GIT_REF.APPCENTER_BUILD_ID.APPVEYOR.bamboo_planKey.BITBUCKET_COMMIT.BITRISE_IO.BUDDY_WORKSPACE_ID.BUILD_ID.BUILD_NUMBER.BUILDER_OUTPUT.BUILDKITE.CF_BUILD_ID.CF_PAGES.CI_XCODE_PROJECT.CIRCLECI.CIRRUS_CI.CM_BUILD_ID.CODEBUILD_BUILD_ARN.DRONE.DSARI.EARTHLY_CI.EAS_BUILD.GERRIT_PROJECT.GITEA_ACTIONS.GITHUB_ACTIONS.GITLAB_CI.GO_PIPELINE_LABEL.HARNESS_BUILD_ID.HUDSON_URL.JENKINS_URL.LAYERCI.MAGNUM.NETLIFY.NEVERCODE.NOW_BUILDER.PROW_JOB_ID.RELEASE_BUILD_ID.RENDER.RUN_ID.SAILCI.SCREWDRIVER.SEMAPHORE.STRIDER.TASK_ID.TEAMCITY_VERSION.TF_BUILD.TRAVIS.VELA.VERCEL.WORKERS_CI.XCS`.split(`.`),i=[`CI`,`CONTINUOUS_INTEGRATION`],a=[`codeship`,`sourcehut`,`woodpecker`],o=e=>{let n=t[e]??t[e.toUpperCase()]??t[e.toLowerCase()];return n!=null&&n!==`0`&&n.toLowerCase()!==`false`},s=r.some(o),c=s||i.some(o)&&(s||typeof t.CI_NAME==`string`&&a.includes(t.CI_NAME.toLowerCase())),l=typeof window<`u`&&window.document!==void 0,u=typeof process<`u`&&process.env.NODE_ENV===e.DEV,d=typeof process<`u`&&process.env.NODE_ENV===e.PROD,f=typeof process<`u`&&process.env.NODE_ENV===e.TEST,p=typeof process<`u`&&process.versions!=null&&process.versions.node!=null;export{n as getRunTimeEnvironment,l as isBrowser,c as isCI,u as isDev,p as isNode,d as isProd,f as isTest};
|
package/package.json
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@js-utils-kit/env",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Environment utilities",
|
|
5
|
-
"private": false,
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"author": {
|
|
8
|
-
"name": "Sriman",
|
|
9
|
-
"email": "136729116+TenEplaysOfficial@users.noreply.github.com",
|
|
10
|
-
"url": "https://tene.vercel.app"
|
|
11
|
-
},
|
|
12
5
|
"homepage": "https://js-utils.js.org",
|
|
13
6
|
"repository": {
|
|
14
7
|
"type": "git",
|
|
@@ -18,24 +11,31 @@
|
|
|
18
11
|
"bugs": {
|
|
19
12
|
"url": "https://github.com/teneplaysofficial/js-utils-kit/issues"
|
|
20
13
|
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Sriman",
|
|
17
|
+
"email": "136729116+TenEplaysOfficial@users.noreply.github.com",
|
|
18
|
+
"url": "https://tene.vercel.app"
|
|
19
|
+
},
|
|
20
|
+
"private": false,
|
|
21
21
|
"files": [
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
|
-
"engines": {
|
|
25
|
-
"node": ">=22"
|
|
26
|
-
},
|
|
27
24
|
"type": "module",
|
|
28
25
|
"main": "./dist/index.cjs",
|
|
29
26
|
"module": "./dist/index.mjs",
|
|
30
|
-
"types": "./dist/index.d.cts",
|
|
31
27
|
"exports": {
|
|
32
28
|
".": {
|
|
33
|
-
"
|
|
34
|
-
"
|
|
29
|
+
"import": "./dist/index.mjs",
|
|
30
|
+
"require": "./dist/index.cjs"
|
|
35
31
|
}
|
|
36
32
|
},
|
|
33
|
+
"types": "./dist/index.d.cts",
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=22"
|
|
36
|
+
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@js-utils-kit/types": "1.
|
|
38
|
+
"@js-utils-kit/types": "1.4.0"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsdown",
|