#env #secret #1password #start #applications #env-file #opx

app onepassword-secret-util

使用opx CLI增强1password密钥扩展

6个版本

0.0.6 2023年9月4日
0.0.5 2023年6月23日
0.0.4 2023年3月11日

#128认证

32 每月下载量

MIT 协议

11KB
170 代码行

onepassword-secret-util

此工具允许您使用opx二进制文件启动应用程序,并将所有传递给op run ....env文件。

安装

cargo安装 onepassword-secret-util

# start your app with secrets injected
opx

上面的命令将在后台运行

op run --env-file=.env --env-file=apps/web/.env -- npm start

演示

在演示仓库中正确执行的示例

opx ✔ $ opx
[OPX] Forcing terminal colors with FORCE_COLOR=1
[ENV] .env
[ENV] apps/demo/.env
[ENV] apps/other-app/.env
[OPX] op run --env-file=/Users/hacksore/Code/opensource/demo-1pass-secrets/.env --env-file=/Users/hacksore/Code/opensource/demo-1pass-secrets/apps/demo/.env --env-file=/Users/hacksore/Code/opensource/demo-1pass-secrets/apps/other-app/.env -- npm start

> demo-1pass-secrets@0.0.0 start
> turbo run start

• Packages in scope: demo, eslint-config-custom, other-app, tsconfig
• Running start in 4 packages
• Remote caching disabled
demo:start: cache bypass, force executing 545833253ebd38cc
other-app:start: cache bypass, force executing 2ed51133d14970ce
other-app:start:
other-app:start: > other-app@1.0.0 start
other-app:start: > node main.js
other-app:start:
demo:start:
demo:start: > demo@1.0.0 start
demo:start: > node main.js
demo:start:
demo:start: Hello this is a sample app that uses a secret from 1password cli
other-app:start: Hello this is a sample app that uses a secret from 1password cli
demo:start: Secret is: <concealed by 1Password>
other-app:start: Secret is: <concealed by 1Password>

 Tasks:    2 successful, 2 total
Cached:    0 cached, 2 total
  Time:    216ms

调试

如何链接它

# dev
cargo watch -x "build --release"

# link it
export PATH="$HOME/code/opensource/onepassword-secret-util/target/release:$PATH"

注意事项

  • 如何处理重复的env变量?
  • 如何处理不同的环境维度(.env.local与.env.production等)?

依赖项

~2–13MB
~109K SLoC