nordnet / cordova-hot-code-push-cli

[DEPRECATED] - This is a command line utility for Cordova Hot Code Push Plugin.

Home Page:https://github.com/nordnet/cordova-hot-code-push-cli/issues/79

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ngrok should use the same address, when server is restarted

nikDemyankov opened this issue · comments

Originally asked in nordnet/cordova-hot-code-push#143.

Before it was working properly. When server starts - it creates .chcpenv config and stores server's url in there. On the next launch it uses it, so that the address would remain the same. But for some reason this stopped working.

Hi, is this plugin ready for publishing application on the store? or it's currently only support for doing local development?

From my understanding, now since ngrok link changes when cordova-hcp server restarted (we cann't promise cordova-hcp server runs all time without any problem), app needed to rebuild and all installed device need to reinstall the app. so it's not ready for publishing application on the store?

Thanks
tingjun

You use ngrok only for development and nothing more. cordova-hcp server is just a feature, which should make your development process easier.

For production you need your own real server, on which you upload configs and web content. And then you set it's url in the config.xml, and no need to rebuild the app, unless it requires some native updates/new plugins.

I set url in the config.xml like this:

    <chcp>
        <config-file url="http://duangwifi.cn/TestProject/www/chcp.json"/>
    </chcp>

and chcp.json:

{
  "autogenerated": true,
  "release": "2016.05.18-16.37.39",
  "content_url": "http://duangwifi.cn/TestProject/www",
  "update": "now"
}

I use nginx webserver. But when I update http://duangwifi.cn/TestProject/www/index.html, my app didn''t update info. Am I missing something?

Did you update your http://duangwifi.cn/TestProject/www/chcp.manifest as well? I can access http://duangwifi.cn/TestProject/www/chcp.json, but not the manifest url. Maybe that's why it's not get updated.

Please, check the docs.

I've updated http://duangwifi.cn/TestProject/www/chcp.manifest as well, but app still not update.

Need I run cordova-hcp server on my server too? (now is nginx) I find cordova-hcp server on local have "a user connected" etc logs. will nginx do the same?

➜  TestProject git:(master) ✗ cordova-hcp server
Running server
Checking:  /home/litingjun/IonicProjects/TestProject/www
local_url http://localhost:31284
Build 2016.05.18-17.17.30 created in /home/litingjun/IonicProjects/TestProject/www
cordova-hcp local server available at: http://localhost:31284
cordova-hcp public server available at: https://39c608aa.ngrok.io
a user connected
user disconnected
a user connected
a user connected
File changed:  /home/litingjun/IonicProjects/TestProject/www/index.html
Build 2016.05.18-17.18.55 created in /home/litingjun/IonicProjects/TestProject/www
Should trigger reload for build: 2016.05.18-17.18.55
user disconnected

First, I don't think you need

{
  "file": "chcp-server.json",
  "hash": "212da626a3e598c8656c4fb4033e6eda"
}

in your manifest file.

Second: if you are trying to get immediate updates after changing file, as you get by using ngrok and local-dev plugin - it's not gonna work like this.

How plugin works in development mode:
To simplify testing and development you can use 2 tools: cordova-hcp CLI client and local development plugin. With the CLI client you launch local server with socket.io. Development plugin connects to this server and listens for changes. When you update some file - CLI client rebuilds configs and notifies via socket connection the local dev plugin. That plugin sends command to fetch update to the main plugin and installs it immediately after loading. This way you can see your changes without the need to restart the app.

How plugin works with production version:
If you are building production version of the app - you don't use local dev plugin to trigger app update process, and you don't use CLI client to launch local server and trigger the re-builds.

For production you have a real external server, on which you put 2 configuration files (as you did): chcp.json and chcp.manifest. First one stores information about the release, second one - about the files in the release.

When you launch the app - plugin loads chcp.json from the server. If release preference differs from the current one - plugin will load chcp.manifest file and then - download updated/new files from the server. After that, it will proceed according to update preference in chcp.json: either install update right away (now), or on the next launch. If release preference is the same - then plugin does nothing. After that plugin doesn't check for updates on the server. So, if the app is running and you changed something - it's not gonna detect that. It will do the full cycle again only on the next app launch. If needed, you can change that behaviour by using plugin's JS API.

If you want your production server to act as cordova-hcp server and trigger updates in the app immediately after uploading them - there can be different ways to do that:

  1. Use push notifications. When you upload something on the server - send push notification to the clients. On the client side capture them and trigger the update. That approach can be used in actual release.
  2. On the server side add support for socket.io and send commands to the connected users, as it is done right now in CLI client. In that case you might try to use local development plugin to trigger update downloads. But don't use local development plugin for actual app release, only for development.

If you don't get updates after re-launching the app - then there's might be some problem with configuration. You can try to launch the app from Xcode by opening YOUR_PROJECT/platforms/ios/YOUR_APP_NAME.xcodeproj and hitting Run button. You should be able to see update logs in the Xcode console.

I find when I run cordova-hcp build, chcp.json becomes like this:

{
  "autogenerated": true,
  "release": "2016.05.19-10.23.02"
}

and my app can't update when relunched. after I update chcp.json manually like this:

{
  "autogenerated": true,
  "release": "2016.05.19-10.23.02",
  "content_url": "http://duangwifi.cn/TestProject/www",
  "update": "now"
}

my app get updates.

At last, thank you for your awesome work!!

Good that you found the problem :)

To make CLI client automatically set correct server address - use cordova-hcp.json config. Let's say your Cordova project has the following structure:

MyCoolApp/
  config.xml
  hooks/
  platforms/
  plugins/
  www/

First, you need to create cordova-hcp.json file in project's root folder:

MyCoolApp/
  config.xml
  cordova-hcp.json
  hooks/
  platforms/
  plugins/
  www/

In that config you put all additional preferences, that should be placed in chcp.json file after running cordova-hcp build. In your case:

{
  "content_url": "http://duangwifi.cn/TestProject/www",
  "update": "now"
}

After running cordova-hcp build the www/chcp.json will be:

{
  "autogenerated": true,
  "release": "2016.05.19-10.23.02",
  "content_url": "http://duangwifi.cn/TestProject/www",
  "update": "now"
}

I got it, thanks!

👋 Hi! Thank you for your interest in this repo.

😢 We are not using nordnet/cordova-hot-code-push-cli anymore, and we lack the manpower and the experience needed to maintain it. We are aware of the inconveniece that this may cause you. Feel free to use it as is, or create your own fork.

🔒 This will now be closed & locked.

ℹ️ Please see #79 for more information.