From 06753368ae3e1cc0624337cf31a94521cc8a32a4 Mon Sep 17 00:00:00 2001 From: The Jared Wilcurt Date: Sat, 30 Dec 2023 19:16:18 -0500 Subject: [PATCH 1/2] readme --- README.md | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9398208..6b9135e 100644 --- a/README.md +++ b/README.md @@ -92,16 +92,17 @@ nwSplasherAutoUpdate.downloadLatestAppAndOpenWindowInBackground({ * Called when an update occurs during download/extract. * * @param {object} update Object containing percents - * @param {number} update.downloadProgress The download progress percent + * @param {object} update.downloadProgress The download progress object provided by "request-progress" * @param {number} update.extractProgress The extract progress percent */ onUpdate: function ({ downloadProgress, extractProgress }) { // This is just an example, you can put any logic you want here if (downloadProgress) { - console.log('Download progress: ' + downloadProgress + '%'); + // for details on this object, see: https://github.com/IndigoUnited/node-request-progress + console.log('Download progress: ' + downloadProgress.percent + '%'); } if (extractProgress) { - console.log('Unzipping: ' + downloadProgress + '%'); + console.log('Unzipping: ' + extractProgress + '%'); } }, /** @@ -241,9 +242,19 @@ path.join(nw.App.dataPath, 'nwSplasherExtracts', version); // Main splash screen needs versionUrl, download start confirmation, and a download path supplied nwSplasherAutoUpdate.downloadLatestAppAndOpenWindowInBackground({ autoUpdate: { + // We'll go to this URL on your behalf and hand you the response in the below functions versionUrl: 'https://example.com/versions.json', - confirmNewVersion: function (response, latestLocal) {}, - downloadPath: function (response) {} + confirmNewVersion: function (response, latestLocal) { + // You write your own logic to determine the latest version number and return it. + // Or return false if we do not need to download a new version. + // The latestLocal variable is the version number the user already has installed locally. + return '1.4.3'; + }, + downloadPath: function (response) { + // You write your own logic to determine the URL of the zip file containing the files + // from the latest version or your app. + return 'https://example.com/1.4.3/update.zip'; + } } }); @@ -274,4 +285,4 @@ We suggest ALL users of this library code in some UI to convey to users when an ### For-profit software -If you are using NW.js to create for-profit software, then this style of auto-update may not work for you. If you require authenticating a license, key, or the user, or the download requires authentication, then this "splash + download a zip" approach is likely too simple for your needs, and you should consider writing your own solution custom to your use case. +If you are using NW.js to create for-profit software, then this style of auto-update may not work for you. If you require authenticating a license, key, or the user, or the download requires authentication, then this "splash + download a zip" approach is likely too simple for your needs, and you should consider writing your own solution custom to your use case. Feel free to fork this repo if you want to use it as a base for your custom solution. From 880c60d136510403a3cdda5e881d562a21910509 Mon Sep 17 00:00:00 2001 From: The Jared Wilcurt Date: Sat, 30 Dec 2023 19:21:15 -0500 Subject: [PATCH 2/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 48f3515..de7cec9 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ nwSplasherAutoUpdate.downloadLatestAppAndOpenWindowInBackground({ * Called when an update occurs during download/extract. May be called many times. * * @param {object} update Object containing percents - * @param {object} update.downloadProgress The download progress object provided by "request-progress" + * @param {object} update.downloadProgress The download progress object * @param {number} update.extractProgress The extract progress percent */ onUpdate: function ({ downloadProgress, extractProgress }) {