Initial commit
This commit is contained in:
31
packages/env/README.md
vendored
Normal file
31
packages/env/README.md
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# Environment Package
|
||||
|
||||
This package contains code which creates env values.
|
||||
To use the code in the package, you need to follow those steps:
|
||||
|
||||
1. Add a new record to `.env` (NEED TO CONTAIN `CEB_` PREFIX),
|
||||
|
||||
- If you want via cli:
|
||||
- Add it as argument like: `pnpm set-global-env CLI_CEB_NEXT_VALUE=new_data ...` (NEED TO CONTAIN `CLI_CEB_` PREFIX)
|
||||
|
||||
> [!IMPORTANT]
|
||||
> `CLI_CEB_DEV` and `CLI_CEB_FIREFOX` are `false` by default \
|
||||
> All CLI values are overwriting in each call, that's mean you'll have access to values from current script run only.
|
||||
|
||||
- If you want dynamic variables go to `lib/index.ts` and edit `dynamicEnvValues` object.
|
||||
|
||||
2. Use it, for example:
|
||||
```ts
|
||||
console.log(process.env['CEB_EXAMPLE']);
|
||||
```
|
||||
or
|
||||
```ts
|
||||
console.log(process.env.CEB_EXAMPLE);
|
||||
```
|
||||
but with first solution, autofill should work for IDE:
|
||||

|
||||
3. You are also able to import const like `IS_DEV` from `@extension/env` like:
|
||||
```ts
|
||||
import { IS_DEV } from '@extension/env';
|
||||
```
|
||||
For more look [ENV CONST](lib/const.ts)
|
||||
9
packages/env/index.mts
vendored
Normal file
9
packages/env/index.mts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { baseEnv, dynamicEnvValues } from './lib/index.js';
|
||||
import type { EnvType } from './lib/types.js';
|
||||
|
||||
export * from './lib/index.js';
|
||||
|
||||
export default {
|
||||
...baseEnv,
|
||||
...dynamicEnvValues,
|
||||
} as EnvType;
|
||||
10
packages/env/lib/config.ts
vendored
Normal file
10
packages/env/lib/config.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { config } from '@dotenvx/dotenvx';
|
||||
|
||||
export const baseEnv =
|
||||
config({
|
||||
path: `${import.meta.dirname}/../../../../.env`,
|
||||
}).parsed ?? {};
|
||||
|
||||
export const dynamicEnvValues = {
|
||||
CEB_NODE_ENV: baseEnv.CEB_DEV === 'true' ? 'development' : 'production',
|
||||
} as const;
|
||||
4
packages/env/lib/const.ts
vendored
Normal file
4
packages/env/lib/const.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export const IS_DEV = process.env['CLI_CEB_DEV'] === 'true';
|
||||
export const IS_PROD = !IS_DEV;
|
||||
export const IS_FIREFOX = process.env['CLI_CEB_FIREFOX'] === 'true';
|
||||
export const IS_CI = process.env['CEB_CI'] === 'true';
|
||||
2
packages/env/lib/index.ts
vendored
Normal file
2
packages/env/lib/index.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './config.js';
|
||||
export * from './const.js';
|
||||
13
packages/env/lib/types.ts
vendored
Normal file
13
packages/env/lib/types.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { dynamicEnvValues } from './index.js';
|
||||
|
||||
interface ICebEnv {
|
||||
readonly CEB_EXAMPLE: string;
|
||||
readonly CEB_DEV_LOCALE: string;
|
||||
}
|
||||
|
||||
interface ICebCliEnv {
|
||||
readonly CLI_CEB_DEV: string;
|
||||
readonly CLI_CEB_FIREFOX: string;
|
||||
}
|
||||
|
||||
export type EnvType = ICebEnv & ICebCliEnv & typeof dynamicEnvValues;
|
||||
30
packages/env/package.json
vendored
Normal file
30
packages/env/package.json
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "@extension/env",
|
||||
"version": "0.5.0",
|
||||
"description": "chrome extension - environment variables",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"dist/**"
|
||||
],
|
||||
"types": "index.mts",
|
||||
"main": "dist/index.mjs",
|
||||
"scripts": {
|
||||
"clean:bundle": "rimraf dist",
|
||||
"clean:node_modules": "pnpx rimraf node_modules",
|
||||
"clean:turbo": "rimraf .turbo",
|
||||
"clean": "pnpm clean:bundle && pnpm clean:node_modules && pnpm clean:turbo",
|
||||
"ready": "tsc -b",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "pnpm lint --fix",
|
||||
"format": "prettier . --write --ignore-path ../../.prettierignore",
|
||||
"type-check": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@dotenvx/dotenvx": "^1.44.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@extension/tsconfig": "workspace:*"
|
||||
}
|
||||
}
|
||||
8
packages/env/tsconfig.json
vendored
Normal file
8
packages/env/tsconfig.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "@extension/tsconfig/module",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": ["index.mts", "lib"]
|
||||
}
|
||||
BIN
packages/env/use-env-example.png
vendored
Normal file
BIN
packages/env/use-env-example.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
Reference in New Issue
Block a user