Comparing version 11.0.2 to 11.1.0
@@ -0,1 +1,8 @@ | ||
# [11.1.0](https://github.com/jdalrymple/node-gitlab/compare/11.0.2...11.1.0) (2019-09-09) | ||
### Features | ||
* Adding support for CLI ([6f90f4c](https://github.com/jdalrymple/node-gitlab/commit/6f90f4c)), closes [#146](https://github.com/jdalrymple/node-gitlab/issues/146) | ||
## [11.0.2](https://github.com/jdalrymple/node-gitlab/compare/11.0.1...11.0.2) (2019-08-30) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "gitlab", | ||
"description": "Full NodeJS implementation of the GitLab API. Supports Promises, Async/Await.", | ||
"version": "11.0.2", | ||
"version": "11.1.0", | ||
"author": { | ||
@@ -9,2 +9,5 @@ "name": "Justin Dalrymple", | ||
}, | ||
"bin": { | ||
"gitlab": "./dist/cli.js" | ||
}, | ||
"browser": "dist/index.browser.js", | ||
@@ -26,3 +29,4 @@ "bugs": { | ||
"query-string": "^6.8.2", | ||
"universal-url": "^2.0.0" | ||
"universal-url": "^2.0.0", | ||
"yargs": "^14.0.0" | ||
}, | ||
@@ -35,4 +39,9 @@ "devDependencies": { | ||
"@types/jest": "^24.0.18", | ||
"change-case": "^3.1.0", | ||
"codecov": "^3.5.0", | ||
"cz-conventional-changelog": "^3.0.2", | ||
"dotenv": "^8.1.0", | ||
"esm": "^3.2.25", | ||
"fs-extra": "^8.1.0", | ||
"get-param-names": "github:jdalrymple/get-param-names#1-improve-functionality", | ||
"husky": "^4.0.0-beta.1", | ||
@@ -50,2 +59,3 @@ "jest": "24.9.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-replace": "^2.2.0", | ||
"rollup-plugin-terser": "^5.1.1", | ||
@@ -71,2 +81,3 @@ "rollup-plugin-typescript2": "^0.24.0", | ||
"browser", | ||
"cli", | ||
"es5", | ||
@@ -85,3 +96,4 @@ "es6", | ||
"scripts": { | ||
"build": "tsc && rollup -c", | ||
"build": "npm run build:cli && tsc && rollup -c", | ||
"build:cli": "tsc -p tsconfig.cli.json && node -r esm temp/bin/generate", | ||
"commit": "npx git-cz", | ||
@@ -98,3 +110,4 @@ "coverage": "codecov", | ||
}, | ||
"type": "module", | ||
"types": "dist/index.d.ts" | ||
} |
172
README.md
@@ -22,6 +22,7 @@ [![npm @latest](https://img.shields.io/npm/v/gitlab.svg)](https://www.npmjs.com/package/gitlab) | ||
- [Install](#install) | ||
- [Usage](#usage) | ||
- [Getting Started](#getting-started) | ||
- [CLI Support](#cli-support) | ||
- [Docs](#docs) | ||
- [Supported APIs](#supported-apis) | ||
- [Import](#import) | ||
- [Bundle Imports](#bundle-imports) | ||
- [Bundle Imports](#bundle-imports) | ||
- [Examples](#examples) | ||
@@ -31,3 +32,3 @@ - [Pagination](#pagination) | ||
- [Custom Request Libraries](#custom-request-libraries) | ||
- [Docs](#docs) | ||
- [Misc](#misc) | ||
- [Development](#development) | ||
@@ -46,4 +47,70 @@ - [Testing](#testing) | ||
## Usage | ||
## Getting Started | ||
Instantiate the library using a basic token created in your [Gitlab Profile](https://docs.gitlab.com/ce/user/profile/personal_access_tokens.html) | ||
```javascript | ||
// ES6 (>=node 10.16.0 LTS) | ||
import { Gitlab } from 'gitlab'; // All Resources | ||
import { Projects } from 'gitlab'; // Just the Project Resource | ||
//...etc | ||
// ES5, assuming native or polyfilled Promise is available | ||
const { Gitlab } = require('gitlab'); | ||
``` | ||
```javascript | ||
const api = new Gitlab({ | ||
token: 'personaltoken', | ||
}); | ||
``` | ||
Available instantiating options: | ||
| Name | Optional | Default | Description | | ||
| -------------------- | -------- | ----------------------------------------------------- | --------------------------------------------------------------- | | ||
| `host` | Yes | `https://gitlab.com` | Gitlab Instance Host URL | | ||
| `token` | No\* | N/A | Personal Token. Required (one of the three tokens are required) | | ||
| `oauthToken` | No\* | N/A | OAuth Token. Required (one of the three tokens are required) | | ||
| `jobToken` | No\* | N/A | CI Job Token. Required (one of the three tokens are required) | | ||
| `rejectUnauthorized` | Yes | `false` | Http Certificate setting | | ||
| `sudo` | Yes | `false` | Sudo query parameter | | ||
| `version` | Yes | `v4` | API Version ID | | ||
| `camelize` | Yes | `false` | Response Key Camelize. Camelizes all response body keys | | ||
| `requester` | Yes | [KyRequester.ts](./src/infrastructure/KyRequester.ts) | Request Library Wrapper. Currently wraps Ky. | | ||
| `requestTimeout` | Yes | `300000` | Request Library Timeout in ms | | ||
### CLI Support | ||
The CLI export functions in a similar manner, following the pattern: | ||
```bash | ||
gitlab [service name] [method name] --arg1 --arg2 --arg3 | ||
``` | ||
Where `service name` is any of the supported API names, `method name` is any of the supported commands on that API service (See source for exceptions, but generally all, show, remove, update) and `--arg1...--arg3` are any of the arguments you would normally supply to the function. The names of the args should match the names in the method headers **EXCEPT** all the optional arguments who's names should match what the GitLab API docs request. | ||
There is one small exception with the instantiating arguments however, which must be supplied using a `gl` prefix. ie. | ||
```bash | ||
# To get all the projects | ||
gitlab projects all --gl-token="personaltoken" | ||
# To get a project with id = 2 | ||
gitlab projects show --gl-token="personaltoken" --projectId=2 | ||
``` | ||
To reduce the annoyance of having to pass those configuration properties each time, it is also possible to pass the token and host information through environment variables in the form of `GITLAB_[option name]` ie: | ||
```bash | ||
GITLAB_HOST=http://example.com | ||
GITLAB_TOKEN=personaltoken | ||
``` | ||
This could be set globally or using a [.env](https://github.com/motdotla/dotenv#readme) file in the project folder. | ||
## Docs | ||
Although there are the [official docs](https://github.com/gitlabhq/gitlabhq/tree/master/doc/api) for the API, there are some extra goodies offered by this package! After the 3.0.0 release, the next large project will be putting together proper documentation for these goodies [#39]! Stay tuned!! | ||
### Supported APIs | ||
@@ -149,43 +216,4 @@ | ||
### Import | ||
### Bundle Imports | ||
URL to your GitLab instance should not include `/api/v4` path. | ||
Instantiate the library using a basic token created in your [Gitlab Profile](https://docs.gitlab.com/ce/user/profile/personal_access_tokens.html) | ||
```javascript | ||
// ES6 (>=node 10.16.0 LTS) | ||
import { Gitlab } from 'gitlab'; // All Resources | ||
import { Projects } from 'gitlab'; // Just the Project Resource | ||
//...etc | ||
// ES5, assuming native or polyfilled Promise is available | ||
const { Gitlab } = require('gitlab'); | ||
``` | ||
Basic Example | ||
```javascript | ||
const api = new Gitlab({ | ||
token: 'personaltoken', | ||
}); | ||
``` | ||
Available instatiating options: | ||
| Name | Optional | Default | Description | | ||
| -------------------- | -------- | ----------------------------------------------------- | --------------------------------------------------------------- | | ||
| `host` | Yes | `https://gitlab.com` | Gitlab Instance Host URL | | ||
| `token` | No\* | N/A | Personal Token. Required (one of the three tokens are required) | | ||
| `oauthToken` | No\* | N/A | OAuth Token. Required (one of the three tokens are required) | | ||
| `jobToken` | No\* | N/A | CI Job Token. Required (one of the three tokens are required) | | ||
| `rejectUnauthorized` | Yes | `false` | Http Certificate setting | | ||
| `sudo` | Yes | `false` | Sudo query parameter | | ||
| `version` | Yes | `v4` | API Version ID | | ||
| `camelize` | Yes | `false` | Response Key Camelize. Camelizes all response body keys | | ||
| `requester` | Yes | [KyRequester.ts](./src/infrastructure/KyRequester.ts) | Request Library Wrapper. Currently wraps Ky. | | ||
| `requestTimeout` | Yes | `300000` | Request Library Timeout in ms | | ||
#### Bundle Imports | ||
It can be annoying to have to import all the API's pertaining to a specific resource. For example, the Projects resource is composed of many API's, Projects, Issues, Labels, MergeRequests, etc. For convenience, there is a Bundle export for importing and instantiating all these related API's at once. | ||
@@ -198,3 +226,3 @@ | ||
host: 'http://example.com', | ||
token: 'abcdefghij123456' | ||
token: 'personaltoken' | ||
}) | ||
@@ -288,14 +316,2 @@ | ||
#### Handling HTTPS certificates | ||
If your Gitlab server is running via HTTPS, the proper way to pass in your certificates is via a `NODE_EXTRA_CA_CERTS` environment key, like this: | ||
```js | ||
"scripts": { | ||
"start": "NODE_EXTRA_CA_CERTS=./secrets/3ShapeCA.pem node bot.js" | ||
}, | ||
``` | ||
> **NOTE**: _Using `process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'` will not work with the `gitlab` library. The `rejectUnauthorized` key is the only way to allow insecure certificates to be bypassed._ | ||
### Examples | ||
@@ -312,3 +328,3 @@ | ||
host: 'http://example.com', | ||
token: 'abcdefghij123456', | ||
token: 'personaltoken', | ||
}); | ||
@@ -337,3 +353,3 @@ | ||
host: 'http://example.com', | ||
token: 'abcdefghij123456', | ||
token: 'personaltoken', | ||
}); | ||
@@ -355,3 +371,3 @@ | ||
host: 'http://example.com', | ||
token: 'abcdefghij123456', | ||
token: 'personaltoken', | ||
}); | ||
@@ -369,3 +385,3 @@ | ||
host: 'http://example.com', | ||
token: 'abcdefghij123456', | ||
token: 'personaltoken', | ||
}); | ||
@@ -418,3 +434,3 @@ | ||
host: 'http://example.com', | ||
token: 'abcdefghij123456' | ||
token: 'personaltoken' | ||
sudo: 8 // Can be the user ID or a username | ||
@@ -442,3 +458,3 @@ }); | ||
host: 'http://example.com', | ||
token: 'abcdefghij123456', | ||
token: 'personaltoken', | ||
requester: YourCustomRequester, | ||
@@ -448,8 +464,16 @@ }); | ||
## Docs | ||
### Misc | ||
Although there are the [official docs](https://github.com/gitlabhq/gitlabhq/tree/master/doc/api) for the API, there are some extra goodies offered by this package! After the 3.0.0 release, the next large project will be putting together proper documentation for these goodies [#39]! Stay tuned!! | ||
#### Handling HTTPS certificates | ||
### Misc | ||
If your Gitlab server is running via HTTPS, the proper way to pass in your certificates is via a `NODE_EXTRA_CA_CERTS` environment key, like this: | ||
```js | ||
"scripts": { | ||
"start": "NODE_EXTRA_CA_CERTS=./secrets/3ShapeCA.pem node bot.js" | ||
}, | ||
``` | ||
> **NOTE**: _Using `process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'` will not work with the `gitlab` library. The `rejectUnauthorized` key is the only way to allow insecure certificates to be bypassed._ | ||
#### Non JSON/Text Responses | ||
@@ -459,3 +483,3 @@ | ||
``` | ||
```javascript | ||
let bufferedData = await api.Jobs.downloadLatestArtifactFile(project.id, "test", "job_test); | ||
@@ -481,5 +505,5 @@ | ||
```json | ||
"dependencies": { | ||
"gitlab": "5.0.0" | ||
} | ||
"dependencies": { | ||
"gitlab": "5.0.0" | ||
} | ||
``` | ||
@@ -490,5 +514,5 @@ | ||
```json | ||
"dependencies": { | ||
"gitlab": "<path-to-your-clone>" | ||
} | ||
"dependencies": { | ||
"gitlab": "<path-to-your-clone>" | ||
} | ||
``` | ||
@@ -495,0 +519,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
647121
222
4303
602
Yes
8
34
3
2
+ Addedyargs@^14.0.0
+ Addedansi-regex@4.1.1(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedcamelcase@5.3.1(transitive)
+ Addedcliui@5.0.0(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addedemoji-regex@7.0.3(transitive)
+ Addedfind-up@3.0.0(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedis-fullwidth-code-point@2.0.0(transitive)
+ Addedlocate-path@3.0.0(transitive)
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@3.0.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedpath-exists@3.0.0(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedrequire-main-filename@2.0.0(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedstring-width@3.1.0(transitive)
+ Addedstrip-ansi@5.2.0(transitive)
+ Addedwhich-module@2.0.1(transitive)
+ Addedwrap-ansi@5.1.0(transitive)
+ Addedy18n@4.0.3(transitive)
+ Addedyargs@14.2.3(transitive)
+ Addedyargs-parser@15.0.3(transitive)