Skip to content

Add DataLad-like dataset commands (clone/get/save/push/drop) - #73

Merged
neuromechanist merged 2 commits into
devfrom
feature/datalad-commands
Jan 24, 2026
Merged

neuromechanist merged 2 commits into
devfrom
feature/datalad-commands

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

  • Adds 5 new CLI commands for local dataset management: clone, get, save, push, drop
  • Adds helper functions to git-annex.ts: dropFiles, getAnnexS3Remotes, copyToAnnexRemote
  • 19 tests covering help output, error handling, and real git-annex operations

Commands

Command Description
nemar dataset clone <id> Resolve dataset ID via API, git clone + annex init
nemar dataset get [files...] Download annexed data files with parallel streams
nemar dataset save [-m msg] Stage all changes + commit
nemar dataset push Push git to GitHub + copy annex content to S3 remote
nemar dataset drop [files...] Free local copies (verifies remote copies exist)

Test plan

  • All 19 new tests pass (help output, error handling, real git-annex ops)
  • Full suite passes (173 tests)
  • Lint clean (biome check)
  • Typecheck clean (tsc --noEmit)
  • E2E test with nm099999 (clone, get, save, push, drop cycle)

Closes #58
Partial #51

DataLad-like CLI commands for local dataset operations:
- clone: resolve dataset ID via API, git clone + annex init
- get: download annexed files with parallel streams
- save: stage all changes + commit
- push: push git to GitHub + copy annex content to S3
- drop: free local copies (with safety check)

Includes 19 tests covering help output, error handling,
and real git-annex operations in temporary repos.
- Rewrite getAnnexS3Remotes: remove dead code, validate remote names,
  add proper error handling instead of silent catch blocks
- Fix dropFiles: return success=false on non-zero exit code, use
  defensive error extraction instead of bare type assertion
- Fix copyToAnnexRemote: defensive error extraction
- Clone: validate github_repo format before constructing URL
- Get: validate --jobs, improve "0 files" message
- Push: exit non-zero on S3 failure, validate --jobs, log which
  remote is selected when multiple exist
- Drop: exit non-zero on partial failure, show error details
@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR73

Version: 0.3.7-PR73.68daa58
Commit: 68daa58


🤖 Updated on each push.

@neuromechanist

Copy link
Copy Markdown
Contributor Author

PR Review Summary

Issues Found and Fixed (commit 68daa58)

Critical:

  • getAnnexS3Remotes had dead code, silent catch blocks, and unvalidated remote names allowing potential command injection. Rewrote the function with proper error handling, remote name validation, and removed dead code.
  • dropFiles returned success: true when exit code was non-zero (partial success). Fixed to always return success: false on non-zero exit.

Important:

  • Added --jobs validation (NaN, < 1) in get and push commands
  • Clone command now validates github_repo format before constructing URL
  • Push S3 failure now exits non-zero (was just a warning before)
  • Drop partial failure now exits non-zero and shows error details
  • All catch blocks use defensive e instanceof Error ? e.message : String(e) instead of bare (e as Error).message
  • Push command logs which S3 remote is selected when multiple exist
  • Get command shows "All data files already present" instead of "Downloaded 0 file(s)"

Verification

  • All 173 tests pass
  • Lint clean
  • Typecheck clean

This branch was previously deployed

1 inactive deployment
npm — 68daa58f Deployed Jan 24, 2026 by neuromechanist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant