Skip to content

dongitran/saptools

Repository files navigation

⚡ saptools

Extract SAP HANA credentials from Cloud Foundry — straight into your SQLTools config.

npm version npm downloads License: MIT Node.js TypeScript Tests


Stop copy-pasting credentials manually.
saptools connects to CF, finds your HANA bindings, and writes your SQLTools connections — in seconds.


✨ Features

  • 🔍 Interactive extraction — guided prompts to pick region → org → space → apps
  • Local cache — orgs and apps are cached locally; subsequent runs are near-instant even with 30+ apps
  • 🔄 Background sync — run a launchd daemon to keep cache fresh every 15 minutes
  • 🎯 SQLTools-ready — auto-updates .vscode/settings.json with sqltools.connections
  • 🌏 Multi-region — supports Singapore (AP11) and Brazil São Paulo (BR10) out of the box
  • 🖥️ Spinner UX — real-time ora progress for every step, no silent waiting

📦 Installation

npm install -g saptools

Set your credentials once:

export SAP_EMAIL=your@email.com
export SAP_PASSWORD=your-password

Tip: Add these to your ~/.zshrc or ~/.bashrc so they persist across sessions.


🚀 Quick Start

saptools

You'll be guided through an interactive menu:

? What would you like to do?
❯ 🔍 Extract to SQLTools Config
  🔄 Refresh Data Cache (Sync All)

Pick Extract, select your region, org, space, and apps — done. Your .vscode/settings.json is updated automatically.


🛠️ Commands

Command Description
saptools Launch interactive mode
saptools sync Manually sync all regions to local cache
saptools cronjob enable Install background sync daemon (launchd on macOS)
saptools cronjob disable Remove background sync daemon
saptools cronjob status Check daemon status

⚙️ How It Works

saptools
   ↓
Interactive menu → Select region, org, space, apps
   ↓
CF API  →  VCAP_SERVICES  →  Extract HANA credentials
   ↓
Write  →  .vscode/settings.json (sqltools.connections)
          ~/.config/saptools/output.json

Cache architecture: On first run, orgs and app lists are fetched from CF and stored in ~/.config/saptools/cache.json. Subsequent runs read from cache — making selection near-instant. Run saptools sync or enable the background daemon to keep cache fresh.


🔄 Background Sync

# Enable auto-sync every 15 minutes (launchd on macOS, crontab on Linux/WSL)
saptools cronjob enable

# Check sync logs
tail -f ~/.config/saptools/sync.log

The daemon runs silently and keeps your local cache up-to-date, so the CLI always loads instantly.


🔐 Credentials

saptools reads credentials from environment variables only — nothing is ever stored on disk.

export SAP_EMAIL=your@email.com
export SAP_PASSWORD=your-password

🧪 Development

git clone https://github.com/dongitran/saptools
cd saptools
npm install

npm run check    # typecheck + lint + spell + tests
npm run test     # unit tests with coverage
npm run build    # compile TypeScript

📄 License

MIT © dongitran

About

⚡ SAP Cloud Foundry CLI — extract HANA credentials & sync SQLTools config instantly

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors