Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
unigazer committed Jul 24, 2018
0 parents commit c648f37
Show file tree
Hide file tree
Showing 12 changed files with 344 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"env": {
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2017
},
"rules": {
"indent": [
"error",
4
],
"linebreak-style": [
"error",
"windows"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"no-console": "off",
"no-unused-vars": "off"
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Node modules
node_modules
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}\\index.js"
}
]
}
21 changes: 21 additions & 0 deletions LICENCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Vladimir Jovanović

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Node.js Checker

Every time you log in, Windows will start a background process to check wether a new version of Node.js has been published. If there is a version newer than the one installed on your machine, it will display a notification with a small description where it shows the latest tag version from official Node GitHub repository.

# Install

```bash
npm i -g node-checker
```

# Contribute

PR's are welcome. If you want to contribute, push the code to the **dev** branch.

# Licence

MIT License

Copyright (c) 2018 Vladimir Jovanović

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
32 changes: 32 additions & 0 deletions components/notify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const WindowsToaster = require('node-notifier').WindowsToaster,
opn = require('opn');

// Create notification
/**
* Creates a toast notification on the desktop
* @param {string} latest Latest Node.js version from GitHub releases.
* This only shows the notification if there is a version greater than
* the one that is installed on your machine.
*/
var Notify = latest => {
let notifier = new WindowsToaster({
withFallback: true
});

notifier.notify({
title: 'New Node.js version is available',
message: `Version tag: ${latest}\nClick on the notification to download`,
icon: './icons/app.png',
wait: true
}, (err, res) => {
if (err) console.error(err);
});

notifier.on('click', () => {
opn(`https://nodejs.org/dist/${latest}/node-${latest}-${process.arch}.msi`);
});

return this;
};

module.exports = Notify;
11 changes: 11 additions & 0 deletions components/startup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const os = require('os'),
AutoLaunch = require('auto-launch');

// Create start up entry
let NodeJSChecker = new AutoLaunch({
name: 'Node.js Checker',
path: `${os.homedir()}\\AppData\\Roaming\\npm\\node_modules\\node-checker\\launch.bat`
});

// Enable the entry
NodeJSChecker.enable();
Binary file added icons/app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Imports
const fetch = require('node-fetch'),
Notify = require('./components/notify');

// Create a start up entry
require('./components/startup');

// Get the latest version
(async () => {
try {
// Get the data
let res = await fetch('https://api.github.com/repos/nodejs/node/releases/latest', {
headers: {
'User-Agent': 'VladimirDev93',
'Content-Type': 'application/json'
}
});
// Put the data
let data = await res.json();
// Get the latest version by tag
let latest = data.tag_name;
// Current Node.js version on the machine
let current = process.version;

// Show the notificaion
if (latest > current)
Notify(latest);

} catch (error) {
console.error(error);
}
})();
2 changes: 2 additions & 0 deletions launch.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cd %AppData%\npm\node_modules\node-checker
node index
145 changes: 145 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "node-checker",
"productName": "Node.js Checker",
"version": "1.0.0",
"description": "Check if there is a newer version of Node.js than the one that is installed on the machine.",
"main": "index.js",
"scripts": {
"start": "node index"
},
"author": "Vladimir Jovanović",
"license": "MIT",
"dependencies": {
"auto-launch": "^5.0.5",
"node-fetch": "^2.2.0",
"node-notifier": "^5.2.1",
"opn": "^5.3.0"
}
}

0 comments on commit c648f37

Please sign in to comment.