Skip to content

Commit

Permalink
Merge pull request #2 from Soyhuce/develop
Browse files Browse the repository at this point in the history
Minor Release v0.1.0
  • Loading branch information
Gaël Reyrol committed Jun 2, 2016
2 parents 01f3954 + ff92c04 commit ebfa9b5
Show file tree
Hide file tree
Showing 26 changed files with 254 additions and 947 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/package.json
npm-debug.log
sinopia-*.tgz
cinabre-*.tgz
.DS_Store

###
bin/**
!bin/sinopia
!bin/cinabre
test-storage*

node_modules
5 changes: 2 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
node_modules
package.json
npm-debug.log
sinopia-*.tgz
cinabre-*.tgz

###
bin/**
!bin/sinopia
!bin/cinabre
test-storage*

/.*
19 changes: 14 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
language: node_js
node_js:
- '0.10'
- '0.12'
- '1'
- '2'
- 'iojs'
- '0.10'
- '4'
- '5'
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.9
- g++-4.9
env:
- CC=gcc-4.9 CXX=g++-4.9
sudo: false
matrix:
allow_failures:
- node_js: '0.10'
- node_js: 'iojs'
fast_finish: true
script: npm install . && npm run test-travis
script: npm install && npm run test-travis
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:5
RUN mkdir -p /opt/cinabre && mkdir -p /opt/cinabre/volume
WORKDIR /opt/cinabre
ADD package.json /opt/cinabre/
RUN npm install
ADD . /opt/cinabre
CMD ["/opt/cinabre/docker/start.sh"]
EXPOSE 4873
VOLUME /opt/cinabre/volume
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readYAML('package.yaml'),
pkg: grunt.file.readJSON('package.json'),
browserify: {
dist: {
files: {
Expand Down
35 changes: 19 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
`sinopia` - a private/caching npm repository server
`cinabre` - a private/caching npm repository server

# This forks aims to merge useful pull requests from original repository which appears to be abandoned (last commit oct 2015).
### This forks aims to merge useful pull requests from original sinopia repository which appears to be abandoned (last commit oct 2015).

[![npm version badge](https://img.shields.io/npm/v/sinopia.svg)](https://www.npmjs.org/package/sinopia)
[![travis badge](http://img.shields.io/travis/rlidwka/sinopia.svg)](https://travis-ci.org/rlidwka/sinopia)
[![downloads badge](http://img.shields.io/npm/dm/sinopia.svg)](https://www.npmjs.org/package/sinopia)
<!-- [![npm version badge](https://img.shields.io/npm/v/cinabre.svg)](https://www.npmjs.org/package/cinabre) -->
[![travis badge](http://img.shields.io/travis/Soyhuce/cinabre.svg)](https://travis-ci.org/Soyhuce/cinabre)
<!-- [![downloads badge](http://img.shields.io/npm/dm/cinabre.svg)](https://www.npmjs.org/package/cinabre) -->

It allows you to have a local npm registry with zero configuration. You don't have to install and replicate an entire CouchDB database. Sinopia keeps its own small database and, if a package doesn't exist there, it asks npmjs.org for it keeping only those packages you use.
It allows you to have a local npm registry with zero configuration. You don't have to install and replicate an entire CouchDB database. Cinabre keeps its own small database and, if a package doesn't exist there, it asks npmjs.org for it keeping only those packages you use.

<p align="center"><img src="https://f.cloud.github.com/assets/999113/1795553/680177b2-6a1d-11e3-82e1-02193aa4e32e.png"></p>

Expand Down Expand Up @@ -36,8 +36,8 @@ It allows you to have a local npm registry with zero configuration. You don't ha
```bash
# installation and starting (application will create default
# config in config.yaml you can edit later)
$ npm install -g sinopia
$ sinopia
$ npm install -g cinabre
$ cinabre

# npm configuration
$ npm set registry http://localhost:4873/
Expand All @@ -51,15 +51,18 @@ Now you can navigate to [http://localhost:4873/](http://localhost:4873/) where y

### Docker

A Sinopia docker image [is available](https://registry.hub.docker.com/u/rnbwd/sinopia/)
```Bash
docker build -t cinabre .
docker run -d --name cinabre -p 4873:4873 -v /path/to/cinabre-volume:/opt/cinabre/volume cinabre
```

### Chef

A Sinopia Chef cookbook [is available at Opscode community](http://community.opscode.com/cookbooks/sinopia) source: https://github.com/BarthV/sinopia-cookbook
A Cinabre Chef cookbook [is available at Opscode community](http://community.opscode.com/cookbooks/sinopia) source: https://github.com/BarthV/sinopia-cookbook

### Puppet

A Sinopia puppet module [is available at puppet forge](http://forge.puppetlabs.com/saheba/sinopia) source: https://github.com/saheba/puppet-sinopia
A Cinabre puppet module [is available at puppet forge](http://forge.puppetlabs.com/saheba/sinopia) source: https://github.com/saheba/puppet-cinopia

## Configuration

Expand All @@ -71,7 +74,7 @@ When you start a server, it auto-creates a config file.
npm adduser --registry http://localhost:4873/
```

This will prompt you for user credentials which will be saved on the Sinopia server.
This will prompt you for user credentials which will be saved on the Cinabre server.

## Using private packages

Expand All @@ -81,7 +84,7 @@ It is recommended that you define a prefix for your private packages, for exampl

## Using public packages from npmjs.org

If some package doesn't exist in the storage, server will try to fetch it from npmjs.org. If npmjs.org is down, it serves packages from cache pretending that no other packages exist. Sinopia will download only what's needed (= requested by clients), and this information will be cached, so if client will ask the same thing second time, it can be served without asking npmjs.org for it.
If some package doesn't exist in the storage, server will try to fetch it from npmjs.org. If npmjs.org is down, it serves packages from cache pretending that no other packages exist. Cinabre will download only what's needed (= requested by clients), and this information will be cached, so if client will ask the same thing second time, it can be served without asking npmjs.org for it.

Example: if you successfully request [email protected] from this server once, you'll able to do that again (with all it's dependencies) anytime even if npmjs.org is down. But say [email protected] will not be downloaded until it's actually needed by somebody. And if npmjs.org is offline, this server would say that only [email protected] (= only what's in the cache) is published, but nothing else.

Expand All @@ -93,7 +96,7 @@ There's two options here:

1. You want to create a separate fork and stop synchronizing with public version.

If you want to do that, you should modify your configuration file so sinopia won't make requests regarding this package to npmjs anymore. Add a separate entry for this package to *config.yaml* and remove `npmjs` from `proxy_access` list and restart the server.
If you want to do that, you should modify your configuration file so cinabre won't make requests regarding this package to npmjs anymore. Add a separate entry for this package to *config.yaml* and remove `npmjs` from `proxy_access` list and restart the server.

When you publish your package locally, you should probably start with version string higher than existing one, so it won't conflict with existing package in the cache.

Expand All @@ -103,7 +106,7 @@ There's two options here:

## Compatibility

Sinopia aims to support all features of a standard npm client that make sense to support in private repository. Unfortunately, it isn't always possible.
Cinabre aims to support all features of a standard npm client that make sense to support in private repository. Unfortunately, it isn't always possible.

Basic features:

Expand All @@ -119,7 +122,7 @@ Advanced package control:
User management:

- Registering new users (npm adduser {newuser}) - supported
- Transferring ownership (npm owner add {user} {pkg}) - not supported, sinopia uses its own acl management system
- Transferring ownership (npm owner add {user} {pkg}) - not supported, cinabre uses its own acl management system

Misc stuff:

Expand Down
5 changes: 5 additions & 0 deletions ToDo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ToDo

- ~~Use [marked](https://github.com/chjj/marked) instead of render-readme for Markdown syntax~~
- Switch from express-json5 to express body-parser
- Do something with sinopia-htpasswd
File renamed without changes.
3 changes: 1 addition & 2 deletions conf/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# so don't use it on production systems.
#
# Look here for more config file examples:
# https://github.com/rlidwka/sinopia/tree/master/conf
# https://github.com/soyhuce/cinabre/tree/master/conf
#

# path to a directory with all packages
Expand Down Expand Up @@ -46,4 +46,3 @@ packages:
logs:
- {type: stdout, format: pretty, level: http}
#- {type: file, path: sinopia.log, level: info}

51 changes: 51 additions & 0 deletions conf/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# This is the default config file. It allows all users to do anything,
# so don't use it on production systems.
#
# Look here for more config file examples:
# https://github.com/soyhuce/cinabre/tree/master/conf
#

# path to a directory with all packages
storage: /opt/cinabre/volume/storage

auth:
htpasswd:
file: /opt/cinabre/volume/htpasswd
# Maximum amount of users allowed to register, defaults to "+inf".
# You can set this to -1 to disable registration.
#max_users: 1000

# a list of other known repositories we can talk to
uplinks:
npmjs:
url: https://registry.npmjs.org/

packages:
'@*/*':
# scoped packages
access: $all
publish: $authenticated

'*':
# allow all users (including non-authenticated users) to read and
# publish all packages
#
# you can specify usernames/groupnames (depending on your auth plugin)
# and three keywords: "$all", "$anonymous", "$authenticated"
access: $all

# allow all known users to publish packages
# (anyone can register by default, remember?)
publish: $authenticated

# if package is not available locally, proxy requests to 'npmjs' registry
proxy: npmjs

# log settings
logs:
- {type: stdout, format: pretty, level: http}
#- {type: file, path: sinopia.log, level: info}

listen:
- 0.0.0.0:4873
6 changes: 3 additions & 3 deletions conf/full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ web:
# this has a lot of issues, e.g. no auth yet, so use at your own risk
#enable: true

title: Sinopia
title: Cinabre
# logo: logo.png
# template: custom.hbs

Expand Down Expand Up @@ -78,7 +78,7 @@ packages:
#####################################################################

# if you use nginx with custom path, use this to override links
#url_prefix: https://dev.company.local/sinopia/
#url_prefix: https://dev.company.local/cinabre/

# You can specify listen address (or simply a port).
# If you add multiple values, sinopia will listen on all of them.
Expand All @@ -97,6 +97,7 @@ packages:
#https:
# key: path/to/server.key
# cert: path/to/server.crt
# ca: path/to/ca.crt

# type: file | stdout | stderr
# level: trace | debug | info | http (default) | warn | error | fatal
Expand Down Expand Up @@ -124,4 +125,3 @@ logs:
# it to be turned off in future versions. If `true`, latest tag is ignored,
# and the highest semver is placed instead.
#ignore_latest_tag: false

6 changes: 6 additions & 0 deletions docker/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
if [ ! -f /opt/cinabre/volume/config.yaml ]; then
cp /opt/cinabre/conf/docker.yaml /opt/cinabre/volume/config.yaml
fi
cat /opt/cinabre/volume/config.yaml
node /opt/cinabre/bin/cinabre --config /opt/cinabre/volume/config.yaml
8 changes: 0 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
require('es6-shim')
module.exports = require('./lib')

/**package
{ "name": "sinopia",
"version": "0.0.0",
"dependencies": {"js-yaml": "*"},
"scripts": {"postinstall": "js-yaml package.yaml > package.json ; npm install"}
}
**/
4 changes: 2 additions & 2 deletions lib/GUI/entry.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
</div>
<div class="col-md-4 col-sm-4">
<div class="author pull-right">
<small>By: {{ _npmUser.name }}</small>
<small>By: {{ author.name }}</small>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="description">{{ description }}</p>
<p class="description">{{{ description }}}</p>
</div>
</div>
</div>
12 changes: 6 additions & 6 deletions lib/GUI/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<meta charset="utf-8">
<title>{{ name }}</title>

<link rel="icon" type="image/png" href="{{ baseUrl }}/-/static/favicon.png"/>
<link rel="stylesheet" type="text/css" href="{{ baseUrl }}/-/static/main.css">
<link rel="icon" type="image/png" href="/-/static/favicon.png"/>
<link rel="stylesheet" type="text/css" href="/-/static/main.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body class="body">
Expand Down Expand Up @@ -99,7 +99,7 @@
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h5 class="modal-title" id="login-form-label">Welcome back</h5>
</div>
<form role="form" action="{{ baseUrl }}/-/login" method="post" id="login-form" autocomplete="off">
<form role="form" action="/-/login" method="post" id="login-form" autocomplete="off">
<div class="modal-body">
<div class="form-group">
<label for="user" class="sr-only">Email</label>
Expand All @@ -119,9 +119,9 @@
</div>
</div>

<form action="{{ baseUrl }}/-/logout" method="post" class="hide" id="userLogoutForm"></form>
<form action="/-/logout" method="post" class="hide" id="userLogoutForm"></form>

<script src="{{ baseUrl }}/-/static/jquery.min.js"></script>
<script type='text/javascript' src='{{ baseUrl }}/-/static/main.js'></script>
<script src="/-/static/jquery.min.js"></script>
<script type='text/javascript' src='/-/static/main.js'></script>
</body>
</html>
8 changes: 4 additions & 4 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ var Path = require('path')
var URL = require('url')
var server = require('./index')
var Utils = require('./utils')
var pkg_file = '../package.yaml'
var pkg = YAML.safeLoad(fs.readFileSync(__dirname+'/'+ pkg_file, 'utf8'))
var pkg_file = '../package.json'
var pkg = fs.readFileSync(__dirname+'/'+ pkg_file, 'utf8')

commander
.option('-l, --listen <[host:]port>', 'host:port number to listen on (default: localhost:4873)')
Expand Down Expand Up @@ -131,7 +131,8 @@ function afterConfigLoad() {
secureProtocol: 'SSLv23_method', // disable insecure SSLv2 and SSLv3
secureOptions: constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3,
key: fs.readFileSync(config.https.key),
cert: fs.readFileSync(config.https.cert)
cert: fs.readFileSync(config.https.cert),
ca: fs.readFileSync(config.https.ca)
}, app)
} catch (err) { // catch errors related to certificate loading
logger.logger.fatal({ err: err }, 'cannot create server: @{err.message}')
Expand Down Expand Up @@ -176,4 +177,3 @@ process.on('uncaughtException', function(err) {
, 'uncaught exception, please report this\n@{err.stack}' )
process.exit(255)
})

7 changes: 3 additions & 4 deletions lib/config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
var assert = require('assert')
var Crypto = require('crypto')
var fs = require('fs')
var YAML = require('js-yaml')
// var YAML = require('js-yaml')
var Error = require('http-errors')
var minimatch = require('minimatch')
var Path = require('path')
var LocalData = require('./local-data')
var Utils = require('./utils')
var pkg_file = '../package.yaml'
var pkg = YAML.safeLoad(fs.readFileSync(__dirname+'/'+pkg_file, 'utf8'))
var pkg_file = '../package.json'
var pkg = fs.readFileSync(__dirname+'/'+pkg_file, 'utf8')

// [[a, [b, c]], d] -> [a, b, c, d]
function flatten(array) {
Expand Down Expand Up @@ -195,4 +195,3 @@ module.exports.parse_interval = function(interval) {
})
return result
}

Loading

0 comments on commit ebfa9b5

Please sign in to comment.