Compare commits
132 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
214d0ad5c3 | ||
|
|
ca70c8a06d | ||
|
|
1c680367a7 | ||
|
|
3bd43d5ba9 | ||
|
|
0965f8f8e5 | ||
|
|
005eb603ae | ||
|
|
65a9303dff | ||
|
|
3bc6b625ec | ||
|
|
2b0dc6d17f | ||
|
|
842d790dcb | ||
|
|
20eac48349 | ||
|
|
efb80e8c33 | ||
|
|
35fbc651cd | ||
|
|
e55779ffa7 | ||
|
|
878176ea9c | ||
|
|
e3a2eab000 | ||
|
|
7478846754 | ||
|
|
8b244e6c26 | ||
|
|
19217de010 | ||
|
|
93a57b5dae | ||
|
|
defb447f29 | ||
|
|
93b73de164 | ||
|
|
ffc6124c0e | ||
|
|
ab40a992c2 | ||
|
|
5258569044 | ||
|
|
04d8055d56 | ||
|
|
68b6d54f60 | ||
|
|
a950a1e44b | ||
|
|
22f5472dbe | ||
|
|
d6d37a623d | ||
|
|
757184fbc8 | ||
|
|
043fa2c32a | ||
|
|
f94f5ca714 | ||
|
|
788bfc68bc | ||
|
|
dacc39c1d9 | ||
|
|
3fb2228031 | ||
|
|
4535178fa9 | ||
|
|
42e9e1603f | ||
|
|
9a0c3c6c62 | ||
|
|
ba864a62bf | ||
|
|
6dbfe18f58 | ||
|
|
d8c65ff1f3 | ||
|
|
426990f94e | ||
|
|
6d57929e89 | ||
|
|
2b51171592 | ||
|
|
701c9ffa5f | ||
|
|
4260b1c2b6 | ||
|
|
5e926f658d | ||
|
|
78e13bb1d3 | ||
|
|
9e5ec3406d | ||
|
|
21804d277b | ||
|
|
95d1a6b35c | ||
|
|
78395d48b4 | ||
|
|
c6795f201f | ||
|
|
8e7a362bc2 | ||
|
|
7ff3e9d017 | ||
|
|
902b0bb638 | ||
|
|
8097352a6c | ||
|
|
ecf902b73e | ||
|
|
bb0ace7e23 | ||
|
|
d964b11b8c | ||
|
|
53fa67f3bf | ||
|
|
adf7ece3e9 | ||
|
|
02d5b4d16b | ||
|
|
67f8e64140 | ||
|
|
45ceb17238 | ||
|
|
a1ee99618c | ||
|
|
de854a76f1 | ||
|
|
d59ebb44be | ||
|
|
5a2ac54c73 | ||
|
|
8fd8bae5aa | ||
|
|
5929b9b1ea | ||
|
|
aae14f1a6e | ||
|
|
96ad637882 | ||
|
|
73aa9129a8 | ||
|
|
1c89a6f6f9 | ||
|
|
c2beb96dda | ||
|
|
4c4fc3fc7f | ||
|
|
82395fdc33 | ||
|
|
ced4887269 | ||
|
|
8f96a5a57b | ||
|
|
f6e79ff5e7 | ||
|
|
e932f16424 | ||
|
|
622c93c3fe | ||
|
|
ccf3e8a83c | ||
|
|
2069b4334c | ||
|
|
ef84cedd79 | ||
|
|
ba07f87ee0 | ||
|
|
10cbe70378 | ||
|
|
244ce60857 | ||
|
|
97a4f6cd92 | ||
|
|
10197ef2aa | ||
|
|
d2e7350b27 | ||
|
|
9a4a7c6bf0 | ||
|
|
550024176f | ||
|
|
90485d33dd | ||
|
|
02d9bd923e | ||
|
|
a256e044c5 | ||
|
|
a194fc8f3c | ||
|
|
0f61c71e2b | ||
|
|
2acfc52057 | ||
|
|
e144506634 | ||
|
|
cc9b547c86 | ||
|
|
e8bea69a4d | ||
|
|
cd36984a56 | ||
|
|
ec00eeee75 | ||
|
|
571aea5277 | ||
|
|
9e9fd84e12 | ||
|
|
dbe0f96855 | ||
|
|
66f17619e6 | ||
|
|
1d491a244b | ||
|
|
bbb6a59441 | ||
|
|
76e0563308 | ||
|
|
5e969cc305 | ||
|
|
9d886b0599 | ||
|
|
cd2e96f460 | ||
|
|
f86734674d | ||
|
|
e2c37d312f | ||
|
|
689e7e1c08 | ||
|
|
cd6f78d91b | ||
|
|
b832c91d21 | ||
|
|
646c830a68 | ||
|
|
e543f8578b | ||
|
|
5ff7e2867f | ||
|
|
98e8e7d498 | ||
|
|
b7eb9f8374 | ||
|
|
12a8eff1f6 | ||
|
|
9156be88a9 | ||
|
|
cebbf7dda2 | ||
|
|
ea226e8ad6 | ||
|
|
eb3b79cae2 | ||
|
|
49b70b4b4d |
@@ -1,10 +1,9 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
node_js:
|
||||
- '1'
|
||||
- '2'
|
||||
- '3'
|
||||
- '4'
|
||||
- '5'
|
||||
addons:
|
||||
- postgresql: '9.3'
|
||||
script: 'make test-travis-all'
|
||||
|
||||
2
AUTHORS
2
AUTHORS
@@ -5,3 +5,5 @@ 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)
|
||||
afc163 <afc163@gmail.com> (https://github.com/afc163)
|
||||
Yuwei Ba <i@xiaoba.me> (https://github.com/ibigbug)
|
||||
|
||||
|
||||
102
History.md
102
History.md
@@ -1,4 +1,106 @@
|
||||
|
||||
2.6.0 / 2016-01-12
|
||||
==================
|
||||
|
||||
* feat(sync): monitor sync status
|
||||
* chore(package): update agentkeepalive to version 2.0.3
|
||||
* fix SequelizeDatabaseError: ER_NO_SUCH_TABLE: Table 'qnpm.total' doesn't exist\nreproduce this bug:\nthe first startup of cnpmjs.org
|
||||
* chore(package): update moment to version 2.11.0
|
||||
* chore(package): update xss to version 0.2.10
|
||||
* chore(package): update pg-hstore to version 2.3.2
|
||||
* chore(package): update mini-logger to version 1.1.0
|
||||
* chore(package): update urllib to version 2.6.0
|
||||
* fix: row.package will json parse error
|
||||
* remove bluebird
|
||||
* chore(package): update utility to version 1.6.0
|
||||
|
||||
2.5.1 / 2015-12-02
|
||||
==================
|
||||
|
||||
* chore(package): update bluebird to version 3.0.6
|
||||
* fix: SequelizeDatabaseError
|
||||
* fix(dist_tag): disable delete latest tag
|
||||
* feat: count total private pkgs
|
||||
* fix: use isoweek. a week start from monday
|
||||
* chore(package): update xss to version 0.2.8
|
||||
* chore(package): update semver to version 5.1.0
|
||||
|
||||
2.5.0 / 2015-11-17
|
||||
==================
|
||||
|
||||
* test: add node v5
|
||||
* feat(sync): sync deleted user
|
||||
* Update show.js
|
||||
* chore(package): update bytes to version 2.2.0
|
||||
* do not sync inner username
|
||||
* gzip static file
|
||||
* chore(package): update bytes to version 2.1.0
|
||||
* chore(package): update is-type-of to version 1.0.0
|
||||
* Update static.js
|
||||
* chore(package): update cfork to version 1.4.0
|
||||
* chore(package): update bluebird to version 3.0.5
|
||||
|
||||
2.4.1 / 2015-10-27
|
||||
==================
|
||||
|
||||
* fix: improve registry index page performance with cache
|
||||
* Configable badge URL prefix.
|
||||
* chore(package): update koa-mock to version 1.5.0
|
||||
* chore(package): update urllib to version 2.5.0
|
||||
* chore(package): update co to version 4.6.0
|
||||
* chore(package): update semver to version 5.0.3
|
||||
|
||||
2.4.0 / 2015-10-21
|
||||
==================
|
||||
|
||||
* feat(registry): add package's dependents api
|
||||
* fix: show package's dependents
|
||||
* chore(package): update utility to version 1.5.0
|
||||
* chore(package): update bluebird to version 2.10.2
|
||||
|
||||
2.3.1 / 2015-10-15
|
||||
==================
|
||||
|
||||
* refactor: remove gnode
|
||||
* deps: upgrade giturl
|
||||
* Some fixes
|
||||
|
||||
2.3.0 / 2015-10-15
|
||||
==================
|
||||
|
||||
* Add dev dependencies.
|
||||
* Package page fix.
|
||||
* refactor: add more sync log
|
||||
* Add mock data.
|
||||
* refactor: add more sync log
|
||||
* Fix sidebar overflow.
|
||||
* Merge pull request #680 from ibigbug/ant-design
|
||||
* Clean code.
|
||||
* Indent.
|
||||
* chore(package): update debug to version 2.2.0
|
||||
* chore(package): update should to version 7.1.0
|
||||
* chore(package): update koa to version 1.1.0
|
||||
* Remove default adBanner.
|
||||
* Package pages.
|
||||
* Common styles.
|
||||
* search page.
|
||||
* Sync page.
|
||||
* Profile page antd style.
|
||||
* Unpublished pkg page style.
|
||||
* Add page title for unpubed pkg.
|
||||
* Index page style use antd.
|
||||
* chore(package): update pg to version 4.4.2
|
||||
* chore(package): update cfork to version 1.3.1
|
||||
* chore(package): update moment to version 2.10.6
|
||||
* feat(badge): Use qiniu cdn
|
||||
|
||||
2.2.1 / 2015-09-30
|
||||
==================
|
||||
|
||||
* test: use istanbul
|
||||
* pref: move out try/catch block
|
||||
* fix: support nfs.url is generator
|
||||
|
||||
2.2.0 / 2015-09-29
|
||||
==================
|
||||
|
||||
|
||||
9
Makefile
9
Makefile
@@ -22,7 +22,7 @@ jshint: install
|
||||
@-node_modules/.bin/jshint ./
|
||||
|
||||
init-database:
|
||||
@$(BIN) --harmony test/init_db.js
|
||||
@$(BIN) test/init_db.js
|
||||
|
||||
init-mysql:
|
||||
@mysql -uroot -e 'DROP DATABASE IF EXISTS cnpmjs_test;'
|
||||
@@ -34,7 +34,6 @@ init-pg:
|
||||
|
||||
test: install init-database
|
||||
@NODE_ENV=test DB=${DB} node_modules/.bin/mocha \
|
||||
--harmony \
|
||||
--reporter $(REPORTER) \
|
||||
--timeout $(TIMEOUT) \
|
||||
--require should \
|
||||
@@ -56,7 +55,7 @@ test-pg: init-pg
|
||||
test-all: test-sqlite test-mysql
|
||||
|
||||
test-cov cov: install init-database
|
||||
@NODE_ENV=test DB=${DB} $(BIN) --harmony \
|
||||
@NODE_ENV=test DB=${DB} $(BIN) \
|
||||
node_modules/.bin/istanbul cover --preserve-comments \
|
||||
node_modules/.bin/_mocha \
|
||||
-- -u exports \
|
||||
@@ -77,7 +76,7 @@ test-cov-mysql: init-mysql
|
||||
|
||||
test-travis: install init-database
|
||||
@NODE_ENV=test DB=${DB} CNPM_SOURCE_NPM=http://registry.npmjs.com CNPM_SOURCE_NPM_ISCNPM=false \
|
||||
$(BIN) --harmony \
|
||||
$(BIN) \
|
||||
node_modules/.bin/istanbul cover --preserve-comments \
|
||||
node_modules/.bin/_mocha \
|
||||
-- -u exports \
|
||||
@@ -113,7 +112,7 @@ autod: install
|
||||
@node_modules/.bin/autod -w \
|
||||
--prefix "~" \
|
||||
--exclude public,view,docs,backup,coverage \
|
||||
--dep bluebird,mysql \
|
||||
--dep mysql \
|
||||
--keep should,supertest,should-http,chunkstream,mm,pedding
|
||||
@$(MAKE) install
|
||||
|
||||
|
||||
13
bin/cli.js
13
bin/cli.js
@@ -1,9 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**!
|
||||
* cnpmjs.org - bin/cli.js
|
||||
*
|
||||
* Copyright(c) fengmk2 and other contributors.
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
@@ -16,7 +14,6 @@
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
require('gnode');
|
||||
var debug = require('debug')('cnpmjs.org:cli');
|
||||
var program = require('commander');
|
||||
var path = require('path');
|
||||
@@ -86,9 +83,10 @@ function start(options) {
|
||||
debug('save config %s to %s', configJSON, configfile);
|
||||
|
||||
// if sqlite db file not exists, init first
|
||||
initDatabase();
|
||||
initDatabase(function() {
|
||||
require('../dispatch');
|
||||
});
|
||||
|
||||
require('../dispatch');
|
||||
fs.writeFileSync(path.join(dataDir, 'pid'), process.pid + '');
|
||||
}
|
||||
|
||||
@@ -108,7 +106,7 @@ function stop(options) {
|
||||
}
|
||||
}
|
||||
|
||||
function initDatabase() {
|
||||
function initDatabase(callback) {
|
||||
var models = require('../models');
|
||||
|
||||
models.sequelize.sync({ force: false })
|
||||
@@ -120,6 +118,7 @@ function initDatabase() {
|
||||
throw err;
|
||||
} else {
|
||||
console.log('[models/init_script.js] `sqlite` sequelize sync and init success');
|
||||
callback();
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ export NODE_ENV='production'
|
||||
ulimit -c unlimited
|
||||
|
||||
cd `dirname $0`/..
|
||||
NODEJS='node --harmony'
|
||||
NODEJS='node'
|
||||
BASE_HOME=`pwd`
|
||||
PROJECT_NAME=`basename ${BASE_HOME}`
|
||||
STDOUT_LOG=`$NODEJS -e "console.log(require('path').join(require('$BASE_HOME/config').logdir, 'nodejs_stdout.log'));\
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
/*!
|
||||
* cnpmjs.org - common/nfs.js
|
||||
*
|
||||
* Copyright(c) cnpmjs.org and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
@@ -174,12 +174,12 @@ var config = {
|
||||
// cnpm wont directly sync from this one
|
||||
// but sometimes will request it for some package infomations
|
||||
// please don't change it if not necessary
|
||||
officialNpmRegistry: 'https://registry.npmjs.org',
|
||||
officialNpmRegistry: 'https://registry.npmjs.com',
|
||||
|
||||
// sync source, upstream registry
|
||||
// If you want to directly sync from official npm's registry
|
||||
// please drop them an email first
|
||||
sourceNpmRegistry: 'http://registry.npm.taobao.org',
|
||||
sourceNpmRegistry: 'https://registry.npm.taobao.org',
|
||||
|
||||
// upstream registry is base on cnpm/cnpmjs.org or not
|
||||
// if your upstream is official npm registry, please turn it off
|
||||
@@ -210,6 +210,7 @@ var config = {
|
||||
syncDevDependencies: false,
|
||||
|
||||
// badge subject on http://shields.io/
|
||||
badgePrefixURL: 'https://img.shields.io/badge',
|
||||
badgeSubject: 'cnpm',
|
||||
|
||||
// custom user service, @see https://github.com/cnpm/cnpmjs.org/wiki/Use-Your-Own-User-Authorization
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
/**!
|
||||
* cnpmjs.org - controllers/registry/package/dist_tag.js
|
||||
*
|
||||
* Copyright(c) fengmk2 and other contributors.
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -25,7 +23,7 @@ function ok() {
|
||||
// GET /-/package/:pkg/dist-tags -- returns the package's dist-tags
|
||||
exports.index = function* () {
|
||||
var name = this.params.name || this.params[0];
|
||||
var rows = yield* packageService.listModuleTags(name);
|
||||
var rows = yield packageService.listModuleTags(name);
|
||||
var tags = {};
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
var row = rows[i];
|
||||
@@ -79,6 +77,14 @@ exports.set = function* () {
|
||||
exports.destroy = function* () {
|
||||
var name = this.params.name || this.params[0];
|
||||
var tag = this.params.tag || this.params[1];
|
||||
if (tag === 'latest') {
|
||||
this.status = 400;
|
||||
this.body = {
|
||||
error: 'dist_tag_error',
|
||||
reason: 'Can\'t not delete latest tag',
|
||||
};
|
||||
return;
|
||||
}
|
||||
yield packageService.removeModuleTagsByNames(name, tag);
|
||||
this.body = ok();
|
||||
};
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
/**!
|
||||
* cnpmjs.org - controllers/registry/package/download.js
|
||||
*
|
||||
* Copyright(c) fengmk2 and other contributors.
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -18,6 +16,7 @@ var debug = require('debug')('cnpmjs.org:controllers:registry:download');
|
||||
var mime = require('mime');
|
||||
var utility = require('utility');
|
||||
var defer = require('co-defer');
|
||||
var is = require('is-type-of');
|
||||
var nfs = require('../../../common/nfs');
|
||||
var logger = require('../../../common/logger');
|
||||
var common = require('../../../lib/common');
|
||||
@@ -32,12 +31,16 @@ module.exports = function* download(next) {
|
||||
var name = this.params.name || this.params[0];
|
||||
var filename = this.params.filename || this.params[1];
|
||||
var version = filename.slice(name.length + 1, -4);
|
||||
var row = yield* packageService.getModule(name, version);
|
||||
var row = yield packageService.getModule(name, version);
|
||||
// can not get dist
|
||||
var url = null;
|
||||
|
||||
if (typeof nfs.url === 'function') {
|
||||
url = nfs.url(common.getCDNKey(name, filename));
|
||||
if (is.generatorFunction(nfs.url)) {
|
||||
url = yield nfs.url(common.getCDNKey(name, filename));
|
||||
} else {
|
||||
url = nfs.url(common.getCDNKey(name, filename));
|
||||
}
|
||||
}
|
||||
|
||||
debug('download %s %s %s %s', name, filename, version, url);
|
||||
@@ -78,7 +81,7 @@ module.exports = function* download(next) {
|
||||
this.attachment(filename);
|
||||
this.etag = dist.shasum;
|
||||
|
||||
this.body = yield* downloadAsReadStream(dist.key);
|
||||
this.body = yield downloadAsReadStream(dist.key);
|
||||
};
|
||||
|
||||
defer.setInterval(function* () {
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
/**!
|
||||
* cnpmjs.org - controllers/registry/package/list.js
|
||||
*
|
||||
* Copyright(c) fengmk2 and other contributors.
|
||||
/**
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -130,6 +128,10 @@ module.exports = function* list() {
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
var row = rows[i];
|
||||
var pkg = row.package;
|
||||
// pkg is string ... ignore it
|
||||
if (typeof pkg === 'string') {
|
||||
continue;
|
||||
}
|
||||
common.setDownloadURL(pkg, this);
|
||||
pkg._cnpm_publish_time = row.publish_time;
|
||||
versions[pkg.version] = pkg;
|
||||
|
||||
26
controllers/registry/package/list_dependents.js
Normal file
26
controllers/registry/package/list_dependents.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**!
|
||||
* list package's dependents
|
||||
*
|
||||
* Copyright(c) cnpmjs.org and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* fengmk2 <m@fengmk2.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
const packageService = require('../../../services/package');
|
||||
|
||||
module.exports = function*() {
|
||||
const name = this.params.name || this.params[0];
|
||||
const dependents = yield packageService.listDependents(name);
|
||||
|
||||
this.body = {
|
||||
dependents: dependents,
|
||||
};
|
||||
};
|
||||
@@ -1,11 +1,9 @@
|
||||
/**!
|
||||
* cnpmjs.org - controllers/registry/package/list_shorts.js
|
||||
*
|
||||
* Copyright(c) fengmk2 and other contributors.
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -19,5 +17,5 @@ var packageService = require('../../../services/package');
|
||||
// GET /-/short
|
||||
// List all packages names only
|
||||
module.exports = function* () {
|
||||
this.body = yield* packageService.listAllPublicModuleNames();
|
||||
this.body = yield packageService.listAllPublicModuleNames();
|
||||
};
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
/**!
|
||||
* cnpmjs.js - controllers/registry/package/show.js
|
||||
*
|
||||
* Copyright(c) fengmk2 and other contributors.
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
@@ -60,8 +60,13 @@ exports.sync = function* () {
|
||||
};
|
||||
|
||||
exports.getSyncLog = function* (next) {
|
||||
var logId = this.params.id || this.params[1];
|
||||
var logId = Number(this.params.id || this.params[1]);
|
||||
var offset = Number(this.query.offset) || 0;
|
||||
|
||||
if (!logId) { // NaN
|
||||
this.status = 404;
|
||||
return;
|
||||
}
|
||||
var row = yield* Log.get(logId);
|
||||
if (!row) {
|
||||
return yield* next;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/**!
|
||||
* cnpmjs.org - controllers/sync_module_worker.js
|
||||
*
|
||||
* Copyright(c) cnpmjs.org and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
@@ -15,7 +13,7 @@
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var debug = require('debug')('cnpmjs.org:proxy:sync_module_worker');
|
||||
var debug = require('debug')('cnpmjs.org:sync_module_worker');
|
||||
var co = require('co');
|
||||
var gather = require('co-gather');
|
||||
var defer = require('co-defer');
|
||||
@@ -385,11 +383,21 @@ function* _listStarUsers(modName) {
|
||||
}
|
||||
|
||||
function* _saveNpmUser(username) {
|
||||
var user = yield* npmSerivce.getUser(username);
|
||||
var user = yield npmSerivce.getUser(username);
|
||||
if (!user) {
|
||||
return;
|
||||
var existsUser = yield User.findByName(username);
|
||||
if (existsUser && existsUser.isNpmUser) {
|
||||
// delete it
|
||||
yield User.destroy({
|
||||
where: {
|
||||
name: username,
|
||||
}
|
||||
});
|
||||
return { exists: true, deleted: true, isNpmUser: true };
|
||||
}
|
||||
return { exists: false };
|
||||
}
|
||||
yield* User.saveNpmUser(user);
|
||||
yield User.saveNpmUser(user);
|
||||
return user;
|
||||
}
|
||||
|
||||
@@ -679,7 +687,7 @@ SyncModuleWorker.prototype._sync = function* (name, pkg) {
|
||||
that.log(' [%s] %d versions: %j need to deleted',
|
||||
name, deletedVersionNames.length, deletedVersionNames);
|
||||
try {
|
||||
yield* packageService.removeModulesByNameAndVersions(name, deletedVersionNames);
|
||||
yield packageService.removeModulesByNameAndVersions(name, deletedVersionNames);
|
||||
} catch (err) {
|
||||
that.log(' [%s] delete error, %s: %s', name, err.name, err.message);
|
||||
}
|
||||
@@ -874,6 +882,7 @@ SyncModuleWorker.prototype._sync = function* (name, pkg) {
|
||||
};
|
||||
|
||||
SyncModuleWorker.prototype._syncOneVersion = function *(versionIndex, sourcePackage) {
|
||||
logger.syncInfo('[sync_module_worker] start sync %s@%s', sourcePackage.name, sourcePackage.version);
|
||||
var that = this;
|
||||
var username = this.username;
|
||||
var downurl = sourcePackage.dist.tarball;
|
||||
@@ -930,6 +939,7 @@ SyncModuleWorker.prototype._syncOneVersion = function *(versionIndex, sourcePack
|
||||
|
||||
try {
|
||||
// get tarball
|
||||
logger.syncInfo('[sync_module_worker] downloading %j to %j', downurl, filepath);
|
||||
var r = yield urllib.request(downurl, options);
|
||||
var statusCode = r.status || -1;
|
||||
// https://github.com/cnpm/cnpmjs.org/issues/325
|
||||
@@ -980,8 +990,17 @@ SyncModuleWorker.prototype._syncOneVersion = function *(versionIndex, sourcePack
|
||||
};
|
||||
// upload to NFS
|
||||
logger.syncInfo('[sync_module_worker] uploading %j to nfs', options);
|
||||
var result = yield nfs.upload(filepath, options);
|
||||
return yield *afterUpload(result);
|
||||
var result;
|
||||
try {
|
||||
result = yield nfs.upload(filepath, options);
|
||||
} catch (err) {
|
||||
logger.syncInfo('[sync_module_worker] upload %j to nfs error: %s', err);
|
||||
throw err;
|
||||
}
|
||||
logger.syncInfo('[sync_module_worker] uploaded, saving %j to database', result);
|
||||
var r = yield *afterUpload(result);
|
||||
logger.syncInfo('[sync_module_worker] sync %s@%s done!', sourcePackage.name, sourcePackage.version);
|
||||
return r;
|
||||
} finally {
|
||||
// remove tmp file whatever
|
||||
fs.unlink(filepath, utility.noop);
|
||||
@@ -1040,7 +1059,7 @@ SyncModuleWorker.prototype._syncOneVersion = function *(versionIndex, sourcePack
|
||||
|
||||
SyncModuleWorker.sync = function* (name, username, options) {
|
||||
options = options || {};
|
||||
var result = yield* logService.create({name: name, username: username});
|
||||
var result = yield logService.create({name: name, username: username});
|
||||
var worker = new SyncModuleWorker({
|
||||
logId: result.id,
|
||||
type: options.type,
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
/**!
|
||||
* cnpmjs.org - controllers/total.js
|
||||
*
|
||||
* Copyright(c) cnpmjs.org and other contributors.
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
|
||||
* dead_horse <dead_horse@qq.com> (http://deadhorse.me)
|
||||
*/
|
||||
|
||||
@@ -15,17 +13,24 @@
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Total = require('../services/total');
|
||||
var version = require('../package.json').version;
|
||||
var config = require('../config');
|
||||
var getDownloadTotal = require('./utils').getDownloadTotal;
|
||||
const Total = require('../services/total');
|
||||
const version = require('../package.json').version;
|
||||
const config = require('../config');
|
||||
const getDownloadTotal = require('./utils').getDownloadTotal;
|
||||
|
||||
var startTime = '' + Date.now();
|
||||
const startTime = '' + Date.now();
|
||||
let cache = null;
|
||||
|
||||
module.exports = function* showTotal() {
|
||||
var r = yield [Total.get(), getDownloadTotal()];
|
||||
var total = r[0];
|
||||
var download = r[1];
|
||||
if (cache && Date.now() - cache.cache_time < 10000) {
|
||||
// cache 10 seconds
|
||||
this.body = cache;
|
||||
return;
|
||||
}
|
||||
|
||||
const r = yield [Total.get(), getDownloadTotal()];
|
||||
const total = r[0];
|
||||
const download = r[1];
|
||||
|
||||
total.download = download;
|
||||
total.db_name = 'registry';
|
||||
@@ -35,5 +40,8 @@ module.exports = function* showTotal() {
|
||||
total.donate = 'https://www.gittip.com/fengmk2';
|
||||
total.sync_model = config.syncModel;
|
||||
|
||||
cache = total;
|
||||
total.cache_time = Date.now();
|
||||
|
||||
this.body = total;
|
||||
};
|
||||
|
||||
@@ -56,11 +56,11 @@ exports.getDownloadTotal = function* (name) {
|
||||
var end = moment();
|
||||
var start = end.clone().subtract(1, 'months').startOf('month');
|
||||
var lastday = end.clone().subtract(1, 'days').format('YYYY-MM-DD');
|
||||
var lastweekStart = end.clone().subtract(1, 'weeks').startOf('week');
|
||||
var lastweekEnd = lastweekStart.clone().endOf('week').format('YYYY-MM-DD');
|
||||
var lastweekStart = end.clone().subtract(1, 'weeks').startOf('isoweek');
|
||||
var lastweekEnd = lastweekStart.clone().endOf('isoweek').format('YYYY-MM-DD');
|
||||
var lastmonthEnd = start.clone().endOf('month').format('YYYY-MM-DD');
|
||||
var thismonthStart = end.clone().startOf('month').format('YYYY-MM-DD');
|
||||
var thisweekStart = end.clone().startOf('week').format('YYYY-MM-DD');
|
||||
var thisweekStart = end.clone().startOf('isoweek').format('YYYY-MM-DD');
|
||||
start = start.format('YYYY-MM-DD');
|
||||
end = end.format('YYYY-MM-DD');
|
||||
lastweekStart = lastweekStart.format('YYYY-MM-DD');
|
||||
|
||||
@@ -46,17 +46,17 @@ exports.version = function* () {
|
||||
}
|
||||
version = version.replace(/\-/g, '--');
|
||||
var style = this.query.style || 'flat-square';
|
||||
var url = util.format('https://img.shields.io/badge/%s-%s-%s.svg?style=%s',
|
||||
var url = util.format(config.badgePrefixURL + '/%s-%s-%s.svg?style=%s',
|
||||
utility.encodeURIComponent(subject), version, color, utility.encodeURIComponent(style));
|
||||
this.redirect(url);
|
||||
};
|
||||
|
||||
exports.downloads = function* () {
|
||||
// https://img.shields.io/badge/downloads-100k/month-brightgreen.svg?style=flat-square
|
||||
// https://dn-img-shields-io.qbox.me/badge/downloads-100k/month-brightgreen.svg?style=flat-square
|
||||
var name = this.params[0];
|
||||
var count = yield DownloadTotal.getTotalByName(name);
|
||||
var style = this.query.style || 'flat-square';
|
||||
var url = util.format('https://img.shields.io/badge/downloads-%s-brightgreen.svg?style=%s',
|
||||
var url = util.format(config.badgePrefixURL + '/downloads-%s-brightgreen.svg?style=%s',
|
||||
count, utility.encodeURIComponent(style));
|
||||
this.redirect(url);
|
||||
};
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
/**!
|
||||
* cnpmjs.org - controllers/web/package/show.js
|
||||
*
|
||||
* Copyright(c) cnpmjs.org and other contributors.
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* dead_horse <dead_horse@qq.com> (http://deadhorse.me)
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -68,7 +66,8 @@ module.exports = function* show(next) {
|
||||
}
|
||||
}
|
||||
yield this.render('package_unpublished', {
|
||||
package: data
|
||||
package: data,
|
||||
title: 'Package - ' + name
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -178,7 +177,7 @@ module.exports = function* show(next) {
|
||||
pkg.engines[k] = {
|
||||
version: engine,
|
||||
title: k + ': ' + engine,
|
||||
badgeURL: 'https://img.shields.io/badge/' + encodeURIComponent(k) +
|
||||
badgeURL: config.badgePrefixURL + '/' + encodeURIComponent(k) +
|
||||
'-' + encodeURIComponent(engine) + '-' + color + '.svg?style=flat-square',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@ module.exports = function* showUser(next) {
|
||||
var data = {
|
||||
name: name,
|
||||
email: user.email,
|
||||
json: user.json || {}
|
||||
json: user.json || {},
|
||||
isNpmUser: user.isNpmUser,
|
||||
};
|
||||
|
||||
if (data.json.login) {
|
||||
|
||||
@@ -9,6 +9,7 @@ So `cnpm` is meaning: **Company npm**.
|
||||
- [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/)。
|
||||
|
||||
<div class="ant-table">
|
||||
<table class="downloads">
|
||||
<tbody>
|
||||
<tr>
|
||||
@@ -28,12 +29,17 @@ So `cnpm` is meaning: **Company npm**.
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<div class="ant-alert ant-alert-info syncing">
|
||||
<span class="anticon ant-alert-icon anticon-info-circle"></span>
|
||||
<span class="ant-alert-description">The sync worker is working in the backend now. </span>
|
||||
</div>
|
||||
<div class="ant-table">
|
||||
<table class="sync-status">
|
||||
<tbody>
|
||||
<tr>
|
||||
@@ -48,6 +54,7 @@ So `cnpm` is meaning: **Company npm**.
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/js/readme.js"></script>
|
||||
@@ -60,9 +67,9 @@ Default style is `flat-square`.
|
||||
|
||||
Badge URL: `http://cnpmjs.org/badge/v/cnpmjs.org.svg` 
|
||||
|
||||
* `<0.1.0 & >=0.0.0`: 
|
||||
* `<1.0.0 & >=0.1.0`: 
|
||||
* `>=1.0.0`: 
|
||||
* `<0.1.0 & >=0.0.0`: 
|
||||
* `<1.0.0 & >=0.1.0`: 
|
||||
* `>=1.0.0`: 
|
||||
|
||||
### Downloads
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
/**!
|
||||
* cnpmjs.org - middleware/exists_package.js
|
||||
*
|
||||
* Copyright(c) fengmk2 and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
@@ -23,7 +23,8 @@ var staticDir = path.join(path.dirname(__dirname), 'public');
|
||||
module.exports = middlewares.staticCache(staticDir, {
|
||||
buffer: config.debug ? false : true,
|
||||
maxAge: config.debug ? 0 : 60 * 60 * 24 * 7,
|
||||
alas: {
|
||||
alias: {
|
||||
'/favicon.ico': '/favicon.png'
|
||||
}
|
||||
},
|
||||
gzip: config.enableCompress,
|
||||
});
|
||||
|
||||
47
package.json
47
package.json
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "cnpmjs.org",
|
||||
"version": "2.2.0",
|
||||
"version": "2.6.0",
|
||||
"description": "Private npm registry and web for Enterprise, base on MySQL and Simple Store Service",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "make install && make jshint && make test",
|
||||
"test": "make jshint && make test",
|
||||
"start": "./bin/nodejsctl start && cp History.md docs/web/history.md",
|
||||
"status": "./bin/nodejsctl status",
|
||||
"stop": "./bin/nodejsctl stop"
|
||||
@@ -13,62 +13,61 @@
|
||||
"cnpmjs.org": "bin/cli.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"agentkeepalive": "~1.2.0",
|
||||
"bluebird": "~2.9.7",
|
||||
"bytes": "~1.0.0",
|
||||
"cfork": "~1.2.2",
|
||||
"co": "~4.3.1",
|
||||
"agentkeepalive": "~2.0.3",
|
||||
"bytes": "~2.2.0",
|
||||
"cfork": "~1.4.0",
|
||||
"co": "~4.6.0",
|
||||
"co-defer": "~1.0.0",
|
||||
"co-gather": "~0.0.1",
|
||||
"co-sleep": "~0.0.1",
|
||||
"commander": "~2.6.0",
|
||||
"copy-to": "~2.0.1",
|
||||
"debug": "~2.1.1",
|
||||
"debug": "~2.2.0",
|
||||
"error-formater": "~1.0.3",
|
||||
"fs-cnpm": "~1.2.0",
|
||||
"giturl": "~0.0.3",
|
||||
"gnode": "~0.1.1",
|
||||
"giturl": "^1.0.0",
|
||||
"graceful": "~1.0.0",
|
||||
"gravatar": "~1.1.0",
|
||||
"humanize-ms": "~1.0.1",
|
||||
"humanize-number": "~0.0.2",
|
||||
"is-type-of": "~1.0.0",
|
||||
"kcors": "~1.0.1",
|
||||
"koa": "~0.17.0",
|
||||
"koa": "~1.1.0",
|
||||
"koa-limit": "~1.0.2",
|
||||
"koa-markdown": "~2.0.1",
|
||||
"koa-middlewares": "~2.1.0",
|
||||
"koa-mock": "~1.1.4",
|
||||
"koa-mock": "~1.5.0",
|
||||
"koa-safe-jsonp": "~0.3.0",
|
||||
"markdown-it": "~3.0.6",
|
||||
"mime": "~1.3.4",
|
||||
"mini-logger": "~1.0.0",
|
||||
"mini-logger": "~1.1.0",
|
||||
"mkdirp": "~0.5.0",
|
||||
"moment": "~2.9.0",
|
||||
"moment": "~2.11.0",
|
||||
"mysql": "~2.5.4",
|
||||
"nodemailer": "~1.3.0",
|
||||
"semver": "~4.2.0",
|
||||
"semver": "~5.1.0",
|
||||
"sequelize": "~2.0.1",
|
||||
"thunkify-wrap": "~1.0.4",
|
||||
"treekill": "~1.0.0",
|
||||
"tunnel-agent": "^0.4.0",
|
||||
"urllib": "~2.2.2",
|
||||
"utility": "~1.3.0",
|
||||
"xss": "~0.1.20"
|
||||
"urllib": "~2.6.0",
|
||||
"utility": "~1.6.0",
|
||||
"xss": "~0.2.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"autod": "*",
|
||||
"chunkstream": "*",
|
||||
"co-mocha": "*",
|
||||
"contributors": "*",
|
||||
"istanbul-harmony": "*",
|
||||
"istanbul": "*",
|
||||
"jshint": "*",
|
||||
"mm": "*",
|
||||
"mocha": "*",
|
||||
"node-dev": "*",
|
||||
"pedding": "*",
|
||||
"pg": "~4.2.0",
|
||||
"pg-hstore": "~2.3.1",
|
||||
"should": "~4.0.4",
|
||||
"pg": "~4.4.2",
|
||||
"pg-hstore": "~2.3.2",
|
||||
"should": "~7.1.0",
|
||||
"should-http": "*",
|
||||
"sqlite3": "*",
|
||||
"supertest": "*"
|
||||
@@ -91,10 +90,10 @@
|
||||
"registry"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 1.0.0"
|
||||
"node": ">= 2.0.0"
|
||||
},
|
||||
"author": [
|
||||
"fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)",
|
||||
"fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)",
|
||||
"dead_horse <dead_horse@qq.com> (http://deadhorse.me)"
|
||||
],
|
||||
"license": "MIT"
|
||||
|
||||
1
public/css/antd-0.9.1.min.css
vendored
Normal file
1
public/css/antd-0.9.1.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -1,28 +1,140 @@
|
||||
body {
|
||||
font-size: 16px;
|
||||
color: #333333;
|
||||
}
|
||||
header {
|
||||
max-width: 1140px;
|
||||
min-width: 960px;
|
||||
margin: 30px auto 30px auto;
|
||||
|
||||
.mb15 {
|
||||
margin-bottom: 15px !important;
|
||||
}
|
||||
header .logo {
|
||||
|
||||
.container {
|
||||
min-width: 960px;;
|
||||
padding-right: 15px;
|
||||
padding-left: 15px;
|
||||
margin-right: auto;
|
||||
margin-left: auto
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.container {
|
||||
width:750px
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 992px) {
|
||||
.container {
|
||||
width:970px
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1200px) {
|
||||
.container {
|
||||
width:1170px
|
||||
}
|
||||
}
|
||||
|
||||
hr {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
border: 0;
|
||||
border-top: 1px solid #eee;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
#header {
|
||||
padding: 30px 0;
|
||||
height: 156px;
|
||||
}
|
||||
|
||||
#header .logo {
|
||||
display: inline-block;
|
||||
}
|
||||
header #search-input {
|
||||
|
||||
#header .logo a {
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#search-input {
|
||||
display: inline-block;
|
||||
width: 400px;
|
||||
height: 50px;
|
||||
font-size: 30px;
|
||||
font-size: 20px;
|
||||
float: right;
|
||||
margin-top: 22px;
|
||||
border-radius: 8px;
|
||||
padding: 10px 20px;
|
||||
transition: width .3s ease-in-out;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
#search-input {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.pack-overview-background {
|
||||
min-width: 960px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#search .package.match {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.bottom {
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
|
||||
code {
|
||||
padding: 2px 4px;
|
||||
font-size: 95%;
|
||||
color: #c7254e;
|
||||
background-color: #f9f2f4;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
img {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
pre {
|
||||
margin-bottom: 20px;
|
||||
background: #333;
|
||||
color: #fff;
|
||||
border-radius: 6px;
|
||||
margin-top: 30px;
|
||||
padding: 10px 20px;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
pre code {
|
||||
padding: 0;
|
||||
font-size: inherit;
|
||||
color: inherit;
|
||||
white-space: pre-wrap;
|
||||
background-color: transparent;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.ant-table {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.ant-alert {
|
||||
font-size: 14px !important;
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
|
||||
.pack-overview {
|
||||
min-width: 960px;
|
||||
color: #f1f1f1;
|
||||
height: 300px;
|
||||
width: 100%;
|
||||
margin-bottom: 50px;
|
||||
position: relative;
|
||||
}
|
||||
.pack-overview-background {
|
||||
height: 300px;
|
||||
@@ -34,13 +146,18 @@ header #search-input {
|
||||
}
|
||||
.pack-overview a {
|
||||
color: #f1f1f1;
|
||||
text-decoration: underline;
|
||||
text-decoration: none;
|
||||
font-size: 16px;
|
||||
transition: all .2s ease-in-out;
|
||||
padding-bottom: 2px;
|
||||
border-bottom: 1px solid;
|
||||
}
|
||||
.pack-overview a:hover {
|
||||
color: #ffffff;
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.pack-info {
|
||||
position: relative;
|
||||
max-width: 1140px;
|
||||
margin: 0 auto;
|
||||
padding: 30px 0;
|
||||
@@ -53,133 +170,125 @@ header #search-input {
|
||||
line-height: 48px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.pack-description {
|
||||
line-height: 28px;
|
||||
text-overflow: ellipsis;
|
||||
color: #fff;
|
||||
font-family: "-apple-system", sans-serif;
|
||||
margin-top: 20px;
|
||||
display: block; /* Fallback for non-webkit */
|
||||
display: -webkit-box;
|
||||
width: 600px;
|
||||
white-space:nowrap;
|
||||
font-size: 20px;
|
||||
line-height: 26px;
|
||||
-webkit-line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
overflow:hidden;
|
||||
max-height: 100px;
|
||||
}
|
||||
.deprecated {
|
||||
text-decoration: line-through;
|
||||
color: #BDBDBD;
|
||||
}
|
||||
.deprecated-content {
|
||||
color: #FF8A65;
|
||||
color: #555;
|
||||
width: 600px;
|
||||
white-space:nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow:hidden;
|
||||
font-style: italic;
|
||||
}
|
||||
.pack-ver {
|
||||
font-size: 28px;
|
||||
line-height: 48px;
|
||||
}
|
||||
.pack-repo {
|
||||
margin-top: 50px;
|
||||
.pack-lastup {
|
||||
font-size: 14px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.pack-repo {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
text-align: right;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pack-repo a {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.pack-repo a:hover {
|
||||
border-bottom: 1px solid;
|
||||
}
|
||||
|
||||
.pack-install {
|
||||
position: absolute;
|
||||
top: 85px;
|
||||
top: 75px;
|
||||
right: 0px;
|
||||
max-width: 450px;
|
||||
}
|
||||
.pack-install pre {
|
||||
border: none;
|
||||
background-color: #666666;
|
||||
color: #f1f1f1;
|
||||
font-size: 16px;
|
||||
width: 480px;
|
||||
}
|
||||
.pack-details {
|
||||
max-width: 1140px;
|
||||
min-width: 960px;
|
||||
margin: 40px auto;
|
||||
}
|
||||
|
||||
|
||||
.pack-details a {
|
||||
color: #333333;
|
||||
}
|
||||
.cols-box {
|
||||
display: flex;
|
||||
-webkit-box-pack: center;
|
||||
|
||||
.pack-details a:hover {
|
||||
border-bottom: 1px solid;
|
||||
opacity: .8;
|
||||
}
|
||||
|
||||
.cols-box ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.cols-box-item {
|
||||
flex: 1;
|
||||
height: 250px;
|
||||
margin-right: 30px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.cols-box-item:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.cols-box-title {
|
||||
font-size: 20px;
|
||||
color: #428bca;
|
||||
margin-bottom: 10px;
|
||||
font-weight: bold;
|
||||
overflow: hidden;
|
||||
border-bottom: 1px solid #ccc;
|
||||
padding-bottom: 3px;
|
||||
}
|
||||
.cols-box-item .more-item {
|
||||
font-size: 16px;
|
||||
line-height: 28px;
|
||||
color: #428bca;
|
||||
text-decoration: underline;
|
||||
float: right;
|
||||
margin-top: 15px;
|
||||
}
|
||||
.pack-dep-ver, .pack-download-num {
|
||||
float: right;
|
||||
}
|
||||
.pack-lastup, .pack-sync {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.pack-sync a {
|
||||
font-size: 23px;
|
||||
}
|
||||
.maintainers .row {
|
||||
display: -moz-box;
|
||||
display: -webkit-box;
|
||||
display: box;
|
||||
-webkit-box-pack: center;
|
||||
margin-right: 0;
|
||||
margin-left: 0;
|
||||
float: left;
|
||||
}
|
||||
|
||||
|
||||
.maintainer {
|
||||
-moz-box-flex: 1;
|
||||
-webkit-box-flex: 1;
|
||||
box-flex: 1;
|
||||
margin-bottom: 10px;
|
||||
width: 50%;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-box-pack: center;
|
||||
line-height: 50px;
|
||||
line-height: 30px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.maintainer a:hover {
|
||||
font-style: italic;
|
||||
border: none;
|
||||
}
|
||||
.maintainer .avatar {
|
||||
-webkit-border-radius: 50px;
|
||||
-moz-border-radius: 50px;
|
||||
border-radius: 50px;
|
||||
border-radius: 30px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.downloads .row {
|
||||
margin-left: 0;
|
||||
margin-right: 50px;
|
||||
line-height: 28px;
|
||||
border-bottom: 1px solid #f2f2f2;
|
||||
}
|
||||
.pack-readme {
|
||||
max-width: 1140px;
|
||||
min-width: 960px;
|
||||
margin: 10px auto;
|
||||
border-top: 1px solid #dddddd;
|
||||
}
|
||||
.pack-readme .title {
|
||||
color: #dddddd;
|
||||
font-weight: bolder;
|
||||
margin-bottom: 20px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
147
public/css/yue.css
Normal file
147
public/css/yue.css
Normal file
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* yue.css
|
||||
*
|
||||
* yue.css is designed for readable content.
|
||||
*
|
||||
* Copyright (c) 2013 - 2014 by Hsiaoming Yang.
|
||||
*/
|
||||
|
||||
|
||||
.yue h1,
|
||||
.yue h2,
|
||||
.yue h3,
|
||||
.yue h4,
|
||||
.yue h5,
|
||||
.yue h6 {
|
||||
font-family: "-apple-system-headline", "Georgia", "Xin Gothic", "Hiragino Sans GB", "Droid Sans Fallback", "Microsoft YaHei", "SimSun", sans-serif;
|
||||
color: #222223;
|
||||
}
|
||||
|
||||
.yue h1 {
|
||||
font-size: 1.8em;
|
||||
margin: 0.67em 0;
|
||||
}
|
||||
|
||||
.yue > h1 {
|
||||
margin-top: 0;
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
.yue h2 {
|
||||
font-size: 1.5em;
|
||||
margin: 0.83em 0;
|
||||
}
|
||||
|
||||
.yue h3 {
|
||||
font-size: 1.17em;
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
.yue h4,
|
||||
.yue h5,
|
||||
.yue h6 {
|
||||
font-size: 1em;
|
||||
margin: 1.6em 0 1em 0;
|
||||
}
|
||||
|
||||
.yue h6 {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.yue p {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1.46em;
|
||||
}
|
||||
|
||||
|
||||
.yue strong,
|
||||
.yue b {
|
||||
font-weight: 700;
|
||||
color: #222223;
|
||||
}
|
||||
|
||||
.yue em,
|
||||
.yue i {
|
||||
font-style: italic;
|
||||
color: #222223;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.yue hr {
|
||||
display: block;
|
||||
width: 14%;
|
||||
margin: 40px auto 34px;
|
||||
border: 0 none;
|
||||
border-top: 3px solid #dededc;
|
||||
}
|
||||
|
||||
.yue blockquote {
|
||||
margin: 0 0 1.64em 0;
|
||||
border-left: 3px solid #dadada;
|
||||
padding-left: 12px;
|
||||
color: #666664;
|
||||
}
|
||||
|
||||
.yue blockquote a {
|
||||
color: #666664;
|
||||
}
|
||||
|
||||
.yue ul,
|
||||
.yue ol {
|
||||
margin: 0 0 24px 6px;
|
||||
padding-left: 16px;
|
||||
}
|
||||
|
||||
.yue ul {
|
||||
list-style-type: square;
|
||||
}
|
||||
|
||||
.yue ol {
|
||||
list-style-type: decimal;
|
||||
}
|
||||
|
||||
.yue li {
|
||||
margin-bottom: 0.2em;
|
||||
}
|
||||
|
||||
.yue li ul,
|
||||
.yue li ol {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
margin-left: 14px;
|
||||
}
|
||||
|
||||
.yue li ul {
|
||||
list-style-type: disc;
|
||||
}
|
||||
|
||||
.yue li ul ul {
|
||||
list-style-type: circle;
|
||||
}
|
||||
|
||||
.yue li p {
|
||||
margin: 0.4em 0 0.6em;
|
||||
}
|
||||
|
||||
.yue .unstyled {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@media (min-width: 1100px) {
|
||||
.yue blockquote {
|
||||
margin-left: -24px;
|
||||
padding-left: 20px;
|
||||
border-width: 4px;
|
||||
}
|
||||
|
||||
.yue blockquote blockquote {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ $(function () {
|
||||
data.last_sync_module + '</a>');
|
||||
|
||||
if (!data.sync_status) {
|
||||
$('.syncing').html('');
|
||||
$('.syncing').remove();
|
||||
}
|
||||
|
||||
$('.sync').show();
|
||||
|
||||
@@ -26,6 +26,7 @@ var listAll = require('../controllers/registry/package/list_all');
|
||||
var listShorts = require('../controllers/registry/package/list_shorts');
|
||||
var listSince = require('../controllers/registry/package/list_since');
|
||||
var listAllVersions = require('../controllers/registry/package/list');
|
||||
var listDependents = require('../controllers/registry/package/list_dependents');
|
||||
var getOneVersion = require('../controllers/registry/package/show');
|
||||
var savePackage = require('../controllers/registry/package/save');
|
||||
var tag = require('../controllers/registry/package/tag');
|
||||
@@ -118,6 +119,10 @@ function routes(app) {
|
||||
app.get('/downloads/range/:range/:name', downloadTotal);
|
||||
app.get('/downloads/range/:range', downloadTotal);
|
||||
|
||||
// GET /-/package/:pkg/dependents
|
||||
app.get('/-/package/:name/dependents', existsPackage, listDependents);
|
||||
app.get(/^\/\-\/package\/(@[\w\-\.]+\/[\w\-\.]+)\/dependents$/, existsPackage, listDependents);
|
||||
|
||||
// GET /-/package/:pkg/dist-tags -- returns the package's dist-tags
|
||||
app.get('/-/package/:name/dist-tags', existsPackage, tags.index);
|
||||
app.get(/^\/\-\/package\/(@[\w\-\.]+\/[\w\-\.]+)\/dist\-tags$/, existsPackage, tags.index);
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
global.Promise = require('bluebird');
|
||||
var koa = require('koa');
|
||||
var app = module.exports = koa();
|
||||
var http = require('http');
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
global.Promise = require('bluebird');
|
||||
var opensearch = require('../middleware/opensearch');
|
||||
var notFound = require('../middleware/web_not_found');
|
||||
var staticCache = require('../middleware/static');
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
/**!
|
||||
* cnpmjs.org - services/download_total.js
|
||||
*
|
||||
* Copyright(c) fengmk2 and other contributors.
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -103,7 +101,7 @@ exports.plusModuleTotal = function* (data) {
|
||||
};
|
||||
|
||||
exports.getTotal = function* (start, end) {
|
||||
return yield* exports.getModuleTotal('__all__', start, end);
|
||||
return yield exports.getModuleTotal('__all__', start, end);
|
||||
};
|
||||
|
||||
function parseYearMonth(date) {
|
||||
|
||||
@@ -50,5 +50,5 @@ exports.append = function* (id, log) {
|
||||
};
|
||||
|
||||
exports.get = function* (id) {
|
||||
return yield ModuleLog.find(Number(id));
|
||||
return yield ModuleLog.find(id);
|
||||
};
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
/**!
|
||||
* cnpmjs.org - services/package.js
|
||||
*
|
||||
* Copyright(c) fengmk2 and other contributors.
|
||||
/**
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -27,20 +25,23 @@ var ModuleUnpublished = models.ModuleUnpublished;
|
||||
var NpmModuleMaintainer = models.NpmModuleMaintainer;
|
||||
|
||||
// module
|
||||
var _parseRow = function (row) {
|
||||
if (row.package.indexOf('%7B%22') === 0) {
|
||||
// now store package will encodeURIComponent() after JSON.stringify
|
||||
row.package = decodeURIComponent(row.package);
|
||||
}
|
||||
row.package = JSON.parse(row.package);
|
||||
if (typeof row.publish_time === 'string') {
|
||||
// pg bigint is string
|
||||
row.publish_time = Number(row.publish_time);
|
||||
}
|
||||
};
|
||||
|
||||
// module:read
|
||||
function parseRow(row) {
|
||||
if (row && row.package) {
|
||||
try {
|
||||
if (row.package.indexOf('%7B%22') === 0) {
|
||||
// now store package will encodeURIComponent() after JSON.stringify
|
||||
row.package = decodeURIComponent(row.package);
|
||||
}
|
||||
row.package = JSON.parse(row.package);
|
||||
if (typeof row.publish_time === 'string') {
|
||||
// pg bigint is string
|
||||
row.publish_time = Number(row.publish_time);
|
||||
}
|
||||
_parseRow(row);
|
||||
} catch (e) {
|
||||
console.warn('parse package error: %s, id: %s version: %s, error: %s', row.name, row.id, row.version, e);
|
||||
}
|
||||
@@ -232,10 +233,11 @@ exports.listModulesByName = function* (moduleName) {
|
||||
},
|
||||
order: [ ['id', 'DESC'] ]
|
||||
});
|
||||
return mods.map(function (mod) {
|
||||
|
||||
for (var mod of mods) {
|
||||
parseRow(mod);
|
||||
return mod;
|
||||
});
|
||||
}
|
||||
return mods;
|
||||
};
|
||||
|
||||
exports.getModuleLastModified = function* (name) {
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
/**!
|
||||
* cnpmjs.org - services/total.js
|
||||
*
|
||||
* Copyright(c) fengmk2 and other contributors.
|
||||
/**
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
/**!
|
||||
* cnpmjs.org - sync/index.js
|
||||
*
|
||||
* Copyright(c) cnpmjs.org and other contributors.
|
||||
/**
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* dead_horse <dead_horse@qq.com> (http://deadhorse.me)
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -14,7 +13,6 @@
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
global.Promise = require('bluebird');
|
||||
var debug = require('debug')('cnpmjs.org:sync:index');
|
||||
var co = require('co');
|
||||
var ms = require('humanize-ms');
|
||||
@@ -49,7 +47,8 @@ function onerror(err) {
|
||||
|
||||
//set sync_status = 0 at first
|
||||
co(function* () {
|
||||
yield* totalService.updateSyncStatus(0);
|
||||
yield totalService.updateSyncStatus(0);
|
||||
yield checkSyncStatus();
|
||||
}).catch(onerror);
|
||||
|
||||
var syncInterval = ms(config.syncInterval);
|
||||
@@ -68,7 +67,7 @@ var syncFn = co.wrap(function* () {
|
||||
var data;
|
||||
var error;
|
||||
try {
|
||||
data = yield* sync();
|
||||
data = yield sync();
|
||||
} catch (err) {
|
||||
error = err;
|
||||
error.message += ' (sync package error)';
|
||||
@@ -80,6 +79,9 @@ var syncFn = co.wrap(function* () {
|
||||
}
|
||||
syncing = false;
|
||||
}
|
||||
|
||||
// check last_sync_time and last_exist_sync_time
|
||||
yield checkSyncStatus();
|
||||
});
|
||||
|
||||
if (sync) {
|
||||
@@ -104,7 +106,7 @@ var syncPopularFn = co.wrap(function* syncPopular() {
|
||||
var data;
|
||||
var error;
|
||||
try {
|
||||
data = yield* startSyncPopular();
|
||||
data = yield startSyncPopular();
|
||||
} catch (err) {
|
||||
error = err;
|
||||
error.message += ' (sync package error)';
|
||||
@@ -174,3 +176,23 @@ function sendMailToAdmin(err, result, syncTime) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function* checkSyncStatus() {
|
||||
var total = yield totalService.getTotalInfo();
|
||||
var lastSyncTime;
|
||||
if (config.syncModel === 'all') {
|
||||
lastSyncTime = total.last_sync_time;
|
||||
} else if (config.syncModel === 'exist') {
|
||||
lastSyncTime = total.last_exist_sync_time;
|
||||
}
|
||||
debug('checkSyncStatus start, lastSyncTime: %s, syncInterval: %s', lastSyncTime, syncInterval);
|
||||
if (!lastSyncTime) {
|
||||
return;
|
||||
}
|
||||
var diff = Date.now() - lastSyncTime;
|
||||
if (diff > syncInterval * 2) {
|
||||
var err = new Error('Last sync time is expired in ' + diff + ' ms, lastSyncTime: ' + new Date(lastSyncTime));
|
||||
err.name = 'SyncExpriedError';
|
||||
sendMailToAdmin(err, null, new Date());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,6 +170,18 @@ describe('controllers/registry/package/dist_tag.test.js', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should not destroy latest tag', function(done) {
|
||||
request(app.listen())
|
||||
.delete('/-/package/@cnpmtest/dist_tag_test_module_destroy/dist-tags/latest')
|
||||
.set('authorization', utils.otherUserAuth)
|
||||
.set('content-type', 'application/json')
|
||||
.expect({
|
||||
error: 'dist_tag_error',
|
||||
reason: 'Can\'t not delete latest tag',
|
||||
})
|
||||
.expect(400, done);
|
||||
});
|
||||
|
||||
it('should 404 destroy not exists tag', function (done) {
|
||||
request(app.listen())
|
||||
.delete('/-/package/@cnpmtest/dist_tag_test_module_destroy/dist-tags/not-exists')
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
/**!
|
||||
* cnpmjs.org - test/controllers/registry/package/download.test.js
|
||||
*
|
||||
* Copyright(c) fengmk2 and other contributors.
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -15,36 +13,66 @@
|
||||
*/
|
||||
|
||||
var request = require('supertest');
|
||||
var mm = require('mm');
|
||||
var config = require('../../../../config');
|
||||
var app = require('../../../../servers/registry');
|
||||
var utils = require('../../../utils');
|
||||
|
||||
describe('controllers/registry/package/download.test.js', function () {
|
||||
describe('test/controllers/registry/package/download.test.js', function () {
|
||||
before(function (done) {
|
||||
var pkg = utils.getPackage('@cnpmtest/download-test-module', '1.0.0', utils.admin);
|
||||
request(app.listen())
|
||||
request(app)
|
||||
.put('/' + pkg.name)
|
||||
.set('authorization', utils.adminAuth)
|
||||
.send(pkg)
|
||||
.expect(201, done);
|
||||
});
|
||||
|
||||
afterEach(mm.restore);
|
||||
|
||||
describe('GET /:name/download/:filename', function () {
|
||||
it('should download a file with 200', function (done) {
|
||||
request(app.listen())
|
||||
request(app)
|
||||
.get('/@cnpmtest/download-test-module/download/@cnpmtest/download-test-module-1.0.0.tgz')
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
it('should alias /:name/-/:filename to /:name/download/:filename', function (done) {
|
||||
request(app.listen())
|
||||
request(app)
|
||||
.get('/@cnpmtest/download-test-module/-/@cnpmtest/download-test-module-1.0.0.tgz')
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
it('should 404 when package not exists', function (done) {
|
||||
request(app.listen())
|
||||
request(app)
|
||||
.get('/@cnpmtest/download-test-module-not-exists/download/@cnpmtest/download-test-module-not-exists-1.0.0.tgz')
|
||||
.expect(404, done);
|
||||
});
|
||||
|
||||
describe('nfs.url is function', function() {
|
||||
it('should work with nfs.url is generatorFunction', function(done) {
|
||||
mm(config.nfs, 'url', function*(key) {
|
||||
return 'http://foo.test.com' + key;
|
||||
});
|
||||
mm(config, 'downloadRedirectToNFS', true);
|
||||
|
||||
request(app)
|
||||
.get('/@cnpmtest/download-test-module/-/@cnpmtest/download-test-module-1.0.0.tgz')
|
||||
.expect('Location', 'http://foo.test.com/@cnpmtest/download-test-module/-/@cnpmtest/download-test-module-1.0.0.tgz')
|
||||
.expect(302, done);
|
||||
});
|
||||
|
||||
it('should work with nfs.url is function', function(done) {
|
||||
mm(config.nfs, 'url', function(key) {
|
||||
return 'http://foo.test.com' + key;
|
||||
});
|
||||
mm(config, 'downloadRedirectToNFS', true);
|
||||
|
||||
request(app)
|
||||
.get('/@cnpmtest/download-test-module/-/@cnpmtest/download-test-module-1.0.0.tgz')
|
||||
.expect('Location', 'http://foo.test.com/@cnpmtest/download-test-module/-/@cnpmtest/download-test-module-1.0.0.tgz')
|
||||
.expect(302, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
54
test/controllers/registry/package/list_dependents.test.js
Normal file
54
test/controllers/registry/package/list_dependents.test.js
Normal file
@@ -0,0 +1,54 @@
|
||||
/**!
|
||||
* Copyright(c) cnpm and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
const pedding = require('pedding');
|
||||
const request = require('supertest');
|
||||
const mm = require('mm');
|
||||
const app = require('../../../../servers/registry');
|
||||
const utils = require('../../../utils');
|
||||
|
||||
describe('test/controllers/registry/package/list_dependents.test.js', function () {
|
||||
afterEach(mm.restore);
|
||||
|
||||
before(function (done) {
|
||||
done = pedding(2, done);
|
||||
const pkg = utils.getPackage('@cnpmtest/testmodule-list-dependents1', '1.0.0', utils.admin);
|
||||
pkg.versions['1.0.0'].dependencies = {
|
||||
'@cnpmtest/testmodule-list-dependents2': '~1.0.0',
|
||||
};
|
||||
request(app.listen())
|
||||
.put('/' + pkg.name)
|
||||
.set('authorization', utils.adminAuth)
|
||||
.send(pkg)
|
||||
.expect(201, done);
|
||||
|
||||
const pkg2 = utils.getPackage('@cnpmtest/testmodule-list-dependents2', '1.0.0', utils.admin);
|
||||
request(app.listen())
|
||||
.put('/' + pkg2.name)
|
||||
.set('authorization', utils.adminAuth)
|
||||
.send(pkg2)
|
||||
.expect(201, done);
|
||||
});
|
||||
|
||||
it('should list package dependents', function (done) {
|
||||
request(app)
|
||||
.get('/-/package/@cnpmtest/testmodule-list-dependents2/dependents')
|
||||
.expect({
|
||||
dependents: [
|
||||
'@cnpmtest/testmodule-list-dependents1',
|
||||
],
|
||||
})
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
@@ -1,11 +1,9 @@
|
||||
/**!
|
||||
* cnpmjs.org - test/controllers/registry/package/save.test.js
|
||||
*
|
||||
* Copyright(c) cnpmjs.org and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
* Authors:
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
|
||||
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -22,7 +20,7 @@ var app = require('../../../../servers/registry');
|
||||
var config = require('../../../../config');
|
||||
var utils = require('../../../utils');
|
||||
|
||||
describe('controllers/registry/package/save.test.js', function () {
|
||||
describe('test/controllers/registry/package/save.test.js', function () {
|
||||
afterEach(mm.restore);
|
||||
|
||||
describe('no @scoped package', function () {
|
||||
@@ -288,11 +286,11 @@ describe('controllers/registry/package/save.test.js', function () {
|
||||
});
|
||||
|
||||
it('should save dependents', function* () {
|
||||
var names = yield* packageService.listDependents('bytetest2');
|
||||
var names = yield packageService.listDependents('bytetest2');
|
||||
names.should.length(2);
|
||||
names.should.eql(['@cnpmtest/testmodule-new-1', '@cnpmtest/testmodule-new-2']);
|
||||
|
||||
names = yield* packageService.listDependents('@cnpmtest/testmodule-new-1');
|
||||
names = yield packageService.listDependents('@cnpmtest/testmodule-new-1');
|
||||
names.should.length(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -123,6 +123,12 @@ describe('controllers/sync.test.js', function () {
|
||||
.get('/sync/pedding/log/123123123')
|
||||
.expect(404, done);
|
||||
});
|
||||
|
||||
it('should 404 when log id not number', function (done) {
|
||||
request(webApp.listen())
|
||||
.get('/sync/pedding/log/info.php')
|
||||
.expect(404, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('scope package', function () {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/**!
|
||||
* cnpmjs.org - test/controllers/sync_module_worker.test.js
|
||||
*
|
||||
* Copyright(c) cnpmjs.org and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
@@ -14,6 +12,7 @@
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var should = require('should');
|
||||
var mm = require('mm');
|
||||
var thunkify = require('thunkify-wrap');
|
||||
var request = require('supertest');
|
||||
@@ -24,6 +23,7 @@ var logService = require('../../services/module_log');
|
||||
var packageService = require('../../services/package');
|
||||
var utils = require('../utils');
|
||||
var app = require('../../servers/registry');
|
||||
var User = require('../../models').User;
|
||||
|
||||
describe('test/controllers/sync_module_worker.test.js', function () {
|
||||
afterEach(mm.restore);
|
||||
@@ -299,5 +299,64 @@ describe('test/controllers/sync_module_worker.test.js', function () {
|
||||
var end = thunkify.event(worker, 'end');
|
||||
yield end();
|
||||
});
|
||||
|
||||
describe('sync deleted user', function() {
|
||||
before(function*() {
|
||||
var user = {
|
||||
name: 'notexistsuserscnpmtest',
|
||||
email: 'notexistsuserscnpmtest@gmail.com',
|
||||
};
|
||||
yield User.saveNpmUser(user);
|
||||
|
||||
var user = {
|
||||
name: 'existsuserscnpmtest',
|
||||
email: 'existsuserscnpmtest@gmail.com',
|
||||
password_sha: '0',
|
||||
salt: '0',
|
||||
ip: '127.0.0.1',
|
||||
};
|
||||
yield User.add(user);
|
||||
});
|
||||
|
||||
it('should not delete when cnpm user exists', function*() {
|
||||
var worker = new SyncModuleWorker({
|
||||
type: 'user',
|
||||
name: 'existsuserscnpmtest',
|
||||
username: 'fengmk2',
|
||||
});
|
||||
worker.start();
|
||||
var end = thunkify.event(worker, 'end');
|
||||
yield end();
|
||||
var user = yield User.findByName('existsuserscnpmtest');
|
||||
should.exists(user);
|
||||
user.name.should.equal('existsuserscnpmtest');
|
||||
});
|
||||
|
||||
it('should delete when user exists', function*() {
|
||||
var worker = new SyncModuleWorker({
|
||||
type: 'user',
|
||||
name: 'notexistsuserscnpmtest',
|
||||
username: 'fengmk2',
|
||||
});
|
||||
worker.start();
|
||||
var end = thunkify.event(worker, 'end');
|
||||
yield end();
|
||||
var user = yield User.findByName('notexistsuserscnpmtest');
|
||||
should.not.exists(user);
|
||||
});
|
||||
|
||||
it('should not delete when user not exists', function*() {
|
||||
var worker = new SyncModuleWorker({
|
||||
type: 'user',
|
||||
name: 'notexistsuserscnpmtest',
|
||||
username: 'fengmk2',
|
||||
});
|
||||
worker.start();
|
||||
var end = thunkify.event(worker, 'end');
|
||||
yield end();
|
||||
var user = yield User.findByName('notexistsuserscnpmtest');
|
||||
should.not.exists(user);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ var should = require('should');
|
||||
var request = require('supertest');
|
||||
var app = require('../../servers/registry');
|
||||
|
||||
describe('controllers/total.test.js', function () {
|
||||
describe('test/controllers/total.test.js', function () {
|
||||
describe('GET / in registry', function () {
|
||||
it('should return total info', function (done) {
|
||||
request(app.listen())
|
||||
@@ -29,7 +29,14 @@ describe('controllers/total.test.js', function () {
|
||||
res.body.db_name.should.equal('registry');
|
||||
res.body.store_engine.should.be.a.String;
|
||||
res.body.node_version.should.equal(process.version);
|
||||
done();
|
||||
res.body.cache_time.should.be.a.Number;
|
||||
// request again should get cache total info
|
||||
request(app.listen())
|
||||
.get('/')
|
||||
.expect(function(res2) {
|
||||
res2.body.cache_time.should.equal(res.body.cache_time);
|
||||
})
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ var mm = require('mm');
|
||||
var app = require('../../../servers/web');
|
||||
var registry = require('../../../servers/registry');
|
||||
var utils = require('../../utils');
|
||||
var config = require('../../../config')
|
||||
|
||||
describe('controllers/web/badge.test.js', function () {
|
||||
afterEach(mm.restore);
|
||||
@@ -35,7 +36,7 @@ describe('controllers/web/badge.test.js', function () {
|
||||
should.not.exists(err);
|
||||
request(app)
|
||||
.get('/badge/v/@cnpmtest/badge-test-module.svg?style=flat-square')
|
||||
.expect('Location', 'https://img.shields.io/badge/cnpm-1.0.1-blue.svg?style=flat-square')
|
||||
.expect('Location', config.badgePrefixURL + '/cnpm-1.0.1-blue.svg?style=flat-square')
|
||||
.expect(302, done);
|
||||
});
|
||||
});
|
||||
@@ -50,7 +51,7 @@ describe('controllers/web/badge.test.js', function () {
|
||||
should.not.exists(err);
|
||||
request(app)
|
||||
.get('/badge/v/@cnpmtest/badge-test-module.svg?style=flat-square&tag=v2')
|
||||
.expect('Location', 'https://img.shields.io/badge/cnpm-2.0.1-blue.svg?style=flat-square')
|
||||
.expect('Location', config.badgePrefixURL + '/cnpm-2.0.1-blue.svg?style=flat-square')
|
||||
.expect(302, done);
|
||||
});
|
||||
});
|
||||
@@ -65,7 +66,7 @@ describe('controllers/web/badge.test.js', function () {
|
||||
should.not.exists(err);
|
||||
request(app)
|
||||
.get('/badge/v/@cnpmtest/badge-test-module.svg?style=flat-square&tag=v3&subject=ant-design')
|
||||
.expect('Location', 'https://img.shields.io/badge/ant--design-3.0.1-blue.svg?style=flat-square')
|
||||
.expect('Location', config.badgePrefixURL + '/ant--design-3.0.1-blue.svg?style=flat-square')
|
||||
.expect(302, done);
|
||||
});
|
||||
});
|
||||
@@ -80,7 +81,7 @@ describe('controllers/web/badge.test.js', function () {
|
||||
should.not.exists(err);
|
||||
request(app)
|
||||
.get('/badge/v/@cnpmtest/badge-test-module.svg?style=flat-square')
|
||||
.expect('Location', 'https://img.shields.io/badge/cnpm-1.0.0--beta1-blue.svg?style=flat-square')
|
||||
.expect('Location', config.badgePrefixURL + '/cnpm-1.0.0--beta1-blue.svg?style=flat-square')
|
||||
.expect(302, done);
|
||||
});
|
||||
});
|
||||
@@ -95,7 +96,7 @@ describe('controllers/web/badge.test.js', function () {
|
||||
should.not.exists(err);
|
||||
request(app)
|
||||
.get('/badge/v/@cnpmtest/badge-test-module.svg?style=flat-square')
|
||||
.expect('Location', 'https://img.shields.io/badge/cnpm-0.1.0-green.svg?style=flat-square')
|
||||
.expect('Location', config.badgePrefixURL + '/cnpm-0.1.0-green.svg?style=flat-square')
|
||||
.expect(302, done);
|
||||
});
|
||||
});
|
||||
@@ -110,7 +111,7 @@ describe('controllers/web/badge.test.js', function () {
|
||||
should.not.exists(err);
|
||||
request(app)
|
||||
.get('/badge/v/@cnpmtest/badge-test-module.svg?style=flat-square')
|
||||
.expect('Location', 'https://img.shields.io/badge/cnpm-0.0.0-red.svg?style=flat-square')
|
||||
.expect('Location', config.badgePrefixURL + '/cnpm-0.0.0-red.svg?style=flat-square')
|
||||
.expect(302, done);
|
||||
});
|
||||
});
|
||||
@@ -118,7 +119,7 @@ describe('controllers/web/badge.test.js', function () {
|
||||
it('should show invalid when package not exists', function (done) {
|
||||
request(app)
|
||||
.get('/badge/v/@cnpmtest/badge-test-module-not-exists.svg?style=flat')
|
||||
.expect('Location', 'https://img.shields.io/badge/cnpm-invalid-lightgrey.svg?style=flat')
|
||||
.expect('Location', config.badgePrefixURL + '/cnpm-invalid-lightgrey.svg?style=flat')
|
||||
.expect(302, done);
|
||||
});
|
||||
});
|
||||
@@ -134,7 +135,7 @@ describe('controllers/web/badge.test.js', function () {
|
||||
should.not.exists(err);
|
||||
request(app)
|
||||
.get('/badge/d/@cnpmtest/badge-download-module.svg?style=flat-square')
|
||||
.expect('Location', 'https://img.shields.io/badge/downloads-0-brightgreen.svg?style=flat-square')
|
||||
.expect('Location', config.badgePrefixURL + '/downloads-0-brightgreen.svg?style=flat-square')
|
||||
.expect(302, done);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
var config = require('../../../../config')
|
||||
module.exports = {
|
||||
title: 'Package - koa',
|
||||
package: {
|
||||
@@ -9,7 +10,7 @@ module.exports = {
|
||||
node: {
|
||||
version: '>= 0.11.13',
|
||||
title: 'node: >=0.11.13',
|
||||
badgeURL: 'https://img.shields.io/badge/node-%3E%3D%200.11.13-red.svg?style=flat-square',
|
||||
badgeURL: config.badgePrefixURL + '/badge/node-%3E%3D%200.11.13-red.svg?style=flat-square',
|
||||
}
|
||||
},
|
||||
_publish_on_cnpm: false,
|
||||
@@ -60,6 +61,10 @@ module.exports = {
|
||||
supertest: '~0.13.0',
|
||||
'test-console': '^0.7.1'
|
||||
},
|
||||
dependents: [
|
||||
'cnpmjs.org',
|
||||
'koa-project',
|
||||
],
|
||||
maintainers: [
|
||||
{
|
||||
name: 'fengmk2',
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
module.exports = {
|
||||
package: {
|
||||
name: 'inch-plugin-socket-behaviour-desktop',
|
||||
description: description()
|
||||
},
|
||||
__requires: ['./default']
|
||||
};
|
||||
|
||||
function description() {
|
||||
var s = ''
|
||||
for (var i = 0; i < 10; i++) {
|
||||
s += 'description: Koa web app framework'
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
@@ -8,34 +8,15 @@
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
|
||||
<link rel="shortcut icon" href="/favicon.png">
|
||||
<!-- Bootstrap -->
|
||||
<link href="//dn-staticfile.qbox.me/twitter-bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" media="screen">
|
||||
<!-- Ant design -->
|
||||
<link href="/css/antd-0.9.1.min.css" rel="stylesheet" media="screen">
|
||||
<link href="/css/main.css" rel="stylesheet" media="screen">
|
||||
<link href="/css/yue.css" rel="stylesheet" media="screen">
|
||||
<link href="/css/github.css" rel="stylesheet" media="screen">
|
||||
<link href="/css/github-markdown.css" rel="stylesheet" media="screen">
|
||||
<!-- JavaScript plugins (requires jQuery) -->
|
||||
<script src="//dn-staticfile.qbox.me/jquery/2.0.3/jquery.min.js"></script>
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="CNPM" />
|
||||
<style>
|
||||
#tagline{display:inline;}
|
||||
/*#wrapper{padding:5% 8%;min-width:480px;}*/
|
||||
#tagline{font:0.8em serif;color:#888;display:inline-block;margin:0.1em 0 1.2em;}
|
||||
#fork{position:fixed;top:0;right:0;_position:absolute;}
|
||||
.bottom{text-align: center;}
|
||||
#content-header {margin: 20px 0 50px 0;}
|
||||
.user .avatar {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
table.downloads td.count {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.nav-tabs{margin:20px 0;}
|
||||
.nav-cont{display:none;}
|
||||
.nav-cont.active{display:block;}
|
||||
</style>
|
||||
<script>
|
||||
$(function () {
|
||||
$('#search-input').keypress(function (e) {
|
||||
@@ -62,15 +43,17 @@
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<header>
|
||||
<header id="header">
|
||||
<div class="logo">
|
||||
<a href="/"><img src="{{logoURL}}"></a>
|
||||
{{adBanner}}
|
||||
</div>
|
||||
<input type="text" id="search-input" class="form-control" placeholder="Search Packages">
|
||||
<input type="text" id="search-input" class="ant-input ant-input-lg" placeholder="Search Packages">
|
||||
</header>
|
||||
|
||||
<%- locals.body %>
|
||||
<div class="yue">
|
||||
<%- locals.body %>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<hr/>
|
||||
<p>
|
||||
@@ -78,8 +61,6 @@
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Include all compiled plugins (below), or include individual files as needed -->
|
||||
<script src="//dn-staticfile.qbox.me/twitter-bootstrap/3.2.0/js/bootstrap.min.js"></script>
|
||||
|
||||
<!-- Enable responsive features in IE8 with Respond.js (https://github.com/scottjehl/Respond) -->
|
||||
<script src="//dn-staticfile.qbox.me/respond.js/1.2.0/respond.min.js"></script>
|
||||
@@ -91,7 +72,6 @@
|
||||
$(function () {
|
||||
$('pre code').parent().addClass('prettyprint');
|
||||
prettyPrint();
|
||||
$('table').addClass('table table-bordered table-striped');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<% if (package.deprecated) { %>
|
||||
<div class="pack-name deprecated"><%= package.name %></div>
|
||||
<% if (package.description) {%>
|
||||
<div class="pack-description deprecated"><%= package.description %></div>
|
||||
<p class="pack-description deprecated"><%= package.description %></p>
|
||||
<% } %>
|
||||
<div class="deprecated-content" title="<%= package.deprecated %>"><%= package.deprecated %></div>
|
||||
<% } else { %>
|
||||
@@ -23,34 +23,34 @@
|
||||
<% }
|
||||
}%>
|
||||
</div>
|
||||
<% if (package.fromNow) { %>
|
||||
<div class="pack-lastup">
|
||||
Last updated <%= package.fromNow %>
|
||||
<% if (package.lastPublishedUser) {
|
||||
var name = package.lastPublishedUser.name;
|
||||
%>
|
||||
by <a href="/~<%= name %>"><%= name %></a>
|
||||
<% } %>
|
||||
.
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<div class="pack-repo">
|
||||
<% if (package.fromNow) { %>
|
||||
<div class="pack-lastup">
|
||||
Last updated <%= package.fromNow %>
|
||||
<% if (package.lastPublishedUser) {
|
||||
var name = package.lastPublishedUser.name;
|
||||
%>
|
||||
by <a href="/~<%= name %>"><%= name %></a>
|
||||
<% } %>
|
||||
.
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<% if (package.license) { %>
|
||||
<a href="<%= package.license.url %>" target="_blank"><%= package.license.name %></a>
|
||||
<% } %>
|
||||
|
||||
<% if (package.repository) { %>
|
||||
<% if (package.license) {%> | <% } %>
|
||||
<% if (package.license) {%> · <% } %>
|
||||
<a href="<%= package.repository.weburl %>" target="_blank">Repository</a>
|
||||
<% } %>
|
||||
|
||||
<% if (package.bugs.url) { %>
|
||||
<% if (package.license || package.repository) {%> | <% } %>
|
||||
<% if (package.license || package.repository) {%> · <% } %>
|
||||
<a href="<%= package.bugs.url %>" target="_blank">Bugs</a>
|
||||
<% } %>
|
||||
|
||||
<% if (package.license || package.repository || package.bugs.url) {%> | <% } %>
|
||||
<% if (package.license || package.repository || package.bugs.url) {%> · <% } %>
|
||||
|
||||
<% if (!package._publish_on_cnpm) { %>
|
||||
<a href="https://www.npmjs.org/package/<%= package.name %>" target="_blank">Original npm</a>
|
||||
@@ -71,106 +71,140 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pack-details cols-box">
|
||||
<div class="pack-dep cols-box-item">
|
||||
<div class="cols-box-title">
|
||||
<%
|
||||
var deps = Object.keys(package.dependencies || {})
|
||||
var l = deps.length
|
||||
var m = 8
|
||||
%>
|
||||
Dependencies<%= ' (' + l + ')' %>
|
||||
<% if (l > m) { %>
|
||||
<a class="more-item" href="<%= package.registryUrl %>" target="_blank">+<%= l-m %> more</a>
|
||||
<% } %>
|
||||
</div>
|
||||
<% if (l) { %>
|
||||
<ul>
|
||||
<% if (l > m) deps = deps.slice(0, m)
|
||||
deps.forEach(function(pkg, i) {
|
||||
%>
|
||||
<li>
|
||||
<a class="pack-dep-name" target="_blank" href="/package/<%= pkg %>"><%= pkg %></a>
|
||||
<span class="pack-dep-ver"><%= package.dependencies[pkg]%></span>
|
||||
</li>
|
||||
<% }) %>
|
||||
</ul>
|
||||
<% } else { %>
|
||||
None
|
||||
<% } %>
|
||||
<div class="row">
|
||||
|
||||
|
||||
<div class="pack-readme col-17">
|
||||
<section id="readme" class="markdown-body">
|
||||
<%- package.readme || 'No README was found.' %>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="pack-maintainers cols-box-item">
|
||||
<div class="cols-box-title">
|
||||
<%
|
||||
var maintainers = package.maintainers || [];
|
||||
var l = maintainers.length
|
||||
var m = 6
|
||||
%>
|
||||
Maintainers <%= l > 0 ? ' (' + l + ')' : '' %>
|
||||
<% if (l > m) { %>
|
||||
<a class="more-item" href="<%= package.registryUrl %>" target="_blank">+<%= l-m %> more</a>
|
||||
<% } %>
|
||||
</div>
|
||||
<div class="maintainers">
|
||||
<% if (l > m) maintainers = maintainers.slice(0, m) %>
|
||||
<% for (var i = 0; i < maintainers.length; i += 2) { %>
|
||||
<div class="row">
|
||||
<div class="pack-details cols-box col-6 col-push-1">
|
||||
|
||||
<div class="pack-maintainers cols-box-item">
|
||||
<div class="cols-box-title">
|
||||
<%
|
||||
var maintainers = package.maintainers || [];
|
||||
var l = maintainers.length
|
||||
%>
|
||||
Maintainers <%= l > 0 ? ' (' + l + ')' : '' %>
|
||||
</div>
|
||||
<div class="maintainers">
|
||||
<% for (var i = 0; i < maintainers.length; i ++) { %>
|
||||
<div class="maintainer">
|
||||
<a class="username" href="/~<%= maintainers[i].name %>">
|
||||
<img src="<%= maintainers[i].gravatar %>" class="avatar">
|
||||
<%= maintainers[i].name %>
|
||||
</a>
|
||||
</div>
|
||||
<% if (maintainers[i + 1]) { %>
|
||||
<div class="maintainer">
|
||||
<a class="username" href="/~<%= maintainers[i + 1].name %>">
|
||||
<img src="<%= maintainers[i + 1].gravatar %>" class="avatar">
|
||||
<%= maintainers[i + 1].name %>
|
||||
</a>
|
||||
</div>
|
||||
<% } %>
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pack-downloads cols-box-item">
|
||||
<div class="cols-box-title">
|
||||
Downloads
|
||||
</div>
|
||||
<div class="downloads">
|
||||
<div class="row">
|
||||
Today
|
||||
<span class="pack-download-num"><%= download.today %></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
This Week
|
||||
<span class="pack-download-num"><%= download.thisweek %></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
This Month
|
||||
<span class="pack-download-num"><%= download.thismonth %></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
Last Day
|
||||
<span class="pack-download-num"><%= download.lastday %></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
Last Week
|
||||
<span class="pack-download-num"><%= download.lastweek %></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
Last Month
|
||||
<span class="pack-download-num"><%= download.lastmonth %></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pack-dep cols-box-item">
|
||||
<div class="cols-box-title">
|
||||
<%
|
||||
var deps = Object.keys(package.dependencies || {});
|
||||
var l = deps.length;
|
||||
%>
|
||||
Dependencies<%= ' (' + l + ')' %>
|
||||
|
||||
</div>
|
||||
<% if (l) { %>
|
||||
<ul>
|
||||
<%
|
||||
deps.forEach(function(pkg, i) {
|
||||
%>
|
||||
<li>
|
||||
<a class="pack-dep-name" target="_blank" href="/package/<%= pkg %>"><%= pkg %></a>
|
||||
<span class="pack-dep-ver"><%= package.dependencies[pkg]%></span>
|
||||
</li>
|
||||
<% }); %>
|
||||
</ul>
|
||||
<% } else { %>
|
||||
None
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pack-dep cols-box-item">
|
||||
<div class="cols-box-title">
|
||||
<%
|
||||
var deps = Object.keys(package.devDependencies || {});
|
||||
var l = deps.length;
|
||||
%>
|
||||
Dev Dependencies<%= ' (' + l + ')' %>
|
||||
|
||||
<div class="pack-downloads cols-box-item">
|
||||
<div class="cols-box-title">
|
||||
Downloads
|
||||
</div>
|
||||
<% if (l) { %>
|
||||
<ul>
|
||||
<%
|
||||
deps.forEach(function(pkg, i) {
|
||||
%>
|
||||
<li>
|
||||
<a class="pack-dep-name" target="_blank" href="/package/<%= pkg %>"><%= pkg %></a>
|
||||
<span class="pack-dep-ver"><%= package.devDependencies[pkg]%></span>
|
||||
</li>
|
||||
<% }); %>
|
||||
</ul>
|
||||
<% } else { %>
|
||||
None
|
||||
<% } %>
|
||||
</div>
|
||||
<div class="downloads">
|
||||
<div class="row">
|
||||
Today
|
||||
<span class="pack-download-num"><%= download.today %></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
This Week
|
||||
<span class="pack-download-num"><%= download.thisweek %></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
This Month
|
||||
<span class="pack-download-num"><%= download.thismonth %></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
Last Day
|
||||
<span class="pack-download-num"><%= download.lastday %></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
Last Week
|
||||
<span class="pack-download-num"><%= download.lastweek %></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
Last Month
|
||||
<span class="pack-download-num"><%= download.lastmonth %></span>
|
||||
|
||||
<div class="pack-dep cols-box-item">
|
||||
<div class="cols-box-title">
|
||||
<%
|
||||
var deps = package.dependents;
|
||||
var l = deps.length;
|
||||
%>
|
||||
Dependents<%= ' (' + l + ')' %>
|
||||
|
||||
</div>
|
||||
<% if (l) { %>
|
||||
<ul>
|
||||
<%
|
||||
deps.forEach(function(pkg) {
|
||||
%>
|
||||
<li>
|
||||
<a class="pack-dep-name" target="_blank" href="/package/<%= pkg %>"><%= pkg %></a>
|
||||
</li>
|
||||
<% }); %>
|
||||
</ul>
|
||||
<% } else { %>
|
||||
None
|
||||
<% } %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pack-readme">
|
||||
<div class="title">README</div>
|
||||
<section id="readme" class="markdown-body">
|
||||
<%- package.readme %>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@@ -7,65 +7,69 @@
|
||||
</h1>
|
||||
|
||||
<p class="description">This package has been unpublished.</p>
|
||||
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a href="#meta">package.json</a></li>
|
||||
<!-- package.json? -->
|
||||
<ul class="ant-menu ant-menu-horizontal ant-menu-root unstyled mb15">
|
||||
<li class="ant-menu-item-selected ant-menu-item unstyled">
|
||||
<span>package.json</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<table class="metadata active">
|
||||
<% if (package.unpublished.description) { %>
|
||||
<tr>
|
||||
<th>Description</th>
|
||||
<td>
|
||||
<%= package.unpublished.description %>
|
||||
</td>
|
||||
</tr>
|
||||
<% } %>
|
||||
<div class="ant-table">
|
||||
<table class="metadata active">
|
||||
<% if (package.unpublished.description) { %>
|
||||
<tr>
|
||||
<th>Description</th>
|
||||
<td>
|
||||
<%= package.unpublished.description %>
|
||||
</td>
|
||||
</tr>
|
||||
<% } %>
|
||||
|
||||
<tr>
|
||||
<th>Unpublished By</th>
|
||||
<td>
|
||||
<span class="user">
|
||||
<a class="username" href="/~<%= package.unpublished.name %>">
|
||||
<%= package.unpublished.name %>
|
||||
</a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Unpublished By</th>
|
||||
<td>
|
||||
<span class="user">
|
||||
<a class="username" href="/~<%= package.unpublished.name %>">
|
||||
<%= package.unpublished.name %>
|
||||
</a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Unpublished On</th>
|
||||
<td>
|
||||
<%= package.unpublished.time %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Unpublished On</th>
|
||||
<td>
|
||||
<%= package.unpublished.time %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<% if (package.unpublished.maintainers) { %>
|
||||
<tr>
|
||||
<th>Maintainers</th>
|
||||
<td>
|
||||
<% package.unpublished.maintainers.forEach(function (m) { %>
|
||||
<span class="user">
|
||||
<a class="username" href="/~<%= m.name %>">
|
||||
<% if (m.gravatar) { %>
|
||||
<img src="<%= m.gravatar %>" class="avatar">
|
||||
<% } %>
|
||||
<%= m.name %>
|
||||
</a>
|
||||
</span>
|
||||
<% }) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% } %>
|
||||
<% if (package.unpublished.maintainers) { %>
|
||||
<tr>
|
||||
<th>Maintainers</th>
|
||||
<td>
|
||||
<% package.unpublished.maintainers.forEach(function (m) { %>
|
||||
<span class="user">
|
||||
<a class="username" href="/~<%= m.name %>">
|
||||
<% if (m.gravatar) { %>
|
||||
<img src="<%= m.gravatar %>" class="avatar">
|
||||
<% } %>
|
||||
<%= m.name %>
|
||||
</a>
|
||||
</span>
|
||||
<% }) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% } %>
|
||||
|
||||
<% if (package.unpublished.versions) { %>
|
||||
<tr>
|
||||
<th>Versions (<%= package.unpublished.versions.length %>)</th>
|
||||
<td>
|
||||
<%= package.unpublished.versions.reverse().slice(0, 20).join(', ') %> ...
|
||||
</td>
|
||||
</tr>
|
||||
<% } %>
|
||||
<% if (package.unpublished.versions) { %>
|
||||
<tr>
|
||||
<th>Versions (<%= package.unpublished.versions.length %>)</th>
|
||||
<td>
|
||||
<%= package.unpublished.versions.reverse().slice(0, 20).join(', ') %> ...
|
||||
</td>
|
||||
</tr>
|
||||
<% } %>
|
||||
|
||||
</table>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
var packages = scopes[scope];
|
||||
%>
|
||||
<h1>
|
||||
Private packages in <%= scope %>
|
||||
Private packages in <%= scope %>(total: <%= packages.length %>)
|
||||
</h1>
|
||||
<hr />
|
||||
<% if (!packages.length) { %>
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
<style>
|
||||
#profile .package {
|
||||
padding: 10px;
|
||||
font-size: 18px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
</style>
|
||||
<div id="profile">
|
||||
<h1>
|
||||
<h2>
|
||||
Packages by
|
||||
<% if (user.json.homepage) { %>
|
||||
<span class="user">
|
||||
@@ -20,41 +13,46 @@
|
||||
<% } else { %>
|
||||
<span style="color:#09f;"><%= user.name %></span>
|
||||
<% } %>
|
||||
<% if (user.json.fullname) { %>
|
||||
<small>(<%= user.json.fullname %>)</small>
|
||||
<% } %>
|
||||
<% if (user.email) { %>
|
||||
<small>(<a href="mailto:<%= user.email %>"><%= user.email %></a>)</small>
|
||||
<% } %>
|
||||
<% if (user.email) { %>
|
||||
<small><<a href="mailto:<%= user.email %>"><%= user.email %></a>></small>
|
||||
<% } %>
|
||||
<% if (user.json.fullname) { %>
|
||||
<small>(<%= user.json.fullname %>)</small>
|
||||
<% } %>
|
||||
|
||||
<small>(<a href="/sync/user:<%= user.name %>" target="_blank">SYNC</a> profile)</small>
|
||||
</h1>
|
||||
<table class="downloads">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>IM</th>
|
||||
<th>Last modified</th>
|
||||
<th>Is admin</th>
|
||||
<th>Publish scopes</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>@<%= user.json.fullname || user.name %></td>
|
||||
<td>
|
||||
<% if (user.json.im) { %>
|
||||
<a href="<%= user.json.im %>" target="_blank"><span class="glyphicon glyphicon-comment"></span></a>
|
||||
<% } %>
|
||||
</td>
|
||||
<td><%- lastModified %></td>
|
||||
<td><%- isAdmin %></td>
|
||||
<td>
|
||||
<%- scopes.map(function (scope) {
|
||||
return '<a href="/browse/keyword/' + scope + '" target="_blank">' + scope + '</a>';
|
||||
}).join(' , ') %>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<% if (user.isNpmUser) { %>
|
||||
<small>[<a href="/sync/user:<%= user.name %>" target="_blank">SYNC</a> profile]</small>
|
||||
<% } %>
|
||||
</h2>
|
||||
<div class="ant-table">
|
||||
<table class="downloads">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>IM</th>
|
||||
<th>Last modified</th>
|
||||
<th>Is admin</th>
|
||||
<th>Publish scopes</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>@<%= user.json.fullname || user.name %></td>
|
||||
<td>
|
||||
<% if (user.json.im) { %>
|
||||
<a href="<%= user.json.im %>" target="_blank"><span class="glyphicon glyphicon-comment"></span></a>
|
||||
<% } %>
|
||||
</td>
|
||||
<td><%- lastModified %></td>
|
||||
<td><%- isAdmin %></td>
|
||||
<td>
|
||||
<%- scopes.map(function (scope) {
|
||||
return '<a href="/browse/keyword/' + scope + '" target="_blank">' + scope + '</a>';
|
||||
}).join(' , ') %>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
<% if (!packages.length) { %>
|
||||
<div class="alert alert-warning">Can not found any package by <%= user.name %>.</div>
|
||||
@@ -62,9 +60,11 @@
|
||||
<% for (var i = 0; i < packages.length; i++) {
|
||||
var package = packages[i];
|
||||
%>
|
||||
<div class="package">
|
||||
<ul>
|
||||
<li class="package">
|
||||
<a href="/package/<%= packages[i].name %>" class="package-name"><%= package.name %></a>
|
||||
<span class="package-description">(latest: <%= package.version %>) <%= package.description %></span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<% } %>
|
||||
</div>
|
||||
|
||||
@@ -1,42 +1,30 @@
|
||||
<style>
|
||||
#search .package {
|
||||
padding: 10px;
|
||||
font-size: 18px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
#search .alert a {
|
||||
font-size: 20px;
|
||||
}
|
||||
#search .package.match {
|
||||
font-size: 25px;
|
||||
font-weight: bolder;
|
||||
}
|
||||
</style>
|
||||
<div id="search">
|
||||
<div id="search" class="row">
|
||||
<% if (!packages.length) { %>
|
||||
<div class="alert alert-warning">
|
||||
<div class="ant-alert ant-alert-warn">
|
||||
Can not found package match <%= keyword %>. You can
|
||||
<a href="/sync/<%= keyword %>" target="_blank">SYNC</a> from official npm registry or
|
||||
<a href="https://npmjs.org/search?q=<%= keyword %>" target="_blank">SEARCH</a> in official npm website.
|
||||
</div>
|
||||
<% } else if (!match) { %>
|
||||
<div class="alert alert-info">
|
||||
<div class="ant-alert ant-alert-info">
|
||||
Can not found package <%= keyword %>. You can
|
||||
<a href="/sync/<%= keyword %>" target="_blank">SYNC</a> from official npm registry or
|
||||
<a href="https://npmjs.org/search?q=<%= keyword %>" target="_blank">SEARCH</a> in official npm website.
|
||||
</div>
|
||||
<% } %>
|
||||
<div class="col-12">
|
||||
|
||||
<% if (packages.length) { %>
|
||||
<h1>
|
||||
<h2>
|
||||
Packages match "<span style="color: #09f;"><%= keyword %></span>"
|
||||
</h1>
|
||||
<hr />
|
||||
</h2>
|
||||
<% if (match) { %>
|
||||
<div class="package match">
|
||||
<a href="/package/<%= match.name %>" class="package-name"><%= match.name %></a>
|
||||
<span class="package-description"><%= match.description %></span>
|
||||
</div>
|
||||
<ul>
|
||||
<li class="package match">
|
||||
<a href="/package/<%= match.name %>" class="package-name"><%= match.name %></a>
|
||||
<span class="package-description"><%= match.description %></span>
|
||||
</li>
|
||||
</ul>
|
||||
<% } %>
|
||||
<% for (var i = 0; i < packages.length; i++) {
|
||||
var item = packages[i];
|
||||
@@ -44,25 +32,30 @@
|
||||
continue;
|
||||
}
|
||||
%>
|
||||
<div class="package">
|
||||
<ul>
|
||||
<li class="package">
|
||||
<a href="/package/<%= item.name %>" class="package-name"><%= item.name %></a>
|
||||
<span class="package-description"><%= item.description %></span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<% } %>
|
||||
<% } %>
|
||||
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<% if (keywords.length) { %>
|
||||
<h1>
|
||||
<h2>
|
||||
Keywords match "<span style="color: #09f;"><%= keyword %></span>"
|
||||
</h1>
|
||||
<hr />
|
||||
</h2>
|
||||
<% for (var i = 0; i < keywords.length; i++) {
|
||||
var item = keywords[i];
|
||||
%>
|
||||
<div class="package <%= item.name === keyword ? 'match' : '' %>">
|
||||
<ul>
|
||||
<li class="package <%= item.name === keyword ? 'match' : '' %>">
|
||||
<a href="/package/<%= item.name %>" class="package-name"><%= item.name %></a>
|
||||
<span class="package-description"><%= item.description %></span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<% } %>
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div id="sync">
|
||||
<h1>Sync <%= type %> <span style="color:#09f;"><%= name %></span></h1>
|
||||
<h2>Sync <%= type %> <span style="color:#09f;"><%= name %></span></h2>
|
||||
<div id="sync-notify">
|
||||
<div class="alert alert-success">Sync started, please wait patiently.</div>
|
||||
<div class="ant-alert ant-alert-success">Sync started, please wait patiently.</div>
|
||||
</div>
|
||||
<h2>Log</h2>
|
||||
<pre style="min-height: 400px;" id="sync-log"></pre>
|
||||
@@ -28,7 +28,7 @@
|
||||
dataType: 'json',
|
||||
success: handleSyncSucess,
|
||||
error: function (err) {
|
||||
var alert = $('<div class="alert alert-error"></div>');
|
||||
var alert = $('<div class="ant-alert ant-alert-error"></div>');
|
||||
var message = 'Sync request error. ';
|
||||
if (err.status === 404) {
|
||||
message += name + ' not exist in official registry.';
|
||||
@@ -48,7 +48,7 @@
|
||||
location.hash = '#logid=' + data.logId;
|
||||
return;
|
||||
}
|
||||
$notify.html('<div class="alert alert-error">Sync request error.</div>');
|
||||
$notify.html('<div class="ant-alert ant-alert-error">Sync request error.</div>');
|
||||
}
|
||||
|
||||
var offset = 0;
|
||||
|
||||
Reference in New Issue
Block a user