@capgo/cli 0.7.4 → 0.8.1

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/.cz.toml CHANGED
@@ -1,7 +1,7 @@
1
1
  [tool.commitizen]
2
2
  name = "cz_conventional_commits"
3
3
  tag_format = "$major.$minor.$patch$prerelease"
4
- version = "0.7.4"
4
+ version = "0.8.1"
5
5
  version_files = [
6
6
  "package.json:version",
7
7
  ".cz.toml"
package/.eslintignore CHANGED
@@ -1,2 +1,3 @@
1
1
  dist
2
+ test
2
3
  webpack.config.js
package/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ ## 0.8.1 (2022-04-29)
2
+
3
+ ### Fix
4
+
5
+ - lint issue
6
+
7
+ ## 0.8.0 (2022-04-29)
8
+
9
+ ### Feat
10
+
11
+ - add --version
12
+
13
+ ## 0.7.6 (2022-04-21)
14
+
15
+ ### Fix
16
+
17
+ - use back binary
18
+
19
+ ## 0.7.5 (2022-04-21)
20
+
21
+ ### Fix
22
+
23
+ - remove useless
24
+
1
25
  ## 0.7.4 (2022-04-21)
2
26
 
3
27
  ### Fix
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- (()=>{"use strict";var o={307:function(o,e,r){var t=this&&this.__awaiter||function(o,e,r,t){return new(r||(r=Promise))((function(a,n){function i(o){try{d(t.next(o))}catch(o){n(o)}}function p(o){try{d(t.throw(o))}catch(o){n(o)}}function d(o){var e;o.done?a(o.value):(e=o.value,e instanceof r?e:new r((function(o){o(e)}))).then(i,p)}d((t=t.apply(o,e||[])).next())}))},a=this&&this.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(e,"__esModule",{value:!0}),e.addApp=void 0;const n=r(778),i=a(r(167)),p=a(r(867)),d=r(304),l=r(147),s=r(470),u=r(11),c=r(406);e.addApp=(o,e)=>t(void 0,void 0,void 0,(function*(){var r,t;let{name:a,icon:v}=e;const{apikey:h}=e;let f,g;try{f=yield(0,n.loadConfig)()}catch(o){d.program.error("No capacitor config file found, run `cap init` first")}o=o||(null===(r=null==f?void 0:f.app)||void 0===r?void 0:r.appId),a=a||(null===(t=null==f?void 0:f.app)||void 0===t?void 0:t.appName)||"Unknown",v=v||"resources/icon.png",h||d.program.error("Missing API key, you need to provide a API key to add your app"),o&&a||d.program.error("Missing argument, you need to provide a appid and a name, or be in a capacitor project"),console.log(`Add ${o} to Capgo`);try{console.log("Adding...");const e={appid:o,name:a};if(v&&(0,s.existsSync)(v)){const o=(0,l.readFileSync)(v),r=(0,u.getType)(v);e.icon=o.toString("base64"),e.iconType=r}g=yield(0,i.default)({method:"POST",url:`${c.host}/api/add`,data:e,validateStatus:()=>!0,headers:{authorization:h}})}catch(o){d.program.error(`Network Error \n${p.default.render(o.response.data)}`)}g&&200===g.status||d.program.error(`Server Error \n${p.default.render(g.data)}`),console.log("App added to server, you can upload a version now")}))},755:function(o,e,r){var t=this&&this.__awaiter||function(o,e,r,t){return new(r||(r=Promise))((function(a,n){function i(o){try{d(t.next(o))}catch(o){n(o)}}function p(o){try{d(t.throw(o))}catch(o){n(o)}}function d(o){var e;o.done?a(o.value):(e=o.value,e instanceof r?e:new r((function(o){o(e)}))).then(i,p)}d((t=t.apply(o,e||[])).next())}))},a=this&&this.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(e,"__esModule",{value:!0}),e.deleteApp=void 0;const n=r(778),i=a(r(167)),p=a(r(867)),d=r(304),l=r(406);e.deleteApp=(o,e)=>t(void 0,void 0,void 0,(function*(){var r;const{apikey:t,version:a}=e;let s,u;try{s=yield(0,n.loadConfig)()}catch(o){d.program.error("No capacitor config file found, run `cap init` first")}o=o||(null===(r=null==s?void 0:s.app)||void 0===r?void 0:r.appId),t||d.program.error("Missing API key, you need to provide an API key to delete your app"),o||d.program.error("Missing argument, you need to provide a appid, or be in a capacitor project"),console.log(`Delete ${o} to Capgo`);try{console.log("Deleting..."),u=yield(0,i.default)({method:"POST",url:`${l.host}/api/delete`,data:{appid:o,version:a},validateStatus:()=>!0,headers:{authorization:t}})}catch(o){d.program.error(`Network Error \n${p.default.render(o.response.data)}`)}u&&200===u.status||d.program.error(`Server Error \n${p.default.render(u.data)}`),console.log("App deleted to server")}))},527:function(o,e,r){var t=this&&this.__awaiter||function(o,e,r,t){return new(r||(r=Promise))((function(a,n){function i(o){try{d(t.next(o))}catch(o){n(o)}}function p(o){try{d(t.throw(o))}catch(o){n(o)}}function d(o){var e;o.done?a(o.value):(e=o.value,e instanceof r?e:new r((function(o){o(e)}))).then(i,p)}d((t=t.apply(o,e||[])).next())}))},a=this&&this.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(e,"__esModule",{value:!0}),e.setChannel=void 0;const n=r(778),i=a(r(167)),p=a(r(867)),d=r(304),l=r(406);e.setChannel=(o,e)=>t(void 0,void 0,void 0,(function*(){var r;const{apikey:t,version:a,state:s,channel:u="dev"}=e;let c,v,h;try{c=yield(0,n.loadConfig)()}catch(o){d.program.error("No capacitor config file found, run `cap init` first")}o=o||(null===(r=null==c?void 0:c.app)||void 0===r?void 0:r.appId),"public"!==s&&"private"!==s||(h="public"===s),t||d.program.error("Missing API key, you need to provide a API key to add your app"),o||d.program.error("Missing argument, you need to provide a appid, or be in a capacitor project"),a||h||d.program.error("Missing argument, you need to provide a state or a version"),a?console.log(`Set ${u} to @${a} in ${o}`):console.log(`Set${u} to @${s} in ${o}`);try{v=yield(0,i.default)({method:"POST",url:`${l.host}/api/channel`,data:{version:a,public:h,appid:o,channel:u},validateStatus:()=>!0,headers:{authorization:t}})}catch(o){d.program.error(`Network Error \n${p.default.render(o.response.data)}`)}v&&200===v.status||d.program.error(`Server Error \n${p.default.render(v.data)}`),a?console.log("Done ✅"):console.log(`You can use now is channel in your app with the url: ${l.host}/api/latest?appid=${o}&channel=${u}`)}))},571:function(o,e,r){var t=this&&this.__awaiter||function(o,e,r,t){return new(r||(r=Promise))((function(a,n){function i(o){try{d(t.next(o))}catch(o){n(o)}}function p(o){try{d(t.throw(o))}catch(o){n(o)}}function d(o){var e;o.done?a(o.value):(e=o.value,e instanceof r?e:new r((function(o){o(e)}))).then(i,p)}d((t=t.apply(o,e||[])).next())}))},a=this&&this.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(e,"__esModule",{value:!0}),e.uploadVersion=void 0;const n=r(778),i=a(r(844)),p=a(r(167)),d=a(r(867)),l=r(304),s=a(r(295)),u=r(406),c=1048576,v="base64";e.uploadVersion=(o,e)=>t(void 0,void 0,void 0,(function*(){var r,t,a,h,f,g;let{version:y,path:m,channel:k}=e;const{apikey:w,external:_}=e;let $;k=k||"dev";try{$=yield(0,n.loadConfig)()}catch(o){l.program.error("No capacitor config file found, run `cap init` first")}if(o=o||(null===(r=null==$?void 0:$.app)||void 0===r?void 0:r.appId),y=y||(null===(a=null===(t=null==$?void 0:$.app)||void 0===t?void 0:t.package)||void 0===a?void 0:a.version),m=m||(null===(h=null==$?void 0:$.app)||void 0===h?void 0:h.webDir),w||l.program.error("Missing API key, you need to provide a API key to add your app"),o&&y&&m||l.program.error("Missing argument, you need to provide a appid and a version and a path, or be in a capacitor project"),console.log(`Upload ${o}@${y} started from path "${m}" to Capgo cloud`),_)try{const e=yield(0,p.default)({method:"POST",url:u.hostUpload,data:{version:y,appid:o,channel:k,external:_},validateStatus:()=>!0,headers:{"Content-Type":"application/json",apikey:w,authorization:`Bearer ${u.supaAnon}`}});200!==e.status&&l.program.error(`Server Error \n${d.default.render((null==e?void 0:e.data)||"")}`)}catch(o){o.response?l.program.error(`Network Error \n${d.default.render((null===(f=o.response)||void 0===f?void 0:f.data)||"")}`):l.program.error(`Network Error \n${d.default.render(o||"")}`)}else{const e=new s.default.SingleBar({},s.default.Presets.shades_grey);try{const r=new i.default;r.addLocalFolder(m),console.log("Uploading:");const t=r.toBuffer(),a=t.toString(v),n=Buffer.byteLength(t),s=(b=t.length,x=c,Math.round(b/((o,e)=>o<e?o:Math.round(o/e))(b,x)));n>31457280&&l.program.error(`The app is too big, the limit is 30 Mb, your is ${Math.round(n/c)} Mb`);const h=[];for(let o=0;o<a.length;o+=s)h.push(a.slice(o,o+s));let f;e.start(h.length,0,{speed:"N/A"});for(let r=0;r<h.length;r+=1){const t=yield(0,p.default)({method:"POST",url:u.hostUpload,data:{version:y,appid:o,fileName:f,channel:k,format:v,app:h[r],isMultipart:h.length>1,chunk:r+1,totalChunks:h.length},validateStatus:()=>!0,headers:{"Content-Type":"application/json",apikey:w,authorization:`Bearer ${u.supaAnon}`}});200!==t.status&&(e.stop(),l.program.error(`Server Error \n${d.default.render((null==t?void 0:t.data)||"")}`)),e.update(r+1),f=t.data.fileName}e.stop()}catch(o){e.stop(),o.response?l.program.error(`Network Error \n${d.default.render((null===(g=o.response)||void 0===g?void 0:g.data)||"")}`):l.program.error(`Network Error \n${d.default.render(o||"")}`)}}var b,x;console.log("App uploaded to server"),console.log(`Try it in mobile app: ${u.host}/app_mobile`),console.log(`Or set the channel ${k} as public here: ${u.hostWeb}/app/package/${o}`),console.log("To use with live update in your own app")}))},406:(o,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.supaAnon=e.hostUpload=e.hostWeb=e.host=void 0,e.host="https://capgo.app",e.hostWeb="https://web.capgo.app",e.hostUpload="https://xvwzpoazmxkqosrdewyv.functions.supabase.co/upload",e.supaAnon="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYzNzgwNTAwOSwiZXhwIjoxOTUzMzgxMDA5fQ.8tgID1d4jodPwuo_fz4KHN4o1XKB9fnqyt0_GaJSj-w"},778:o=>{o.exports=require("@capacitor/cli/dist/config")},844:o=>{o.exports=require("adm-zip")},167:o=>{o.exports=require("axios")},295:o=>{o.exports=require("cli-progress")},304:o=>{o.exports=require("commander")},470:o=>{o.exports=require("fs-extra")},11:o=>{o.exports=require("mime")},867:o=>{o.exports=require("prettyjson")},147:o=>{o.exports=require("fs")}},e={};function r(t){var a=e[t];if(void 0!==a)return a.exports;var n=e[t]={exports:{}};return o[t].call(n.exports,n,n.exports,r),n.exports}(()=>{const o=r(304),e=r(307),t=r(755),a=r(527),n=r(571);o.program.command("add [appid]").alias("a").action(e.addApp).option("-n, --name <name>","app name").option("-i, --icon <icon>","app icon path").option("-a, --apikey <apikey>","apikey to link to your account"),o.program.command("upload [appid]").alias("u").action(n.uploadVersion).option("-a, --apikey <apikey>","apikey to link to your account").option("-p, --path <path>","path of the file to upload").option("-c, --channel <channel>","channel to link to").option("-e, --externa <url>","link to external url intead of upload to capgo cloud").option("-v, --version <version>","version number of the file to upload"),o.program.command("set [appid]").alias("s").action(a.setChannel).option("-c, --channel <channel>","channel to link to").option("-v, --version <version>","version number of the file to upload").option("-s, --state <state>","set the state of the channel, public or private").option("-a, --apikey <apikey>","apikey to link to your account"),o.program.description("Manage package and version in capgo Cloud").command("delete [appid]").alias("a").action(t.deleteApp).option("-a, --apikey <apikey>","apikey to link to your account").option("-v, --version <version>","version number of the app to delete"),o.program.parse(process.argv)})()})();
2
+ (()=>{"use strict";var e={307:function(e,o,t){var r=this&&this.__awaiter||function(e,o,t,r){return new(t||(t=Promise))((function(a,n){function i(e){try{s(r.next(e))}catch(e){n(e)}}function p(e){try{s(r.throw(e))}catch(e){n(e)}}function s(e){var o;e.done?a(e.value):(o=e.value,o instanceof t?o:new t((function(e){e(o)}))).then(i,p)}s((r=r.apply(e,o||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.addApp=void 0;const n=t(778),i=a(t(167)),p=a(t(867)),s=t(304),d=t(147),l=t(470),c=t(11),u=t(406);o.addApp=(e,o)=>r(void 0,void 0,void 0,(function*(){var t,r;let{name:a,icon:v}=o;const{apikey:f}=o;let h,g;try{h=yield(0,n.loadConfig)()}catch(e){s.program.error("No capacitor config file found, run `cap init` first")}e=e||(null===(t=null==h?void 0:h.app)||void 0===t?void 0:t.appId),a=a||(null===(r=null==h?void 0:h.app)||void 0===r?void 0:r.appName)||"Unknown",v=v||"resources/icon.png",f||s.program.error("Missing API key, you need to provide a API key to add your app"),e&&a||s.program.error("Missing argument, you need to provide a appid and a name, or be in a capacitor project"),console.log(`Add ${e} to Capgo`);try{console.log("Adding...");const o={appid:e,name:a};if(v&&(0,l.existsSync)(v)){const e=(0,d.readFileSync)(v),t=(0,c.getType)(v);o.icon=e.toString("base64"),o.iconType=t}g=yield(0,i.default)({method:"POST",url:`${u.host}/api/add`,data:o,validateStatus:()=>!0,headers:{authorization:f}})}catch(e){s.program.error(`Network Error \n${p.default.render(e.response.data)}`)}g&&200===g.status||s.program.error(`Server Error \n${p.default.render(g.data)}`),console.log("App added to server, you can upload a version now")}))},755:function(e,o,t){var r=this&&this.__awaiter||function(e,o,t,r){return new(t||(t=Promise))((function(a,n){function i(e){try{s(r.next(e))}catch(e){n(e)}}function p(e){try{s(r.throw(e))}catch(e){n(e)}}function s(e){var o;e.done?a(e.value):(o=e.value,o instanceof t?o:new t((function(e){e(o)}))).then(i,p)}s((r=r.apply(e,o||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.deleteApp=void 0;const n=t(778),i=a(t(167)),p=a(t(867)),s=t(304),d=t(406);o.deleteApp=(e,o)=>r(void 0,void 0,void 0,(function*(){var t;const{apikey:r,version:a}=o;let l,c;try{l=yield(0,n.loadConfig)()}catch(e){s.program.error("No capacitor config file found, run `cap init` first")}e=e||(null===(t=null==l?void 0:l.app)||void 0===t?void 0:t.appId),r||s.program.error("Missing API key, you need to provide an API key to delete your app"),e||s.program.error("Missing argument, you need to provide a appid, or be in a capacitor project"),console.log(`Delete ${e} to Capgo`);try{console.log("Deleting..."),c=yield(0,i.default)({method:"POST",url:`${d.host}/api/delete`,data:{appid:e,version:a},validateStatus:()=>!0,headers:{authorization:r}})}catch(e){s.program.error(`Network Error \n${p.default.render(e.response.data)}`)}c&&200===c.status||s.program.error(`Server Error \n${p.default.render(c.data)}`),console.log("App deleted to server")}))},655:function(e,o,t){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0});const a=t(304),n=t(307),i=t(755),p=t(527),s=t(571),d=r(t(598));a.program.version(d.default.version).command("add [appid]").alias("a").action(n.addApp).option("-n, --name <name>","app name").option("-i, --icon <icon>","app icon path").option("-a, --apikey <apikey>","apikey to link to your account"),a.program.command("upload [appid]").alias("u").action(s.uploadVersion).option("-a, --apikey <apikey>","apikey to link to your account").option("-p, --path <path>","path of the file to upload").option("-c, --channel <channel>","channel to link to").option("-e, --externa <url>","link to external url intead of upload to capgo cloud").option("-v, --version <version>","version number of the file to upload"),a.program.command("set [appid]").alias("s").action(p.setChannel).option("-c, --channel <channel>","channel to link to").option("-v, --version <version>","version number of the file to upload").option("-s, --state <state>","set the state of the channel, public or private").option("-a, --apikey <apikey>","apikey to link to your account"),a.program.description("Manage package and version in capgo Cloud").command("delete [appid]").alias("a").action(i.deleteApp).option("-a, --apikey <apikey>","apikey to link to your account").option("-v, --version <version>","version number of the app to delete"),a.program.parse(process.argv)},527:function(e,o,t){var r=this&&this.__awaiter||function(e,o,t,r){return new(t||(t=Promise))((function(a,n){function i(e){try{s(r.next(e))}catch(e){n(e)}}function p(e){try{s(r.throw(e))}catch(e){n(e)}}function s(e){var o;e.done?a(e.value):(o=e.value,o instanceof t?o:new t((function(e){e(o)}))).then(i,p)}s((r=r.apply(e,o||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.setChannel=void 0;const n=t(778),i=a(t(167)),p=a(t(867)),s=t(304),d=t(406);o.setChannel=(e,o)=>r(void 0,void 0,void 0,(function*(){var t;const{apikey:r,version:a,state:l,channel:c="dev"}=o;let u,v,f;try{u=yield(0,n.loadConfig)()}catch(e){s.program.error("No capacitor config file found, run `cap init` first")}e=e||(null===(t=null==u?void 0:u.app)||void 0===t?void 0:t.appId),"public"!==l&&"private"!==l||(f="public"===l),r||s.program.error("Missing API key, you need to provide a API key to add your app"),e||s.program.error("Missing argument, you need to provide a appid, or be in a capacitor project"),a||f||s.program.error("Missing argument, you need to provide a state or a version"),a?console.log(`Set ${c} to @${a} in ${e}`):console.log(`Set${c} to @${l} in ${e}`);try{v=yield(0,i.default)({method:"POST",url:`${d.host}/api/channel`,data:{version:a,public:f,appid:e,channel:c},validateStatus:()=>!0,headers:{authorization:r}})}catch(e){s.program.error(`Network Error \n${p.default.render(e.response.data)}`)}v&&200===v.status||s.program.error(`Server Error \n${p.default.render(v.data)}`),a?console.log("Done ✅"):console.log(`You can use now is channel in your app with the url: ${d.host}/api/latest?appid=${e}&channel=${c}`)}))},571:function(e,o,t){var r=this&&this.__awaiter||function(e,o,t,r){return new(t||(t=Promise))((function(a,n){function i(e){try{s(r.next(e))}catch(e){n(e)}}function p(e){try{s(r.throw(e))}catch(e){n(e)}}function s(e){var o;e.done?a(e.value):(o=e.value,o instanceof t?o:new t((function(e){e(o)}))).then(i,p)}s((r=r.apply(e,o||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.uploadVersion=void 0;const n=t(778),i=a(t(844)),p=a(t(167)),s=a(t(867)),d=t(304),l=a(t(295)),c=t(406),u=1048576,v="binary";o.uploadVersion=(e,o)=>r(void 0,void 0,void 0,(function*(){var t,r,a,f,h,g;let{version:y,path:m,channel:k}=o;const{apikey:b,external:w}=o;let x;k=k||"dev";try{x=yield(0,n.loadConfig)()}catch(e){d.program.error("No capacitor config file found, run `cap init` first")}if(e=e||(null===(t=null==x?void 0:x.app)||void 0===t?void 0:t.appId),y=y||(null===(a=null===(r=null==x?void 0:x.app)||void 0===r?void 0:r.package)||void 0===a?void 0:a.version),m=m||(null===(f=null==x?void 0:x.app)||void 0===f?void 0:f.webDir),b||d.program.error("Missing API key, you need to provide a API key to add your app"),e&&y&&m||d.program.error("Missing argument, you need to provide a appid and a version and a path, or be in a capacitor project"),console.log(`Upload ${e}@${y} started from path "${m}" to Capgo cloud`),w)try{const o=yield(0,p.default)({method:"POST",url:c.hostUpload,data:{version:y,appid:e,channel:k,external:w},validateStatus:()=>!0,headers:{"Content-Type":"application/json",apikey:b,authorization:`Bearer ${c.supaAnon}`}});200!==o.status&&d.program.error(`Server Error \n${s.default.render((null==o?void 0:o.data)||"")}`)}catch(e){e.response?d.program.error(`Network Error \n${s.default.render((null===(h=e.response)||void 0===h?void 0:h.data)||"")}`):d.program.error(`Network Error \n${s.default.render(e||"")}`)}else{const o=new l.default.SingleBar({},l.default.Presets.shades_grey);try{const t=new i.default;t.addLocalFolder(m),console.log("Uploading:");const r=t.toBuffer(),a=r.toString(v),n=Buffer.byteLength(r),l=(_=r.length,$=u,Math.round(_/((e,o)=>e<o?e:Math.round(e/o))(_,$)));n>31457280&&d.program.error(`The app is too big, the limit is 30 Mb, your is ${Math.round(n/u)} Mb`);const f=[];for(let e=0;e<a.length;e+=l)f.push(a.slice(e,e+l));let h;o.start(f.length,0,{speed:"N/A"});for(let t=0;t<f.length;t+=1){const r=yield(0,p.default)({method:"POST",url:c.hostUpload,data:{version:y,appid:e,fileName:h,channel:k,format:v,app:f[t],isMultipart:f.length>1,chunk:t+1,totalChunks:f.length},validateStatus:()=>!0,headers:{"Content-Type":"application/json",apikey:b,authorization:`Bearer ${c.supaAnon}`}});200!==r.status&&(o.stop(),d.program.error(`Server Error \n${s.default.render((null==r?void 0:r.data)||"")}`)),o.update(t+1),h=r.data.fileName}o.stop()}catch(e){o.stop(),e.response?d.program.error(`Network Error \n${s.default.render((null===(g=e.response)||void 0===g?void 0:g.data)||"")}`):d.program.error(`Network Error \n${s.default.render(e||"")}`)}}var _,$;console.log("App uploaded to server"),console.log(`Try it in mobile app: ${c.host}/app_mobile`),console.log(`Or set the channel ${k} as public here: ${c.hostWeb}/app/package/${e}`),console.log("To use with live update in your own app")}))},406:(e,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.supaAnon=o.hostUpload=o.hostWeb=o.host=void 0,o.host="https://capgo.app",o.hostWeb="https://web.capgo.app",o.hostUpload="https://xvwzpoazmxkqosrdewyv.functions.supabase.co/upload",o.supaAnon="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYzNzgwNTAwOSwiZXhwIjoxOTUzMzgxMDA5fQ.8tgID1d4jodPwuo_fz4KHN4o1XKB9fnqyt0_GaJSj-w"},778:e=>{e.exports=require("@capacitor/cli/dist/config")},844:e=>{e.exports=require("adm-zip")},167:e=>{e.exports=require("axios")},295:e=>{e.exports=require("cli-progress")},304:e=>{e.exports=require("commander")},470:e=>{e.exports=require("fs-extra")},11:e=>{e.exports=require("mime")},867:e=>{e.exports=require("prettyjson")},147:e=>{e.exports=require("fs")},598:e=>{e.exports=JSON.parse('{"name":"@capgo/cli","version":"0.8.1","description":"A CLI to upload to capgo servers","main":"dist/index.js","bin":{"capgo":"dist/index.js"},"repository":{"type":"git","url":"git+https://github.com/Cap-go/capgo-cli.git"},"bugs":{"url":"https://github.com/Cap-go/capgo-cli/issues"},"keywords":["appflow alternative","ionic","capacitor","auto update","live update","capgo","cli","upload","capgo-cli"],"scripts":{"dev":"set NODE_ENV=development&& npx webpack --config webpack.config.js","no-debug":"node dist/index.js","build":"set NODE_ENV=production&& npx webpack --config webpack.config.js","pack":"pkg","lint":"eslint . --ext .ts --fix"},"author":"github.com/riderx","license":"Apache 2.0","dependencies":{"@capacitor/cli":"^3.4.3","adm-zip":"^0.5.9","axios":"^0.26.1","cli-progress":"^3.10.0","commander":"^9.0.0","form-data":"^4.0.0","fs-extra":"^10.0.1","mime":"^3.0.0","node-stream-zip":"^1.15.0","prettyjson":"^1.2.5","upath":"^2.0.1"},"devDependencies":{"@types/adm-zip":"^0.4.34","@types/fs-extra":"^9.0.13","@typescript-eslint/eslint-plugin":"5.14.0","@typescript-eslint/parser":"^5.14.0","awesome-typescript-loader":"^5.2.1","eslint":"^8.11.0","eslint-config-airbnb-base":"^15.0.0","eslint-config-prettier":"^8.5.0","eslint-import-resolver-typescript":"^2.5.0","eslint-plugin-import":"^2.25.4","eslint-plugin-prettier":"^4.0.0","git-format-staged":"^2.1.3","husky":"^7.0.4","nodemon":"^2.0.15","pkg":"^5.5.2","prettier":"^2.5.1","ts-node":"^10.7.0","tsconfig-paths":"^3.14.0","typescript":"^4.6.2","webpack":"^5.70.0","webpack-cli":"^4.9.2","webpack-node-externals":"^3.0.0"}}')}},o={};!function t(r){var a=o[r];if(void 0!==a)return a.exports;var n=o[r]={exports:{}};return e[r].call(n.exports,n,n.exports,t),n.exports}(655)})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/cli",
3
- "version": "0.7.4",
3
+ "version": "0.8.1",
4
4
  "description": "A CLI to upload to capgo servers",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/src/bin/index.ts CHANGED
@@ -3,8 +3,10 @@ import { addApp } from './add';
3
3
  import { deleteApp } from './delete';
4
4
  import { setChannel } from './set';
5
5
  import { uploadVersion } from './upload';
6
+ import pack from '../../package.json'
6
7
 
7
8
  program
9
+ .version(pack.version)
8
10
  .command('add [appid]').alias('a')
9
11
  .action(addApp)
10
12
  .option('-n, --name <name>', 'app name')
package/src/bin/upload.ts CHANGED
@@ -9,13 +9,7 @@ import { host, hostWeb, hostUpload, supaAnon } from './utils';
9
9
  const oneMb = 1048576; // size of one mb in bytes
10
10
  const maxMb = 30;
11
11
  const limitMb = oneMb * maxMb; // size of 1/2 mb
12
- const formatType = 'base64';
13
- const byteConvert = {
14
- 'base64': (s: string) => (3 * (s.length / 4)) - ((s.match(/=/g) || []).length),
15
- 'hex': (s: string) => s.length / 2,
16
- 'binary': (s: string) => s.length / 10,
17
- 'utf8': (s: string) => s.length,
18
- }
12
+ const formatType = 'binary';
19
13
  const chuckNumber = (l: number, divider: number) => l < divider ? l : Math.round(l / divider)
20
14
  const chuckSize = (l: number, divider: number) => Math.round(l / chuckNumber(l, divider))
21
15
 
@@ -0,0 +1,22 @@
1
+ import { lorem } from './data'
2
+
3
+ const byteConvert = {
4
+ 'base64': (s: string) => (3 * (s.length / 4)) - ((s.match(/=/g) || []).length),
5
+ 'hex': (s: string) => s.length / 2,
6
+ 'binary': (s: string) => s.length / 10,
7
+ 'utf8': (s: string) => s.length,
8
+ }
9
+ const oneMb = 1048576;
10
+
11
+ const buff = Buffer.from(lorem)
12
+ const b64 = buff.toString('base64')
13
+ const hex = buff.toString('hex')
14
+ const s = buff.toString('utf8')
15
+
16
+ const chuckNumber = (l: number, divider: number) => l < divider ? l : Math.round(l / divider)
17
+ const chuckSize = (l: number, divider: number) => Math.round(l / chuckNumber(l, divider))
18
+
19
+ console.log('buff', buff.length, buff.byteLength, chuckNumber(buff.length, oneMb), chuckSize(buff.length, oneMb))
20
+ console.log('b64', b64.length, byteConvert.base64(b64) / oneMb)
21
+ console.log('hex', hex.length, byteConvert.hex(hex) / oneMb)
22
+ console.log('string', s.length, byteConvert.utf8(s) / oneMb)