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

Commit dec4cd1

Browse files
author
Axel Rindle
committed
Version 2.0.0 🎉
1 parent 5e665e2 commit dec4cd1

4 files changed

Lines changed: 56 additions & 25 deletions

File tree

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 Axel Rindle
3+
Copyright (c) 2018 Axel Rindle
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

MIGRATING-TO-2.0.0.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Migrating to Version `2.0.0`
2+
3+
Please note the following changes, when you migrate from a version below `2.0.0`:
4+
5+
- The `options` object changed and require using a [personal access token](https://blog.github.com/2013-05-16-personal-api-tokens/). See [here](https://github.com/axelrindle/github-version-checker#the-options-object).
6+
- The `callback` structure changed. I decided to apply a node convention called **Error-First** in which a callback function's first parameter is the `error`. See [here](https://github.com/axelrindle/github-version-checker#the-callback-function-optional).
7+
8+
Before opening an issue, please confirm that you changed your code according to these changes.

README.md

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# github-version-checker
2-
Simple **version checker** working with **GitHub releases** and the **GitHub API**.
2+
> Simple **version checker** working with **GitHub releases** and the **GitHub API**.
3+
4+
# Note on upgrading to **v2.0.0**
5+
If you are upgrading from a version before **v2.0.0**, please read [**this guide**](MIGRATING-TO-2.0.0.md).
36

47
## Install
58
```bash
69
$ npm install github-version-checker
710
```
8-
or
9-
```bash
10-
$ yarn add github-version-checker
11-
```
1211

1312
## Usage
1413
```javascript
@@ -18,16 +17,16 @@ const pkg = require('./package.json'); // or whereever your package.json lies
1817

1918
// version check options (for details see below)
2019
const options = {
21-
repo: 'axelrindle/github-version-checker', // will be expanded to https://api.github.com/repos/axelrindle/github-version-checker/releases
22-
currentVersion: pkg.version, // your app's current version
23-
includePreReleases: false // if you want to check pre-releases to
20+
token: 'PUT-YOUR-TOKEN-HERE', // personal access token
21+
repo: 'github-version-checker', // repository name
22+
owner: 'axelrindle', // repository owner
23+
currentVersion: pkg.version, // your app's current version
24+
fetchTags: false // whether to fetch releases or tags
2425
};
25-
versionCheck(options, function (update, error) { // callback function
26+
versionCheck(options, function (error, update) { // callback function
2627
if (error) throw error;
2728
if (update) { // print some update info if an update is available
28-
console.log('An update is available!');
29-
console.log('New version: ' + update.tag_name);
30-
console.log('Details here: ' + update.html_url);
29+
console.log('An update is available! ' + update.name);
3130
}
3231

3332
// start your app
@@ -45,27 +44,51 @@ Always try to follow a clear [semver format](http://semver.org/). This helps to
4544
Performs an update check with the given options. The `callback` is optional, can be left out to return a `Promise`.
4645

4746
#### The `options` object
48-
Option | Default value | Description
47+
Option | Description | Default Value
4948
--- | --- | ---
50-
repo | **None. Required option** | Defines from which GitHub repository to load releases from.
51-
currentVersion | **None. Required option** | Your app's current version. Needed to check if a newer release is found.
52-
includePreReleases | false | Whether or not to include pre-releases. **Note:** This will fetch **all** releases, which might result in high traffic, depending on how much releases your app has on GitHub.
49+
token | A [personal access token](https://blog.github.com/2013-05-16-personal-api-tokens/) used to access the Github GraphQL API (as of version **2.0.0**).
50+
repo | The name of your Github repository.
51+
owner | The owner of your Github repository (usually your username).
52+
currentVersion | Your app's current version. Needed to check if a newer release is found.
53+
fetchTags | Whether to fetch the repositorie's git tags instead of the GitHub releases (this is useful when the releases are autogenerated from the tags). | `false`
5354

5455
#### The `callback` function (optional)
5556
Should be of the following form:
5657
```javascript
57-
function(update, error) {
58+
function(error, update) {
5859
// ...your code
5960
}
6061
```
61-
* `update`:
62-
* An object in the format specified [here](https://developer.github.com/v3/repos/releases/#get-a-single-release). `null` if no update was found.
6362
* `error`:
6463
* If an error occurs, this holds the error message. `null` if no error occurs.
64+
* `update`:
65+
* An object in the format specified below. `null` if no update was found.
6566

67+
#### Using `Promise`
68+
You can omit the `callback` function to return a `Promise`, which resolved with the `update` object.
6669

67-
## Todo
70+
### Object schemes
71+
#### Releases
72+
When fetching releases, an object with the following structure will be returned:
73+
```js
74+
Object {
75+
name
76+
tag {
77+
name
78+
}
79+
isPrerelease
80+
publishedAt
81+
url
82+
}
83+
```
84+
85+
#### Tags
86+
When fetching tags, you will receive an object with the following structure:
87+
```js
88+
Object {
89+
name
90+
}
91+
```
6892

69-
* ~~Add a sync method returning just `true` or `false`~~ Can be achieved with **async/await**
70-
* ~~Add settings to define an own update service~~ For now, I stay with GitHub releases only
71-
* ~~Only compare to the latest release on GitHub (see [#1](https://github.com/axelrindle/github-version-checker/issues/1))~~
93+
## License
94+
[MIT](LICENSE)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-version-checker",
3-
"version": "1.2.0",
3+
"version": "2.0.0",
44
"description": "Version checker working with GitHub releases.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)