Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "gitolite", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Interface to a gitolite backend system", | ||
"main": "index.js", | ||
"main": "lib/gitolite.js", | ||
"repository": { | ||
@@ -18,3 +18,3 @@ "type": "git", | ||
], | ||
"author": "Sam Thompson <git@samt.us>", | ||
"author": "Sam Thompson <contact@samt.us>", | ||
"license": "MIT", | ||
@@ -29,3 +29,6 @@ "bugs": { | ||
"mocha": "~1.18.2" | ||
}, | ||
"engines": { | ||
"node": ">=0.8.0" | ||
} | ||
} |
# gitolite [![Build Status](https://secure.travis-ci.org/samt/node-gitolite.png)](http://travis-ci.org/samt/node-gitolite) | ||
This is a Work-in-progress. | ||
Node.js interface to a gitolite backend system, inspired by the ruby gem [gitolite](https://github.com/wingrunr21/gitolite) | ||
This works by maintaining interal data structures to represent the gitoltie | ||
admin repository. It does not require you to relinquish external control over | ||
the repository as it will rebuild the data structures based upon the current | ||
state of the repository, the configuration files, and the user keys. | ||
## Features | ||
@@ -26,6 +33,13 @@ | ||
var gitolite = require('gitolite'); | ||
var myAdminRepo = gitolite('/path/to/gitolite/repo'); | ||
gitolite('/path/to/gitolite/repo', function (err, adminRepo) { | ||
if (err) throw err; | ||
// manage here | ||
}); | ||
// Dump internal data structures and reload the repo | ||
myAdminRepo.reload(); | ||
// This will call `git fetch origin master && git merge --no-commit origin/master` | ||
adminRepo.reload(function (err, adminRepo) { | ||
if (err) throw err; | ||
// manage here | ||
}); | ||
@@ -38,5 +52,5 @@ ### User/Key management | ||
var bobsSSHkey = 'ssh-rsa AAAA53bd...uV36sBsm== Bob@SHASTA'; | ||
myAdminRepo.addUser('bob'); | ||
var bob = myAdminRepo.users['bob']; | ||
adminRepo.addUser('bob'); | ||
var bob = adminRepo.users['bob']; | ||
bob.addKey('laptop', bobsLaptopSSHkey); // creates 'keydir/laptop/bob.pub' | ||
@@ -46,30 +60,35 @@ bob.addKey('desktop', bobsDesktopSSHkey); | ||
bob.removeKey('laptop'); | ||
// Load key from file | ||
bob.addKeyFile('worklaptop', '/path/to/key.pub'); | ||
// Fluent interface | ||
var alicesMacbookSSHkey = 'ssh-rsa AAAA7b4p...5iK2kFSD== Alice@OAKLAND'; | ||
var alice = myAdminRepo.addUser('alice'); | ||
var alice = adminRepo.addUser('alice'); | ||
alice.addKey('macbook', alicesMacbookSSHkey) // creates keydir/macbook/alice.pub | ||
.addKey('ubuntu', alicesUbuntuSSHkey) // creates keydir/macbook/alice.pub | ||
.addKey('ubuntulaptop', alicesUbuntuLaptopSSHkey); | ||
// View all keys a given user has | ||
for (var label in alice.keys) | ||
for (var label in alice.keys) | ||
console.log(label + ' => ' + alice.keys[label]); // macbook => ssh-rsa AAAA7b4p...5iK2kFSD== Alice@OAKLAND; | ||
// Delete user | ||
myAdminRepo.removeUser('alice'); | ||
adminRepo.removeUser('alice'); | ||
### Group managemnet | ||
// Please note that users who are created but who are not given SSH keys | ||
// will NOT be added to the admin repository. This is a limitation of | ||
// gitolite itself. | ||
var carol = adminRepo.addUser('carol'); | ||
adminRepo.commit(function (err, adminRepo) { | ||
adminRepo.users['carol'] // does not exist | ||
}); | ||
myAdminRepo.addGroup('@admins', [ 'alice', 'bob' ]); | ||
var adminGroup = myAdminRepo.groups['@admins']; | ||
### Group management | ||
adminRepo.addGroup('@admins', [ 'alice', 'bob' ]); | ||
var adminGroup = adminRepo.groups['@admins']; | ||
adminGroup.add('dave'); | ||
adminGroup.remove('bob'); | ||
console.log(adminGroup.users.join(', ')); // alice, dave | ||
// get group object from 'addGroup()' | ||
var devs = myAdminRepo.addGroup('@devs', [ 'ryan', 'sally', 'thomas' ]); | ||
var devs = adminRepo.addGroup('@devs', [ 'ryan', 'sally', 'thomas' ]); | ||
console.log(devs.users.join(', ')); // alice, dave | ||
@@ -79,10 +98,10 @@ | ||
var fooRepo = myAdminRepo.addRepo('foo'); | ||
var fooRepo = adminRepo.addRepo('foo'); | ||
// Delete the repo | ||
myAdminRepo.removeRepo('bar'); | ||
adminRepo.removeRepo('bar'); | ||
### User/Group permissions | ||
var fooRepo = myAdminRepo.repos['foo']; | ||
var fooRepo = adminRepo.repos['foo']; | ||
fooRepo.addPermission('@admins', 'RW+'); | ||
@@ -95,12 +114,12 @@ fooRepo.addPermission('john', 'RW+'); | ||
fooRepo.removePermission('jane'); // partial match of line | ||
### Repo configuration | ||
var fooRepo = myAdminRepo.repos['foo']; | ||
### Repo configuration | ||
var fooRepo = adminRepo.repos['foo']; | ||
fooRepo.addConfig('hook.foo', './runfoobar.sh'); | ||
fooRepo.removeConfig('hook.bar'); | ||
var hookFoobarValue = fooRepo.configs['hook.foo']; | ||
// commit changes to repo and push | ||
myAdminRepo.commit(function (err) { | ||
adminRepo.commit(function (err, adminRepo) { | ||
if (err) throw err; | ||
@@ -107,0 +126,0 @@ console.log('admin repo updated'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
7076
147
6
0