This repository has been archived by the owner on Feb 22, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nsis-compat-updater): initialize
- Loading branch information
Showing
14 changed files
with
516 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"lerna": "2.0.0-rc.3", | ||
"packages": [ | ||
"packages/*" | ||
], | ||
"version": "independent" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<style type="text/css"> | ||
|
||
body { | ||
width: 100%; | ||
height: 100%; | ||
margin: 0; | ||
} | ||
|
||
</style> | ||
</head> | ||
<body> | ||
<script type="text/javascript"> | ||
|
||
document.write(`Version: ${ nw.App.manifest.version }`); | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<style type="text/css"> | ||
|
||
body { | ||
width: 100%; | ||
height: 100%; | ||
margin: 0; | ||
} | ||
|
||
</style> | ||
</head> | ||
<body> | ||
<script type="text/javascript"> | ||
|
||
document.write(`<p>App launches.</p>`); | ||
|
||
const { NsisCompatUpdater } = require('nsis-compat-updater'); | ||
|
||
const updater = new NsisCompatUpdater('http://127.0.0.1:8080/versions.nsis.json', nw.App.manifest.version, 'x86'); | ||
|
||
updater.checkForUpdates() | ||
.then((version) => { | ||
|
||
document.write(`<p>Version: ${ version }</p>`); | ||
|
||
if(version && confirm(`New version of ${ version.version } is available, download now?`)) { | ||
|
||
return updater.downloadUpdate(version.version) | ||
.then((path) => { | ||
|
||
document.write(`<p>Path: ${ path }</p>`); | ||
|
||
if(confirm(`New version of ${ version.version } is downloaded, install now?`)) { | ||
return updater.quitAndInstall(path); | ||
} | ||
else { | ||
return updater.installWhenQuit(path); | ||
} | ||
|
||
}); | ||
|
||
} | ||
else { | ||
|
||
nw.Window.open('./app/index.html', { | ||
width: 640, | ||
height: 480, | ||
new_instance: true, | ||
}); | ||
|
||
nw.Window.get().close(); | ||
|
||
} | ||
|
||
}) | ||
.catch((err) => { | ||
document.write(`<p>[ERROR] ${ err.message }</p>`); | ||
}); | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "nsis-compat-tester", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "main.html", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"serve": "http-server ./dist/", | ||
"start": "DEBUG=nsis-compat-updater run --mirror https://npm.taobao.org/mirrors/nwjs/ .", | ||
"dist": "build --win --x86 --mirror https://npm.taobao.org/mirrors/nwjs/ ." | ||
}, | ||
"author": "evshiron", | ||
"license": "MIT", | ||
"dependencies": { | ||
"nsis-compat-updater": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"http-server": "^0.9.0", | ||
"nwjs-builder-phoenix": "^1.9.3" | ||
}, | ||
"build": { | ||
"nwFlavor": "sdk", | ||
"targets": [ | ||
"nsis" | ||
], | ||
"nsis": { | ||
"diffUpdaters": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "nsis-compat-updater", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "./dist/lib/index.js", | ||
"scripts": { | ||
"prepublish": "npm run build", | ||
"test": "npm run build && ava --verbose", | ||
"build": "tsc" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/evshiron/nwjs-builder-phoenix.git" | ||
}, | ||
"author": "evshiron", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/evshiron/nwjs-builder-phoenix/issues" | ||
}, | ||
"homepage": "https://github.com/evshiron/nwjs-builder-phoenix#readme", | ||
"devDependencies": { | ||
"@types/bluebird-global": "^3.5.1", | ||
"@types/node": "^7.0.12", | ||
"@types/semver": "^5.3.31", | ||
"@types/tmp": "0.0.32", | ||
"ava": "^0.18.2", | ||
"nwjs-builder-phoenix": "^1.9.3", | ||
"tslint": "^5.0.0", | ||
"typescript": "^2.2.2" | ||
}, | ||
"dependencies": { | ||
"bluebird": "^3.5.0", | ||
"debug": "^2.6.3", | ||
"got": "^6.7.1", | ||
"progress-stream": "^1.2.0", | ||
"semver": "^5.3.0", | ||
"tmp": "0.0.31" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
declare const nw: any; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
export class Event<TArgs> { | ||
|
||
public listeners: Array<(args: TArgs) => void> = []; | ||
|
||
constructor(name: string) { | ||
|
||
} | ||
|
||
public subscribe(fn: ((args: TArgs) => void)) { | ||
this.listeners.push(fn); | ||
} | ||
|
||
public trigger = (args: TArgs) => { | ||
this.listeners.map(fn => fn(args)); | ||
} | ||
|
||
public unsubscribe(fn: ((args: TArgs) => void)) { | ||
this.listeners = this.listeners.filter(f => f != fn); | ||
} | ||
|
||
} |
Oops, something went wrong.