dsheiko / nw-autoupdater

⛔️ [DEPRECATED] Library provides low-level API to control NW.js app auto-updates
MIT License
75 stars 36 forks source link

[question] Is there a way to update only a specific file? #3

Closed CosmoMyzrailGorynych closed 7 years ago

CosmoMyzrailGorynych commented 7 years ago

If I don't update nw itself, the only file I really need to update is an NW executable with a compressed app in it. Is there an easy way to do so??

dsheiko commented 7 years ago

To say truth, I didn't think about this. So at the moment it simply downloads an archive from the list of the remote manifest and unpacks it to a temp folder. But I like the challenge, going to think of a possibility to specify explicitly what to take from the archive

dsheiko commented 7 years ago

Since version 1.1.0 you can set via swapScript option your own swap script like:

rsync -a\${VERBOSE} --delete \${APP_PATH}/. \${BAK_PATH}/
rsync -a\${VERBOSE} \${UPDATE_PATH}/. \${APP_PATH}/package

that copies the downloaded/extracted HTML5 project files in package subfolder in application directory, given your app manually bundled and HTML5 project located in package

vinaynb commented 7 years ago

@dsheiko i am trying to achieve the same thing i.e. update just the html5 project but i don't understand what you mean by specifying the packages sub directory ? How should the app be packaged and built for this technique to work ? Can you shed a bit more light on this ?

dsheiko commented 7 years ago

This way it works if you do not bundle updates, but simply compress with zip or tar.gz. Thus updater, downloads the archive, unpack in TMP, takes project directory from there and replaces in the project. On macOS, NW.js app is kind of a folder, so it do it. On Windows/Linux, seems like the project shall not be bundled at all, but simply archived (usually with nw executable rebranded). In fact on Windows it even makes sense as it uncompress the package every time you run it and it takes considerably long time.

vinaynb commented 7 years ago

I am at the moment using nw-builder to build my app.

This way it works if you do not bundle updates, but simply compress with zip or tar.gz.

Do you mean to say that this technique won't work if i bundle my app using the tool i mentioned above ?

dsheiko commented 7 years ago

What OS do you target?

vinaynb commented 7 years ago

Linux at the moment and Windows eventually. I mean i am developing on linux(ubuntu) right now but my end users are going to be mostly windows.

vinaynb commented 7 years ago

@dsheiko The name of my app is testApp. Now when building with --flavor=sdk there is file named testApp which when executed from bash runs the app (Lets call this build A).

I made changes to code and rebuilt it (let's call this build B).

Now i simply replaced testApp in build A's folder with testApp from build B's folder and my code changes are available in the old build. While this satisfies my idea of updating just a single file which contains my source i don't think this is the correct way. Can you tell us which files contain the application code in the sdk build folder and if just replacing a single file and restarting the app will be the correct way to go about an update ?

dsheiko commented 7 years ago

Well, nw-builder creates self-extracting executable for Windows, so the updater by default simply replaces that file with the downloaded one - thus it works. But it cannot currently modify the executable for updating let's project folder. At the moment I do not know for sure how to unpack that sort of bundle safely, update the folder and pack it back.

dsheiko commented 7 years ago

In the nw-autoupdater examples I also refer to SDK version nwbuild -v 0.21.3-sdk, as I want DevTools available in the demo app. The problem again, you get the project sources bundled together with NW.js executable and so it distributes. So to update source one needs to unpack the bundle

vinaynb commented 7 years ago

Filed an issue in nw-builder repo. Posting here just for reference https://github.com/nwjs-community/nw-builder/issues/460