Compare commits
1 Commits
2.19.4
...
fix-qs-sec
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb164900aa |
@@ -1,10 +1,4 @@
|
||||
|
||||
2.19.4 / 2017-03-26
|
||||
==================
|
||||
|
||||
* feat: need to sync sourceNpmRegistry also (#1153)
|
||||
* docs: change user.json to utf8mb4
|
||||
|
||||
2.19.3 / 2017-02-22
|
||||
==================
|
||||
|
||||
|
||||
@@ -292,19 +292,6 @@ SyncModuleWorker.prototype.next = function* (concurrencyId) {
|
||||
return setImmediate(this.finish.bind(this));
|
||||
}
|
||||
|
||||
// try to sync from official replicate when source npm registry is not cnpmjs.org
|
||||
const registry = config.sourceNpmRegistryIsCNpm ? config.sourceNpmRegistry : config.officialNpmReplicate;
|
||||
|
||||
const versions = yield this.syncByName(concurrencyId, name, registry);
|
||||
if (versions && versions.length === 0 && registry === config.officialNpmReplicate) {
|
||||
// need to sync sourceNpmRegistry also
|
||||
// make sure package data be update event replicate down.
|
||||
// https://github.com/npm/registry/issues/129
|
||||
yield this.syncByName(concurrencyId, name, config.officialNpmRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
SyncModuleWorker.prototype.syncByName = function* (concurrencyId, name, registry) {
|
||||
var that = this;
|
||||
that.syncingNames[name] = true;
|
||||
var pkg = null;
|
||||
@@ -322,6 +309,8 @@ SyncModuleWorker.prototype.syncByName = function* (concurrencyId, name, registry
|
||||
|
||||
// get from npm
|
||||
const packageUrl = '/' + name.replace('/', '%2f');
|
||||
// try to sync from official replicate when source npm registry is not cnpmjs.org
|
||||
const registry = config.sourceNpmRegistryIsCNpm ? config.sourceNpmRegistry : config.officialNpmReplicate;
|
||||
try {
|
||||
var result = yield npmSerivce.request(packageUrl, { registry: registry });
|
||||
pkg = result.data;
|
||||
@@ -405,6 +394,13 @@ SyncModuleWorker.prototype.syncByName = function* (concurrencyId, name, registry
|
||||
return;
|
||||
}
|
||||
|
||||
// if (versions.length === 0 && registry === config.officialNpmReplicate) {
|
||||
// // TODO:
|
||||
// // need to sync sourceNpmRegistry also
|
||||
// // make sure package data be update event replicate down.
|
||||
// // https://github.com/npm/registry/issues/129
|
||||
// }
|
||||
|
||||
// has new version
|
||||
if (versions.length > 0) {
|
||||
that.updates.push(name);
|
||||
@@ -413,8 +409,6 @@ SyncModuleWorker.prototype.syncByName = function* (concurrencyId, name, registry
|
||||
this.log('[c#%d] [%s] synced success, %d versions: %s',
|
||||
concurrencyId, name, versions.length, versions.join(', '));
|
||||
yield this._doneOne(concurrencyId, name, true);
|
||||
|
||||
return versions;
|
||||
};
|
||||
|
||||
function* _listStarUsers(modName) {
|
||||
|
||||
@@ -18,7 +18,6 @@ CREATE TABLE IF NOT EXISTS `user` (
|
||||
-- ALTER TABLE `user`
|
||||
-- ADD `json` longtext CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT 'json details',
|
||||
-- ADD `npm_user` tinyint(1) DEFAULT '0' COMMENT 'user sync from npm or not, 1: true, other: false';
|
||||
-- ALTER TABLE `user` CHANGE `json` `json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'json details';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `module_keyword` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'primary key',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cnpmjs.org",
|
||||
"version": "2.19.4",
|
||||
"version": "2.19.3",
|
||||
"description": "Private npm registry and web for Enterprise, base on MySQL and Simple Store Service",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@@ -36,6 +36,7 @@
|
||||
"is-type-of": "^1.0.0",
|
||||
"kcors": "^1.2.1",
|
||||
"koa": "^1.2.0",
|
||||
"koa-bodyparser": "^2.4.0",
|
||||
"koa-limit": "^1.0.2",
|
||||
"koa-markdown": "^2.0.1",
|
||||
"koa-maxrequests": "^1.0.0",
|
||||
|
||||
@@ -14,6 +14,7 @@ var notFound = require('../middleware/registry_not_found');
|
||||
var cors = require('kcors');
|
||||
var proxyToNpm = require('../middleware/proxy_to_npm');
|
||||
var maxrequests = require('koa-maxrequests');
|
||||
var bodyParser = require('koa-bodyparser');
|
||||
|
||||
app.use(maxrequests());
|
||||
app.use(block());
|
||||
@@ -24,7 +25,7 @@ app.use(staticCache);
|
||||
|
||||
app.keys = ['todokey', config.sessionSecret];
|
||||
app.proxy = true;
|
||||
app.use(middlewares.bodyParser({ jsonLimit: config.jsonLimit }));
|
||||
app.use(bodyParser({ jsonLimit: config.jsonLimit }));
|
||||
app.use(cors({
|
||||
allowMethods: 'GET,HEAD',
|
||||
}));
|
||||
|
||||
@@ -18,6 +18,7 @@ var http = require('http');
|
||||
var koa = require('koa');
|
||||
var fs = require('fs');
|
||||
var maxrequests = require('koa-maxrequests');
|
||||
var bodyParser = require('koa-bodyparser');
|
||||
|
||||
var app = koa();
|
||||
|
||||
@@ -43,7 +44,7 @@ app.proxy = true;
|
||||
app.use(proxyToNpm({
|
||||
isWeb: true
|
||||
}));
|
||||
app.use(middlewares.bodyParser());
|
||||
app.use(bodyParser({ jsonLimit: config.jsonLimit }));
|
||||
app.use(auth());
|
||||
app.use(notFound);
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ describe('test/sync/sync_exist.test.js', function () {
|
||||
it('should sync first time ok', function *() {
|
||||
mm.data(npmService, 'getShort', ['byte']);
|
||||
mm.data(totalService, 'getTotalInfo', {last_exist_sync_time: 0});
|
||||
var data = yield sync();
|
||||
data.successes[0].should.equal('byte');
|
||||
var data = yield* sync();
|
||||
data.successes.should.eql(['byte']);
|
||||
});
|
||||
|
||||
it('should sync common ok', function *() {
|
||||
@@ -47,7 +47,7 @@ describe('test/sync/sync_exist.test.js', function () {
|
||||
});
|
||||
mm.data(totalService, 'getTotalInfo', {last_exist_sync_time: Date.now()});
|
||||
var data = yield* sync();
|
||||
data.successes[0].should.equal('byte');
|
||||
data.successes.should.eql(['byte']);
|
||||
|
||||
mm.data(npmService, 'getAllSince', []);
|
||||
var data = yield* sync();
|
||||
@@ -62,7 +62,7 @@ describe('test/sync/sync_exist.test.js', function () {
|
||||
]);
|
||||
mm.data(totalService, 'getTotalInfo', {last_exist_sync_time: Date.now()});
|
||||
var data = yield* sync();
|
||||
data.successes[0].should.equal('byte');
|
||||
data.successes.should.eql(['byte']);
|
||||
|
||||
mm.data(npmService, 'getAllSince', []);
|
||||
var data = yield* sync();
|
||||
|
||||
Reference in New Issue
Block a user