@junobuild/cli 0.1.4 → 0.1.5

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 CHANGED
@@ -196,7 +196,7 @@ Done. The ${ba(t)} ${(0,Ho.green)(r)} has been configured for your terminal. \u2
196
196
  `),await ii("Have you completed this step?")};var d$=at(P0(),1);var Wd=at(jt(),1);import{createServer as Ibe}from"http";import Nbe from"node:fs";import Fbe,{dirname as Bbe}from"node:path";import{fileURLToPath as kbe}from"url";import jbe from"util";var M7=({port:e,nonce:t,principal:r})=>{let n=N1e({port:e,nonce:t}),s=new URL(D5);return s.searchParams.set("redirect_uri",encodeURIComponent(n.toString())),s.searchParams.set("principal",r),s.toString()},R7=({port:e,reqUrl:t})=>`${w2.replace("{port}",`${e}`)}${t}`,N1e=({port:e,nonce:t})=>{let r=new URL(w2.replace("{port}",`${e}`));return r.searchParams.set("state",`${t}`),r.toString()};import ix from"node:process";import{Buffer as tbe}from"node:buffer";import G7 from"node:path";import{fileURLToPath as rbe}from"node:url";import nbe from"node:child_process";import UC,{constants as z7}from"node:fs/promises";import U7 from"node:process";import M1e from"node:os";import R1e from"node:fs";import k1e from"node:fs";import L7 from"node:fs";var FC;function F1e(){try{return L7.statSync("/.dockerenv"),!0}catch{return!1}}function B1e(){try{return L7.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function BC(){return FC===void 0&&(FC=F1e()||B1e()),FC}var kC,j1e=()=>{try{return k1e.statSync("/run/.containerenv"),!0}catch{return!1}};function Ff(){return kC===void 0&&(kC=j1e()||BC()),kC}var $7=()=>{if(U7.platform!=="linux")return!1;if(M1e.release().toLowerCase().includes("microsoft"))return!Ff();try{return R1e.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!Ff():!1}catch{return!1}},Ny=U7.env.__IS_WSL_TEST__?$7:$7();function Vd(e,t,r){let n=s=>Object.defineProperty(e,t,{value:s,enumerable:!0,writable:!0});return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let s=r();return n(s),s},set(s){n(s)}}),e}import{promisify as X1e}from"node:util";import LC from"node:process";import{execFile as Q1e}from"node:child_process";import{promisify as L1e}from"node:util";import $1e from"node:process";import{execFile as U1e}from"node:child_process";var q1e=L1e(U1e);async function jC(){if($1e.platform!=="darwin")throw new Error("macOS only");let{stdout:e}=await q1e("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]);return/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??"com.apple.Safari"}import V1e from"node:process";import{promisify as K1e}from"node:util";import{execFile as W1e,execFileSync as e6e}from"node:child_process";var H1e=K1e(W1e);async function q7(e,{humanReadableOutput:t=!0}={}){if(V1e.platform!=="darwin")throw new Error("macOS only");let r=t?[]:["-ss"],{stdout:n}=await H1e("osascript",["-e",e,r]);return n.trim()}async function MC(e){return q7(`tell application "Finder" to set app_path to application file id "${e}" as string
197
197
  tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as G1e}from"node:util";import{execFile as z1e}from"node:child_process";var Y1e=G1e(z1e),J1e={AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},MSEdgeDHTML:{name:"Edge",id:"com.microsoft.edge"},MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"}},nx=class extends Error{};async function RC(e=Y1e){let{stdout:t}=await e("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),r=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(t);if(!r)throw new nx(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:n}=r.groups,s=J1e[n];if(!s)throw new nx(`Unknown browser ID: ${n}`);return s}var Z1e=X1e(Q1e),ebe=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,t=>t.toUpperCase());async function $C(){if(LC.platform==="darwin"){let e=await jC();return{name:await MC(e),id:e}}if(LC.platform==="linux"){let{stdout:e}=await Z1e("xdg-mime",["query","default","x-scheme-handler/http"]),t=e.trim();return{name:ebe(t.replace(/.desktop$/,"").replace("-"," ")),id:t}}if(LC.platform==="win32")return RC();throw new Error("Only macOS, Linux, and Windows are supported")}var qC=G7.dirname(rbe(import.meta.url)),V7=G7.join(qC,"xdg-open"),{platform:Bf,arch:K7}=ix,ibe=(()=>{let e="/mnt/",t;return async function(){if(t)return t;let r="/etc/wsl.conf",n=!1;try{await UC.access(r,z7.F_OK),n=!0}catch{}if(!n)return e;let s=await UC.readFile(r,{encoding:"utf8"}),o=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(s);return o?(t=o.groups.mountPoint.trim(),t=t.endsWith("/")?t:`${t}/`,t):e}})(),W7=async(e,t)=>{let r;for(let n of e)try{return await t(n)}catch(s){r=s}throw r},sx=async e=>{if(e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e},Array.isArray(e.app))return W7(e.app,c=>sx({...e,app:c}));let{name:t,arguments:r=[]}=e.app??{};if(r=[...r],Array.isArray(t))return W7(t,c=>sx({...e,app:{name:c,arguments:r}}));if(t==="browser"||t==="browserPrivate"){let c={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","microsoft-edge.desktop":"edge"},p={chrome:"--incognito",firefox:"--private-window",edge:"--inPrivate"},d=await $C();if(d.id in c){let l=c[d.id];return t==="browserPrivate"&&r.push(p[l]),sx({...e,app:{name:Rp[l],arguments:r}})}throw new Error(`${d.name} is not supported as a default browser`)}let n,s=[],o={};if(Bf==="darwin")n="open",e.wait&&s.push("--wait-apps"),e.background&&s.push("--background"),e.newInstance&&s.push("--new"),t&&s.push("-a",t);else if(Bf==="win32"||Ny&&!Ff()&&!t){let c=await ibe();n=Ny?`${c}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`:`${ix.env.SYSTEMROOT||ix.env.windir||"C:\\Windows"}\\System32\\WindowsPowerShell\\v1.0\\powershell`,s.push("-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"),Ny||(o.windowsVerbatimArguments=!0);let p=["Start"];e.wait&&p.push("-Wait"),t?(p.push(`"\`"${t}\`""`),e.target&&r.push(e.target)):e.target&&p.push(`"${e.target}"`),r.length>0&&(r=r.map(d=>`"\`"${d}\`""`),p.push("-ArgumentList",r.join(","))),e.target=tbe.from(p.join(" "),"utf16le").toString("base64")}else{if(t)n=t;else{let c=!qC||qC==="/",p=!1;try{await UC.access(V7,z7.X_OK),p=!0}catch{}n=ix.versions.electron??(Bf==="android"||c||!p)?"xdg-open":V7}r.length>0&&s.push(...r),e.wait||(o.stdio="ignore",o.detached=!0)}Bf==="darwin"&&r.length>0&&s.push("--args",...r),e.target&&s.push(e.target);let a=nbe.spawn(n,s,o);return e.wait?new Promise((c,p)=>{a.once("error",p),a.once("close",d=>{if(!e.allowNonzeroExitCode&&d>0){p(new Error(`Exited with code ${d}`));return}c(a)})}):(a.unref(),a)},sbe=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a `target`");return sx({...t,target:e})};function H7(e){if(typeof e=="string"||Array.isArray(e))return e;let{[K7]:t}=e;if(!t)throw new Error(`${K7} is not supported`);return t}function VC({[Bf]:e},{wsl:t}){if(t&&Ny)return H7(t);if(!e)throw new Error(`${Bf} is not supported`);return H7(e)}var Rp={};Vd(Rp,"chrome",()=>VC({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));Vd(Rp,"firefox",()=>VC({darwin:"firefox",win32:"C:\\Program Files\\Mozilla Firefox\\firefox.exe",linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));Vd(Rp,"edge",()=>VC({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));Vd(Rp,"browser",()=>"browser");Vd(Rp,"browserPrivate",()=>"browserPrivate");var Y7=sbe;var kf=async({url:e,browser:t})=>{let{chrome:r,firefox:n,edge:s}=Rp,o;switch(t?.toLowerCase()){case"chrome":o=r;break;case"firefox":o=n;break;case"edge":o=s;break;case"safari":o="Safari";break;default:o=void 0}return await Y7(e,o!==void 0?{app:{name:o}}:void 0)};var fx=at(c$(),1);(0,fx.setBasePort)(9005);var p$=async()=>await(0,fx.getPortPromise)();var Mbe=kbe(import.meta.url),Rbe=Bbe(Mbe),ky=async e=>{let t=await p$(),r=Math.floor(Math.random()*(2<<29)+1),n=d$.Ed25519KeyIdentity.generate(),s=n.getPrincipal().toText(),o=n.toJSON();console.log(`
198
198
  \u{1F513} Your terminal will take control as: ${(0,Wd.green)(s)}`);let a=Lr({args:e,option:"-b"})??Lr({args:e,option:"--browser"});await new Promise((c,p)=>{let d=Ibe(async(l,y)=>{let m=new URL(R7({port:t,reqUrl:l.url})),b=m.searchParams.get("state"),f=m.searchParams.get("satellites"),v=m.searchParams.get("orbiters"),T=m.searchParams.get("mission_control"),x=m.searchParams.get("profile");if(b!==`${r}`){await YC(l,y,400,"../templates/login/failure.html"),p(new Error("Unexpected error while logging in.")),d.close();return}try{await Lbe({token:o,satellites:f,orbiters:v,missionControl:T,profile:x}),await YC(l,y,200,"../templates/login/success.html"),console.log(`${(0,Wd.green)("Success!")} Logged in. \u2705`),c()}catch(S){console.error(S),await YC(l,y,400,"../templates/login/failure.html"),p(S)}d.close()});d.listen(t,async()=>{let l=M7({port:t,nonce:r,principal:s});console.log(),console.log("Visit this URL on this device to log in:"),console.log((0,Wd.bold)((0,Wd.underline)(l))),console.log(),console.log("Waiting for authentication..."),await kf({url:l,browser:a})}),d.on("error",l=>{p(l)})})};async function YC(e,t,r,n){let s=await jbe.promisify(Nbe.readFile)(Fbe.join(Rbe,n));t.writeHead(r,{"Content-Length":s.length,"Content-Type":"text/html"}),t.end(s),e.socket.destroy()}var Lbe=async({token:e,satellites:t,orbiters:r,missionControl:n,profile:s})=>{await x7({token:e,satellites:JSON.parse(decodeURIComponent(t??"[]")),orbiters:r!==null?JSON.parse(decodeURIComponent(r)):null,missionControl:n,profile:s})};var y$=async()=>{await _7(),console.log((0,JC.green)("Logged out"))},g$=async e=>{let t=await kp();if((0,f$.isNullish)(t)){await ky(e);return}let r=h$.Ed25519KeyIdentity.fromParsedJson(t);console.log(`\u{1F510} Your terminal is already a controller: ${(0,JC.green)(r.getPrincipal().toText())}
199
- `);let{action:n}=await(0,m$.default)({type:"select",name:"action",message:"What would you like to do?",choices:[{title:"Create a new controller via a login with your browser",value:"login"},{title:"Reuse the existing controller",value:"reuse"}]});if(ns(n),n==="login"){await ky(e);return}await j7(r.getPrincipal())};var iO=at(jt(),1);var ml=at(jt(),1);var b$=at(jt(),1),Vi=`${(0,b$.yellow)("-m, --mode")} Set env mode. For example production or a custom string. Default is production.`,Rn=e=>Rr({args:e,options:["-d","--doc"]})?"doc":"cli";var _i=at(jt(),1);var mx="0.1.4";var Lp=at(jt(),1);var yx="Clear existing dapp code by removing JavaScript, HTML, CSS, and other files from your satellite.",v$=`Usage: ${(0,Lp.green)("juno")} ${(0,Lp.cyan)("clear")} ${(0,Lp.yellow)("[options]")}
199
+ `);let{action:n}=await(0,m$.default)({type:"select",name:"action",message:"What would you like to do?",choices:[{title:"Create a new controller via a login with your browser",value:"login"},{title:"Reuse the existing controller",value:"reuse"}]});if(ns(n),n==="login"){await ky(e);return}await j7(r.getPrincipal())};var iO=at(jt(),1);var ml=at(jt(),1);var b$=at(jt(),1),Vi=`${(0,b$.yellow)("-m, --mode")} Set env mode. For example production or a custom string. Default is production.`,Rn=e=>Rr({args:e,options:["-d","--doc"]})?"doc":"cli";var _i=at(jt(),1);var mx="0.1.5";var Lp=at(jt(),1);var yx="Clear existing dapp code by removing JavaScript, HTML, CSS, and other files from your satellite.",v$=`Usage: ${(0,Lp.green)("juno")} ${(0,Lp.cyan)("clear")} ${(0,Lp.yellow)("[options]")}
200
200
 
201
201
  Options:
202
202
  ${(0,Lp.yellow)("-f, --fullPath")} Clear a particular file of your dapp.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junobuild/cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "The Juno command-line interface",
5
5
  "author": "David Dal Busco (https://daviddalbusco.com)",
6
6
  "license": "MIT",
@@ -12,7 +12,7 @@ ic-cdk = "0.17.1"
12
12
  ic-cdk-macros = "0.17.1"
13
13
  serde = "1.0.217"
14
14
  serde_cbor = "0.11.2"
15
- junobuild-satellite = "= 0.0.22"
15
+ junobuild-satellite = "0.0.22"
16
16
  junobuild-macros = "0.0.4"
17
17
  junobuild-utils = "0.0.4"
18
18
 
@@ -1,18 +1,3 @@
1
- // This file was automatically generated by the Juno CLI.
2
- // Any modifications may be overwritten.
3
-
4
- import service "satellite_extension.did";
5
-
6
- // This file was automatically generated by the Juno CLI.
7
- // Any modifications may be overwritten.
8
-
9
- import service "satellite_extension.did";
10
-
11
- // This file was automatically generated by the Juno CLI.
12
- // Any modifications may be overwritten.
13
-
14
- import service "satellite_extension.did";
15
-
16
1
  type AssetEncodingNoContent = record {
17
2
  modified : nat64;
18
3
  sha256 : blob;