@r5n/ariadne 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +1 -1
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -53,7 +53,7 @@ ${d}
53
53
  `))});return`${p?"[":"{"}${x}${S.join(M)}${b}${p?"]":"}"}`}function c(l,u,d){if(!d)return jo(l,i);let p=t.lastIndexOf(`
54
54
  `,u-1)+1,f=t.slice(p,u).match(/^[\t ]*/)?.[0]??"";return JSON.stringify(l,null,s).replaceAll(`
55
55
  `,o+f)}return t.slice(0,r.start)+a(r,n)+t.slice(r.end)}function jo(t,e){if(Array.isArray(t))return`[${t.map((s)=>jo(s,e)).join(`,${e}`)}]`;if(t===null||typeof t!=="object")return JSON.stringify(t);let n=Object.entries(t);if(n.length===0)return"{}";let r=n.map(([s,o])=>`${JSON.stringify(s)}:${e}${jo(o,e)}`);return`{${e}${r.join(`,${e}`)}${e}}`}function Jh(t){let e=t.matchAll(/"(?:[^"\\]|\\.)*"|[^\s{}[\],:]+|[{}[\],:]/g),n=e.next().value;function r(){if(!n)throw Error("Unexpected end of JSON");let o=n;return n=e.next().value,o}function s(){let o=r(),i=[],a=o[0]==="{";if(!a&&o[0]!=="[")return{end:o.index+o[0].length,entries:i,start:o.index,value:JSON.parse(o[0])};let c=a?"}":"]";while(n&&n[0]!==c){let u=n.index,d=a?JSON.parse(r()[0]):String(i.length);if(a)r();if(i.push({key:d,node:s(),start:u}),n?.[0]===",")r()}let l=r().index+1;return{end:l,entries:i,start:o.index,value:JSON.parse(t.slice(o.index,l))}}return s()}var qh=2,Go="ConfigError",Yh=On(Object);class Ho{loaded;configPath;defaultConfig;options;constructor(t,e,n={}){this.configPath=Mo.resolve(t),this.defaultConfig=e,this.options=n}get path(){return this.configPath}get failure(){return this.state().failure}get(t){return this.current()[t]}set(t,e){let n=this.writable();this.update((r)=>({...r,[t]:e})),n.config={...n.config,[t]:e}}delete(t){let e=this.writable();this.update((n)=>(delete n[t],n)),delete e.config[t]}exists(){return Ft.existsSync(this.configPath)}getAll(){return structuredClone(this.current())}save(t){let e=this.writable();if(t)e.config={...t};this.update(()=>e.config)}state(){return this.loaded??=this.load(),this.loaded}current(){let{config:t,failure:e}=this.state();if(e)throw e;return t}writable(){let t=this.state();if(t.failure)throw t.failure;if(t.error)throw this.unreadable(t.error);return t}unreadable(t){return new g(`Cannot overwrite unreadable config at ${this.configPath}`,"Repair the file and try again",void 0,{cause:t,tag:Go})}readStored(){try{let t=this.readConfigFile();if(t===void 0)return structuredClone(this.defaultConfig);return An(structuredClone(this.defaultConfig),wl(t))}catch(t){throw this.unreadable(t)}}update(t){try{let e=this.savePath();ml(e,()=>this.write(e,t(this.readStored())))}catch(e){throw e instanceof g?e:this.saveFailure(e)}}savePath(){let t=this.exists()?Ft.realpathSync(this.configPath):kl(this.configPath);return Ft.mkdirSync(Mo.dirname(t),{recursive:!0}),t}write(t,e){let n=`${t}.${crypto.randomUUID()}.tmp`;try{let r=this.exists()?Ft.statSync(this.configPath).mode:void 0,s=this.exists()?Lo(Ft.readFileSync(this.configPath,"utf-8"),e):`${JSON.stringify(e,null,qh)}
56
- `;if(Ft.writeFileSync(n,s,{flag:"wx",mode:r}),r!==void 0)Ft.chmodSync(n,r);Ft.renameSync(n,t)}finally{Ft.rmSync(n,{force:!0})}}saveFailure(t){return new g(`Cannot save config at ${this.configPath}: ${$l(t)}`,`Check that ${Mo.dirname(this.configPath)} is writable and that no other process is saving the file`,void 0,{cause:t,tag:Go})}load(){let{parse:t,strict:e}=this.options;try{let n=this.readConfigFile();if(n===void 0)return{config:structuredClone(this.defaultConfig)};let r=An(structuredClone(this.defaultConfig),wl(n));return{config:t?t(r):r}}catch(n){if(e)return{config:structuredClone(this.defaultConfig),failure:this.loadFailure(n)};return qt.warn(G.yellow(`Config file corrupted at ${this.configPath}. Using defaults.`),{output:$r()}),{config:structuredClone(this.defaultConfig),error:n}}}loadFailure(t){return new g(`Cannot read config at ${this.configPath}: ${$l(t)}`,"Repair the file and try again",void 0,{cause:t,tag:Go})}readConfigFile(){try{return Ft.readFileSync(this.configPath,"utf-8")}catch(t){if(t.code==="ENOENT")return;throw t}}}function wl(t){let e=JSON.parse(t);if(Array.isArray(e))throw Error("Config must be an object");return Yh(e)}function $l(t){return t instanceof Error?t.message:String(t)}var bl="0.1.0";var R=gr();var zh=["GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_COMMON_DIR","GIT_DIR","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_PREFIX","GIT_WORK_TREE"],Ur=Object.fromEntries(zh.map((t)=>[t,void 0]));var Tl={SIGHUP:129,SIGINT:130,SIGTERM:143},xl=Object.keys(Tl),Sl={SIGHUP:()=>Fo("SIGHUP"),SIGINT:()=>Fo("SIGINT"),SIGTERM:()=>Fo("SIGTERM")},Xe=[],Ko={interrupted:!1};function ge(t){if(Xe.length===0)for(let e of xl)process.on(e,Sl[e]);return Xe.push(t),()=>{let e=Xe.indexOf(t);if(e===-1)return;if(Xe.splice(e,1),Xe.length===0)for(let n of xl)process.off(n,Sl[n])}}function vl(){return Ko.interrupted}function Fo(t){if(Ko.interrupted)return;Ko.interrupted=!0;let e=Tl[t],n=Xe.toReversed().flatMap((r)=>Zh(r)??[]);if(n.length===0)process.exit(e);Promise.all(n).finally(()=>process.exit(e))}function Zh(t){try{let e=t();return e instanceof Promise?e.catch(El):null}catch(e){return El(e),null}}function El(t){let e=t instanceof Error?t.message:String(t);process.stderr.write(`ari could not clean up after an interrupt: ${e}
56
+ `;if(Ft.writeFileSync(n,s,{flag:"wx",mode:r}),r!==void 0)Ft.chmodSync(n,r);Ft.renameSync(n,t)}finally{Ft.rmSync(n,{force:!0})}}saveFailure(t){return new g(`Cannot save config at ${this.configPath}: ${$l(t)}`,`Check that ${Mo.dirname(this.configPath)} is writable and that no other process is saving the file`,void 0,{cause:t,tag:Go})}load(){let{parse:t,strict:e}=this.options;try{let n=this.readConfigFile();if(n===void 0)return{config:structuredClone(this.defaultConfig)};let r=An(structuredClone(this.defaultConfig),wl(n));return{config:t?t(r):r}}catch(n){if(e)return{config:structuredClone(this.defaultConfig),failure:this.loadFailure(n)};return qt.warn(G.yellow(`Config file corrupted at ${this.configPath}. Using defaults.`),{output:$r()}),{config:structuredClone(this.defaultConfig),error:n}}}loadFailure(t){return new g(`Cannot read config at ${this.configPath}: ${$l(t)}`,"Repair the file and try again",void 0,{cause:t,tag:Go})}readConfigFile(){try{return Ft.readFileSync(this.configPath,"utf-8")}catch(t){if(t.code==="ENOENT")return;throw t}}}function wl(t){let e=JSON.parse(t);if(Array.isArray(e))throw Error("Config must be an object");return Yh(e)}function $l(t){return t instanceof Error?t.message:String(t)}var bl="0.2.0";var R=gr();var zh=["GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_COMMON_DIR","GIT_DIR","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_PREFIX","GIT_WORK_TREE"],Ur=Object.fromEntries(zh.map((t)=>[t,void 0]));var Tl={SIGHUP:129,SIGINT:130,SIGTERM:143},xl=Object.keys(Tl),Sl={SIGHUP:()=>Fo("SIGHUP"),SIGINT:()=>Fo("SIGINT"),SIGTERM:()=>Fo("SIGTERM")},Xe=[],Ko={interrupted:!1};function ge(t){if(Xe.length===0)for(let e of xl)process.on(e,Sl[e]);return Xe.push(t),()=>{let e=Xe.indexOf(t);if(e===-1)return;if(Xe.splice(e,1),Xe.length===0)for(let n of xl)process.off(n,Sl[n])}}function vl(){return Ko.interrupted}function Fo(t){if(Ko.interrupted)return;Ko.interrupted=!0;let e=Tl[t],n=Xe.toReversed().flatMap((r)=>Zh(r)??[]);if(n.length===0)process.exit(e);Promise.all(n).finally(()=>process.exit(e))}function Zh(t){try{let e=t();return e instanceof Promise?e.catch(El):null}catch(e){return El(e),null}}function El(t){let e=t instanceof Error?t.message:String(t);process.stderr.write(`ari could not clean up after an interrupt: ${e}
57
57
  `)}var Qh=["ESRCH","EPERM"];function Rn(t,e){try{process.kill(-t,e)}catch(n){if(!Qh.includes(n.code))throw n}}var ty=1000,ey=2147483647,ny=60,Rl=8192,ry=Rl*2,sy=1000,oy=`exec 2>&1
58
58
  `,iy=192,ay=128,Cl=`
59
59
  `,cy=[126,127],Al=128,ly=31;async function Il(t,e){let n=performance.now(),r=Bun.spawn(["sh","-c",`${oy}${t}`],{cwd:e.cwd,detached:!0,env:{...process.env,...Ur},stderr:"pipe",stdin:"ignore",stdout:"pipe"}),s=ge(()=>Uo(r.pid));try{return await uy(r,t,e,n)}finally{s()}}async function uy(t,e,n,r){let s={hasher:new Bun.CryptoHasher("sha256"),window:new Uint8Array},o=[t.stdout.getReader(),t.stderr.getReader()],i=Promise.all(o.map((u)=>dy(u,s))),a={timedOut:!1},c=setTimeout(()=>{a.timedOut=!0,Uo(t.pid)},Math.min(n.timeoutSeconds*ty,ey));await t.exited,clearTimeout(c);let l=await py(i,sy);if(Uo(t.pid),!l)await Promise.all(o.map((u)=>u.cancel()));return{command:e,durationMs:Math.round(performance.now()-r),exitCode:t.exitCode,outputSha256:s.hasher.digest("hex"),outputTail:my(s.window),timedOut:a.timedOut}}function _l(t){return t.exitCode===0&&!t.timedOut}function Pl(t){return t.exitCode!==0&&!t.timedOut&&!Bo(t)&&!Wo(t)}function Bo(t){let{exitCode:e}=t;return e===null||e>Al&&e<=Al+ly}function Wo(t){return t.exitCode!==null&&!t.timedOut&&cy.includes(t.exitCode)}async function dy(t,e){for(;;){let{done:n,value:r}=await t.read();if(n)return;e.hasher.update(r),e.window=Nl(fy(e.window,r),ry)}}async function py(t,e){let n,r=new Promise((o)=>{n=setTimeout(()=>o(!1),e)}),s=await Promise.race([t.then(()=>!0),r]);return clearTimeout(n),s}function Uo(t){Rn(t,"SIGKILL")}function my(t){let n=new TextDecoder().decode(Ol(t)).split(Cl);if(n.at(-1)==="")n.pop();let r=new TextEncoder().encode(n.slice(-ny).join(Cl));return new TextDecoder().decode(Ol(Nl(r,Rl)))}function Ol(t){let e=0;while(e<t.length&&((t[e]??0)&iy)===ay)e++;return t.subarray(e)}function Nl(t,e){return t.length<=e?t:t.subarray(t.length-e)}function fy(t,e){let n=new Uint8Array(t.length+e.length);return n.set(t),n.set(e,t.length),n}function z(t,e,n,r=[],s=[]){return{checks:[...s],details:[...r],gate:t,ok:e,summary:n}}async function wt(t,e,n){let r=[];for(let s of t){let o=await Il(s.run,{cwd:n,timeoutSeconds:s.timeoutSeconds});r.push(gy(s.name,e,o))}return r}function gy(t,e,n){let r=e==="pass"?_l(n):Pl(n);return{...n,expect:e,name:t,ok:r}}function Vo(t){return`${t.name} should ${t.expect} but ${hy(t)}`}function Ae(t){return t.filter((e)=>!e.ok).map(Vo)}function Z(t,e,n){return t===1?e:n}function hy(t){if(t.timedOut)return`timed out after ${t.durationMs} ms`;if(Wo(t))return`could not run (exit code ${t.exitCode})`;if(!Bo(t))return`exited with ${t.exitCode}`;return t.exitCode===null?"was killed by a signal":`was killed by a signal (exit code ${t.exitCode})`}var Dl=new Map;function K(t,e){return e.some((n)=>ky(n).match(t))}function Jo(t){if(t.trim().length===0)return"is empty";if(t!==t.trim())return"has leading or trailing white space";if(t.includes("\x00"))return"contains a NUL character";if(t.startsWith("!"))return"must not be negated with a leading !";if(t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t))return"must be relative to the repository root";if(t.startsWith("./"))return"must not start with ./";if(t.split("/").includes(".."))return"must not contain a .. segment";return yy(t)}function Oe(t){let e=Jo(t);if(e!==null)return e;if(t.endsWith("/"))return"ends with /, so it matches no file; use a pattern such as dir/**";return t.split("/").includes("")?"has an empty path segment, so it matches no file":null}function yy(t){let e=0,n=!1;for(let r=0;r<t.length;r++){let s=t[r];if(s==="\\"){if(r===t.length-1)return"ends with a lone backslash";r++;continue}if(n){n=s!=="]";continue}if(s==="[")n=!0;if(s==="{")e++;if(s==="}"){if(e===0)return"has an unmatched }";e--}}if(n)return"has an unclosed [";return e>0?"has an unclosed {":null}function ky(t){let e=Dl.get(t);if(e)return e;let n=new Bun.Glob(t);return Dl.set(t,n),n}import{copyFileSync as Ey,existsSync as Ty,mkdtempSync as vy,readFileSync as Cy,readlinkSync as Ay,rmSync as Oy,utimesSync as Ry}from"fs";import{tmpdir as Iy}from"os";import{join as Br,resolve as _y}from"path";function N(t,e){if(t<e)return-1;if(t>e)return 1;return 0}function $t(t){return new Bun.CryptoHasher("sha256").update(t).digest("hex")}import{lstatSync as wy,statSync as $y}from"fs";import{dirname as by,join as xy}from"path";var Sy=["ENOENT","ENOTDIR","ELOOP"];function he(t){return jl(()=>wy(t))}function qo(t){return jl(()=>$y(t))}function ze(t,e,n=new Map){let r=by(e);if(r===".")return!1;let s=n.get(r);if(s!==void 0)return s;let o=he(xy(t,r))?.isSymbolicLink()===!0||ze(t,r,n);return n.set(r,o),o}function jl(t){try{return t()}catch(e){if(Sy.includes(e.code))return null;throw e}}var Wr="\x00",gt=0,Py=128,Ny=128,Kl=1,Ul=1,Dy=1,jy="ari-index-",Yo=["diff","--name-only","--no-renames","--ignore-submodules=untracked","-z"],Ly=["git","--no-optional-locks","--no-replace-objects",...["core.fsmonitor=false","core.untrackedCache=false","core.trustctime=true","core.checkStat=default"].flatMap((t)=>["-c",t])],Ll=1,My=/^(?:[a-z]|S) /,Ml=/^s/i,Gy=2,Hy="symlink:",Fy=["--no-assume-unchanged","--no-skip-worktree"],Gl="worktree ",Ky="bare",Uy="prunable",Hl=/^(?:error|fatal): /;async function A(t,e,n={}){let r=[...Ly,...e],s=Vy(r,t,n),[o,i,a]=await Promise.all([new Response(s.stdout).text(),new Response(s.stderr).text(),s.exited]);if((n.allowedExitCodes??[gt]).includes(a))return{exitCode:a,stderr:i,stdout:o};let l=i.trim()||o.trim()||"no output";throw Error(`git ${e.join(" ")} failed in ${t} with exit code ${a}: ${l}`)}async function Bl(t){let e=await A(t,["rev-parse","--show-toplevel"],{allowedExitCodes:[gt,Py]});if(e.exitCode!==gt)throw new g(`${t} is not inside a git working tree`,"Run ari from inside a git repository");return e.stdout.trim()}async function Re(t,e){let n=await A(t,["rev-parse","--git-path",e]);return _y(t,n.stdout.trim())}async function Vr(t){let e=await A(t,["rev-parse","--verify","--quiet","HEAD^{commit}"],{allowedExitCodes:[gt,Kl]});if(e.exitCode!==gt)throw new g("The repository has no commits yet","Make a first commit, then run the command again");return e.stdout.trim()}async function Wl(t){let e=await A(t,["config","user.name"],{allowedExitCodes:[gt,Ul]}),n=e.stdout.trim();return e.exitCode===gt&&n.length>0?n:null}async function Ct(t,e){let n=await Yl(t,async(o)=>(await ql(t,await qr(t),o),A(t,[...Yo,e,"--"],{env:o}))),r=await A(t,[...Yo,"--cached",e,"--"]),s=await A(t,["ls-files","--others","--exclude-standard","-z"]);return zo([n,r,s].flatMap((o)=>Zt(o.stdout)))}async function Jr(t,e,n){let r=await A(t,[...Yo,e,n,"--"]);return zo(Zt(r.stdout))}async function Ze(t,e){let n=await A(t,["rev-parse","--verify","--quiet","--end-of-options",`${e}^{commit}`],{allowedExitCodes:[gt,Kl]});if(n.exitCode!==gt)throw new g(`"${e}" does not name a commit`,"Pass a branch, tag or commit that this repository has");return n.stdout.trim()}async function Vl(t,e,n){let r=await A(t,["merge-base",e,n],{allowedExitCodes:[gt,Dy]});if(r.exitCode!==gt)throw new g(`${e} and ${n} share no history`,"Pass a ref that the current branch was integrated with");return r.stdout.trim()}async function Jl(t){let e=await A(t,["worktree","list","--porcelain","-z"]),n=[],r=null;for(let s of[...e.stdout.split(Wr),""])if(s.startsWith(Gl))r=s.slice(Gl.length);else if(s===Ky||s.startsWith(Uy))r=null;else if(s===""&&r!==null)n.push(r),r=null;return n}async function Qe(t,e){return Yl(t,async(n)=>{await ql(t,await qr(t),n);let r=await A(t,["add","--all","--sparse","--","."],{allowedExitCodes:[gt,Ny],env:n});if(r.exitCode!==gt)throw new g(`git cannot hash the working tree: ${Xo(r.stderr)}`,"Commit, remove or ignore those paths (an embedded repository needs a commit), then run the command again");if(e.length>0){let o=e.map((i)=>`:(glob)${i}`);await A(t,["rm","--cached","-r","-q","--sparse","--ignore-unmatch","--",...o],{env:n})}return(await A(t,["write-tree"],{env:n})).stdout.trim()})}async function zt(t,e){if(e.length===0)return{};let n=await A(t,["ls-files","--cached","--others","--exclude-standard","-z"]),r=new Map,s=zo(Zt(n.stdout)).filter((o)=>K(o,e)&&!ze(t,o,r));return Object.fromEntries(s.flatMap((o)=>{let i=Wy(Br(t,o));return i===null?[]:[[o,i]]}))}function Xo(t){let e=t.split(`
package/package.json CHANGED
@@ -39,5 +39,5 @@
39
39
  "package:publish": "bun ../../tools/scripts/publish-package.ts ."
40
40
  },
41
41
  "type": "module",
42
- "version": "0.1.0"
42
+ "version": "0.2.0"
43
43
  }