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

@saptools/cf-export

v0.1.8

Published

Export CAP/CF project artifacts (package.json, lockfiles, .cdsrc.json, default-env.json, .npmrc) from running SAP BTP Cloud Foundry apps

Readme

📤 @saptools/cf-export

Export CAP / Cloud Foundry project artifacts (package.json, lockfiles, .cdsrc.json, default-env.json, .npmrc) from a running SAP BTP Cloud Foundry application. (v0.1.1+)

Pull the exact files you need for local development or debugging directly from a live CF container using cf ssh + CF API.

npm version license node install size types

InstallQuick StartCLIDevelopment


✨ Features

  • 📦 Selective artifact export — default exports everything, or pick exactly what you need with --file
  • 🌍 Remote root support — specify --remote-root (or "root url") to locate files when they are not at the standard /home/vcap/app
  • 🔄 Synthesized default-env.json — built from live cf curl /v3/apps/.../env (full VCAP_SERVICES + env vars)
  • 🛡️ Best-effort for optional files — missing files (package.json, locks, .cdsrc.json, .npmrc) are skipped gracefully
  • 🧰 CLI + typed library — use from terminal or Node.js/TypeScript with full types
  • 🔐 Secure by default — sensitive files (default-env.json, .npmrc) written with 0600 permissions
  • 🪶 Lightweight — only depends on commander + reuses @saptools/cf-files

📦 Install

# Global CLI
npm install -g @saptools/cf-export

# Or as a library
npm install @saptools/cf-export
# pnpm add @saptools/cf-export

[!NOTE] Requires Node.js ≥ 20 and the official cf CLI on PATH.


🚀 Quick Start

# Export credentials (used only during the operation)
export SAP_EMAIL="[email protected]"
export SAP_PASSWORD="your-sap-password"

# (Recommended) Set your CF target once — then you can skip region/org/space
cf target -o my-org -s dev

# Export all artifacts — region/org/space are auto-detected from `cf target`!
cf-export -a my-cap-app --out ./exported

# You can still pass them explicitly when needed
cf-export -r ap10 -o my-org -s dev -a my-cap-app --out ./exported

# Export with a custom remote root
cf-export -a my-cap-app \
  --remote-root /home/vcap/app/srv \
  --out ./exported

# Export only specific files
cf-export -a my-cap-app \
  --file package.json --file pnpm-lock.yaml --file default-env.json

After export you will have the requested files locally, ready for local CAP development or attaching to tickets.


🧰 CLI

The default (and only) command is export.

cf-export [options]

Common examples

Export everything (recommended default)

cf-export \
  -r ap10 \
  -o my-org \
  -s dev \
  -a my-cap-app \
  --out ./exported-artifacts

With custom remote root

cf-export -r ap10 -o my-org -s dev -a my-cap-app \
  --remote-root /home/vcap/app \
  --out ./out

Selective export

cf-export ... --file package.json --file default-env.json

Options

Region/org/space flags are optional. They are auto-detected from your current cf target (recommended: run cf target -o ORG -s SPACE first).

| Flag | Description | Required | |-----------------------|-----------------------------------------------------------------------------|----------| | -r, --region <key> | CF region key (e.g. ap10, eu10). Auto-detected from current cf target | No | | -o, --org <name> | CF org name. Auto-detected from current cf target | No | | -s, --space <name> | CF space name. Auto-detected from current cf target | No | | -a, --app <name> | CF app name | Yes | | --out <dir> | Output directory (default: current working directory) | No | | --remote-root <path>| Hint for the base directory inside the container (the "root url") | No | | --file <name> | Artifact to export (repeatable). Omit to export all | No | | --all | Explicitly request all supported artifacts (default behavior) | No |

Supported artifact names (use with --file):

  • package.json
  • package-lock.json
  • pnpm-lock.yaml
  • .cdsrc.json
  • default-env.json
  • .npmrc

Missing optional files are skipped (only default-env.json failures when explicitly selected will surface clearly).


Environment variables

| Variable | Purpose | |----------------------|----------------------------------------------------------------------| | SAP_EMAIL | SAP SSO email (required for cf auth) | | SAP_PASSWORD | SAP SSO password | | CF_EXPORT_CF_HOME | Reuse an existing CF_HOME (advanced) | | CF_EXPORT_CF_BIN | Override the cf binary path (mainly for testing / fake-cf) |


How remote root works

When --remote-root is provided, candidate paths are tried in this order:

  1. ${remoteRoot}/<filename>
  2. /home/vcap/app/<filename>
  3. <filename> (relative, last resort)

This matches the strategy used by the "Export" feature in the SAP Tools VS Code extension.


Security

  • default-env.json and .npmrc are always written with mode 0600.
  • Every operation uses an isolated temporary CF_HOME (unless you explicitly override via env).
  • Credentials are never logged or written to disk by this tool.
  • Treat any exported default-env.json as a secret.

🛠️ Development (inside monorepo)

pnpm install
pnpm --filter @saptools/cf-export build
pnpm --filter @saptools/cf-export typecheck
pnpm --filter @saptools/cf-export lint
pnpm --filter @saptools/cf-export test:unit
pnpm --filter @saptools/cf-export test:e2e:fake

The fake-backed e2e tests do not require real SAP credentials.


🌐 Related packages


📄 License

MIT © Dong Tran


Made to make SAP BTP CF development less painful ✨