nemar-cli 0.9.1-PR977.79fb62f → 0.9.1-PR977.9a372f7
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.
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -102,7 +102,7 @@ ${H.dim(`eta: ${D.eta}`)}`:"";process.stderr.write(`${F}
|
|
|
102
102
|
${$} ${D.message}
|
|
103
103
|
${Q}${J}
|
|
104
104
|
${F}
|
|
105
|
-
`)}var Pp=!1;var wz=S(()=>{e0()});var Sp;var Ip=S(()=>{Sp={name:"nemar-cli",version:"0.9.1-PR977.79fb62f",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",prepare:"husky",postinstall:"bun scripts/postinstall-check.mjs",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://docs.nemar.org",engines:{bun:">=1.0.0"},files:["dist","scripts/postinstall-check.mjs","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",ajv:"^8.20.0","ajv-formats":"^3.0.1",bcryptjs:"^3.0.3",husky:"^9.1.7","lint-staged":"^16.3.2",typescript:"^5.5.4",wrangler:"^4.70.0",yaml:"^2.8.4"}}});var T3;var KX=S(()=>{Ip();T3=Sp.version});function a(D){if(D instanceof Error)return D.message;return String(D)}var f,w3;var K1=S(()=>{f=class f extends Error{statusCode;details;step;constructor(D,F,$,Q){super(F);this.statusCode=D;this.details=$;this.step=Q;this.name="ApiError"}};w3=class w3 extends f{mode;eta;constructor(D,F,$,Q){super(503,F,Q);this.mode=D;this.eta=$;this.name="MaintenanceError"}}});function kp(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(Iz)return Pz;return KD().apiUrl||Pz}async function x(D,F={},$=!1,Q){let J=`${kp()}${D}`,Y={"Content-Type":"application/json","X-CLI-Version":T3,...F.headers};if($){let G=KD();if(!G.apiKey&&$===!0)throw new f(401,"Not authenticated. Run 'nemar auth login' first.");if(G.apiKey)Y.Authorization=`Bearer ${G.apiKey}`}let X;try{X=await fetch(J,{...F,headers:Y})}catch(G){throw new f(0,`Network error: Could not connect to ${kp()}`,{originalError:G instanceof Error?G.message:String(G)})}let B;try{B=await X.json()}catch{throw new f(X.status,`Invalid response from server (status ${X.status})`)}if(!X.ok){if(X.status===503&&(B.mode==="read-only"||B.mode==="full")){let G=typeof B.message==="string"?B.message:"NEMAR is in maintenance mode. Please retry shortly.",W=typeof B.eta==="string"?B.eta:null,q=new w3(B.mode,G,W,B.details);throw qX(q),q}throw new f(X.status,B.error||B.message||"Request failed",B.details,typeof B.step==="string"?B.step:void 0)}if(Q){let G=Q.safeParse(B);if(!G.success)throw new f(X.status,`Response for ${D} did not match the expected NEMAR contract`,{issues:G.error.issues});return G.data}return B}var Pz="https://api.nemar.org",Iz;var I4=S(()=>{P4();wz();KX();K1();Iz=Pz.includes("workers.dev")});async function vp(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F)$.set("role",F);let Q=$.toString()?`?${$.toString()}`:"";return x(`/admin/users${Q}`,{},!0)}async function yp(D){return x(`/admin/approve/${D}`,{method:"POST"},!0)}async function xp(D){return x(`/admin/revoke/${D}`,{method:"POST"},!0)}async function _p(D,F){return x(`/admin/users/${D}/role`,{method:"POST",body:JSON.stringify({role:F})},!0)}async function Sz(D,F){return x(`/admin/datasets/${D}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:F})},!0)}async function fp(D){return x(`/datasets/${D}/publish`,{method:"POST"},!0)}async function bp(D){return x(`/admin/datasets/${D}/ci`,{},!0)}async function j6(D){return x(`/admin/datasets/${D}/ci`,{method:"POST"},!0)}async function kz(D){return x(`/admin/datasets/${D}/ci/validate`,{method:"POST"},!0)}async function vz(D){return x(`/admin/datasets/${D}/ci/sync`,{method:"POST"},!0)}async function gp(D,F){return x(`/admin/datasets/${D}/doi/concept`,{method:"POST",body:JSON.stringify(F)},!0)}async function B$(D){return x(`/admin/datasets/${D}/doi`,{},!0)}async function yz(D,F){return x(`/admin/datasets/${D}/doi/update`,{method:"POST",body:JSON.stringify(F)},!0)}async function hp(D,F){return x(`/admin/datasets/${D}/withdraw`,{method:"POST",body:JSON.stringify({reason:F.reason,dry_run:F.dryRun})},!0)}async function up(D,F){return x(`/admin/datasets/${D}/restore`,{method:"POST",body:JSON.stringify({dry_run:F.dryRun})},!0)}async function mp(D){return x(`/admin/datasets/${D}/reset`,{method:"POST"},!0)}async function lp(D,F=!1){return x(`/admin/datasets/${D}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:F})},!0)}async function pp(D){return x("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:D})},!0)}async function dp(D){return x("/admin/datasets/import",{method:"POST",body:JSON.stringify(D)},!0)}async function cp(D){return x("/admin/datasets/exemplar",{method:"POST",body:JSON.stringify(D)},!0)}async function np(D){return x(`/admin/datasets/${D}/exemplar/remint-dois`,{method:"POST"},!0)}async function ip(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F!==void 0)$.set("blocklisted",F?"1":"0");let Q=$.toString();return x(`/admin/imports${Q?`?${Q}`:""}`,{},!0)}async function ap(D){return x(`/admin/imports/${D}/rollback`,{method:"POST"},!0)}async function op(D){return x(`/admin/imports/${D}/retry`,{method:"POST"},!0)}async function sp(D){return x(`/admin/imports/${D}/verify`,{method:"POST"},!0)}async function w5(D,F){return x(`/admin/datasets/${D}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F??{})},!0)}async function rp(D,F){return x("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:D,...F??{}})},!0)}async function tp(D){let F=D?.limit??15;return x(`/admin/datasets/hed-sweep?limit=${encodeURIComponent(String(F))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function ep(){return x("/admin/datasets/hed-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Dd(D){let F=D?.limit??15,$=new URLSearchParams({limit:String(F)});if(D?.olderThan!=null)$.set("older-than",String(D.olderThan));return x(`/admin/datasets/data-integrity-sweep?${$.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Fd(){return x("/admin/datasets/data-integrity-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function $d(D){let F=new URLSearchParams;if(D?.prefix)F.set("prefix",D.prefix);if(D?.visibility)F.set("visibility",D.visibility);if(D?.limit)F.set("limit",String(D.limit));let $=F.toString()?`?${F.toString()}`:"";return x(`/admin/fleet/drift${$}`,{},!0)}async function P5(D,F){return x(`/admin/datasets/${D}/enforce`,{method:"POST",body:JSON.stringify({dry_run:F})},!0)}async function Qd(D){return x("/admin/datasets/enforce/bulk",{method:"POST",body:JSON.stringify({prefix:D.prefix,visibility:D.visibility,limit:D.limit,dry_run:D.dryRun})},!0)}async function Jd(D,F=!1){return x(`/admin/datasets/${D}/revalidate${F?"?force=true":""}`,{method:"POST"},!0)}async function Yd(D){let F=D?`?user=${encodeURIComponent(D)}`:"";return x(`/admin/email-preferences${F}`,{},!0)}async function Xd(D,F){let $=F?`?user=${encodeURIComponent(F)}`:"";return x(`/admin/email-preferences${$}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)},!0)}async function xz(D){return x("/admin/notify",{method:"POST",body:JSON.stringify(D)},!0)}async function Bd(){return x("/admin/summary/coverage",{},!0)}async function Gd(D,F,$){return x("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:D,version:F,skip_canary:$?.skipCanary??!1})},!0)}var I5=S(()=>{I4()});async function o8(D,F){return x(`/datasets/${D}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function _z(D,F){return x(`/datasets/${D}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function Wd(D){return x(`/admin/datasets/${D}/files`,{},!0)}async function Hd(D){let F,$=0,Q=[],J=!0;while(J){let Y=await x(`/admin/datasets/${D}/s3-lock`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({continuation_token:F})},!0);if($+=Y.locked,Y.failed?.length)Q.push(...Y.failed);if(J=Y.hasMore,F=Y.continuation_token,J&&!F)throw new f(500,"S3 lock paginated response missing continuation_token; aborting to avoid infinite loop")}return{locked:$,failed:Q}}var S5=S(()=>{I4();K1()});async function ZX(D){return x(`/datasets/${D}/ci/status`,{},!0)}async function qd(D){return x(`/datasets/${D}/manifest`,{},!0)}async function VX(D,F){return x(`/datasets/${D}/manifest/${F}`,{},!0)}function Kd(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 k5(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.license)F.set("license",D.license);if(D.hasDoi)F.set("has_doi","true");if(D.hasHed)F.set("has_hed","1");if(D.dataComplete)F.set("data_complete","1");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()}`:"",Q=await x(`/datasets${$}`,{},D.mine?!0:"optional");return Q.datasets=Q.datasets.map(Kd),Q}async function zd(D){return x(`/datasets/resolve/${D}`,{},"optional")}async function Zd(D,F={}){let $=new URLSearchParams({q:D});if(F.modality)$.set("modality",F.modality);if(F.limit)$.set("limit",String(F.limit));if(F.hasHed)$.set("has_hed","1");return x(`/datasets/search?${$.toString()}`,{},"optional")}async function ID(D){let F=await x(`/datasets/${D}`,{},"optional");return Kd(F.dataset)}async function Vd(D){return x(`/datasets/${D}/versions`,{},!0)}async function EX(D){return x("/datasets",{method:"POST",body:JSON.stringify(D)},!0)}async function UX(D){return x(`/datasets/${D}/finalize`,{method:"POST"},!0)}async function fz(D){return x(`/datasets/${D}/request-access`,{method:"POST"},!0)}async function Ed(D,F){let $=F?`?status=${F}`:"";return x(`/datasets/${D}/access-requests${$}`,{},!0)}async function Ud(D,F){return x(`/datasets/${D}/access-requests/${F}/approve`,{method:"POST"},!0)}async function Ld(D,F){return x(`/datasets/${D}/access-requests/${F}/deny`,{method:"POST"},!0)}async function Md(D,F){return x(`/datasets/${D}/invite`,{method:"POST",body:JSON.stringify({username:F})},!0)}async function Ad(D){return x(`/datasets/${D}/collaborators`,{},!0)}async function Nd(D,F){return x(`/admin/datasets/${D}/enrichment`,{method:"POST",body:JSON.stringify(F)},!0)}var zX;var P3=S(()=>{I4();zX=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/});var v5;var Td=S(()=>{v5=["ci_check","enrichment_check","s3_public_read","repo_public","tag_protect","doi_create","update_metadata","update_readme","create_tag","create_release","upload_to_zenodo","publish_doi","version_doi","s3_lock","sync_nemar","notify_user"]});async function y5(D){return x(`/datasets/${D}/publish/request`,{method:"POST"},!0)}async function Pd(D){return x(`/datasets/${D}/publish/status`,{},!0)}async function Id(D){return x(`/datasets/${D}/publish/resend`,{method:"POST"},!0)}async function Sd(D){let F=D?`?status=${D}`:"";return x(`/admin/publish/requests${F}`,{},!0)}async function kd(D,F){return x(`/admin/publish/${D}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:F})},!0)}function eI0(D,F=[]){if(D){let $=v5.indexOf(D);if($>=0)return $+1}return Math.min(F.length+1,v5.length)}function DS0(D){if(!(D instanceof f))return!1;if(D.statusCode===0)return!0;if(D.statusCode===429)return!0;if(D.statusCode>=500&&D.statusCode<600)return!0;if(D.statusCode===403&&/repository has been locked/i.test(D.message))return!0;return!1}async function x5(D,F=!1,$=!1,Q=!1,J,Y){let G,W,q=0,K=!1,Z,z=F,E=[],U;function M(A,N,R,T){if(!Y)return;Y({step:A,stepIndex:eI0(A,N),stepTotal:v5.length,s3LockLocked:R,s3LockTotal:T,s3LockResumed:A==="s3_lock"&&K?!0:void 0})}for(let A=1;A<=5;A++)try{let N,R=!0;do{if(N=await x(`/admin/publish/${D}/approve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resume:R?z:!0,sandbox:$,s3_lock_continuation_token:G,s3_lock_total:W,skip_ci_check:Q})},!0),R=!1,N.step_results)E.push(...N.step_results);if(N.s3_lock_total!==void 0)W=N.s3_lock_total;if(N.s3_lock_batch_count!==void 0)q+=N.s3_lock_batch_count;let T=N.step??N.step_results?.[N.step_results.length-1]?.step;if(T&&(T!==Z||T==="s3_lock"))M(T,N.steps_completed??[],T==="s3_lock"?q:void 0,T==="s3_lock"?W:void 0),Z=T;if(N.hasMore&&N.s3_lock_continuation_token!==void 0)G=N.s3_lock_continuation_token;else break}while(N.hasMore);if(E.length>0)N.step_results=wd(E);return N}catch(N){if(U=N,A===5||!DS0(N)){if(N instanceof f&&E.length>0)N.stepResults=wd(E);throw N}let T=N;if(J?.({attempt:A,maxAttempts:5,delayMs:1e4,step:T.step,error:T.message}),await new Promise((C)=>setTimeout(C,1e4)),z=!0,G!==void 0)K=!0}throw U}function wd(D){let F=new Map;for(let $ of D)F.set($.step,$);return Array.from(F.values())}var G$=S(()=>{Td();I4();K1()});function xd(D){gz=D}function hz(){return gz}function W$(D){if(gz)process.stderr.write(`${D}
|
|
105
|
+
`)}var Pp=!1;var wz=S(()=>{e0()});var Sp;var Ip=S(()=>{Sp={name:"nemar-cli",version:"0.9.1-PR977.9a372f7",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",prepare:"husky",postinstall:"bun scripts/postinstall-check.mjs",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://docs.nemar.org",engines:{bun:">=1.0.0"},files:["dist","scripts/postinstall-check.mjs","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",ajv:"^8.20.0","ajv-formats":"^3.0.1",bcryptjs:"^3.0.3",husky:"^9.1.7","lint-staged":"^16.3.2",typescript:"^5.5.4",wrangler:"^4.70.0",yaml:"^2.8.4"}}});var T3;var KX=S(()=>{Ip();T3=Sp.version});function a(D){if(D instanceof Error)return D.message;return String(D)}var f,w3;var K1=S(()=>{f=class f extends Error{statusCode;details;step;constructor(D,F,$,Q){super(F);this.statusCode=D;this.details=$;this.step=Q;this.name="ApiError"}};w3=class w3 extends f{mode;eta;constructor(D,F,$,Q){super(503,F,Q);this.mode=D;this.eta=$;this.name="MaintenanceError"}}});function kp(){if(process.env.TEST_API_URL)return process.env.TEST_API_URL;if(Iz)return Pz;return KD().apiUrl||Pz}async function x(D,F={},$=!1,Q){let J=`${kp()}${D}`,Y={"Content-Type":"application/json","X-CLI-Version":T3,...F.headers};if($){let G=KD();if(!G.apiKey&&$===!0)throw new f(401,"Not authenticated. Run 'nemar auth login' first.");if(G.apiKey)Y.Authorization=`Bearer ${G.apiKey}`}let X;try{X=await fetch(J,{...F,headers:Y})}catch(G){throw new f(0,`Network error: Could not connect to ${kp()}`,{originalError:G instanceof Error?G.message:String(G)})}let B;try{B=await X.json()}catch{throw new f(X.status,`Invalid response from server (status ${X.status})`)}if(!X.ok){if(X.status===503&&(B.mode==="read-only"||B.mode==="full")){let G=typeof B.message==="string"?B.message:"NEMAR is in maintenance mode. Please retry shortly.",W=typeof B.eta==="string"?B.eta:null,q=new w3(B.mode,G,W,B.details);throw qX(q),q}throw new f(X.status,B.error||B.message||"Request failed",B.details,typeof B.step==="string"?B.step:void 0)}if(Q){let G=Q.safeParse(B);if(!G.success)throw new f(X.status,`Response for ${D} did not match the expected NEMAR contract`,{issues:G.error.issues});return G.data}return B}var Pz="https://api.nemar.org",Iz;var I4=S(()=>{P4();wz();KX();K1();Iz=Pz.includes("workers.dev")});async function vp(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F)$.set("role",F);let Q=$.toString()?`?${$.toString()}`:"";return x(`/admin/users${Q}`,{},!0)}async function yp(D){return x(`/admin/approve/${D}`,{method:"POST"},!0)}async function xp(D){return x(`/admin/revoke/${D}`,{method:"POST"},!0)}async function _p(D,F){return x(`/admin/users/${D}/role`,{method:"POST",body:JSON.stringify({role:F})},!0)}async function Sz(D,F){return x(`/admin/datasets/${D}/visibility`,{method:"PATCH",body:JSON.stringify({visibility:F})},!0)}async function fp(D){return x(`/datasets/${D}/publish`,{method:"POST"},!0)}async function bp(D){return x(`/admin/datasets/${D}/ci`,{},!0)}async function j6(D){return x(`/admin/datasets/${D}/ci`,{method:"POST"},!0)}async function kz(D){return x(`/admin/datasets/${D}/ci/validate`,{method:"POST"},!0)}async function vz(D){return x(`/admin/datasets/${D}/ci/sync`,{method:"POST"},!0)}async function gp(D,F){return x(`/admin/datasets/${D}/doi/concept`,{method:"POST",body:JSON.stringify(F)},!0)}async function B$(D){return x(`/admin/datasets/${D}/doi`,{},!0)}async function yz(D,F){return x(`/admin/datasets/${D}/doi/update`,{method:"POST",body:JSON.stringify(F)},!0)}async function hp(D,F){return x(`/admin/datasets/${D}/withdraw`,{method:"POST",body:JSON.stringify({reason:F.reason,dry_run:F.dryRun})},!0)}async function up(D,F){return x(`/admin/datasets/${D}/restore`,{method:"POST",body:JSON.stringify({dry_run:F.dryRun})},!0)}async function mp(D){return x(`/admin/datasets/${D}/reset`,{method:"POST"},!0)}async function lp(D,F=!1){return x(`/admin/datasets/${D}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:F})},!0)}async function pp(D){return x("/admin/datasets/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataset_ids:D})},!0)}async function dp(D){return x("/admin/datasets/import",{method:"POST",body:JSON.stringify(D)},!0)}async function cp(D){return x("/admin/datasets/exemplar",{method:"POST",body:JSON.stringify(D)},!0)}async function np(D){return x(`/admin/datasets/${D}/exemplar/remint-dois`,{method:"POST"},!0)}async function ip(D,F){let $=new URLSearchParams;if(D)$.set("status",D);if(F!==void 0)$.set("blocklisted",F?"1":"0");let Q=$.toString();return x(`/admin/imports${Q?`?${Q}`:""}`,{},!0)}async function ap(D){return x(`/admin/imports/${D}/rollback`,{method:"POST"},!0)}async function op(D){return x(`/admin/imports/${D}/retry`,{method:"POST"},!0)}async function sp(D){return x(`/admin/imports/${D}/verify`,{method:"POST"},!0)}async function w5(D,F){return x(`/admin/datasets/${D}/reindex`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F??{})},!0)}async function rp(D,F){return x("/admin/datasets/reindex/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filter:D,...F??{}})},!0)}async function tp(D){let F=D?.limit??15;return x(`/admin/datasets/hed-sweep?limit=${encodeURIComponent(String(F))}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function ep(){return x("/admin/datasets/hed-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Dd(D){let F=D?.limit??15,$=new URLSearchParams({limit:String(F)});if(D?.olderThan!=null)$.set("older-than",String(D.olderThan));return x(`/admin/datasets/data-integrity-sweep?${$.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function Fd(){return x("/admin/datasets/data-integrity-sweep?reset=1",{method:"POST",headers:{"Content-Type":"application/json"}},!0)}async function $d(D){let F=new URLSearchParams;if(D?.prefix)F.set("prefix",D.prefix);if(D?.visibility)F.set("visibility",D.visibility);if(D?.limit)F.set("limit",String(D.limit));let $=F.toString()?`?${F.toString()}`:"";return x(`/admin/fleet/drift${$}`,{},!0)}async function P5(D,F){return x(`/admin/datasets/${D}/enforce`,{method:"POST",body:JSON.stringify({dry_run:F})},!0)}async function Qd(D){return x("/admin/datasets/enforce/bulk",{method:"POST",body:JSON.stringify({prefix:D.prefix,visibility:D.visibility,limit:D.limit,dry_run:D.dryRun})},!0)}async function Jd(D,F=!1){return x(`/admin/datasets/${D}/revalidate${F?"?force=true":""}`,{method:"POST"},!0)}async function Yd(D){let F=D?`?user=${encodeURIComponent(D)}`:"";return x(`/admin/email-preferences${F}`,{},!0)}async function Xd(D,F){let $=F?`?user=${encodeURIComponent(F)}`:"";return x(`/admin/email-preferences${$}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(D)},!0)}async function xz(D){return x("/admin/notify",{method:"POST",body:JSON.stringify(D)},!0)}async function Bd(){return x("/admin/summary/coverage",{},!0)}async function Gd(D,F,$){return x("/admin/manifest/dispatch",{method:"POST",body:JSON.stringify({dataset_id:D,version:F,skip_canary:$?.skipCanary??!1})},!0)}var I5=S(()=>{I4()});async function o8(D,F){return x(`/datasets/${D}/upload-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function _z(D,F){return x(`/datasets/${D}/download-credentials`,{method:"POST",body:JSON.stringify({duration_seconds:F})},!0)}async function Wd(D){return x(`/admin/datasets/${D}/files`,{},!0)}async function Hd(D){let F,$=0,Q=[],J=!0;while(J){let Y=await x(`/admin/datasets/${D}/s3-lock`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({continuation_token:F})},!0);if($+=Y.locked,Y.failed?.length)Q.push(...Y.failed);if(J=Y.hasMore,F=Y.continuation_token,J&&!F)throw new f(500,"S3 lock paginated response missing continuation_token; aborting to avoid infinite loop")}return{locked:$,failed:Q}}var S5=S(()=>{I4();K1()});async function ZX(D){return x(`/datasets/${D}/ci/status`,{},!0)}async function qd(D){return x(`/datasets/${D}/manifest`,{},!0)}async function VX(D,F){return x(`/datasets/${D}/manifest/${F}`,{},!0)}function Kd(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 k5(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.license)F.set("license",D.license);if(D.hasDoi)F.set("has_doi","true");if(D.hasHed)F.set("has_hed","1");if(D.dataComplete)F.set("data_complete","1");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()}`:"",Q=await x(`/datasets${$}`,{},D.mine?!0:"optional");return Q.datasets=Q.datasets.map(Kd),Q}async function zd(D){return x(`/datasets/resolve/${D}`,{},"optional")}async function Zd(D,F={}){let $=new URLSearchParams({q:D});if(F.modality)$.set("modality",F.modality);if(F.limit)$.set("limit",String(F.limit));if(F.hasHed)$.set("has_hed","1");return x(`/datasets/search?${$.toString()}`,{},"optional")}async function ID(D){let F=await x(`/datasets/${D}`,{},"optional");return Kd(F.dataset)}async function Vd(D){return x(`/datasets/${D}/versions`,{},!0)}async function EX(D){return x("/datasets",{method:"POST",body:JSON.stringify(D)},!0)}async function UX(D){return x(`/datasets/${D}/finalize`,{method:"POST"},!0)}async function fz(D){return x(`/datasets/${D}/request-access`,{method:"POST"},!0)}async function Ed(D,F){let $=F?`?status=${F}`:"";return x(`/datasets/${D}/access-requests${$}`,{},!0)}async function Ud(D,F){return x(`/datasets/${D}/access-requests/${F}/approve`,{method:"POST"},!0)}async function Ld(D,F){return x(`/datasets/${D}/access-requests/${F}/deny`,{method:"POST"},!0)}async function Md(D,F){return x(`/datasets/${D}/invite`,{method:"POST",body:JSON.stringify({username:F})},!0)}async function Ad(D){return x(`/datasets/${D}/collaborators`,{},!0)}async function Nd(D,F){return x(`/admin/datasets/${D}/enrichment`,{method:"POST",body:JSON.stringify(F)},!0)}var zX;var P3=S(()=>{I4();zX=/^\d{4}-\d{4}-\d{4}-\d{3}[\dX]$/});var v5;var Td=S(()=>{v5=["ci_check","enrichment_check","s3_public_read","repo_public","tag_protect","doi_create","update_metadata","update_readme","create_tag","create_release","upload_to_zenodo","publish_doi","version_doi","s3_lock","sync_nemar","notify_user"]});async function y5(D){return x(`/datasets/${D}/publish/request`,{method:"POST"},!0)}async function Pd(D){return x(`/datasets/${D}/publish/status`,{},!0)}async function Id(D){return x(`/datasets/${D}/publish/resend`,{method:"POST"},!0)}async function Sd(D){let F=D?`?status=${D}`:"";return x(`/admin/publish/requests${F}`,{},!0)}async function kd(D,F){return x(`/admin/publish/${D}/deny`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:F})},!0)}function eI0(D,F=[]){if(D){let $=v5.indexOf(D);if($>=0)return $+1}return Math.min(F.length+1,v5.length)}function DS0(D){if(!(D instanceof f))return!1;if(D.statusCode===0)return!0;if(D.statusCode===429)return!0;if(D.statusCode>=500&&D.statusCode<600)return!0;if(D.statusCode===403&&/repository has been locked/i.test(D.message))return!0;return!1}async function x5(D,F=!1,$=!1,Q=!1,J,Y){let G,W,q=0,K=!1,Z,z=F,E=[],U;function M(A,N,R,T){if(!Y)return;Y({step:A,stepIndex:eI0(A,N),stepTotal:v5.length,s3LockLocked:R,s3LockTotal:T,s3LockResumed:A==="s3_lock"&&K?!0:void 0})}for(let A=1;A<=5;A++)try{let N,R=!0;do{if(N=await x(`/admin/publish/${D}/approve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resume:R?z:!0,sandbox:$,s3_lock_continuation_token:G,s3_lock_total:W,skip_ci_check:Q})},!0),R=!1,N.step_results)E.push(...N.step_results);if(N.s3_lock_total!==void 0)W=N.s3_lock_total;if(N.s3_lock_batch_count!==void 0)q+=N.s3_lock_batch_count;let T=N.step??N.step_results?.[N.step_results.length-1]?.step;if(T&&(T!==Z||T==="s3_lock"))M(T,N.steps_completed??[],T==="s3_lock"?q:void 0,T==="s3_lock"?W:void 0),Z=T;if(N.hasMore&&N.s3_lock_continuation_token!==void 0)G=N.s3_lock_continuation_token;else break}while(N.hasMore);if(E.length>0)N.step_results=wd(E);return N}catch(N){if(U=N,A===5||!DS0(N)){if(N instanceof f&&E.length>0)N.stepResults=wd(E);throw N}let T=N;if(J?.({attempt:A,maxAttempts:5,delayMs:1e4,step:T.step,error:T.message}),await new Promise((C)=>setTimeout(C,1e4)),z=!0,G!==void 0)K=!0}throw U}function wd(D){let F=new Map;for(let $ of D)F.set($.step,$);return Array.from(F.values())}var G$=S(()=>{Td();I4();K1()});function xd(D){gz=D}function hz(){return gz}function W$(D){if(gz)process.stderr.write(`${D}
|
|
106
106
|
`)}var gz=!1;var _d={};k6(_d,{runCommand:()=>w});var{spawn:FS0}=globalThis.Bun;async function w(D,F={}){let $={...process.env,GIT_TERMINAL_PROMPT:"0",...F.env};for(let W of F.unsetEnv??[])delete $[W];let Q=FS0({cmd:D,cwd:F.cwd,stdout:"pipe",stderr:"pipe",env:$}),J=!1,Y;if(F.timeout)Y=setTimeout(()=>{J=!0,Q.kill()},F.timeout);if(hz()){let W=F.cwd?` (cwd=${F.cwd})`:"";W$(H.dim(`$ ${D.join(" ")}${W}`))}let X=await new Response(Q.stdout).text(),B=await new Response(Q.stderr).text(),G=await Q.exited;if(Y)clearTimeout(Y);if(hz()){if(X.trim())W$(H.dim(X.trimEnd()));if(B.trim())W$(H.yellow(B.trimEnd()));W$(H.dim(`(exit ${G})`))}if(J)return{stdout:X,stderr:B||`Command timed out after ${Math.round(F.timeout/1000)}s`,exitCode:G??1};return{stdout:X,stderr:B,exitCode:G}}var z1=S(()=>{e0()});async function $S0(){try{let{exitCode:D,stderr:F}=await w(["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 H$(){try{let{stdout:D,exitCode:F,stderr:$}=await w(["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 LX(D){try{let{stdout:F,exitCode:$,stderr:Q}=await w(["gh","api","user","--jq",".login"]);if($!==0){if(Q.includes("not logged in")||Q.includes("auth login"))return{authenticated:!1,error:"gh CLI not authenticated. Run 'gh auth login' to authenticate."};return{authenticated:!1,error:`gh CLI error: ${Q.trim()||"unknown error"}`}}let J=F.trim();if(!J)return{authenticated:!1,error:"gh CLI returned empty username"};if(D){let Y=J.toLowerCase()===D.toLowerCase();return{authenticated:!0,username:J,matches:Y,error:Y?void 0:`gh CLI authenticated as '${J}', expected '${D}'`}}return{authenticated:!0,username:J}}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 MX(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:Q}=await w(["gh","api","/user/repository_invitations"]);if($!==0){if(Q.includes("not logged in")||Q.includes("auth login"))return{accepted:!1,error:"gh CLI not authenticated. Run 'gh auth login' to authenticate."};if(Q.includes("API rate limit")||Q.includes("403"))return{accepted:!1,error:"GitHub API rate limit exceeded. Please try again in a few minutes."};if(Q.includes("ENOENT")||Q.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: ${Q.trim()||"unknown error"}`}}let J=null;try{J=JSON.parse(F||"[]").find((W)=>W.repository.full_name===D)?.id??null}catch(B){let G=B instanceof Error?B.message:String(B);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(!J){let{exitCode:B}=await w(["gh","api",`/repos/${D}`,"--silent"]);if(B===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:X}=await w(["gh","api","--method","PATCH",`/user/repository_invitations/${J}`]);if(Y!==0)return{accepted:!1,error:`Failed to accept invitation: ${X.trim()||"unknown error"}`};return{accepted:!0}}async function s8(D,F,$="origin"){let Q=F;if(process.env.GH_TOKEN&&F.startsWith("git@github.com:")){let J=process.env.GH_TOKEN.trim();if(!J||/\s/.test(J))return{success:!1,error:"GH_TOKEN environment variable is set but appears malformed (empty or contains whitespace)"};Q=`https://github.com/${F.replace("git@github.com:","")}`,await w(["git","config","credential.https://github.com.helper",`!printf 'username=x-access-token\\npassword=${J}'`],{cwd:D})}else if(F.startsWith("git@github.com:")){let J=F.replace("git@github.com:",""),Y=await H$();if(Y.token)Q=`https://github.com/${J}`,await w(["git","config","credential.https://github.com.helper",`!printf 'username=x-access-token\\npassword=${Y.token}'`],{cwd:D});else{let X=await $S0();if(X.works)Q=F;else return{success:!1,error:`GitHub authentication not configured.
|
|
107
107
|
|
|
108
108
|
gh CLI failed: ${Y.error||"could not get token"}
|
|
@@ -374,7 +374,7 @@ Deletion summary:`)),console.log(` GitHub repo: ${Y.steps.github.success?H.gree
|
|
|
374
374
|
Warnings:`));for(let X of Y.warnings)console.log(H.yellow(` - ${X}`))}}catch(Q){s0(Q,$,"Failed to delete dataset",{403:"Published datasets can only be deleted by the NEMAR owner",404:"Dataset not found",409:"Cannot delete dataset with active publication requests"}),process.exit(1)}});_0.command("bulk-delete").description("Delete multiple phantom/orphaned datasets at once (owner only)").argument("<dataset-ids>","Comma-separated dataset IDs (e.g., nm000153,nm000154,nm000155)").option("--yes","Skip confirmation prompt").action(async(D,F)=>{if(!E0())return;let $=D.split(",").map((J)=>J.trim()).filter(Boolean);if($.length===0)console.log(H.red("No dataset IDs provided.")),process.exit(1);if(console.log(H.bold(`
|
|
375
375
|
Bulk delete: ${$.length} datasets`)),console.log(H.dim(` IDs: ${$.slice(0,10).join(", ")}${$.length>10?` ... +${$.length-10} more`:""}`)),console.log(H.yellow(`
|
|
376
376
|
Only private datasets without DOIs will be deleted.`)),!F.yes){let{proceed:J}=await t.prompt([{type:"confirm",name:"proceed",message:H.red(`Delete ${$.length} datasets? This cannot be undone.`),default:!1}]);if(!J){console.log(H.dim("Cancelled."));return}}let Q=O(`Deleting ${$.length} datasets...`).start();try{let J=await pp($);if(Q.succeed(`Bulk delete complete: ${J.deleted} deleted, ${J.failed} failed`),J.failed>0){console.log(H.yellow(`
|
|
377
|
-
Failed deletions:`));for(let Y of J.results.filter((X)=>!X.deleted))console.log(H.yellow(` ${Y.dataset_id}: ${Y.error||"unknown error"}`))}}catch(J){s0(J,Q,"Bulk delete failed",{403:"Only the NEMAR owner can bulk-delete datasets"}),process.exit(1)}});function Gn(){return zZ(import.meta.dir,"..","..","scripts","withdrawn-datasets.json")}function Wn(D,F,$,Q){if(Q){console.log(` ${H.red("error".padEnd(8))} ${F}: ${Q}`);return}if(!$)return;if(
|
|
377
|
+
Failed deletions:`));for(let Y of J.results.filter((X)=>!X.deleted))console.log(H.yellow(` ${Y.dataset_id}: ${Y.error||"unknown error"}`))}}catch(J){s0(J,Q,"Bulk delete failed",{403:"Only the NEMAR owner can bulk-delete datasets"}),process.exit(1)}});function Gn(){return zZ(import.meta.dir,"..","..","scripts","withdrawn-datasets.json")}function Wn(D,F,$,Q){if(Q){console.log(` ${H.red("error".padEnd(8))} ${F}: ${Q}`);return}if(!$)return;if("skipped"in $){console.log(` ${H.yellow("skipped".padEnd(8))} ${F}: ${$.skipped}`);return}let J=$.resumed?H.yellow(" (resumed)"):"";console.log(H.bold(` ${D}${F}${J}`));let Y=$.visibility.status==="failed"?H.red:H.green;if(console.log(` visibility: ${Y($.visibility.status)}`),$.visibility.status==="failed"){if(console.log(H.red(` stage=${$.visibility.stage}: ${$.visibility.error}`)),"githubReverted"in $.visibility){let X="s3Reverted"in $.visibility?` s3Reverted=${$.visibility.s3Reverted}`:"",B=$.visibility.revertError?` revertError=${$.visibility.revertError}`:"";console.log(H.dim(` githubReverted=${$.visibility.githubReverted}${X}${B}`))}}for(let X of $.dois){let B=X.status==="failed"?H.red:X.status==="planned"?H.yellow:H.green,G=X.kind==="version"?`version ${X.version}`:"concept";if(console.log(` ${B(X.status.padEnd(8))} ${G} -> ${X.action} ${H.dim(X.doi)}`),X.error)console.log(H.red(` ${X.error}`))}if($.warning)console.log(H.yellow(` warning: ${$.warning}`))}_0.command("withdraw").description("Withdraw a broken published dataset: make it private and tombstone its EZID DOIs (concept + every version). Dry-run by default.").argument("[ids...]","Dataset id(s) to withdraw (omit when using --all)").option("--all","Target every entry in the checked-in withdrawn-datasets list").option("--reason <reason>","Withdrawal reason (default: the list entry's own reason)").option("--execute","Actually apply the withdrawal (default is a dry run)").option("--force","Allow a dataset id that is not on the checked-in withdrawn-datasets list").option("--withdrawn-file <path>","Path to the withdrawn-datasets JSON (default: scripts/withdrawn-datasets.json)").option(k0,v0).option(h0,x0).option("--json","Output raw JSON").action(async(D,F)=>{if(!E0())return;if(D.length===0&&!F.all)console.log(H.red("Error: provide dataset id(s) or use --all")),process.exit(1);if(D.length>0&&F.all)console.log(H.red("Error: provide dataset id(s) OR --all, not both")),process.exit(1);let $=F.withdrawnFile||Gn(),Q;try{Q=mz($)}catch(W){console.error(H.red(`Failed to load withdrawn-datasets file: ${a(W)}`)),process.exit(1)}let J=F.all?{targets:Q.map((W)=>({datasetId:W.dataset_id,reason:F.reason||W.reason}))}:Fc(D,Q,{reason:F.reason,force:F.force});if("error"in J)console.error(H.red(J.error)),process.exit(1);let Y=J.targets,X=!F.execute,B=X?"[dry-run] ":"";if(!X){console.log(H.red(`
|
|
378
378
|
WARNING: this makes ${Y.length} dataset(s) private and tombstones their EZID DOIs (concept + every version).`));let W=await S0(`Execute withdrawal for ${Y.length} dataset(s)?`,F);if(W!=="confirmed"){console.log(H.dim(W==="declined"?"Skipped":"Cancelled"));return}}let G=[];for(let W of Y)try{let q=await hp(W.datasetId,{reason:W.reason,dryRun:X});G.push({dataset_id:W.datasetId,result:q})}catch(q){G.push({dataset_id:W.datasetId,error:a(q)})}if(F.json){console.log(JSON.stringify(G,null,2));return}console.log();for(let W of G)Wn(B,W.dataset_id,W.result,W.error)});_0.command("restore").description("Reverse a withdrawal: make a dataset public again and restore its EZID DOIs (concept + every version). Dry-run by default.").argument("[ids...]","Dataset id(s) to restore (omit when using --all)").option("--all","Target every entry in the checked-in withdrawn-datasets list").option("--execute","Actually apply the restore (default is a dry run)").option("--withdrawn-file <path>","Path to the withdrawn-datasets JSON (default: scripts/withdrawn-datasets.json)").option(k0,v0).option(h0,x0).option("--json","Output raw JSON").action(async(D,F)=>{if(!E0())return;if(D.length===0&&!F.all)console.log(H.red("Error: provide dataset id(s) or use --all")),process.exit(1);if(D.length>0&&F.all)console.log(H.red("Error: provide dataset id(s) OR --all, not both")),process.exit(1);let $;if(F.all){let X=F.withdrawnFile||Gn();try{$=mz(X).map((B)=>B.dataset_id)}catch(B){console.error(H.red(`Failed to load withdrawn-datasets file: ${a(B)}`)),process.exit(1)}}else $=D;let Q=!F.execute,J=Q?"[dry-run] ":"";if(!Q){console.log(H.yellow(`
|
|
379
379
|
This makes ${$.length} dataset(s) public again and restores their EZID DOIs.`));let X=await S0(`Execute restore for ${$.length} dataset(s)?`,F);if(X!=="confirmed"){console.log(H.dim(X==="declined"?"Skipped":"Cancelled"));return}}let Y=[];for(let X of $)try{let B=await up(X,{dryRun:Q});Y.push({dataset_id:X,result:B})}catch(B){Y.push({dataset_id:X,error:a(B)})}if(F.json){console.log(JSON.stringify(Y,null,2));return}console.log();for(let X of Y)Wn(J,X.dataset_id,X.result,X.error)});_0.command("import-openneuro").description("Import an OpenNeuro dataset into NEMAR").argument("<openneuro-ids>","OpenNeuro dataset ID(s), comma-separated (e.g., ds007262,ds007263)").option("--local","Run import locally instead of dispatching GitHub Actions workflow").option("--dir <path>","Working directory for local clone (requires --local)").option("--skip-data","Skip S3 data copy, metadata only (requires --local)").option("--trust-upstream","If BIDS validation does not register within the bounded poll, fall back to skip_ci_check=true at approval. OpenNeuro data is pre-validated upstream so this is the recommended setting for OpenNeuro imports (#431).").option("--phase <phase>","Run a single import phase in-process (prepare|copy|finalize) for the sharded CI workflow. State passes between phases via S3 staging. Implies in-process execution.").option("--shard <i/N>","Copy-phase only: process shard i of N (0-indexed), e.g. 0/8. Required with --phase copy.").action(async(D,F)=>{if(!E0())return;let $=D.split(",").map((X)=>X.trim()).filter(Boolean);for(let X of $)if(!/^ds\d{6}$/.test(X))console.error(H.red(`Invalid OpenNeuro ID "${X}". Expected format: ds###### (e.g., ds007262)`)),process.exit(1);if((F.dir||F.skipData)&&!F.local&&!F.phase)console.error(H.red("--dir and --skip-data require --local or --phase")),process.exit(1);if(F.phase){if(!["prepare","copy","finalize"].includes(F.phase))console.error(H.red(`Invalid --phase "${F.phase}". Expected prepare|copy|finalize.`)),process.exit(1);if($.length>1)console.error(H.red("--phase only supports a single dataset ID")),process.exit(1);if(F.shard&&F.phase!=="copy")console.error(H.red("--shard is only valid with --phase copy")),process.exit(1);if(F.phase==="copy"&&!F.shard)console.error(H.red("--phase copy requires --shard i/N (e.g. --shard 0/8)")),process.exit(1);let{prepareImport:B,copyShard:G,finalizeImport:W}=await Promise.resolve().then(() => (yX(),QZ)),{parseShardArg:q}=await Promise.resolve().then(() => (kX(),Lc)),K={workDir:F.dir,skipData:F.skipData,trustUpstream:F.trustUpstream,persistStaging:!0};try{if(F.phase==="prepare")await B($[0],K);else if(F.phase==="copy")await G($[0],q(F.shard),K);else await W($[0],K)}catch(Z){let z=Z instanceof Error?Z.message:String(Z);console.error(H.red(`
|
|
380
380
|
[${F.phase}] failed: ${z}`)),process.exit(1)}return}if(F.local){if($.length>1)console.error(H.red("--local only supports a single dataset ID")),process.exit(1);let{importOpenNeuro:X}=await Promise.resolve().then(() => (yX(),QZ));try{await X($[0],{workDir:F.dir,skipData:F.skipData,trustUpstream:F.trustUpstream})}catch(B){let G=B instanceof Error?B.message:String(B);console.error(H.red(`
|
package/package.json
CHANGED