mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-02-17 23:45:29 -05:00
Merge branch 'master' into 612-cicleci-upgrade
This commit is contained in:
commit
bbb6151556
4 changed files with 83 additions and 41 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -2,6 +2,16 @@
|
|||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
<a name="3.1.1"></a>
|
||||
## [3.1.1](https://github.com/verdaccio/verdaccio/compare/v3.1.0...v3.1.1) (2018-06-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* migration issue with old storage [#740](https://github.com/verdaccio/verdaccio/issues/740) ([e977d50](https://github.com/verdaccio/verdaccio/commit/e977d50))
|
||||
|
||||
|
||||
|
||||
<a name="3.1.0"></a>
|
||||
# [3.1.0](https://github.com/verdaccio/verdaccio/compare/v3.0.2...v3.1.0) (2018-06-05)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "verdaccio",
|
||||
"version": "3.1.0",
|
||||
"version": "3.1.1",
|
||||
"description": "Private npm repository server",
|
||||
"author": {
|
||||
"name": "Alex Kocharin",
|
||||
|
|
|
@ -9,12 +9,13 @@ import UrlNode from 'url';
|
|||
import _ from 'lodash';
|
||||
// $FlowFixMe
|
||||
import async from 'async';
|
||||
import {ErrorCode, isObject, getLatestVersion, tagVersion, validateName, semverSort, DIST_TAGS} from './utils';
|
||||
import {ErrorCode, isObject, getLatestVersion, tagVersion, validateName, DIST_TAGS} from './utils';
|
||||
import {
|
||||
generatePackageTemplate, normalizePackage, generateRevision, getLatestReadme, cleanUpReadme,
|
||||
fileExist, noSuchFile, DEFAULT_REVISION, pkgFileName,
|
||||
} from './storage-utils';
|
||||
import {createTarballHash} from './crypto-utils';
|
||||
import {prepareSearchPackage} from './storage-utils';
|
||||
import {loadPlugin} from '../lib/plugin-loader';
|
||||
import LocalDatabase from '@verdaccio/local-storage';
|
||||
import {UploadTarball, ReadTarball} from '@verdaccio/streams';
|
||||
|
@ -238,6 +239,12 @@ class LocalStorage implements IStorage {
|
|||
}
|
||||
|
||||
let currentDate = new Date().toISOString();
|
||||
|
||||
// some old storage do not have this field #740
|
||||
if (_.isNil(data.time)) {
|
||||
data.time = {};
|
||||
}
|
||||
|
||||
data.time['modified'] = currentDate;
|
||||
|
||||
if (('created' in data.time) === false) {
|
||||
|
@ -567,7 +574,7 @@ class LocalStorage implements IStorage {
|
|||
search(startKey: string, options: any) {
|
||||
const stream = new UploadTarball({objectMode: true});
|
||||
|
||||
this._eachPackage((item, cb) => {
|
||||
this._searchEachPackage((item, cb) => {
|
||||
fs.stat(item.path, (err, stats) => {
|
||||
if (_.isNil(err) === false) {
|
||||
return cb(err);
|
||||
|
@ -579,33 +586,12 @@ class LocalStorage implements IStorage {
|
|||
return cb(err);
|
||||
}
|
||||
|
||||
const listVersions: Array<string> = Object.keys(data.versions);
|
||||
const versions: Array<string> = semverSort(listVersions);
|
||||
const latest: string = data[DIST_TAGS] && data[DIST_TAGS].latest ? data[DIST_TAGS].latest : versions.pop();
|
||||
const time = item.time ? new Date(item.time).toISOString() : stats.mtime;
|
||||
|
||||
if (data.versions[latest]) {
|
||||
const version: Version = data.versions[latest];
|
||||
const pkg: any = {
|
||||
name: version.name,
|
||||
description: version.description,
|
||||
'dist-tags': {latest},
|
||||
maintainers: version.maintainers || [version.author].filter(Boolean),
|
||||
author: version.author,
|
||||
repository: version.repository,
|
||||
readmeFilename: version.readmeFilename || '',
|
||||
homepage: version.homepage,
|
||||
keywords: version.keywords,
|
||||
bugs: version.bugs,
|
||||
license: version.license,
|
||||
time: {
|
||||
modified: item.time ? new Date(item.time).toISOString() : stats.mtime,
|
||||
},
|
||||
versions: {[latest]: 'latest'},
|
||||
};
|
||||
|
||||
stream.push(pkg);
|
||||
const result = prepareSearchPackage(data, time);
|
||||
if (_.isNil(result) === false) {
|
||||
stream.push(result);
|
||||
}
|
||||
|
||||
cb();
|
||||
});
|
||||
} else {
|
||||
|
@ -650,22 +636,37 @@ class LocalStorage implements IStorage {
|
|||
});
|
||||
}
|
||||
|
||||
_getCustomPackageLocalStorages() {
|
||||
const storages = {};
|
||||
|
||||
// add custom storage if exist
|
||||
if (this.config.storage) {
|
||||
storages[this.config.storage] = true;
|
||||
}
|
||||
|
||||
const {packages} = this.config;
|
||||
|
||||
if (packages) {
|
||||
const listPackagesConf = Object.keys(packages || {});
|
||||
|
||||
listPackagesConf.map( (pkg) => {
|
||||
if (packages[pkg].storage) {
|
||||
storages[packages[pkg].storage] = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return storages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Walks through each package and calls `on_package` on them.
|
||||
* @param {*} onPackage
|
||||
* @param {*} onEnd
|
||||
*/
|
||||
_eachPackage(onPackage: Callback, onEnd: Callback) {
|
||||
const storages = {};
|
||||
_searchEachPackage(onPackage: Callback, onEnd: Callback) {
|
||||
const storages = this._getCustomPackageLocalStorages();
|
||||
|
||||
storages[this.config.storage] = true;
|
||||
if (this.config.packages) {
|
||||
Object.keys(this.config.packages || {}).map( (pkg) => {
|
||||
if (this.config.packages[pkg].storage) {
|
||||
storages[this.config.packages[pkg].storage] = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
const base = Path.dirname(this.config.self_path);
|
||||
|
||||
async.eachSeries(Object.keys(storages), function(storage, cb) {
|
||||
|
@ -684,10 +685,12 @@ class LocalStorage implements IStorage {
|
|||
|
||||
async.eachSeries(files, (file2, cb) => {
|
||||
if (validateName(file2)) {
|
||||
onPackage({
|
||||
const item = {
|
||||
name: `${file}/${file2}`,
|
||||
path: Path.resolve(base, storage, file, file2),
|
||||
}, cb);
|
||||
};
|
||||
|
||||
onPackage(item, cb);
|
||||
} else {
|
||||
cb();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// @flow
|
||||
|
||||
import _ from 'lodash';
|
||||
import {ErrorCode, isObject, normalizeDistTags, DIST_TAGS} from './utils';
|
||||
import {ErrorCode, isObject, normalizeDistTags, DIST_TAGS, semverSort} from './utils';
|
||||
import Search from './search';
|
||||
import {generateRandomHexString} from '../lib/crypto-utils';
|
||||
|
||||
|
@ -179,6 +179,35 @@ export function checkPackageRemote(name: string, isAllowPublishOffline: boolean,
|
|||
});
|
||||
}
|
||||
|
||||
export function prepareSearchPackage(data: Package, time: mixed) {
|
||||
const listVersions: Array<string> = Object.keys(data.versions);
|
||||
const versions: Array<string> = semverSort(listVersions);
|
||||
const latest: string = data[DIST_TAGS] && data[DIST_TAGS].latest ? data[DIST_TAGS].latest : versions.pop();
|
||||
|
||||
if (data.versions[latest]) {
|
||||
const version: Version = data.versions[latest];
|
||||
const pkg: any = {
|
||||
name: version.name,
|
||||
description: version.description,
|
||||
'dist-tags': {latest},
|
||||
maintainers: version.maintainers || [version.author].filter(Boolean),
|
||||
author: version.author,
|
||||
repository: version.repository,
|
||||
readmeFilename: version.readmeFilename || '',
|
||||
homepage: version.homepage,
|
||||
keywords: version.keywords,
|
||||
bugs: version.bugs,
|
||||
license: version.license,
|
||||
time: {
|
||||
modified: time,
|
||||
},
|
||||
versions: {[latest]: 'latest'},
|
||||
};
|
||||
|
||||
return pkg;
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
generatePackageTemplate,
|
||||
normalizePackage,
|
||||
|
|
Loading…
Add table
Reference in a new issue