@capgo/cli 0.7.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.
package/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # Capgo CLI
2
+
3
+ A CLI to upload and download files from the Capacitor go Cloud.
4
+
5
+ ## Install
6
+
7
+ `npm i -g capgo`
8
+ ## Usage
9
+
10
+ Before use the CLI you should register here : https://capgo.app/
11
+
12
+ Then go in you account in apikey section and click in the read/write key to copy it.
13
+
14
+ ## Add new app to Cloud
15
+ `capgo add [appId] --apikey=********`
16
+ `[appId]` your app ID the format `com.test.app` is explained [here](https://capacitorjs.com/docs/cli/init)
17
+
18
+ Optionally you can give:
19
+ - icon with `--icon /path/to/my/icon` to have a custom icon in the list
20
+ - name with `--name test` to have a custom name in the list
21
+
22
+
23
+ ### Send version to Cloud
24
+ `capgo upload [appId] --apikey=********`
25
+ `[appId]` is your app ID the format is explained [here](https://capacitorjs.com/docs/cli/init)
26
+
27
+ Optionally you can give:
28
+ - icon with `--path /path/to/my/dist/folder` to send your code to the cloud
29
+ - name with `--name test` to have a custom name in the list
30
+ - channel with `--channel prod` to link this version to channel
31
+ ### Send version to Cloud channel
32
+ `capgo set [appId] [version] [channel] --apikey=********`
33
+ `[appId]` your app ID the format is explained [here](https://capacitorjs.com/docs/cli/init)
34
+ `[version]` your app version already sended to the cloud
35
+ `[channel]` the channel you want to link the version
36
+
37
+ ### Delete package to Cloud
38
+ `capgo delete [appId] --apikey=********`
39
+ `[appId]` your app ID present in the Cloud
40
+
41
+
42
+ ## Dev contribution
43
+
44
+ 1. Install development dependencies
45
+
46
+ ```shell
47
+ rm -rf node_modules
48
+ npm i
49
+ ```
50
+
51
+ 2. Set `"sourceMap": true,` in tsconfig.json
52
+
53
+ 3. Run webpack development server
54
+
55
+ ```shell
56
+ npm run dev
57
+ ```
58
+
59
+ 4. Attach debugger to the process started with `npm run dev`
60
+
61
+ > VScode:
62
+
63
+ - Run `Debug on fixtures` launch configuration
64
+ - Edit configuration to debug on different files
65
+
66
+ > Other IDEs:
67
+
68
+ - Attach debugger of your choice to the running process, use .vscode/launch.json `Debug on fixtures` configuration as the example
69
+
70
+ ## Production build
71
+
72
+ 1. Set `"sourceMap": false,` in tsconfig.json
73
+
74
+ > TODO: add separate build config
75
+
76
+ 2. Run
77
+
78
+ ```shell
79
+ npm install && set NODE_ENV=production&& npx webpack --config webpack.config.js && rm -rf node_modules && npm i --only=prod && npm prune --production && npm shrinkwrap
80
+ ```
81
+
82
+ ## Publish to NPM
83
+
84
+ To release a new package version:
85
+
86
+ 1. Bump version in `package.json` manually
87
+ 2. Run commands from **Production build** section
88
+ 3. Run `npm publish --dry-run`:
89
+
90
+ - ensure that only necessary files are listed in package preview
91
+
92
+ - ensure that `npm-shrinkwrap.json` **does not include development dependencies**
93
+
94
+ 4. Run `npm publish` or `npm publish --tag beta`
95
+
96
+ ## Pack executable
97
+
98
+ **prerequisite**: perform production build
99
+
100
+ > Pkg will not resolve dynamic module imports, so avoid these at all costs. (Basically, just use plain ordinary static `import Something from 'somewhere'` and no issue should arise)
101
+
102
+ Build for all supported platforms
103
+
104
+ ```shell
105
+ pkg ./dist/index.js
106
+ ```
107
+
108
+ > You can specify targets with `-t` option (refer to `pkg --help` and examples on [pkg's npm](https://www.npmjs.com/package/pkg))
109
+ > e.g. use `pkg -t node14-win-x64 ./dist/index.js` to build for Node14, Windows x64
110
+
111
+ Build for Node14 Windows x64
112
+
113
+ ```shell
114
+ pkg -t node14-win-x64 ./dist/index.js
115
+ ```
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright 2020 EPAM Systems
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { CapacitorConfig } from '@capacitor/cli'
17
+
18
+ const config: CapacitorConfig = {
19
+ appId: 'com.neufmoispourtoi.app',
20
+ appName: '9moispourtoi',
21
+ webDir: 'dist',
22
+ bundledWebRuntime: false,
23
+ plugins: {
24
+ PushNotifications: {
25
+ presentationOptions: ['badge', 'sound', 'alert'],
26
+ },
27
+ SplashScreen: {
28
+ launchAutoHide: false,
29
+ },
30
+ },
31
+ }
32
+
33
+ export default config
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
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="binary";e.uploadVersion=(o,e)=>t(void 0,void 0,void 0,(function*(){var r,t,a,v,h,f;let{version:g,path:y,channel:m}=e;const{apikey:k,external:w}=e;let _;m=m||"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),g=g||(null===(a=null===(t=null==_?void 0:_.app)||void 0===t?void 0:t.package)||void 0===a?void 0:a.version),y=y||(null===(v=null==_?void 0:_.app)||void 0===v?void 0:v.webDir),k||l.program.error("Missing API key, you need to provide a API key to add your app"),o&&g&&y||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}@${g} started from path "${y}" to Capgo cloud`),w)try{const e=yield(0,p.default)({method:"POST",url:u.hostUpload,data:{version:g,appid:o,channel:m,external:w},validateStatus:()=>!0,headers:{"Content-Type":"application/json",apikey:k,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===(h=o.response)||void 0===h?void 0:h.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(y),console.log("Uploading:");const t=r.toBuffer().toString(c),a=1048576;t.length>31457280&&l.program.error("The app is too big, the limit is 30 Mb");const n=[];for(let o=0;o<t.length;o+=a)n.push(t.slice(o,o+a));let s;e.start(n.length,0,{speed:"N/A"});for(let r=0;r<n.length;r+=1){const t=yield(0,p.default)({method:"POST",url:u.hostUpload,data:{version:g,appid:o,fileName:s,channel:m,format:c,app:n[r],isMultipart:n.length>1,chunk:r+1,totalChunks:n.length},validateStatus:()=>!0,headers:{"Content-Type":"application/json",apikey:k,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),s=t.data.fileName}e.stop()}catch(o){e.stop(),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||"")}`)}}console.log("App uploaded to server"),console.log(`Try it in mobile app: ${u.host}/app_mobile`),console.log(`Or set the channel ${m} 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)})()})();
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@capgo/cli",
3
+ "version": "0.7.0",
4
+ "description": "A CLI to upload to capgo servers",
5
+ "main": "dist/index.js",
6
+ "bin": {
7
+ "capgo": "dist/index.js"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/Cap-go/capgo-cli.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/Cap-go/capgo-cli/issues"
15
+ },
16
+ "keywords": [
17
+ "appflow alternative",
18
+ "ionic",
19
+ "capacitor",
20
+ "auto update",
21
+ "live update",
22
+ "capgo",
23
+ "cli",
24
+ "upload",
25
+ "capgo-cli"
26
+ ],
27
+ "scripts": {
28
+ "dev": "set NODE_ENV=development&& npx webpack --config webpack.config.js",
29
+ "no-debug": "node dist/index.js",
30
+ "build": "set NODE_ENV=production&& npx webpack --config webpack.config.js",
31
+ "pack": "pkg",
32
+ "lint": "eslint . --ext .ts --fix"
33
+ },
34
+ "author": "github.com/riderx",
35
+ "license": "Apache 2.0",
36
+ "dependencies": {
37
+ "@capacitor/cli": "^3.4.3",
38
+ "adm-zip": "^0.5.9",
39
+ "axios": "^0.26.1",
40
+ "cli-progress": "^3.10.0",
41
+ "commander": "^9.0.0",
42
+ "form-data": "^4.0.0",
43
+ "fs-extra": "^10.0.1",
44
+ "mime": "^3.0.0",
45
+ "node-stream-zip": "^1.15.0",
46
+ "prettyjson": "^1.2.5",
47
+ "upath": "^2.0.1"
48
+ },
49
+ "devDependencies": {
50
+ "@types/adm-zip": "^0.4.34",
51
+ "@types/fs-extra": "^9.0.13",
52
+ "@typescript-eslint/eslint-plugin": "5.14.0",
53
+ "@typescript-eslint/parser": "^5.14.0",
54
+ "awesome-typescript-loader": "^5.2.1",
55
+ "eslint": "^8.11.0",
56
+ "eslint-config-airbnb-base": "^15.0.0",
57
+ "eslint-config-prettier": "^8.5.0",
58
+ "eslint-import-resolver-typescript": "^2.5.0",
59
+ "eslint-plugin-import": "^2.25.4",
60
+ "eslint-plugin-prettier": "^4.0.0",
61
+ "git-format-staged": "^2.1.3",
62
+ "husky": "^7.0.4",
63
+ "nodemon": "^2.0.15",
64
+ "pkg": "^5.5.2",
65
+ "prettier": "^2.5.1",
66
+ "ts-node": "^10.7.0",
67
+ "tsconfig-paths": "^3.14.0",
68
+ "typescript": "^4.6.2",
69
+ "webpack": "^5.70.0",
70
+ "webpack-cli": "^4.9.2",
71
+ "webpack-node-externals": "^3.0.0"
72
+ }
73
+ }