|
1 | 1 | # github-version-checker |
2 | 2 | > Simple **version checker** working with **GitHub releases** and the **GitHub API**. |
3 | 3 |
|
4 | | -# Note on upgrading to **v2.0.0** |
| 4 | +## Note on upgrading to **v2.0.0** |
5 | 5 | If you are upgrading from a version before **v2.0.0**, please read [**this guide**](MIGRATING-TO-2.0.0.md). |
6 | 6 |
|
7 | 7 | ## Install |
8 | 8 | ```bash |
9 | 9 | $ npm install github-version-checker |
10 | 10 | ``` |
11 | 11 |
|
12 | | -## Usage |
13 | | -```javascript |
14 | | -// require modules |
15 | | -const versionCheck = require('github-version-checker'); |
16 | | -const pkg = require('./package.json'); // or whereever your package.json lies |
17 | | - |
18 | | -// version check options (for details see below) |
19 | | -const options = { |
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 |
25 | | -}; |
26 | | -versionCheck(options, function (error, update) { // callback function |
27 | | - if (error) throw error; |
28 | | - if (update) { // print some update info if an update is available |
29 | | - console.log('An update is available! ' + update.name); |
30 | | - } |
31 | | - |
32 | | - // start your app |
33 | | - console.log('Starting app...'); |
34 | | - //... |
35 | | -}); |
36 | | -``` |
37 | | -Check the [examples folder](https://github.com/axelrindle/github-version-checker/tree/master/examples) for more examples. |
38 | | - |
39 | | -### Note on semantic versioning |
40 | | -Always try to follow a clear [semver format](http://semver.org/). This helps to avoid parsing mistakes and getting a clear result. Also read [here](https://github.com/npm/node-semver#versions). |
41 | | - |
42 | | -## API |
43 | | -### `function versionCheck(options, [callback])` |
44 | | -Performs an update check with the given options. The `callback` is optional, can be left out to return a `Promise`. |
45 | | - |
46 | | -#### The `options` object |
47 | | -Option | Description | Default Value |
48 | | ---- | --- | --- |
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` |
54 | | - |
55 | | -#### The `callback` function (optional) |
56 | | -Should be of the following form: |
57 | | -```javascript |
58 | | -function(error, update) { |
59 | | - // ...your code |
60 | | -} |
61 | | -``` |
62 | | -* `error`: |
63 | | - * 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. |
66 | | - |
67 | | -#### Using `Promise` |
68 | | -You can omit the `callback` function to return a `Promise`, which resolved with the `update` object. |
69 | | - |
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 | | -``` |
| 12 | +## Documentation |
| 13 | +[Check the Wiki](https://github.com/axelrindle/github-version-checker/wiki) |
92 | 14 |
|
93 | 15 | ## License |
94 | 16 | [MIT](LICENSE) |
0 commit comments