Compare commits
120 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af4401fc62 | ||
|
|
c2d608a5cc | ||
|
|
b91b160b66 | ||
|
|
46a3df95bd | ||
|
|
d08aee047e | ||
|
|
406d8cf9a1 | ||
|
|
e1b9ab6b09 | ||
|
|
71f9014777 | ||
|
|
adca5adff2 | ||
|
|
1857f1d0e5 | ||
|
|
2d56820e8b | ||
|
|
119094b230 | ||
|
|
744b6e1e15 | ||
|
|
17f47732a0 | ||
|
|
3a46b97544 | ||
|
|
44976f4afa | ||
|
|
9da7c6ccf2 | ||
|
|
4b68eecf53 | ||
|
|
8d7058b947 | ||
|
|
933ae69d0b | ||
|
|
1af36f0a7a | ||
|
|
f4e9de5094 | ||
|
|
2ccaf404ab | ||
|
|
44c79c7646 | ||
|
|
a845d3f74d | ||
|
|
730113424c | ||
|
|
658be3004f | ||
|
|
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 |
@@ -1,9 +1,8 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
node_js:
|
||||
- '1'
|
||||
- '2'
|
||||
- '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)
|
||||
|
||||
|
||||
134
History.md
134
History.md
@@ -1,4 +1,134 @@
|
||||
|
||||
2.8.0 / 2016-02-23
|
||||
==================
|
||||
|
||||
* fix: convert `*` to latest tag
|
||||
* deps: upgrade deps and remove node 2.0.0 support
|
||||
* doc: update sponsors on readme
|
||||
* fix: update copyright year
|
||||
* doc: fix disturl typo
|
||||
* deps: sequelize@3.19.0
|
||||
|
||||
2.7.1 / 2016-02-01
|
||||
==================
|
||||
|
||||
* fix(semver): when have invalid version([#817](https://github.com/cnpm/cnpmjs.org/issues/817))
|
||||
|
||||
2.7.0 / 2016-02-01
|
||||
==================
|
||||
|
||||
* test: fix all test cases
|
||||
* test: fix unpublish
|
||||
* test: add complex range test case
|
||||
* feat: support semver([#816](https://github.com/cnpm/cnpmjs.org/issues/816))
|
||||
|
||||
2.6.2 / 2016-01-19
|
||||
==================
|
||||
|
||||
* feat: list & show support jsonp
|
||||
* chore(package): update urllib to version 2.7.0
|
||||
* Delete install.md
|
||||
|
||||
2.6.1 / 2016-01-12
|
||||
==================
|
||||
|
||||
* fix: source registry is not cnpm, ignore check status
|
||||
|
||||
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](https://github.com/cnpm/cnpmjs.org/issues/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
|
||||
==================
|
||||
|
||||
@@ -76,10 +206,10 @@
|
||||
|
||||
* feat: support always-auth
|
||||
* fix mysql select args = [] bug
|
||||
* fix #597 sequelize raw query.
|
||||
* fix [#597](https://github.com/cnpm/cnpmjs.org/issues/597) sequelize raw query.
|
||||
* fix(markdown): hotfix markdown-it cpu problem
|
||||
* feat: upgrade to co4
|
||||
* use kcors fixes #594
|
||||
* use kcors fixes [#594](https://github.com/cnpm/cnpmjs.org/issues/594)
|
||||
|
||||
2.0.0-rc.13 / 2015-02-04
|
||||
==================
|
||||
|
||||
34
Makefile
34
Makefile
@@ -3,17 +3,10 @@ REPORTER = spec
|
||||
TIMEOUT = 30000
|
||||
MOCHA_OPTS =
|
||||
DB = sqlite
|
||||
DISTURL = https://npm.taobao.org/mirrors/iojs
|
||||
BIN = iojs
|
||||
|
||||
ifeq ($(findstring io.js, $(shell which node)),)
|
||||
BIN = node
|
||||
DISTURL = https://npm.taobao.org/mirrors/node
|
||||
endif
|
||||
|
||||
install:
|
||||
@npm install --build-from-source --registry=http://registry.npm.taobao.org \
|
||||
--disturl=$(DISTURL)
|
||||
@npm install --build-from-source --registry=https://registry.npm.taobao.org \
|
||||
--disturl=https://npm.taobao.org/mirrors/node
|
||||
|
||||
install-production production:
|
||||
@NODE_ENV=production $(MAKE) install
|
||||
@@ -22,7 +15,7 @@ jshint: install
|
||||
@-node_modules/.bin/jshint ./
|
||||
|
||||
init-database:
|
||||
@$(BIN) --harmony test/init_db.js
|
||||
@node test/init_db.js
|
||||
|
||||
init-mysql:
|
||||
@mysql -uroot -e 'DROP DATABASE IF EXISTS cnpmjs_test;'
|
||||
@@ -34,12 +27,11 @@ init-pg:
|
||||
|
||||
test: install init-database
|
||||
@NODE_ENV=test DB=${DB} node_modules/.bin/mocha \
|
||||
--harmony \
|
||||
--reporter $(REPORTER) \
|
||||
--timeout $(TIMEOUT) \
|
||||
--require should \
|
||||
--require should-http \
|
||||
--require co-mocha \
|
||||
--require thunk-mocha \
|
||||
--require ./test/init.js \
|
||||
$(MOCHA_OPTS) \
|
||||
$(TESTS)
|
||||
@@ -56,15 +48,15 @@ test-pg: init-pg
|
||||
test-all: test-sqlite test-mysql
|
||||
|
||||
test-cov cov: install init-database
|
||||
@NODE_ENV=test DB=${DB} $(BIN) \
|
||||
node_modules/.bin/istanbul cover --preserve-comments \
|
||||
@NODE_ENV=test DB=${DB} node \
|
||||
node_modules/.bin/istanbul cover \
|
||||
node_modules/.bin/_mocha \
|
||||
-- -u exports \
|
||||
--reporter $(REPORTER) \
|
||||
--timeout $(TIMEOUT) \
|
||||
--require should \
|
||||
--require should-http \
|
||||
--require co-mocha \
|
||||
--require thunk-mocha \
|
||||
--require ./test/init.js \
|
||||
$(MOCHA_OPTS) \
|
||||
$(TESTS)
|
||||
@@ -76,16 +68,16 @@ test-cov-mysql: init-mysql
|
||||
@$(MAKE) test-cov DB=mysql
|
||||
|
||||
test-travis: install init-database
|
||||
@NODE_ENV=test DB=${DB} CNPM_SOURCE_NPM=http://registry.npmjs.com CNPM_SOURCE_NPM_ISCNPM=false \
|
||||
$(BIN) \
|
||||
node_modules/.bin/istanbul cover --preserve-comments \
|
||||
@NODE_ENV=test DB=${DB} CNPM_SOURCE_NPM=https://registry.npmjs.com CNPM_SOURCE_NPM_ISCNPM=false \
|
||||
node \
|
||||
node_modules/.bin/istanbul cover \
|
||||
node_modules/.bin/_mocha \
|
||||
-- -u exports \
|
||||
--reporter dot \
|
||||
--timeout $(TIMEOUT) \
|
||||
--require should \
|
||||
--require should-http \
|
||||
--require co-mocha \
|
||||
--require thunk-mocha \
|
||||
--require ./test/init.js \
|
||||
$(MOCHA_OPTS) \
|
||||
$(TESTS)
|
||||
@@ -104,7 +96,7 @@ test-travis-pg:
|
||||
test-travis-all: test-travis-sqlite test-travis-mysql test-travis-pg
|
||||
|
||||
dev:
|
||||
@NODE_ENV=development $(BIN) node_modules/.bin/node-dev --harmony dispatch.js
|
||||
@NODE_ENV=development node node_modules/.bin/node-dev dispatch.js
|
||||
|
||||
contributors: install
|
||||
@node_modules/.bin/contributors -f plain -o AUTHORS
|
||||
@@ -113,7 +105,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
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ as well as [New features in 2.x](https://github.com/cnpm/cnpmjs.org/wiki/New-fea
|
||||
|
||||
### Dependencies
|
||||
|
||||
* [node](http://nodejs.org) >=0.11.12, use `--harmony`
|
||||
* [node](http://nodejs.org) >= 4.3.1
|
||||
* Databases: only required one type
|
||||
* [sqlite3](https://npm.taobao.org/package/sqlite3) >= 3.0.2, we use `sqlite3` by default
|
||||
* [MySQL](http://dev.mysql.com/downloads/) >= 0.5.0, include `mysqld` and `mysql cli`. I test on `mysql@5.6.16`.
|
||||
@@ -111,7 +111,8 @@ Tips: make sure your code is following the [node-style-guide](https://github.com
|
||||
|
||||
## Sponsors
|
||||
|
||||
- [](http://www.ucloud.cn?sem=sdk-CNPMJS)
|
||||
- [](https://www.aliyun.com?from=cnpmjs.org) (2016.2 - now)
|
||||
- [](http://www.ucloud.cn?sem=sdk-CNPMJS) (2015.3 - 2016.3)
|
||||
|
||||
## License
|
||||
|
||||
|
||||
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,4 +1,4 @@
|
||||
/**!
|
||||
/**
|
||||
* Copyright(c) cnpmjs.org and other contributors.
|
||||
* MIT Licensed
|
||||
*
|
||||
@@ -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/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;
|
||||
@@ -196,5 +198,5 @@ module.exports = function* list() {
|
||||
info.license = pkg.license;
|
||||
|
||||
debug('show module %s: %s, latest: %s', orginalName, rev, latestMod.version);
|
||||
this.body = info;
|
||||
this.jsonp = info;
|
||||
};
|
||||
|
||||
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';
|
||||
@@ -32,13 +30,20 @@ var config = require('../../../config');
|
||||
module.exports = function* show() {
|
||||
var name = this.params.name || this.params[0];
|
||||
var tag = this.params.version || this.params[1];
|
||||
if (tag === '*') {
|
||||
tag = 'latest';
|
||||
}
|
||||
var version = semver.valid(tag);
|
||||
var range = semver.validRange(tag);
|
||||
var mod;
|
||||
if (version) {
|
||||
mod = yield* packageService.getModule(name, version);
|
||||
mod = yield packageService.getModule(name, version);
|
||||
} else if (range) {
|
||||
mod = yield packageService.getModuleByRange(name, range);
|
||||
} else {
|
||||
mod = yield* packageService.getModuleByTag(name, tag);
|
||||
mod = yield packageService.getModuleByTag(name, tag);
|
||||
}
|
||||
|
||||
if (mod) {
|
||||
setDownloadURL(mod.package, this);
|
||||
mod.package._cnpm_publish_time = mod.publish_time;
|
||||
@@ -46,14 +51,14 @@ module.exports = function* show() {
|
||||
if (maintainers.length > 0) {
|
||||
mod.package.maintainers = maintainers;
|
||||
}
|
||||
this.body = mod.package;
|
||||
this.jsonp = mod.package;
|
||||
return;
|
||||
}
|
||||
|
||||
// if not fond, sync from source registry
|
||||
if (!this.allowSync) {
|
||||
this.status = 404;
|
||||
this.body = {
|
||||
this.jsonp = {
|
||||
error: 'not exist',
|
||||
reason: 'version not found: ' + version
|
||||
};
|
||||
@@ -61,7 +66,7 @@ module.exports = function* show() {
|
||||
}
|
||||
|
||||
// start sync
|
||||
var logId = yield* SyncModuleWorker.sync(name, 'sync-by-install');
|
||||
var logId = yield SyncModuleWorker.sync(name, 'sync-by-install');
|
||||
debug('start sync %s, get log id %s', name, logId);
|
||||
|
||||
this.redirect(config.officialNpmRegistry + this.url);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -13,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');
|
||||
@@ -383,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;
|
||||
}
|
||||
|
||||
@@ -677,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);
|
||||
}
|
||||
@@ -1049,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,7 +46,7 @@ exports.version = function* () {
|
||||
}
|
||||
version = version.replace(/\-/g, '--');
|
||||
var style = this.query.style || 'flat-square';
|
||||
var url = util.format('https://dn-img-shields-io.qbox.me/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);
|
||||
};
|
||||
@@ -56,7 +56,7 @@ exports.downloads = function* () {
|
||||
var name = this.params[0];
|
||||
var count = yield DownloadTotal.getTotalByName(name);
|
||||
var style = this.query.style || 'flat-square';
|
||||
var url = util.format('https://dn-img-shields-io.qbox.me/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';
|
||||
@@ -179,7 +177,7 @@ module.exports = function* show(next) {
|
||||
pkg.engines[k] = {
|
||||
version: engine,
|
||||
title: k + ': ' + engine,
|
||||
badgeURL: 'https://dn-img-shields-io.qbox.me/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) {
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
# Install & Get Started
|
||||
|
||||
## Deps
|
||||
|
||||
* MySQL Server: http://db4free.net/
|
||||
* qiniu CDN: http://www.qiniu.com/
|
||||
* redis session: https://garantiadata.com Support 24MB free spaces.
|
||||
* node: >=0.10.21
|
||||
|
||||
## Clone
|
||||
|
||||
```bash
|
||||
$ git clone git://github.com/fengmk2/cnpmjs.org.git $HOME/cnpmjs.org
|
||||
$ cd $HOME/cnpmjs.org
|
||||
```
|
||||
|
||||
## Create your `config.js`
|
||||
|
||||
```bash
|
||||
$ vim config/config.js
|
||||
```
|
||||
|
||||
`config.js` content sample:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
debug: false,
|
||||
enableCluster: true, // enable cluster mode
|
||||
logdir: 'your application log dir',
|
||||
mysqlServers: [
|
||||
{
|
||||
host: 'your mysql host',
|
||||
port: 3306,
|
||||
user: 'yourname',
|
||||
password: 'your password'
|
||||
}
|
||||
],
|
||||
mysqlDatabase: 'cnpmjs',
|
||||
redis: {
|
||||
host: 'your redist host',
|
||||
port: 6379,
|
||||
},
|
||||
qn: {
|
||||
accessKey: "your qiniu appkey",
|
||||
secretKey: "your secret key",
|
||||
bucket: "foobucket",
|
||||
domain: "http://foobucket.u.qiniudn.com"
|
||||
},
|
||||
nfs: null, // you can set a nfs to replace qiniu cdn
|
||||
enablePrivate: true, // enable private mode, only admin can publish, other use just can sync package from source npm
|
||||
admins: {
|
||||
admin: 'admin@cnpmjs.org',
|
||||
},
|
||||
syncModel: 'exist', //`all` sync all packages, `exist` only update exist packages, `none` do nothing
|
||||
};
|
||||
```
|
||||
|
||||
## Create MySQL Database and Tables
|
||||
|
||||
```bash
|
||||
$ mysql -u yourname -p
|
||||
|
||||
mysql> use cnpmjs;
|
||||
mysql> source docs/db.sql
|
||||
```
|
||||
|
||||
## Use your own CDN
|
||||
If you wan to use your own CDN instead of qiniu. Just look at `common/qnfs.js` and implement the interface like it, then pass it by set `config.nfs`.
|
||||
|
||||
## npm install
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
|
||||
## start
|
||||
|
||||
```bash
|
||||
$ ./bin/nodejsctl start
|
||||
|
||||
Starting cnpmjs.org ...
|
||||
Start nodejs success. PID=27175
|
||||
```
|
||||
|
||||
## open registry and web
|
||||
|
||||
```bash
|
||||
# registry
|
||||
$ open http://localhost:7001
|
||||
# web
|
||||
$ open http://localhost:7002
|
||||
```
|
||||
|
||||
## use cnpm cli with your own registry
|
||||
You do not need to write another command line tool with your own registry,
|
||||
just alias [cnpm](http://github.com/fengmk2/cnpm), then you can get a npm client for you own registry.
|
||||
|
||||
```
|
||||
# install cnpm first
|
||||
npm install -g cnpm
|
||||
|
||||
# then alias lnpm to cnpm, but change config to your own registry
|
||||
alias lnpm='cnpm --registry=http://localhost:7001\
|
||||
--registryweb=http://localhost:7002\
|
||||
--cache=$HOME/.npm/.cache/lnpm\
|
||||
--disturl=http://cnpmjs.org/dist\
|
||||
--userconfig=$HOME/.lnpmrc'
|
||||
|
||||
#or put this in .zshrc or .bashrc
|
||||
echo "#lnpm alias\nalias lnpm='cnpm --registry=http://localhost:7001\
|
||||
--registryweb=http://localhost:7002\
|
||||
--cache=$HOME/.npm/.cache/lnpm\
|
||||
--disturl=http://cnpmjs.org/dist\
|
||||
--userconfig=$HOME/.lnpmrc'" >> $HOME/.zshrc && source $HOME/.zshrc
|
||||
```
|
||||
@@ -4,10 +4,10 @@ So `cnpm` is meaning: **Company npm**.
|
||||
|
||||
## Registry
|
||||
|
||||
- Our public registry: [r.cnpmjs.org](//r.cnpmjs.org), syncing from [registry.npmjs.org](//registry.npmjs.org)
|
||||
- Our public registry: [r.cnpmjs.org](//r.cnpmjs.org), syncing from [registry.npmjs.org](https://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/)。
|
||||
- For developers in China, please visit [the China mirror](https://npm.taobao.org). 中国用户请访问[国内镜像站点](https://npm.taobao.org/)。
|
||||
|
||||
<div class="ant-table">
|
||||
<table class="downloads">
|
||||
@@ -35,9 +35,9 @@ So `cnpm` is meaning: **Company npm**.
|
||||
<h3>Sync Status</h3>
|
||||
<p id="sync-model"></p>
|
||||
<p>Last sync time is <span id="last-sync-time"></span>. </p>
|
||||
<div class="ant-alert ant-alert-info">
|
||||
<div class="ant-alert ant-alert-info syncing">
|
||||
<span class="anticon ant-alert-icon anticon-info-circle"></span>
|
||||
<span class="syncing ant-alert-description">The sync worker is working in the backend now. </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">
|
||||
@@ -65,7 +65,7 @@ Default style is `flat-square`.
|
||||
|
||||
### Version
|
||||
|
||||
Badge URL: `http://cnpmjs.org/badge/v/cnpmjs.org.svg` 
|
||||
Badge URL: `https://cnpmjs.org/badge/v/cnpmjs.org.svg` 
|
||||
|
||||
* `<0.1.0 & >=0.0.0`: 
|
||||
* `<1.0.0 & >=0.1.0`: 
|
||||
@@ -73,34 +73,34 @@ Badge URL: `http://cnpmjs.org/badge/v/cnpmjs.org.svg` 
|
||||
Badge URL: `https://cnpmjs.org/badge/d/cnpmjs.org.svg` 
|
||||
|
||||
## 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=http://registry.npm.taobao.org
|
||||
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
|
||||
```
|
||||
|
||||
Or you can alias NPM to use it:
|
||||
|
||||
```bash
|
||||
alias cnpm="npm --registry=http://registry.npm.taobao.org \
|
||||
alias cnpm="npm --registry=https://registry.npm.taobao.org \
|
||||
--cache=$HOME/.npm/.cache/cnpm \
|
||||
--disturl=http://registry.npm.taobao.org/mirrors/node \
|
||||
--disturl=https://npm.taobao.org/mirrors/node \
|
||||
--userconfig=$HOME/.cnpmrc"
|
||||
|
||||
#Or alias it in .bashrc or .zshrc
|
||||
$ echo '\n#alias for cnpm\nalias cnpm="npm --registry=http://registry.npm.taobao.org \
|
||||
$ echo '\n#alias for cnpm\nalias cnpm="npm --registry=https://registry.npm.taobao.org \
|
||||
--cache=$HOME/.npm/.cache/cnpm \
|
||||
--disturl=http://registry.npm.taobao.org/mirrors/node \
|
||||
--disturl=https://npm.taobao.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.
|
||||
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](https://registry.npmjs.org)), and sync this package to cnpm in the backend.
|
||||
|
||||
```bash
|
||||
$ cnpm install [name]
|
||||
@@ -151,4 +151,5 @@ Release [History](/history).
|
||||
|
||||
## Sponsors
|
||||
|
||||
- [](http://www.ucloud.cn?sem=sdk-CNPMJS)
|
||||
- [](https://www.aliyun.com?from=cnpmjs.org) (2016.2 - now)
|
||||
- [](http://www.ucloud.cn?sem=sdk-CNPMJS) (2015.3 - 2016.3)
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@ module.exports = {
|
||||
|
||||
query: function* (sql, args) {
|
||||
var options = { replacements: args };
|
||||
var data = yield this.sequelize.query(sql, options).spread();
|
||||
var data = yield this.sequelize.query(sql, options);
|
||||
if (/select /i.test(sql)) {
|
||||
return data[0];
|
||||
}
|
||||
|
||||
@@ -35,7 +35,10 @@ if (username) {
|
||||
|
||||
var models = require('./');
|
||||
|
||||
models.sequelize.sync({ force: force })
|
||||
models.sequelize.sync({
|
||||
force: force,
|
||||
logging: console.log,
|
||||
})
|
||||
.then(function () {
|
||||
models.Total.init(function (err) {
|
||||
if (err) {
|
||||
|
||||
@@ -70,7 +70,7 @@ module.exports = function (sequelize, DataTypes) {
|
||||
});
|
||||
if (row) {
|
||||
row.package = pkg;
|
||||
if (row.isDirty) {
|
||||
if (row.changed()) {
|
||||
row = yield row.save(['package']);
|
||||
}
|
||||
return row;
|
||||
|
||||
@@ -155,7 +155,7 @@ module.exports = function (sequelize, DataTypes) {
|
||||
user.json = data;
|
||||
user.email = data.email || '';
|
||||
user.rev = data._rev || '';
|
||||
if (user.isDirty) {
|
||||
if (user.changed()) {
|
||||
user = yield user.save();
|
||||
}
|
||||
return user;
|
||||
@@ -182,7 +182,7 @@ module.exports = function (sequelize, DataTypes) {
|
||||
user.rev = rev;
|
||||
user.salt = salt;
|
||||
user.password_sha = passwordSha;
|
||||
if (user.isDirty) {
|
||||
if (user.changed()) {
|
||||
user = yield user.save();
|
||||
}
|
||||
return user;
|
||||
|
||||
52
package.json
52
package.json
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "cnpmjs.org",
|
||||
"version": "2.2.1",
|
||||
"version": "2.8.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,53 +13,50 @@
|
||||
"cnpmjs.org": "bin/cli.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"agentkeepalive": "~1.2.0",
|
||||
"bluebird": "~2.9.7",
|
||||
"bytes": "~1.0.0",
|
||||
"cfork": "~1.3.1",
|
||||
"co": "~4.3.1",
|
||||
"agentkeepalive": "~2.0.3",
|
||||
"bytes": "~2.3.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",
|
||||
"commander": "~2.9.0",
|
||||
"copy-to": "~2.0.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",
|
||||
"gravatar": "~1.4.0",
|
||||
"humanize-ms": "~1.0.1",
|
||||
"humanize-number": "~0.0.2",
|
||||
"is-type-of": "~0.3.1",
|
||||
"is-type-of": "~1.0.0",
|
||||
"kcors": "~1.0.1",
|
||||
"koa": "~1.1.0",
|
||||
"koa": "~1.1.2",
|
||||
"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.10.6",
|
||||
"mysql": "~2.5.4",
|
||||
"moment": "~2.11.2",
|
||||
"mysql": "~2.10.2",
|
||||
"nodemailer": "~1.3.0",
|
||||
"semver": "~4.2.0",
|
||||
"sequelize": "~2.0.1",
|
||||
"semver": "~5.1.0",
|
||||
"sequelize": "~3.19.0",
|
||||
"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.7.0",
|
||||
"utility": "~1.6.0",
|
||||
"xss": "~0.2.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"autod": "*",
|
||||
"chunkstream": "*",
|
||||
"co-mocha": "*",
|
||||
"contributors": "*",
|
||||
"istanbul": "*",
|
||||
"jshint": "*",
|
||||
@@ -68,11 +65,12 @@
|
||||
"node-dev": "*",
|
||||
"pedding": "*",
|
||||
"pg": "~4.4.2",
|
||||
"pg-hstore": "~2.3.1",
|
||||
"pg-hstore": "~2.3.2",
|
||||
"should": "~7.1.0",
|
||||
"should-http": "*",
|
||||
"sqlite3": "*",
|
||||
"supertest": "*"
|
||||
"supertest": "*",
|
||||
"thunk-mocha": "1"
|
||||
},
|
||||
"homepage": "https://github.com/cnpm/cnpmjs.org",
|
||||
"repository": {
|
||||
@@ -92,10 +90,10 @@
|
||||
"registry"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 1.0.0"
|
||||
"node": ">= 4.3.1"
|
||||
},
|
||||
"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"
|
||||
|
||||
@@ -63,8 +63,21 @@ hr {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
.yue h4,
|
||||
.yue h5,
|
||||
.yue h6 {
|
||||
font-family: "-apple-system", "Georgia", "Xin Gothic", "Hiragino Sans GB", "Droid Sans Fallback", "Microsoft YaHei", "SimSun", sans-serif;
|
||||
font-family: "-apple-system-headline", "Georgia", "Xin Gothic", "Hiragino Sans GB", "Droid Sans Fallback", "Microsoft YaHei", "SimSun", sans-serif;
|
||||
color: #222223;
|
||||
}
|
||||
|
||||
|
||||
@@ -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');
|
||||
@@ -64,9 +65,9 @@ function routes(app) {
|
||||
|
||||
// module
|
||||
// scope package: params: [$name]
|
||||
app.get(/^\/(@[\w\-\.]+\/[\w\-\.]+)$/, syncByInstall, listAllVersions);
|
||||
app.get(/^\/(@[\w\-\.]+\/[^\/]+)$/, syncByInstall, listAllVersions);
|
||||
// scope package: params: [$name, $version]
|
||||
app.get(/^\/(@[\w\-\.]+\/[\w\-\.]+)\/([\w\.\-]+)$/, syncByInstall, getOneVersion);
|
||||
app.get(/^\/(@[\w\-\.]+\/[\w\-\.]+)\/([^\/]+)$/, syncByInstall, getOneVersion);
|
||||
|
||||
app.get('/:name', syncByInstall, listAllVersions);
|
||||
app.get('/:name/:version', syncByInstall, getOneVersion);
|
||||
@@ -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';
|
||||
@@ -74,7 +72,7 @@ exports.plusModuleTotal = function* (data) {
|
||||
row[field] = utility.toSafeNumber(row[field]);
|
||||
}
|
||||
row[field] += data.count;
|
||||
if (row.isDirty) {
|
||||
if (row.changed()) {
|
||||
yield row.save();
|
||||
}
|
||||
|
||||
@@ -96,14 +94,14 @@ exports.plusModuleTotal = function* (data) {
|
||||
row[field] = utility.toSafeNumber(row[field]);
|
||||
}
|
||||
row[field] += data.count;
|
||||
if (row.isDirty) {
|
||||
if (row.changed()) {
|
||||
return yield row.save();
|
||||
}
|
||||
return row;
|
||||
};
|
||||
|
||||
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.findById(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';
|
||||
@@ -14,6 +12,7 @@
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var semver = require('semver');
|
||||
var models = require('../models');
|
||||
var common = require('./common');
|
||||
var Tag = models.Tag;
|
||||
@@ -27,7 +26,6 @@ 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
|
||||
@@ -57,7 +55,7 @@ function stringifyPackage(pkg) {
|
||||
}
|
||||
|
||||
exports.getModuleById = function* (id) {
|
||||
var row = yield Module.find(Number(id));
|
||||
var row = yield Module.findById(Number(id));
|
||||
parseRow(row);
|
||||
return row;
|
||||
};
|
||||
@@ -76,6 +74,20 @@ exports.getModuleByTag = function* (name, tag) {
|
||||
return yield* exports.getModule(tag.name, tag.version);
|
||||
};
|
||||
|
||||
exports.getModuleByRange = function* (name, range) {
|
||||
var rows = yield exports.listModulesByName(name);
|
||||
var versionMap = {};
|
||||
var versions = rows.map(function(row) {
|
||||
versionMap[row.version] = row;
|
||||
return row.version;
|
||||
}).filter(function(version) {
|
||||
return semver.valid(version);
|
||||
});
|
||||
|
||||
var version = semver.maxSatisfying(versions, range);
|
||||
return versionMap[version];
|
||||
};
|
||||
|
||||
exports.getLatestModule = function* (name) {
|
||||
return yield* exports.getModuleByTag(name, 'latest');
|
||||
};
|
||||
@@ -236,10 +248,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) {
|
||||
@@ -284,7 +297,7 @@ exports.saveModule = function* (mod) {
|
||||
item.dist_size = dist.size;
|
||||
item.description = description;
|
||||
|
||||
if (item.isDirty) {
|
||||
if (item.changed()) {
|
||||
item = yield item.save();
|
||||
}
|
||||
var result = {
|
||||
@@ -316,7 +329,7 @@ exports.saveModule = function* (mod) {
|
||||
};
|
||||
|
||||
exports.updateModulePackage = function* (id, pkg) {
|
||||
var mod = yield Module.find(Number(id));
|
||||
var mod = yield Module.findById(Number(id));
|
||||
if (!mod) {
|
||||
// not exists
|
||||
return null;
|
||||
@@ -369,8 +382,9 @@ exports.updateModuleLastModified = function* (name) {
|
||||
if (!row) {
|
||||
return null;
|
||||
}
|
||||
row.gmt_modified = new Date();
|
||||
return yield row.save(['gmt_modified']);
|
||||
// gmt_modified is readonly, we must use setDataValue
|
||||
row.setDataValue('gmt_modified', new Date());
|
||||
return yield row.save();
|
||||
};
|
||||
|
||||
exports.removeModulesByName = function* (name) {
|
||||
@@ -407,7 +421,7 @@ exports.addModuleTag = function* (name, tag, version) {
|
||||
}
|
||||
row.module_id = mod.id;
|
||||
row.version = version;
|
||||
if (row.isDirty) {
|
||||
if (row.changed()) {
|
||||
return yield row.save();
|
||||
}
|
||||
return row;
|
||||
@@ -583,7 +597,7 @@ exports.addKeyword = function* (data) {
|
||||
item = ModuleKeyword.build(data);
|
||||
}
|
||||
item.description = data.description;
|
||||
if (item.isDirty) {
|
||||
if (item.changed()) {
|
||||
// make sure object will change, otherwise will cause empty sql error
|
||||
// @see https://github.com/cnpm/cnpmjs.org/issues/533
|
||||
return yield item.save();
|
||||
|
||||
@@ -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,27 @@ function sendMailToAdmin(err, result, syncTime) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function* checkSyncStatus() {
|
||||
// if source registry not cnpm, ignore it. e.g.: cnpmjs.org source registry is npmjs.org
|
||||
if (!config.sourceNpmRegistryIsCNpm) {
|
||||
return;
|
||||
}
|
||||
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')
|
||||
|
||||
@@ -89,6 +89,13 @@ describe('controllers/registry/package/list.test.js', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should support jsonp', function (done) {
|
||||
request(app.listen())
|
||||
.get('/@cnpmtest/testmodule-list-1?callback=jsonp')
|
||||
.expect(/jsonp\(\{/)
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
it('should 404 when package not exists', function (done) {
|
||||
request(app.listen())
|
||||
.get('/@cnpmtest/not-exists-package')
|
||||
@@ -130,18 +137,17 @@ describe('controllers/registry/package/list.test.js', function () {
|
||||
|
||||
describe('unpublished', function () {
|
||||
before(function (done) {
|
||||
utils.sync('tfs', done);
|
||||
utils.sync('moduletest1', done);
|
||||
});
|
||||
|
||||
it('should show unpublished info', function (done) {
|
||||
mm(config, 'syncModel', 'all');
|
||||
request(app.listen())
|
||||
.get('/tfs')
|
||||
.get('/moduletest1')
|
||||
.expect(404, function (err, res) {
|
||||
should.not.exist(err);
|
||||
var data = res.body;
|
||||
data.time.unpublished.name.should.equal('fengmk2');
|
||||
data.time.unpublished.description.should.equal('tfs');
|
||||
data.time.unpublished.name.should.equal('dead_horse');
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
/**!
|
||||
* cnpmjs.org - test/controllers/registry/package/show.test.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)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -20,15 +18,32 @@ var mm = require('mm');
|
||||
var app = require('../../../../servers/registry');
|
||||
var utils = require('../../../utils');
|
||||
|
||||
describe('controllers/registry/package/show.test.js', function () {
|
||||
describe('test/controllers/registry/package/show.test.js', function () {
|
||||
afterEach(mm.restore);
|
||||
|
||||
before(function (done) {
|
||||
before(function(done) {
|
||||
var pkg = utils.getPackage('@cnpmtest/testmodule-show', '0.0.1', utils.admin);
|
||||
request(app.listen())
|
||||
.put('/' + pkg.name)
|
||||
.set('authorization', utils.adminAuth)
|
||||
.send(pkg)
|
||||
.expect(201, function(err) {
|
||||
should.not.exist(err);
|
||||
pkg = utils.getPackage('@cnpmtest/testmodule-show', '1.1.0', utils.admin);
|
||||
request(app.listen())
|
||||
.put('/' + pkg.name)
|
||||
.set('authorization', utils.adminAuth)
|
||||
.send(pkg)
|
||||
.expect(201, done);
|
||||
});
|
||||
});
|
||||
|
||||
before(function(done) {
|
||||
var pkg = utils.getPackage('@cnpmtest/testmodule-only-beta', '1.0.0-beta.1', utils.admin);
|
||||
request(app.listen())
|
||||
.put('/' + pkg.name)
|
||||
.set('authorization', utils.adminAuth)
|
||||
.send(pkg)
|
||||
.expect(201, done);
|
||||
});
|
||||
|
||||
@@ -45,6 +60,65 @@ describe('controllers/registry/package/show.test.js', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should return max satisfied package with semver range', function (done) {
|
||||
request(app.listen())
|
||||
.get('/@cnpmtest/testmodule-show/^1.0.0')
|
||||
.expect(200, function (err, res) {
|
||||
should.not.exist(err);
|
||||
var data = res.body;
|
||||
data.name.should.equal('@cnpmtest/testmodule-show');
|
||||
data.version.should.equal('1.1.0');
|
||||
data.dist.tarball.should.containEql('/@cnpmtest/testmodule-show/download/@cnpmtest/testmodule-show-1.1.0.tgz');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return max satisfied package with complex semver range', function (done) {
|
||||
request(app.listen())
|
||||
.get('/@cnpmtest/testmodule-show/>1.2.0 <=2 || 0.0.1')
|
||||
.expect(200, function (err, res) {
|
||||
should.not.exist(err);
|
||||
var data = res.body;
|
||||
data.name.should.equal('@cnpmtest/testmodule-show');
|
||||
data.version.should.equal('0.0.1');
|
||||
data.dist.tarball.should.containEql('/@cnpmtest/testmodule-show/download/@cnpmtest/testmodule-show-0.0.1.tgz');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return max satisfied package with *', function (done) {
|
||||
request(app.listen())
|
||||
.get('/@cnpmtest/testmodule-show/*')
|
||||
.expect(200, function (err, res) {
|
||||
should.not.exist(err);
|
||||
var data = res.body;
|
||||
data.name.should.equal('@cnpmtest/testmodule-show');
|
||||
data.version.should.equal('1.1.0');
|
||||
data.dist.tarball.should.containEql('/@cnpmtest/testmodule-show/download/@cnpmtest/testmodule-show-1.1.0.tgz');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the only beta version', function (done) {
|
||||
request(app.listen())
|
||||
.get('/@cnpmtest/testmodule-only-beta/*')
|
||||
.expect(200, function (err, res) {
|
||||
should.not.exist(err);
|
||||
var data = res.body;
|
||||
data.name.should.equal('@cnpmtest/testmodule-only-beta');
|
||||
data.version.should.equal('1.0.0-beta.1');
|
||||
data.dist.tarball.should.containEql('/@cnpmtest/testmodule-only-beta/download/@cnpmtest/testmodule-only-beta-1.0.0-beta.1.tgz');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should support jsonp', function (done) {
|
||||
request(app.listen())
|
||||
.get('/@cnpmtest/testmodule-show/0.0.1?callback=jsonp')
|
||||
.expect(/jsonp\(\{/)
|
||||
.expect(200, done);
|
||||
});
|
||||
|
||||
it('should return latest tag', function (done) {
|
||||
request(app.listen())
|
||||
.get('/@cnpmtest/testmodule-show/latest')
|
||||
@@ -52,7 +126,7 @@ describe('controllers/registry/package/show.test.js', function () {
|
||||
should.not.exist(err);
|
||||
var data = res.body;
|
||||
data.name.should.equal('@cnpmtest/testmodule-show');
|
||||
data.version.should.equal('0.0.1');
|
||||
data.version.should.equal('1.1.0');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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://dn-img-shields-io.qbox.me/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://dn-img-shields-io.qbox.me/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://dn-img-shields-io.qbox.me/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://dn-img-shields-io.qbox.me/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://dn-img-shields-io.qbox.me/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://dn-img-shields-io.qbox.me/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://dn-img-shields-io.qbox.me/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://dn-img-shields-io.qbox.me/badge/downloads-0-brightgreen.svg?style=flat-square')
|
||||
.expect('Location', config.badgePrefixURL + '/downloads-0-brightgreen.svg?style=flat-square')
|
||||
.expect(302, done);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -121,7 +121,7 @@ describe('controllers/web/package/show.test.js', function () {
|
||||
it('should display unpublished info', function (done) {
|
||||
mm(config, 'syncModel', 'all');
|
||||
request(app)
|
||||
.get('/package/tfs')
|
||||
.get('/package/moduletest1')
|
||||
.expect(200)
|
||||
.expect(/This package has been unpublished\./, 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://dn-img-shields-io.qbox.me/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,11 +1,9 @@
|
||||
/**!
|
||||
* cnpmjs.org - test/services/default_user_service.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';
|
||||
@@ -47,7 +45,7 @@ describe('services/default_user_service.test.js', function () {
|
||||
email: 'fengmk2@gmail.com',
|
||||
name: 'cnpmjstest10',
|
||||
html_url: 'http://cnpmjs.org/~cnpmjstest10',
|
||||
avatar_url: 'https://secure.gravatar.com/avatar/95b9d41231617a05ced5604d242c9670?s=50&d=retro',
|
||||
avatar_url: 'https://s.gravatar.com/avatar/95b9d41231617a05ced5604d242c9670?s=50&d=retro',
|
||||
im_url: '',
|
||||
site_admin: true,
|
||||
scopes: ['@cnpm', '@cnpmtest'],
|
||||
@@ -69,7 +67,7 @@ describe('services/default_user_service.test.js', function () {
|
||||
email: 'fengmk2@gmail.com',
|
||||
name: 'cnpmjstest10',
|
||||
html_url: 'http://cnpmjs.org/~cnpmjstest10',
|
||||
avatar_url: 'https://secure.gravatar.com/avatar/95b9d41231617a05ced5604d242c9670?s=50&d=retro',
|
||||
avatar_url: 'https://s.gravatar.com/avatar/95b9d41231617a05ced5604d242c9670?s=50&d=retro',
|
||||
im_url: '',
|
||||
site_admin: true,
|
||||
scopes: ['@cnpm', '@cnpmtest'],
|
||||
@@ -84,7 +82,7 @@ describe('services/default_user_service.test.js', function () {
|
||||
email: 'fengmk2@gmail.com',
|
||||
name: 'cnpmjstest101',
|
||||
html_url: 'http://cnpmjs.org/~cnpmjstest101',
|
||||
avatar_url: 'https://secure.gravatar.com/avatar/95b9d41231617a05ced5604d242c9670?s=50&d=retro',
|
||||
avatar_url: 'https://s.gravatar.com/avatar/95b9d41231617a05ced5604d242c9670?s=50&d=retro',
|
||||
im_url: '',
|
||||
site_admin: false,
|
||||
scopes: ['@cnpm', '@cnpmtest'],
|
||||
@@ -99,7 +97,7 @@ describe('services/default_user_service.test.js', function () {
|
||||
email: 'fengmk2@gmail.com',
|
||||
name: 'Yuan Feng',
|
||||
html_url: 'http://cnpmjs.org/~fengmk2',
|
||||
avatar_url: 'https://secure.gravatar.com/avatar/95b9d41231617a05ced5604d242c9670?s=50&d=retro',
|
||||
avatar_url: 'https://s.gravatar.com/avatar/95b9d41231617a05ced5604d242c9670?s=50&d=retro',
|
||||
im_url: '',
|
||||
site_admin: true,
|
||||
scopes: ['@cnpm', '@cnpmtest'],
|
||||
|
||||
@@ -331,6 +331,36 @@ describe('test/services/package.test.js', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('getModuleByRange()', function() {
|
||||
it('should get undefined when not match semver range', function* () {
|
||||
yield* createModule('test-getModuleByRange-module-0', '1.0.0');
|
||||
yield* createModule('test-getModuleByRange-module-0', '1.1.0');
|
||||
yield* createModule('test-getModuleByRange-module-0', '2.0.0');
|
||||
var mod = yield* Package.getModuleByRange('test-getModuleByRange-module-0', '~2.1.0');
|
||||
should.not.exist(mod);
|
||||
});
|
||||
|
||||
it('should get package with semver range', function* () {
|
||||
yield* createModule('test-getModuleByRange-module-1', '1.0.0');
|
||||
yield* createModule('test-getModuleByRange-module-1', '1.1.0');
|
||||
yield* createModule('test-getModuleByRange-module-1', '2.0.0');
|
||||
var mod = yield* Package.getModuleByRange('test-getModuleByRange-module-1', '1');
|
||||
mod.package.name.should.equal(mod.name);
|
||||
mod.name.should.equal('test-getModuleByRange-module-1');
|
||||
mod.version.should.equal('1.1.0');
|
||||
});
|
||||
|
||||
it('should get package with semver range when have invalid version', function* () {
|
||||
yield* createModule('test-getModuleByRange-module-2', '1.0.0');
|
||||
yield* createModule('test-getModuleByRange-module-2', '1.1.0');
|
||||
yield* createModule('test-getModuleByRange-module-2', 'next');
|
||||
var mod = yield* Package.getModuleByRange('test-getModuleByRange-module-2', '1');
|
||||
mod.package.name.should.equal(mod.name);
|
||||
mod.name.should.equal('test-getModuleByRange-module-2');
|
||||
mod.version.should.equal('1.1.0');
|
||||
});
|
||||
});
|
||||
|
||||
describe('updateModulePackage()', function () {
|
||||
it('should update not exists package return null', function* () {
|
||||
var r = yield* Package.updateModulePackage(101010101, {});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Copyright 2013 - 2014 © cnpmjs.org
|
||||
Copyright 2013 - 2016 © cnpmjs.org
|
||||
|
|
||||
<a href="/">Home</a>
|
||||
|
|
||||
<script>var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_5757157'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s17.cnzz.com/stat.php%3Fid%3D5757157%26online%3D1%26show%3Dline' type='text/javascript'%3E%3C/script%3E"));</script>
|
||||
<script>var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_5757157'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s17.cnzz.com/stat.php%3Fid%3D5757157%26online%3D1%26show%3Dline' type='text/javascript'%3E%3C/script%3E"));</script>
|
||||
|
||||
@@ -136,8 +136,8 @@
|
||||
<div class="pack-dep cols-box-item">
|
||||
<div class="cols-box-title">
|
||||
<%
|
||||
var deps = Object.keys(package.dependencies || {})
|
||||
var l = deps.length
|
||||
var deps = Object.keys(package.dependencies || {});
|
||||
var l = deps.length;
|
||||
%>
|
||||
Dependencies<%= ' (' + l + ')' %>
|
||||
|
||||
@@ -151,7 +151,7 @@
|
||||
<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
|
||||
@@ -160,8 +160,8 @@
|
||||
<div class="pack-dep cols-box-item">
|
||||
<div class="cols-box-title">
|
||||
<%
|
||||
var deps = Object.keys(package.devDependencies || {})
|
||||
var l = deps.length
|
||||
var deps = Object.keys(package.devDependencies || {});
|
||||
var l = deps.length;
|
||||
%>
|
||||
Dev Dependencies<%= ' (' + l + ')' %>
|
||||
|
||||
@@ -175,13 +175,36 @@
|
||||
<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="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>
|
||||
|
||||
@@ -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) { %>
|
||||
|
||||
@@ -20,8 +20,9 @@
|
||||
<small>(<%= user.json.fullname %>)</small>
|
||||
<% } %>
|
||||
|
||||
|
||||
<small>[<a href="/sync/user:<%= user.name %>" target="_blank">SYNC</a> profile]</small>
|
||||
<% if (user.isNpmUser) { %>
|
||||
<small>[<a href="/sync/user:<%= user.name %>" target="_blank">SYNC</a> profile]</small>
|
||||
<% } %>
|
||||
</h2>
|
||||
<div class="ant-table">
|
||||
<table class="downloads">
|
||||
|
||||
Reference in New Issue
Block a user