mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-30 22:34:10 -05:00
Merge remote-tracking branch 'origin/master' into 4.x
This commit is contained in:
commit
1c301b1c3a
10 changed files with 128 additions and 21 deletions
|
@ -14,3 +14,4 @@ Dockerfile
|
||||||
*.scss
|
*.scss
|
||||||
*.png
|
*.png
|
||||||
*.jpg
|
*.jpg
|
||||||
|
test/unit/partials/
|
||||||
|
|
38
CHANGELOG.md
38
CHANGELOG.md
|
@ -66,6 +66,42 @@ All notable changes to this project will be documented in this file. See [standa
|
||||||
* replaced lunr by lunr-mutable ([#915](https://github.com/verdaccio/verdaccio/issues/915)) ([1602840](https://github.com/verdaccio/verdaccio/commit/1602840))
|
* replaced lunr by lunr-mutable ([#915](https://github.com/verdaccio/verdaccio/issues/915)) ([1602840](https://github.com/verdaccio/verdaccio/commit/1602840))
|
||||||
* verdaccio update notification on CLI ([#988](https://github.com/verdaccio/verdaccio/issues/988)) ([#998](https://github.com/verdaccio/verdaccio/issues/998)) ([bc04703](https://github.com/verdaccio/verdaccio/commit/bc04703))
|
* verdaccio update notification on CLI ([#988](https://github.com/verdaccio/verdaccio/issues/988)) ([#998](https://github.com/verdaccio/verdaccio/issues/998)) ([bc04703](https://github.com/verdaccio/verdaccio/commit/bc04703))
|
||||||
|
|
||||||
|
<a name="3.11.1"></a>
|
||||||
|
## [3.11.1](https://github.com/verdaccio/verdaccio/compare/v3.11.0...v3.11.1) (2019-01-31)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* don’t make change if `time` fields match ([#1167](https://github.com/verdaccio/verdaccio/issues/1167)) ([e62ef8d](https://github.com/verdaccio/verdaccio/commit/e62ef8d))
|
||||||
|
* don’t packages that have no uplinks after reading ([#1204](https://github.com/verdaccio/verdaccio/issues/1204)) ([95686be](https://github.com/verdaccio/verdaccio/commit/95686be))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="3.11.0"></a>
|
||||||
|
# [3.11.0](https://github.com/verdaccio/verdaccio/compare/v3.10.2...v3.11.0) (2019-01-27)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* introduce server keepAliveTimeout into config files ([a359055](https://github.com/verdaccio/verdaccio/commit/a359055))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="3.10.2"></a>
|
||||||
|
## [3.10.2](https://github.com/verdaccio/verdaccio/compare/v3.10.1...v3.10.2) (2019-01-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add logic to catch clause ([#1183](https://github.com/verdaccio/verdaccio/issues/1183)) ([056d396](https://github.com/verdaccio/verdaccio/commit/056d396))
|
||||||
|
* adds _id to normalise metadata ([#1194](https://github.com/verdaccio/verdaccio/issues/1194)) ([e2fa581](https://github.com/verdaccio/verdaccio/commit/e2fa581))
|
||||||
|
* remove some unneeded checks ([#1182](https://github.com/verdaccio/verdaccio/issues/1182)) ([ab56d75](https://github.com/verdaccio/verdaccio/commit/ab56d75))
|
||||||
|
* remove unused object ([#1185](https://github.com/verdaccio/verdaccio/issues/1185)) ([e9b3907](https://github.com/verdaccio/verdaccio/commit/e9b3907))
|
||||||
|
* remove unused parameters from processBody method invocation ([#1184](https://github.com/verdaccio/verdaccio/issues/1184)) ([064f7cf](https://github.com/verdaccio/verdaccio/commit/064f7cf))
|
||||||
|
* remove use of comma separator ([#1186](https://github.com/verdaccio/verdaccio/issues/1186)) ([f20fefa](https://github.com/verdaccio/verdaccio/commit/f20fefa))
|
||||||
|
* remove useless assignment to local variable emailCopy ([#1181](https://github.com/verdaccio/verdaccio/issues/1181)) ([13b8347](https://github.com/verdaccio/verdaccio/commit/13b8347))
|
||||||
|
|
||||||
|
|
||||||
<a name="3.10.1"></a>
|
<a name="3.10.1"></a>
|
||||||
## [3.10.1](https://github.com/verdaccio/verdaccio/compare/v3.10.0...v3.10.1) (2018-12-20)
|
## [3.10.1](https://github.com/verdaccio/verdaccio/compare/v3.10.0...v3.10.1) (2018-12-20)
|
||||||
|
|
||||||
|
@ -1165,4 +1201,4 @@ in [#108](https://github.com/verdaccio/verdaccio/pull/108)
|
||||||
## 22 May 2013, version 0.0.0
|
## 22 May 2013, version 0.0.0
|
||||||
|
|
||||||
- first commits
|
- first commits
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,12 @@ packages:
|
||||||
# if package is not available locally, proxy requests to 'npmjs' registry
|
# if package is not available locally, proxy requests to 'npmjs' registry
|
||||||
proxy: npmjs
|
proxy: npmjs
|
||||||
|
|
||||||
|
# You can specify HTTP/1.1 server keep alive timeout in seconds for incomming connections.
|
||||||
|
# A value of 0 makes the http server behave similarly to Node.js versions prior to 8.0.0, which did not have a keep-alive timeout.
|
||||||
|
# WORKAROUND: Through given configuration you can workaround following issue https://github.com/verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enought.
|
||||||
|
server:
|
||||||
|
keepAliveTimeout: 60
|
||||||
|
|
||||||
# To use `npm audit` uncomment the following section
|
# To use `npm audit` uncomment the following section
|
||||||
middlewares:
|
middlewares:
|
||||||
audit:
|
audit:
|
||||||
|
|
5
src/lib/bootstrap.js
vendored
5
src/lib/bootstrap.js
vendored
|
@ -48,7 +48,10 @@ function startVerdaccio(config: any, cliListen: string, configPath: string, pkgV
|
||||||
// http
|
// http
|
||||||
webServer = http.createServer(app);
|
webServer = http.createServer(app);
|
||||||
}
|
}
|
||||||
|
if (config.server && config.server.keepAliveTimeout) {
|
||||||
|
// $FlowFixMe library definition for node is not up to date (doesn't contain recent 8.0 changes)
|
||||||
|
webServer.keepAliveTimeout = config.server.keepAliveTimeout;
|
||||||
|
}
|
||||||
unlinkAddressPath(addr);
|
unlinkAddressPath(addr);
|
||||||
|
|
||||||
callback(webServer, addr, pkgName, pkgVersion);
|
callback(webServer, addr, pkgName, pkgVersion);
|
||||||
|
|
|
@ -169,7 +169,7 @@ class LocalStorage implements IStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('time' in packageInfo) {
|
if ('time' in packageInfo && !_.isEqual(packageLocalJson.time, packageInfo.time)) {
|
||||||
packageLocalJson.time = packageInfo.time;
|
packageLocalJson.time = packageInfo.time;
|
||||||
change = true;
|
change = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,10 @@ export function normalizePackage(pkg: Package) {
|
||||||
pkg._rev = STORAGE.DEFAULT_REVISION;
|
pkg._rev = STORAGE.DEFAULT_REVISION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_.isString(pkg._id) === false) {
|
||||||
|
pkg._id = pkg.name;
|
||||||
|
}
|
||||||
|
|
||||||
// normalize dist-tags
|
// normalize dist-tags
|
||||||
normalizeDistTags(pkg);
|
normalizeDistTags(pkg);
|
||||||
|
|
||||||
|
@ -93,7 +97,7 @@ export function normalizeContributors(contributors: Array<Author>): Array<Author
|
||||||
return contributors;
|
return contributors;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WHITELIST = ['_rev', 'name', 'versions', 'dist-tags', 'readme', 'time'];
|
export const WHITELIST = ['_rev', 'name', 'versions', 'dist-tags', 'readme', 'time', '_id'];
|
||||||
|
|
||||||
export function cleanUpLinksRef(keepUpLinkData: boolean, result: Package): Package {
|
export function cleanUpLinksRef(keepUpLinkData: boolean, result: Package): Package {
|
||||||
const propertyToKeep = [...WHITELIST];
|
const propertyToKeep = [...WHITELIST];
|
||||||
|
|
|
@ -497,6 +497,10 @@ class Storage implements IStorageHandler {
|
||||||
return callback(ErrorCode.getNotFound(API_ERROR.NO_PACKAGE), null, upLinksErrors);
|
return callback(ErrorCode.getNotFound(API_ERROR.NO_PACKAGE), null, upLinksErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (upLinks.length === 0) {
|
||||||
|
return callback(null, packageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
self.localStorage.updateVersions(name, packageInfo, function(err, packageJsonLocal: Package) {
|
self.localStorage.updateVersions(name, packageInfo, function(err, packageJsonLocal: Package) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
|
|
|
@ -25,6 +25,13 @@ describe('LocalStorage', () => {
|
||||||
const pkgNameScoped = `@scope/${pkgName}-scope`;
|
const pkgNameScoped = `@scope/${pkgName}-scope`;
|
||||||
const tarballName: string = `${pkgName}-add-tarball-1.0.4.tgz`;
|
const tarballName: string = `${pkgName}-add-tarball-1.0.4.tgz`;
|
||||||
const tarballName2: string = `${pkgName}-add-tarball-1.0.5.tgz`;
|
const tarballName2: string = `${pkgName}-add-tarball-1.0.5.tgz`;
|
||||||
|
|
||||||
|
const getStorage = (LocalStorageClass = LocalStorage) => {
|
||||||
|
const config: Config = new AppConfig(configExample);
|
||||||
|
config.self_path = path.join('../partials/store');
|
||||||
|
return new LocalStorageClass(config, Logger.logger);
|
||||||
|
}
|
||||||
|
|
||||||
const getPackageMetadataFromStore = (pkgName: string) => {
|
const getPackageMetadataFromStore = (pkgName: string) => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
storage.getPackageMetadata(pkgName, (err, data ) => {
|
storage.getPackageMetadata(pkgName, (err, data ) => {
|
||||||
|
@ -76,10 +83,7 @@ describe('LocalStorage', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
const config: Config = new AppConfig(configExample);
|
storage = getStorage();
|
||||||
config.self_path = path.join('../partials/store');
|
|
||||||
|
|
||||||
storage = new LocalStorage(config, Logger.logger);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should be defined', () => {
|
test('should be defined', () => {
|
||||||
|
@ -249,16 +253,27 @@ describe('LocalStorage', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('LocalStorage::updateVersions', () => {
|
describe('LocalStorage::updateVersions', () => {
|
||||||
test('should update versions from external source', async (done) => {
|
const metadata = JSON.parse(readMetadata('metadata-update-versions-tags'));
|
||||||
const metadata = JSON.parse(readMetadata('metadata-update-versions-tags'));
|
const pkgName = 'add-update-versions-test-1';
|
||||||
const pkgName = 'add-update-versions-test-1';
|
const version = '1.0.2';
|
||||||
const version = '1.0.2';
|
let _storage;
|
||||||
await addPackageToStore(pkgName, generatePackageTemplate(pkgName));
|
beforeEach(done => {
|
||||||
await addNewVersion(pkgName, '1.0.1');
|
class MockLocalStorage extends LocalStorage {}
|
||||||
await addNewVersion(pkgName, version);
|
// $FlowFixMe
|
||||||
|
MockLocalStorage.prototype._writePackage = jest.fn(LocalStorage.prototype._writePackage)
|
||||||
|
_storage = getStorage(MockLocalStorage);
|
||||||
|
rimRaf(path.join(configExample.storage, pkgName), async () => {
|
||||||
|
await addPackageToStore(pkgName, generatePackageTemplate(pkgName));
|
||||||
|
await addNewVersion(pkgName, '1.0.1');
|
||||||
|
await addNewVersion(pkgName, version);
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
storage.updateVersions(pkgName, metadata, (err, data) => {
|
test('should update versions from external source', async (done) => {
|
||||||
|
_storage.updateVersions(pkgName, metadata, (err, data) => {
|
||||||
expect(err).toBeNull();
|
expect(err).toBeNull();
|
||||||
|
expect(_storage._writePackage).toHaveBeenCalledTimes(1);
|
||||||
expect(data.versions['1.0.1']).toBeDefined();
|
expect(data.versions['1.0.1']).toBeDefined();
|
||||||
expect(data.versions[version]).toBeDefined();
|
expect(data.versions[version]).toBeDefined();
|
||||||
expect(data.versions['1.0.4']).toBeDefined();
|
expect(data.versions['1.0.4']).toBeDefined();
|
||||||
|
@ -273,6 +288,17 @@ describe('LocalStorage', () => {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not update if the metadata match', done => {
|
||||||
|
_storage.updateVersions(pkgName, metadata, e => {
|
||||||
|
expect(e).toBeNull()
|
||||||
|
_storage.updateVersions(pkgName, metadata, err => {
|
||||||
|
expect(err).toBeNull()
|
||||||
|
expect(_storage._writePackage).toHaveBeenCalledTimes(1);
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('LocalStorage::changePackage', () => {
|
describe('LocalStorage::changePackage', () => {
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import fs from 'fs';
|
||||||
|
import rimraf from 'rimraf';
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
import configExample from '../partials/config/index';
|
import configExample from '../partials/config/index';
|
||||||
import AppConfig from '../../../src/lib/config';
|
import AppConfig from '../../../src/lib/config';
|
||||||
|
@ -16,12 +18,12 @@ import {DOMAIN_SERVERS} from '../../functional/config.functional';
|
||||||
|
|
||||||
setup(configExample.logs);
|
setup(configExample.logs);
|
||||||
|
|
||||||
|
const storagePath = path.join(__dirname, '../partials/store/test-storage-store.spec');
|
||||||
const mockServerPort: number = 55548;
|
const mockServerPort: number = 55548;
|
||||||
const generateStorage = async function(port = mockServerPort, configDefault = configExample) {
|
const generateStorage = async function(port = mockServerPort, configDefault = configExample) {
|
||||||
const storageConfig = _.clone(configDefault);
|
const storageConfig = _.clone(configDefault);
|
||||||
const storage = path.join(__dirname, '../partials/store/test-storage-store.spec');
|
|
||||||
storageConfig.self_path = __dirname;
|
storageConfig.self_path = __dirname;
|
||||||
storageConfig.storage = storage;
|
storageConfig.storage = storagePath;
|
||||||
storageConfig.uplinks = {
|
storageConfig.uplinks = {
|
||||||
npmjs: {
|
npmjs: {
|
||||||
url: `http://${DOMAIN_SERVERS}:${port}`
|
url: `http://${DOMAIN_SERVERS}:${port}`
|
||||||
|
@ -37,8 +39,11 @@ const generateStorage = async function(port = mockServerPort, configDefault = co
|
||||||
describe('StorageTest', () => {
|
describe('StorageTest', () => {
|
||||||
let mockRegistry;
|
let mockRegistry;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(done => {
|
||||||
mockRegistry = await mockServer(mockServerPort).init();
|
rimraf(storagePath, async () => {
|
||||||
|
mockRegistry = await mockServer(mockServerPort).init();
|
||||||
|
done()
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(function(done) {
|
afterAll(function(done) {
|
||||||
|
@ -90,5 +95,21 @@ describe('StorageTest', () => {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not touch if the package exists and has no uplinks', async (done) => {
|
||||||
|
const storage: IStorageHandler = await generateStorage();
|
||||||
|
const metadataSource = path.join(__dirname, '../partials/metadata');
|
||||||
|
const metadataPath = path.join(storagePath, 'npm_test/package.json');
|
||||||
|
fs.mkdirSync(path.join(storagePath, 'npm_test'));
|
||||||
|
fs.writeFileSync(metadataPath, fs.readFileSync(metadataSource));
|
||||||
|
const metadata = JSON.parse(fs.readFileSync(metadataPath).toString());
|
||||||
|
// $FlowFixMe
|
||||||
|
storage.localStorage.updateVersions = jest.fn(storage.localStorage.updateVersions);
|
||||||
|
storage._syncUplinksMetadata('npm_test', metadata, {}, (err) => {
|
||||||
|
expect(err).toBeNull();
|
||||||
|
expect(storage.localStorage.updateVersions).not.toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -82,7 +82,13 @@
|
||||||
"beta": "1.0.2",
|
"beta": "1.0.2",
|
||||||
"next": "1.0.4"
|
"next": "1.0.4"
|
||||||
},
|
},
|
||||||
"time": {},
|
"time": {
|
||||||
|
"modified": "2019-01-29T03:20:04.000Z",
|
||||||
|
"created": "2019-01-29T03:20:00.000Z",
|
||||||
|
"1.0.1": "2019-01-29T03:20:01.000Z",
|
||||||
|
"1.0.2": "2019-01-29T03:20:02.000Z",
|
||||||
|
"1.0.4": "2019-01-29T03:20:04.000Z"
|
||||||
|
},
|
||||||
"_distfiles": {},
|
"_distfiles": {},
|
||||||
"_attachments": {},
|
"_attachments": {},
|
||||||
"_uplinks": {},
|
"_uplinks": {},
|
||||||
|
|
Loading…
Reference in a new issue