Compare commits

...

95 Commits

Author SHA1 Message Date
fengmk2
1b04d59539 Release 2.10.0 2016-04-15 23:45:54 +08:00
fengmk2
e6998506f3 feat: show tarball url on package page (#894)
closes #893
2016-04-15 23:44:07 +08:00
Greenkeeper
576397b2b0 chore(package): update koa-mock to version 1.6.1 (#891)
http://greenkeeper.io/
2016-04-13 16:53:16 +08:00
Greenkeeper
6c1935bc61 chore(package): update koa-mock to version 1.6.0 (#890)
http://greenkeeper.io/
2016-04-13 09:58:15 +08:00
fengmk2
1e68cfa568 Release 2.9.5 2016-04-12 11:24:10 +08:00
fengmk2
8188d9a07a fix: change logo url to a better https source
closes #887
2016-04-12 11:21:58 +08:00
Nimo Chu
d7ae8d28c1 fix: http://cnpmjs.org/package/fms pre style (#739) 2016-04-09 12:38:30 +08:00
fengmk2
afa5639752 Release 2.9.4 2016-04-09 12:34:39 +08:00
fengmk2
e0213e18a0 fix: don't sync constructor package on exists mode (#883)
closes #857
2016-04-09 12:33:52 +08:00
Greenkeeper
a74d60c7eb Update utility to version 1.7.0 🚀
http://greenkeeper.io/
2016-04-07 09:22:29 +08:00
fengmk2
fcabc49d39 chore: update sponsor link 2016-04-05 23:06:48 +08:00
fengmk2
ad0722b57b Release 2.9.3 2016-04-05 22:39:37 +08:00
fengmk2
6e11a2c8a7 fix: use better diff time to check sync status
closes #858
2016-04-05 15:43:29 +08:00
Greenkeeper
0329cfad61 Update sequelize to version 3.21.0 🚀
http://greenkeeper.io/
2016-04-04 17:19:45 +08:00
Yiyu He
ede8a3ce5f Merge pull request #876 from cnpm/greenkeeper-agentkeepalive-2.1.0
Update agentkeepalive to version 2.1.0 🚀
2016-04-02 17:49:39 +08:00
greenkeeperio-bot
cde4f2179e chore(package): update agentkeepalive to version 2.1.0
http://greenkeeper.io/
2016-04-02 11:04:29 +08:00
Yiyu He
374dc17a6b Merge pull request #875 from cnpm/greenkeeper-pg-4.5.2
Update pg to version 4.5.2 🚀
2016-03-31 01:41:35 +08:00
greenkeeperio-bot
626259c379 chore(package): update pg to version 4.5.2
http://greenkeeper.io/
2016-03-31 01:33:38 +08:00
fengmk2
36644bda67 Release 2.9.2 2016-03-29 17:56:05 +08:00
fengmk2
236e9e2fb3 Merge pull request #874 from dickeylth/master
fix: override antd for ul & ol list number & icon.
2016-03-29 17:54:06 +08:00
dickeylth
b551216517 Update main.css
override antd for ul & ol list number & icon.
2016-03-29 17:15:28 +08:00
dead_horse
c8d9d9f075 Release 2.9.1 2016-03-29 15:31:52 +08:00
Yiyu He
4d43588b10 Merge pull request #872 from cnpm/add-more-ua-info-on-syncer
refactor: add more ua info on syncer
2016-03-29 15:31:04 +08:00
fengmk2
5f71add418 refactor: add more ua info on syncer 2016-03-29 14:53:05 +08:00
fengmk2
3fcfc6306d Release 2.9.0 2016-03-26 11:16:22 +08:00
fengmk2
e78c774dbf Merge pull request #867 from cnpm/unpublish
feat: only admin can unpublish
2016-03-26 11:14:58 +08:00
dead_horse
6a54b1328f feat: only admin can unpublish 2016-03-25 17:50:24 +08:00
Yiyu He
47c8273b7d Merge pull request #864 from cnpm/greenkeeper-gravatar-1.5.0
Update gravatar to version 1.5.0 🚀
2016-03-22 11:28:49 +08:00
greenkeeperio-bot
0f01a4c076 chore(package): update gravatar to version 1.5.0
http://greenkeeper.io/
2016-03-22 08:14:10 +08:00
Yiyu He
17b43e3ae4 Merge pull request #862 from cnpm/greenkeeper-sequelize-3.20.0
Update sequelize to version 3.20.0 🚀
2016-03-22 01:35:42 +08:00
greenkeeperio-bot
7fd6b10ddf chore(package): update sequelize to version 3.20.0
http://greenkeeper.io/
2016-03-21 23:17:54 +08:00
Yiyu He
7f16050f9e Merge pull request #856 from cnpm/fix-download-count
fix: fix save download count unqiue constraint error
2016-03-14 10:46:41 +08:00
dead_horse
f57d525452 fix: fix save download count unqiue constraint error 2016-03-10 18:23:26 +08:00
fengmk2
f05046b8bd Merge pull request #854 from cnpm/greenkeeper-moment-2.12.0
Update moment to version 2.12.0 🚀
2016-03-07 22:37:30 +08:00
greenkeeperio-bot
a34aa7d72f chore(package): update moment to version 2.12.0
http://greenkeeper.io/
2016-03-07 17:28:42 +08:00
fengmk2
72646ffee2 Release 2.8.1 2016-03-07 02:11:24 +08:00
fengmk2
060fc65ffb Merge pull request #853 from cnpm/fix-sync-expired-notice
fix: only send warning email if no any sync data after 24h
2016-03-07 02:10:32 +08:00
fengmk2
4169ee9c6e fix: only send warning email if no any sync data after 24h 2016-03-07 02:02:46 +08:00
fengmk2
51f380a800 Merge pull request #852 from cnpm/greenkeeper-kcors-1.1.0
Update kcors to version 1.1.0 🚀
2016-03-07 01:50:39 +08:00
greenkeeperio-bot
c90062e7a0 chore(package): update kcors to version 1.1.0
http://greenkeeper.io/
2016-03-07 01:34:40 +08:00
Yiyu He
26007f8318 Merge pull request #848 from cnpm/greenkeeper-koa-1.2.0
Update koa to version 1.2.0 🚀
2016-03-04 12:18:11 +08:00
greenkeeperio-bot
0146ce5c30 chore(package): update koa to version 1.2.0
http://greenkeeper.io/
2016-03-04 11:34:46 +08:00
Yiyu He
87518df394 Merge pull request #846 from cnpm/greenkeeper-urllib-2.8.0
Update urllib to version 2.8.0 🚀
2016-02-28 17:29:21 +08:00
greenkeeperio-bot
e49f5474f6 chore(package): update urllib to version 2.8.0
http://greenkeeper.io/
2016-02-27 21:46:55 +08:00
fengmk2
af4401fc62 Release 2.8.0 2016-02-23 14:46:37 +08:00
fengmk2
c2d608a5cc Merge pull request #841 from cnpm/fix-range-version-for-beta-version
fix: convert `*` to latest tag
2016-02-23 14:45:39 +08:00
fengmk2
b91b160b66 fix: convert * to latest tag
closes #840
2016-02-23 14:32:59 +08:00
fengmk2
46a3df95bd Merge pull request #837 from cnpm/deps
deps: upgrade deps and remove node 2.0.0 support
2016-02-23 14:15:19 +08:00
fengmk2
d08aee047e deps: upgrade deps and remove node 2.0.0 support 2016-02-23 13:59:11 +08:00
fengmk2
406d8cf9a1 doc: update sponsors on readme 2016-02-20 02:14:00 +08:00
fengmk2
e1b9ab6b09 fix: update copyright year 2016-02-20 02:06:14 +08:00
fengmk2
71f9014777 doc: fix disturl typo
Add aliyun to sponsors
2016-02-20 02:01:51 +08:00
fengmk2
adca5adff2 Merge pull request #822 from cnpm/sequelize
deps: sequelize@3.19.0
2016-02-19 23:35:25 +08:00
dead_horse
1857f1d0e5 deps: sequelize@3.19.0 2016-02-02 16:32:41 +08:00
dead_horse
2d56820e8b Release 2.7.1 2016-02-01 14:02:02 +08:00
Yiyu He
119094b230 Merge pull request #817 from cnpm/fix-semver
fix(semver): when have invalid version
2016-02-01 14:00:43 +08:00
dead_horse
744b6e1e15 fix(semver): when have invalid version 2016-02-01 13:55:12 +08:00
fengmk2
17f47732a0 Release 2.7.0 2016-02-01 13:16:35 +08:00
fengmk2
3a46b97544 Merge pull request #816 from cnpm/feat-semver
feat: support semver
2016-02-01 11:56:21 +08:00
dead_horse
44976f4afa test: fix all test cases 2016-02-01 01:42:09 +08:00
dead_horse
9da7c6ccf2 test: fix unpublish 2016-01-31 00:14:46 +08:00
dead_horse
4b68eecf53 test: add complex range test case 2016-01-30 23:08:27 +08:00
dead_horse
8d7058b947 feat: support semver
e.x. `/npm/~1.0.0`
2016-01-30 20:42:59 +08:00
dead_horse
933ae69d0b Release 2.6.2 2016-01-19 11:44:23 +08:00
Yiyu He
1af36f0a7a Merge pull request #799 from cnpm/jsonp
feat: list & show support jsonp
2016-01-19 11:43:24 +08:00
dead_horse
f4e9de5094 feat: list & show support jsonp 2016-01-18 11:07:21 +08:00
Yiyu He
2ccaf404ab Merge pull request #795 from cnpm/greenkeeper-urllib-2.7.0
Update urllib to version 2.7.0 🚀
2016-01-14 11:11:53 +08:00
greenkeeperio-bot
44c79c7646 chore(package): update urllib to version 2.7.0
http://greenkeeper.io/
2016-01-14 01:30:25 +08:00
alsotang
a845d3f74d Delete install.md
this file is deprecated, see https://github.com/cnpm/cnpmjs.org/wiki/Deploy for deploy
2016-01-13 11:54:59 +08:00
fengmk2
730113424c Release 2.6.1 2016-01-12 17:34:23 +08:00
fengmk2
658be3004f fix: source registry is not cnpm, ignore check status 2016-01-12 17:33:53 +08:00
fengmk2
214d0ad5c3 Release 2.6.0 2016-01-12 11:54:25 +08:00
Yiyu He
ca70c8a06d Merge pull request #786 from cnpm/add-sync-expired-check
feat(sync): monitor sync status
2016-01-12 10:20:02 +08:00
fengmk2
1c680367a7 feat(sync): monitor sync status
if last_sync_time > 2 x syncInterval, send the expired
warning message to admin
2016-01-12 10:11:20 +08:00
Yiyu He
3bd43d5ba9 Merge pull request #759 from cnpm/greenkeeper-urllib-2.6.0
Update urllib to version 2.6.0 🚀
2016-01-07 00:25:43 +08:00
Yiyu He
0965f8f8e5 Merge pull request #779 from cnpm/greenkeeper-agentkeepalive-2.0.3
Update agentkeepalive to version 2.0.3 🚀
2016-01-06 10:47:57 +08:00
greenkeeperio-bot
005eb603ae chore(package): update agentkeepalive to version 2.0.3
http://greenkeeper.io/
2016-01-05 20:40:22 +08:00
Yiyu He
65a9303dff Merge pull request #777 from gniavaj/master
fix SequelizeDatabaseError: ER_NO_SUCH_TABLE: Table 'qnpm.total' does…
2016-01-05 16:26:36 +08:00
gniavaj
3bc6b625ec fix SequelizeDatabaseError: ER_NO_SUCH_TABLE: Table 'qnpm.total' doesn't exist\nreproduce this bug:\nthe first startup of cnpmjs.org 2016-01-04 21:43:50 +08:00
Yiyu He
2b0dc6d17f Merge pull request #773 from cnpm/greenkeeper-moment-2.11.0
Update moment to version 2.11.0 🚀
2016-01-04 10:39:49 +08:00
Yiyu He
842d790dcb Merge pull request #774 from cnpm/greenkeeper-xss-0.2.10
xss@0.2.10 breaks build 🚨
2016-01-04 10:37:26 +08:00
greenkeeperio-bot
20eac48349 chore(package): update moment to version 2.11.0
http://greenkeeper.io/
2016-01-03 07:42:58 +08:00
greenkeeperio-bot
efb80e8c33 chore(package): update xss to version 0.2.10
http://greenkeeper.io/
2015-12-23 12:42:54 +08:00
alsotang
35fbc651cd remove bluebird
same as #767
2015-12-17 13:34:33 +08:00
Yiyu He
e55779ffa7 Merge pull request #767 from liyangready/master
remove bluebird
2015-12-17 11:12:23 +08:00
leon.lee
878176ea9c remove bluebird
maybe forget remove bluebird in this file
2015-12-17 11:08:49 +08:00
Yiyu He
e3a2eab000 Merge pull request #764 from cnpm/greenkeeper-pg-hstore-2.3.2
pg-hstore@2.3.2 breaks build ⚠️
2015-12-14 15:54:29 +08:00
greenkeeperio-bot
7478846754 chore(package): update pg-hstore to version 2.3.2
http://greenkeeper.io/
2015-12-14 08:31:56 +08:00
Yiyu He
8b244e6c26 Merge pull request #761 from cnpm/greenkeeper-mini-logger-1.1.0
Update mini-logger to version 1.1.0 🚀
2015-12-12 00:10:05 +08:00
greenkeeperio-bot
19217de010 chore(package): update mini-logger to version 1.1.0
http://greenkeeper.io/
2015-12-11 12:04:38 +08:00
greenkeeperio-bot
93a57b5dae chore(package): update urllib to version 2.6.0
http://greenkeeper.io/
2015-12-09 14:13:25 +08:00
Yiyu He
defb447f29 Merge pull request #756 from cnpm/fix-package-decode-error
fix: row.package will json parse error
2015-12-08 20:45:03 +08:00
fengmk2
93b73de164 Merge pull request #754 from cnpm/remove_bluebird
remove bluebird
2015-12-08 16:44:50 +08:00
fengmk2
ffc6124c0e fix: row.package will json parse error
need to ignore it.

also remove array.map on parseRow
2015-12-08 16:20:47 +08:00
Jackson Tian
ab40a992c2 remove bluebird 2015-12-08 12:03:36 +08:00
39 changed files with 458 additions and 304 deletions

View File

@@ -1,11 +1,10 @@
sudo: false
language: node_js
node_js:
- '2'
- '4'
- '5'
addons:
- postgresql: '9.3'
script: 'make test-travis-all'
after_script:
- "npm i codecov.io && cat ./coverage/coverage.json | ./node_modules/codecov.io/bin/codecov.io.js"
- 'npm i codecov && codecov'

View File

@@ -6,4 +6,6 @@ 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)
dickeylth <dickeylth@gmail.com> (https://github.com/dickeylth)

View File

@@ -1,4 +1,108 @@
2.10.0 / 2016-04-15
==================
* feat: show tarball url on package page (#894)
* chore(package): update koa-mock to version 1.6.1 (#891)
2.9.5 / 2016-04-12
==================
* fix: change logo url to a better https source
* fix: http://cnpmjs.org/package/fms pre style (#739)
2.9.4 / 2016-04-09
==================
* fix: don't sync constructor package on exists mode (#883)
* Update utility to version 1.7.0 🚀
* chore: update sponsor link
2.9.3 / 2016-04-05
==================
* fix: use better diff time to check sync status
* Update sequelize to version 3.21.0 🚀
* chore(package): update agentkeepalive to version 2.1.0
* chore(package): update pg to version 4.5.2
2.9.2 / 2016-03-29
==================
* fix: override antd for ul & ol list number & icon.
2.9.1 / 2016-03-29
==================
* refactor: add more ua info on syncer
2.9.0 / 2016-03-26
==================
* feat: only admin can unpublish
* chore(package): update gravatar to version 1.5.0
* chore(package): update sequelize to version 3.20.0
* fix: fix save download count unqiue constraint error
* chore(package): update moment to version 2.12.0
2.8.1 / 2016-03-07
==================
* fix: only send warning email if no any sync data after 24h
* chore(package): update kcors to version 1.1.0
* chore(package): update koa to version 1.2.0
* chore(package): update urllib to version 2.8.0
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
==================
@@ -59,7 +163,7 @@
* Add mock data.
* refactor: add more sync log
* Fix sidebar overflow.
* Merge pull request #680 from ibigbug/ant-design
* 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
@@ -156,10 +260,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
==================

View File

@@ -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) test/init_db.js
@node test/init_db.js
init-mysql:
@mysql -uroot -e 'DROP DATABASE IF EXISTS cnpmjs_test;'
@@ -38,7 +31,7 @@ test: install init-database
--timeout $(TIMEOUT) \
--require should \
--require should-http \
--require co-mocha \
--require thunk-mocha \
--require ./test/init.js \
$(MOCHA_OPTS) \
$(TESTS)
@@ -55,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)
@@ -75,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)
@@ -103,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
@@ -112,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

View File

@@ -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
- [![UCloud云计算](https://www.ucloud.cn/static/style/images/about/logo.png)](http://www.ucloud.cn?sem=sdk-CNPMJS)
- [![阿里云](https://static.aliyun.com/images/www-summerwind/logo.gif)](http://click.aliyun.com/m/4288/) (2016.2 - now)
- [![UCloud云计算](https://www.ucloud.cn/static/style/images/about/logo.png)](http://www.ucloud.cn?sem=sdk-CNPMJS) (2015.3 - 2016.3)
## License

View File

@@ -83,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 + '');
}
@@ -105,7 +106,7 @@ function stop(options) {
}
}
function initDatabase() {
function initDatabase(callback) {
var models = require('../models');
models.sequelize.sync({ force: false })
@@ -117,6 +118,7 @@ function initDatabase() {
throw err;
} else {
console.log('[models/init_script.js] `sqlite` sequelize sync and init success');
callback();
}
});
})

View File

@@ -1,4 +1,4 @@
/**!
/**
* Copyright(c) cnpmjs.org and other contributors.
* MIT Licensed
*
@@ -93,7 +93,7 @@ var config = {
}
},
logoURL: '//ww4.sinaimg.cn/large/69c1d4acgw1ebfly5kjlij208202oglr.jpg', // cnpm logo image url
logoURL: 'https://os.alipayobjects.com/rmsportal/oygxuIUkkrRccUz.jpg', // cnpm logo image url
adBanner: '',
customReadmeFile: '', // you can use your custom readme file instead the cnpm one
customFooter: '', // you can add copyright and site total script html here

View File

@@ -107,10 +107,12 @@ defer.setInterval(function* () {
try {
yield* downloadTotalService.plusModuleTotal({ name: name, date: date, count: count });
} catch (err) {
err.message += '; name: ' + name + ', count: ' + count + ', date: ' + date;
logger.error(err);
if (err.name !== 'SequelizeUniqueConstraintError') {
err.message += '; name: ' + name + ', count: ' + count + ', date: ' + date;
logger.error(err);
}
// save back to _downloads, try again next time
_downloads[name] = (_downloads[name] || 0) + count;
}
}
}, 5000);
}, 5000 + Math.ceil(Math.random() * 1000));

View File

@@ -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;
};

View File

@@ -30,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;
@@ -44,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
};
@@ -59,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);

View File

@@ -38,7 +38,11 @@ var User = require('../models').User;
var os = require('os');
var USER_AGENT = 'sync.cnpmjs.org/' + config.version +
' hostname/' + os.hostname() + ' ' + urllib.USER_AGENT;
' hostname/' + os.hostname() +
' syncModel/' + config.syncModel +
' syncInterval/' + config.syncInterval +
' syncConcurrency/' + config.syncConcurrency +
' ' + urllib.USER_AGENT;
function SyncModuleWorker(options) {
EventEmitter.call(this);

View File

@@ -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
```

View File

@@ -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">
@@ -65,7 +65,7 @@ Default style is `flat-square`.
### Version
Badge URL: `http://cnpmjs.org/badge/v/cnpmjs.org.svg` ![cnpmjs.org-version-badge](//cnpmjs.org/badge/v/cnpmjs.org.svg)
Badge URL: `https://cnpmjs.org/badge/v/cnpmjs.org.svg` ![cnpmjs.org-version-badge](//cnpmjs.org/badge/v/cnpmjs.org.svg)
* `<0.1.0 & >=0.0.0`: ![red-badge](https://dn-img-shields-io.qbox.me/badge/cnpm-0.0.1-red.svg?style=flat-square)
* `<1.0.0 & >=0.1.0`: ![red-badge](https://dn-img-shields-io.qbox.me/badge/cnpm-0.1.0-green.svg?style=flat-square)
@@ -73,34 +73,34 @@ Badge URL: `http://cnpmjs.org/badge/v/cnpmjs.org.svg` ![cnpmjs.org-version-badge
### Downloads
Badge URL: `http://cnpmjs.org/badge/d/cnpmjs.org.svg` ![cnpmjs.org-download-badge](//cnpmjs.org/badge/d/cnpmjs.org.svg)
Badge URL: `https://cnpmjs.org/badge/d/cnpmjs.org.svg` ![cnpmjs.org-download-badge](//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
- [![UCloud云计算](https://www.ucloud.cn/static/style/images/about/logo.png)](http://www.ucloud.cn?sem=sdk-CNPMJS)
- [![阿里云](https://static.aliyun.com/images/www-summerwind/logo.gif)](http://click.aliyun.com/m/4288/) (2016.2 - now)
- [![UCloud云计算](https://www.ucloud.cn/static/style/images/about/logo.png)](http://www.ucloud.cn?sem=sdk-CNPMJS) (2015.3 - 2016.3)

View File

@@ -0,0 +1,24 @@
/**!
* cnpmjs.org - middleware/unpublishable.js
*
* Copyright(c) cnpmjs.org and other contributors.
* MIT Licensed
*
* Authors:
* dead_horse <dead_horse@qq.com>
*/
'use strict';
module.exports = function *unpublishable(next) {
// only admin user can unpublish
if (!this.user.isAdmin) {
this.status = 403;
this.body = {
error: 'no_perms',
reason: 'Only administrators can unpublish module',
};
return;
}
yield next;
};

View File

@@ -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];
}

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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;

View File

@@ -1,6 +1,6 @@
{
"name": "cnpmjs.org",
"version": "2.5.1",
"version": "2.10.0",
"description": "Private npm registry and web for Enterprise, base on MySQL and Simple Store Service",
"main": "index.js",
"scripts": {
@@ -13,52 +13,50 @@
"cnpmjs.org": "bin/cli.js"
},
"dependencies": {
"agentkeepalive": "~1.2.0",
"bluebird": "~3.0.6",
"bytes": "~2.2.0",
"agentkeepalive": "~2.1.0",
"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": "^1.0.0",
"graceful": "~1.0.0",
"gravatar": "~1.1.0",
"gravatar": "~1.5.0",
"humanize-ms": "~1.0.1",
"humanize-number": "~0.0.2",
"is-type-of": "~1.0.0",
"kcors": "~1.0.1",
"koa": "~1.1.0",
"kcors": "~1.1.0",
"koa": "~1.2.0",
"koa-limit": "~1.0.2",
"koa-markdown": "~2.0.1",
"koa-middlewares": "~2.1.0",
"koa-mock": "~1.5.0",
"koa-mock": "~1.6.1",
"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.12.0",
"mysql": "~2.10.2",
"nodemailer": "~1.3.0",
"semver": "~5.1.0",
"sequelize": "~2.0.1",
"sequelize": "~3.21.0",
"thunkify-wrap": "~1.0.4",
"treekill": "~1.0.0",
"tunnel-agent": "^0.4.0",
"urllib": "~2.5.0",
"utility": "~1.6.0",
"xss": "~0.2.8"
"urllib": "~2.8.0",
"utility": "~1.7.0",
"xss": "~0.2.10"
},
"devDependencies": {
"autod": "*",
"chunkstream": "*",
"co-mocha": "*",
"contributors": "*",
"istanbul": "*",
"jshint": "*",
@@ -66,12 +64,13 @@
"mocha": "*",
"node-dev": "*",
"pedding": "*",
"pg": "~4.4.2",
"pg-hstore": "~2.3.1",
"pg": "~4.5.2",
"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": {
@@ -91,7 +90,7 @@
"registry"
],
"engines": {
"node": ">= 2.0.0"
"node": ">= 4.3.1"
},
"author": [
"fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)",

View File

@@ -453,6 +453,7 @@
font-size: 85%;
line-height: 1.45;
background-color: #f7f7f7;
color:#333;
border-radius: 3px;
}

View File

@@ -292,3 +292,6 @@ pre code {
height: 30px;
margin-right: 10px;
}
ul, ol{
list-style: initial;
}

View File

@@ -19,6 +19,7 @@ var publishable = require('../middleware/publishable');
var syncByInstall = require('../middleware/sync_by_install');
var editable = require('../middleware/editable');
var existsPackage = require('../middleware/exists_package');
var unpublishable = require('../middleware/unpublishable');
var showTotal = require('../controllers/total');
@@ -65,9 +66,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);
@@ -94,16 +95,16 @@ function routes(app) {
// delete tarball and remove one version
app.delete(/^\/(@[\w\-\.]+\/[\w\-\.]+)\/download\/(@[\w\-\.]+\/[\w\-\.]+)\/\-rev\/([\w\-\.]+)$/,
login, publishable, editable, removeOneVersion);
app.delete('/:name/download/:filename/-rev/:rev', login, publishable, editable, removeOneVersion);
login, unpublishable, removeOneVersion);
app.delete('/:name/download/:filename/-rev/:rev', login, unpublishable, removeOneVersion);
// update module, unpublish will PUT this
app.put(/^\/(@[\w\-\.]+\/[\w\-\.]+)\/\-rev\/([\w\-\.]+)$/, login, publishable, editable, updatePackage);
app.put('/:name/-rev/:rev', login, publishable, editable, updatePackage);
// remove all versions
app.delete(/^\/(@[\w\-\.]+\/[\w\-\.]+)\/\-rev\/([\w\-\.]+)$/, login, publishable, editable, removePackage);
app.delete('/:name/-rev/:rev', login, publishable, editable, removePackage);
app.delete(/^\/(@[\w\-\.]+\/[\w\-\.]+)\/\-rev\/([\w\-\.]+)$/, login, unpublishable, removePackage);
app.delete('/:name/-rev/:rev', login, unpublishable, removePackage);
// try to create a new user
// https://registry.npmjs.org/-/user/org.couchdb.user:fengmk2

View File

@@ -15,7 +15,6 @@
* Module dependencies.
*/
global.Promise = require('bluebird');
var koa = require('koa');
var app = module.exports = koa();
var http = require('http');

View File

@@ -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');

View File

@@ -72,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();
}
@@ -94,7 +94,7 @@ 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;

View File

@@ -50,5 +50,5 @@ exports.append = function* (id, log) {
};
exports.get = function* (id) {
return yield ModuleLog.find(id);
return yield ModuleLog.findById(id);
};

View File

@@ -1,4 +1,4 @@
/**!
/**
* Copyright(c) cnpm and other contributors.
* MIT Licensed
*
@@ -12,6 +12,7 @@
* Module dependencies.
*/
var semver = require('semver');
var models = require('../models');
var common = require('./common');
var Tag = models.Tag;
@@ -54,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;
};
@@ -73,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');
};
@@ -233,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) {
@@ -281,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 = {
@@ -313,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;
@@ -366,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) {
@@ -404,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;
@@ -580,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();

View File

@@ -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';

View File

@@ -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,30 @@ 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;
var oneDay = 3600000 * 24;
var maxTime = Math.max(oneDay, syncInterval * 2);
if (diff > maxTime) {
var err = new Error('Last sync time is expired in ' + diff + ' ms, lastSyncTime: ' +
new Date(lastSyncTime) + ', maxTime: ' + maxTime + ' ms');
err.name = 'SyncExpiredError';
sendMailToAdmin(err, null, new Date());
}
}

View File

@@ -31,7 +31,7 @@ function intersection(arrOne, arrTwo) {
map[name] = true;
});
arrTwo.forEach(function (name) {
map[name] && results.push(name);
map[name] === true && results.push(name);
});
return results;
}
@@ -48,7 +48,7 @@ module.exports = function* sync() {
var allPackages;
if (!info.last_exist_sync_time) {
var pkgs = yield* npmService.getShort();
var pkgs = yield npmService.getShort();
debug('First time sync all packages from official registry, got %d packages', pkgs.length);
if (info.last_sync_module) {
// start from last success
@@ -74,7 +74,7 @@ module.exports = function* sync() {
fails: []
};
}
debug('Total %d packages to sync', packages.length);
debug('Total %d packages to sync, top 10: %j', packages.length, packages.slice(0, 10));
var worker = new SyncModuleWorker({
username: 'admin',

View File

@@ -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();
});
});

View File

@@ -27,10 +27,10 @@ describe('test/controllers/registry/package/remove.test.js', function () {
afterEach(mm.restore);
before(function (done) {
var pkg = utils.getPackage('@cnpmtest/testmodule-remove-1', '1.0.0', utils.admin);
var pkg = utils.getPackage('@cnpmtest/testmodule-remove-1', '1.0.0', utils.otherUser);
request(app.listen())
.put('/' + pkg.name)
.set('authorization', utils.adminAuth)
.set('authorization', utils.otherUserAuth)
.send(pkg)
.expect(201, done);
});
@@ -56,47 +56,13 @@ describe('test/controllers/registry/package/remove.test.js', function () {
.expect(404, done);
});
it('should delete 403 when user is not admin on config.enablePrivate = true', function (done) {
mm(config, 'enablePrivate', true);
it('should delete 403 when user is not admin', function (done) {
request(app)
.del('/@cnpmtest/testmodule-remove-1/-rev/1')
.set('authorization', utils.otherUserAuth)
.expect({
error: 'no_perms',
reason: 'Private mode enable, only admin can publish this module'
})
.expect(403, done);
});
it('should 400 when scope not exists', function (done) {
request(app)
.del('/@cnpm-not-exists/testmodule-remove-1/-rev/1')
.set('authorization', utils.otherUserAuth)
.expect({
error: 'invalid scope',
reason: 'scope @cnpm-not-exists not match legal scopes: @cnpm, @cnpmtest, @cnpm-test'
})
.expect(400, done);
});
it('should 403 when delete non scoped package', function (done) {
request(app)
.del('/testmodule-remove-1/-rev/1')
.set('authorization', utils.otherUserAuth)
.expect({
error: 'no_perms',
reason: 'only allow publish with @cnpm, @cnpmtest, @cnpm-test scope(s)'
})
.expect(403, done);
});
it('should 403 when user not maintainer', function (done) {
request(app)
.del('/@cnpmtest/testmodule-remove-1/-rev/1')
.set('authorization', utils.otherUserAuth)
.expect({
error: 'forbidden user',
reason: 'cnpmjstest101 not authorized to modify @cnpmtest/testmodule-remove-1'
reason: 'Only administrators can unpublish module'
})
.expect(403, done);
});

View File

@@ -27,10 +27,10 @@ describe('controllers/registry/package/remove_version.test.js', function () {
var lastRev;
before(function (done) {
var pkg = utils.getPackage('@cnpmtest/testmodule-remove_version-1', '0.0.1', utils.admin);
var pkg = utils.getPackage('@cnpmtest/testmodule-remove_version-1', '0.0.1', utils.otherUser);
request(app.listen())
.put('/' + pkg.name)
.set('authorization', utils.adminAuth)
.set('authorization', utils.otherUserAuth)
.send(pkg)
.expect(201, function (err, res) {
should.not.exist(err);
@@ -78,7 +78,7 @@ describe('controllers/registry/package/remove_version.test.js', function () {
.expect(401, done);
});
it('should 403 when auth error', function (done) {
it('should 403 when not admin', function (done) {
request(app)
.del('/@cnpmtest/testmodule-remove_version-1/download/@cnpmtest/testmodule-remove_version-1-0.0.1.tgz/-rev/' + lastRev)
.set('authorization', utils.otherUserAuth)
@@ -94,10 +94,10 @@ describe('controllers/registry/package/remove_version.test.js', function () {
describe('mock error', function () {
before(function (done) {
var pkg = utils.getPackage('@cnpmtest/testmodule-remove_version-1', '0.0.2', utils.admin);
var pkg = utils.getPackage('@cnpmtest/testmodule-remove_version-1', '0.0.2', utils.otherUser);
request(app.listen())
.put('/' + pkg.name)
.set('authorization', utils.adminAuth)
.set('authorization', utils.otherUserAuth)
.send(pkg)
.expect(201, done);
});

View File

@@ -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();
});
});

View File

@@ -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);
});

View File

@@ -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'],

View File

@@ -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, {});

View File

@@ -1,5 +1,5 @@
Copyright 2013 - 2014 &copy; cnpmjs.org
Copyright 2013 - 2016 &copy; 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>

View File

@@ -55,6 +55,11 @@
<% if (!package._publish_on_cnpm) { %>
<a href="https://www.npmjs.org/package/<%= package.name %>" target="_blank">Original npm</a>
<% } %>
<% if (package.dist.tarball) { %>
&middot;
<a href="<%= package.dist.tarball %>" target="_blank">Tarball</a>
<% } %>
</div>
<div class="pack-install">
<pre class="sh">$ <%- config.npmClientName %> install <%= package.name %> <% if (package.preferGlobal) { %>-g<% } %></pre>