Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43a4440886 |
2
AUTHORS
2
AUTHORS
@@ -1,6 +1,6 @@
|
||||
# Ordered by date of first contribution.
|
||||
|
||||
fengmk2 <fengmk2@gmail.com> (https://github.com/fengmk2)
|
||||
fengmk2 <m@fengmk2.com> (https://github.com/fengmk2)
|
||||
dead-horse <dead_horse@qq.com> (https://github.com/dead-horse)
|
||||
alsotang <alsotang@gmail.com> (https://github.com/alsotang)
|
||||
4simple <wondger@qq.com> (https://github.com/4simple)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
This software is licensed under the MIT License.
|
||||
|
||||
Copyright(c) cnpmjs.org and other contributors.
|
||||
Copyright(c) 2014 - 2015 cnpm and other contributors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
21
controllers/web/home.js
Normal file
21
controllers/web/home.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/**!
|
||||
* cnpmjs.org - controllers/web/home.js
|
||||
*
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* fengmk2 <m@fengmk2.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
module.exports = function* () {
|
||||
yield this.render('home', {
|
||||
title: 'cnpmjs.org: Private npm registry and web for Company'
|
||||
});
|
||||
};
|
||||
@@ -1,141 +0,0 @@
|
||||
# cnpmjs.org: Private npm registry and web for Company
|
||||
|
||||
So `cnpm` is meaning: **Company npm**.
|
||||
|
||||
## Registry
|
||||
|
||||
- Our public registry: [r.cnpmjs.org](//r.cnpmjs.org), syncing from [registry.npmjs.org](//registry.npmjs.org)
|
||||
- [cnpmjs.org](/) version: <span id="app-version"></span>
|
||||
- [Node.js](https://nodejs.org) version: <span id="node-version"></span>
|
||||
- For developers behind the GFW, please visit [the Chinese mirror](https://npm.taobao.org). 中国用户请访问[国内镜像站点](https://npm.taobao.org/)。
|
||||
|
||||
<table class="downloads">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="count" id="total-packages"></td><td>total packages</td>
|
||||
<td class="count" id="total-versions"></td><td>total package versions</td>
|
||||
<td class="count" id="total-deletes"></td><td>total delete packages</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="count"></td><td> downloads today</td>
|
||||
<td class="count"></td><td> downloads in this week</td>
|
||||
<td class="count"></td><td> downloads in this month</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="count"></td><td> downloads in the last day</td>
|
||||
<td class="count"></td><td> downloads in the last week</td>
|
||||
<td class="count"></td><td> downloads in the last month</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="sync" style="display:none;">
|
||||
<h3>Sync Status</h3>
|
||||
<p id="sync-model"></p>
|
||||
<p>Last sync time is <span id="last-sync-time"></span>. </p>
|
||||
<p class="syncing alert alert-info">The sync worker is working in the backend now. </p>
|
||||
<table class="sync-status">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><span id="need-sync"></span> packages need to be sync</td>
|
||||
<td class="syncing"><span id="left-sync"></span> packages and dependencies waiting for sync</td>
|
||||
<td><span id="percent-sync"></span>% progress</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span id="success-sync"></span> packages and dependencies sync successed</td>
|
||||
<td><span id="fail-sync"></span> packages and dependencies sync failed</td>
|
||||
<td>last success: <span id="last-success-name"></span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script src="/js/readme.js"></script>
|
||||
|
||||
## Version Badge
|
||||
|
||||
Default style is `flat-square`.
|
||||
|
||||
Badge URL: `https://cnpmjs.org/badge/v/cnpmjs.org.svg` 
|
||||
|
||||
* `<0.1.0 & >=0.0.0`: 
|
||||
* `<1.0.0 & >=0.1.0`: 
|
||||
* `>=1.0.0`: 
|
||||
|
||||
## Usage
|
||||
|
||||
use our npm client [cnpm](https://github.com/cnpm/cnpm)(More suitable with cnpmjs.org and gzip support), you can get our client through npm:
|
||||
|
||||
```bash
|
||||
$ npm install -g cnpm --registry=https://r.cnpmjs.org
|
||||
```
|
||||
|
||||
Or you can alias NPM to use it:
|
||||
|
||||
```bash
|
||||
alias cnpm="npm --registry=https://r.cnpmjs.org \
|
||||
--cache=$HOME/.npm/.cache/cnpm \
|
||||
--disturl=https://cnpmjs.org/mirrors/node \
|
||||
--userconfig=$HOME/.cnpmrc"
|
||||
|
||||
#Or alias it in .bashrc or .zshrc
|
||||
$ echo '\n#alias for cnpm\nalias cnpm="npm --registry=https://r.cnpmjs.org \
|
||||
--cache=$HOME/.npm/.cache/cnpm \
|
||||
--disturl=https://cnpmjs.org/mirrors/node \
|
||||
--userconfig=$HOME/.cnpmrc"' >> ~/.zshrc && source ~/.zshrc
|
||||
```
|
||||
|
||||
### install
|
||||
|
||||
Install package from [r.cnpmjs.org](//r.cnpmjs.org). When installing a package or version does not exist, it will try to install from the official registry([registry.npmjs.org](//registry.npmjs.org)), and sync this package to cnpm in the backend.
|
||||
|
||||
```bash
|
||||
$ cnpm install [name]
|
||||
```
|
||||
|
||||
### sync
|
||||
|
||||
Only `cnpm` cli has this command. Meaning sync package from source npm.
|
||||
|
||||
```bash
|
||||
$ cnpm sync connect
|
||||
```
|
||||
|
||||
sync package on web: [sync/connect](/sync/connect)
|
||||
|
||||
```bash
|
||||
$ open https://cnpmjs.org/sync/connect
|
||||
```
|
||||
|
||||
### publish / unpublish
|
||||
|
||||
Only `admin` user can publish / unpublish package to private registry.
|
||||
|
||||
```bash
|
||||
$ cnpm publish [name]
|
||||
$ cnpm unpublish [name]
|
||||
```
|
||||
|
||||
### Other commands
|
||||
|
||||
Support all the other npm commands. e.g.:
|
||||
|
||||
```bash
|
||||
$ cnpm info cnpm
|
||||
```
|
||||
|
||||
## TODO list
|
||||
|
||||
@see Github [Issues](https://github.com/cnpm/cnpmjs.org/issues)
|
||||
|
||||
## Histories
|
||||
|
||||
Release [History](/history).
|
||||
|
||||
## npm and cnpm relation
|
||||
|
||||

|
||||
|
||||
## Sponsors
|
||||
|
||||
- [](http://www.ucloud.cn/sdk?sem=sdk-CNPMJS)
|
||||
3
locales/en_US.json
Normal file
3
locales/en_US.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"cnpmjs.org: Private npm registry and web for Company": "cnpmjs.org: Private npm registry and web for Company"
|
||||
}
|
||||
3
locales/zh_CN.json
Normal file
3
locales/zh_CN.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"cnpmjs.org: Private npm registry and web for Company": "cnpmjs.org: 企业级私有 npm 仓库"
|
||||
}
|
||||
26
middleware/i18n.js
Normal file
26
middleware/i18n.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**!
|
||||
* cnpmjs.org - middleware/i18n.js
|
||||
*
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* fengmk2 <m@fengmk2.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var locales = require('koa-locales');
|
||||
|
||||
module.exports = function (options, app) {
|
||||
locales(app, options);
|
||||
|
||||
return function* i18n(next) {
|
||||
this.state.__ = this.__.bind(this);
|
||||
yield* next;
|
||||
};
|
||||
};
|
||||
11
package.json
11
package.json
@@ -35,8 +35,9 @@
|
||||
"kcors": "~1.0.1",
|
||||
"koa": "~0.17.0",
|
||||
"koa-limit": "~1.0.2",
|
||||
"koa-locales": "~1.0.2",
|
||||
"koa-markdown": "~2.0.1",
|
||||
"koa-middlewares": "~2.1.0",
|
||||
"koa-middlewares": "~3.1.0",
|
||||
"koa-mock": "~1.1.4",
|
||||
"markdown-it": "~3.0.6",
|
||||
"mime": "~1.3.4",
|
||||
@@ -46,7 +47,7 @@
|
||||
"mysql": "~2.5.4",
|
||||
"nodemailer": "~1.3.0",
|
||||
"semver": "~4.2.0",
|
||||
"sequelize": "~2.0.1",
|
||||
"sequelize": "~3.0.0",
|
||||
"thunkify-wrap": "~1.0.4",
|
||||
"treekill": "~1.0.0",
|
||||
"tunnel-agent": "^0.4.0",
|
||||
@@ -80,7 +81,7 @@
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/cnpm/cnpmjs.org/issues",
|
||||
"email": "fengmk2@gmail.com"
|
||||
"email": "m@fengmk2.com"
|
||||
},
|
||||
"keywords": [
|
||||
"cnpmjs.org",
|
||||
@@ -90,10 +91,10 @@
|
||||
"registry"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.11.14"
|
||||
"node": ">=2.0.2"
|
||||
},
|
||||
"author": [
|
||||
"fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)",
|
||||
"fengmk2 <m@fengmk2.com> (http://fengmk2.com)",
|
||||
"dead_horse <dead_horse@qq.com> (http://deadhorse.me)"
|
||||
],
|
||||
"license": "MIT"
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/**!
|
||||
* cnpmjs.org - routes/web.js
|
||||
*
|
||||
* Copyright(c) cnpmjs.org and other contributors.
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* dead_horse <dead_horse@qq.com>
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
|
||||
* fengmk2 <m@fengmk2.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -24,8 +24,10 @@ var showUser = require('../controllers/web/user/show');
|
||||
var sync = require('../controllers/sync');
|
||||
var showTotal = require('../controllers/total');
|
||||
var badge = require('../controllers/web/badge');
|
||||
var home = require('../controllers/web/home');
|
||||
|
||||
function routes(app) {
|
||||
app.get('/', home);
|
||||
app.get('/total', showTotal);
|
||||
|
||||
// scope package without version
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/**!
|
||||
* cnpmjs.org - servers/web.js
|
||||
*
|
||||
* Copyright(c) cnpmjs.org and other contributors.
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* dead_horse <dead_horse@qq.com>
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
|
||||
* fengmk2 <m@fengmk2.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
@@ -26,6 +26,7 @@ var logger = require('../common/logger');
|
||||
var renderMarkdown = require('../common/markdown').render;
|
||||
var auth = require('../middleware/auth');
|
||||
var proxyToNpm = require('../middleware/proxy_to_npm');
|
||||
var i18n = require('../middleware/i18n');
|
||||
var routes = require('../routes/web');
|
||||
var config = require('../config');
|
||||
var path = require('path');
|
||||
@@ -77,14 +78,11 @@ var layout = fs.readFileSync(path.join(viewDir, 'layout.html'), 'utf8')
|
||||
fs.writeFileSync(layoutFile, layout);
|
||||
|
||||
// custom web readme home page support
|
||||
var readmeFile = path.join(docDir, '_readme.md');
|
||||
var readmeContent;
|
||||
if (config.customReadmeFile) {
|
||||
readmeContent = fs.readFileSync(config.customReadmeFile, 'utf8');
|
||||
} else {
|
||||
readmeContent = fs.readFileSync(path.join(docDir, 'readme.md'), 'utf8');
|
||||
var readmeFile = path.join(docDir, '_readme.md');
|
||||
var readmeContent = fs.readFileSync(config.customReadmeFile, 'utf8');
|
||||
fs.writeFileSync(readmeFile, readmeContent);
|
||||
}
|
||||
fs.writeFileSync(readmeFile, readmeContent);
|
||||
|
||||
app.use(markdownMiddleware({
|
||||
baseUrl: '/',
|
||||
@@ -99,7 +97,12 @@ app.use(markdownMiddleware({
|
||||
},
|
||||
}));
|
||||
|
||||
var locals = {
|
||||
app.use(i18n({
|
||||
dir: path.join(__dirname, '..', 'locales'),
|
||||
defaultLocale: 'en_US'
|
||||
}, app));
|
||||
|
||||
var globalLocals = {
|
||||
config: config
|
||||
};
|
||||
|
||||
@@ -109,7 +112,7 @@ middlewares.ejs(app, {
|
||||
layout: '_layout',
|
||||
cache: config.viewCache,
|
||||
debug: config.debug,
|
||||
locals: locals
|
||||
locals: globalLocals
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
117
view/web/home.html
Normal file
117
view/web/home.html
Normal file
@@ -0,0 +1,117 @@
|
||||
<h1><%= __('cnpmjs.org: Private npm registry and web for Company') %></h1>
|
||||
<p>So <code>cnpm</code> is meaning: <strong>Company npm</strong>.</p>
|
||||
|
||||
<h2>Registry</h2>
|
||||
<ul>
|
||||
<li>Our public registry: <a href="//r.cnpmjs.org">r.cnpmjs.org</a>, syncing from <a href="//registry.npmjs.org">registry.npmjs.org</a></li>
|
||||
<li><a href="/">cnpmjs.org</a> version: <span id="app-version"></span></li>
|
||||
<li><a href="https://nodejs.org">Node.js</a> version: <span id="node-version"></span></li>
|
||||
<li>For developers behind the GFW, please visit <a href="https://npm.taobao.org">the Chinese mirror</a>. 中国用户请访问<a href="https://npm.taobao.org/">国内镜像站点</a>。</li>
|
||||
</ul>
|
||||
|
||||
<table class="downloads">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="count" id="total-packages"></td><td>total packages</td>
|
||||
<td class="count" id="total-versions"></td><td>total package versions</td>
|
||||
<td class="count" id="total-deletes"></td><td>total delete packages</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="count"></td><td> downloads today</td>
|
||||
<td class="count"></td><td> downloads in this week</td>
|
||||
<td class="count"></td><td> downloads in this month</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="count"></td><td> downloads in the last day</td>
|
||||
<td class="count"></td><td> downloads in the last week</td>
|
||||
<td class="count"></td><td> downloads in the last month</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="sync" style="display:none;">
|
||||
<h3>Sync Status</h3>
|
||||
<p id="sync-model"></p>
|
||||
<p>Last sync time is <span id="last-sync-time"></span>. </p>
|
||||
<p class="syncing alert alert-info">The sync worker is working in the backend now. </p>
|
||||
<table class="sync-status">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><span id="need-sync"></span> packages need to be sync</td>
|
||||
<td class="syncing"><span id="left-sync"></span> packages and dependencies waiting for sync</td>
|
||||
<td><span id="percent-sync"></span>% progress</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span id="success-sync"></span> packages and dependencies sync successed</td>
|
||||
<td><span id="fail-sync"></span> packages and dependencies sync failed</td>
|
||||
<td>last success: <span id="last-success-name"></span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script src="/js/readme.js"></script>
|
||||
|
||||
<h2>Version Badge</h2>
|
||||
<p>Default style is <code>flat-square</code>.</p>
|
||||
<p>Badge URL: <code>https://cnpmjs.org/badge/v/cnpmjs.org.svg</code> <img src="//cnpmjs.org/badge/v/cnpmjs.org.svg" alt="cnpmjs.org-badge"></p>
|
||||
<ul>
|
||||
<li><code><0.1.0 & >=0.0.0</code>: <img src="https://img.shields.io/badge/cnpm-0.0.1-red.svg?style=flat-square" alt="red-badge"></li>
|
||||
<li><code><1.0.0 & >=0.1.0</code>: <img src="https://img.shields.io/badge/cnpm-0.1.0-green.svg?style=flat-square" alt="red-badge"></li>
|
||||
<li><code>>=1.0.0</code>: <img src="https://img.shields.io/badge/cnpm-1.0.0-blue.svg?style=flat-square" alt="red-badge"></li>
|
||||
</ul>
|
||||
|
||||
<h2>Usage</h2>
|
||||
<p>use our npm client <a href="https://github.com/cnpm/cnpm">cnpm</a>(More suitable with cnpmjs.org and gzip support), you can get our client through npm:</p>
|
||||
<pre><code class="language-bash">$ npm install -g cnpm --registry=https://r.cnpmjs.org
|
||||
</code></pre>
|
||||
<p>Or you can alias NPM to use it:</p>
|
||||
<pre><code class="language-bash">alias cnpm="npm --registry=https://r.cnpmjs.org \
|
||||
--cache=$HOME/.npm/.cache/cnpm \
|
||||
--disturl=https://cnpmjs.org/mirrors/node \
|
||||
--userconfig=$HOME/.cnpmrc"
|
||||
|
||||
#Or alias it in .bashrc or .zshrc
|
||||
$ echo '\n#alias for cnpm\nalias cnpm="npm --registry=https://r.cnpmjs.org \
|
||||
--cache=$HOME/.npm/.cache/cnpm \
|
||||
--disturl=https://cnpmjs.org/mirrors/node \
|
||||
--userconfig=$HOME/.cnpmrc"' >> ~/.zshrc && source ~/.zshrc
|
||||
</code></pre>
|
||||
|
||||
<h3>install</h3>
|
||||
<p>Install package from <a href="//r.cnpmjs.org">r.cnpmjs.org</a>. When installing a package or version does not exist, it will try to install from the official registry(<a href="//registry.npmjs.org">registry.npmjs.org</a>), and sync this package to cnpm in the backend.</p>
|
||||
<pre><code class="language-bash">$ cnpm install [name]
|
||||
</code></pre>
|
||||
|
||||
<h3>sync</h3>
|
||||
<p>Only <code>cnpm</code> cli has this command. Meaning sync package from source npm.</p>
|
||||
<pre><code class="language-bash">$ cnpm sync connect
|
||||
</code></pre>
|
||||
<p>sync package on web: <a href="/sync/connect">sync/connect</a></p>
|
||||
<pre><code class="language-bash">$ open https://cnpmjs.org/sync/connect
|
||||
</code></pre>
|
||||
|
||||
<h3>publish / unpublish</h3>
|
||||
<p>Only <code>admin</code> user can publish / unpublish package to private registry.</p>
|
||||
<pre><code class="language-bash">$ cnpm publish [name]
|
||||
$ cnpm unpublish [name]
|
||||
</code></pre>
|
||||
|
||||
<h3>Other commands</h3>
|
||||
<p>Support all the other npm commands. e.g.:</p>
|
||||
<pre><code class="language-bash">$ cnpm info cnpm
|
||||
</code></pre>
|
||||
|
||||
<h2>TODO list</h2>
|
||||
<p>@see Github <a href="https://github.com/cnpm/cnpmjs.org/issues">Issues</a></p>
|
||||
|
||||
<h2>Histories</h2>
|
||||
<p>Release <a href="/history">History</a>.</p>
|
||||
|
||||
<h2>npm and cnpm relation</h2>
|
||||
<p><img src="https://dn-cnpm.qbox.me/cnpm-npm-relation.png" alt="npm&cnpm"></p>
|
||||
|
||||
<h2>Sponsors</h2>
|
||||
<ul>
|
||||
<li><a href="http://www.ucloud.cn/sdk?sem=sdk-CNPMJS"><img src="https://www.ucloud.cn/www/img/www/logo.png" alt="UCloud云计算"></a></li>
|
||||
</ul>
|
||||
Reference in New Issue
Block a user