nemar-cli 0.3.11-PR110.4a18316 → 0.3.11-PR110.80de83a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +2 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -148,7 +148,7 @@ ${E.cyan("CI Status:")} ${D}
148
148
  `);let B=$.bids_validation.present,J=B?E.green("[x]"):E.red("[ ]");if(console.log(` ${J} BIDS Validation`),B){let Y=$.bids_validation.status==="success"?E.green:$.bids_validation.status==="failure"?E.red:E.yellow;if(console.log(` Status: ${Y($.bids_validation.status)}`),$.bids_validation.url)console.log(` URL: ${E.gray($.bids_validation.url)}`)}else console.log(` ${E.gray("Not deployed. Use 'nemar admin ci add' to deploy.")}`);let Q=$.version_check.present,X=Q?E.green("[x]"):E.red("[ ]");if(console.log(` ${X} Version Check`),!Q)console.log(` ${E.gray("Not deployed. Use 'nemar admin ci add' to deploy.")}`);console.log()}catch($){if($ instanceof g){if(F.fail($.message),$.statusCode===403)console.log(E.gray(" This command requires admin privileges"));else if($.statusCode===404)console.log(E.gray(" Dataset not found"))}else{F.fail("Failed to check CI status");let B=$ instanceof Error?$.message:String($);console.log(E.gray(` Error details: ${B}`))}}});j2.command("add").description("Deploy CI workflows to a dataset repository").argument("<dataset-id>","Dataset ID (e.g., nm000104)").option(yD,xD).option(hD,bD).action(async(D,F)=>{if(!D0())return;console.log(E.cyan(`
149
149
  Deploy CI workflows to: ${D}
150
150
  `)),console.log("This will add the following workflows:"),console.log(" 1. BIDS Validation (runs on PRs)"),console.log(" 2. Version Check (ensures version bump on PRs)"),console.log(" 3. PR Merge Handler (creates releases, publishes DOIs)"),console.log();let $=await gD(`Deploy CI workflows to ${D}?`,F);if($!=="confirmed"){console.log(E.gray($==="declined"?"Skipped":"Cancelled"));return}let B=C(`Deploying CI workflows to ${D}...`).start();try{let J=await K$(D);B.succeed("CI workflows deployed"),console.log();for(let Q of J.workflows_deployed)console.log(` ${E.green("[x]")} ${Q}`);console.log()}catch(J){if(J instanceof g){if(B.fail(J.message),J.statusCode===403)console.log(E.gray(" This command requires admin privileges"));else if(J.statusCode===404)console.log(E.gray(" Dataset not found"))}else{B.fail("Failed to deploy CI workflows");let Q=J instanceof Error?J.message:String(J);console.log(E.gray(` Error details: ${Q}`))}}});v0.addCommand(j2);var T$=new F0("doi").description("DOI management");T$.command("create").description("Create concept DOI for a dataset").argument("<dataset-id>","Dataset ID (e.g., nm000104)").option("--title <title>","DOI title (defaults to dataset name)").option("--description <desc>","DOI description").option("--provider <provider>","DOI provider: ezid (default) or zenodo","ezid").option("--sandbox","Use sandbox/test DOI").option(yD,xD).option(hD,bD).action(async(D,F)=>{if(!D0())return;let $=C("Fetching dataset info...").start(),B;try{B=await X8(D),$.succeed(`Found dataset: ${B.name}`)}catch(G){if(G instanceof g){if($.fail(G.message),G.statusCode===404)console.log(E.gray(" Dataset not found"))}else $.fail("Failed to fetch dataset");return}try{let G=await L2(D);if(G.concept_doi){if(console.log(E.yellow(`
151
- Dataset already has a concept DOI:`)),console.log(` Concept DOI: ${E.cyan(G.concept_doi)}`),G.zenodo_concept_url)console.log(` Zenodo URL: ${G.zenodo_concept_url}`);return}}catch{}if(console.log(),console.log(E.cyan("Dataset Information:")),console.log(` ID: ${B.dataset_id}`),console.log(` Name: ${B.name}`),B.github_repo)console.log(` GitHub: ${B.github_repo}`);if(F.sandbox)console.log(` Mode: ${E.yellow("SANDBOX (test DOI)")}`);console.log();let J=F.provider==="zenodo"?"zenodo":"ezid";if(F.sandbox){if(console.log(E.yellow("\u2501".repeat(60))),console.log(E.yellow.bold(" SANDBOX MODE ENABLED")),console.log(E.yellow("\u2501".repeat(60))),J==="zenodo")console.log(E.yellow(" \u2022 Using Zenodo sandbox (sandbox.zenodo.org)"));else console.log(E.yellow(" \u2022 Using EZID test shoulder (doi:10.5072/FK2)")),console.log(E.yellow(" \u2022 Test DOIs auto-delete after 2 weeks"));console.log(E.yellow(" \u2022 DOI will NOT be indexed by DataCite")),console.log(E.yellow(" \u2022 DOI will NOT resolve in production")),console.log(E.yellow(" \u2022 Use this for testing workflows only")),console.log(E.yellow("\u2501".repeat(60))),console.log()}console.log(E.red("WARNING: DOIs are PERMANENT and cannot be deleted!")),console.log(E.gray("The DOI will be pre-reserved but not published until the first version release.")),console.log(` Provider: ${E.cyan(J.toUpperCase())}`),console.log();let Q=F.sandbox?`Create TEST concept DOI via ${J.toUpperCase()} SANDBOX?`:`Create PERMANENT concept DOI via ${J.toUpperCase()} PRODUCTION?`,X=await gD(Q,F);if(X!=="confirmed"){console.log(E.gray(X==="declined"?"Skipped":"Cancelled"));return}let Y=C(`Creating concept DOI via ${J.toUpperCase()}...`).start();try{let G=await wv(D,{title:F.title,description:F.description,sandbox:F.sandbox,provider:J});Y.succeed("Concept DOI created successfully");let H=C("Applying branch protection...").start();try{let W=await V$(D);if(W.warnings&&W.warnings.length>0){H.warn("Branch protection applied with warnings");for(let K of W.warnings)console.log(E.yellow(` Warning: ${K}`))}else H.succeed("Branch protection applied")}catch(W){if(H.warn("Could not apply branch protection"),W instanceof g){if(console.log(E.gray(` ${W.message}`)),W.statusCode===403)console.log(E.gray(" Check admin credentials and permissions"))}else console.log(E.gray(` ${W instanceof Error?W.message:"Unknown error"}`));console.log(E.gray(" Manual setup: Go to GitHub repo Settings > Branches > Add rule"))}if(console.log(),console.log(E.green("DOI Information:")),console.log(` Concept DOI: ${E.cyan(G.concept_doi)}`),console.log(` Provider: ${G.provider?.toUpperCase()||"ZENODO"}`),G.zenodo_url)console.log(` Zenodo URL: ${G.zenodo_url}`);if(G.doi_url)console.log(` DOI URL: ${G.doi_url}`);if(G.ezid_identifier)console.log(` EZID ID: ${G.ezid_identifier}`);if(console.log(),console.log(E.yellow("Next steps:")),console.log(" 1. Set up automatic DOI publishing by running:"),console.log(E.gray(` ${G.setup_command}`)),console.log(" (paste the webhook token when prompted)"),console.log(),console.log(" 2. Update dataset_description.json with DatasetDOI field"),console.log(" 3. Create a PR and merge it to trigger version DOI publication"),console.log(),F.sandbox)console.log(E.gray("Note: This is a sandbox DOI and will not resolve in production."))}catch(G){if(G instanceof g){if(Y.fail(G.message),G.statusCode===403)console.log(E.gray(" This command requires admin privileges"))}else Y.fail("Failed to create concept DOI"),console.log(E.gray(` ${G instanceof Error?G.message:"Unknown error"}`))}});T$.command("info").description("Get DOI info for a dataset").argument("<dataset-id>","Dataset ID (e.g., nm000104)").action(async(D)=>{if(!D0())return;let F=C("Fetching DOI info...").start();try{let $=await L2(D);if(F.stop(),console.log(),console.log(E.cyan(`DOI Information for ${D}:`)),console.log(` Dataset Name: ${$.name}`),console.log(),$.concept_doi){if(console.log(E.green("Concept DOI:")),console.log(` DOI: ${$.concept_doi}`),console.log(` URL: https://doi.org/${$.concept_doi}`),console.log(` Provider: ${($.doi_provider||"zenodo").toUpperCase()}`),$.doi_provider==="ezid"){if($.ezid_identifier)console.log(` EZID ID: ${$.ezid_identifier}`);if($.ezid_status){let B=$.ezid_status==="public"?E.green:E.yellow;console.log(` Status: ${B($.ezid_status)}`)}}if($.zenodo_concept_url){if(console.log(` Zenodo: ${$.zenodo_concept_url}`),$.zenodo_concept_url.includes("sandbox.zenodo.org"))console.log(),console.log(E.yellow("Mode: SANDBOX (test DOI)")),console.log(E.yellow(" This DOI is not indexed by DataCite and will not resolve in production"))}}else console.log(E.yellow("No concept DOI created yet")),console.log(E.gray(" Use 'nemar admin doi create' to create one"));if(console.log(),$.latest_version_doi){if(console.log(E.green("Latest Version DOI:")),console.log(` DOI: ${$.latest_version_doi}`),console.log(` URL: https://doi.org/${$.latest_version_doi}`),$.zenodo_latest_version_url)console.log(` Zenodo: ${$.zenodo_latest_version_url}`)}else if($.concept_doi)console.log(E.yellow("No version DOI published yet")),console.log(E.gray(" Version DOIs are created automatically on PR merge"))}catch($){if($ instanceof g){if(F.fail($.message),$.statusCode===404)console.log(E.gray(" Dataset not found"));else if($.statusCode===403)console.log(E.gray(" This command requires admin privileges"))}else F.fail("Failed to fetch DOI info")}});T$.command("update").description("Update EZID DOI metadata or status").argument("<dataset-id>","Dataset ID (e.g., nm000104)").option("--make-public","Transition DOI from reserved to public (permanent)").option("--refresh","Refresh metadata from BIDS dataset_description.json").option(yD,xD).option(hD,bD).action(async(D,F)=>{if(!D0())return;if(!F.makePublic&&!F.refresh){console.log(E.yellow("No action specified. Use --make-public and/or --refresh."));return}if(F.makePublic){console.log(E.red("WARNING: Making a DOI public is PERMANENT!")),console.log(E.gray(" The DOI will be findable in DataCite and cannot be reverted.")),console.log();let B=await gD(`Make DOI for ${D} PUBLIC and permanent?`,F);if(B!=="confirmed"){console.log(E.gray(B==="declined"?"Skipped":"Cancelled"));return}}let $=C("Updating DOI...").start();try{let B=await Tv(D,{status:F.makePublic?"public":void 0,refresh_metadata:F.refresh});$.succeed("DOI updated successfully"),console.log(),console.log(` EZID ID: ${E.cyan(B.ezid_identifier)}`),console.log(` Status: ${B.status==="public"?E.green(B.status):E.yellow(B.status)}`),console.log(` URL: ${B.doi_url}`)}catch(B){if(B instanceof g){if($.fail(B.message),B.statusCode===400)console.log(E.gray(" DOI update is only supported for EZID-managed DOIs"))}else $.fail("Failed to update DOI"),console.log(E.gray(` ${B instanceof Error?B.message:"Unknown error"}`))}});v0.addCommand(T$);var j$=new F0("publish").description("Publication workflow management");j$.command("list").description("List publication requests").option("-s, --status <status>","Filter by status (requested, approving, published, denied)").addHelpText("after",`
151
+ Dataset already has a concept DOI:`)),console.log(` Concept DOI: ${E.cyan(G.concept_doi)}`),G.zenodo_concept_url)console.log(` Zenodo URL: ${G.zenodo_concept_url}`);return}}catch{}if(console.log(),console.log(E.cyan("Dataset Information:")),console.log(` ID: ${B.dataset_id}`),console.log(` Name: ${B.name}`),B.github_repo)console.log(` GitHub: ${B.github_repo}`);if(F.sandbox)console.log(` Mode: ${E.yellow("SANDBOX (test DOI)")}`);console.log();let J=F.provider==="zenodo"?"zenodo":"ezid";if(F.sandbox){if(console.log(E.yellow("\u2501".repeat(60))),console.log(E.yellow.bold(" SANDBOX MODE ENABLED")),console.log(E.yellow("\u2501".repeat(60))),J==="zenodo")console.log(E.yellow(" \u2022 Using Zenodo sandbox (sandbox.zenodo.org)"));else console.log(E.yellow(" \u2022 Using EZID test shoulder (doi:10.5072/FK2)")),console.log(E.yellow(" \u2022 Test DOIs auto-delete after 2 weeks"));console.log(E.yellow(" \u2022 DOI will NOT be indexed by DataCite")),console.log(E.yellow(" \u2022 DOI will NOT resolve in production")),console.log(E.yellow(" \u2022 Use this for testing workflows only")),console.log(E.yellow("\u2501".repeat(60))),console.log()}console.log(E.red("WARNING: DOIs are PERMANENT and cannot be deleted!")),console.log(E.gray("The DOI will be pre-reserved but not published until the first version release.")),console.log(` Provider: ${E.cyan(J.toUpperCase())}`),console.log();let Q=F.sandbox?`Create TEST concept DOI via ${J.toUpperCase()} SANDBOX?`:`Create PERMANENT concept DOI via ${J.toUpperCase()} PRODUCTION?`,X=await gD(Q,F);if(X!=="confirmed"){console.log(E.gray(X==="declined"?"Skipped":"Cancelled"));return}let Y=C(`Creating concept DOI via ${J.toUpperCase()}...`).start();try{let G=await wv(D,{title:F.title,description:F.description,sandbox:F.sandbox,provider:J});Y.succeed("Concept DOI created successfully");let H=C("Applying branch protection...").start();try{let W=await V$(D);if(W.warnings&&W.warnings.length>0){H.warn("Branch protection applied with warnings");for(let K of W.warnings)console.log(E.yellow(` Warning: ${K}`))}else H.succeed("Branch protection applied")}catch(W){if(H.warn("Could not apply branch protection"),W instanceof g){if(console.log(E.gray(` ${W.message}`)),W.statusCode===403)console.log(E.gray(" Check admin credentials and permissions"))}else console.log(E.gray(` ${W instanceof Error?W.message:"Unknown error"}`));console.log(E.gray(" Manual setup: Go to GitHub repo Settings > Branches > Add rule"))}if(console.log(),console.log(E.green("DOI Information:")),console.log(` Concept DOI: ${E.cyan(G.concept_doi)}`),console.log(` Provider: ${G.provider.toUpperCase()}`),G.provider==="ezid")console.log(` DOI URL: ${G.doi_url}`),console.log(` EZID ID: ${G.ezid_identifier}`);else console.log(` Zenodo URL: ${G.zenodo_url}`);if(G.metadata_warning)console.log(E.yellow(` Warning: ${G.metadata_warning}`));if(console.log(),console.log(E.yellow("Next steps:")),console.log(" 1. Set up automatic DOI publishing by running:"),console.log(E.gray(` ${G.setup_command}`)),console.log(" (paste the webhook token when prompted)"),console.log(),console.log(" 2. Update dataset_description.json with DatasetDOI field"),console.log(" 3. Create a PR and merge it to trigger version DOI publication"),console.log(),F.sandbox)console.log(E.gray("Note: This is a sandbox DOI and will not resolve in production."))}catch(G){if(G instanceof g){if(Y.fail(G.message),G.statusCode===403)console.log(E.gray(" This command requires admin privileges"))}else Y.fail("Failed to create concept DOI"),console.log(E.gray(` ${G instanceof Error?G.message:"Unknown error"}`))}});T$.command("info").description("Get DOI info for a dataset").argument("<dataset-id>","Dataset ID (e.g., nm000104)").action(async(D)=>{if(!D0())return;let F=C("Fetching DOI info...").start();try{let $=await L2(D);if(F.stop(),console.log(),console.log(E.cyan(`DOI Information for ${D}:`)),console.log(` Dataset Name: ${$.name}`),console.log(),$.concept_doi){if(console.log(E.green("Concept DOI:")),console.log(` DOI: ${$.concept_doi}`),console.log(` URL: https://doi.org/${$.concept_doi}`),console.log(` Provider: ${($.doi_provider||"zenodo").toUpperCase()}`),$.doi_provider==="ezid"){if($.ezid_identifier)console.log(` EZID ID: ${$.ezid_identifier}`);if($.ezid_status){let B=$.ezid_status==="public"?E.green:E.yellow;console.log(` Status: ${B($.ezid_status)}`)}}if($.zenodo_concept_url){if(console.log(` Zenodo: ${$.zenodo_concept_url}`),$.zenodo_concept_url.includes("sandbox.zenodo.org"))console.log(),console.log(E.yellow("Mode: SANDBOX (test DOI)")),console.log(E.yellow(" This DOI is not indexed by DataCite and will not resolve in production"))}}else console.log(E.yellow("No concept DOI created yet")),console.log(E.gray(" Use 'nemar admin doi create' to create one"));if(console.log(),$.latest_version_doi){if(console.log(E.green("Latest Version DOI:")),console.log(` DOI: ${$.latest_version_doi}`),console.log(` URL: https://doi.org/${$.latest_version_doi}`),$.zenodo_latest_version_url)console.log(` Zenodo: ${$.zenodo_latest_version_url}`)}else if($.concept_doi)console.log(E.yellow("No version DOI published yet")),console.log(E.gray(" Version DOIs are created automatically on PR merge"))}catch($){if($ instanceof g){if(F.fail($.message),$.statusCode===404)console.log(E.gray(" Dataset not found"));else if($.statusCode===403)console.log(E.gray(" This command requires admin privileges"))}else F.fail("Failed to fetch DOI info")}});T$.command("update").description("Update EZID DOI metadata or status").argument("<dataset-id>","Dataset ID (e.g., nm000104)").option("--make-public","Transition DOI from reserved to public (permanent)").option("--refresh","Refresh metadata from BIDS dataset_description.json").option(yD,xD).option(hD,bD).action(async(D,F)=>{if(!D0())return;if(!F.makePublic&&!F.refresh){console.log(E.yellow("No action specified. Use --make-public and/or --refresh."));return}if(F.makePublic){console.log(E.red("WARNING: Making a DOI public is PERMANENT!")),console.log(E.gray(" The DOI will be findable in DataCite and cannot be reverted.")),console.log();let B=await gD(`Make DOI for ${D} PUBLIC and permanent?`,F);if(B!=="confirmed"){console.log(E.gray(B==="declined"?"Skipped":"Cancelled"));return}}let $=C("Updating DOI...").start();try{let B=await Tv(D,{status:F.makePublic?"public":void 0,refresh_metadata:F.refresh});$.succeed("DOI updated successfully"),console.log(),console.log(` EZID ID: ${E.cyan(B.ezid_identifier)}`),console.log(` Status: ${B.status==="public"?E.green(B.status):E.yellow(B.status)}`),console.log(` URL: ${B.doi_url}`)}catch(B){if(B instanceof g){if($.fail(B.message),B.statusCode===400)console.log(E.gray(" DOI update is only supported for EZID-managed DOIs"))}else $.fail("Failed to update DOI"),console.log(E.gray(` ${B instanceof Error?B.message:"Unknown error"}`))}});v0.addCommand(T$);var j$=new F0("publish").description("Publication workflow management");j$.command("list").description("List publication requests").option("-s, --status <status>","Filter by status (requested, approving, published, denied)").addHelpText("after",`
152
152
  Description:
153
153
  List all publication requests from users, with optional filtering by status.
154
154
  Shows dataset ID, status, requesting user, and current progress.
@@ -598,7 +598,7 @@ Examples:
598
598
  $ nemar sandbox # Run sandbox training
599
599
  $ nemar sandbox status # Check if training is completed
600
600
  $ nemar sandbox reset # Reset for re-training
601
- `).action(OGD);async function OGD(){if(console.log(),console.log(E.bold("NEMAR Sandbox Training")),console.log(E.gray("Verify your setup and learn the upload workflow")),console.log(),!PD()){console.log(E.red("Not authenticated")),console.log(E.gray("Run 'nemar auth login' first"));return}let D=eD();if(D.sandboxCompleted){console.log(E.green("Sandbox training already completed!")),console.log(E.gray(`Dataset ID: ${D.sandboxDatasetId}`)),console.log(),console.log("You can upload real datasets with:"),console.log(E.cyan(" nemar dataset upload ./your-dataset")),console.log(),console.log(E.gray("To re-run training, use: nemar sandbox reset"));return}console.log(E.bold("Step 1/6: Checking prerequisites..."));let F=C("Checking git-annex and SSH...").start(),$=await A$();if(!$.allPassed){F.fail("Prerequisites check failed"),console.log(),console.log(E.red("Missing requirements:"));for(let O of $.errors)console.log(E.yellow(` - ${O}`));if(!$.githubSSH.accessible)console.log(E.gray(" Run 'nemar auth setup-ssh' to configure SSH"));return}F.succeed("All prerequisites met");let B=C("Verifying GitHub CLI authentication...").start(),J=await L$(D.githubUsername);if(!J.authenticated){B.fail("GitHub CLI not authenticated"),console.log(E.red(` ${J.error}`)),console.log(),console.log("GitHub CLI is required for sandbox training. Install and authenticate:"),console.log(E.cyan(" brew install gh # or visit https://cli.github.com/")),console.log(E.cyan(" gh auth login"));return}if(D.githubUsername&&!J.matches)B.warn("GitHub CLI user mismatch"),console.log(E.yellow(` ${J.error}`)),console.log(),console.log("Your gh CLI is authenticated as a different GitHub account than your NEMAR account."),console.log("This may cause issues with repository access. To fix:"),console.log(E.cyan(` gh auth login # Login as ${D.githubUsername}`)),console.log(),console.log(E.yellow("WARNING: If upload fails with permission errors, this mismatch is the likely cause.")),console.log();else B.succeed(`GitHub CLI authenticated as ${J.username}`);console.log(),console.log(E.bold("Step 2/6: Generating test dataset..."));let Q=C("Creating minimal BIDS structure...").start(),X;try{let O=My();X=O.root;let YD=Ny(O);Q.succeed(`Test dataset created (${C$(YD)})`),console.log(E.gray(` Location: ${X}`))}catch(O){Q.fail("Failed to generate test dataset"),console.log(E.red(` ${O instanceof Error?O.message:"Unknown error"}`));return}console.log(),console.log(E.bold("Step 3/6: Registering sandbox dataset..."));let Y=C("Creating dataset on NEMAR...").start(),G,H,W,K,V,A;try{let O=await z$({name:"Sandbox Training Dataset",description:"Placeholder dataset for sandbox training",files:[{path:"sub-01/eeg/sub-01_task-rest_eeg.edf",size:512000,type:"data"},{path:"dataset_description.json",size:200,type:"metadata"},{path:"participants.tsv",size:50,type:"metadata"},{path:"README",size:500,type:"metadata"},{path:"sub-01/eeg/sub-01_task-rest_eeg.json",size:300,type:"metadata"}],sandbox:!0});G=O.dataset.dataset_id,H=O.dataset.ssh_url,W=O.dataset.github_url,K=O.s3_config,V=O.dataset.s3_prefix,A=O.upload_urls||{},Y.succeed(`Sandbox dataset created: ${E.cyan(G)}`),console.log(E.gray(` GitHub: ${W}`)),await new Promise((YD)=>setTimeout(YD,1e4))}catch(O){if(Y.fail("Failed to create sandbox dataset"),O instanceof g)console.log(E.red(` ${O.message}`));else console.log(E.red(` ${O instanceof Error?O.message:"Unknown error"}`));A1(X);return}let Z=C("Accepting GitHub repository invitation...").start(),U=W?.match(/github\.com\/([a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+)/),L=U?U[1].replace(/\.git$/,""):null;if(!L){Z.fail("Invalid GitHub repository URL from backend"),console.log(E.red(` Received: ${W||"(empty)"}`)),console.log(E.red(" Expected format: https://github.com/owner/repo")),console.log(),console.log("This may indicate a backend issue. Please contact support."),A1(X);return}let M=await M$(L);if(M.accepted)if(M.alreadyCollaborator)Z.succeed("Already a collaborator on this repository");else Z.succeed("GitHub invitation accepted");else Z.warn("Could not auto-accept invitation"),console.log(E.yellow(` ${M.error}`)),console.log(),console.log("You may need to accept the invitation manually:"),console.log(E.cyan(` https://github.com/${L}/invitations`)),console.log();console.log(),console.log(E.bold("Step 4/6: Initializing repository..."));let w=C("Setting up git-annex...").start(),P=D.username&&D.email?{name:D.username,email:D.email}:void 0;try{await Z$(X,{author:P}),await U$(X),await N$(X,H),w.succeed("Repository initialized")}catch(O){w.fail("Failed to initialize repository"),console.log(E.red(` ${O instanceof Error?O.message:"Unknown error"}`)),A1(X);return}if(console.log(),console.log(E.bold("Step 5/6: Uploading to S3...")),Object.keys(A).length===0)console.log(E.yellow(" No data files to upload (metadata only)"));else{let O=C("Uploading test data...").start();try{let _D=0,h=Object.keys(A).length,qD=await R$(X,A,{jobs:4,onProgress:(ED)=>{if(ED.status==="completed"||ED.status==="failed")_D++,O.text=`Uploading... ${_D}/${h} files`}});if(qD.failed.length>0){O.fail(`Upload failed for ${qD.failed.length} file(s)`);for(let ED of qD.failed)console.log(E.red(` Failed: ${ED}`));if(qD.error)console.log(E.red(` Error: ${qD.error}`));console.log(),console.log(E.yellow("Sandbox training aborted due to upload failures.")),console.log(E.gray("Please check your network connection and try again.")),A1(X);return}O.succeed(`Uploaded ${qD.uploaded} file(s)`)}catch(_D){O.fail("Upload failed"),console.log(E.red(` ${_D instanceof Error?_D.message:"Unknown error"}`)),A1(X);return}let YD=C("Registering file URLs...").start();try{let _D={};for(let qD of Object.keys(A))_D[qD]=`${K.public_url}/${V}/objects/${qD}`;let h=await w$(X,_D);if(!h.success){YD.fail(`URL registration failed for ${h.failed.length} file(s)`);for(let qD of h.failed)console.log(E.red(` Failed: ${qD}`));console.log(),console.log(E.yellow("Sandbox training aborted due to URL registration failures.")),console.log(E.gray("This may indicate a git-annex configuration issue.")),A1(X);return}YD.succeed(`Registered ${h.registered} file URLs`)}catch(_D){YD.fail("Failed to register URLs"),console.log(E.red(` ${_D instanceof Error?_D.message:"Unknown error"}`)),A1(X);return}}console.log(),console.log(E.bold("Step 6/6: Pushing to GitHub..."));let u=C("Saving and pushing...").start();try{await W5(X,"Initial sandbox training upload",P),await E5(X),u.succeed("Pushed to GitHub")}catch(O){u.fail("Failed to push to GitHub"),console.log(E.red(` ${O instanceof Error?O.message:"Unknown error"}`)),A1(X);return}let T=C("Finalizing...").start();try{await V$(G),await Pv(G),K0("sandboxCompleted",!0),K0("sandboxDatasetId",G),T.succeed("Sandbox training complete!")}catch(O){T.fail("Failed to finalize"),console.log(E.red(` ${O instanceof Error?O.message:"Unknown error"}`)),A1(X);return}A1(X),console.log(),console.log(E.green.bold("Congratulations! Sandbox training completed successfully.")),console.log(),console.log("Your setup is verified and you're ready to upload real datasets:"),console.log(E.cyan(" nemar dataset upload ./your-dataset")),console.log(),console.log(E.gray(`Sandbox dataset: ${G}`))}x$.command("status").description("Check sandbox training completion status").option("--refresh","Fetch latest status from server").action(async(D)=>{if(!PD()){console.log(E.red("Not authenticated")),console.log(E.gray("Run 'nemar auth login' first"));return}if(D.refresh){let F=C("Checking status...").start();try{let $=await kv();if(K0("sandboxCompleted",$.sandbox_completed),$.sandbox_dataset_id)K0("sandboxDatasetId",$.sandbox_dataset_id);if(F.stop(),$.sandbox_completed){if(console.log(E.green("Sandbox training: Completed")),console.log(E.gray(` Dataset ID: ${$.sandbox_dataset_id}`)),$.sandbox_completed_at)console.log(E.gray(` Completed: ${$.sandbox_completed_at}`))}else console.log(E.yellow("Sandbox training: Not completed")),console.log(),console.log("Run sandbox training with:"),console.log(E.cyan(" nemar sandbox"))}catch($){if(F.fail("Failed to check status"),$ instanceof g)console.log(E.red(` ${$.message}`))}}else{let F=eD();if(F.sandboxCompleted)console.log(E.green("Sandbox training: Completed")),console.log(E.gray(` Dataset ID: ${F.sandboxDatasetId}`));else console.log(E.yellow("Sandbox training: Not completed")),console.log(),console.log("Run sandbox training with:"),console.log(E.cyan(" nemar sandbox"))}});x$.command("reset").description("Reset sandbox training status for re-training").option(yD,xD).option(hD,bD).action(async(D)=>{if(!PD()){console.log(E.red("Not authenticated")),console.log(E.gray("Run 'nemar auth login' first"));return}if(!eD().sandboxCompleted){console.log(E.yellow("Sandbox training not yet completed")),console.log(E.gray("Nothing to reset"));return}let $=await gD("Reset sandbox training status? You will need to complete training again.",D);if($!=="confirmed"){console.log(E.gray($==="declined"?"Skipped":"Cancelled"));return}let B=C("Resetting sandbox status...").start();try{await Sv(),A2("sandboxCompleted"),A2("sandboxDatasetId"),B.succeed("Sandbox status reset"),console.log(),console.log("Run sandbox training again with:"),console.log(E.cyan(" nemar sandbox"))}catch(J){if(B.fail("Failed to reset"),J instanceof g)console.log(E.red(` ${J.message}`));else console.log(E.red(` ${J instanceof Error?J.message:"Unknown error"}`))}});var Cy={name:"nemar-cli",version:"0.3.11-PR110.4a18316",description:"CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",type:"module",main:"dist/index.js",bin:{nemar:"dist/index.js"},scripts:{dev:"bun run src/index.ts",build:"bun build src/index.ts --outdir dist --target bun --minify && sed '1s|#!/usr/bin/env node|#!/usr/bin/env bun|' dist/index.js > dist/index.js.tmp && mv dist/index.js.tmp dist/index.js",test:"bun test",lint:"biome check src/","lint:fix":"biome check --fix src/",format:"biome format --write src/",typecheck:"tsc --noEmit",prepublishOnly:"bun run build","docs:generate":"bun run scripts/generate-docs.ts","docs:serve":"mkdocs serve","docs:build":"mkdocs build"},keywords:["nemar","bids","neuroimaging","eeg","emg","datalad","cli"],author:"NEMAR Team",license:"MIT",repository:{type:"git",url:"git+https://github.com/nemarOrg/nemar-cli.git"},bugs:{url:"https://github.com/nemarOrg/nemar-cli/issues"},homepage:"https://nemar-cli.pages.dev",engines:{bun:">=1.0.0"},files:["dist","README.md","LICENSE"],dependencies:{chalk:"^5.3.0",commander:"^12.1.0",conf:"^13.0.1",inquirer:"^9.2.15",ora:"^8.0.1",zod:"^3.23.8"},devDependencies:{"@biomejs/biome":"1.9.4","@types/bcryptjs":"^3.0.0","@types/bun":"latest","@types/inquirer":"^9.0.7",bcryptjs:"^3.0.3",typescript:"^5.5.4"}};var Ry=Cy.version;var Z1=new F0;Z1.name("nemar").description(`CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource)
601
+ `).action(OGD);async function OGD(){if(console.log(),console.log(E.bold("NEMAR Sandbox Training")),console.log(E.gray("Verify your setup and learn the upload workflow")),console.log(),!PD()){console.log(E.red("Not authenticated")),console.log(E.gray("Run 'nemar auth login' first"));return}let D=eD();if(D.sandboxCompleted){console.log(E.green("Sandbox training already completed!")),console.log(E.gray(`Dataset ID: ${D.sandboxDatasetId}`)),console.log(),console.log("You can upload real datasets with:"),console.log(E.cyan(" nemar dataset upload ./your-dataset")),console.log(),console.log(E.gray("To re-run training, use: nemar sandbox reset"));return}console.log(E.bold("Step 1/6: Checking prerequisites..."));let F=C("Checking git-annex and SSH...").start(),$=await A$();if(!$.allPassed){F.fail("Prerequisites check failed"),console.log(),console.log(E.red("Missing requirements:"));for(let O of $.errors)console.log(E.yellow(` - ${O}`));if(!$.githubSSH.accessible)console.log(E.gray(" Run 'nemar auth setup-ssh' to configure SSH"));return}F.succeed("All prerequisites met");let B=C("Verifying GitHub CLI authentication...").start(),J=await L$(D.githubUsername);if(!J.authenticated){B.fail("GitHub CLI not authenticated"),console.log(E.red(` ${J.error}`)),console.log(),console.log("GitHub CLI is required for sandbox training. Install and authenticate:"),console.log(E.cyan(" brew install gh # or visit https://cli.github.com/")),console.log(E.cyan(" gh auth login"));return}if(D.githubUsername&&!J.matches)B.warn("GitHub CLI user mismatch"),console.log(E.yellow(` ${J.error}`)),console.log(),console.log("Your gh CLI is authenticated as a different GitHub account than your NEMAR account."),console.log("This may cause issues with repository access. To fix:"),console.log(E.cyan(` gh auth login # Login as ${D.githubUsername}`)),console.log(),console.log(E.yellow("WARNING: If upload fails with permission errors, this mismatch is the likely cause.")),console.log();else B.succeed(`GitHub CLI authenticated as ${J.username}`);console.log(),console.log(E.bold("Step 2/6: Generating test dataset..."));let Q=C("Creating minimal BIDS structure...").start(),X;try{let O=My();X=O.root;let YD=Ny(O);Q.succeed(`Test dataset created (${C$(YD)})`),console.log(E.gray(` Location: ${X}`))}catch(O){Q.fail("Failed to generate test dataset"),console.log(E.red(` ${O instanceof Error?O.message:"Unknown error"}`));return}console.log(),console.log(E.bold("Step 3/6: Registering sandbox dataset..."));let Y=C("Creating dataset on NEMAR...").start(),G,H,W,K,V,A;try{let O=await z$({name:"Sandbox Training Dataset",description:"Placeholder dataset for sandbox training",files:[{path:"sub-01/eeg/sub-01_task-rest_eeg.edf",size:512000,type:"data"},{path:"dataset_description.json",size:200,type:"metadata"},{path:"participants.tsv",size:50,type:"metadata"},{path:"README",size:500,type:"metadata"},{path:"sub-01/eeg/sub-01_task-rest_eeg.json",size:300,type:"metadata"}],sandbox:!0});G=O.dataset.dataset_id,H=O.dataset.ssh_url,W=O.dataset.github_url,K=O.s3_config,V=O.dataset.s3_prefix,A=O.upload_urls||{},Y.succeed(`Sandbox dataset created: ${E.cyan(G)}`),console.log(E.gray(` GitHub: ${W}`)),await new Promise((YD)=>setTimeout(YD,1e4))}catch(O){if(Y.fail("Failed to create sandbox dataset"),O instanceof g)console.log(E.red(` ${O.message}`));else console.log(E.red(` ${O instanceof Error?O.message:"Unknown error"}`));A1(X);return}let Z=C("Accepting GitHub repository invitation...").start(),U=W?.match(/github\.com\/([a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+)/),L=U?U[1].replace(/\.git$/,""):null;if(!L){Z.fail("Invalid GitHub repository URL from backend"),console.log(E.red(` Received: ${W||"(empty)"}`)),console.log(E.red(" Expected format: https://github.com/owner/repo")),console.log(),console.log("This may indicate a backend issue. Please contact support."),A1(X);return}let M=await M$(L);if(M.accepted)if(M.alreadyCollaborator)Z.succeed("Already a collaborator on this repository");else Z.succeed("GitHub invitation accepted");else Z.warn("Could not auto-accept invitation"),console.log(E.yellow(` ${M.error}`)),console.log(),console.log("You may need to accept the invitation manually:"),console.log(E.cyan(` https://github.com/${L}/invitations`)),console.log();console.log(),console.log(E.bold("Step 4/6: Initializing repository..."));let w=C("Setting up git-annex...").start(),P=D.username&&D.email?{name:D.username,email:D.email}:void 0;try{await Z$(X,{author:P}),await U$(X),await N$(X,H),w.succeed("Repository initialized")}catch(O){w.fail("Failed to initialize repository"),console.log(E.red(` ${O instanceof Error?O.message:"Unknown error"}`)),A1(X);return}if(console.log(),console.log(E.bold("Step 5/6: Uploading to S3...")),Object.keys(A).length===0)console.log(E.yellow(" No data files to upload (metadata only)"));else{let O=C("Uploading test data...").start();try{let _D=0,h=Object.keys(A).length,qD=await R$(X,A,{jobs:4,onProgress:(ED)=>{if(ED.status==="completed"||ED.status==="failed")_D++,O.text=`Uploading... ${_D}/${h} files`}});if(qD.failed.length>0){O.fail(`Upload failed for ${qD.failed.length} file(s)`);for(let ED of qD.failed)console.log(E.red(` Failed: ${ED}`));if(qD.error)console.log(E.red(` Error: ${qD.error}`));console.log(),console.log(E.yellow("Sandbox training aborted due to upload failures.")),console.log(E.gray("Please check your network connection and try again.")),A1(X);return}O.succeed(`Uploaded ${qD.uploaded} file(s)`)}catch(_D){O.fail("Upload failed"),console.log(E.red(` ${_D instanceof Error?_D.message:"Unknown error"}`)),A1(X);return}let YD=C("Registering file URLs...").start();try{let _D={};for(let qD of Object.keys(A))_D[qD]=`${K.public_url}/${V}/objects/${qD}`;let h=await w$(X,_D);if(!h.success){YD.fail(`URL registration failed for ${h.failed.length} file(s)`);for(let qD of h.failed)console.log(E.red(` Failed: ${qD}`));console.log(),console.log(E.yellow("Sandbox training aborted due to URL registration failures.")),console.log(E.gray("This may indicate a git-annex configuration issue.")),A1(X);return}YD.succeed(`Registered ${h.registered} file URLs`)}catch(_D){YD.fail("Failed to register URLs"),console.log(E.red(` ${_D instanceof Error?_D.message:"Unknown error"}`)),A1(X);return}}console.log(),console.log(E.bold("Step 6/6: Pushing to GitHub..."));let u=C("Saving and pushing...").start();try{await W5(X,"Initial sandbox training upload",P),await E5(X),u.succeed("Pushed to GitHub")}catch(O){u.fail("Failed to push to GitHub"),console.log(E.red(` ${O instanceof Error?O.message:"Unknown error"}`)),A1(X);return}let T=C("Finalizing...").start();try{await V$(G),await Pv(G),K0("sandboxCompleted",!0),K0("sandboxDatasetId",G),T.succeed("Sandbox training complete!")}catch(O){T.fail("Failed to finalize"),console.log(E.red(` ${O instanceof Error?O.message:"Unknown error"}`)),A1(X);return}A1(X),console.log(),console.log(E.green.bold("Congratulations! Sandbox training completed successfully.")),console.log(),console.log("Your setup is verified and you're ready to upload real datasets:"),console.log(E.cyan(" nemar dataset upload ./your-dataset")),console.log(),console.log(E.gray(`Sandbox dataset: ${G}`))}x$.command("status").description("Check sandbox training completion status").option("--refresh","Fetch latest status from server").action(async(D)=>{if(!PD()){console.log(E.red("Not authenticated")),console.log(E.gray("Run 'nemar auth login' first"));return}if(D.refresh){let F=C("Checking status...").start();try{let $=await kv();if(K0("sandboxCompleted",$.sandbox_completed),$.sandbox_dataset_id)K0("sandboxDatasetId",$.sandbox_dataset_id);if(F.stop(),$.sandbox_completed){if(console.log(E.green("Sandbox training: Completed")),console.log(E.gray(` Dataset ID: ${$.sandbox_dataset_id}`)),$.sandbox_completed_at)console.log(E.gray(` Completed: ${$.sandbox_completed_at}`))}else console.log(E.yellow("Sandbox training: Not completed")),console.log(),console.log("Run sandbox training with:"),console.log(E.cyan(" nemar sandbox"))}catch($){if(F.fail("Failed to check status"),$ instanceof g)console.log(E.red(` ${$.message}`))}}else{let F=eD();if(F.sandboxCompleted)console.log(E.green("Sandbox training: Completed")),console.log(E.gray(` Dataset ID: ${F.sandboxDatasetId}`));else console.log(E.yellow("Sandbox training: Not completed")),console.log(),console.log("Run sandbox training with:"),console.log(E.cyan(" nemar sandbox"))}});x$.command("reset").description("Reset sandbox training status for re-training").option(yD,xD).option(hD,bD).action(async(D)=>{if(!PD()){console.log(E.red("Not authenticated")),console.log(E.gray("Run 'nemar auth login' first"));return}if(!eD().sandboxCompleted){console.log(E.yellow("Sandbox training not yet completed")),console.log(E.gray("Nothing to reset"));return}let $=await gD("Reset sandbox training status? You will need to complete training again.",D);if($!=="confirmed"){console.log(E.gray($==="declined"?"Skipped":"Cancelled"));return}let B=C("Resetting sandbox status...").start();try{await Sv(),A2("sandboxCompleted"),A2("sandboxDatasetId"),B.succeed("Sandbox status reset"),console.log(),console.log("Run sandbox training again with:"),console.log(E.cyan(" nemar sandbox"))}catch(J){if(B.fail("Failed to reset"),J instanceof g)console.log(E.red(` ${J.message}`));else console.log(E.red(` ${J instanceof Error?J.message:"Unknown error"}`))}});var Cy={name:"nemar-cli",version:"0.3.11-PR110.80de83a",description:"CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",type:"module",main:"dist/index.js",bin:{nemar:"dist/index.js"},scripts:{dev:"bun run src/index.ts",build:"bun build src/index.ts --outdir dist --target bun --minify && sed '1s|#!/usr/bin/env node|#!/usr/bin/env bun|' dist/index.js > dist/index.js.tmp && mv dist/index.js.tmp dist/index.js",test:"bun test",lint:"biome check src/","lint:fix":"biome check --fix src/",format:"biome format --write src/",typecheck:"tsc --noEmit",prepublishOnly:"bun run build","docs:generate":"bun run scripts/generate-docs.ts","docs:serve":"mkdocs serve","docs:build":"mkdocs build"},keywords:["nemar","bids","neuroimaging","eeg","emg","datalad","cli"],author:"NEMAR Team",license:"MIT",repository:{type:"git",url:"git+https://github.com/nemarOrg/nemar-cli.git"},bugs:{url:"https://github.com/nemarOrg/nemar-cli/issues"},homepage:"https://nemar-cli.pages.dev",engines:{bun:">=1.0.0"},files:["dist","README.md","LICENSE"],dependencies:{chalk:"^5.3.0",commander:"^12.1.0",conf:"^13.0.1",inquirer:"^9.2.15",ora:"^8.0.1",zod:"^3.23.8"},devDependencies:{"@biomejs/biome":"1.9.4","@types/bcryptjs":"^3.0.0","@types/bun":"latest","@types/inquirer":"^9.0.7",bcryptjs:"^3.0.3",typescript:"^5.5.4"}};var Ry=Cy.version;var Z1=new F0;Z1.name("nemar").description(`CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource)
602
602
 
603
603
  NEMAR is a curated repository for neurophysiology data in BIDS format.
604
604
  This CLI provides tools for uploading, downloading, and managing datasets.`).version(Ry,"-v, --version","Output the current version").option("--no-color","Disable colored output").option("--verbose","Enable verbose output").addHelpText("after",`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nemar-cli",
3
- "version": "0.3.11-PR110.4a18316",
3
+ "version": "0.3.11-PR110.80de83a",
4
4
  "description": "CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",