icoa-cli 2.19.576 → 2.19.578

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.
@@ -1 +1 @@
1
- import{spawnSync as t}from"node:child_process";import{existsSync as r,mkdirSync as n,readFileSync as e,renameSync as o,statSync as a,writeFileSync as s}from"node:fs";import{homedir as c}from"node:os";import{dirname as i,join as u}from"node:path";const l="https://practice.icoa2026.au/assets/translations";export function assetDir(){const t=u(c(),".icoa","assets");return r(t)||n(t,{recursive:!0}),t}export async function lazyJson(t,n=6e3,e){const o=u(assetDir(),t),s=r(o);return s&&function(t){try{return Date.now()-a(t).mtimeMs<6048e5}catch{return!1}}(o)&&!e?.force||await p(`${l}/${t}`,o,n)||s?f(o):null}function f(t){try{return JSON.parse(e(t,"utf8"))}catch{return null}}async function p(t,r,e){const a=`${r}.part`;try{n(i(r),{recursive:!0});const c=new AbortController,u=setTimeout(()=>c.abort(),e),l=await fetch(t,{signal:c.signal});if(clearTimeout(u),!l.ok)return!1;const f=Buffer.from(await l.arrayBuffer());return!!f.length&&(s(a,f),o(a,r),!0)}catch{return!1}}export async function lazyFile(t,n=2e4){const e=u(assetDir(),t);return r(e)||await p(`${l}/${t}`,e,n)?e:null}export async function lazyTarball(e,a,c=15e3){const i=u(assetDir(),a),f=u(i,".complete");if(r(f))return i;const m=u(assetDir(),e);if(!await p(`${l}/${e}`,m,c))return null;const y=`${i}.staging`;try{return n(y,{recursive:!0}),0!==t("tar",["-xzf",m,"-C",y],{stdio:"ignore"}).status?null:(r(i)&&o(i,`${i}.old-${Date.now()}`),o(y,i),s(f,(new Date).toISOString()),i)}catch{return null}}
1
+ import{spawnSync as t}from"node:child_process";import{existsSync as n,mkdirSync as e,readFileSync as r,renameSync as a,statSync as o,writeFileSync as s}from"node:fs";import{homedir as c}from"node:os";import{dirname as i,join as u}from"node:path";const l="https://practice.icoa2026.au/assets/translations";export function assetDir(){const t=u(c(),".icoa","assets");return n(t)||e(t,{recursive:!0}),t}export async function lazyJson(t,e=6e3,r){const a=u(assetDir(),t),s=n(a);return s&&function(t){try{return Date.now()-o(t).mtimeMs<6048e5}catch{return!1}}(a)&&!r?.force||await g(`${l}/${t}`,a,e)||s?f(a):null}function f(t){try{return JSON.parse(r(t,"utf8"))}catch{return null}}async function g(t,n,e){return null!==await m(t,n,e)}function h(t){return{etag:t.headers.get("etag")??"",length:t.headers.get("content-length")??""}}async function m(t,n,r){const o=`${n}.part`;try{e(i(n),{recursive:!0});const c=new AbortController,u=setTimeout(()=>c.abort(),r),l=await fetch(t,{signal:c.signal});if(clearTimeout(u),!l.ok)return null;const f=Buffer.from(await l.arrayBuffer());return f.length?(s(o,f),a(o,n),h(l)):null}catch{return null}}export async function lazyFile(t,e=2e4){const r=u(assetDir(),t);return n(r)||await g(`${l}/${t}`,r,e)?r:null}export async function lazyTarball(o,c,i=15e3,f={}){const g=u(assetDir(),c),y=u(g,".complete"),p=`${l}/${o}`;if(n(y)){if(!f.revalidate)return g;const t=await async function(t){try{const n=new AbortController,e=setTimeout(()=>n.abort(),4e3),r=await fetch(t,{method:"HEAD",signal:n.signal});return clearTimeout(e),r.ok?h(r):null}catch{return null}}(p);if(!t||(w=function(t){try{const n=JSON.parse(r(t,"utf8"));return{etag:n.etag??"",length:n.length??""}}catch{return null}}(y),d=t,w&&d&&(w.etag&&d.etag?w.etag===d.etag:w.length&&w.length===d.length)))return g}var w,d;const $=u(assetDir(),o),D=await m(p,$,i);if(!D)return n(y)?g:null;const b=`${g}.staging`;try{return e(b,{recursive:!0}),0!==t("tar",["-xzf",$,"-C",b],{stdio:"ignore"}).status?n(y)?g:null:(n(g)&&a(g,`${g}.old-${Date.now()}`),a(b,g),s(y,JSON.stringify({at:(new Date).toISOString(),...D})),g)}catch{return n(y)?g:null}}
@@ -1 +1 @@
1
- import{Interface as e,createInterface as o}from"node:readline";import{getMainRl as n}from"./main-rl.js";export function makeReplAsker(){const r=n(),s=null!==r,t=s?r.listeners("line").slice():[];s&&r.removeAllListeners("line");const l=s?r:o({input:process.stdin,output:process.stdout}),i=s?l.prompt:null;return s&&(l.prompt=e.prototype.prompt),{ask:e=>new Promise(o=>{const n=e=>{l.removeListener("close",r),o(e)},r=()=>{l.removeListener("line",n),o(null)};l.once("line",n),l.once("close",r),l.setPrompt(e),l.prompt()}),close:()=>{if(s){i&&(r.prompt=i),r.removeAllListeners("line");for(const e of t)r.on("line",e)}else l.close()}}}
1
+ import{Interface as e,createInterface as o}from"node:readline";import{getMainRl as n}from"./main-rl.js";export function makeReplAsker(){const t=n(),l=null!==t,s=l?t.listeners("line").slice():[];l&&t.removeAllListeners("line");const r=l?t:o({input:process.stdin,output:process.stdout}),i=l?r.prompt:null;l&&(r.prompt=e.prototype.prompt);const p=[];let m=null;const c=e=>{if(m){const o=m;m=null,o(e)}else p.push(e)};return r.on("line",c),{ask:e=>new Promise(o=>{if(r.setPrompt(e),p.length)return r.prompt(),void o(p.shift());const n=()=>{m=null,o(null)};m=e=>{r.removeListener("close",n),o(e)},r.once("close",n),r.prompt()}),close:()=>{if(r.removeListener("line",c),m=null,l){i&&(t.prompt=i),t.removeAllListeners("line");for(const e of s)t.on("line",e)}else r.close()}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icoa-cli",
3
- "version": "2.19.576",
3
+ "version": "2.19.578",
4
4
  "description": "ICOA CLI — AI-native competition runtime of the International Cyber Olympiad in AI: learn, practise, and compete in AI & cybersecurity from the terminal (AI4CTF · CTF4AI · CTF4EAI)",
5
5
  "author": "Charlie Zhu",
6
6
  "type": "module",