Eve library

@oshun/tara-content

Other

Revision 1

On this page

The Tara content importer CLI (P9.4 of the Tara Content Workbench). It takes a validated publish bundle and lays it into the real apps/tara/content tree on a fresh git branch — the last step of the publishing bridge, run by an editorial lead once a bundle is approved and its assets are staged.

What it does#

Given a bundle-export JSON ({ manifest, assets: [{ relativePath, sha256, base64 }] }), the importer:

  1. Validates manifest against the checked-in apps/tara/content/schemas/meditation.schema.json (JSON Schema 2020-12).
  2. Re-hashes every asset's bytes and compares against its recorded sha256 — integrity is verified from the content, never trusted from the bundle's own claim.
  3. Refuses (exit code 1, prints every reason) if the manifest is invalid or any checksum mismatches — before a single file is written and before any branch is created. There are no partial imports.
  4. Otherwise creates a git branch and writes the item at meditations/<category>/<slug>/ — metadata.json (the manifest) plus every asset beside it — then git add + git commit.

Usage#

bash
# From the repo root (uses the workspace tsx):
pnpm --filter @oshun/tara-content cli -- import \
  --bundle path/to/bundle-export.json \
  --content-root apps/tara/content

# Validate + plan only (writes nothing, no git):
… import --bundle b.json --content-root apps/tara/content --dry-run

# Write files without branching/committing (non-repo targets, CI diffs):
… import --bundle b.json --content-root apps/tara/content --skip-git

Options:

  • -b, --bundle <path> — the bundle-export JSON (required).
  • -c, --content-root <path> — the apps/tara/content tree (required).
  • --branch <name> — branch name (default tara-content/<category>-<slug>).
  • --dry-run — validate + plan only.
  • --skip-git — write files but do not branch/commit.

Programmatic use#

importBundle(bundle, options, schemaPath?) is exported for the golden-bundle round-trip test (P9.8): it throws ImportRefusedError with reasons[] on any validation failure, and returns the { itemDir, branch, files } plan otherwise.