@junobuild/cli-tools 0.2.0-next-2025-06-02.1 → 0.2.0-next-2025-06-03

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.
@@ -22,10 +22,10 @@ var lh=Object.create;var Go=Object.defineProperty;var fh=Object.getOwnPropertyDe
22
22
  globstar while`,e,m,i,d,x),this.matchOne(e.slice(m),i.slice(d),n))return this.debug("globstar found match!",m,c,x),!0;if(x==="."||x===".."||!r.dot&&x.charAt(0)==="."){this.debug("dot detected!",e,m,i,d);break}this.debug("globstar swallow a segment, and continue"),m++}return!!(n&&(this.debug(`
23
23
  >>> no match, partial?`,e,m,i,d),m===c))}let h;if(typeof p=="string"?(h=f===p,this.debug("string match",p,f,h)):(h=p.test(f),this.debug("pattern match",p,f,h)),!h)return!1}if(o===c&&s===u)return!0;if(o===c)return n;if(s===u)return o===c-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return jc(this.pattern,this.options)}parse(e){Dt(e);let i=this.options;if(e==="**")return ee;if(e==="")return"";let n,r=null;(n=e.match(cx))?r=i.dot?ux:px:(n=e.match(Xv))?r=(i.nocase?i.dot?ix:tx:i.dot?ex:Kv)(n[1]):(n=e.match(lx))?r=(i.nocase?i.dot?mx:fx:i.dot?dx:hx)(n):(n=e.match(nx))?r=i.dot?ax:rx:(n=e.match(ox))&&(r=sx);let a=et.fromGlob(e,this.options).toMMPattern();return r&&typeof a=="object"&&Reflect.defineProperty(a,"test",{value:r}),a}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let i=this.options,n=i.noglobstar?bx:i.dot?gx:yx,r=new Set(i.nocase?["i"]:[]),a=e.map(c=>{let u=c.map(p=>{if(p instanceof RegExp)for(let f of p.flags.split(""))r.add(f);return typeof p=="string"?Ox(p):p===ee?ee:p._src});return u.forEach((p,f)=>{let m=u[f+1],d=u[f-1];p!==ee||d===ee||(d===void 0?m!==void 0&&m!==ee?u[f+1]="(?:\\/|"+n+"\\/)?"+m:u[f]=n:m===void 0?u[f-1]=d+"(?:\\/|"+n+")?":m!==ee&&(u[f-1]=d+"(?:\\/|\\/"+n+"\\/)"+m,u[f+1]=ee))}),u.filter(p=>p!==ee).join("/")}).join("|"),[o,s]=e.length>1?["(?:",")"]:["",""];a="^"+o+a+s+"$",this.negate&&(a="^(?!"+a+").+$");try{this.regexp=new RegExp(a,[...r].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,i=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&i)return!0;let n=this.options;this.isWindows&&(e=e.split("\\").join("/"));let r=this.slashSplit(e);this.debug(this.pattern,"split",r);let a=this.set;this.debug(this.pattern,"set",a);let o=r[r.length-1];if(!o)for(let s=r.length-2;!o&&s>=0;s--)o=r[s];for(let s=0;s<a.length;s++){let c=a[s],u=r;if(n.matchBase&&c.length===1&&(u=[o]),this.matchOne(u,c,i))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return C.defaults(e).Minimatch}};C.AST=et;C.Minimatch=tt;C.escape=er;C.unescape=_e;import{readFile as Lx}from"node:fs/promises";import{extname as ir,join as Ux}from"node:path";import{createReadStream as jx,createWriteStream as Ex}from"node:fs";import{Readable as Tx}from"node:stream";import{createGunzip as Ax,createGzip as Cx}from"node:zlib";var hj=async({source:t})=>await new Promise((e,i)=>{let n=Tx.from(t),r=[],a=Ax();n.pipe(a),a.on("data",o=>r.push(o)),a.on("end",()=>{e(Buffer.concat(r))}),a.on("error",i)}),Ec=async({sourceFiles:t,gzip:e})=>{if(e===!1)return[];let i=e===!0?yi:e,n=t.filter(r=>C(r,i));return await Promise.all(n.map(async r=>await qx({source:r})))},qx=async({source:t,destination:e})=>await new Promise((i,n)=>{let r=jx(t),a=e??`${t}.gz`,o=Ex(a),s=Cx();r.pipe(s).pipe(o),o.on("close",()=>{i(a)}),o.on("error",n)}),vj=t=>t.length>2&&t[0]===31&&t[1]===139;import{lstatSync as Ix}from"node:fs";import{basename as Dx}from"node:path";import{lstatSync as Fx,readdirSync as Px}from"node:fs";import{access as Mx}from"node:fs/promises";import{join as Tc}from"node:path";var tr=t=>Px(t).flatMap(e=>{let i=Tc(t,e);return Fx(i).isDirectory()?tr(i):Tc(i)}),wj=async t=>{try{return await Mx(t),!0}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return!1;throw e}};var Mi=({file:t,sourceAbsolutePath:e})=>t.replace(e,"").replace(/\\/g,"/"),Ac=({sourceAbsolutePath:t,ignore:e})=>tr(t).filter(n=>zx({file:n,ignore:e})),zx=({file:t,ignore:e})=>Ix(t).size<=0||Zo.includes(Dx(t).toLowerCase())?!1:e.find(i=>C(t,i))===void 0;var Fc=async({config:t,listAssets:e,assertSourceDirExists:i,includeAllFiles:n})=>{let{source:r=Wo,ignore:a=Ho,encoding:o=Vo,gzip:s=yi}=t,c=Ux(process.cwd(),r);return i?.(c),{files:await Gx({sourceAbsolutePath:c,ignore:a,encoding:o,gzip:s,listAssets:e,includeAllFiles:n}),sourceAbsolutePath:c}},Bx=async({files:t,sourceAbsolutePath:e,listAssets:i})=>{let n=await i({}),r=t.map(async o=>await Yx({file:o,sourceAbsolutePath:e,existingAssets:n}));return(await Promise.all(r)).filter(({upload:o})=>o).map(({file:o})=>o)},$x=async t=>{let e=await Lx(t);return Nx.createHash("sha256").update(e).digest("base64")},Yx=async({file:t,existingAssets:e,sourceAbsolutePath:i})=>{let n=t.alternateFile??t.file,r=e.find(({fullPath:o})=>o===Mi({file:n,sourceAbsolutePath:i}));if(Cc(r))return{file:t,upload:!0};let a=await $x(n);return{file:t,upload:a!==r.encodings.identity?.sha256}},Gx=async({sourceAbsolutePath:t,ignore:e,encoding:i,gzip:n,listAssets:r,includeAllFiles:a})=>{let o=Ac({sourceAbsolutePath:t,ignore:e}),s=await Ec({sourceFiles:o,gzip:n}),c=[...o,...s.filter(d=>!o.includes(d))],u=({file:d,ext:x})=>{let h=i.find(([g,S])=>C(d,g));if(Rx(h)){let[g,S]=h;return S}if(x==="Z")return"compress";if(x==="gz")return"gzip";if(ir(d)===".br")return"br";if(ir(d)===".zlib")return"deflate"},p=({file:d,encodingType:x})=>{if(!Cc(x))return c.find(h=>h===d.replace(ir(d),""))},f=async d=>{let x=await $s(d),h=u({file:d,ext:x?.ext}),g=p({file:d,encodingType:h}),S=qc.default.lookup(g??d);return{file:d,alternateFile:g,mime:typeof S=="string"?S:void 0,encoding:h}},m=await Promise.all(c.map(f));return a===!0?m:await Bx({files:m,sourceAbsolutePath:t,listAssets:r})};import{fromNullable as Wx,isNullish as Hx,uint8ArrayToHexString as Vx}from"@dfinity/utils";import{commitProposal as Zx,initProposal as Jx,submitProposal as Qx}from"@junobuild/cdn";var Pc=async({proposalType:t,cdn:e,executeChanges:i,autoCommit:n})=>{let[r,a]=await Jx({proposalType:t,cdn:e});await i(r);let[o,{sha256:s,status:c}]=await Qx({cdn:e,proposalId:r}),u=Wx(s);return console.log(`
24
24
  Change submitted.
25
- `),console.log("\u{1F194} ",r),console.log("\u23F3 ",c),Hx(u)&&(console.log("\u274C Hash undefined. This is unexpected."),process.exit(1)),console.log("\u{1F512} ",Vx(u)),n?(await Zx({proposal:{proposal_id:r,sha256:u},cdn:e}),console.log(`\u{1F3AF} Change ${r} applied.`),{proposalId:r}):{proposalId:r}};var ih=Et(eh(),1);import{isNullish as LS,nonNullish as th}from"@dfinity/utils";import{Blob as US}from"buffer";import{readFile as BS}from"node:fs/promises";import{basename as $S}from"node:path";var On=async({files:t,uploadFile:e,collection:i})=>{await YS({files:t,upload:async({file:r,paths:a})=>{await GS({collection:i,...a,file:r,uploadFile:e})}})},YS=async({files:t,upload:e})=>{let i=async n=>{for(let r=0;r<n.length;r+=20){let a=n.slice(r,r+20);await new ih.default(a.map(({file:s,paths:c})=>({title:`Uploading ${c.fullPath}`,task:async()=>await e({file:s,paths:c})})),{concurrent:!0}).run()}};await i(t.filter(({file:{alternateFile:n}})=>th(n))),await i(t.filter(({file:{alternateFile:n}})=>LS(n)))},GS=async({uploadFile:t,file:e,fullPath:i,collection:n,filePath:r})=>{await t({filename:$S(r),fullPath:i,data:new US([await BS(e.file)]),collection:n,headers:[...e.mime===void 0?[]:[["Content-Type",e.mime]]],encoding:e.encoding,...th(e.token)&&{token:e.token}})};var jn=async({deploy:{uploadFile:t,files:e,collection:i},proposal:{proposalType:n,autoCommit:r,...a}})=>{let o=async c=>{await On({files:e,collection:i,uploadFile:p=>t({...p,proposalId:c})})},{proposalId:s}=await Pc({...a,autoCommit:r,proposalType:n,executeChanges:o});return r?{result:"deployed",files:e.map(c=>c.file),proposalId:s}:{result:"submitted",files:e.map(c=>c.file),proposalId:s}};var zT=async({config:{predeploy:t}})=>{await Mn(t)},RT=async({config:{postdeploy:t}})=>{await Mn(t)},NT=async({uploadFile:t,...e})=>{let i=await nh(e);if(i.result==="skipped")return{result:"skipped"};let n=rh(i);await On({files:n,uploadFile:t,collection:qn}),console.log(`
25
+ `),console.log("\u{1F194} ",Number(r)),console.log("\u23F3 ",Object.keys(c)[0]??c),Hx(u)&&(console.log("\u274C Hash undefined. This is unexpected."),process.exit(1)),console.log("\u{1F512} ",Vx(u)),n?(await Zx({proposal:{proposal_id:r,sha256:u},cdn:e}),console.log(`\u{1F3AF} Change #${r} applied.`),{proposalId:r}):{proposalId:r}};var ih=Et(eh(),1);import{isNullish as LS,nonNullish as th}from"@dfinity/utils";import{Blob as US}from"buffer";import{readFile as BS}from"node:fs/promises";import{basename as $S}from"node:path";var On=async({files:t,uploadFile:e,collection:i})=>{await YS({files:t,upload:async({file:r,paths:a})=>{await GS({collection:i,...a,file:r,uploadFile:e})}})},YS=async({files:t,upload:e})=>{let i=async n=>{for(let r=0;r<n.length;r+=20){let a=n.slice(r,r+20);await new ih.default(a.map(({file:s,paths:c})=>({title:`Uploading ${c.fullPath}`,task:async()=>await e({file:s,paths:c})})),{concurrent:!0}).run()}};await i(t.filter(({file:{alternateFile:n}})=>th(n))),await i(t.filter(({file:{alternateFile:n}})=>LS(n)))},GS=async({uploadFile:t,file:e,fullPath:i,collection:n,filePath:r})=>{await t({filename:$S(r),fullPath:i,data:new US([await BS(e.file)]),collection:n,headers:[...e.mime===void 0?[]:[["Content-Type",e.mime]]],encoding:e.encoding,...th(e.token)&&{token:e.token}})};var jn=async({deploy:{uploadFile:t,files:e,collection:i},proposal:{proposalType:n,autoCommit:r,...a}})=>{let o=async c=>{await On({files:e,collection:i,uploadFile:p=>t({...p,proposalId:c})})},{proposalId:s}=await Pc({...a,autoCommit:r,proposalType:n,executeChanges:o});return r?{result:"deployed",files:e.map(c=>c.file),proposalId:s}:{result:"submitted",files:e.map(c=>c.file),proposalId:s}};var zT=async({config:{predeploy:t}})=>{await Mn(t)},RT=async({config:{postdeploy:t}})=>{await Mn(t)},NT=async({uploadFile:t,...e})=>{let i=await nh(e);if(i.result==="skipped")return{result:"skipped"};let n=rh(i);await On({files:n,uploadFile:t,collection:qn}),console.log(`
26
26
  \u{1F680} Deploy complete!`);let{files:r}=i;return{result:"deployed",files:r}},LT=async({deploy:{uploadFile:t,...e},proposal:{clearAssets:i,...n}})=>{let r=await nh(e);if(r.result==="skipped")return{result:"skipped"};let a=rh(r),o=await jn({deploy:{uploadFile:t,files:a,collection:qn},proposal:{...n,proposalType:{AssetsUpgrade:{clear_existing_assets:WS(i)}}}});return o.result==="deployed"&&console.log(`
27
27
  \u{1F680} Deploy complete!`),o},nh=async({assertMemory:t,...e})=>{let{files:i,sourceAbsolutePath:n}=await Fc(e);return i.length===0?(console.log("\u26A0\uFE0F No file changes detected. Upload skipped."),{result:"skipped"}):(await t?.(),{result:"to-deploy",files:i,sourceAbsolutePath:n})},rh=({files:t,sourceAbsolutePath:e})=>{let i=n=>{let r=n.alternateFile??n.file;return{fullPath:Mi({file:r,sourceAbsolutePath:e}),filePath:r}};return t.map(n=>({file:n,paths:i(n)}))};import{toNullable as Io}from"@dfinity/utils";var GT=async({deploy:{uploadFile:t,assertMemory:e,filePath:i,fullPath:n,token:r},proposal:{version:a,...o}})=>{await e?.();let c=await jn({deploy:{uploadFile:t,files:[{file:{file:i,token:r},paths:{filePath:i,fullPath:n}}],collection:Jo},proposal:{...o,proposalType:{SegmentsDeployment:{satellite_version:Io(a),orbiter:Io(),mission_control_version:Io()}}}});return c.result==="deployed"&&console.log(`
28
- \u{1F680} Satellite WASM deployed to CDN!`),c};var HT=({args:t,options:e})=>t?.find(i=>e.includes(i))!==void 0,VT=({args:t,option:e})=>{let i=(t??[]).findIndex(n=>n===e);if(i!==-1)return t?.[i+1]};import{nonNullish as ah}from"@dfinity/utils";import{get as HS}from"https";var VS=async t=>await new Promise((e,i)=>{HS(t,async n=>{ah(n.statusCode)&&ah(n.headers.location)&&[301,302].includes(n.statusCode)&&await VS(n.headers.location).then(e,i);let r=[];n.on("data",a=>r.push(a)),n.on("end",()=>{e(Buffer.concat(r))}),n.on("error",i)})});import{readFile as ZS}from"node:fs/promises";var e6=async({packageJsonPath:t})=>{let e=await ZS(t,"utf-8"),{dependencies:i,version:n,juno:r,name:a}=JSON.parse(e);return{name:a,version:n,dependencies:i,juno:r}};import{isNullish as JS,nonNullish as QS}from"@dfinity/utils";var n6=(t,e)=>{(JS(t)||t==="")&&(QS(e)&&console.error(e),process.exit(1))};export{Jo as COLLECTION_CDN,qn as COLLECTION_DAPP,Vo as DEPLOY_DEFAULT_ENCODING,yi as DEPLOY_DEFAULT_GZIP,Ho as DEPLOY_DEFAULT_IGNORE,Wo as DEPLOY_DEFAULT_SOURCE,Zo as IGNORE_OS_FILES,Cn as UPLOAD_BATCH_SIZE,n6 as assertAnswerCtrlC,e3 as buildEsm,NT as deploy,GT as deploySatelliteWasmWithProposal,LT as deployWithProposal,VS as downloadFromURL,ts as execute,wj as fileExists,tr as files,hj as gunzipFile,qx as gzipFile,Ec as gzipFiles,HT as hasArgs,vj as isGzip,VT as nextArg,RT as postDeploy,zT as preDeploy,e6 as readPackageJson,f3 as spawn};
28
+ \u{1F4E1} Satellite WASM deployed to CDN.`),c};var HT=({args:t,options:e})=>t?.find(i=>e.includes(i))!==void 0,VT=({args:t,option:e})=>{let i=(t??[]).findIndex(n=>n===e);if(i!==-1)return t?.[i+1]};import{nonNullish as ah}from"@dfinity/utils";import{get as HS}from"https";var VS=async t=>await new Promise((e,i)=>{HS(t,async n=>{ah(n.statusCode)&&ah(n.headers.location)&&[301,302].includes(n.statusCode)&&await VS(n.headers.location).then(e,i);let r=[];n.on("data",a=>r.push(a)),n.on("end",()=>{e(Buffer.concat(r))}),n.on("error",i)})});import{readFile as ZS}from"node:fs/promises";var e6=async({packageJsonPath:t})=>{let e=await ZS(t,"utf-8"),{dependencies:i,version:n,juno:r,name:a}=JSON.parse(e);return{name:a,version:n,dependencies:i,juno:r}};import{isNullish as JS,nonNullish as QS}from"@dfinity/utils";var n6=(t,e)=>{(JS(t)||t==="")&&(QS(e)&&console.error(e),process.exit(1))};export{Jo as COLLECTION_CDN,qn as COLLECTION_DAPP,Vo as DEPLOY_DEFAULT_ENCODING,yi as DEPLOY_DEFAULT_GZIP,Ho as DEPLOY_DEFAULT_IGNORE,Wo as DEPLOY_DEFAULT_SOURCE,Zo as IGNORE_OS_FILES,Cn as UPLOAD_BATCH_SIZE,n6 as assertAnswerCtrlC,e3 as buildEsm,NT as deploy,GT as deploySatelliteWasmWithProposal,LT as deployWithProposal,VS as downloadFromURL,ts as execute,wj as fileExists,tr as files,hj as gunzipFile,qx as gzipFile,Ec as gzipFiles,HT as hasArgs,vj as isGzip,VT as nextArg,RT as postDeploy,zT as preDeploy,e6 as readPackageJson,f3 as spawn};
29
29
  /*! Bundled license information:
30
30
 
31
31
  ieee754/index.js: