nemar-cli 0.4.0-dev.233 → 0.4.0-dev.234

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
@@ -176,7 +176,7 @@ ${W.cyan("CI Status:")} ${D}
176
176
  `);let B=$.bids_validation.present,J=B?W.green("[x]"):W.red("[ ]");if(console.log(` ${J} BIDS Validation`),B){let Y=$.bids_validation.status==="success"?W.green:$.bids_validation.status==="failure"?W.red:W.yellow;if(console.log(` Status: ${Y($.bids_validation.status)}`),$.bids_validation.url)console.log(` URL: ${W.gray($.bids_validation.url)}`)}else console.log(` ${W.gray("Not deployed. Use 'nemar admin ci add' to deploy.")}`);let Q=$.version_check.present,X=Q?W.green("[x]"):W.red("[ ]");if(console.log(` ${X} Version Check`),!Q)console.log(` ${W.gray("Not deployed. Use 'nemar admin ci add' to deploy.")}`);console.log()}catch($){p0($,F,"Failed to check CI status",{404:"Dataset not found"})}});p2.command("add").description("Deploy CI workflows to a dataset repository").argument("<dataset-id>","Dataset ID (e.g., nm000104)").option(yD,xD).option(lD,dD).action(async(D,F)=>{if(!pD())return;console.log(W.cyan(`
177
177
  Deploy CI workflows to: ${D}
178
178
  `)),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 OD(`Deploy CI workflows to ${D}?`,F);if($!=="confirmed"){console.log(W.gray($==="declined"?"Skipped":"Cancelled"));return}let B=C(`Deploying CI workflows to ${D}...`).start();try{let J=await v$(D);B.succeed("CI workflows deployed"),console.log();for(let Q of J.workflows_deployed)console.log(` ${W.green("[x]")} ${Q}`);console.log()}catch(J){p0(J,B,"Failed to deploy CI workflows",{404:"Dataset not found"})}});j0.addCommand(p2);var I5=new H0("doi").description("DOI management");I5.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(lD,dD).action(async(D,F)=>{if(!pD())return;let $=C("Fetching dataset info...").start(),B;try{B=await d0(D),$.succeed(`Found dataset: ${B.name}`)}catch(G){if(G instanceof m){if($.fail(G.message),G.statusCode===404)console.log(W.gray(" Dataset not found"))}else $.fail("Failed to fetch dataset");return}try{let G=await R5(D);if(G.concept_doi){if(console.log(W.yellow(`
179
- Dataset already has a concept DOI:`)),console.log(` Concept DOI: ${W.cyan(G.concept_doi)}`),G.zenodo_concept_url)console.log(` Zenodo URL: ${G.zenodo_concept_url}`);return}}catch(G){if(process.env.DEBUG)console.error("[debug] DOI info fetch:",G)}if(console.log(),console.log(W.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: ${W.yellow("SANDBOX (test DOI)")}`);console.log();let J=F.provider==="zenodo"?"zenodo":"ezid";if(F.sandbox){if(console.log(W.yellow("\u2501".repeat(60))),console.log(W.yellow.bold(" SANDBOX MODE ENABLED")),console.log(W.yellow("\u2501".repeat(60))),J==="zenodo")console.log(W.yellow(" \u2022 Using Zenodo sandbox (sandbox.zenodo.org)"));else console.log(W.yellow(" \u2022 Using EZID test shoulder (doi:10.5072/FK2)")),console.log(W.yellow(" \u2022 Test DOIs auto-delete after 2 weeks"));console.log(W.yellow(" \u2022 DOI will NOT be indexed by DataCite")),console.log(W.yellow(" \u2022 DOI will NOT resolve in production")),console.log(W.yellow(" \u2022 Use this for testing workflows only")),console.log(W.yellow("\u2501".repeat(60))),console.log()}console.log(W.red("WARNING: DOIs are PERMANENT and cannot be deleted!")),console.log(W.gray("The DOI will be pre-reserved but not published until the first version release.")),console.log(` Provider: ${W.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 OD(Q,F);if(X!=="confirmed"){console.log(W.gray(X==="declined"?"Skipped":"Cancelled"));return}let Y=C(`Creating concept DOI via ${J.toUpperCase()}...`).start();try{let G=await iv(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 q=await x$(D);if(q.warnings&&q.warnings.length>0){H.warn("Branch protection applied with warnings");for(let K of q.warnings)console.log(W.yellow(` Warning: ${K}`))}else H.succeed("Branch protection applied")}catch(q){if(H.warn("Could not apply branch protection"),q instanceof m){if(console.log(W.gray(` ${q.message}`)),q.statusCode===403)console.log(W.gray(" Check admin credentials and permissions"))}else console.log(W.gray(` ${q instanceof Error?q.message:"Unknown error"}`));console.log(W.gray(" Manual setup: Go to GitHub repo Settings > Branches > Add rule"))}if(console.log(),console.log(W.green("DOI Information:")),console.log(` Concept DOI: ${W.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(W.yellow(` Warning: ${G.metadata_warning}`));if(console.log(),console.log(W.yellow("Next steps:")),console.log(" 1. Set up automatic DOI publishing by running:"),console.log(W.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(W.gray("Note: This is a sandbox DOI and will not resolve in production."))}catch(G){if(G instanceof m){if(Y.fail(G.message),G.statusCode===403)console.log(W.gray(" This command requires admin privileges"))}else Y.fail("Failed to create concept DOI"),console.log(W.gray(` ${f0(G)}`))}});I5.command("info").description("Get DOI info for a dataset").argument("<dataset-id>","Dataset ID (e.g., nm000104)").action(async(D)=>{if(!pD())return;let F=C("Fetching DOI info...").start();try{let $=await R5(D);if(F.stop(),console.log(),console.log(W.cyan(`DOI Information for ${D}:`)),console.log(` Dataset Name: ${$.name}`),console.log(),$.concept_doi){if(console.log(W.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"?W.green:W.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(W.yellow("Mode: SANDBOX (test DOI)")),console.log(W.yellow(" This DOI is not indexed by DataCite and will not resolve in production"))}}else console.log(W.yellow("No concept DOI created yet")),console.log(W.gray(" Use 'nemar admin doi create' to create one"));if(console.log(),$.latest_version_doi){if(console.log(W.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(W.yellow("No version DOI published yet")),console.log(W.gray(" Version DOIs are created automatically on PR merge"))}catch($){if($ instanceof m){if(F.fail($.message),$.statusCode===404)console.log(W.gray(" Dataset not found"));else if($.statusCode===403)console.log(W.gray(" This command requires admin privileges"))}else F.fail("Failed to fetch DOI info")}});I5.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(lD,dD).action(async(D,F)=>{if(!pD())return;if(!F.makePublic&&!F.refresh){console.log(W.yellow("No action specified. Use --make-public and/or --refresh."));return}if(F.makePublic){console.log(W.red("WARNING: Making a DOI public is PERMANENT!")),console.log(W.gray(" The DOI will be findable in DataCite and cannot be reverted.")),console.log();let B=await OD(`Make DOI for ${D} PUBLIC and permanent?`,F);if(B!=="confirmed"){console.log(W.gray(B==="declined"?"Skipped":"Cancelled"));return}}let $=C("Updating DOI...").start();try{let B=await b2(D,{status:F.makePublic?"public":void 0,refresh_metadata:F.refresh});$.succeed("DOI updated successfully"),console.log(),console.log(` EZID ID: ${W.cyan(B.ezid_identifier)}`),console.log(` Status: ${B.status==="public"?W.green(B.status):W.yellow(B.status)}`),console.log(` URL: ${B.doi_url}`)}catch(B){if(B instanceof m){if($.fail(B.message),B.statusCode===400)console.log(W.gray(" DOI update is only supported for EZID-managed DOIs"))}else $.fail("Failed to update DOI"),console.log(W.gray(` ${f0(B)}`))}});I5.command("enrich").description("Enrich DOI metadata with ORCIDs, descriptions, funding, and more").argument("<dataset-id>","Dataset ID (e.g., nm000104)").option("--no-llm","Skip LLM-based enrichment from README").option("--sandbox","Use sandbox DOI").option(yD,xD).option(lD,dD).action(async(D,F)=>{if(!pD())return;let $=C("Fetching dataset and existing enrichment...").start(),B;try{B=await d0(D),$.succeed(`Dataset: ${B.name}`)}catch(K){if(K instanceof m)$.fail(K.message);else $.fail("Failed to fetch dataset");return}let J,Q=!1;try{J=await R5(D)}catch(K){if(K instanceof m&&K.statusCode===404);else Q=!0,console.log(W.yellow(` Warning: Could not fetch DOI info: ${f0(K)}`))}if(J?.concept_doi)console.log(` DOI: ${W.cyan(J.concept_doi)}`);let X={version:"1.0"};console.log(),console.log(W.cyan("--- Author ORCIDs ---"));let{updateAuthors:Y}=await RD.prompt([{type:"confirm",name:"updateAuthors",message:"Update author ORCIDs?",default:!1}]);if(Y){let K={},V=!0;while(V){let{authorName:A}=await RD.prompt([{type:"input",name:"authorName",message:'Author name (as in BIDS, e.g., "Shirazi, Yahya"):'}]);if(!A)break;let{orcid:Z}=await RD.prompt([{type:"input",name:"orcid",message:`ORCID for "${A}" (Enter to skip):`,validate:(N)=>{if(!N)return!0;return S$.test(N)||"Invalid ORCID format (XXXX-XXXX-XXXX-XXXX)"}}]),U={};if(Z)U.orcid=Z;let{affiliation:L}=await RD.prompt([{type:"input",name:"affiliation",message:`Affiliation for "${A}" (optional):`}]);if(L)U.affiliation=L;if(U.orcid||U.affiliation)K[A]=U;let{more:M}=await RD.prompt([{type:"confirm",name:"more",message:"Add another author?",default:!0}]);V=M}if(Object.keys(K).length>0)X.authors=K}if(F.llm!==!1){console.log(),console.log(W.cyan("--- Generating enrichment from README ---"));let K=process.env.OPENROUTER_API_KEY;if(!K)console.log(W.yellow(" OPENROUTER_API_KEY not set; skipping LLM enrichment")),console.log(W.gray(" Set it in your environment to enable LLM-based enrichment"));else{let V=C("Analyzing README and dataset metadata...").start();try{let{enrichFromReadme:A}=await Promise.resolve().then(() => (Sy(),Py)),Z=B.github_repo;if(!Z)V.warn("No GitHub repository configured for this dataset");else{let U=await ky(Z,"README");if(!U)V.warn("Could not fetch README from repository");else{let L=await ky(Z,"dataset_description.json"),M={};if(L)try{M=JSON.parse(L)}catch{console.log(W.yellow(" Warning: Could not parse dataset_description.json; LLM will use README only"))}let N=await A(U,M,K);if(V.succeed("LLM enrichment complete"),N.description)console.log(` Description: ${N.description.slice(0,100)}...`),X.description=N.description;if(N.methodsDescription)X.methodsDescription=N.methodsDescription;if(N.keywords&&N.keywords.length>0)console.log(` Keywords: ${N.keywords.join(", ")}`),X.keywords=N.keywords;if(N.fundingReferences&&N.fundingReferences.length>0)console.log(` Funding: ${N.fundingReferences.map((O)=>`${O.funderName} ${O.awardNumber||""}`).join(", ")}`),X.fundingReferences=N.fundingReferences;if(N.relatedDois&&N.relatedDois.length>0)console.log(` Related DOIs: ${N.relatedDois.map((O)=>`${O.doi} (${O.relationType})`).join(", ")}`),X.relatedDois=N.relatedDois}}}catch(A){V.fail("LLM enrichment failed"),console.log(W.gray(` ${f0(A)}`))}}}console.log(),console.log(W.cyan("--- Dataset stats ---"));let G=C("Computing dataset sizes and formats...").start();try{let K=await Yy(D),V=v3(K.total_size);X.sizes=[`${V} (${K.file_count} files)`],X.formats=K.extensions,G.succeed(`Sizes: ${V} (${K.file_count} files), Formats: ${K.extensions.join(", ")}`)}catch(K){G.warn("Could not compute dataset stats"),console.log(W.gray(` ${f0(K)}`))}console.log(),console.log(W.cyan("--- Review ---")),console.log(JSON.stringify(X,null,2)),console.log();let H=await OD("Commit to repo and refresh DOI?",F,!0);if(H!=="confirmed"){console.log(W.gray(H==="declined"?"Skipped":"Cancelled"));return}let q=C("Saving enrichment...").start();try{let K=await Xy(D,X);if(q.succeed(K.message),K.bidsignore_updated)console.log(W.gray(" .bidsignore updated to include nemar_metadata.json"));if(!J&&Q)try{J=await R5(D)}catch(V){if(process.env.DEBUG)console.error("[debug] DOI info re-fetch:",V)}if(J?.ezid_identifier){let V=C("Refreshing DOI metadata...").start();try{await b2(D,{refresh_metadata:!0}),V.succeed("DOI metadata refreshed")}catch(A){V.warn("Could not refresh DOI metadata"),console.log(W.gray(` ${f0(A)}`))}}else if(Q)console.log(W.yellow(" DOI refresh skipped: could not verify DOI exists. Run 'nemar admin doi update --refresh' manually."))}catch(K){if(K instanceof m)q.fail(K.message);else q.fail("Failed to save enrichment"),console.log(W.gray(` ${f0(K)}`))}});j0.addCommand(I5);var c$=new H0("publish").description("Publication workflow management");c$.command("list").description("List publication requests").option("-s, --status <status>","Filter by status (requested, approving, published, denied)").addHelpText("after",`
179
+ Dataset already has a concept DOI:`)),console.log(` Concept DOI: ${W.cyan(G.concept_doi)}`),G.zenodo_concept_url)console.log(` Zenodo URL: ${G.zenodo_concept_url}`);return}}catch(G){if(process.env.DEBUG)console.error("[debug] DOI info fetch:",G)}if(console.log(),console.log(W.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: ${W.yellow("SANDBOX (test DOI)")}`);console.log();let J=F.provider==="zenodo"?"zenodo":"ezid";if(F.sandbox){if(console.log(W.yellow("\u2501".repeat(60))),console.log(W.yellow.bold(" SANDBOX MODE ENABLED")),console.log(W.yellow("\u2501".repeat(60))),J==="zenodo")console.log(W.yellow(" \u2022 Using Zenodo sandbox (sandbox.zenodo.org)"));else console.log(W.yellow(" \u2022 Using EZID test shoulder (doi:10.5072/FK2)")),console.log(W.yellow(" \u2022 Test DOIs auto-delete after 2 weeks"));console.log(W.yellow(" \u2022 DOI will NOT be indexed by DataCite")),console.log(W.yellow(" \u2022 DOI will NOT resolve in production")),console.log(W.yellow(" \u2022 Use this for testing workflows only")),console.log(W.yellow("\u2501".repeat(60))),console.log()}console.log(W.red("WARNING: DOIs are PERMANENT and cannot be deleted!")),console.log(W.gray("The DOI will be pre-reserved but not published until the first version release.")),console.log(` Provider: ${W.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 OD(Q,F);if(X!=="confirmed"){console.log(W.gray(X==="declined"?"Skipped":"Cancelled"));return}let Y=C(`Creating concept DOI via ${J.toUpperCase()}...`).start();try{let G=await iv(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 q=await x$(D);if(q.warnings&&q.warnings.length>0){H.warn("Branch protection applied with warnings");for(let K of q.warnings)console.log(W.yellow(` Warning: ${K}`))}else H.succeed("Branch protection applied")}catch(q){if(H.warn("Could not apply branch protection"),q instanceof m){if(console.log(W.gray(` ${q.message}`)),q.statusCode===403)console.log(W.gray(" Check admin credentials and permissions"))}else console.log(W.gray(` ${q instanceof Error?q.message:"Unknown error"}`));console.log(W.gray(" Manual setup: Go to GitHub repo Settings > Branches > Add rule"))}if(console.log(),console.log(W.green("DOI Information:")),console.log(` Concept DOI: ${W.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(W.yellow(` Warning: ${G.metadata_warning}`));if(console.log(),console.log(W.yellow("Next steps:")),console.log(" 1. Update dataset_description.json with DatasetDOI field"),console.log(" 2. Create a PR and merge it to trigger version DOI publication"),console.log(),F.sandbox)console.log(W.gray("Note: This is a sandbox DOI and will not resolve in production."))}catch(G){if(G instanceof m){if(Y.fail(G.message),G.statusCode===403)console.log(W.gray(" This command requires admin privileges"))}else Y.fail("Failed to create concept DOI"),console.log(W.gray(` ${f0(G)}`))}});I5.command("info").description("Get DOI info for a dataset").argument("<dataset-id>","Dataset ID (e.g., nm000104)").action(async(D)=>{if(!pD())return;let F=C("Fetching DOI info...").start();try{let $=await R5(D);if(F.stop(),console.log(),console.log(W.cyan(`DOI Information for ${D}:`)),console.log(` Dataset Name: ${$.name}`),console.log(),$.concept_doi){if(console.log(W.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"?W.green:W.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(W.yellow("Mode: SANDBOX (test DOI)")),console.log(W.yellow(" This DOI is not indexed by DataCite and will not resolve in production"))}}else console.log(W.yellow("No concept DOI created yet")),console.log(W.gray(" Use 'nemar admin doi create' to create one"));if(console.log(),$.latest_version_doi){if(console.log(W.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(W.yellow("No version DOI published yet")),console.log(W.gray(" Version DOIs are created automatically on PR merge"))}catch($){if($ instanceof m){if(F.fail($.message),$.statusCode===404)console.log(W.gray(" Dataset not found"));else if($.statusCode===403)console.log(W.gray(" This command requires admin privileges"))}else F.fail("Failed to fetch DOI info")}});I5.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(lD,dD).action(async(D,F)=>{if(!pD())return;if(!F.makePublic&&!F.refresh){console.log(W.yellow("No action specified. Use --make-public and/or --refresh."));return}if(F.makePublic){console.log(W.red("WARNING: Making a DOI public is PERMANENT!")),console.log(W.gray(" The DOI will be findable in DataCite and cannot be reverted.")),console.log();let B=await OD(`Make DOI for ${D} PUBLIC and permanent?`,F);if(B!=="confirmed"){console.log(W.gray(B==="declined"?"Skipped":"Cancelled"));return}}let $=C("Updating DOI...").start();try{let B=await b2(D,{status:F.makePublic?"public":void 0,refresh_metadata:F.refresh});$.succeed("DOI updated successfully"),console.log(),console.log(` EZID ID: ${W.cyan(B.ezid_identifier)}`),console.log(` Status: ${B.status==="public"?W.green(B.status):W.yellow(B.status)}`),console.log(` URL: ${B.doi_url}`)}catch(B){if(B instanceof m){if($.fail(B.message),B.statusCode===400)console.log(W.gray(" DOI update is only supported for EZID-managed DOIs"))}else $.fail("Failed to update DOI"),console.log(W.gray(` ${f0(B)}`))}});I5.command("enrich").description("Enrich DOI metadata with ORCIDs, descriptions, funding, and more").argument("<dataset-id>","Dataset ID (e.g., nm000104)").option("--no-llm","Skip LLM-based enrichment from README").option("--sandbox","Use sandbox DOI").option(yD,xD).option(lD,dD).action(async(D,F)=>{if(!pD())return;let $=C("Fetching dataset and existing enrichment...").start(),B;try{B=await d0(D),$.succeed(`Dataset: ${B.name}`)}catch(K){if(K instanceof m)$.fail(K.message);else $.fail("Failed to fetch dataset");return}let J,Q=!1;try{J=await R5(D)}catch(K){if(K instanceof m&&K.statusCode===404);else Q=!0,console.log(W.yellow(` Warning: Could not fetch DOI info: ${f0(K)}`))}if(J?.concept_doi)console.log(` DOI: ${W.cyan(J.concept_doi)}`);let X={version:"1.0"};console.log(),console.log(W.cyan("--- Author ORCIDs ---"));let{updateAuthors:Y}=await RD.prompt([{type:"confirm",name:"updateAuthors",message:"Update author ORCIDs?",default:!1}]);if(Y){let K={},V=!0;while(V){let{authorName:A}=await RD.prompt([{type:"input",name:"authorName",message:'Author name (as in BIDS, e.g., "Shirazi, Yahya"):'}]);if(!A)break;let{orcid:Z}=await RD.prompt([{type:"input",name:"orcid",message:`ORCID for "${A}" (Enter to skip):`,validate:(N)=>{if(!N)return!0;return S$.test(N)||"Invalid ORCID format (XXXX-XXXX-XXXX-XXXX)"}}]),U={};if(Z)U.orcid=Z;let{affiliation:L}=await RD.prompt([{type:"input",name:"affiliation",message:`Affiliation for "${A}" (optional):`}]);if(L)U.affiliation=L;if(U.orcid||U.affiliation)K[A]=U;let{more:M}=await RD.prompt([{type:"confirm",name:"more",message:"Add another author?",default:!0}]);V=M}if(Object.keys(K).length>0)X.authors=K}if(F.llm!==!1){console.log(),console.log(W.cyan("--- Generating enrichment from README ---"));let K=process.env.OPENROUTER_API_KEY;if(!K)console.log(W.yellow(" OPENROUTER_API_KEY not set; skipping LLM enrichment")),console.log(W.gray(" Set it in your environment to enable LLM-based enrichment"));else{let V=C("Analyzing README and dataset metadata...").start();try{let{enrichFromReadme:A}=await Promise.resolve().then(() => (Sy(),Py)),Z=B.github_repo;if(!Z)V.warn("No GitHub repository configured for this dataset");else{let U=await ky(Z,"README");if(!U)V.warn("Could not fetch README from repository");else{let L=await ky(Z,"dataset_description.json"),M={};if(L)try{M=JSON.parse(L)}catch{console.log(W.yellow(" Warning: Could not parse dataset_description.json; LLM will use README only"))}let N=await A(U,M,K);if(V.succeed("LLM enrichment complete"),N.description)console.log(` Description: ${N.description.slice(0,100)}...`),X.description=N.description;if(N.methodsDescription)X.methodsDescription=N.methodsDescription;if(N.keywords&&N.keywords.length>0)console.log(` Keywords: ${N.keywords.join(", ")}`),X.keywords=N.keywords;if(N.fundingReferences&&N.fundingReferences.length>0)console.log(` Funding: ${N.fundingReferences.map((O)=>`${O.funderName} ${O.awardNumber||""}`).join(", ")}`),X.fundingReferences=N.fundingReferences;if(N.relatedDois&&N.relatedDois.length>0)console.log(` Related DOIs: ${N.relatedDois.map((O)=>`${O.doi} (${O.relationType})`).join(", ")}`),X.relatedDois=N.relatedDois}}}catch(A){V.fail("LLM enrichment failed"),console.log(W.gray(` ${f0(A)}`))}}}console.log(),console.log(W.cyan("--- Dataset stats ---"));let G=C("Computing dataset sizes and formats...").start();try{let K=await Yy(D),V=v3(K.total_size);X.sizes=[`${V} (${K.file_count} files)`],X.formats=K.extensions,G.succeed(`Sizes: ${V} (${K.file_count} files), Formats: ${K.extensions.join(", ")}`)}catch(K){G.warn("Could not compute dataset stats"),console.log(W.gray(` ${f0(K)}`))}console.log(),console.log(W.cyan("--- Review ---")),console.log(JSON.stringify(X,null,2)),console.log();let H=await OD("Commit to repo and refresh DOI?",F,!0);if(H!=="confirmed"){console.log(W.gray(H==="declined"?"Skipped":"Cancelled"));return}let q=C("Saving enrichment...").start();try{let K=await Xy(D,X);if(q.succeed(K.message),K.bidsignore_updated)console.log(W.gray(" .bidsignore updated to include nemar_metadata.json"));if(!J&&Q)try{J=await R5(D)}catch(V){if(process.env.DEBUG)console.error("[debug] DOI info re-fetch:",V)}if(J?.ezid_identifier){let V=C("Refreshing DOI metadata...").start();try{await b2(D,{refresh_metadata:!0}),V.succeed("DOI metadata refreshed")}catch(A){V.warn("Could not refresh DOI metadata"),console.log(W.gray(` ${f0(A)}`))}}else if(Q)console.log(W.yellow(" DOI refresh skipped: could not verify DOI exists. Run 'nemar admin doi update --refresh' manually."))}catch(K){if(K instanceof m)q.fail(K.message);else q.fail("Failed to save enrichment"),console.log(W.gray(` ${f0(K)}`))}});j0.addCommand(I5);var c$=new H0("publish").description("Publication workflow management");c$.command("list").description("List publication requests").option("-s, --status <status>","Filter by status (requested, approving, published, denied)").addHelpText("after",`
180
180
  Description:
181
181
  List all publication requests from users, with optional filtering by status.
182
182
  Shows dataset ID, status, requesting user, and current progress.
@@ -690,7 +690,7 @@ Examples:
690
690
  $ nemar sandbox # Run sandbox training
691
691
  $ nemar sandbox status # Check if training is completed
692
692
  $ nemar sandbox reset # Reset for re-training
693
- `).action(GHD);async function GHD(){if(console.log(),console.log(W.bold("NEMAR Sandbox Training")),console.log(W.gray("Verify your setup and learn the upload workflow")),console.log(),!vD()){console.log(W.red("Not authenticated")),console.log(W.gray("Run 'nemar auth login' first"));return}let D=Y0();if(D.sandboxCompleted){console.log(W.green("Sandbox training already completed!")),console.log(W.gray(`Dataset ID: ${D.sandboxDatasetId}`)),console.log(),console.log("You can upload real datasets with:"),console.log(W.cyan(" nemar dataset upload ./your-dataset")),console.log(),console.log(W.gray("To re-run training, use: nemar sandbox reset"));return}console.log(W.bold("Step 1/6: Checking prerequisites..."));let F=C("Checking git-annex and SSH...").start(),$=await _$();if(!$.allPassed){F.fail("Prerequisites check failed"),console.log(),console.log(W.red("Missing requirements:"));for(let I of $.errors)console.log(W.yellow(` - ${I}`));if(!$.githubSSH.accessible)console.log(W.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 h$(D.githubUsername);if(!J.authenticated){B.fail("GitHub CLI not authenticated"),console.log(W.red(` ${J.error}`)),console.log(),console.log("GitHub CLI is required for sandbox training. Install and authenticate:"),console.log(W.cyan(" brew install gh # or visit https://cli.github.com/")),console.log(W.cyan(" gh auth login"));return}if(D.githubUsername&&!J.matches)B.warn("GitHub CLI user mismatch"),console.log(W.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(W.cyan(` gh auth login # Login as ${D.githubUsername}`)),console.log(),console.log(W.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(W.bold("Step 2/6: Generating test dataset..."));let Q=C("Creating minimal BIDS structure...").start(),X;try{let I=sy();X=I.root;let w=ry(I);Q.succeed(`Test dataset created (${v3(w)})`),console.log(W.gray(` Location: ${X}`))}catch(I){Q.fail("Failed to generate test dataset"),console.log(W.red(` ${I instanceof Error?I.message:"Unknown error"}`));return}console.log(),console.log(W.bold("Step 3/6: Registering sandbox dataset..."));let Y=C("Creating dataset on NEMAR...").start(),G,H,q,K,V,A;try{let I=await y$({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=I.dataset.dataset_id,H=I.dataset.ssh_url,q=I.dataset.github_url,K=I.s3_config,V=I.dataset.s3_prefix,A=I.upload_urls||{},Y.succeed(`Sandbox dataset created: ${W.cyan(G)}`),console.log(W.gray(` GitHub: ${q}`)),await new Promise((w)=>setTimeout(w,1e4))}catch(I){if(Y.fail("Failed to create sandbox dataset"),I instanceof m)console.log(W.red(` ${I.message}`));else console.log(W.red(` ${I instanceof Error?I.message:"Unknown error"}`));k1(X);return}let Z=C("Accepting GitHub repository invitation...").start(),U=q?.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(W.red(` Received: ${q||"(empty)"}`)),console.log(W.red(" Expected format: https://github.com/owner/repo")),console.log(),console.log("This may indicate a backend issue. Please contact support."),k1(X);return}let M=await b$(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(W.yellow(` ${M.error}`)),console.log(),console.log("You may need to accept the invitation manually:"),console.log(W.cyan(` https://github.com/${L}/invitations`)),console.log();console.log(),console.log(W.bold("Step 4/6: Initializing repository..."));let N=C("Setting up git-annex...").start(),O=D.username&&D.email?{name:D.username,email:D.email}:void 0;try{await f$(X,{author:O}),await g$(X),await u$(X,H),N.succeed("Repository initialized")}catch(I){N.fail("Failed to initialize repository"),console.log(W.red(` ${I instanceof Error?I.message:"Unknown error"}`)),k1(X);return}if(console.log(),console.log(W.bold("Step 5/6: Uploading to S3...")),Object.keys(A).length===0)console.log(W.yellow(" No data files to upload (metadata only)"));else{let I=C("Uploading test data...").start();try{let c=0,GD=Object.keys(A).length,S=await m$(X,A,{jobs:4,onProgress:(JD)=>{if(JD.status==="completed"||JD.status==="failed")c++,I.text=`Uploading... ${c}/${GD} files`}});if(S.failed.length>0){I.fail(`Upload failed for ${S.failed.length} file(s)`);for(let JD of S.failed)console.log(W.red(` Failed: ${JD}`));if(S.error)console.log(W.red(` Error: ${S.error}`));console.log(),console.log(W.yellow("Sandbox training aborted due to upload failures.")),console.log(W.gray("Please check your network connection and try again.")),k1(X);return}I.succeed(`Uploaded ${S.uploaded} file(s)`)}catch(c){I.fail("Upload failed"),console.log(W.red(` ${c instanceof Error?c.message:"Unknown error"}`)),k1(X);return}let w=C("Registering file URLs...").start();try{let c={};for(let S of Object.keys(A))c[S]=`${K.public_url}/${V}/objects/${S}`;let GD=await l$(X,c);if(!GD.success){w.fail(`URL registration failed for ${GD.failed.length} file(s)`);for(let S of GD.failed)console.log(W.red(` Failed: ${S}`));console.log(),console.log(W.yellow("Sandbox training aborted due to URL registration failures.")),console.log(W.gray("This may indicate a git-annex configuration issue.")),k1(X);return}w.succeed(`Registered ${GD.registered} file URLs`)}catch(c){w.fail("Failed to register URLs"),console.log(W.red(` ${c instanceof Error?c.message:"Unknown error"}`)),k1(X);return}}console.log(),console.log(W.bold("Step 6/6: Pushing to GitHub..."));let g=C("Saving and pushing...").start();try{await j5(X,"Initial sandbox training upload",O),await T5(X),g.succeed("Pushed to GitHub")}catch(I){g.fail("Failed to push to GitHub"),console.log(W.red(` ${I instanceof Error?I.message:"Unknown error"}`)),k1(X);return}let j=C("Finalizing...").start();try{await x$(G),await rv(G),R0("sandboxCompleted",!0),R0("sandboxDatasetId",G),j.succeed("Sandbox training complete!")}catch(I){j.fail("Failed to finalize"),console.log(W.red(` ${I instanceof Error?I.message:"Unknown error"}`)),k1(X);return}k1(X),console.log(),console.log(W.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(W.cyan(" nemar dataset upload ./your-dataset")),console.log(),console.log(W.gray(`Sandbox dataset: ${G}`))}FB.command("status").description("Check sandbox training completion status").option("--refresh","Fetch latest status from server").action(async(D)=>{if(!vD()){console.log(W.red("Not authenticated")),console.log(W.gray("Run 'nemar auth login' first"));return}if(D.refresh){let F=C("Checking status...").start();try{let $=await ev();if(R0("sandboxCompleted",$.sandbox_completed),$.sandbox_dataset_id)R0("sandboxDatasetId",$.sandbox_dataset_id);if(F.stop(),$.sandbox_completed){if(console.log(W.green("Sandbox training: Completed")),console.log(W.gray(` Dataset ID: ${$.sandbox_dataset_id}`)),$.sandbox_completed_at)console.log(W.gray(` Completed: ${$.sandbox_completed_at}`))}else console.log(W.yellow("Sandbox training: Not completed")),console.log(),console.log("Run sandbox training with:"),console.log(W.cyan(" nemar sandbox"))}catch($){if(F.fail("Failed to check status"),$ instanceof m)console.log(W.red(` ${$.message}`))}}else{let F=Y0();if(F.sandboxCompleted)console.log(W.green("Sandbox training: Completed")),console.log(W.gray(` Dataset ID: ${F.sandboxDatasetId}`));else console.log(W.yellow("Sandbox training: Not completed")),console.log(),console.log("Run sandbox training with:"),console.log(W.cyan(" nemar sandbox"))}});FB.command("reset").description("Reset sandbox training status for re-training").option(yD,xD).option(lD,dD).action(async(D)=>{if(!vD()){console.log(W.red("Not authenticated")),console.log(W.gray("Run 'nemar auth login' first"));return}if(!Y0().sandboxCompleted){console.log(W.yellow("Sandbox training not yet completed")),console.log(W.gray("Nothing to reset"));return}let $=await OD("Reset sandbox training status? You will need to complete training again.",D);if($!=="confirmed"){console.log(W.gray($==="declined"?"Skipped":"Cancelled"));return}let B=C("Resetting sandbox status...").start();try{await tv(),f2("sandboxCompleted"),f2("sandboxDatasetId"),B.succeed("Sandbox status reset"),console.log(),console.log("Run sandbox training again with:"),console.log(W.cyan(" nemar sandbox"))}catch(J){if(B.fail("Failed to reset"),J instanceof m)console.log(W.red(` ${J.message}`));else console.log(W.red(` ${J instanceof Error?J.message:"Unknown error"}`))}});var ty={name:"nemar-cli",version:"0.4.0-dev.233",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 ey=ty.version;var v1=new H0;v1.name("nemar").description(`CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource)
693
+ `).action(GHD);async function GHD(){if(console.log(),console.log(W.bold("NEMAR Sandbox Training")),console.log(W.gray("Verify your setup and learn the upload workflow")),console.log(),!vD()){console.log(W.red("Not authenticated")),console.log(W.gray("Run 'nemar auth login' first"));return}let D=Y0();if(D.sandboxCompleted){console.log(W.green("Sandbox training already completed!")),console.log(W.gray(`Dataset ID: ${D.sandboxDatasetId}`)),console.log(),console.log("You can upload real datasets with:"),console.log(W.cyan(" nemar dataset upload ./your-dataset")),console.log(),console.log(W.gray("To re-run training, use: nemar sandbox reset"));return}console.log(W.bold("Step 1/6: Checking prerequisites..."));let F=C("Checking git-annex and SSH...").start(),$=await _$();if(!$.allPassed){F.fail("Prerequisites check failed"),console.log(),console.log(W.red("Missing requirements:"));for(let I of $.errors)console.log(W.yellow(` - ${I}`));if(!$.githubSSH.accessible)console.log(W.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 h$(D.githubUsername);if(!J.authenticated){B.fail("GitHub CLI not authenticated"),console.log(W.red(` ${J.error}`)),console.log(),console.log("GitHub CLI is required for sandbox training. Install and authenticate:"),console.log(W.cyan(" brew install gh # or visit https://cli.github.com/")),console.log(W.cyan(" gh auth login"));return}if(D.githubUsername&&!J.matches)B.warn("GitHub CLI user mismatch"),console.log(W.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(W.cyan(` gh auth login # Login as ${D.githubUsername}`)),console.log(),console.log(W.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(W.bold("Step 2/6: Generating test dataset..."));let Q=C("Creating minimal BIDS structure...").start(),X;try{let I=sy();X=I.root;let w=ry(I);Q.succeed(`Test dataset created (${v3(w)})`),console.log(W.gray(` Location: ${X}`))}catch(I){Q.fail("Failed to generate test dataset"),console.log(W.red(` ${I instanceof Error?I.message:"Unknown error"}`));return}console.log(),console.log(W.bold("Step 3/6: Registering sandbox dataset..."));let Y=C("Creating dataset on NEMAR...").start(),G,H,q,K,V,A;try{let I=await y$({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=I.dataset.dataset_id,H=I.dataset.ssh_url,q=I.dataset.github_url,K=I.s3_config,V=I.dataset.s3_prefix,A=I.upload_urls||{},Y.succeed(`Sandbox dataset created: ${W.cyan(G)}`),console.log(W.gray(` GitHub: ${q}`)),await new Promise((w)=>setTimeout(w,1e4))}catch(I){if(Y.fail("Failed to create sandbox dataset"),I instanceof m)console.log(W.red(` ${I.message}`));else console.log(W.red(` ${I instanceof Error?I.message:"Unknown error"}`));k1(X);return}let Z=C("Accepting GitHub repository invitation...").start(),U=q?.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(W.red(` Received: ${q||"(empty)"}`)),console.log(W.red(" Expected format: https://github.com/owner/repo")),console.log(),console.log("This may indicate a backend issue. Please contact support."),k1(X);return}let M=await b$(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(W.yellow(` ${M.error}`)),console.log(),console.log("You may need to accept the invitation manually:"),console.log(W.cyan(` https://github.com/${L}/invitations`)),console.log();console.log(),console.log(W.bold("Step 4/6: Initializing repository..."));let N=C("Setting up git-annex...").start(),O=D.username&&D.email?{name:D.username,email:D.email}:void 0;try{await f$(X,{author:O}),await g$(X),await u$(X,H),N.succeed("Repository initialized")}catch(I){N.fail("Failed to initialize repository"),console.log(W.red(` ${I instanceof Error?I.message:"Unknown error"}`)),k1(X);return}if(console.log(),console.log(W.bold("Step 5/6: Uploading to S3...")),Object.keys(A).length===0)console.log(W.yellow(" No data files to upload (metadata only)"));else{let I=C("Uploading test data...").start();try{let c=0,GD=Object.keys(A).length,S=await m$(X,A,{jobs:4,onProgress:(JD)=>{if(JD.status==="completed"||JD.status==="failed")c++,I.text=`Uploading... ${c}/${GD} files`}});if(S.failed.length>0){I.fail(`Upload failed for ${S.failed.length} file(s)`);for(let JD of S.failed)console.log(W.red(` Failed: ${JD}`));if(S.error)console.log(W.red(` Error: ${S.error}`));console.log(),console.log(W.yellow("Sandbox training aborted due to upload failures.")),console.log(W.gray("Please check your network connection and try again.")),k1(X);return}I.succeed(`Uploaded ${S.uploaded} file(s)`)}catch(c){I.fail("Upload failed"),console.log(W.red(` ${c instanceof Error?c.message:"Unknown error"}`)),k1(X);return}let w=C("Registering file URLs...").start();try{let c={};for(let S of Object.keys(A))c[S]=`${K.public_url}/${V}/objects/${S}`;let GD=await l$(X,c);if(!GD.success){w.fail(`URL registration failed for ${GD.failed.length} file(s)`);for(let S of GD.failed)console.log(W.red(` Failed: ${S}`));console.log(),console.log(W.yellow("Sandbox training aborted due to URL registration failures.")),console.log(W.gray("This may indicate a git-annex configuration issue.")),k1(X);return}w.succeed(`Registered ${GD.registered} file URLs`)}catch(c){w.fail("Failed to register URLs"),console.log(W.red(` ${c instanceof Error?c.message:"Unknown error"}`)),k1(X);return}}console.log(),console.log(W.bold("Step 6/6: Pushing to GitHub..."));let g=C("Saving and pushing...").start();try{await j5(X,"Initial sandbox training upload",O),await T5(X),g.succeed("Pushed to GitHub")}catch(I){g.fail("Failed to push to GitHub"),console.log(W.red(` ${I instanceof Error?I.message:"Unknown error"}`)),k1(X);return}let j=C("Finalizing...").start();try{await x$(G),await rv(G),R0("sandboxCompleted",!0),R0("sandboxDatasetId",G),j.succeed("Sandbox training complete!")}catch(I){j.fail("Failed to finalize"),console.log(W.red(` ${I instanceof Error?I.message:"Unknown error"}`)),k1(X);return}k1(X),console.log(),console.log(W.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(W.cyan(" nemar dataset upload ./your-dataset")),console.log(),console.log(W.gray(`Sandbox dataset: ${G}`))}FB.command("status").description("Check sandbox training completion status").option("--refresh","Fetch latest status from server").action(async(D)=>{if(!vD()){console.log(W.red("Not authenticated")),console.log(W.gray("Run 'nemar auth login' first"));return}if(D.refresh){let F=C("Checking status...").start();try{let $=await ev();if(R0("sandboxCompleted",$.sandbox_completed),$.sandbox_dataset_id)R0("sandboxDatasetId",$.sandbox_dataset_id);if(F.stop(),$.sandbox_completed){if(console.log(W.green("Sandbox training: Completed")),console.log(W.gray(` Dataset ID: ${$.sandbox_dataset_id}`)),$.sandbox_completed_at)console.log(W.gray(` Completed: ${$.sandbox_completed_at}`))}else console.log(W.yellow("Sandbox training: Not completed")),console.log(),console.log("Run sandbox training with:"),console.log(W.cyan(" nemar sandbox"))}catch($){if(F.fail("Failed to check status"),$ instanceof m)console.log(W.red(` ${$.message}`))}}else{let F=Y0();if(F.sandboxCompleted)console.log(W.green("Sandbox training: Completed")),console.log(W.gray(` Dataset ID: ${F.sandboxDatasetId}`));else console.log(W.yellow("Sandbox training: Not completed")),console.log(),console.log("Run sandbox training with:"),console.log(W.cyan(" nemar sandbox"))}});FB.command("reset").description("Reset sandbox training status for re-training").option(yD,xD).option(lD,dD).action(async(D)=>{if(!vD()){console.log(W.red("Not authenticated")),console.log(W.gray("Run 'nemar auth login' first"));return}if(!Y0().sandboxCompleted){console.log(W.yellow("Sandbox training not yet completed")),console.log(W.gray("Nothing to reset"));return}let $=await OD("Reset sandbox training status? You will need to complete training again.",D);if($!=="confirmed"){console.log(W.gray($==="declined"?"Skipped":"Cancelled"));return}let B=C("Resetting sandbox status...").start();try{await tv(),f2("sandboxCompleted"),f2("sandboxDatasetId"),B.succeed("Sandbox status reset"),console.log(),console.log("Run sandbox training again with:"),console.log(W.cyan(" nemar sandbox"))}catch(J){if(B.fail("Failed to reset"),J instanceof m)console.log(W.red(` ${J.message}`));else console.log(W.red(` ${J instanceof Error?J.message:"Unknown error"}`))}});var ty={name:"nemar-cli",version:"0.4.0-dev.234",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 ey=ty.version;var v1=new H0;v1.name("nemar").description(`CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource)
694
694
 
695
695
  NEMAR is a curated repository for neurophysiology data in BIDS format.
696
696
  This CLI provides tools for uploading, downloading, and managing datasets.`).version(ey,"-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.4.0-dev.233",
3
+ "version": "0.4.0-dev.234",
4
4
  "description": "CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",