CLICLItypeA command you run, rather than a dependency you import.See every one →What this type is →independently maintainedindependently maintainedoriginPublished by one person or a small company outside SAP. Says nothing about quality; the readings say that.See every one →

@saptools/cf-sync

A command line and Node.js API that logs into Cloud Foundry once, walks every region, org, space and app the user can reach, and caches that topology as JSON for the other @saptools packages to read.

cf orgs and cf spaces answer only for the region and org currently targeted, so finding where an app runs across a landscape means retargeting by hand. cf-sync sync walks region, org, space and app across every region in one pass and writes the snapshot to ~/.saptools/cf-structure.json, with the requested state, instance count and routes of each app; --only and the region, orgs, org and space commands refresh part of it without walking the rest. A separate db-sync collects each app's VCAP_SERVICES.hana credentials in a background worker into ~/.saptools/cf-db-bindings.json, a file the README says to treat as a secret. SAP_EMAIL and SAP_PASSWORD are read only while syncing, and the read commands work offline from the cache. The README names @saptools/cf-xsuaa as one of the packages that read its output.

Facts

Latestv0.5.0ReleasedLast pushLicenceMIT

Where it sits

Lives in
Runs
Cloud Foundry
Requires
SAP BTP, Cloud Foundry RuntimeSAP BTP, Cloud Foundry RuntimeartifactThe landscape it walks and caches: every region, org, space and app the signed-in user can reach, read through the cf CLI.Node.jsNode.jsoutside the atlasIt is a Node command line and library, and the README names the Node version it needs beside the cf CLI on the PATH.

Who is behind it

Đông TrầnĐông TrầnPersonMaintains this
In the atlas: maintains 18, contributes to 18
@dongitran
maintainer

What it declares

Every artifact

Type
CLI
Origin
Independently maintained
Runs on
Cloud Foundry

As a CLI

Distributed through
npm

Connections4

Install

npm add @saptools/cf-sync

Derived from the package name. No recipe recorded; the README has the configuration.

Where @saptools/cf-sync runsYour SAP BTP subaccountBy its type: a CLI is run from a terminalcallsdocumentedrequiresdocumentedrequiresYour terminal, actorYour terminalNode.js, systemNode.jssystem@saptools/cf-sync, module@saptools/cf-syncSAP BTP, Cloud Foundry Runtime, service instanceSAP BTP, CloudFoundry Runtime
SAPnot SAP's, or the project's ownstated in the documentdocumented only

README

quoted from dongitran/saptools under MIT, read
dongitran/saptools/packages/cf-sync/README.mdOn GitHub

☁️ @saptools/cf-sync

Map your SAP BTP Cloud Foundry topology and HANA app bindings into package-managed JSON files.

Walk every region, org, space, and app you have access to, cache the topology, then optionally collect app-level HANA credentials in a background sync — no more juggling cf target or hand-running cf env.

npm version license node install size types

Install • Quick Start • CLI • FAQ


✨ Features

  • 🌍 Full-landscape sync — logs into CF once, walks region → org → space → app across every region you can reach
  • 🟢 App runtime metadata — snapshots include requested state, instance counts, and routes from cf apps
  • ⚡ Partial + streaming reads — read / regions / region commands return whatever is already known, even while a long sync is in progress
  • 🧭 Region org refresh — orgs refreshes one region's org list without walking spaces or apps
  • 🗄️ Background DB binding sync — db-sync can collect VCAP_SERVICES.hana credentials for every cached app or one app selector in the background
  • 🧠 Smart fallbacks — runtime state first, last stable snapshot next, on-demand fetch as a last resort
  • 🧩 CLI & typed API — every command has a zero-config Node.js equivalent with full TypeScript definitions
  • 📦 Drop-in for other saptools — the output file is the shared source of truth for packages like @saptools/cf-xsuaa
  • 🪶 Small + boring — two deps (commander, ora), one-shot background workers only when requested, no resident daemon

📦 Install

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

# Or as a dependency
npm install @saptools/cf-sync
# pnpm add @saptools/cf-sync
# yarn add @saptools/cf-sync

Note

Requires Node.js ≥ 20 and the official cf CLI on PATH (v8 recommended).


Updates

Every command first checks npm for a newer @saptools/cf-sync (at most once an hour, one small request with a 2-second timeout) and, when one exists, installs that exact version with the package manager that owns the running binary and re-runs the command you typed on the new version. Both steps are announced on stderr; nothing is printed when the install is already current:

cf-sync: updating 0.5.0 -> 0.6.0 ...
cf-sync: updated to 0.6.0; re-running the command

If the install cannot complete, one stderr line gives the manual command and the command runs on the installed version; that version is not retried for a day. cf-sync self-update forces the check and install now; cf-sync self-update --check only reports.

ControlEffect
SAPTOOLS_AUTO_UPDATE=on|notify|offon (default) installs and re-runs; notify prints the manual command once per version; off never checks. Applies to every @saptools CLI.
CF_SYNC_AUTO_UPDATEsame values, this CLI only; wins over the global variable
SAPTOOLS_UPDATE_INTERVAL_MINUTESminutes between checks (default 60; 0 checks on every run)
SAPTOOLS_NPM_REGISTRYregistry to check and install from (default: npm's configured registry, then npmjs)
SAPTOOLS_UPDATE_DEBUG=1explain on stderr why nothing happened

The updater switches itself off in CI (CI set), under NODE_ENV=test or NO_UPDATE_NOTIFIER, when the binary runs from a source checkout, an npm link or an npx cache, and inside the re-run itself. It never writes to stdout, never asks for input, never uses sudo, and never moves onto a prerelease. Its state lives in ~/.saptools/updates/.

🚀 Quick Start

# 1. Export your SAP SSO credentials (only used during sync)
export SAP_EMAIL="you@company.com"
export SAP_PASSWORD="your-sap-password"

# 2. Sync every accessible region in parallel
cf-sync sync --verbose

# 3. Read the topology snapshot back from anywhere — CLI, script, or Node process
cf-sync read | jq '.regions[] | {key, accessible}'

# 4. Optionally collect HANA DB bindings for every cached app in the background
cf-sync db-sync
cf-sync db-read | jq '.metadata'

After the first topology sync, ~/.saptools/cf-structure.json is ready for the rest of your tooling. If you run db-sync, the HANA binding snapshot is stored separately.


🧰 CLI

🔄 cf-sync sync

Run a live sync and write a topology snapshot. A full sync replaces the snapshot; --only refreshes the listed regions and merges them into the existing snapshot without removing other cached regions.

cf-sync sync
cf-sync sync --verbose
cf-sync sync --no-interactive
cf-sync sync --only ap10,ap11,eu10
FlagDescription
--verbosePrint progress lines
--no-interactiveDisable the spinner (use in CI)
--only <keys>Sync only the listed region keys
📖 cf-sync read

Print the best-available full structure as JSON — always succeeds as long as something has been synced before.

  • Returns runtime state while a sync is in progress
  • Falls back to the last stable snapshot otherwise
cf-sync read
🗺️ cf-sync regions

Print the list of regions (key + label + endpoint + accessibility).

  • Returns the default SAP CF catalog while a first sync is still running
  • Returns only synced regions with orgs once a snapshot exists
cf-sync regions
🎯 cf-sync region <key>

Print one region as JSON, fetching it on demand if it's missing.

cf-sync region eu10
cf-sync region eu10 --no-refresh
FlagDescription
--no-refreshRead cached data only, never call CF

Tip

cf-sync region <key> is the fastest way to answer "what's in just this region right now?" without walking everything.

🧭 cf-sync orgs <region>

Refresh only the Cloud Foundry org names for one region and merge that list back into the shared topology snapshot.

  • Updates only the requested region
  • Preserves cached spaces/apps for orgs that still exist
  • Removes stale org entries from that region only
  • Adds newly discovered orgs with empty spaces until a targeted org, space, or full sync fills them in
  • Uses an isolated CF_HOME, so it does not clobber your interactive CF CLI target
cf-sync orgs ap10
cf-sync orgs eu10 --verbose
🧭 cf-sync org <region> <org>

Refresh exactly one Cloud Foundry org and merge every refreshed space/app in that org back into the shared topology snapshot.

  • Updates only the requested region/org
  • Preserves sibling orgs and regions already present in the snapshot
  • Fails without changing the stable snapshot when the requested org cannot be targeted
  • Uses an isolated CF_HOME, so it does not clobber your interactive CF CLI target
cf-sync org ap10 my-org
cf-sync org eu10 my-org --verbose
🔁 cf-sync space <region> <org> <space>

Refresh exactly one Cloud Foundry space and merge the latest app metadata back into the shared topology snapshot.

  • Updates only the requested region/org/space
  • Preserves sibling orgs and spaces already present in the snapshot
  • Uses an isolated CF_HOME, so it does not clobber your interactive CF CLI target
  • Can run while a full cf-sync sync is active; the merge is serialized through the same runtime-state lock
cf-sync space ap10 my-org dev
cf-sync space eu10 my-org app --verbose
🗄️ cf-sync db-sync [selector]

Start a detached background worker that collects VCAP_SERVICES.hana credentials.

  • with no selector: sync every app in the cached topology snapshot
  • with <app>: sync one uniquely named app from the cached topology snapshot
  • with region/org/space/app: sync one explicit app even if no topology snapshot exists yet
cf-sync db-sync
cf-sync db-sync orders-srv
cf-sync db-sync ap10/my-org/dev/orders-srv

Important

cf-sync db-sync persists HANA credentials to local disk under ~/.saptools/. Treat that file like a secret.

📚 cf-sync db-read [selector]

Read the best available HANA binding snapshot as JSON.

  • cf-sync db-read returns the full runtime/stable DB snapshot view
  • cf-sync db-read <selector> returns one app binding view
cf-sync db-read
cf-sync db-read orders-srv
cf-sync db-read ap10/my-org/dev/orders-srv

📁 Output Files

All state lives under your home directory:

~/.saptools/cf-structure.json     # last successful full sync (stable)
~/.saptools/cf-sync-state.json    # active runtime state, partial reads, sync metadata
~/.saptools/cf-sync-history.jsonl # append-only timeline of sync milestones for debugging
~/.saptools/cf-db-bindings.json   # last successful HANA binding snapshot (contains credentials)
~/.saptools/cf-db-sync-state.json # active DB binding runtime state
~/.saptools/cf-db-sync-history.jsonl # append-only DB sync milestones

cf-sync-history.jsonl is newline-delimited JSON. Each entry records a timestamped milestone such as lock acquisition, region traversal, runtime merges, recoveries, and final completion/failure so you can reconstruct where a sync got stuck.

cf-db-bindings.json is also newline-free JSON, but unlike the topology files it contains HANA credentials. Do not commit it, attach it to tickets, or paste it into logs.

🔬 Shape of cf-structure.json
{
  "syncedAt": "2026-04-18T00:00:00Z",
  "regions": [
    {
      "key": "ap10",
      "label": "Singapore",
      "apiEndpoint": "https://api.cf.ap10.hana.ondemand.com",
      "accessible": true,
      "orgs": [
        {
          "name": "my-org",
          "spaces": [
            {
              "name": "dev",
              "apps": [{ "name": "my-srv" }]
            }
          ]
        }
      ]
    }
  ]
}

Important

Prefer the CLI read commands or the exported APIs over parsing these files directly — the on-disk format is an implementation detail.


❓ FAQ

Do I have to re-enter my SAP credentials for every read?

No. SAP_EMAIL / SAP_PASSWORD are only used during sync, db-sync, and cf-sync region <key> when the region is missing locally. Pure read commands work offline.

How often should I sync?

As often as your CF topology changes in a way you care about — usually daily or weekly is plenty. cf-sync sync --only ap10,eu10 keeps hot regions fresh without walking everything.

Is the output file safe to commit?

cf-structure.json does not contain secrets, but it does list every org, space, and app you can reach — so it leaks your landscape's structure. Keep it out of public repos.

cf-db-bindings.json is more sensitive: it contains HANA credentials by design. Treat it like a secret and never commit it.

How does this compare to cf orgs / cf spaces?

Those commands only act on the currently targeted region/org. cf-sync walks every region in one pass and gives you a unified, cached view — which is what every other saptools package consumes.


🛠️ Development

From the monorepo root:

pnpm install
pnpm --filter @saptools/cf-sync build
pnpm --filter @saptools/cf-sync typecheck
pnpm --filter @saptools/cf-sync test:unit
pnpm --filter @saptools/cf-sync test:e2e

The e2e suite hits live SAP BTP CF. Set CF_SYNC_E2E_ONLY=ap10,eu10 (plus SAP_EMAIL / SAP_PASSWORD) to restrict the regions it walks in CI.



👨‍💻 Author

dongtran ✨

📄 License

MIT


Made with ❤️ to make your work life easier!

MIT, read

History

Latest

v0.5.0

Other 1

Notes
  • Self-updating. Every command now checks npm for a newer @saptools/cf-sync (at most once an hour) and, when one exists, installs that exact version and re-runs the command on it, announcing both steps on stderr. SAPTOOLS_AUTO_UPDATE=on|notify|off controls it (see the README's Updates section); it is off by itself in CI, in tests, from a source checkout and inside the re-run. New cf-sync self-update [--check] forces the check and install now. --version now reads package.json at runtime. Both come from the private, build-time-bundled @saptools/core package; the published tarball gains no runtime dependency.
  1. v0.4.12

    Other 3

    Notes
    • Fixed a lost-update race where two concurrent targeted refreshes (cf-sync space/org/orgs) could each collect against a stale topology snapshot and overwrite one another's freshly persisted subtree.
    • Added a dedicated targeted-refresh lock so syncSpace(), syncOrg(), and syncRegionOrgs() serialize collect-and-persist end to end without blocking full syncs or topology reads.
    • Added unit coverage proving concurrent targeted space refreshes are serialized.
  2. v0.4.11

    Other 3

    Notes
    • Added fetchAppDbBindings() to fetch a single app's HANA service bindings on demand, without persisting anything under ~/.saptools/ (no snapshot, lock, or history writes).
    • Extracted the ephemeral CF_HOME session helper into a shared cf/session module reused by both runDbSync() and fetchAppDbBindings().
    • Added unit coverage for non-persisting DB binding fetches.
  3. v0.4.9

    Other 3

    Notes
    • Added cf-sync orgs <region> and syncRegionOrgs() to refresh only a region's org list without walking spaces or apps.
    • Preserved cached spaces/apps for still-present orgs while removing stale org entries only from the refreshed region.
    • Added unit and fake-backed E2E coverage for region org-list refresh behavior.
  4. v0.4.8

    Other 3

    Notes
    • Fixed region-limited cf-sync sync --only <region> so refreshed regions are merged into the existing topology snapshot instead of replacing unrelated cached regions.
    • Added cf-sync org <region> <org> and syncOrg() for targeted org refreshes that preserve sibling topology.
    • Added unit and fake-backed E2E coverage for targeted region and org sync behavior.
4downloads per week, npm
Weekly downloads for @saptools/cf-sync26 complete calendar weeks from 2026-04-27 to 2026-10-25; the latest total is 4.27 Apr – 3 May: 8884 May – 10 May: 43111 May – 17 May: 57018 May – 24 May: 1,39225 May – 31 May: 4771 Jun – 7 Jun: 5468 Jun – 14 Jun: 72415 Jun – 21 Jun: 54722 Jun – 28 Jun: 1,09429 Jun – 5 Jul: 1,3336 Jul – 12 Jul: 36713 Jul – 19 Jul: 62820 Jul – 26 Jul: 61227 Jul – 2 Aug: 4293 Aug – 9 Aug: 44410 Aug – 16 Aug: 48417 Aug – 23 Aug: 50324 Aug – 30 Aug: 6331 Aug – 6 Sept: 3587 Sept – 13 Sept: 8814 Sept – 20 Sept: 11121 Sept – 27 Sept: 18328 Sept – 4 Oct: 1775 Oct – 11 Oct: 33012 Oct – 18 Oct: 5419 Oct – 25 Oct: 4

Details

Sources4
Added by handdiscovered herechecked
npm registry, @saptools/cf-syncversion, releases, installschecked
github.com/git+https://github.com/dongitran/saptools.gittree, pushes, contributors, CIchecked
packages/cf-sync/README.mdquoted, and what the entry declareschecked

Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.

Compatibility and provenance
deploymentCloud Foundry
latestv0.5.0
first release
releases and cadence28, ~3d median
discovered viaAdded by hand
first seen in the atlas
ecosystem and domainbtp, developer-experience
History in the atlas1
  1. First seen.
For your agent
Ref
artifact:saptools-cf-sync
JSON
/artifacts/saptools-cf-sync.json
MCP
Connecting an agent