Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main' into readme
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
  • Loading branch information
TheJaredWilcurt committed Dec 28, 2023
2 parents 686204c + 3d5ad03 commit a65c3cb
Show file tree
Hide file tree
Showing 27 changed files with 4,123 additions and 1,820 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict';

/**
* @file ESLint setup
* @author TheJaredWilcurt
* @file ESLint setup
*/

const path = require('path');
Expand All @@ -19,6 +18,7 @@ module.exports = {
jest: true
},
globals: {
nw: true,
vi: true
},
extends: [
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [20.7.0]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ nwSplasherAutoUpdate.downloadLatestAppAndOpenWindowInBackground({
* warning/error messages from the internal validators. Only used if
* verbose: true. Defaults to console.error if not supplied.
*
* @param string} message The human readable warning/error message
* @param object} error Sometimes an error or options object is passed
* @param {string} message The human readable warning/error message
* @param {object} error Sometimes an error or options object is passed
*/
customLogger: function (message, error) {
console.log(message, error);
Expand Down Expand Up @@ -78,7 +78,7 @@ nwSplasherAutoUpdate.downloadLatestAppAndOpenWindowInBackground({
},
/**
* Called after hitting the versionUrl with the response.
* Must return a url to a ZIP file to be downloaded/extracted
* Must return a url to a ZIP file to be downloaded/extracted.
*
* @param {string} response The response body from the network request
* @return {string} A url to a ZIP file to be downloaded
Expand Down Expand Up @@ -115,7 +115,7 @@ nwSplasherAutoUpdate.downloadLatestAppAndOpenWindowInBackground({
* nwSplasherAutoUpdate will retry the download or stop running.
*
* @param {string} pathToZip File path to the downloaded zip file
* @return {Boolean} true = continue, false = retry/stop
* @return {boolean} true = continue, false = retry/stop
*/
validateZip: function (pathToZip) {
// This is just an example, you can put any logic you want here
Expand All @@ -128,7 +128,7 @@ nwSplasherAutoUpdate.downloadLatestAppAndOpenWindowInBackground({
* then nwSplasherAutoUpdate will retry extraction or stop running.
*
* @param {string} pathToExtract File path to extracted folder
* @return {Boolean} true = continue, false = retry/stop
* @return {boolean} true = continue, false = retry/stop
*/
validateExtract: function (pathToExtract) {
// This is just an example, you can put any logic you want here
Expand All @@ -152,11 +152,11 @@ nwSplasherAutoUpdate.downloadLatestAppAndOpenWindowInBackground({
* all retries were exhausted.
*
* @param {string} errorMessage Human readable error message
* @param {object} err Detailed error information if available
* @param {object} error Detailed error information if available
*/
onError: function (errorMessage, err) {
onError: function (errorMessage, error) {
// This is just an example, you can put any logic you want here
console.log(errorMessage, err);
console.log(errorMessage, error);
},
/**
* Optional event hook.
Expand Down
3 changes: 1 addition & 2 deletions api-type-definitions.js → api-type-definitions.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* @file Type definitions for the API and reusable functions/objects
* @author TheJaredWilcurt
* @file Type definitions for the API and reusable functions/objects.
*/

/**
Expand Down
78 changes: 78 additions & 0 deletions index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
'use strict';

/**
* @file Entry point for the library. Exposes the external facing function that
* accepts the input defined in the API documentation.
*/

/* eslint-disable */

const { OPTIONS } = require('./api-type-definitions.cjs');

const validation = require('./src/validation.cjs');
const getVersionUrl = require('./src/getVersionUrl.cjs');
const getLatestLocal = require('./src/getLatestLocal.cjs');
const downloadZip = require('./src/downloadZip.cjs');

function stub () {}

const nwSplasherAutoUpdate = {
/**
* Checks for updates. Downloads zip and extracts it if
* new version is available. Launches a window pointed
* to the latest version.
*
* @param {OPTIONS} options The user's options object
*/
downloadLatestAppAndOpenWindowInBackground: async function (options) {
// Validate options
options = validation.validateDownloadLatestAppAndOpenWindowInBackgroundOptions(options);

// Get remote version data
const versionUrlResponse = await getVersionUrl(options);

// Get latest local
const latestLocal = await getLatestLocal(options);

// confirm version
const latestRemote = await options.autoUpdate.confirmNewVersion(versionUrlResponse, latestLocal);

console.log({ latestRemote, latestLocal });

// get download path
const downloadPath = await options.autoUpdate.downloadPath(versionUrlResponse);

// download zip
await downloadZip(options, downloadPath);

// validate zip
stub();

// extract zip
stub();

// validate extraction
stub();

// Update/Retry/Error/Complete
stub();

// close splash
stub();

// open app window
stub();
},
setCurrentWorkingDirectory: function () {},
closeSplashAndShowApp: function (options) {
options = {
// Must match the port number used in the splash.html
port: 4443
};
},
deletePastVersions: function () {
console.log('This is a stub');
}
};

module.exports = nwSplasherAutoUpdate;
45 changes: 0 additions & 45 deletions index.js

This file was deleted.

29 changes: 0 additions & 29 deletions manual-testing.js

This file was deleted.

50 changes: 50 additions & 0 deletions nw-testing/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html>
<head>
<title>Manual test</title>
<style>
body {
background: #333;
color: #CCC;
padding-top: 40px;
text-align: center;
}
button {
background: #888;
border: 0px;
margin-right: 10px;
color: #EEE;
font-size: 40px;
}
</style>
</head>
<body>
<button id="run">
Run
</button>
<button id="reload">
Reload
</button>
<script>
nw.Window.get().moveTo(1587, 64);
chrome.developerPrivate.openDevTools({
renderViewId: -1,
renderProcessId: -1,
extensionId: chrome.runtime.id
});

const { manualTesting } = require('./manual-testing.cjs');

const runButton = document.getElementById('run');
const reloadButton = document.getElementById('reload');

runButton.addEventListener('click', function () {
manualTesting();
});

reloadButton.addEventListener('click', function () {
nw.Window.get().reloadIgnoringCache();
});
</script>
</body>
</html>
Loading

0 comments on commit a65c3cb

Please sign in to comment.