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

Commit 3b943c5

Browse files
committed
Update api
1 parent 3505037 commit 3b943c5

File tree

1 file changed

+60
-20
lines changed

1 file changed

+60
-20
lines changed

docs/docs/api.md

Lines changed: 60 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ sidebar_label: 🧩 API
77

88
```js
99
// Require the module
10-
const versionCheck = require('github-version-checker');
10+
const versionCheck = require('@github-version-checker/core');
11+
12+
// Or import
13+
import versionCheck from '@github-version-checker/core'
1114
```
1215

13-
### `function versionCheck(options, [callback])`
16+
## `function versionCheck(options, [callback])`
1417
Performs an update check with the given options. The `callback` is optional, can be omitted to return a `Promise`.
1518

16-
#### The `options` object
19+
### The `options` object
1720
Option | Description | Default Value | Introduction
1821
--- | --- | --- | ---
1922
token | A [personal access token](https://blog.github.com/2013-05-16-personal-api-tokens/) used to access the **Github GraphQL API (v4)**. Can be omitted and instead be read from an env variable called `GITHUB_API_TOKEN`. When no token can be found, the module will fall back to the **Github Rest API (v3)**. | `undefined` | `v2.0.0`
@@ -23,8 +26,9 @@ currentVersion | Your app's current version. | **None. Required.** | `v1.0.0`
2326
fetchTags | Whether to fetch the repositories' git tags instead of the GitHub releases. Useful when no releases are created, but only tags. | `false` | `v1.0.0`
2427
latestOnly | Setting this to `true` will fetch the latest release only | `false` | `v2.2.0`
2528
excludePrereleases | Excludes pre-releases from checks. Currently only works when no token is specified. | `false` | `v2.3.0`
29+
forceRest | Will use the Github REST API (v3) even with a supplied token. | `false` | `v3.0.0`
2630

27-
#### The `callback` function (optional)
31+
### The `callback` function (optional)
2832
Should be of the following form:
2933
```javascript
3034
function(error, update) {
@@ -36,28 +40,64 @@ function(error, update) {
3640
* `update`:
3741
* An object in the format specified below. `null` if no update was found.
3842

39-
#### Using `Promise`
43+
### Return type
44+
45+
The function returns a `CheckResult` which has the following structure:
46+
47+
```typescript
48+
interface CheckResult {
49+
src: string
50+
type: string
51+
update: ReleaseDescriptor | TagDescriptor | undefined
52+
}
53+
```
54+
55+
#### Properties
56+
##### `src`
57+
58+
States which API endpoint has been used.
59+
60+
Possible values:
61+
62+
- `rest`
63+
- `graphql`
64+
65+
##### `type`
66+
67+
States whether releases or tags have been fetched.
68+
69+
Possible values:
70+
71+
- `releases`
72+
- `tags`
73+
74+
##### `update`
75+
76+
Holds the actual data on a possible update. For structure details refer to [Object schemes](#object-schemes).
77+
78+
It is `undefined` in case no update could be found.
79+
80+
### Using `Promise`
4081
You can omit the `callback` function to return a `Promise`, which resolves with the `update` object.
4182

42-
### Object schemes
43-
#### Releases
83+
## Object schemes
84+
### ReleaseDescriptor
4485
When fetching releases, an object with the following structure will be returned:
45-
```js
46-
Object {
47-
name
48-
tag {
49-
name
50-
}
51-
isPrerelease
52-
publishedAt
53-
url
86+
```typescript
87+
interface ReleaseDescriptor {
88+
name: string
89+
tag: TagDescriptor
90+
isPrerelease: boolean
91+
isDraft: boolean
92+
publishedAt: string
93+
url: string
5494
}
5595
```
5696

57-
#### Tags
97+
### TagDescriptor
5898
When fetching tags, you will receive an object with the following structure:
59-
```js
60-
Object {
61-
name
99+
```typescript
100+
interface TagDescriptor {
101+
name: string
62102
}
63103
```

0 commit comments

Comments
 (0)