mirror of
https://github.com/idrainformatica/PecFlow.git
synced 2026-06-16 12:45:42 +02:00
fase 5
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Pooya Parsa <pooya@pi0.io>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
# std-env
|
||||
|
||||
[](http://npmjs.com/package/std-env)
|
||||
[](http://npmjs.com/package/std-env)
|
||||
[](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 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/):
|
||||
|
||||
```ts
|
||||
import { runtime, runtimeInfo } from "std-env";
|
||||
|
||||
// "" | "node" | "deno" | "bun" | "workerd" ...
|
||||
console.log(runtime);
|
||||
|
||||
// { name: "node" }
|
||||
console.log(runtimeInfo);
|
||||
```
|
||||
|
||||
You can also use individual named exports for each runtime detection:
|
||||
|
||||
> [!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`
|
||||
- `isBun`
|
||||
- `isDeno`
|
||||
- `isNetlify`
|
||||
- `isEdgeLight`
|
||||
- `isWorkerd`
|
||||
- `isFastly`
|
||||
|
||||
List of well known providers can be found from [./src/runtimes.ts](./src/runtimes.ts).
|
||||
|
||||
## Platform-Agnostic `env`
|
||||
|
||||
`std-env` provides a lightweight proxy to access environment variables in a platform agnostic way.
|
||||
|
||||
```ts
|
||||
import { env } from "std-env";
|
||||
```
|
||||
|
||||
## Platform-Agnostic `process`
|
||||
|
||||
`std-env` provides a lightweight proxy to access [`process`](https://nodejs.org/api/process.html) object in a platform agnostic way.
|
||||
|
||||
```ts
|
||||
import { process } from "std-env";
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "std-env",
|
||||
"version": "3.10.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",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "unbuild",
|
||||
"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",
|
||||
"test": "pnpm lint && pnpm typecheck && vitest run --coverage",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.7.2",
|
||||
"@vitest/coverage-v8": "^3.2.4",
|
||||
"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",
|
||||
"typescript": "^5.9.3",
|
||||
"unbuild": "^3.6.1",
|
||||
"vitest": "^3.2.4"
|
||||
},
|
||||
"packageManager": "pnpm@10.18.2"
|
||||
}
|
||||
Reference in New Issue
Block a user