
Research
Shai-Hulud Descends to Hades: Miasma Worm Campaign Spreads with New PyPI Wave
Socket found 37 malicious PyPI wheels that abuse Python startup hooks to launch a Bun-powered credential stealer tied to Mini Shai-Hulud/Miasma.
`plain-env` is a framework-agnostic `.env` and `Webpack.DefinePlugin` replacement, making business code cleaner, safer, better support `tree-shaking` and code inspection.
plain-env is a framework-agnostic .env and Webpack.DefinePlugin replacement, making business code cleaner, safer, better support tree-shaking and code inspection.
plain-env 是框架无关的 .env 和 Webpack.DefinePlugin 的替代品,让业务代码更干净、更安全、更好的支持 tree-shaking 和代码检查。
plain-env 的使用与工程框架完全解耦,提供命令行和 Node.js 支持。
以前通过 Webpack.DefinePlugin 动态注入并替换业务代码中的 process.env.xx 的耦合方式。
现在只需要 import {xx} from "./config.ts" 即可。
plain-env 通过解析配置声明文件自动生成 TS/JS 文件,通过 import 在业务代码中使用。
绝佳的隔离了工程环境和业务环境。
同时保留了注释在 IDE 中的提示。
plain-env 支持自动选择对应部署环境的子配置,拒绝导出一切无用信息,防止误用。
plain-env 支持从 CI/CD 中接受环境变量的注入,避免关键信息配置在代码仓库中有泄漏风险。
TS/JS 的静态化导出有更好的支持类型提示、打包过程的静态错误检查和 tree-shaking。
完全规避掉了前端业务代码中使用 process.env 的缺点。
plain-env ...process.env.xx / --inject--modeTODO:
import/require 使用安装: npm i -D plain-env 或 yarn add -D plain-env 或 pnpm add -D plain-env
基础用法:
plain-env {config1.yaml}={output-file1.js} {config2.yaml}={output-file2.ts}
配置文件使用 yaml,配置格式参考 ./examples/y-env1.yaml
用例:
plain-env examples/y-env1.yaml=examples/y-env1.ts
自动将 y-env1.yaml 转换为 y-env1.ts,结果见 ./examples/y-env1.ts
plain-env examples/y-env1.yaml=examples/y-env1.ts examples/y-env1.yaml=examples/y-env1.js
多文件支持,自动将 y-env1.yaml 转换为 y-env1.ts,将 y-env1.yaml 转换为 y-env1.js,结果见 examples 文件夹
plain-env examples/y-env1.yaml=examples/y-env1.cjs --module cjs
指定 --module cjs 将 y-env1.yaml 转换为 CommonJS 模块系统的 y-env1.cjs,结果见 ./examples/y-env1.cjs
plain-env examples/y-env1.yaml=examples/y-env1.ts --mode dev
指定 --mode dev 将 y-env1.yaml 转换为 y-env1.ts,并过滤存在 dev 异或 * 的子配置。结果见 ./examples/y-env1.ts
--mode
--mode [mode]
指定使用的子配置。如果配置项为 Map 且有对应的子字段或者有 '*',则输出对应子字段的值
例如,对于配置
ENV_TAG:
dev: 'dev'
test: 'test'
pro: 'pro'
VAR_1:
'*': 123
pro: 456
PLAIN: 'plain-env'
使用 --mode test 生成的配置为:
export const ENV_TAG = 'test' as const
export const VAR_1 = 123 as const
export const PLAIN = 'plain-env' as const
--module
--module <esm, cjs>
指定输出的 TS/JS 文件的模块系统类型。
--watch
TODO
-v
查看当前版本
-h
plain-env -h
查看帮助信息
TODO
支持的数据类型都有哪些?
对于 yaml 配置文件,支持:
stringnumber(正负数、浮点数、NaN、Infinity)booleannullObjectArray为什么推荐使用 yaml,而不是 json/.env?
有更完备的数据类型支持
有更好的数据层级支持
关于 yaml 的使用,更多信息访问这里: https://eemeli.org/yaml/
构建到不同 mode 时,指定的 output.ts 文件内容总是变化怎么办?
将 output.ts 添加到 .gitignore 即可
FAQs
`plain-env` is a framework-agnostic `.env` and `Webpack.DefinePlugin` replacement, making business code cleaner, safer, better support `tree-shaking` and code inspection.
We found that plain-env demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Socket found 37 malicious PyPI wheels that abuse Python startup hooks to launch a Bun-powered credential stealer tied to Mini Shai-Hulud/Miasma.

Security News
RubyGems and Bundler 4.0.13 introduced an opt-in cooldown feature that delays newly published gems during dependency resolution.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.