feat: ignore sync private pkg (#1747)
> Ignore sync requests for private pacakges. * update isLocalModule Logic, follow the #privatePackages field in config.
This commit is contained in:
@@ -97,6 +97,9 @@ exports.isMaintainer = function (user, maintainers) {
|
||||
exports.isLocalModule = function (mods) {
|
||||
for (var i = 0; i < mods.length; i++) {
|
||||
var r = mods[i];
|
||||
if (config.privatePackages.includes(r.name)) {
|
||||
return true;
|
||||
}
|
||||
if (r.package && r.package._publish_on_cnpm) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -11,28 +11,50 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const { co } = require('co');
|
||||
const mm = require('mm');
|
||||
const config = require('../../config');
|
||||
const createModule = require('../utils').createModule;
|
||||
const packageService = require('../../services/package');
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var common = require('../../lib/common');
|
||||
|
||||
describe('test/lib/common.test.js', function () {
|
||||
describe('isAdmin()', function () {
|
||||
it('should admin is admin', function () {
|
||||
common.isAdmin('admin').should.equal(true);
|
||||
common.isAdmin('fengmk2').should.equal(true);
|
||||
common.isAdmin('constructor').should.equal(false);
|
||||
common.isAdmin('toString').should.equal(false);
|
||||
describe("test/lib/common.test.js", function () {
|
||||
describe("isAdmin()", function () {
|
||||
it("should admin is admin", function () {
|
||||
common.isAdmin("admin").should.equal(true);
|
||||
common.isAdmin("fengmk2").should.equal(true);
|
||||
common.isAdmin("constructor").should.equal(false);
|
||||
common.isAdmin("toString").should.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getCDNKey()', function () {
|
||||
it('should auto fix scope filename', function () {
|
||||
common.getCDNKey('foo', 'foo-1.0.0.tgz').should.equal('/foo/-/foo-1.0.0.tgz');
|
||||
common.getCDNKey('@bar/foo', 'foo-1.0.0.tgz').should.equal('/@bar/foo/-/@bar/foo-1.0.0.tgz');
|
||||
common.getCDNKey('@bar/foo', '@bar/foo-1.0.0.tgz').should.equal('/@bar/foo/-/@bar/foo-1.0.0.tgz');
|
||||
common.getCDNKey('@bar/foo', '@bar1/foo-1.0.0.tgz').should.equal('/@bar/foo/-/@bar1/foo-1.0.0.tgz');
|
||||
describe("getCDNKey()", function () {
|
||||
it("should auto fix scope filename", function () {
|
||||
common
|
||||
.getCDNKey("foo", "foo-1.0.0.tgz")
|
||||
.should.equal("/foo/-/foo-1.0.0.tgz");
|
||||
common
|
||||
.getCDNKey("@bar/foo", "foo-1.0.0.tgz")
|
||||
.should.equal("/@bar/foo/-/@bar/foo-1.0.0.tgz");
|
||||
common
|
||||
.getCDNKey("@bar/foo", "@bar/foo-1.0.0.tgz")
|
||||
.should.equal("/@bar/foo/-/@bar/foo-1.0.0.tgz");
|
||||
common
|
||||
.getCDNKey("@bar/foo", "@bar1/foo-1.0.0.tgz")
|
||||
.should.equal("/@bar/foo/-/@bar1/foo-1.0.0.tgz");
|
||||
});
|
||||
});
|
||||
|
||||
describe("isLocalModule", function () {
|
||||
it("should ignore private packages", function * () {
|
||||
yield createModule("banana", "1.0.0");
|
||||
const modules = yield packageService.listModulesByName('banana');
|
||||
mm(config, "privatePackages", ["banana"]);
|
||||
common.isLocalModule(modules).should.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user