Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

Commit e27a6e4

Browse files
author
axelrindle
committed
Added files.
1 parent 3dae59f commit e27a6e4

12 files changed

Lines changed: 432 additions & 0 deletions

File tree

.gitignore

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
# Created by https://www.gitignore.io/api/node
3+
4+
### Node ###
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
24+
# nyc test coverage
25+
.nyc_output
26+
27+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
28+
.grunt
29+
30+
# Bower dependency directory (https://bower.io/)
31+
bower_components
32+
33+
# node-waf configuration
34+
.lock-wscript
35+
36+
# Compiled binary addons (http://nodejs.org/api/addons.html)
37+
build/Release
38+
39+
# Dependency directories
40+
node_modules/
41+
jspm_packages/
42+
43+
# Typescript v1 declaration files
44+
typings/
45+
46+
# Optional npm cache directory
47+
.npm
48+
49+
# Optional eslint cache
50+
.eslintcache
51+
52+
# Optional REPL history
53+
.node_repl_history
54+
55+
# Output of 'npm pack'
56+
*.tgz
57+
58+
# Yarn Integrity file
59+
.yarn-integrity
60+
61+
# dotenv environment variables file
62+
.env
63+
64+
65+
# End of https://www.gitignore.io/api/node

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Axel Rindle
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# github-version-checker
2+
Simple **version checker** working with **GitHub releases** and the **GitHub API**.
3+
4+
## Install
5+
```bash
6+
npm install --save github-version-checker
7+
```
8+
9+
## Usage
10+
### JavaScript
11+
```javascript
12+
// require modules
13+
const versionCheck = require('github-version-checker');
14+
const pkg = require('./package.json'); // or whereever your package.json lies
15+
16+
// version check options
17+
const options = {
18+
repo: 'axelrindle/github-version-checker', // will be expanded to https://api.github.com/repos/axelrindle/github-version-checker/releases
19+
currentVersion: pkg.version
20+
};
21+
versionCheck(options, function (update) { // callback function
22+
if (update) { // print some update info if an update is available
23+
console.log('An update is available!');
24+
console.log('New version: ' + update.tag_name);
25+
console.log('Details here: ' + update.html_url);
26+
}
27+
28+
// start your app
29+
console.log('Starting app...');
30+
//...
31+
});
32+
```
33+
34+
### CoffeeScript
35+
```coffeescript
36+
# require modules
37+
versionCheck = require('github-version-checker')
38+
pkg = require('./package.json') # or whereever your package.json lies
39+
40+
# version check options
41+
options =
42+
repo: 'axelrindle/github-version-checker'
43+
currentVersion: pkg.version
44+
45+
versionCheck options, (update) -> # callback function
46+
if update # print some update info if an update is available
47+
console.log 'An update is available!'
48+
console.log 'New version: ' + update.tag_name
49+
console.log 'Details here: ' + update.html_url
50+
51+
# start your app
52+
console.log 'Starting app...'
53+
#...
54+
```
55+
56+
## The `update` object
57+
The object you receive in the callback function, follows the format specified here:
58+
https://developer.github.com/v3/repos/releases/#get-a-single-release

gulp/coffeelint.json

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
{
2+
"arrow_spacing": {
3+
"level": "ignore"
4+
},
5+
"braces_spacing": {
6+
"level": "ignore",
7+
"spaces": 0,
8+
"empty_object_spaces": 0
9+
},
10+
"camel_case_classes": {
11+
"level": "error"
12+
},
13+
"coffeescript_error": {
14+
"level": "error"
15+
},
16+
"colon_assignment_spacing": {
17+
"level": "ignore",
18+
"spacing": {
19+
"left": 0,
20+
"right": 0
21+
}
22+
},
23+
"cyclomatic_complexity": {
24+
"level": "ignore",
25+
"value": 10
26+
},
27+
"duplicate_key": {
28+
"level": "error"
29+
},
30+
"empty_constructor_needs_parens": {
31+
"level": "ignore"
32+
},
33+
"ensure_comprehensions": {
34+
"level": "warn"
35+
},
36+
"eol_last": {
37+
"level": "ignore"
38+
},
39+
"indentation": {
40+
"value": 2,
41+
"level": "error"
42+
},
43+
"line_endings": {
44+
"level": "ignore",
45+
"value": "unix"
46+
},
47+
"max_line_length": {
48+
"value": 120,
49+
"level": "warn",
50+
"limitComments": false
51+
},
52+
"missing_fat_arrows": {
53+
"level": "ignore",
54+
"is_strict": false
55+
},
56+
"newlines_after_classes": {
57+
"value": 3,
58+
"level": "ignore"
59+
},
60+
"no_backticks": {
61+
"level": "error"
62+
},
63+
"no_debugger": {
64+
"level": "warn",
65+
"console": false
66+
},
67+
"no_empty_functions": {
68+
"level": "ignore"
69+
},
70+
"no_empty_param_list": {
71+
"level": "ignore"
72+
},
73+
"no_implicit_braces": {
74+
"level": "ignore",
75+
"strict": true
76+
},
77+
"no_implicit_parens": {
78+
"level": "ignore",
79+
"strict": true
80+
},
81+
"no_interpolation_in_single_quotes": {
82+
"level": "ignore"
83+
},
84+
"no_nested_string_interpolation": {
85+
"level": "warn"
86+
},
87+
"no_plusplus": {
88+
"level": "ignore"
89+
},
90+
"no_private_function_fat_arrows": {
91+
"level": "warn"
92+
},
93+
"no_stand_alone_at": {
94+
"level": "ignore"
95+
},
96+
"no_tabs": {
97+
"level": "error"
98+
},
99+
"no_this": {
100+
"level": "ignore"
101+
},
102+
"no_throwing_strings": {
103+
"level": "error"
104+
},
105+
"no_trailing_semicolons": {
106+
"level": "error"
107+
},
108+
"no_trailing_whitespace": {
109+
"level": "error",
110+
"allowed_in_comments": false,
111+
"allowed_in_empty_lines": true
112+
},
113+
"no_unnecessary_double_quotes": {
114+
"level": "ignore"
115+
},
116+
"no_unnecessary_fat_arrows": {
117+
"level": "warn"
118+
},
119+
"non_empty_constructor_needs_parens": {
120+
"level": "ignore"
121+
},
122+
"prefer_english_operator": {
123+
"level": "ignore",
124+
"doubleNotLevel": "ignore"
125+
},
126+
"space_operators": {
127+
"level": "ignore"
128+
},
129+
"spacing_after_comma": {
130+
"level": "ignore"
131+
},
132+
"transform_messes_up_line_numbers": {
133+
"level": "warn"
134+
}
135+
}

gulp/index.coffee

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# which tasks to laod
2+
tasks = [
3+
'coffeelint'
4+
]
5+
6+
# load tasks
7+
gulp = require('./tasker')(tasks)
8+
9+
# execute tasks
10+
gulp.task 'default', gulp.series tasks

gulp/tasker.coffee

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
gulp = require('gulp')
2+
3+
module.exports = (tasks) ->
4+
tasks.forEach (name) ->
5+
gulp.task name, require('./tasks/' + name)
6+
return gulp

gulp/tasks/coffeelint.coffee

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# require modules from npm
2+
gulp = require 'gulp'
3+
coffeelint = require 'gulp-coffeelint'
4+
conf = require '../coffeelint.json'
5+
6+
# path to source files
7+
path = 'lib/**/*.coffee'
8+
9+
task = () ->
10+
gulp.src(path)
11+
.pipe coffeelint(conf)
12+
.pipe coffeelint.reporter('coffeelint-stylish')
13+
14+
# register the task
15+
gulp.task 'coffeelint', task
16+
module.exports = task

gulpfile.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Note the new way of requesting CoffeeScript since 1.7.x
2+
require('coffee-script/register');
3+
// This bootstraps your Gulp's main file
4+
require('./gulp');

index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
// register coffee-script
5+
require('coffee-script/register');
6+
7+
// export lib
8+
module.exports = require('./lib/main.coffee');

lib/main.coffee

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# require npm modules
2+
request = require 'request'
3+
semcmp = require 'semver-compare'
4+
chalk = require 'chalk'
5+
sprintf = require('sprintf-js').sprintf
6+
7+
baseApiUrl = 'https://api.github.com/repos/%s/releases'
8+
9+
module.exports = (options, callback) ->
10+
11+
# get options
12+
repo = options.repo
13+
currentVersion = options.currentVersion
14+
15+
# check if required options are defined
16+
error 'no repository specified' if repo is undefined
17+
error 'no current version given' if currentVersion is undefined
18+
19+
apiUrl = sprintf baseApiUrl, repo
20+
21+
# request options
22+
reqOpts =
23+
url: apiUrl
24+
headers:
25+
'User-Agent': options.useragent or 'github-version-checker'
26+
27+
request reqOpts, (error, response, body) ->
28+
throw error if error
29+
30+
# parse the response body into an object
31+
releases = JSON.parse body
32+
33+
found = false
34+
35+
# loop through releases
36+
# if a remote version is higher than the installed one, the callback
37+
# will be called with the release object
38+
for release in releases
39+
tag = release.tag_name.replace(/\D/g, '')
40+
if semcmp(currentVersion, tag) is -1
41+
found = true
42+
callback release
43+
break
44+
45+
callback null if not found
46+
47+
# error method
48+
error = (cause) ->
49+
throw chalk.bgRed.bold('Error!') + ' ' + cause

0 commit comments

Comments
 (0)