npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ingeni/igs-vault

v2.1.1

Published

A CLI tool to fetch secrets from HashiCorp Vault and write to .env files

Readme

igs-vault

CLI ดึง secrets จาก HashiCorp Vault (KV v2) มาเขียนเป็นไฟล์ .env — รองรับหลาย vault path ต่อไฟล์เดียว, template, และจัดกลุ่มให้รู้ว่า key ไหนมาจาก path ไหน


Install / Develop

npm run build
chmod +x dist/index.js
npm link
igs-vault --help

Setup (ตั้งค่า Vault credentials)

# แบบ interactive (ถาม addr / username / password)
igs-vault setup

# แบบ non-interactive
igs-vault setup-script <addr> <username> <password>
# เช่น
igs-vault setup-script http://127.0.0.1:8200 admin admin

credentials ถูกเก็บที่ ~/.igs-vault/config.json


init — สร้าง igs-vault.json

igs-vault init .env

Interactive flow:

  1. เลือก root (development / global / preview / prod / stag)
  2. เลือก sub แบบเจาะลึก (drill-down) — Vault KV v2 folder จะลงท้ายด้วย / ถ้าเลือกโดน folder tool จะ list ต่อลงไปเรื่อยๆ จนถึง secret จริง (leaf)
    global/         → เลือก dev/
    global/dev/     → เลือก mac      ← leaf
    ได้ path เต็ม: global/data/dev/mac
  3. ถามว่าจะใช้ template สำหรับ .env หรือไม่

ผลลัพธ์บันทึกลง igs-vault.json:

[{ "path": "global/data/dev/mac", "env": ".env", "template": ".env.example" }]

write — ดึง secrets เขียนทับไฟล์

igs-vault write global/data/dev/mac .env    # ระบุ path ตรงๆ
igs-vault write                             # ไม่ใส่ arg → เลือกจาก igs-vault.json

append — ดึง secrets มา merge เข้าไฟล์เดิม

igs-vault append global/data/dev/mac .env   # ระบุ path
igs-vault append global/                    # path ลงท้าย '/' → เลือกจาก list
igs-vault append                            # ไม่ใส่ arg → เลือกจาก igs-vault.json

read / setkv / updatekv

# อ่าน secrets ออกหน้าจอ
igs-vault read global/data/dev/mac

# ตั้งค่า key เดียว
igs-vault setkv global/data/dev/mac KEY value

# push ค่าจากไฟล์ .env กลับขึ้น vault
igs-vault updatekv global/data/dev/mac .env.local
igs-vault updatekv global/               # ลงท้าย '/' → เลือกจาก list
igs-vault updatekv                       # ไม่ใส่ arg → เลือกจาก igs-vault.json

updatekv behavior:

  • key มีใน vault path → update
  • key ไม่มีใน path แต่มีใน global (คนละค่า) → เตือนแล้ว update
  • key ไม่มีทั้งใน path และ global → ถามก่อนว่าจะเพิ่ม (Yes/No)

igs-vault.json

เก็บ mapping ระหว่าง vault path ↔ ไฟล์ .env ต่อ 1 project — ทำให้รัน write / append / updatekv แบบไม่ใส่ arg ได้ (จะขึ้น list ให้เลือก)

[
  { "path": "global/data/dev/mac", "env": ".env", "template": ".env.example" },
  { "path": "stag/data/shipment", "env": ".env" }
]

| field | ความหมาย | | ---------- | --------------------------------------------------- | | path | vault read path (KV v2 = <root>/data/<sub...>) | | env | ไฟล์ปลายทางในเครื่อง | | template | (optional) ไฟล์ template ที่ใช้คุมโครงสร้าง/comment |


Template + การจัด group ตาม path

ระบุ template ใน igs-vault.json ได้ตรงๆ หรือถ้ามีไฟล์ .env.sample วางข้างๆ .env ก็ถูก auto-detect ให้เอง (ไม่ต้องตั้งค่า)

การ merge ทำงานแบบนี้:

  • key ที่มีใน template → เติมค่าจาก vault ลง ตำแหน่งเดิมใน template — comment, section, ลำดับ ของ template อยู่ครบ
  • key ที่ไม่มีใน template → ต่อท้ายไฟล์ โดย จัดกลุ่มด้วย header ## <vault path> ให้รู้ว่ามาจาก path ไหน
  • append หลาย path เข้าไฟล์เดียว → ถ้า path ใดตั้ง template ไว้ ทุกครั้งที่ append จะ render ผ่าน template เสมอ comment จึงไม่หาย
  • key ซ้ำข้าม path → path ที่ append ทีหลังชนะ และใส่ note # replace <old path> -> <new path> ไว้เหนือ key นั้น

ตัวอย่าง template (.env.example) — whole-file, มี section + comment:

# -----------------------------------------------------------------------------
# App
# -----------------------------------------------------------------------------
PORT=3000
API_URL=http://localhost:${PORT}/api

# -----------------------------------------------------------------------------
# Database
# -----------------------------------------------------------------------------
ORACLE_USER=admin

หลัง append global/data/dev/mac .env แล้วตามด้วย append stag/data/shipment .env ได้ .env หน้าตาแบบนี้ (key ใน template อยู่ที่เดิม, ที่เหลือ group ตาม path):

# -----------------------------------------------------------------------------
# App
# -----------------------------------------------------------------------------
PORT=3000
API_URL=http://localhost:3000/api

# -----------------------------------------------------------------------------
# Database
# -----------------------------------------------------------------------------
ORACLE_USER=<ค่าจาก vault>

## global/data/dev/mac
JWT_SECRET=...
TELEGRAM_TOKEN=...

## stag/data/shipment
# replace global/data/dev/mac -> stag/data/shipment
NODE_ENV=...
SHIPMENT_API=...
LOG_LEVEL=DEBUG

ไม่มี template?write / append จะเขียนแบบ plain โดยยัง group ด้วย ## <vault path> และใส่ note # replace ... ให้เหมือนกัน จึงรู้ที่มาของทุก key เสมอ