nemar-cli 0.8.2-dev.650 → 0.8.2-dev.651

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 +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -95,7 +95,7 @@ ${W.dim(`eta: ${D.eta}`)}`:"";process.stderr.write(`${F}
95
95
  ${$} ${D.message}
96
96
  ${J}${Q}
97
97
  ${F}
98
- `)}var $f=!1;var KW=P(()=>{kD()});var Qf;var Jf=P(()=>{Qf={name:"nemar-cli",version:"0.8.2-dev.650",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",prepare:"husky",deploy:"wrangler deploy",preview:"wrangler dev"},keywords:["nemar","bids","neuroimaging","eeg","emg","datalad","cli"],author:"NEMAR Team",license:"CC-BY-NC-ND-4.0",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","fuse.js":"^7.1.0",inquirer:"^9.2.15",ora:"^8.0.1",zod:"^3.23.8"},"lint-staged":{"src/**/*.{ts,tsx}":["biome check --fix"],"backend/src/**/*.{ts,tsx}":["biome check --fix"]},devDependencies:{"@biomejs/biome":"1.9.4","@types/bcryptjs":"^3.0.0","@types/bun":"latest","@types/inquirer":"^9.0.7",bcryptjs:"^3.0.3",husky:"^9.1.7","lint-staged":"^16.3.2",typescript:"^5.5.4",wrangler:"^4.70.0"}}});var v4;var cJ=P(()=>{Jf();v4=Qf.version});function S0(D){if(D instanceof Error)return D.message;return String(D)}function Yf(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(EW)return zW;return QD().apiUrl||zW}async function p(D,F={},$=!1){let J=`${Yf()}${D}`,Q={"Content-Type":"application/json","X-CLI-Version":v4,...F.headers};if($){let X=QD();if(!X.apiKey&&$===!0)throw new c(401,"Not authenticated. Run 'nemar auth login' first.");if(X.apiKey)Q.Authorization=`Bearer ${X.apiKey}`}let Y;try{Y=await fetch(J,{...F,headers:Q})}catch(X){throw new c(0,`Network error: Could not connect to ${Yf()}`,{originalError:X instanceof Error?X.message:String(X)})}let B;try{B=await Y.json()}catch{throw new c(Y.status,`Invalid response from server (status ${Y.status})`)}if(!Y.ok){if(Y.status===503&&(B.mode==="read-only"||B.mode==="full")){let X=typeof B.message==="string"?B.message:"NEMAR is in maintenance mode. Please retry shortly.",G=typeof B.eta==="string"?B.eta:null,H=new iJ(B.mode,X,G,B.details);throw dJ(H),H}throw new c(Y.status,B.error||B.message||"Request failed",B.details)}return B}async function Bf(D){return p(`/auth/check-username?username=${encodeURIComponent(D)}`)}async function Xf(D){return p(`/auth/check-github?username=${encodeURIComponent(D)}`)}async function Gf(D){return p("/auth/signup",{method:"POST",body:JSON.stringify(D)})}async function Wf(D){return p("/auth/login",{method:"POST",body:JSON.stringify({api_key:D})})}async function Hf(D){return p("/auth/resend-verification",{method:"POST",body:JSON.stringify({email:D})})}async function qf(D,F){return p("/auth/retrieve-key",{method:"POST",body:JSON.stringify({email:D,password:F})})}async function Kf(D){return p("/auth/request-key-regeneration",{method:"POST",body:JSON.stringify({email:D})})}async function aJ(){return p("/users/me",{},!0)}async function zf(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F)$.set("role",F);let J=$.toString()?`?${$.toString()}`:"";return p(`/admin/users${J}`,{},!0)}async function Ef(D){return p(`/admin/approve/${D}`,{method:"POST"},!0)}async function Vf(D){return p(`/admin/revoke/${D}`,{method:"POST"},!0)}async function Zf(D,F){return p(`/admin/users/${D}/role`,{method:"POST",body:JSON.stringify({role:F})},!0)}async function VW(D,F){return p(`/admin/datasets/${D}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:F})},!0)}async function Uf(D){return p(`/datasets/${D}/publish`,{method:"POST"},!0)}async function Af(D){return p(`/admin/datasets/${D}/ci`,{},!0)}async function y4(D){return p(`/admin/datasets/${D}/ci`,{method:"POST"},!0)}async function Lf(D){return p(`/datasets/${D}/ci/status`,{},!0)}async function Mf(D){return p(`/datasets/${D}/manifest`,{},!0)}async function oJ(D,F){return p(`/datasets/${D}/manifest/${F}`,{},!0)}function Nf(D){let F=D;if(!F.status)F.status="active";else if(!["active","archived","deleted"].includes(F.status))throw Error(`Invalid dataset status: ${F.status}`);if(!F.visibility)F.visibility="private";else if(!["public","private"].includes(F.visibility))throw Error(`Invalid dataset visibility: ${F.visibility}`);return F}async function sJ(D={}){let F=new URLSearchParams;if(D.mine)F.set("mine","true");if(D.search)F.set("search",D.search);if(D.modality)F.set("modality",D.modality);if(D.author)F.set("author",D.author);if(D.task)F.set("task",D.task);if(D.hasDoi)F.set("has_doi","true");if(D.recent)F.set("recent",String(D.recent));if(D.sort)F.set("sort",D.sort);if(D.limit!=null)F.set("limit",String(D.limit));if(D.offset!=null)F.set("offset",String(D.offset));if(D.owner)F.set("owner",D.owner);let $=F.toString()?`?${F.toString()}`:"",J=await p(`/datasets${$}`,{},D.mine?!0:"optional");return J.datasets=J.datasets.map(Nf),J}async function Cf(D){return p(`/datasets/resolve/${D}`,{},"optional")}async function Rf(D,F={}){let $=new URLSearchParams({q:D});if(F.modality)$.set("modality",F.modality);if(F.limit)$.set("limit",String(F.limit));return p(`/datasets/search?${$.toString()}`,{},"optional")}async function gD(D){let F=await p(`/datasets/${D}`,{},"optional");return Nf(F.dataset)}async function Of(D){return p(`/datasets/${D}/versions`,{},!0)}async function rJ(D){return p("/datasets",{method:"POST",body:JSON.stringify(D)},!0)}async function tJ(D){return p(`/datasets/${D}/finalize`,{method:"POST"},!0)}async function x4(D,F){return p(`/datasets/${D}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function eJ(D,F){return p(`/datasets/${D}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function Tf(D,F){return p(`/admin/datasets/${D}/doi/concept`,{method:"POST",body:JSON.stringify(F)},!0)}async function P9(D){return p(`/admin/datasets/${D}/doi`,{},!0)}async function ZW(D,F){return p(`/admin/datasets/${D}/doi/update`,{method:"POST",body:JSON.stringify(F)},!0)}async function wf(D){return p(`/datasets/${D}/request-access`,{method:"POST"},!0)}async function jf(D,F){return p(`/datasets/${D}/invite`,{method:"POST",body:JSON.stringify({username:F})},!0)}async function Pf(D){return p(`/datasets/${D}/collaborators`,{},!0)}async function If(D){return p("/sandbox/complete",{method:"POST",body:JSON.stringify({dataset_id:D})},!0)}async function Sf(){return p("/sandbox/reset",{method:"POST"},!0)}async function kf(){return p("/sandbox/status",{},!0)}async function DQ(D){return p(`/datasets/${D}/publish/request`,{method:"POST"},!0)}async function vf(D){return p(`/datasets/${D}/publish/status`,{},!0)}async function yf(D){return p(`/datasets/${D}/publish/resend`,{method:"POST"},!0)}async function xf(D){let F=D?`?status=${D}`:"";return p(`/admin/publish/requests${F}`,{},!0)}async function _f(D,F){return p(`/admin/publish/${D}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:F})},!0)}async function FQ(D,F=!1,$=!1,J=!1){let Q,Y,B=[],X=!0;do{if(Y=await p(`/admin/publish/${D}/approve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resume:X?F:!0,sandbox:$,s3_lock_offset:Q,skip_ci_check:J})},!0),X=!1,Y.step_results)B.push(...Y.step_results);if(Y.hasMore&&Y.s3_lock_offset!==void 0)Q=Y.s3_lock_offset;else break}while(Y.hasMore);if(B.length>0)Y.step_results=B;return Y}async function ff(D,F){return p(`/admin/datasets/${D}/enrichment`,{method:"POST",body:JSON.stringify(F)},!0)}async function gf(D){return p(`/admin/datasets/${D}/files`,{},!0)}async function hf(D){let F=0,$=0,J=[],Q=0,Y=!0;while(Y){let B=await p(`/admin/datasets/${D}/s3-lock`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({offset:F})},!0);if($+=B.locked,J.push(...B.failed),Q=B.total,Y=B.hasMore,Y)F+=40}return{locked:$,total:Q,failed:J}}async function bf(D){return p(`/admin/datasets/${D}/reset`,{method:"POST"},!0)}async function uf(D,F=!1){return p(`/admin/datasets/${D}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:F})},!0)}async function mf(D){return p("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:D})},!0)}async function lf(D){return p("/admin/datasets/import",{method:"POST",body:JSON.stringify(D)},!0)}async function pf(D){return p(`/admin/datasets/${D}/sync`,{method:"POST"},!0)}async function df(){return p("/admin/sync/status",{},!0)}async function cf(){return p("/admin/email-preferences",{},!0)}async function nf(D){return p("/admin/email-preferences",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)},!0)}async function af(){return p("/notices",{},"optional")}async function of(){return p("/admin/notices",{},!0)}async function sf(D){return p("/admin/notices",{method:"POST",body:JSON.stringify(D)},!0)}async function rf(D){return p(`/admin/notices/${D}`,{method:"DELETE"},!0)}async function UW(D){return p("/admin/notify",{method:"POST",body:JSON.stringify(D)},!0)}var zW="https://nemar-api-dev.sccn-org.workers.dev",nJ,c,iJ,EW;var p8=P(()=>{k4();KW();cJ();nJ=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/;c=class c extends Error{statusCode;details;constructor(D,F,$){super(F);this.statusCode=D;this.details=$;this.name="ApiError"}};iJ=class iJ extends c{mode;eta;constructor(D,F,$,J){super(503,F,J);this.mode=D;this.eta=$;this.name="MaintenanceError"}};EW=zW.includes("workers.dev")});function PD(D){if(D===0)return"0 B";let F=["B","KB","MB","GB","TB"],$=Math.min(Math.floor(Math.log(D)/Math.log(1024)),F.length-1);return`${(D/1024**$).toFixed($===0?0:1)} ${F[$]}`}function ef(D){return`${PD(D)}/s`}function jz0(D){if(D<60)return`${Math.round(D)}s`;if(D<3600)return`${Math.floor(D/60)}m ${Math.round(D%60)}s`;return`${Math.floor(D/3600)}h ${Math.floor(D%3600/60)}m`}function Pz0(D,F=20){let $=Math.round(D/100*F),J=F-$;return`[${"=".repeat($)}${" ".repeat(J)}]`}class AW{filesCompleted=0;filesTotal;currentFileBytesTransferred=0;currentFileBytesTotal=0;currentFile="";startTime;lastUpdateTime;lastBytesTransferred=0;totalBytesTransferred=0;speedSamples=[];lastRenderedLine="";constructor(D=0){this.filesTotal=D,this.startTime=Date.now(),this.lastUpdateTime=this.startTime}processLine(D){if(D.ok===!0||D.success===!0){if(this.filesCompleted++,this.filesTotal===0||this.filesCompleted>this.filesTotal)this.filesTotal=this.filesCompleted;this.totalBytesTransferred+=this.currentFileBytesTotal||this.currentFileBytesTransferred,this.currentFileBytesTransferred=0,this.currentFileBytesTotal=0,this.render();return}if(D["byte-progress"]!==void 0){if(this.currentFile=D.file||this.currentFile,this.currentFileBytesTransferred=D["byte-progress"],D["total-size"]!==void 0)this.currentFileBytesTotal=D["total-size"];let F=Date.now(),$=(F-this.lastUpdateTime)/1000;if($>0.5){let Q=(this.totalBytesTransferred+this.currentFileBytesTransferred-this.lastBytesTransferred)/$;if(Q>0){if(this.speedSamples.push(Q),this.speedSamples.length>5)this.speedSamples.shift()}this.lastBytesTransferred=this.totalBytesTransferred+this.currentFileBytesTransferred,this.lastUpdateTime=F}this.render()}}incrementFilesCompleted(){if(this.filesCompleted++,this.filesTotal===0)this.filesTotal=this.filesCompleted}setFilesTotal(D){this.filesTotal=D}render(){let D=this.speedSamples.length>0?this.speedSamples.reduce((B,X)=>B+X,0)/this.speedSamples.length:0,F=this.totalBytesTransferred+this.currentFileBytesTransferred,$=this.filesTotal>0?Math.round(this.filesCompleted/this.filesTotal*100):0,J=Pz0($),Q=this.filesTotal>0?`${this.filesCompleted}/${this.filesTotal} files`:`${this.filesCompleted} files`,Y=`${J} ${$}% ${Q}`;if(F>0)Y+=` | ${PD(F)}`;if(D>0)Y+=` | ${ef(D)}`;if(D>0&&this.currentFileBytesTotal>0){let X=(this.currentFileBytesTotal-this.currentFileBytesTransferred)/D;if(X>0)Y+=` | ETA ${jz0(X)}`}if(Y!==this.lastRenderedLine)process.stderr.write(`\r${W.cyan(Y)}${" ".repeat(10)}`),this.lastRenderedLine=Y}finish(D){let F=(Date.now()-this.startTime)/1000;if(process.stderr.write(`\r${" ".repeat(this.lastRenderedLine.length+15)}\r`),D>0){let $=F>0?`${ef(this.totalBytesTransferred/F)}`:"",J=[`${D} file${D!==1?"s":""} downloaded`,this.totalBytesTransferred>0?PD(this.totalBytesTransferred):"",$].filter(Boolean).join(" | ");process.stderr.write(`${W.green(J)}
98
+ `)}var $f=!1;var KW=P(()=>{kD()});var Qf;var Jf=P(()=>{Qf={name:"nemar-cli",version:"0.8.2-dev.651",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",prepare:"husky",deploy:"wrangler deploy",preview:"wrangler dev"},keywords:["nemar","bids","neuroimaging","eeg","emg","datalad","cli"],author:"NEMAR Team",license:"CC-BY-NC-ND-4.0",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","fuse.js":"^7.1.0",inquirer:"^9.2.15",ora:"^8.0.1",zod:"^3.23.8"},"lint-staged":{"src/**/*.{ts,tsx}":["biome check --fix"],"backend/src/**/*.{ts,tsx}":["biome check --fix"]},devDependencies:{"@biomejs/biome":"1.9.4","@types/bcryptjs":"^3.0.0","@types/bun":"latest","@types/inquirer":"^9.0.7",bcryptjs:"^3.0.3",husky:"^9.1.7","lint-staged":"^16.3.2",typescript:"^5.5.4",wrangler:"^4.70.0"}}});var v4;var cJ=P(()=>{Jf();v4=Qf.version});function S0(D){if(D instanceof Error)return D.message;return String(D)}function Yf(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(EW)return zW;return QD().apiUrl||zW}async function p(D,F={},$=!1){let J=`${Yf()}${D}`,Q={"Content-Type":"application/json","X-CLI-Version":v4,...F.headers};if($){let X=QD();if(!X.apiKey&&$===!0)throw new c(401,"Not authenticated. Run 'nemar auth login' first.");if(X.apiKey)Q.Authorization=`Bearer ${X.apiKey}`}let Y;try{Y=await fetch(J,{...F,headers:Q})}catch(X){throw new c(0,`Network error: Could not connect to ${Yf()}`,{originalError:X instanceof Error?X.message:String(X)})}let B;try{B=await Y.json()}catch{throw new c(Y.status,`Invalid response from server (status ${Y.status})`)}if(!Y.ok){if(Y.status===503&&(B.mode==="read-only"||B.mode==="full")){let X=typeof B.message==="string"?B.message:"NEMAR is in maintenance mode. Please retry shortly.",G=typeof B.eta==="string"?B.eta:null,H=new iJ(B.mode,X,G,B.details);throw dJ(H),H}throw new c(Y.status,B.error||B.message||"Request failed",B.details)}return B}async function Bf(D){return p(`/auth/check-username?username=${encodeURIComponent(D)}`)}async function Xf(D){return p(`/auth/check-github?username=${encodeURIComponent(D)}`)}async function Gf(D){return p("/auth/signup",{method:"POST",body:JSON.stringify(D)})}async function Wf(D){return p("/auth/login",{method:"POST",body:JSON.stringify({api_key:D})})}async function Hf(D){return p("/auth/resend-verification",{method:"POST",body:JSON.stringify({email:D})})}async function qf(D,F){return p("/auth/retrieve-key",{method:"POST",body:JSON.stringify({email:D,password:F})})}async function Kf(D){return p("/auth/request-key-regeneration",{method:"POST",body:JSON.stringify({email:D})})}async function aJ(){return p("/users/me",{},!0)}async function zf(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F)$.set("role",F);let J=$.toString()?`?${$.toString()}`:"";return p(`/admin/users${J}`,{},!0)}async function Ef(D){return p(`/admin/approve/${D}`,{method:"POST"},!0)}async function Vf(D){return p(`/admin/revoke/${D}`,{method:"POST"},!0)}async function Zf(D,F){return p(`/admin/users/${D}/role`,{method:"POST",body:JSON.stringify({role:F})},!0)}async function VW(D,F){return p(`/admin/datasets/${D}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:F})},!0)}async function Uf(D){return p(`/datasets/${D}/publish`,{method:"POST"},!0)}async function Af(D){return p(`/admin/datasets/${D}/ci`,{},!0)}async function y4(D){return p(`/admin/datasets/${D}/ci`,{method:"POST"},!0)}async function Lf(D){return p(`/datasets/${D}/ci/status`,{},!0)}async function Mf(D){return p(`/datasets/${D}/manifest`,{},!0)}async function oJ(D,F){return p(`/datasets/${D}/manifest/${F}`,{},!0)}function Nf(D){let F=D;if(!F.status)F.status="active";else if(!["active","archived","deleted"].includes(F.status))throw Error(`Invalid dataset status: ${F.status}`);if(!F.visibility)F.visibility="private";else if(!["public","private"].includes(F.visibility))throw Error(`Invalid dataset visibility: ${F.visibility}`);return F}async function sJ(D={}){let F=new URLSearchParams;if(D.mine)F.set("mine","true");if(D.search)F.set("search",D.search);if(D.modality)F.set("modality",D.modality);if(D.author)F.set("author",D.author);if(D.task)F.set("task",D.task);if(D.hasDoi)F.set("has_doi","true");if(D.recent)F.set("recent",String(D.recent));if(D.sort)F.set("sort",D.sort);if(D.limit!=null)F.set("limit",String(D.limit));if(D.offset!=null)F.set("offset",String(D.offset));if(D.owner)F.set("owner",D.owner);let $=F.toString()?`?${F.toString()}`:"",J=await p(`/datasets${$}`,{},D.mine?!0:"optional");return J.datasets=J.datasets.map(Nf),J}async function Cf(D){return p(`/datasets/resolve/${D}`,{},"optional")}async function Rf(D,F={}){let $=new URLSearchParams({q:D});if(F.modality)$.set("modality",F.modality);if(F.limit)$.set("limit",String(F.limit));return p(`/datasets/search?${$.toString()}`,{},"optional")}async function gD(D){let F=await p(`/datasets/${D}`,{},"optional");return Nf(F.dataset)}async function Of(D){return p(`/datasets/${D}/versions`,{},!0)}async function rJ(D){return p("/datasets",{method:"POST",body:JSON.stringify(D)},!0)}async function tJ(D){return p(`/datasets/${D}/finalize`,{method:"POST"},!0)}async function x4(D,F){return p(`/datasets/${D}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function eJ(D,F){return p(`/datasets/${D}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function Tf(D,F){return p(`/admin/datasets/${D}/doi/concept`,{method:"POST",body:JSON.stringify(F)},!0)}async function P9(D){return p(`/admin/datasets/${D}/doi`,{},!0)}async function ZW(D,F){return p(`/admin/datasets/${D}/doi/update`,{method:"POST",body:JSON.stringify(F)},!0)}async function wf(D){return p(`/datasets/${D}/request-access`,{method:"POST"},!0)}async function jf(D,F){return p(`/datasets/${D}/invite`,{method:"POST",body:JSON.stringify({username:F})},!0)}async function Pf(D){return p(`/datasets/${D}/collaborators`,{},!0)}async function If(D){return p("/sandbox/complete",{method:"POST",body:JSON.stringify({dataset_id:D})},!0)}async function Sf(){return p("/sandbox/reset",{method:"POST"},!0)}async function kf(){return p("/sandbox/status",{},!0)}async function DQ(D){return p(`/datasets/${D}/publish/request`,{method:"POST"},!0)}async function vf(D){return p(`/datasets/${D}/publish/status`,{},!0)}async function yf(D){return p(`/datasets/${D}/publish/resend`,{method:"POST"},!0)}async function xf(D){let F=D?`?status=${D}`:"";return p(`/admin/publish/requests${F}`,{},!0)}async function _f(D,F){return p(`/admin/publish/${D}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:F})},!0)}async function FQ(D,F=!1,$=!1,J=!1){let Q,Y,B=[],X=!0;do{if(Y=await p(`/admin/publish/${D}/approve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resume:X?F:!0,sandbox:$,s3_lock_offset:Q,skip_ci_check:J})},!0),X=!1,Y.step_results)B.push(...Y.step_results);if(Y.hasMore&&Y.s3_lock_offset!==void 0)Q=Y.s3_lock_offset;else break}while(Y.hasMore);if(B.length>0)Y.step_results=B;return Y}async function ff(D,F){return p(`/admin/datasets/${D}/enrichment`,{method:"POST",body:JSON.stringify(F)},!0)}async function gf(D){return p(`/admin/datasets/${D}/files`,{},!0)}async function hf(D){let F=0,$=0,J=[],Q=0,Y=!0;while(Y){let B=await p(`/admin/datasets/${D}/s3-lock`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({offset:F})},!0);if($+=B.locked,J.push(...B.failed),Q=B.total,Y=B.hasMore,Y)F+=40}return{locked:$,total:Q,failed:J}}async function bf(D){return p(`/admin/datasets/${D}/reset`,{method:"POST"},!0)}async function uf(D,F=!1){return p(`/admin/datasets/${D}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:F})},!0)}async function mf(D){return p("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:D})},!0)}async function lf(D){return p("/admin/datasets/import",{method:"POST",body:JSON.stringify(D)},!0)}async function pf(D){return p(`/admin/datasets/${D}/sync`,{method:"POST"},!0)}async function df(){return p("/admin/sync/status",{},!0)}async function cf(){return p("/admin/email-preferences",{},!0)}async function nf(D){return p("/admin/email-preferences",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)},!0)}async function af(){return p("/notices",{},"optional")}async function of(){return p("/admin/notices",{},!0)}async function sf(D){return p("/admin/notices",{method:"POST",body:JSON.stringify(D)},!0)}async function rf(D){return p(`/admin/notices/${D}`,{method:"DELETE"},!0)}async function UW(D){return p("/admin/notify",{method:"POST",body:JSON.stringify(D)},!0)}var zW="https://nemar-api-dev.sccn-org.workers.dev",nJ,c,iJ,EW;var p8=P(()=>{k4();KW();cJ();nJ=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/;c=class c extends Error{statusCode;details;constructor(D,F,$){super(F);this.statusCode=D;this.details=$;this.name="ApiError"}};iJ=class iJ extends c{mode;eta;constructor(D,F,$,J){super(503,F,J);this.mode=D;this.eta=$;this.name="MaintenanceError"}};EW=zW.includes("workers.dev")});function PD(D){if(D===0)return"0 B";let F=["B","KB","MB","GB","TB"],$=Math.min(Math.floor(Math.log(D)/Math.log(1024)),F.length-1);return`${(D/1024**$).toFixed($===0?0:1)} ${F[$]}`}function ef(D){return`${PD(D)}/s`}function jz0(D){if(D<60)return`${Math.round(D)}s`;if(D<3600)return`${Math.floor(D/60)}m ${Math.round(D%60)}s`;return`${Math.floor(D/3600)}h ${Math.floor(D%3600/60)}m`}function Pz0(D,F=20){let $=Math.round(D/100*F),J=F-$;return`[${"=".repeat($)}${" ".repeat(J)}]`}class AW{filesCompleted=0;filesTotal;currentFileBytesTransferred=0;currentFileBytesTotal=0;currentFile="";startTime;lastUpdateTime;lastBytesTransferred=0;totalBytesTransferred=0;speedSamples=[];lastRenderedLine="";constructor(D=0){this.filesTotal=D,this.startTime=Date.now(),this.lastUpdateTime=this.startTime}processLine(D){if(D.ok===!0||D.success===!0){if(this.filesCompleted++,this.filesTotal===0||this.filesCompleted>this.filesTotal)this.filesTotal=this.filesCompleted;this.totalBytesTransferred+=this.currentFileBytesTotal||this.currentFileBytesTransferred,this.currentFileBytesTransferred=0,this.currentFileBytesTotal=0,this.render();return}if(D["byte-progress"]!==void 0){if(this.currentFile=D.file||this.currentFile,this.currentFileBytesTransferred=D["byte-progress"],D["total-size"]!==void 0)this.currentFileBytesTotal=D["total-size"];let F=Date.now(),$=(F-this.lastUpdateTime)/1000;if($>0.5){let Q=(this.totalBytesTransferred+this.currentFileBytesTransferred-this.lastBytesTransferred)/$;if(Q>0){if(this.speedSamples.push(Q),this.speedSamples.length>5)this.speedSamples.shift()}this.lastBytesTransferred=this.totalBytesTransferred+this.currentFileBytesTransferred,this.lastUpdateTime=F}this.render()}}incrementFilesCompleted(){if(this.filesCompleted++,this.filesTotal===0)this.filesTotal=this.filesCompleted}setFilesTotal(D){this.filesTotal=D}render(){let D=this.speedSamples.length>0?this.speedSamples.reduce((B,X)=>B+X,0)/this.speedSamples.length:0,F=this.totalBytesTransferred+this.currentFileBytesTransferred,$=this.filesTotal>0?Math.round(this.filesCompleted/this.filesTotal*100):0,J=Pz0($),Q=this.filesTotal>0?`${this.filesCompleted}/${this.filesTotal} files`:`${this.filesCompleted} files`,Y=`${J} ${$}% ${Q}`;if(F>0)Y+=` | ${PD(F)}`;if(D>0)Y+=` | ${ef(D)}`;if(D>0&&this.currentFileBytesTotal>0){let X=(this.currentFileBytesTotal-this.currentFileBytesTransferred)/D;if(X>0)Y+=` | ETA ${jz0(X)}`}if(Y!==this.lastRenderedLine)process.stderr.write(`\r${W.cyan(Y)}${" ".repeat(10)}`),this.lastRenderedLine=Y}finish(D){let F=(Date.now()-this.startTime)/1000;if(process.stderr.write(`\r${" ".repeat(this.lastRenderedLine.length+15)}\r`),D>0){let $=F>0?`${ef(this.totalBytesTransferred/F)}`:"",J=[`${D} file${D!==1?"s":""} downloaded`,this.totalBytesTransferred>0?PD(this.totalBytesTransferred):"",$].filter(Boolean).join(" | ");process.stderr.write(`${W.green(J)}
99
99
  `)}}}var LW=P(()=>{kD()});var qg={};p4(qg,{verifyGitHubAuth:()=>S9,uploadFilesWithPresignedUrls:()=>OW,uploadFileWithPresignedUrl:()=>Xg,toS3Credentials:()=>hD,switchBranch:()=>bz0,setKeyPresent:()=>Hg,saveDataset:()=>c8,runCommand:()=>I,resolveUpstreamRef:()=>xW,registerUrlsWithGitAnnex:()=>TW,registerUrlWithGitAnnex:()=>Gg,readRemoteHeadDatasetVersion:()=>yW,readLocalDatasetVersion:()=>vW,pushToGitHub:()=>a1,pushBranch:()=>jF,listDatasetVersions:()=>PW,isWorkingTreeDirty:()=>_W,isGitAnnexDataset:()=>R1,isDataladDataset:()=>dz0,initDataset:()=>m6,gitMergeFastForward:()=>gW,gitFetchOrigin:()=>fW,gitAnnexAdd:()=>TF,getVersionCommit:()=>IW,getRemoteUuid:()=>mW,getLocalDatasetInfo:()=>jW,getKeyHashDirs:()=>lz0,getKeyHashDir:()=>Wg,getDatasetStats:()=>fz0,getDatasetIdFromRemote:()=>i8,getDatasetData:()=>JQ,getCurrentBranch:()=>n8,getAnnexWhereisAll:()=>uW,getAnnexS3Remotes:()=>v9,formatBytes:()=>PD,ensureLocalMainBranch:()=>y9,ensureGitAnnexInitialized:()=>RW,enableS3Remote:()=>f4,dropUnusedAnnexObjects:()=>hW,dropFiles:()=>wW,createRevertBranch:()=>SW,createDataladDataset:()=>pz0,copyToAnnexRemote:()=>p6,configureWebRemote:()=>gz0,configureS3Remote:()=>l6,configureLargefiles:()=>_4,configureGitHubRemote:()=>d8,commitRevert:()=>kW,collectFileManifest:()=>bW,cloneDataset:()=>o1,clearAnnexCredentials:()=>Q1,checkPrerequisites:()=>I9,checkGitHubSSH:()=>Qg,checkGitAnnexInstalled:()=>CW,checkDownloadPrerequisites:()=>wF,checkAWSCredentials:()=>vz0,batchSetKeysPresent:()=>lW,acceptGitHubInvitation:()=>k9});import{existsSync as NW,readFileSync as Iz0,statSync as Sz0}from"fs";import{join as $Q}from"path";var{spawn:Jg}=globalThis.Bun;async function I(D,F={}){let $=Jg({cmd:D,cwd:F.cwd,stdout:"pipe",stderr:"pipe",env:{...process.env,GIT_TERMINAL_PROMPT:"0",...F.env}}),J=!1,Q;if(F.timeout)Q=setTimeout(()=>{J=!0,$.kill()},F.timeout);let Y=await new Response($.stdout).text(),B=await new Response($.stderr).text(),X=await $.exited;if(Q)clearTimeout(Q);if(J)return{stdout:Y,stderr:B||`Command timed out after ${Math.round(F.timeout/1000)}s`,exitCode:X??1};return{stdout:Y,stderr:B,exitCode:X}}function Dg(D){return D.split(".").map((F)=>{let $=Number.parseInt(F.replace(/[^0-9]/g,""),10);return Number.isNaN($)?0:$})}function kz0(D,F){let $=Dg(D),J=Dg(F);for(let Q=0;Q<Math.max($.length,J.length);Q++){let Y=$[Q]||0,B=J[Q]||0;if(Y>B)return!0;if(Y<B)return!1}return!0}async function CW(){try{let{stdout:F,exitCode:$,stderr:J}=await I(["git-annex","version"]);if($!==0)return console.warn("git-annex version returned non-zero exit code:",$),console.warn("stderr:",J),{installed:!1,minVersion:"10.0",error:`Version check failed: ${J.trim()}`};let Q=F.match(/version:\s*(\d+\.\d+)/),Y=Q?Q[1]:void 0;if(!Y)console.warn("Could not parse git-annex version from output:",F);return{installed:!0,version:Y,minVersion:"10.0",compatible:Y?kz0(Y,"10.0"):void 0}}catch(F){let $=F instanceof Error?F.message:String(F);if($.includes("ENOENT")||$.includes("not found"))return console.info("git-annex not found in PATH"),{installed:!1,minVersion:"10.0"};return console.error("Error checking git-annex installation:",$),{installed:!1,minVersion:"10.0",error:$}}}async function Qg(){if(process.env.GH_TOKEN)return{accessible:!0,username:"token-auth",useHttps:!0};try{let{stdout:D,stderr:F}=await I(["ssh","-T","-o","BatchMode=yes","-o","StrictHostKeyChecking=accept-new","-o","ConnectTimeout=10","git@github.com"]),$=D+F,J=$.match(/Hi ([^!]+)!/);if(J)return{accessible:!0,username:J[1]};if($.includes("Permission denied"))return{accessible:!1};return{accessible:$.includes("successfully authenticated")}}catch(D){let F=D instanceof Error?D.message:String(D);if(F.includes("ENOENT")||F.includes("not found"))console.info("SSH command not found");else console.error("Error checking GitHub SSH access:",F);return{accessible:!1}}}async function vz0(){if(process.env.AWS_ACCESS_KEY_ID&&process.env.AWS_SECRET_ACCESS_KEY)return{configured:!0,source:"environment"};try{let{stdout:D,exitCode:F}=await I(["aws","configure","get","aws_access_key_id"]);if(F===0&&D.trim())return{configured:!0,source:"aws-cli"}}catch(D){let F=D instanceof Error?D.message:String(D);if(F.includes("ENOENT")||F.includes("not found"))console.info("AWS CLI not found in PATH");else console.error("Error checking AWS credentials:",F)}return{configured:!1}}function Yg(){let D=process.platform;if(D==="darwin")return"brew install git-annex";if(D==="linux")return"apt install git-annex (Debian/Ubuntu)";return"See https://git-annex.branchable.com/install/"}async function I9(){let[D,F]=await Promise.all([CW(),Qg()]),$=[];if(!D.installed)$.push(`git-annex is not installed. Install: ${Yg()}`);else if(D.compatible===!1)$.push(`git-annex version ${D.version} is too old. Required: >= ${D.minVersion}`);if(!F.accessible){if(!(await Bg()).token)$.push("GitHub authentication not configured. Run 'gh auth login' to authenticate.")}return{gitAnnex:D,githubSSH:F,allPassed:$.length===0,errors:$}}async function R1(D){if(!NW($Q(D,".git")))return!1;try{let{exitCode:F}=await I(["git","annex","info"],{cwd:D});return F===0}catch(F){let $=F instanceof Error?F.message:String(F);if(!$.includes("ENOENT")&&!$.includes("not found"))console.error(`Error checking if ${D} is a git-annex dataset:`,$);return!1}}async function m6(D,F={}){if(!F.force&&await R1(D))return{success:!0};try{let $={};if(F.author)$.GIT_AUTHOR_NAME=F.author.name,$.GIT_AUTHOR_EMAIL=F.author.email,$.GIT_COMMITTER_NAME=F.author.name,$.GIT_COMMITTER_EMAIL=F.author.email;let{stderr:J,exitCode:Q}=await I(["git","init","-b","main",D],{...Object.keys($).length>0?{env:$}:{}});if(Q!==0)return{success:!1,error:J.trim()||"Failed to initialize git repository"};let Y=Object.keys($).length>0?{env:$}:{},{stderr:B,exitCode:X}=await I(["git","annex","init"],{cwd:D,...Y});if(X!==0)return{success:!1,error:B.trim()||"Failed to initialize git-annex"};let{stderr:G,exitCode:H}=await I(["git","commit","--allow-empty","-m","Initialize dataset"],{cwd:D,...Y});if(H!==0)return{success:!1,error:G.trim()||"Failed to create initial commit"};let{stderr:q,exitCode:K}=await I(["git","annex","adjust","--unlock"],{cwd:D,...Y});if(K!==0)return{success:!1,error:q.trim()||"Failed to switch to unlocked mode"};return{success:!0}}catch($){return{success:!1,error:$.message}}}async function RW(D){try{let{exitCode:F,stderr:$}=await I(["git","annex","info"],{cwd:D});if(F===0)return{success:!0};if($.includes("First run: git-annex init")){let{stderr:J,exitCode:Q}=await I(["git","annex","init"],{cwd:D});if(Q!==0)return{success:!1,error:J.trim()||"Failed to initialize git-annex"};return{success:!0}}return{success:!1,error:$.trim()||"Failed to check git-annex status"}}catch(F){return{success:!1,error:F.message}}}async function _4(D,F){let $=["*.edf","*.bdf","*.set","*.fif","*.vhdr","*.eeg","*.cnt","*.fdt"],J=["*.tsv","*.json","*.md","*.txt","*.yml","*.yaml","README*","LICENSE*","CHANGES*",".bidsignore",".gitignore"],Q=$.map((G)=>`include=${G}`).join(" or "),Y=J.map((G)=>`exclude=${G}`).join(" and "),B=`(${Q} or largerthan=100kb) and ${Y}`,X=F||B;try{let{stderr:G,exitCode:H}=await I(["git","annex","config","--set","annex.largefiles",X],{cwd:D});if(H!==0)return{success:!1,error:G.trim()||"Failed to configure largefiles"};return{success:!0}}catch(G){return{success:!1,error:G.message}}}async function TF(D,F="."){try{let{stderr:$,exitCode:J}=await I(["git","annex","add",F],{cwd:D});if(J!==0)return{success:!1,error:$.trim()||"Failed to add files to git-annex"};return{success:!0}}catch($){return{success:!1,error:$.message}}}function hD(D){return{accessKeyId:D.access_key_id,secretAccessKey:D.secret_access_key,sessionToken:D.session_token}}function MW(D){let F=[/^\(merging .* into .*\.\.\.\)$/,/^\(recording state in git\.\.\.\)$/,/^\(scanning for /,/^\(checking /];return D.split(`
100
100
  `).filter(($)=>{let J=$.trim();if(!J)return!1;if(J.includes("setting annex-ignore"))return!1;if(F.some((Q)=>Q.test(J)))return!1;return!0}).join(`
101
101
  `).trim()}function yz0(D){let F=["type=S3","encryption=none",`bucket=${D.bucket}`,`fileprefix=${D.prefix.replace(/\/$/,"")}/`,`datacenter=${D.region}`,"signature=v4","autoenable=true","protocol=https"];if(D.publicUrl)F.push(`publicurl=${D.publicUrl}`);return F}async function xz0(D,F){let{stdout:$,stderr:J,exitCode:Q}=await I(["git","annex","info","--json"],{cwd:D});if(Q!==0)return console.warn(`Warning: could not check for existing remote (git annex info exited ${Q}): ${J.trim()}`),!1;try{let Y=JSON.parse($);return[...Y["semitrusted repositories"]??[],...Y["trusted repositories"]??[],...Y["untrusted repositories"]??[]].some((X)=>X.description?.includes(`[${F}]`)||X.description===F)}catch(Y){return console.warn(`Warning: could not parse git annex info output: ${Y.message}`),!1}}async function Fg(D,F,$,J){let Q=["git","annex","enableremote",F,...$],Y=await I(Q,{cwd:D,env:J});if(Y.exitCode!==0)return{success:!1,error:MW(Y.stderr)||Y.stderr.trim()||`enableremote exited with code ${Y.exitCode}`};return{success:!0}}async function l6(D,F,$){let J={AWS_ACCESS_KEY_ID:$.accessKeyId,AWS_SECRET_ACCESS_KEY:$.secretAccessKey};if($.sessionToken)J.AWS_SESSION_TOKEN=$.sessionToken;let Q=await I(["git","config","remote.origin.annex-ignore","true"],{cwd:D});if(Q.exitCode!==0)console.warn(`Warning: could not set remote.origin.annex-ignore: ${Q.stderr.trim()}`);let Y=yz0(F);try{if(await xz0(D,F.name))return Fg(D,F.name,Y,J);let X=["git","annex","initremote",F.name,...Y],{stderr:G,exitCode:H}=await I(X,{cwd:D,env:J});if(H!==0){if(G.includes("already exists"))return Fg(D,F.name,Y,J);return{success:!1,error:MW(G)||"Failed to configure S3 remote"}}let q=MW(G);if(q)console.warn(` Warning during S3 remote setup: ${q}`);return{success:!0}}catch(B){return{success:!1,error:`S3 remote configuration failed: ${B instanceof Error?B.message:String(B)}`}}}async function Q1(D){let{join:F}=await import("path"),{readdirSync:$,unlinkSync:J}=await import("fs"),Q=F(D,".git","annex","creds"),Y;try{Y=$(Q)}catch(B){if(B.code==="ENOENT")return;console.warn(`Warning: Could not read ${Q}: ${B.message}`);return}for(let B of Y)try{J(F(Q,B))}catch(X){console.warn(`Warning: Could not delete ${B}: ${X.message}`)}}async function f4(D,F="nemar-s3",$){try{let J={};if($){if(J.AWS_ACCESS_KEY_ID=$.accessKeyId,J.AWS_SECRET_ACCESS_KEY=$.secretAccessKey,$.sessionToken)J.AWS_SESSION_TOKEN=$.sessionToken}let{stderr:Q,exitCode:Y}=await I(["git","annex","enableremote",F],{cwd:D,...Object.keys(J).length>0&&{env:Object.fromEntries(Object.entries({...process.env,...J}).filter((B)=>B[1]!=null))}});if(Y===0)return{success:!0,enabled:!0};if(Q.includes("there is no special remote named")||Q.includes("not a special remote")||Q.includes("Unknown remote")||Q.includes("not found"))return{success:!0,enabled:!1};return{success:!1,enabled:!1,error:Q.trim()}}catch(J){return{success:!1,enabled:!1,error:J.message}}}async function _z0(){try{let{exitCode:D,stderr:F}=await I(["ssh","-T","-o","BatchMode=yes","-o","ConnectTimeout=5","git@github.com"]),$=F.includes("successfully authenticated");if(!$)console.warn("SSH test to github.com failed:",{exitCode:D,stderr:F.trim().slice(0,500)});return{works:$,error:$?void 0:F.trim().slice(0,500)}}catch(D){let F=D instanceof Error?D.message:String(D);return console.warn("SSH test exception:",F),{works:!1,error:F}}}async function Bg(){try{let{stdout:D,exitCode:F,stderr:$}=await I(["gh","auth","token"]);if(F!==0)return console.warn("gh CLI returned non-zero exit code:",F),console.warn("stderr:",$),{token:null,error:`gh auth token failed: ${$.trim()||"unknown error"}`};if(!D.trim())return console.warn("gh auth token returned empty output"),{token:null,error:"gh CLI returned empty token"};return{token:D.trim()}}catch(D){let F=D instanceof Error?D.message:String(D);if(console.error("Failed to get GitHub token from gh CLI:",F),F.includes("ENOENT")||F.includes("not found"))return{token:null,error:"gh CLI not installed (command not found)"};return{token:null,error:`gh CLI error: ${F}`}}}async function S9(D){try{let{stdout:F,exitCode:$,stderr:J}=await I(["gh","api","user","--jq",".login"]);if($!==0){if(J.includes("not logged in")||J.includes("auth login"))return{authenticated:!1,error:"gh CLI not authenticated. Run 'gh auth login' to authenticate."};return{authenticated:!1,error:`gh CLI error: ${J.trim()||"unknown error"}`}}let Q=F.trim();if(!Q)return{authenticated:!1,error:"gh CLI returned empty username"};if(D){let Y=Q.toLowerCase()===D.toLowerCase();return{authenticated:!0,username:Q,matches:Y,error:Y?void 0:`gh CLI authenticated as '${Q}', expected '${D}'`}}return{authenticated:!0,username:Q}}catch(F){let $=F instanceof Error?F.message:String(F);if($.includes("ENOENT")||$.includes("not found"))return{authenticated:!1,error:"gh CLI not installed. Install from https://cli.github.com/"};return{authenticated:!1,error:`Failed to verify gh CLI: ${$}`}}}async function k9(D){if(!/^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/.test(D))return{accepted:!1,error:`Invalid repository format: ${D}`};let{stdout:F,exitCode:$,stderr:J}=await I(["gh","api","/user/repository_invitations"]);if($!==0){if(J.includes("not logged in")||J.includes("auth login"))return{accepted:!1,error:"gh CLI not authenticated. Run 'gh auth login' to authenticate."};if(J.includes("API rate limit")||J.includes("403"))return{accepted:!1,error:"GitHub API rate limit exceeded. Please try again in a few minutes."};if(J.includes("ENOENT")||J.includes("not found"))return{accepted:!1,error:"gh CLI not installed. Install from https://cli.github.com/"};return{accepted:!1,error:`Failed to list invitations: ${J.trim()||"unknown error"}`}}let Q=null;try{Q=JSON.parse(F||"[]").find((H)=>H.repository.full_name===D)?.id??null}catch(X){let G=X instanceof Error?X.message:String(X);return console.error("Failed to parse GitHub invitations response:",G),console.error(" Raw response (first 500 chars):",(F||"").slice(0,500)),{accepted:!1,error:`Failed to parse GitHub API response: ${G}`}}if(!Q){let{exitCode:X}=await I(["gh","api",`/repos/${D}`,"--silent"]);if(X===0)return{accepted:!0,alreadyCollaborator:!0};return{accepted:!1,error:`No pending invitation found for ${D}. You may need to accept it manually via GitHub.`}}let{exitCode:Y,stderr:B}=await I(["gh","api","--method","PATCH",`/user/repository_invitations/${Q}`]);if(Y!==0)return{accepted:!1,error:`Failed to accept invitation: ${B.trim()||"unknown error"}`};return{accepted:!0}}async function d8(D,F,$="origin"){let J=F;if(process.env.GH_TOKEN&&F.startsWith("git@github.com:")){let Q=process.env.GH_TOKEN.trim();if(!Q||/\s/.test(Q))return{success:!1,error:"GH_TOKEN environment variable is set but appears malformed (empty or contains whitespace)"};J=`https://github.com/${F.replace("git@github.com:","")}`,await I(["git","config","credential.https://github.com.helper",`!printf 'username=x-access-token\\npassword=${Q}'`],{cwd:D})}else if(F.startsWith("git@github.com:")){let Q=F.replace("git@github.com:",""),Y=await Bg();if(Y.token)J=`https://github.com/${Q}`,await I(["git","config","credential.https://github.com.helper",`!printf 'username=x-access-token\\npassword=${Y.token}'`],{cwd:D});else{let B=await _z0();if(B.works)J=F;else return{success:!1,error:`GitHub authentication not configured.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nemar-cli",
3
- "version": "0.8.2-dev.650",
3
+ "version": "0.8.2-dev.651",
4
4
  "description": "CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",