nemar-cli 0.10.28-PR2113.0f67efa → 0.10.28-PR2113.e415fcc
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/git-annex-remote-nemar.js +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -23,7 +23,7 @@ ${t}`,HM,BM,WM=(e,t,r)=>{let n=r===""?"":`with ${r.trim()}() `,s=KM.bind(null,n,
|
|
|
23
23
|
`)}var Fl=!1;var{spawn:JF}=globalThis.Bun;function Vl(e,t=[]){let r=e.replace(QF,'("$1","<redacted>")');for(let n of t)if(n.length>=ZF)r=r.split(n).join("<redacted>");return r}function tV(e){let t=["AWS_SESSION_TOKEN","AWS_SECRET_ACCESS_KEY","AWS_ACCESS_KEY_ID"],r=new Set;for(let n of[process.env,e??{}])for(let s of t){let o=n[s];if(typeof o==="string"&&o.length>0)r.add(o)}return[...r]}async function hw(e,t){let r=e.getReader(),n=new TextDecoder,s="";while(!0){let{done:o,value:i}=await r.read();if(o)break;if(i.byteLength===0)continue;t(),s+=n.decode(i,{stream:!0})}return s+n.decode()}async function mw(e,t={}){let r={...process.env,GIT_TERMINAL_PROMPT:"0",...t.env};for(let y of t.unsetEnv??[])delete r[y];let n=JF({cmd:e,cwd:t.cwd,...t.stdin===void 0?{}:{stdin:new TextEncoder().encode(t.stdin)},stdout:"pipe",stderr:"pipe",env:r}),s=!1,o,i,a=performance.now(),c=()=>{if(i!==void 0)clearTimeout(i),i=void 0},u=()=>{if(!t.onInactivityWarning)return;c(),i=setTimeout(()=>{i=void 0;try{t.onInactivityWarning?.(performance.now()-a)}catch{console.error("Could not display subprocess inactivity warning; the child result is unaffected.")}},t.inactivityWarningAfterMs??eV)};if(u(),t.timeout)o=setTimeout(()=>{s=!0,c(),n.kill()},t.timeout);let l=ic()?[...tV(r),...t.redact??[]]:[];if(ic()){let y=t.cwd?` (cwd=${t.cwd})`:"";Ms(It.dim(Vl(`$ ${e.join(" ")}${y}`,l)))}let d=()=>{a=performance.now(),u()},h,f,p,m=n.exited.then((y)=>(c(),y));try{[h,f,p]=await Promise.all([hw(n.stdout,d),hw(n.stderr,d),m])}finally{if(c(),o)clearTimeout(o)}if(ic()){if(t.sensitiveOutput)Ms(It.dim("[sensitive subprocess output suppressed]"));else{if(h.trim())Ms(It.dim(Vl(h.trimEnd(),l)));if(f.trim())Ms(It.yellow(Vl(f.trimEnd(),l)))}Ms(It.dim(`(exit ${p})`))}if(s)return{stdout:h,stderr:f||`Command timed out after ${Math.round(t.timeout/1000)}s`,exitCode:p??1,timedOut:!0};return{stdout:h,stderr:f,exitCode:p,timedOut:!1}}var QF,ZF=8,eV=120000;var gw=F(()=>{Ul();QF=/\(\s*"((?:x-amz-)[^"]*|authorization|proxy-authorization)"\s*,\s*"[^"]*"\s*\)/gi});function nV(){if(process.platform==="darwin")return"macos";if(process.platform==="win32")return"windows";return"linux"}function _w(e,t=nV()){return e.installInstructions[t]}function sV(e){let t=e.match(/(\d+\.\d+(?:\.\d+)?)/);return t?t[1]:void 0}function iV(){let e=Number(process.env.TEST_PROBE_TIMEOUT_MS);return Number.isFinite(e)&&e>0?e:oV}async function vw(e){try{let{exitCode:t,stdout:r,timedOut:n}=await mw(e.cmd,{timeout:iV()});if(n)return{available:!1,timedOut:!0};if(t!==0)return{available:!1};return{available:!0,version:sV(r)}}catch(t){let r=t instanceof Error?t.message:String(t);if(!r.includes("ENOENT")&&!r.includes("not found"))console.error(` Warning: ${e.name} check failed unexpectedly: ${r}`);return{available:!1}}}async function zl(){let e=Object.entries(yw);return Promise.all(e.map(async([t,r])=>{let{available:n,version:s,timedOut:o}=await vw(r);return{key:t,name:r.name,purpose:r.purpose,required:r.required,available:n,version:s,timedOut:o,installInstruction:_w(r)}}))}async function oB(){let t=(await zl()).filter((r)=>r.required&&!r.available);if(t.length===0)return[];console.warn(`
|
|
24
24
|
Heads up: some tools NEMAR needs for uploading/validating aren't installed yet:`);for(let r of t)console.warn(` - ${r.name} (${r.purpose})`),console.warn(` Install: ${r.installInstruction}`);return console.warn("Run `nemar doctor` anytime to re-check. You can finish signup without them.\n"),t}async function iB(e){let r=rV[e].map((i)=>yw[i]).filter(Boolean),n=await Promise.all(r.map(async(i)=>{let a=await vw(i);return{check:i,available:a.available,timedOut:a.timedOut}}));for(let i of n)if(i.timedOut&&i.check.required)console.warn(`Warning: ${i.check.name} did not respond to a version check in time; continuing anyway.`);let s=n.filter((i)=>!i.available&&!i.timedOut&&i.check.required).map((i)=>({tool:i.check.name,installInstruction:_w(i.check)}));if(s.length===0)return;let o=[`
|
|
25
25
|
Missing required tools:`];for(let i of s)o.push(` ${i.tool} not installed`),o.push(` Install: ${i.installInstruction}`);throw Error(o.join(`
|
|
26
|
-
`))}var yw,rV,oV=4000;var $w=F(()=>{gw();yw={git:{name:"git",purpose:"version control for dataset metadata",cmd:["git","--version"],required:!0,installInstructions:{macos:"brew install git (or install Xcode Command Line Tools)",linux:"sudo apt-get install git OR sudo dnf install git",windows:"winget install Git.Git (or https://git-scm.com/download/win)"}},"git-annex":{name:"git-annex",purpose:"large-file data transfer (upload/download)",cmd:["git-annex","version"],required:!0,installInstructions:{macos:"brew install git-annex",linux:"sudo apt-get install git-annex OR sudo dnf install git-annex",windows:"Download the installer from https://git-annex.branchable.com/install/Windows/"}},gh:{name:"GitHub CLI (gh)",purpose:"GitHub authentication + repository operations",cmd:["gh","--version"],required:!0,installInstructions:{macos:"brew install gh",linux:"See https://cli.github.com/manual/installation",windows:"winget install GitHub.cli (or: scoop install gh)"}},aws:{name:"AWS CLI",purpose:"S3 data upload/download",cmd:["aws","--version"],required:!0,installInstructions:{macos:"brew install awscli",linux:"pip install awscli OR sudo snap install aws-cli --classic",windows:"winget install Amazon.AWSCLI (or the MSI from https://aws.amazon.com/cli/)"}},deno:{name:"Deno",purpose:"BIDS validation",cmd:["deno","--version"],required:!0,installInstructions:{macos:"brew install deno (or: curl -fsSL https://deno.land/install.sh | sh)",linux:"curl -fsSL https://deno.land/install.sh | sh",windows:"winget install DenoLand.Deno (or: irm https://deno.land/install.ps1 | iex)"}}},rV={upload:["git-annex","gh","aws","deno"],download:["gh"],clone:["git","gh"],push:["git-annex","gh"],publish:["gh","aws"],update:["git","gh"],release:["git","gh"]}});var Ew;var bw=F(()=>{Ew={name:"nemar-cli",packageManager:"bun@1.4.3",version:"0.10.28-PR2113.
|
|
26
|
+
`))}var yw,rV,oV=4000;var $w=F(()=>{gw();yw={git:{name:"git",purpose:"version control for dataset metadata",cmd:["git","--version"],required:!0,installInstructions:{macos:"brew install git (or install Xcode Command Line Tools)",linux:"sudo apt-get install git OR sudo dnf install git",windows:"winget install Git.Git (or https://git-scm.com/download/win)"}},"git-annex":{name:"git-annex",purpose:"large-file data transfer (upload/download)",cmd:["git-annex","version"],required:!0,installInstructions:{macos:"brew install git-annex",linux:"sudo apt-get install git-annex OR sudo dnf install git-annex",windows:"Download the installer from https://git-annex.branchable.com/install/Windows/"}},gh:{name:"GitHub CLI (gh)",purpose:"GitHub authentication + repository operations",cmd:["gh","--version"],required:!0,installInstructions:{macos:"brew install gh",linux:"See https://cli.github.com/manual/installation",windows:"winget install GitHub.cli (or: scoop install gh)"}},aws:{name:"AWS CLI",purpose:"S3 data upload/download",cmd:["aws","--version"],required:!0,installInstructions:{macos:"brew install awscli",linux:"pip install awscli OR sudo snap install aws-cli --classic",windows:"winget install Amazon.AWSCLI (or the MSI from https://aws.amazon.com/cli/)"}},deno:{name:"Deno",purpose:"BIDS validation",cmd:["deno","--version"],required:!0,installInstructions:{macos:"brew install deno (or: curl -fsSL https://deno.land/install.sh | sh)",linux:"curl -fsSL https://deno.land/install.sh | sh",windows:"winget install DenoLand.Deno (or: irm https://deno.land/install.ps1 | iex)"}}},rV={upload:["git-annex","gh","aws","deno"],download:["gh"],clone:["git","gh"],push:["git-annex","gh"],publish:["gh","aws"],update:["git","gh"],release:["git","gh"]}});var Ew;var bw=F(()=>{Ew={name:"nemar-cli",packageManager:"bun@1.4.3",version:"0.10.28-PR2113.e415fcc",description:"CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",type:"module",main:"dist/index.js",bin:{nemar:"dist/index.js","git-annex-remote-nemar":"dist/git-annex-remote-nemar.js"},scripts:{dev:"bun run src/index.ts",build:"bun build src/index.ts src/git-annex-remote-nemar.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:scrub":"biome check scripts/scrub shared/identifier-scrub.ts test/scrub","test:scrub":"bun test --preload ./test/scrub/helpers/temp-dirs-preload.ts --path-ignore-patterns='__run_every_scrub_suite__' test/scrub test/identifier-scan.test.ts test/identifier-scrub.test.ts test/identifier-dates.test.ts test/identifier-fleet.test.ts","migrations:d1-check":"bun run scripts/d1-migration-check.ts","zarr:geometry-check":"bun run backend/scripts/zarr-geometry-conformance.ts","lint:fix":"biome check --fix src/",format:"biome format --write src/",typecheck:"tsc --noEmit && tsc --noEmit -p backend","generate-openapi":"bun run scripts/generate-openapi.ts",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","scripts/recover-datasets.json","scripts/withdrawn-datasets.json","README.md","LICENSE"],dependencies:{chalk:"^5.3.0",commander:"^12.1.0",conf:"^13.0.1",inquirer:"^9.2.15",ora:"^8.0.1",semver:"^7.8.5",zod:"^3.23.8"},"lint-staged":{"src/**/*.{ts,tsx}":["biome check --fix"],"backend/src/**/*.{ts,tsx}":["biome check --fix"]},trustedDependencies:["@biomejs/biome"],devDependencies:{"@anthropic-ai/sdk":"^0.132.1","@asteasolutions/zod-to-openapi":"^7.3.4","@biomejs/biome":"1.9.4","@types/bun":"latest","@types/inquirer":"^9.0.7","@types/semver":"^7.8.0",ajv:"^8.20.0","ajv-formats":"^3.0.1",husky:"^9.1.7",jose:"6.2.12","lint-staged":"^16.3.2",oauth4webapi:"3.8.8","openid-client":"6.8.9",typescript:"^5.5.4",wrangler:"^4.70.0",yaml:"^2.8.4"}}});var ac;var Gl=F(()=>{bw();ac=Ew.version});import{mkdirSync as cV,readdirSync as uV,unlinkSync as lV,writeFileSync as dV}from"fs";import{join as Kl}from"path";function yB(){Ls=!0}function lc(){return Ls}function _B(e,t=process.env){return e.includes("--debug")||t.NEMAR_DEBUG==="1"}function vB(e){Tw=e,mr(`Step: ${e}`)}function $B(){xw=!0}function bB(){return xw}function EB(){if(Rw)return;Bl=!0}function wB(){Bl=!1,Rw=!0}function SB(){return Bl}function mr(e){if(Ls)process.stderr.write(`[debug] ${e}
|
|
27
27
|
`)}function mV(e){let t={};for(let[r,n]of Object.entries(e))t[r]=hV.has(r.toLowerCase())?"[REDACTED]":n;return t}function Ow(e){let t=e.indexOf("@");if(t<=0)return"***";return`${e[0]}***${e.slice(t)}`}function Hl(e,t,r=0){if(r>yV)return"[REDACTED: depth]";if(Array.isArray(t))return t.map((n)=>Hl(e,n,r+1));if(t&&typeof t==="object"){let n={};for(let[s,o]of Object.entries(t))n[s]=Hl(s,o,r+1);return n}if(typeof t==="string"){if(gV.test(e))return"[REDACTED]";return t.replace(kw,Ow)}return t}function Wl(e){return e.replace(_V,"Bearer [REDACTED]").replace(vV,"[REDACTED_AWS_KEY]").replace($V,"$1[REDACTED]").replace(bV,"$1$2=[REDACTED]").replace(kw,Ow)}function EV(e){return Wl(e)}function ww(e,t=pV){if(e===void 0)return;let r=e;try{let n=JSON.parse(e);r=JSON.stringify(Hl("",n))}catch{}if(r=Wl(r),Buffer.byteLength(r,"utf8")>t)r=`${Buffer.from(r,"utf8").subarray(0,t).toString("utf8")}... [truncated]`;return r}function dc(e){if(!Ls)return;let t=EV(e.url);try{let r={...e,url:t,requestHeaders:e.requestHeaders?mV(e.requestHeaders):void 0,requestBody:ww(e.requestBody),responseBody:ww(e.responseBody)};uc.push(r),mr(`${e.method} ${t} -> ${e.status??"ERROR"} (${e.durationMs}ms)`)}catch(r){let n=pr(r);uc.push({method:e.method,url:t,status:e.status,durationMs:e.durationMs,note:`redaction failed: ${n}`}),mr(`redaction failed for ${e.method} ${t}: ${n}`)}}async function wV(){let e=[];try{let t=process.versions.bun?`Bun ${process.versions.bun}`:`Node ${process.version}`;e.push(`CLI version: ${ac}`),e.push(`OS/Arch: ${process.platform}/${process.arch}`),e.push(`Runtime: ${t}`)}catch(t){e.push(`(could not read CLI/OS/runtime info: ${pr(t)})`)}e.push(""),e.push("Active account:");try{let t=vn();if(t.apiKey){if(t.username)e.push(` Username: ${t.username}`);if(e.push(` API URL: ${t.apiUrl}`),t.role)e.push(` Role: ${t.role}`);e.push(` Sandbox completed: ${!!t.sandboxCompleted}`)}else e.push(" (not authenticated)")}catch(t){e.push(` (could not read account config: ${pr(t)})`)}e.push(""),e.push("External tools:");try{let t=await zl();for(let r of t){let n=r.available?r.version??"installed":r.timedOut?"(timed out)":"not installed";e.push(` ${r.name}: ${n}`)}}catch(t){e.push(` (could not probe external tools: ${pr(t)})`)}return e}async function SV(){return(await wV()).join(`
|
|
28
28
|
`)}async function xB(){if(!Ls||cc!==void 0)return;try{cc=await SV()}catch(e){let t=pr(e);cc=`(could not build environment report: ${t})`,mr(`environment snapshot failed: ${t}`)}}function Aw(e){if(Sw.has(e))return{flag:e};for(let t of Sw){if(!e.startsWith(t)||e.length<=t.length)continue;if(t.length===2)return{flag:t,kind:"short-attached"};if(e[t.length]==="=")return{flag:t,kind:"long-eq"}}return null}function xV(e){let t=[];for(let r=0;r<e.length;r++){let n=e[r],s=Aw(n);if(!s){t.push(n);continue}if(s.kind==="long-eq")t.push(`${s.flag}=[REDACTED]`);else if(s.kind==="short-attached")t.push(`${s.flag}[REDACTED]`);else if(t.push(n),r+1<e.length)t.push("[REDACTED]"),r++}return t}function RV(e){let t=[];for(let r=0;r<e.length;r++){let n=e[r],s=Aw(n);if(!s){t.push(n);continue}if(!s.kind&&r+1<e.length)r++}return t}function TV(e){let t=[];for(let n of RV(e)){if(n.startsWith("-"))continue;if(t.push(n),t.length===2)break}return(t.length>0?t.join("-"):"nemar").replace(/[^a-zA-Z0-9_-]/g,"_")}function kV(e,t){let r=[];if(r.push("NEMAR CLI Debug Log"),r.push(`Generated: ${new Date().toISOString()}`),r.push(`Command: nemar ${Wl(xV(e).join(" "))}`),r.push(""),r.push(cc??"(environment snapshot unavailable)"),r.push(""),r.push("HTTP requests:"),uc.length===0)r.push(" (none)");else uc.forEach((n,s)=>{if(r.push(` [${s+1}] ${n.method} ${n.url} -> ${n.status??"ERROR"} (${n.durationMs}ms)`),n.error)r.push(` Error: ${n.error}`);if(n.note)r.push(` Note: ${n.note}`);if(n.requestHeaders)r.push(` Request headers: ${JSON.stringify(n.requestHeaders)}`);if(n.requestBody)r.push(` Request body: ${n.requestBody}`);if(n.responseBody)r.push(` Response body: ${n.responseBody}`)});return r.push(""),r.push(`Failing step: ${Tw??"(none recorded)"}`),r.push(`Exit code: ${t}`),`${r.join(`
|
|
29
29
|
`)}
|
package/dist/index.js
CHANGED
|
@@ -99,7 +99,7 @@ ${t}`,Eet,ket,Ret=(e,t,n)=>{let r=n===""?"":`with ${n.trim()}() `,o=vet.bind(nul
|
|
|
99
99
|
`)}var GM=!1;var{spawn:lxt}=globalThis.Bun;function Ap(e,t=[]){let n=e.replace(uxt,'("$1","<redacted>")');for(let r of t)if(r.length>=dxt)n=n.split(r).join("<redacted>");return n}function b$(e){let t=["AWS_SESSION_TOKEN","AWS_SECRET_ACCESS_KEY","AWS_ACCESS_KEY_ID"],n=new Set;for(let r of[process.env,e??{}])for(let o of t){let s=r[o];if(typeof s==="string"&&s.length>0)n.add(s)}return[...n]}async function uye(e,t){let n=e.getReader(),r=new TextDecoder,o="";while(!0){let{done:s,value:i}=await n.read();if(s)break;if(i.byteLength===0)continue;t(),o+=r.decode(i,{stream:!0})}return o+r.decode()}async function O(e,t={}){let n={...process.env,GIT_TERMINAL_PROMPT:"0",...t.env};for(let y of t.unsetEnv??[])delete n[y];let r=lxt({cmd:e,cwd:t.cwd,...t.stdin===void 0?{}:{stdin:new TextEncoder().encode(t.stdin)},stdout:"pipe",stderr:"pipe",env:n}),o=!1,s,i,a=performance.now(),c=()=>{if(i!==void 0)clearTimeout(i),i=void 0},l=()=>{if(!t.onInactivityWarning)return;c(),i=setTimeout(()=>{i=void 0;try{t.onInactivityWarning?.(performance.now()-a)}catch{console.error("Could not display subprocess inactivity warning; the child result is unaffected.")}},t.inactivityWarningAfterMs??fxt)};if(l(),t.timeout)s=setTimeout(()=>{o=!0,c(),r.kill()},t.timeout);let d=iy()?[...b$(n),...t.redact??[]]:[];if(iy()){let y=t.cwd?` (cwd=${t.cwd})`:"";Kd(u.dim(Ap(`$ ${e.join(" ")}${y}`,d)))}let f=()=>{a=performance.now(),l()},p,m,h,g=r.exited.then((y)=>(c(),y));try{[p,m,h]=await Promise.all([uye(r.stdout,f),uye(r.stderr,f),g])}finally{if(c(),s)clearTimeout(s)}if(iy()){if(t.sensitiveOutput)Kd(u.dim("[sensitive subprocess output suppressed]"));else{if(p.trim())Kd(u.dim(Ap(p.trimEnd(),d)));if(m.trim())Kd(u.yellow(Ap(m.trimEnd(),d)))}Kd(u.dim(`(exit ${h})`))}if(o)return{stdout:p,stderr:m||`Command timed out after ${Math.round(t.timeout/1000)}s`,exitCode:h??1,timedOut:!0};return{stdout:p,stderr:m,exitCode:h,timedOut:!1}}var uxt,dxt=8,fxt=120000;var Jt=H(()=>{Ue();uxt=/\(\s*"((?:x-amz-)[^"]*|authorization|proxy-authorization)"\s*,\s*"[^"]*"\s*\)/gi});function mxt(){if(process.platform==="darwin")return"macos";if(process.platform==="win32")return"windows";return"linux"}function fye(e,t=mxt()){return e.installInstructions[t]}function hxt(e){let t=e.match(/(\d+\.\d+(?:\.\d+)?)/);return t?t[1]:void 0}function yxt(){let e=Number(process.env.TEST_PROBE_TIMEOUT_MS);return Number.isFinite(e)&&e>0?e:gxt}async function pye(e){try{let{exitCode:t,stdout:n,timedOut:r}=await O(e.cmd,{timeout:yxt()});if(r)return{available:!1,timedOut:!0};if(t!==0)return{available:!1};return{available:!0,version:hxt(n)}}catch(t){let n=t instanceof Error?t.message:String(t);if(!n.includes("ENOENT")&&!n.includes("not found"))console.error(` Warning: ${e.name} check failed unexpectedly: ${n}`);return{available:!1}}}async function t_(){let e=Object.entries(dye);return Promise.all(e.map(async([t,n])=>{let{available:r,version:o,timedOut:s}=await pye(n);return{key:t,name:n.name,purpose:n.purpose,required:n.required,available:r,version:o,timedOut:s,installInstruction:fye(n)}}))}async function mye(){let t=(await t_()).filter((n)=>n.required&&!n.available);if(t.length===0)return[];console.warn(`
|
|
100
100
|
Heads up: some tools NEMAR needs for uploading/validating aren't installed yet:`);for(let n of t)console.warn(` - ${n.name} (${n.purpose})`),console.warn(` Install: ${n.installInstruction}`);return console.warn("Run `nemar doctor` anytime to re-check. You can finish signup without them.\n"),t}async function Op(e){let n=pxt[e].map((i)=>dye[i]).filter(Boolean),r=await Promise.all(n.map(async(i)=>{let a=await pye(i);return{check:i,available:a.available,timedOut:a.timedOut}}));for(let i of r)if(i.timedOut&&i.check.required)console.warn(`Warning: ${i.check.name} did not respond to a version check in time; continuing anyway.`);let o=r.filter((i)=>!i.available&&!i.timedOut&&i.check.required).map((i)=>({tool:i.check.name,installInstruction:fye(i.check)}));if(o.length===0)return;let s=[`
|
|
101
101
|
Missing required tools:`];for(let i of o)s.push(` ${i.tool} not installed`),s.push(` Install: ${i.installInstruction}`);throw Error(s.join(`
|
|
102
|
-
`))}var dye,pxt,gxt=4000;var n_=H(()=>{Jt();dye={git:{name:"git",purpose:"version control for dataset metadata",cmd:["git","--version"],required:!0,installInstructions:{macos:"brew install git (or install Xcode Command Line Tools)",linux:"sudo apt-get install git OR sudo dnf install git",windows:"winget install Git.Git (or https://git-scm.com/download/win)"}},"git-annex":{name:"git-annex",purpose:"large-file data transfer (upload/download)",cmd:["git-annex","version"],required:!0,installInstructions:{macos:"brew install git-annex",linux:"sudo apt-get install git-annex OR sudo dnf install git-annex",windows:"Download the installer from https://git-annex.branchable.com/install/Windows/"}},gh:{name:"GitHub CLI (gh)",purpose:"GitHub authentication + repository operations",cmd:["gh","--version"],required:!0,installInstructions:{macos:"brew install gh",linux:"See https://cli.github.com/manual/installation",windows:"winget install GitHub.cli (or: scoop install gh)"}},aws:{name:"AWS CLI",purpose:"S3 data upload/download",cmd:["aws","--version"],required:!0,installInstructions:{macos:"brew install awscli",linux:"pip install awscli OR sudo snap install aws-cli --classic",windows:"winget install Amazon.AWSCLI (or the MSI from https://aws.amazon.com/cli/)"}},deno:{name:"Deno",purpose:"BIDS validation",cmd:["deno","--version"],required:!0,installInstructions:{macos:"brew install deno (or: curl -fsSL https://deno.land/install.sh | sh)",linux:"curl -fsSL https://deno.land/install.sh | sh",windows:"winget install DenoLand.Deno (or: irm https://deno.land/install.ps1 | iex)"}}},pxt={upload:["git-annex","gh","aws","deno"],download:["gh"],clone:["git","gh"],push:["git-annex","gh"],publish:["gh","aws"],update:["git","gh"],release:["git","gh"]}});var gye;var hye=H(()=>{gye={name:"nemar-cli",packageManager:"bun@1.4.3",version:"0.10.28-PR2113.
|
|
102
|
+
`))}var dye,pxt,gxt=4000;var n_=H(()=>{Jt();dye={git:{name:"git",purpose:"version control for dataset metadata",cmd:["git","--version"],required:!0,installInstructions:{macos:"brew install git (or install Xcode Command Line Tools)",linux:"sudo apt-get install git OR sudo dnf install git",windows:"winget install Git.Git (or https://git-scm.com/download/win)"}},"git-annex":{name:"git-annex",purpose:"large-file data transfer (upload/download)",cmd:["git-annex","version"],required:!0,installInstructions:{macos:"brew install git-annex",linux:"sudo apt-get install git-annex OR sudo dnf install git-annex",windows:"Download the installer from https://git-annex.branchable.com/install/Windows/"}},gh:{name:"GitHub CLI (gh)",purpose:"GitHub authentication + repository operations",cmd:["gh","--version"],required:!0,installInstructions:{macos:"brew install gh",linux:"See https://cli.github.com/manual/installation",windows:"winget install GitHub.cli (or: scoop install gh)"}},aws:{name:"AWS CLI",purpose:"S3 data upload/download",cmd:["aws","--version"],required:!0,installInstructions:{macos:"brew install awscli",linux:"pip install awscli OR sudo snap install aws-cli --classic",windows:"winget install Amazon.AWSCLI (or the MSI from https://aws.amazon.com/cli/)"}},deno:{name:"Deno",purpose:"BIDS validation",cmd:["deno","--version"],required:!0,installInstructions:{macos:"brew install deno (or: curl -fsSL https://deno.land/install.sh | sh)",linux:"curl -fsSL https://deno.land/install.sh | sh",windows:"winget install DenoLand.Deno (or: irm https://deno.land/install.ps1 | iex)"}}},pxt={upload:["git-annex","gh","aws","deno"],download:["gh"],clone:["git","gh"],push:["git-annex","gh"],publish:["gh","aws"],update:["git","gh"],release:["git","gh"]}});var gye;var hye=H(()=>{gye={name:"nemar-cli",packageManager:"bun@1.4.3",version:"0.10.28-PR2113.e415fcc",description:"CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",type:"module",main:"dist/index.js",bin:{nemar:"dist/index.js","git-annex-remote-nemar":"dist/git-annex-remote-nemar.js"},scripts:{dev:"bun run src/index.ts",build:"bun build src/index.ts src/git-annex-remote-nemar.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:scrub":"biome check scripts/scrub shared/identifier-scrub.ts test/scrub","test:scrub":"bun test --preload ./test/scrub/helpers/temp-dirs-preload.ts --path-ignore-patterns='__run_every_scrub_suite__' test/scrub test/identifier-scan.test.ts test/identifier-scrub.test.ts test/identifier-dates.test.ts test/identifier-fleet.test.ts","migrations:d1-check":"bun run scripts/d1-migration-check.ts","zarr:geometry-check":"bun run backend/scripts/zarr-geometry-conformance.ts","lint:fix":"biome check --fix src/",format:"biome format --write src/",typecheck:"tsc --noEmit && tsc --noEmit -p backend","generate-openapi":"bun run scripts/generate-openapi.ts",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","scripts/recover-datasets.json","scripts/withdrawn-datasets.json","README.md","LICENSE"],dependencies:{chalk:"^5.3.0",commander:"^12.1.0",conf:"^13.0.1",inquirer:"^9.2.15",ora:"^8.0.1",semver:"^7.8.5",zod:"^3.23.8"},"lint-staged":{"src/**/*.{ts,tsx}":["biome check --fix"],"backend/src/**/*.{ts,tsx}":["biome check --fix"]},trustedDependencies:["@biomejs/biome"],devDependencies:{"@anthropic-ai/sdk":"^0.132.1","@asteasolutions/zod-to-openapi":"^7.3.4","@biomejs/biome":"1.9.4","@types/bun":"latest","@types/inquirer":"^9.0.7","@types/semver":"^7.8.0",ajv:"^8.20.0","ajv-formats":"^3.0.1",husky:"^9.1.7",jose:"6.2.12","lint-staged":"^16.3.2",oauth4webapi:"3.8.8","openid-client":"6.8.9",typescript:"^5.5.4",wrangler:"^4.70.0",yaml:"^2.8.4"}}});var qs;var Tp=H(()=>{hye();qs=gye.version});import{mkdirSync as wxt,readdirSync as _xt,unlinkSync as xxt,writeFileSync as vxt}from"fs";import{join as VM}from"path";function vye(){ay=!0}function Bl(){return ay}function Eye(e,t=process.env){return e.includes("--debug")||t.NEMAR_DEBUG==="1"}function o_(e){xye=e,Fn(`Step: ${e}`)}function Jo(){wye=!0}function Sye(){return wye}function de(){if(_ye)return;KM=!0}function Jd(){KM=!1,_ye=!0}function kye(){return KM}function Fn(e){if(ay)process.stderr.write(`[debug] ${e}
|
|
103
103
|
`)}function Rxt(e){let t={};for(let[n,r]of Object.entries(e))t[n]=kxt.has(n.toLowerCase())?"[REDACTED]":r;return t}function $ye(e){let t=e.indexOf("@");if(t<=0)return"***";return`${e[0]}***${e.slice(t)}`}function WM(e,t,n=0){if(n>Dxt)return"[REDACTED: depth]";if(Array.isArray(t))return t.map((r)=>WM(e,r,n+1));if(t&&typeof t==="object"){let r={};for(let[o,s]of Object.entries(t))r[o]=WM(o,s,n+1);return r}if(typeof t==="string"){if($xt.test(e))return"[REDACTED]";return t.replace(Rye,$ye)}return t}function JM(e){return e.replace(Cxt,"Bearer [REDACTED]").replace(Axt,"[REDACTED_AWS_KEY]").replace(Oxt,"$1[REDACTED]").replace(Txt,"$1$2=[REDACTED]").replace(Rye,$ye)}function Pxt(e){return JM(e)}function yye(e,t=Sxt){if(e===void 0)return;let n=e;try{let r=JSON.parse(e);n=JSON.stringify(WM("",r))}catch{}if(n=JM(n),Buffer.byteLength(n,"utf8")>t)n=`${Buffer.from(n,"utf8").subarray(0,t).toString("utf8")}... [truncated]`;return n}function x$(e){if(!ay)return;let t=Pxt(e.url);try{let n={...e,url:t,requestHeaders:e.requestHeaders?Rxt(e.requestHeaders):void 0,requestBody:yye(e.requestBody),responseBody:yye(e.responseBody)};_$.push(n),Fn(`${e.method} ${t} -> ${e.status??"ERROR"} (${e.durationMs}ms)`)}catch(n){let r=W(n);_$.push({method:e.method,url:t,status:e.status,durationMs:e.durationMs,note:`redaction failed: ${r}`}),Fn(`redaction failed for ${e.method} ${t}: ${r}`)}}async function Nxt(){let e=[];try{let t=process.versions.bun?`Bun ${process.versions.bun}`:`Node ${process.version}`;e.push(`CLI version: ${qs}`),e.push(`OS/Arch: ${process.platform}/${process.arch}`),e.push(`Runtime: ${t}`)}catch(t){e.push(`(could not read CLI/OS/runtime info: ${W(t)})`)}e.push(""),e.push("Active account:");try{let t=Wt();if(t.apiKey){if(t.username)e.push(` Username: ${t.username}`);if(e.push(` API URL: ${t.apiUrl}`),t.role)e.push(` Role: ${t.role}`);e.push(` Sandbox completed: ${!!t.sandboxCompleted}`)}else e.push(" (not authenticated)")}catch(t){e.push(` (could not read account config: ${W(t)})`)}e.push(""),e.push("External tools:");try{let t=await t_();for(let n of t){let r=n.available?n.version??"installed":n.timedOut?"(timed out)":"not installed";e.push(` ${n.name}: ${r}`)}}catch(t){e.push(` (could not probe external tools: ${W(t)})`)}return e}async function YM(){return(await Nxt()).join(`
|
|
104
104
|
`)}async function Dye(){if(!ay||w$!==void 0)return;try{w$=await YM()}catch(e){let t=W(e);w$=`(could not build environment report: ${t})`,Fn(`environment snapshot failed: ${t}`)}}function Cye(e){if(bye.has(e))return{flag:e};for(let t of bye){if(!e.startsWith(t)||e.length<=t.length)continue;if(t.length===2)return{flag:t,kind:"short-attached"};if(e[t.length]==="=")return{flag:t,kind:"long-eq"}}return null}function Ixt(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n],o=Cye(r);if(!o){t.push(r);continue}if(o.kind==="long-eq")t.push(`${o.flag}=[REDACTED]`);else if(o.kind==="short-attached")t.push(`${o.flag}[REDACTED]`);else if(t.push(r),n+1<e.length)t.push("[REDACTED]"),n++}return t}function Fxt(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n],o=Cye(r);if(!o){t.push(r);continue}if(!o.kind&&n+1<e.length)n++}return t}function Mxt(e){let t=[];for(let r of Fxt(e)){if(r.startsWith("-"))continue;if(t.push(r),t.length===2)break}return(t.length>0?t.join("-"):"nemar").replace(/[^a-zA-Z0-9_-]/g,"_")}function jxt(e,t){let n=[];if(n.push("NEMAR CLI Debug Log"),n.push(`Generated: ${new Date().toISOString()}`),n.push(`Command: nemar ${JM(Ixt(e).join(" "))}`),n.push(""),n.push(w$??"(environment snapshot unavailable)"),n.push(""),n.push("HTTP requests:"),_$.length===0)n.push(" (none)");else _$.forEach((r,o)=>{if(n.push(` [${o+1}] ${r.method} ${r.url} -> ${r.status??"ERROR"} (${r.durationMs}ms)`),r.error)n.push(` Error: ${r.error}`);if(r.note)n.push(` Note: ${r.note}`);if(r.requestHeaders)n.push(` Request headers: ${JSON.stringify(r.requestHeaders)}`);if(r.requestBody)n.push(` Request body: ${r.requestBody}`);if(r.responseBody)n.push(` Response body: ${r.responseBody}`)});return n.push(""),n.push(`Failing step: ${xye??"(none recorded)"}`),n.push(`Exit code: ${t}`),`${n.join(`
|
|
105
105
|
`)}
|
|
@@ -2686,7 +2686,7 @@ Examples:
|
|
|
2686
2686
|
Stopped waiting. Job ${t} is still running and was not canceled.
|
|
2687
2687
|
Look at it: nemar compute status ${t} Stop it: nemar compute cancel ${t}`);return;case"unavailable":process.exitCode=lO,console.error(`NEMAR could not be reached (${k(e.detail)}), so the wait ended. Job ${t} may still be running.
|
|
2688
2688
|
Look at it: nemar compute status ${t}`);return;case"ceiling":process.exitCode=lO,console.error(`Stopped waiting: the job's time limit and a 30-minute allowance have passed and it is still live. Job ${t} was not canceled.
|
|
2689
|
-
Look at it: nemar compute status ${t} Stop it: nemar compute cancel ${t}`);return;case"refused":jf(e.error,"Could not read the job.");return}}async function wBt(e,t,n){let r=R3(n),o=null,s=await CNe({fetchJob:async(i)=>{let a=await xD(e,{signal:i,timeoutMs:DNe});return o=a,a},onState:(i,a)=>{r(` ${hBt()} ${k(i.state)}${a?" (may be out of date)":""}`)},onRetry:(i,a)=>{r(u.dim(` NEMAR answered with an error (${k(i)}); retrying (${a})...`))}});if(n)console.log(JSON.stringify(o??t,null,2));bBt(s,e,n)}var Li=new oe("compute").description("Use NEMAR compute: ask for access, run your own jobs, and see your balance, limits, jobs and results (NEMAR's own processing is a separate administrator path)");Li.addCommand(nPe);Li.addCommand(yPe);Li.addCommand(bPe);Li.addCommand(wPe);Li.addCommand(_Pe);Li.addCommand(xPe);Li.addCommand(PNe);Li.addCommand(fPe);Li.addCommand(pPe);Li.addCommand(mPe);Ue();import{existsSync as Os,mkdtempSync as z5t,readFileSync as Sv,writeFileSync as KFe}from"fs";import{tmpdir as G5t}from"os";import{join as Um,resolve as ti}from"path";var{spawn:Lo}=globalThis.Bun;fs();ko();dp();$3();$m();var D3=["public","attribution","sharealike","noncommercial","noderiv","unknown"];var v1n=["Filter by modality: a whole-token, case-insensitive match against the dataset's modality","list, so `eeg` does not match `ieeg`. A comma-separated list matches a dataset holding any","of its modalities, at most 32 distinct values; more is refused."].join(" "),C3=["Filter by modality (eeg, emg, meg, etc.), matched as a whole token;","a comma list matches any of up to 32"].join(" ");bk();class Sa extends Error{reason;constructor(e,t){super(t);this.name="RangeParseError",this.reason=e}}var vBt={"":1,b:1,kb:1024,mb:1048576,gb:1073741824,tb:1099511627776},EBt={"":1,s:1,m:60,h:3600,d:86400},SBt={"":1};function kBt(e){switch(e){case"bytes":return vBt;case"duration":return EBt;case"number":return SBt}}var RBt=/^(-?\d+(?:\.\d+)?)([a-z]*)$/i;function A3(e,t){let n=RBt.exec(e);if(!n)throw new Sa("non-numeric",`"${e}" is not a valid number`);let[,r,o]=n,s=o.toLowerCase(),i=Number(r);if(!Number.isFinite(i))throw new Sa("non-finite",`"${e}" is not a finite number`);if(i<0)throw new Sa("negative",`"${e}" must not be negative`);if(s!==""&&t==="number")throw new Sa("unit-not-allowed",`"${e}" has a unit, but this facet takes a plain number`);let c=kBt(t)[s];if(c===void 0)throw new Sa("unknown-unit",`"${s}" is not a recognized ${t} unit`);return i*c}function FNe(e,t){let n=e.trim();if(n.includes("..")){let o=n.split("..");if(o.length!==2)throw new Sa("malformed",`"${e}" must contain at most one ".." separator`);let[s,i]=o,a=s.trim(),c=i.trim();if(a===""&&c==="")throw new Sa("malformed",`"${e}" does not specify either bound`);let l=a===""?null:A3(a,t),d=c===""?null:A3(c,t);if(l!==null&&d!==null&&l>d)throw new Sa("inverted",`"${e}" is inverted: ${l} is greater than ${d}`);return{min:l,max:d}}let r=A3(n,t);return{min:r,max:r}}Rc();$c();je();sa();Ue();fs();var mO="https://docs.nemar.org/policies/contributor-terms/",MNe={deposit_type:"owner",key_status:"destroyed",deidentified:!0};function $Bt(e){let{depositType:t,keyStatus:n,confirmDeidentified:r,affirmNoDuplicate:o,upstreamSource:s}=e;if(!(t!==void 0||n!==void 0||r===!0||o===!0||s!==void 0))return null;if(t!=="owner"&&t!=="redistribution")throw Error(`--deposit-type must be "owner" or "redistribution" (got ${t??"nothing"}); it is required when attesting via flags.`);if(n!=="destroyed"&&n!=="retained")throw Error(`--key-status must be "destroyed" or "retained" (got ${n??"nothing"}); it is required when attesting via flags.`);if(r!==!0)throw Error("--confirm-deidentified is required when attesting via flags: you must confirm the dataset contains no identifiable personal information.");if(t==="redistribution"&&o!==!0)throw Error("Redistribution deposits require --affirm-no-duplicate: you must affirm the dataset is not already on NEMAR or an upstream archive in BIDS format.");if(t==="owner"&&o)throw Error("--affirm-no-duplicate only applies to --deposit-type redistribution.");let a={deposit_type:t,key_status:n,deidentified:!0};if(t==="redistribution"){if(a.no_duplicate=!0,s)a.upstream_source=s}else if(s)throw Error("--upstream-source only applies to --deposit-type redistribution.");return a}async function DBt(){console.log(),console.log(u.bold("Deposit attestation")),console.log(u.dim(` These answers are recorded with the dataset. Terms: ${mO}`));let{depositType:e}=await Oe.prompt([{type:"list",name:"depositType",message:"Which describes this deposit?",choices:[{name:"I own this dataset (or am authorized by the owner) and hold ethics permissions for public sharing",value:"owner"},{name:"I am redistributing a publicly released dataset whose license permits it",value:"redistribution"}]}]),{keyStatus:t}=await Oe.prompt([{type:"list",name:"keyStatus",message:"The key linking subject codes to participant identities:",choices:[{name:"Has been destroyed (dataset is anonymous)",value:"destroyed"},{name:"Is retained by the owning institution and is never transmitted to NEMAR",value:"retained"}]}]),n={deposit_type:e,key_status:t,deidentified:!0};if(e==="redistribution"){let{noDuplicate:o}=await Oe.prompt([{type:"confirm",name:"noDuplicate",message:"Do you affirm this dataset is NOT already available on NEMAR or an upstream archive (e.g. OpenNeuro) in BIDS format?",default:!1}]);if(!o)throw Error("Upload cancelled: NEMAR does not accept duplicates of datasets already archived in BIDS format.");n.no_duplicate=!0;let{upstream:s}=await Oe.prompt([{type:"input",name:"upstream",message:"Upstream source of this dataset in its original form (URL or accession; blank if none):"}]);if(s.trim())n.upstream_source=s.trim()}let{deidentified:r}=await Oe.prompt([{type:"confirm",name:"deidentified",message:"Do you confirm the dataset contains no identifiable personal information (HIPAA Safe Harbor identifiers removed, anatomical images defaced, headers scrubbed)?",default:!0}]);if(!r)throw Error("Upload cancelled: datasets must be de-identified before deposit. See the contributor terms for what must be removed.");return n}async function jNe(e,t=process.stdin.isTTY===!0){let n=$Bt(e);if(n)return n;if(!t)throw Error(`Deposit attestation required: run interactively, or pass --deposit-type, --key-status, and --confirm-deidentified (plus --affirm-no-duplicate for redistribution). --yes does not substitute for attestation. Terms: ${mO}`);return DBt()}Gy();var{Glob:LNe}=globalThis.Bun;var CBt=["stimuli/**","**/stimuli/**"],ABt=["derivatives/**","**/derivatives/**"];function qNe(e,t){let n=e.trim();if(!n)return"";let r=n.startsWith(`${t}-`)?n.slice(t.length+1):n;return`${t}-${r}`}function OBt(e){let t=e.trim().replace(/^run-/,"");if(!t)return[];if(/^[1-9]$/.test(t))return[t,`0${t}`];return[t]}function TBt(e,t){let n=e.trim();if(!n)return"";return n.startsWith(`${t}-`)?n.slice(t.length+1):n}function jm(e){if(!e)return[];return e.split(",").map((t)=>t.trim()).filter(Boolean)}function PBt(e){let t=Array.from(new Set(e)).filter(Boolean);if(t.length===0)return[];if(t.length===1)return["--include",t[0]];let n=["-("];for(let r=0;r<t.length;r++){if(r>0)n.push("--or");n.push("--include",t[r])}return n.push("-)"),n}function hO(e){let t=[],n=[],r=jm(e.subjects).map((m)=>qNe(m,"sub"));if(r.length>0)t.push(r.map((m)=>`${m}/**`)),n.push(`subjects: ${r.join(", ")}`);let o=jm(e.sessions).map((m)=>qNe(m,"ses"));if(o.length>0)t.push(o.map((m)=>`**/${m}/**`)),n.push(`sessions: ${o.join(", ")}`);let s=jm(e.tasks).map((m)=>TBt(m,"task"));if(s.length>0)t.push(s.map((m)=>`**/*_task-${m}_*`)),n.push(`tasks: ${s.join(", ")}`);let i=jm(e.runs).flatMap(OBt);if(i.length>0)t.push(i.map((m)=>`**/*_run-${m}_*`)),n.push(`runs: ${i.join(", ")}`);let a=jm(e.datatypes);if(a.length>0)t.push(a.map((m)=>`**/${m}/**`)),n.push(`datatypes: ${a.join(", ")}`);let c=jm(e.include);if(c.length>0)t.push(c),n.push(`include: ${c.join(", ")}`);let l=jm(e.exclude),d=t.length>0||l.length>0,f=[];if(e.excludeStimuli)f.push(...CBt),n.push("skipping stimuli/ (use --stimuli to include)");if(e.excludeDerivatives)f.push(...ABt),n.push("skipping derivatives/ (use --derivatives to include)");let p=[];for(let m of t)p.push(...PBt(m));for(let m of f)p.push("--exclude",m);for(let m of l)p.push("--exclude",m);if(l.length>0)n.push(`exclude: ${l.join(", ")}`);return{args:p,active:d,summary:n,includeGroups:t,excludePatterns:[...f,...l]}}function BNe(e,t){let n=NBt(t);for(let r of n.excludes)if(r.match(e))return!1;for(let r of n.includes){if(r.length===0)continue;if(!r.some((o)=>o.match(e)))return!1}return!0}var UNe=new WeakMap;function NBt(e){let t=UNe.get(e);if(t)return t;let n={includes:e.includeGroups.map((r)=>r.map((o)=>new LNe(o))),excludes:e.excludePatterns.map((r)=>new LNe(r))};return UNe.set(e,n),n}function HNe(e,t){if(e&&e.length>0)return hO({});return hO({excludeStimuli:t.stimuli!==!0,excludeDerivatives:t.derivatives!==!0})}import{existsSync as FBt,readFileSync as MBt,statSync as GNe,writeFileSync as zNe}from"fs";import{homedir as T3}from"os";import{join as bv}from"path";var{spawn:_v}=globalThis.Bun;var O3={version:"3.0.2",specifier:"jsr:@bids/validator"};var Lb=O3.version,wv=`${O3.specifier}@${Lb}`,jBt=86400000,gO=16;async function qb(){try{let e=_v({cmd:["deno","--version"],stdout:"pipe",stderr:"pipe"}),t=await new Response(e.stdout).text();await e.exited;let n=t.match(/deno\s+(\d+\.\d+\.\d+)/);return{installed:!0,version:n?n[1]:void 0}}catch{return{installed:!1}}}function P3(){try{let e=process.platform,t=process.env.DENO_DIR||(e==="darwin"?bv(T3(),"Library","Caches","deno"):e==="win32"?bv(process.env.LOCALAPPDATA||bv(T3(),"AppData","Local"),"deno"):bv(T3(),".cache","deno")),n=bv(t,"deps");if(!FBt(n))return!0;let r=GNe(n);return Date.now()-r.mtimeMs>jBt}catch{return!0}}async function N3(){try{let e=_v({cmd:["deno","run","--node-modules-dir=none",`--reload=${wv}`,"-ERWN",wv,"--version"],stdout:"pipe",stderr:"pipe"}),t=await new Response(e.stdout).text();await e.exited;let n=t.match(/(\d+\.\d+\.\d+)/);return n?n[1]:null}catch{return null}}async function I3(){try{let e=_v({cmd:["deno","run","--node-modules-dir=none","-ERWN",wv,"--version"],stdout:"pipe",stderr:"pipe"}),t=await new Response(e.stdout).text();await e.exited;let n=t.match(/(\d+\.\d+\.\d+)/);return n?n[1]:null}catch{return null}}function VNe(e,t={}){let n=["run","--node-modules-dir=none"];if(t.forceReload)n.push(`--reload=${wv}`);if(n.push("-ERWN",wv,e),t.json)n.push("--json");if(t.config)n.push("--config",t.config);if(t.ignoreWarnings)n.push("--ignoreWarnings");if(t.recursive)n.push("--recursive");if(t.prune)n.push("--prune");if(t.verbose)n.push("--verbose");if(t.extraArgs?.length)n.push(...t.extraArgs);return n}var LBt=/\u001b\[[0-9;]*[A-Za-z]/g;function qBt(e){let t=e.replace(LBt,"").split(`
|
|
2689
|
+
Look at it: nemar compute status ${t} Stop it: nemar compute cancel ${t}`);return;case"refused":jf(e.error,"Could not read the job.");return}}async function wBt(e,t,n){let r=R3(n),o=null,s=await CNe({fetchJob:async(i)=>{let a=await xD(e,{signal:i,timeoutMs:DNe});return o=a,a},onState:(i,a)=>{r(` ${hBt()} ${k(i.state)}${a?" (may be out of date)":""}`)},onRetry:(i,a)=>{r(u.dim(` NEMAR answered with an error (${k(i)}); retrying (${a})...`))}});if(n)console.log(JSON.stringify(o??t,null,2));bBt(s,e,n)}var Li=new oe("compute").description("Use NEMAR compute: ask for access, run jobs, and see your balance, limits, jobs and results");Li.addCommand(nPe);Li.addCommand(yPe);Li.addCommand(bPe);Li.addCommand(wPe);Li.addCommand(_Pe);Li.addCommand(xPe);Li.addCommand(PNe);Li.addCommand(fPe);Li.addCommand(pPe);Li.addCommand(mPe);Ue();import{existsSync as Os,mkdtempSync as z5t,readFileSync as Sv,writeFileSync as KFe}from"fs";import{tmpdir as G5t}from"os";import{join as Um,resolve as ti}from"path";var{spawn:Lo}=globalThis.Bun;fs();ko();dp();$3();$m();var D3=["public","attribution","sharealike","noncommercial","noderiv","unknown"];var v1n=["Filter by modality: a whole-token, case-insensitive match against the dataset's modality","list, so `eeg` does not match `ieeg`. A comma-separated list matches a dataset holding any","of its modalities, at most 32 distinct values; more is refused."].join(" "),C3=["Filter by modality (eeg, emg, meg, etc.), matched as a whole token;","a comma list matches any of up to 32"].join(" ");bk();class Sa extends Error{reason;constructor(e,t){super(t);this.name="RangeParseError",this.reason=e}}var vBt={"":1,b:1,kb:1024,mb:1048576,gb:1073741824,tb:1099511627776},EBt={"":1,s:1,m:60,h:3600,d:86400},SBt={"":1};function kBt(e){switch(e){case"bytes":return vBt;case"duration":return EBt;case"number":return SBt}}var RBt=/^(-?\d+(?:\.\d+)?)([a-z]*)$/i;function A3(e,t){let n=RBt.exec(e);if(!n)throw new Sa("non-numeric",`"${e}" is not a valid number`);let[,r,o]=n,s=o.toLowerCase(),i=Number(r);if(!Number.isFinite(i))throw new Sa("non-finite",`"${e}" is not a finite number`);if(i<0)throw new Sa("negative",`"${e}" must not be negative`);if(s!==""&&t==="number")throw new Sa("unit-not-allowed",`"${e}" has a unit, but this facet takes a plain number`);let c=kBt(t)[s];if(c===void 0)throw new Sa("unknown-unit",`"${s}" is not a recognized ${t} unit`);return i*c}function FNe(e,t){let n=e.trim();if(n.includes("..")){let o=n.split("..");if(o.length!==2)throw new Sa("malformed",`"${e}" must contain at most one ".." separator`);let[s,i]=o,a=s.trim(),c=i.trim();if(a===""&&c==="")throw new Sa("malformed",`"${e}" does not specify either bound`);let l=a===""?null:A3(a,t),d=c===""?null:A3(c,t);if(l!==null&&d!==null&&l>d)throw new Sa("inverted",`"${e}" is inverted: ${l} is greater than ${d}`);return{min:l,max:d}}let r=A3(n,t);return{min:r,max:r}}Rc();$c();je();sa();Ue();fs();var mO="https://docs.nemar.org/policies/contributor-terms/",MNe={deposit_type:"owner",key_status:"destroyed",deidentified:!0};function $Bt(e){let{depositType:t,keyStatus:n,confirmDeidentified:r,affirmNoDuplicate:o,upstreamSource:s}=e;if(!(t!==void 0||n!==void 0||r===!0||o===!0||s!==void 0))return null;if(t!=="owner"&&t!=="redistribution")throw Error(`--deposit-type must be "owner" or "redistribution" (got ${t??"nothing"}); it is required when attesting via flags.`);if(n!=="destroyed"&&n!=="retained")throw Error(`--key-status must be "destroyed" or "retained" (got ${n??"nothing"}); it is required when attesting via flags.`);if(r!==!0)throw Error("--confirm-deidentified is required when attesting via flags: you must confirm the dataset contains no identifiable personal information.");if(t==="redistribution"&&o!==!0)throw Error("Redistribution deposits require --affirm-no-duplicate: you must affirm the dataset is not already on NEMAR or an upstream archive in BIDS format.");if(t==="owner"&&o)throw Error("--affirm-no-duplicate only applies to --deposit-type redistribution.");let a={deposit_type:t,key_status:n,deidentified:!0};if(t==="redistribution"){if(a.no_duplicate=!0,s)a.upstream_source=s}else if(s)throw Error("--upstream-source only applies to --deposit-type redistribution.");return a}async function DBt(){console.log(),console.log(u.bold("Deposit attestation")),console.log(u.dim(` These answers are recorded with the dataset. Terms: ${mO}`));let{depositType:e}=await Oe.prompt([{type:"list",name:"depositType",message:"Which describes this deposit?",choices:[{name:"I own this dataset (or am authorized by the owner) and hold ethics permissions for public sharing",value:"owner"},{name:"I am redistributing a publicly released dataset whose license permits it",value:"redistribution"}]}]),{keyStatus:t}=await Oe.prompt([{type:"list",name:"keyStatus",message:"The key linking subject codes to participant identities:",choices:[{name:"Has been destroyed (dataset is anonymous)",value:"destroyed"},{name:"Is retained by the owning institution and is never transmitted to NEMAR",value:"retained"}]}]),n={deposit_type:e,key_status:t,deidentified:!0};if(e==="redistribution"){let{noDuplicate:o}=await Oe.prompt([{type:"confirm",name:"noDuplicate",message:"Do you affirm this dataset is NOT already available on NEMAR or an upstream archive (e.g. OpenNeuro) in BIDS format?",default:!1}]);if(!o)throw Error("Upload cancelled: NEMAR does not accept duplicates of datasets already archived in BIDS format.");n.no_duplicate=!0;let{upstream:s}=await Oe.prompt([{type:"input",name:"upstream",message:"Upstream source of this dataset in its original form (URL or accession; blank if none):"}]);if(s.trim())n.upstream_source=s.trim()}let{deidentified:r}=await Oe.prompt([{type:"confirm",name:"deidentified",message:"Do you confirm the dataset contains no identifiable personal information (HIPAA Safe Harbor identifiers removed, anatomical images defaced, headers scrubbed)?",default:!0}]);if(!r)throw Error("Upload cancelled: datasets must be de-identified before deposit. See the contributor terms for what must be removed.");return n}async function jNe(e,t=process.stdin.isTTY===!0){let n=$Bt(e);if(n)return n;if(!t)throw Error(`Deposit attestation required: run interactively, or pass --deposit-type, --key-status, and --confirm-deidentified (plus --affirm-no-duplicate for redistribution). --yes does not substitute for attestation. Terms: ${mO}`);return DBt()}Gy();var{Glob:LNe}=globalThis.Bun;var CBt=["stimuli/**","**/stimuli/**"],ABt=["derivatives/**","**/derivatives/**"];function qNe(e,t){let n=e.trim();if(!n)return"";let r=n.startsWith(`${t}-`)?n.slice(t.length+1):n;return`${t}-${r}`}function OBt(e){let t=e.trim().replace(/^run-/,"");if(!t)return[];if(/^[1-9]$/.test(t))return[t,`0${t}`];return[t]}function TBt(e,t){let n=e.trim();if(!n)return"";return n.startsWith(`${t}-`)?n.slice(t.length+1):n}function jm(e){if(!e)return[];return e.split(",").map((t)=>t.trim()).filter(Boolean)}function PBt(e){let t=Array.from(new Set(e)).filter(Boolean);if(t.length===0)return[];if(t.length===1)return["--include",t[0]];let n=["-("];for(let r=0;r<t.length;r++){if(r>0)n.push("--or");n.push("--include",t[r])}return n.push("-)"),n}function hO(e){let t=[],n=[],r=jm(e.subjects).map((m)=>qNe(m,"sub"));if(r.length>0)t.push(r.map((m)=>`${m}/**`)),n.push(`subjects: ${r.join(", ")}`);let o=jm(e.sessions).map((m)=>qNe(m,"ses"));if(o.length>0)t.push(o.map((m)=>`**/${m}/**`)),n.push(`sessions: ${o.join(", ")}`);let s=jm(e.tasks).map((m)=>TBt(m,"task"));if(s.length>0)t.push(s.map((m)=>`**/*_task-${m}_*`)),n.push(`tasks: ${s.join(", ")}`);let i=jm(e.runs).flatMap(OBt);if(i.length>0)t.push(i.map((m)=>`**/*_run-${m}_*`)),n.push(`runs: ${i.join(", ")}`);let a=jm(e.datatypes);if(a.length>0)t.push(a.map((m)=>`**/${m}/**`)),n.push(`datatypes: ${a.join(", ")}`);let c=jm(e.include);if(c.length>0)t.push(c),n.push(`include: ${c.join(", ")}`);let l=jm(e.exclude),d=t.length>0||l.length>0,f=[];if(e.excludeStimuli)f.push(...CBt),n.push("skipping stimuli/ (use --stimuli to include)");if(e.excludeDerivatives)f.push(...ABt),n.push("skipping derivatives/ (use --derivatives to include)");let p=[];for(let m of t)p.push(...PBt(m));for(let m of f)p.push("--exclude",m);for(let m of l)p.push("--exclude",m);if(l.length>0)n.push(`exclude: ${l.join(", ")}`);return{args:p,active:d,summary:n,includeGroups:t,excludePatterns:[...f,...l]}}function BNe(e,t){let n=NBt(t);for(let r of n.excludes)if(r.match(e))return!1;for(let r of n.includes){if(r.length===0)continue;if(!r.some((o)=>o.match(e)))return!1}return!0}var UNe=new WeakMap;function NBt(e){let t=UNe.get(e);if(t)return t;let n={includes:e.includeGroups.map((r)=>r.map((o)=>new LNe(o))),excludes:e.excludePatterns.map((r)=>new LNe(r))};return UNe.set(e,n),n}function HNe(e,t){if(e&&e.length>0)return hO({});return hO({excludeStimuli:t.stimuli!==!0,excludeDerivatives:t.derivatives!==!0})}import{existsSync as FBt,readFileSync as MBt,statSync as GNe,writeFileSync as zNe}from"fs";import{homedir as T3}from"os";import{join as bv}from"path";var{spawn:_v}=globalThis.Bun;var O3={version:"3.0.2",specifier:"jsr:@bids/validator"};var Lb=O3.version,wv=`${O3.specifier}@${Lb}`,jBt=86400000,gO=16;async function qb(){try{let e=_v({cmd:["deno","--version"],stdout:"pipe",stderr:"pipe"}),t=await new Response(e.stdout).text();await e.exited;let n=t.match(/deno\s+(\d+\.\d+\.\d+)/);return{installed:!0,version:n?n[1]:void 0}}catch{return{installed:!1}}}function P3(){try{let e=process.platform,t=process.env.DENO_DIR||(e==="darwin"?bv(T3(),"Library","Caches","deno"):e==="win32"?bv(process.env.LOCALAPPDATA||bv(T3(),"AppData","Local"),"deno"):bv(T3(),".cache","deno")),n=bv(t,"deps");if(!FBt(n))return!0;let r=GNe(n);return Date.now()-r.mtimeMs>jBt}catch{return!0}}async function N3(){try{let e=_v({cmd:["deno","run","--node-modules-dir=none",`--reload=${wv}`,"-ERWN",wv,"--version"],stdout:"pipe",stderr:"pipe"}),t=await new Response(e.stdout).text();await e.exited;let n=t.match(/(\d+\.\d+\.\d+)/);return n?n[1]:null}catch{return null}}async function I3(){try{let e=_v({cmd:["deno","run","--node-modules-dir=none","-ERWN",wv,"--version"],stdout:"pipe",stderr:"pipe"}),t=await new Response(e.stdout).text();await e.exited;let n=t.match(/(\d+\.\d+\.\d+)/);return n?n[1]:null}catch{return null}}function VNe(e,t={}){let n=["run","--node-modules-dir=none"];if(t.forceReload)n.push(`--reload=${wv}`);if(n.push("-ERWN",wv,e),t.json)n.push("--json");if(t.config)n.push("--config",t.config);if(t.ignoreWarnings)n.push("--ignoreWarnings");if(t.recursive)n.push("--recursive");if(t.prune)n.push("--prune");if(t.verbose)n.push("--verbose");if(t.extraArgs?.length)n.push(...t.extraArgs);return n}var LBt=/\u001b\[[0-9;]*[A-Za-z]/g;function qBt(e){let t=e.replace(LBt,"").split(`
|
|
2690
2690
|
`).map((n)=>n.trim()).filter((n)=>n!==""&&!n.startsWith("Download"));return t.find((n)=>n.startsWith("error:"))??t.filter((n)=>!n.startsWith("at ")).pop()}async function WNe(e,t={}){let n=VNe(e,{...t,json:!0}),r=_v({cmd:["deno",...n],stdout:"pipe",stderr:"pipe",env:{...process.env,NO_COLOR:"1"}}),o=await new Response(r.stdout).text(),s=await new Response(r.stderr).text(),i=await r.exited;if(i!==0&&i!==gO){let f=qBt(s);throw Error(f?`BIDS validator failed (exit ${i}): ${f}`:`BIDS validator failed with exit code ${i}`)}let a;try{a=JSON.parse(o)}catch{throw Error(`Failed to parse validator output: ${o.slice(0,200)}`)}if(!Array.isArray(a?.issues?.issues))throw Error("The BIDS validator's report has no list of issues");let c=a.issues.issues,l=c.filter((f)=>f.severity==="error").length,d=c.filter((f)=>f.severity==="warning").length;return{valid:l===0,issues:c,codeMessages:a.issues.codeMessages||{},summary:a.summary,errorCount:l,warningCount:d,validatorVersion:Lb}}async function KNe(e,t={}){let n=VNe(e,t),r=_v({cmd:["deno",...n],stdout:"pipe",stderr:"pipe"}),o=await new Response(r.stdout).text(),s=await new Response(r.stderr).text(),i=await r.exited;return{stdout:o,stderr:s,exitCode:i}}function F3(e){let t;try{t=JSON.parse(e)}catch{throw Error("The BIDS validator did not print a JSON report")}if(typeof t!=="object"||t===null||Array.isArray(t))throw Error("The BIDS validator's JSON report is not an object");return JSON.stringify({...t,validatorVersion:Lb})}function JNe(e){let t;for(let n=0;n<e.length;n++){let r=e[n];if(r==="--outfile"||r==="-o"){let o=e[n+1];if(o)t=o,n++}else if(r.startsWith("--outfile=")&&r.length>10)t=r.slice(10)}return t}function YNe(e,t){try{if(!GNe(e).isFile())return}catch(o){if(o.code==="ENOENT")throw Error(`The BIDS validator exited normally but wrote no report to ${e}`);throw o}let n=MBt(e,"utf-8");if(t){let o;try{o=F3(n)}catch{throw Error(`The BIDS validator's report file does not hold a JSON report: ${e}`)}zNe(e,o);return}let r=n===""||n.endsWith(`
|
|
2691
2691
|
`)?"":`
|
|
2692
2692
|
`;zNe(e,`${n}${r}Validator: @bids/validator ${Lb}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nemar-cli",
|
|
3
3
|
"packageManager": "bun@1.4.3",
|
|
4
|
-
"version": "0.10.28-PR2113.
|
|
4
|
+
"version": "0.10.28-PR2113.e415fcc",
|
|
5
5
|
"description": "CLI for NEMAR (Neuroelectromagnetic Data Archive and Tools Resource) dataset management",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|