@junobuild/cli 0.0.83 → 0.0.84
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
|
@@ -635,7 +635,7 @@ variant ${r} -> ${s.message}`)}}))return!0;throw new Error(`Invalid ${this.displ
|
|
|
635
635
|
`),this)}stop(){return this.#c?(clearInterval(this.#l),this.#l=void 0,this.#r=0,this.clear(),this.#i.hideCursor&&oD.show(this.#a),this.#i.discardStdin&&vx.stdin.isTTY&&this.#n&&(mD.stop(),this.#n=!1),this):this}succeed(t){return this.stopAndPersist({symbol:Ay.success,text:t})}fail(t){return this.stopAndPersist({symbol:Ay.error,text:t})}warn(t){return this.stopAndPersist({symbol:Ay.warning,text:t})}info(t){return this.stopAndPersist({symbol:Ay.info,text:t})}stopAndPersist(t={}){if(this.#d)return this;let r=t.prefixText??this.#p,n=this.#g(r," "),s=t.symbol??" ",o=t.text??this.text,c=typeof o=="string"?(s?" ":"")+o:"",p=t.suffixText??this.#f,d=this.#b(p," "),l=n+s+c+d+`
|
|
636
636
|
`;return this.stop(),this.#a.write(l),this}};function Uo(e){return new yD(e)}var IV=Tt(Ht(),1);var _V=Tt(la(),1),CV=Tt(Zw(),1);var DV=Tt(Ht(),1);var Uu=async()=>{let e=S_()??await Pp();ir(e)&&(console.log(`${(0,DV.red)("No controller found.")} Are you logged in?`),process.exit(1));let t=CV.Ed25519KeyIdentity.fromParsedJson(e);if(X6.includes(t.getPrincipal().toText()))throw new Error("The controller has been revoked for security reason!");return{identity:t,fetch,...or(process.env.CONTAINER_URL)&&{container:process.env.CONTAINER_URL}}},OV=async()=>{let{identity:e,container:t,fetch:r}=await Uu(),n=or(t)&&t!==!1,s=n?t===!0?"http://127.0.0.1:5987":t:"https://icp-api.io",o=new _V.HttpAgent({identity:e,host:s,retryTimes:10,fetch:r});return n&&await o.fetchRootKey(),o};var ns=async({satellite:{satelliteId:e,id:t,ids:r},env:{mode:n}})=>{let s=r?.[n]??t??e;return ir(s)&&(console.log(`${(0,IV.red)(`A satellite ID for ${n} must be set in your configuration.`)}`),process.exit(1)),{satelliteId:s,...await Uu()}},xx=async e=>(await ny()).find(({p:n})=>n===e)?.n??e,Ex=async e=>{let r=(await Ac())?.find(({p:n})=>n===e);return r?.n!==void 0&&r?.n!==""?r.n:e};var Tx=async e=>{let t=Ls(e),{satellite:r}=await Us(t),n=await ns({satellite:r,env:t}),s=Uo("Clearing dapp assets...").start();try{let o=await jp({satellite:n});await AU({collection:h0,satellite:n}),await rx({satellite:n,domains:o})}finally{s.stop()}},qEe=e=>{let t=e.replace(/\\/g,"/");return`${t.startsWith("/")?"":"/"}${t}`},NV=async({fullPath:e,args:t})=>{let r=Ls(t),{satellite:n}=await Us(r),s=await ns({satellite:n,env:r}),o=Uo(`Clearing ${e}...`).start();try{await XU({collection:h0,satellite:s,fullPath:qEe(e)})}finally{o.stop()}};var FV=Tt(Ht(),1),Mf=()=>{console.log(`Oops! ${(0,FV.red)("No config file found.")} Try to run the command from your project root.`)};var kV=async e=>{if(!await $s()){Mf();return}if(mn({args:e,options:["-f","--fullpath","--fullPath"]})){let t=yn({args:e,option:"-f"})??yn({args:e,option:"--fullpath"})??yn({args:e,option:"--fullPath"});if(ir(t)){console.log(`You did not provide a ${(0,BV.yellow)("fullPath")} to delete.`);return}await NV({fullPath:t,args:e});return}await Tx(e)};var Fy=Tt(nq(),1),oq=Tt(un(),1);var Ny=Tt(Ht(),1),$f=Tt(yc(),1);import{unlink as qTe}from"node:fs/promises";import{basename as KTe}from"node:path";var iq=Tt(yc(),1),Px=async()=>{let{configType:e}=await(0,iq.default)({type:"select",name:"configType",message:"What configuration file format do you prefer?",choices:[{title:"TypeScript",value:"ts"},{title:"JavaScript",value:"js"},{title:"JSON",value:"json"}],initial:0});return Hi(e),e};import{existsSync as _x}from"node:fs";import{join as Cx}from"node:path";var sq=()=>{let e=Cx(process.cwd(),"pnpm-lock.yaml");if(_x(e))return"pnpm";let t=Cx(process.cwd(),"yarn.lock");if(_x(t))return"yarn";let r=Cx(process.cwd(),"bun.lockb");if(_x(r))return"bun";let n=Cx(process.cwd(),"package-lock.json");if(_x(n))return"npm"};var Uf=async e=>{let t=await Pp();if(ir(t)){if(!await Dd(`Your terminal is not authenticated. Would you like to ${(0,Ny.cyan)("log in")} now?`))return;await ly(e)}await $s()&&await es("Your existing configuration will be overwritten. Are you sure you want to continue?"),await WTe()},WTe=async()=>{let e=await HTe(),t=await GTe(),r=await JTe(),{configType:n,configPath:s}=await YTe(),o=sq();await c$({config:{satellite:{id:e,source:r},...or(t)&&{orbiter:{id:t}}},configType:n,configPath:s,pm:o}),or(s)&&KTe(s)==="juno.json"&&await qTe(s),n!=="json"&&console.log(`${Zi}\u{1F4A1} You can leverage your IDE's intellisense with type hints by installing the library: ${(0,Ny.yellow)("npm i @junobuild/config -D")}${Zi}`)},HTe=async()=>{let e=await ny(),t=await(e?.length>0?zTe(e):aq());return t==="_manual_"?await aq():t},GTe=async()=>{let e=await Ac();if(e===void 0||e.length===0)return;let t=await XTe(e);if(t!=="_none_")return t},zTe=async e=>{let{satellite:t}=await(0,$f.default)({type:"select",name:"satellite",message:"Which satellite should be linked with this dapp?",choices:[...e.map(({p:r,n})=>({title:n,value:r})),{title:"<not listed, manual entry>",value:"_manual_"}],initial:0});return Hi(t),t},YTe=async()=>{if(!await $s()){let e=u$();return or(e)?e:{configType:await Px()}}return l$()},aq=async()=>{let{satellite:e}=await(0,$f.default)([{type:"text",name:"satellite",message:`What's the ${(0,Ny.cyan)("id")} of your satellite?`}]);return Hi(e,"The satellite ID is mandatory"),e},JTe=async()=>{let{output:e}=await(0,$f.default)({type:"select",name:"output",message:"What is the output folder of your `npm run build` command?",choices:[{title:"build",value:"build"},{title:"dist",value:"dist"},{title:"<not listed, manual entry>",value:"_manual_"}],initial:0});if(Hi(e),e!=="_manual_")return e;let{source:t}=await(0,$f.default)([{type:"text",name:"source",message:"Please enter the name of your output folder"}]);return Hi(t),t},XTe=async e=>{let{orbiter:t}=await(0,$f.default)({type:"select",name:"orbiter",message:"Which orbiter do you use for the analytics in this dapp?",choices:[...e.map(({p:r,n})=>({title:n??r,value:r})),{title:"<none>",value:"_none_"}],initial:0});return Hi(t),t};var lq=async e=>{await $s()||await Uf();let t=Ls(e),{satellite:r}=await Us(t),{storage:n,authentication:s,datastore:o,settings:a}=r,c=await ns({satellite:r,env:t}),p=Uo("Configuring...").start();try{await Promise.allSettled([vU({config:{headers:n?.headers??[],rewrites:n?.rewrites,redirects:n?.redirects,iframe:n?.iframe,rawAccess:n?.rawAccess,maxMemorySize:n?.maxMemorySize},satellite:c}),...ir(o)?[]:[xU({config:o,satellite:c})],...ir(s)?[]:[EU({config:s,satellite:c})],...ir(a)?[]:[QTe({settings:a,satellite:c})]])}finally{p.stop()}},QTe=async({settings:e,satellite:t})=>{let{freezingThreshold:r,reservedCyclesLimit:n,logVisibility:s,heapMemoryLimit:o,memoryAllocation:a,computeAllocation:c}=e,{satelliteId:p}=t,d=await OV(),{updateSettings:l}=Fy.ICManagementCanister.create({agent:d});await l({canisterId:oq.Principal.fromText(p),settings:{freezingThreshold:r,reservedCyclesLimit:n,logVisibility:ir(s)?void 0:s==="public"?Fy.LogVisibility.Public:Fy.LogVisibility.Controllers,wasmMemoryLimit:o,memoryAllocation:a,computeAllocation:c}})};var mq=Tt(Ht(),1);import{lstatSync as ewe}from"node:fs";var pq=Tt(Ht(),1),dq=Tt(Ap(),1);var uq="0.0.14",cq=900000000n;var hq=async e=>{let t=Ls(e),{satellite:r}=await Us(t),{assertions:n}=r;if(n?.heapMemory===!1)return;let s=await ns({satellite:r,env:t}),o=await Ud({satellite:s});if((0,dq.compare)(o,uq)<0){console.log(`Your satellite (${(0,pq.yellow)(`v${o}`)}) is not up-to-date, and the memory size cannot be verified.${Zi}`);return}let a=n?.heapMemory!==void 0&&typeof n?.heapMemory!="boolean"?BigInt(n?.heapMemory):cq,{heap:c}=await SU({satellite:s});if(c<a)return;let p=d=>Intl.NumberFormat("en-US",{maximumSignificantDigits:3}).format(Number(d)/1e6);await es(`\u26A0\uFE0F Your satellite's heap memory is ${p(c)} MB, which exceeds the recommended limit of ${p(a)} MB. Are you sure you want to proceed with the deployment?`)},PD=async({startAfter:e,env:t})=>{let{assets:r,items_page:n,matches_pages:s}=await JU({collection:h0,satellite:await ns(t),filter:{order:{desc:!0,field:"keys"},paginate:{startAfter:e,limit:500}}}),o=a=>{let{length:c,[c-1]:p}=a;return p};if((n??0n)<(s??0n)){let a=await PD({startAfter:o(r)?.fullPath,env:t});return[...r,...a]}return r};var fq=Tt(Ht(),1);var Vf=e=>`https://${e}.icp0.io`,Dx=e=>`${Y6}${e}`;var Ox=async e=>{if(yv()||!await $s())return;let t=Ls(e),{satellite:r}=await Us(t),n=await ns({satellite:r,env:t}),{satelliteId:s}=n,o=Vf(s),a=Dx(s);try{let c=await jp({satellite:n});if(console.log(`
|
|
637
637
|
\u{1F6E0}\uFE0F ${bf(a)}`),c.length===0){console.log(`\u{1F6F0}\uFE0F ${bf(o)}`);return}c.forEach(({domain:p})=>{console.log(`\u{1F30D} ${bf(`https://${p}`)}`)})}catch{console.log(`${(0,fq.red)("Cannot list the custom domains.")}`)}};var yq=async e=>{await $s()||await Uf(),mn({args:e,options:["-c","--clear"]})&&await Tx(e),await twe(e),await Ox(e)},twe=async e=>{let t=Ls(e),{satellite:r}=await Us(t),n=async({startAfter:c})=>await PD({startAfter:c,env:{env:t,satellite:r}}),s=async()=>{await hq(e)},o=await ns({satellite:r,env:t}),a=async({filename:c,fullPath:p,data:d,collection:l,headers:m,encoding:y})=>{await YU({satellite:o,filename:c,fullPath:p,data:d,collection:l,headers:m,encoding:y})};await EI({config:r}),await wI({config:r,listAssets:n,assertSourceDirExists:rwe,assertMemory:s,uploadFile:a}),await TI({config:r})},rwe=e=>{try{ewe(e)}catch{console.log(`${(0,mq.red)("Cannot proceed deployment.")}
|
|
638
|
-
Are you sure the folder containing your built app (the "source" tag in the configuration file for Juno) files is correctly configured, or have you built your app?`),process.exit(1)}};var qK=Tt(Ht(),1);var qu=Tt(Ht(),1);var gq=Tt(Ht(),1),Vo=`${(0,gq.yellow)("-m, --mode")} Set env mode. For example production or a custom string. Default is production.`,Mi=e=>mn({args:e,options:["-d","--doc"]})?"doc":"cli";var Si=Tt(Ht(),1);var Ix="0.0.
|
|
638
|
+
Are you sure the folder containing your built app (the "source" tag in the configuration file for Juno) files is correctly configured, or have you built your app?`),process.exit(1)}};var qK=Tt(Ht(),1);var qu=Tt(Ht(),1);var gq=Tt(Ht(),1),Vo=`${(0,gq.yellow)("-m, --mode")} Set env mode. For example production or a custom string. Default is production.`,Mi=e=>mn({args:e,options:["-d","--doc"]})?"doc":"cli";var Si=Tt(Ht(),1);var Ix="0.0.84";var Rp=Tt(Ht(),1);var Nx="Clear existing dapp code by removing JavaScript, HTML, CSS, and other files from your satellite.",bq=`Usage: ${(0,Rp.green)("juno")} ${(0,Rp.cyan)("clear")} ${(0,Rp.yellow)("[options]")}
|
|
639
639
|
|
|
640
640
|
Options:
|
|
641
641
|
${(0,Rp.yellow)("-f, --fullPath")} Clear a particular file of your dapp.
|
package/package.json
CHANGED
|
@@ -8,11 +8,11 @@ crate-type = ["cdylib"]
|
|
|
8
8
|
|
|
9
9
|
[dependencies]
|
|
10
10
|
candid = "0.10.2"
|
|
11
|
-
ic-cdk = "0.
|
|
12
|
-
ic-cdk-macros = "0.
|
|
11
|
+
ic-cdk = "0.17.0"
|
|
12
|
+
ic-cdk-macros = "0.17.0"
|
|
13
13
|
serde = "1.0.190"
|
|
14
14
|
serde_cbor = "0.11.2"
|
|
15
|
-
junobuild-satellite = "0.0.
|
|
16
|
-
junobuild-macros = "0.0.
|
|
17
|
-
junobuild-utils = "0.0.
|
|
15
|
+
junobuild-satellite = "= 0.0.21-patch.1"
|
|
16
|
+
junobuild-macros = "0.0.3"
|
|
17
|
+
junobuild-utils = "0.0.4"
|
|
18
18
|
|
|
@@ -117,6 +117,7 @@ type ListResults_1 = record {
|
|
|
117
117
|
type Memory = variant { Heap; Stable };
|
|
118
118
|
type MemorySize = record { stable : nat64; heap : nat64 };
|
|
119
119
|
type Permission = variant { Controllers; Private; Public; Managed };
|
|
120
|
+
type RateConfig = record { max_tokens : nat64; time_per_token_ns : nat64 };
|
|
120
121
|
type Rule = record {
|
|
121
122
|
max_capacity : opt nat32;
|
|
122
123
|
memory : opt Memory;
|
|
@@ -126,6 +127,7 @@ type Rule = record {
|
|
|
126
127
|
created_at : nat64;
|
|
127
128
|
version : opt nat64;
|
|
128
129
|
mutable_permissions : opt bool;
|
|
130
|
+
rate_config : opt RateConfig;
|
|
129
131
|
write : Permission;
|
|
130
132
|
};
|
|
131
133
|
type RulesType = variant { Db; Storage };
|
|
@@ -150,6 +152,7 @@ type SetRule = record {
|
|
|
150
152
|
read : Permission;
|
|
151
153
|
version : opt nat64;
|
|
152
154
|
mutable_permissions : opt bool;
|
|
155
|
+
rate_config : opt RateConfig;
|
|
153
156
|
write : Permission;
|
|
154
157
|
};
|
|
155
158
|
type StorageConfig = record {
|
|
@@ -208,6 +211,8 @@ service : () -> {
|
|
|
208
211
|
del_custom_domain : (text) -> ();
|
|
209
212
|
del_doc : (text, text, DelDoc) -> ();
|
|
210
213
|
del_docs : (text) -> ();
|
|
214
|
+
del_filtered_assets : (text, ListParams) -> ();
|
|
215
|
+
del_filtered_docs : (text, ListParams) -> ();
|
|
211
216
|
del_many_assets : (vec record { text; text }) -> ();
|
|
212
217
|
del_many_docs : (vec record { text; text; DelDoc }) -> ();
|
|
213
218
|
del_rule : (RulesType, text, DelRule) -> ();
|
|
@@ -223,6 +228,7 @@ service : () -> {
|
|
|
223
228
|
get_many_docs : (vec record { text; text }) -> (
|
|
224
229
|
vec record { text; opt Doc },
|
|
225
230
|
) query;
|
|
231
|
+
get_rule : (RulesType, text) -> (opt Rule) query;
|
|
226
232
|
get_storage_config : () -> (StorageConfig) query;
|
|
227
233
|
http_request : (HttpRequest) -> (HttpResponse) query;
|
|
228
234
|
http_request_streaming_callback : (StreamingCallbackToken) -> (
|
|
@@ -245,7 +251,7 @@ service : () -> {
|
|
|
245
251
|
set_many_docs : (vec record { text; text; SetDoc }) -> (
|
|
246
252
|
vec record { text; Doc },
|
|
247
253
|
);
|
|
248
|
-
set_rule : (RulesType, text, SetRule) -> ();
|
|
254
|
+
set_rule : (RulesType, text, SetRule) -> (Rule);
|
|
249
255
|
set_storage_config : (StorageConfig) -> ();
|
|
250
256
|
upload_asset_chunk : (UploadChunk) -> (UploadChunkResult);
|
|
251
257
|
version : () -> (text) query;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
use junobuild_macros::{
|
|
2
2
|
assert_delete_asset, assert_delete_doc, assert_set_doc, assert_upload_asset, on_delete_asset,
|
|
3
|
-
on_delete_doc,
|
|
4
|
-
on_upload_asset,
|
|
3
|
+
on_delete_doc, on_delete_filtered_assets, on_delete_filtered_docs, on_delete_many_assets,
|
|
4
|
+
on_delete_many_docs, on_set_doc, on_set_many_docs, on_upload_asset,
|
|
5
5
|
};
|
|
6
6
|
use junobuild_satellite::{
|
|
7
7
|
include_satellite, AssertDeleteAssetContext, AssertDeleteDocContext, AssertSetDocContext,
|
|
8
|
-
AssertUploadAssetContext, OnDeleteAssetContext, OnDeleteDocContext,
|
|
8
|
+
AssertUploadAssetContext, OnDeleteAssetContext, OnDeleteDocContext,
|
|
9
|
+
OnDeleteFilteredAssetsContext, OnDeleteFilteredDocsContext, OnDeleteManyAssetsContext,
|
|
9
10
|
OnDeleteManyDocsContext, OnSetDocContext, OnSetManyDocsContext, OnUploadAssetContext,
|
|
10
11
|
};
|
|
11
12
|
|
|
@@ -29,6 +30,11 @@ async fn on_delete_many_docs(_context: OnDeleteManyDocsContext) -> Result<(), St
|
|
|
29
30
|
Ok(())
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
#[on_delete_filtered_docs]
|
|
34
|
+
async fn on_delete_filtered_docs(_context: OnDeleteFilteredDocsContext) -> Result<(), String> {
|
|
35
|
+
Ok(())
|
|
36
|
+
}
|
|
37
|
+
|
|
32
38
|
#[on_upload_asset]
|
|
33
39
|
async fn on_upload_asset(_context: OnUploadAssetContext) -> Result<(), String> {
|
|
34
40
|
Ok(())
|
|
@@ -44,6 +50,10 @@ async fn on_delete_many_assets(_context: OnDeleteManyAssetsContext) -> Result<()
|
|
|
44
50
|
Ok(())
|
|
45
51
|
}
|
|
46
52
|
|
|
53
|
+
#[on_delete_filtered_assets]
|
|
54
|
+
async fn on_delete_filtered_assets(_context: OnDeleteFilteredAssetsContext) -> Result<(), String> {
|
|
55
|
+
Ok(())
|
|
56
|
+
}
|
|
47
57
|
#[assert_set_doc]
|
|
48
58
|
fn assert_set_doc(_context: AssertSetDocContext) -> Result<(), String> {
|
|
49
59
|
Ok(())
|