simple-gitlab-api
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "simple-gitlab-api", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A simple GitLab API library for Node.js using simple request-promise calls", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Tests coming soon.\" && exit 0" | ||
}, | ||
@@ -9,0 +9,0 @@ "repository": { |
# simple-gitlab-api | ||
[![npm version](https://badge.fury.io/js/simple-gitlab-api.svg)](https://badge.fury.io/js/simple-gitlab-api) | ||
[![Build Status](https://travis-ci.org/napramirez/simple-gitlab-api.svg?branch=master)](https://travis-ci.org/napramirez/simple-gitlab-api) | ||
[![NPM](https://nodei.co/npm/simple-gitlab-api.png)](https://nodei.co/npm/simple-gitlab-api/) | ||
A simple GitLab API library for Node.js using simple request-promise calls | ||
Install | ||
======= | ||
```bash | ||
# Install from npm | ||
npm install simple-gitlab-api | ||
``` | ||
Usage in Node.js | ||
================ | ||
```javascript | ||
var gitlab = require('simple-gitlab-api'); | ||
gitlab.get('/groups').then(function(groups) { | ||
for (var i = 0; i < groups.length; i++) | ||
console.log(groups[i].name); | ||
}); | ||
``` | ||
Environment Variables | ||
===================== | ||
- `GITLAB_URL` - the url to the GitLab server, _e.g._ `https://gitlab.mycompany.com` | ||
- `GITLAB_API_PREFIX` - the API endpoint prefix including the API version, _e.g._ `/api/v4` | ||
- `GITLAB_API_TOKEN` - the access token to the API passed into the header, _e.g._ (as used in `curl`): | ||
```bash | ||
curl --request GET --header 'PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK' 'https://gitlab.example.com/api/v4/projects/13083/repository/files/app%2Fmodels%2Fkey%2Erb/raw?ref=master' | ||
``` |
@@ -24,6 +24,51 @@ var requestPromise = require('request-promise'); | ||
put: (api_path, api_params = {}) => | ||
self.invoke('PUT', api_path, api_params) | ||
self.invoke('PUT', api_path, api_params), | ||
newGroup: (path, name) => | ||
self.post('/groups', { | ||
path: path, | ||
name: name, | ||
visibility: 'internal', | ||
lfs_enabled: false | ||
}), | ||
getGroup: (path) => | ||
self.get('/groups/' + path), | ||
forkProject: (project_path, namespace) => | ||
self.post('/projects/' + encodeURIComponent(project_path) + '/fork', { | ||
namespace: namespace | ||
}), | ||
getProject: (project_path) => | ||
self.get('/projects/' + encodeURIComponent(project_path), { | ||
statistics: false | ||
}), | ||
deleteForkRelationship: (project_path) => | ||
self.delete('/projects/' + encodeURIComponent(project_path) + '/fork'), | ||
renameProject: (project_path, name) => | ||
self.put('/projects/' + encodeURIComponent(project_path), { | ||
name: name, | ||
path: name | ||
}), | ||
waitUntilForkComplete: (project_path) => | ||
new Promise(function(fullfill, reject) { | ||
var forkRefreshId = setInterval(() => | ||
self.getProject(project_path) | ||
.then(function(project) { | ||
if (project.import_status == 'finished') { | ||
clearInterval(forkRefreshId); | ||
fullfill(); | ||
} | ||
}, function(err) { | ||
clearInterval(forkRefreshId); | ||
reject(err); | ||
}), 3000) | ||
}) | ||
} | ||
module.exports = self; |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
4122
4
58
0
38