diff --git a/wiki/README.md b/wiki/README.md index 7c7b9143c..e88e99ba1 100644 --- a/wiki/README.md +++ b/wiki/README.md @@ -64,7 +64,6 @@ from a fresh look at the code and the outstanding issues. So here we are 🎉 ## Extend Verdaccio * [Installing Plugins](plugins.md) -* Create your own plugins ## DevOps diff --git a/wiki/dev/plugins.md b/wiki/dev/plugins.md index e69de29bb..ad5c74a9d 100644 --- a/wiki/dev/plugins.md +++ b/wiki/dev/plugins.md @@ -0,0 +1,67 @@ +# Creating Plugins + +There are many ways to extend `verdaccio`, currently we only support `authentication plugins` + +## Authentication Plugins + +This section will describe how it looks like a Verdaccio plugin in a ES5 way. Basically we have to return an object with a single method called `authenticate` that will recieve 3 arguments (`user, password, callback`). Once the authentication has been executed there is 2 options to give a response to `verdaccio`. + +##### OnError + +Either something bad happened or auth was unsuccessful. + +``` +callback(null, false) +``` + +##### OnSuccess + +The auth was successful. + + +`groups` is an array of strings where the user is part of. + +``` + callback(null, groups); +``` + +### Example + +```javascript +function Auth(config, stuff) { + var self = Object.create(Auth.prototype); + self._users = {}; + + // config for this module + self._config = config; + + // verdaccio logger + self._logger = stuff.logger; + + // pass verdaccio logger to ldapauth + self._config.client_options.log = stuff.logger; + + return self; +} + +Auth.prototype.authenticate = function (user, password, callback) { + var LdapClient = new LdapAuth(self._config.client_options); + .... + LdapClient.authenticate(user, password, function (err, ldapUser) { + ... + var groups; + ... + callback(null, groups); + }); +}; + +module.exports = Auth; +``` + +## Storage Plugins + +// in progress + +## Middleware Integration + +// in progress \ No newline at end of file diff --git a/wiki/dev/repositories.md b/wiki/dev/repositories.md index e9cb863f4..1139cf1e1 100644 --- a/wiki/dev/repositories.md +++ b/wiki/dev/repositories.md @@ -1,28 +1,27 @@ # Repositories -`verdaccio` is composed or multiple repositories you might contribute. +`verdaccio` is composed or multiple repositories you might contribute. Look into the **issues** tab whether there is a ticket waiting for you 🤠. -Repository | Usage ---- | ---| -[https://github.com/verdaccio/verdaccio](https://github.com/verdaccio/verdaccio) | The main repository -[https://github.com/verdaccio/streams](https://github.com/verdaccio/streams) | Small library to handle streams -[https://github.com/verdaccio/file-locking](https://github.com/verdaccio/file-locking) | Small library to handle locked files -[https://github.com/verdaccio/local-storage](https://github.com/verdaccio/local-storage) | Default dependency for verdaccio to handle local file system storage (since `v3.x`) -[https://github.com/verdaccio/flow-types](https://github.com/verdaccio/flow-types) | `flow` type definitions for verdaccio and sub dependencies. -[https://github.com/verdaccio/verdaccio.github.io](https://github.com/verdaccio/verdaccio.github.io) | Public `verdaccio` website and future documentation page. -[https://github.com/verdaccio/docker-examples](https://github.com/verdaccio/docker-examples) | Docker examples with `docker-compose` to play around with integrations, (nginx, kubernetes, apache, ldap, etc..) -[https://github.com/verdaccio/docker-examples](https://github.com/verdaccio/docker-examples) | Docker examples with `docker-compose` to play around with integrations, (nginx, kubernetes, apache, ldap, etc..) -[https://github.com/verdaccio/puppet-verdaccio](https://github.com/verdaccio/puppet-verdaccio) | Puppet support -[https://github.com/verdaccio/ansible-verdaccio](https://github.com/verdaccio/ansible-verdaccio) | Ansible support -[https://github.com/verdaccio/verdaccio-cookbook](https://github.com/verdaccio/verdaccio-cookbook) | Chef support +Repository | Usage | Stack +--- | ---| ---| +[https://github.com/verdaccio/verdaccio](https://github.com/verdaccio/verdaccio) | The main repository | Node, Express, async, React, Babel, ES6, Mocha, Markdown, HTML, Sass +[https://github.com/verdaccio/streams](https://github.com/verdaccio/streams) | Small library to handle streams | ES6, Babel, *Soon: Flow* +[https://github.com/verdaccio/file-locking](https://github.com/verdaccio/file-locking) | Small library to handle locked files | ES6, Babel, *Soon: Flow* +[https://github.com/verdaccio/local-storage](https://github.com/verdaccio/local-storage) | Default dependency for verdaccio to handle local file system storage (since `v3.x`) | ES6, Babel, Flow +[https://github.com/verdaccio/flow-types](https://github.com/verdaccio/flow-types) | `flow` type definitions for verdaccio and sub dependencies. | Flow, flow-typed +[https://github.com/verdaccio/verdaccio.github.io](https://github.com/verdaccio/verdaccio.github.io) | Public `verdaccio` website and future documentation page. | Markdown, HTML, Sass, Github Pages +[https://github.com/verdaccio/docker-examples](https://github.com/verdaccio/docker-examples) | Docker examples with `docker-compose` to play around with integrations, (nginx, kubernetes, apache, ldap, etc..) | Docker Compose, Docker +[https://github.com/verdaccio/puppet-verdaccio](https://github.com/verdaccio/puppet-verdaccio) | Puppet support | Puppet +[https://github.com/verdaccio/ansible-verdaccio](https://github.com/verdaccio/ansible-verdaccio) | Ansible support | Ansible +[https://github.com/verdaccio/verdaccio-cookbook](https://github.com/verdaccio/verdaccio-cookbook) | Chef support | Chef ## Experimental Repos The following repositories aims to be part of the future infraestructure of `verdaccio` and are just PoC looking for active colaborators. -Repository | Usage ---- | ---| -[https://github.com/verdaccio/verdaccio-plugin-auth-htpasswd](https://github.com/verdaccio/verdaccio-plugin-auth-htpasswd) | Default authentification plugin based on Babel -[https://github.com/verdaccio/generator-verdaccio-plugin](https://github.com/verdaccio/generator-verdaccio-plugin) | Yeoman generators for future verdaccio plugins -[https://github.com/verdaccio/blog](https://github.com/verdaccio/blog) | Any article related with verdaccio +Repository | Usage | Stack +--- | ---| ---| +[https://github.com/verdaccio/verdaccio-plugin-auth-htpasswd](https://github.com/verdaccio/verdaccio-plugin-auth-htpasswd) | Default authentification plugin based on Babel | ES6, Babel, Flow +[https://github.com/verdaccio/generator-verdaccio-plugin](https://github.com/verdaccio/generator-verdaccio-plugin) | Yeoman generators for future verdaccio plugins | ES6, Babel, Yeoman +[https://github.com/verdaccio/blog](https://github.com/verdaccio/blog) | Any article related with verdaccio | Markdown diff --git a/wiki/dev/test.md b/wiki/dev/test.md index 5e4961f9b..f4bcfccac 100644 --- a/wiki/dev/test.md +++ b/wiki/dev/test.md @@ -10,7 +10,7 @@ Unit and functional tests are executed automatically by running `npm test` from We use `mocha` for all test. -## Script +## The npm Script To run the test script you can use either `npm` or `yarn`. @@ -20,8 +20,7 @@ yarn run test That will trigger only two first groups of test, unit and functional. -### Unit Test - +### Using test/unit The following is just an example how a unit test should looks like. Basically follow the `mocha` standard. Try to describe what exactly does the unit test in a single sentence in the header of the `it` section. ```javacript @@ -40,7 +39,7 @@ describe('Parse interval', function() { });}); ``` -### Functional Test +### Using test/functional Funtional testing in verdaccio has a bit more of complextity that needs a deep explanation in order to success in your experience. @@ -112,6 +111,47 @@ The startup file is the responsable to create the 3 verdaccio instances and inje This module holds a `PromiseAssert` which extends from `Promise` adding methods to handle all request from `lib/server.js`. +### Usage + +Here we are gonna describe how it looks like an usual functional test, check inline for more detail information. + +```javascript +'use strict'; + +module.exports = function() { + // you can access the 3 instance through process global variables + const server = process.server; + const server2 = process.server2; + + describe('my-functional-group-test', function() { + before(function() { + // create a raw emtpy package + const pkg = require('./fixtures/package')('new-package'); + return server.putPackage('new-package', pkg) + // check whether was uploaded correctly + .status(201) + // check whether body response is ok + .body_ok(/created new package/); + }); + + // since before are not registred, we use emtpy it to display before putPackage was success + it('creating new package / srv1', function() {}); + + it('should do something else here ..... ', function() { + // this should fails since fakeVersion does not exist + // note we use server2 because is an uplink of server 1 + return server2.getTarball('new-package', 'fakeVersion') + .status(404) + .body_error(/no such file/); + }); + }); +}; +``` + +### Test/integration + +These section never has been used, but we are looking for help to make it run properly. All new ideas are very welcome. +