diff --git a/.babelrc b/.babelrc index f0d422e80..21cd820bc 100644 --- a/.babelrc +++ b/.babelrc @@ -1,68 +1,3 @@ { - "env": { - "ui": { - "presets": [ - "@babel/react", - "@babel/flow", - ["@babel/env",{ - "targets": { - "browsers": [ - "last 5 versions", - "FireFox >= 44", - "Safari >= 7", - "Explorer 11", - "last 4 Edge versions" - ] - } - }] - ], - "plugins": [ - "react-hot-loader/babel", - "@babel/transform-runtime", - "@babel/proposal-class-properties", - "@babel/plugin-proposal-object-rest-spread", - "@babel/syntax-dynamic-import", - "emotion" - ] - }, - "test": { - "presets": [["@babel/env", { - "targets": { - "node": "6.10" - } - }], "@babel/flow", - "@babel/react"], - "plugins": [ - "@babel/plugin-proposal-class-properties", - "@babel/plugin-proposal-object-rest-spread", - "babel-plugin-dynamic-import-node", - "emotion" - ] - }, - "registry": { - "presets": [ - ["@babel/env", { - "targets": { - "node": "6.10" - } - }], "@babel/flow"], - "plugins": [ - "@babel/plugin-proposal-object-rest-spread", - "@babel/proposal-class-properties" - ] - }, - "registry-docker": { - "presets": [ - ["@babel/env", { - "targets": { - "node": "10" - } - }], - "@babel/flow"], - "plugins": [ - "@babel/plugin-proposal-object-rest-spread", - "@babel/proposal-class-properties" - ] - } - } + "presets": [["@verdaccio", {"flow": true}]] } diff --git a/.eslintignore b/.eslintignore index 7840d0e66..2cea1dff6 100644 --- a/.eslintignore +++ b/.eslintignore @@ -14,3 +14,4 @@ Dockerfile *.scss *.png *.jpg +test/unit/partials/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fbaebbd9..49160c30c 100644 --- a/CHANGELOG.md +++ b/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)) * 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)) + +## [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)) + + + + +# [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)) + + + + +## [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)) + + ## [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 - first commits - \ No newline at end of file + diff --git a/conf/default.yaml b/conf/default.yaml index 782a03f6c..4b721a700 100644 --- a/conf/default.yaml +++ b/conf/default.yaml @@ -61,6 +61,12 @@ packages: # if package is not available locally, proxy requests to 'npmjs' registry 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 middlewares: audit: diff --git a/package.json b/package.json index 3d33084e9..ce4cf2a53 100644 --- a/package.json +++ b/package.json @@ -16,77 +16,49 @@ }, "dependencies": { "@verdaccio/file-locking": "0.0.7", - "@verdaccio/local-storage": "1.2.0", - "@verdaccio/streams": "1.0.0", - "JSONStream": "1.3.4", + "@verdaccio/local-storage": "2.0.0-beta.1", + "@verdaccio/streams": "2.0.0-beta.0", + "JSONStream": "1.3.5", "async": "2.6.1", "body-parser": "1.18.3", "bunyan": "1.8.12", - "chalk": "2.4.1", - "commander": "2.18.0", + "chalk": "2.4.2", + "commander": "2.19.0", "compression": "1.7.3", - "cookies": "0.7.2", - "cors": "2.8.4", - "date-fns": "1.29.0", - "express": "4.16.3", + "cookies": "0.7.3", + "cors": "2.8.5", + "date-fns": "1.30.1", + "express": "4.16.4", "global": "4.3.2", "handlebars": "4.0.12", "http-errors": "1.7.1", - "js-base64": "2.4.9", + "js-base64": "2.5.1", "js-string-escape": "1.0.1", - "js-yaml": "3.12.0", - "jsonwebtoken": "8.3.0", + "js-yaml": "3.12.1", + "jsonwebtoken": "8.4.0", "lockfile": "1.0.4", "lodash": "4.17.11", - "lunr-mutable-indexes": "2.3.1", - "marked": "0.5.1", - "mime": "2.3.1", + "lunr-mutable-indexes": "2.3.2", + "marked": "0.6.0", + "mime": "2.4.0", "minimatch": "3.0.4", "mkdirp": "0.5.1", "mv": "2.1.1", "pkginfo": "0.4.1", "request": "2.88.0", - "semver": "5.5.1", + "semver": "5.6.0", "verdaccio-audit": "1.1.0", - "verdaccio-htpasswd": "1.0.1", + "verdaccio-htpasswd": "2.0.0-beta.0", "verror": "1.10.0" }, "devDependencies": { - "@babel/cli": "7.2.3", - "@babel/core": "7.2.2", - "@babel/node": "7.2.2", - "@babel/plugin-proposal-class-properties": "7.2.3", - "@babel/plugin-proposal-decorators": "7.2.3", - "@babel/plugin-proposal-export-namespace-from": "7.2.0", - "@babel/plugin-proposal-function-sent": "7.2.0", - "@babel/plugin-proposal-json-strings": "7.2.0", - "@babel/plugin-proposal-numeric-separator": "7.2.0", - "@babel/plugin-proposal-object-rest-spread": "7.2.0", - "@babel/plugin-proposal-throw-expressions": "7.2.0", - "@babel/plugin-syntax-dynamic-import": "7.2.0", - "@babel/plugin-syntax-import-meta": "7.2.0", - "@babel/plugin-transform-async-to-generator": "7.2.0", - "@babel/plugin-transform-classes": "7.2.2", - "@babel/plugin-transform-runtime": "7.2.0", - "@babel/polyfill": "7.2.3", - "@babel/preset-env": "7.2.3", - "@babel/preset-flow": "7.0.0", - "@babel/preset-react": "7.0.0", - "@babel/register": "7.0.0", - "@babel/runtime": "^7.2.0", "@commitlint/cli": "7.2.1", "@commitlint/config-conventional": "7.1.2", "@material-ui/core": "3.9.0", "@material-ui/icons": "3.0.2", + "@verdaccio/babel-preset": "0.0.4", "@verdaccio/types": "4.1.4", "autosuggest-highlight": "3.1.1", - "babel-core": "7.0.0-bridge.0", - "babel-eslint": "10.0.1", - "babel-jest": "23.6.0", - "babel-loader": "8.0.4", - "babel-plugin-dynamic-import-node": "2.2.0", - "babel-plugin-emotion": "9.2.10", - "babel-plugin-flow-runtime": "0.17.0", "bundlesize": "0.17.0", "codecov": "3.1.0", "cross-env": "5.2.0", @@ -154,7 +126,7 @@ "typeface-roboto": "0.0.54", "url-loader": "1.1.1", "verdaccio-auth-memory": "0.0.4", - "verdaccio-memory": "1.0.3", + "verdaccio-memory": "2.0.0-beta.0", "webpack": "4.20.2", "webpack-bundle-analyzer": "3.0.2", "webpack-cli": "3.1.1", diff --git a/src/api/web/index.js b/src/api/web/index.js index be76dec57..71bbfe863 100644 --- a/src/api/web/index.js +++ b/src/api/web/index.js @@ -12,6 +12,7 @@ import express from 'express'; import { combineBaseUrl, getWebProtocol } from '../../lib/utils'; import Search from '../../lib/search'; import { HEADERS, HTTP_STATUS, WEB_TITLE } from '../../lib/constants'; +import { spliceURL } from '../../utils/string'; const { securityIframe } = require('../middleware'); /* eslint new-cap:off */ @@ -52,9 +53,8 @@ module.exports = function(config, auth, storage) { }); }); - router.get('/', function(req, res) { - const installPath = _.get(config, 'url_prefix', ''); - const base = combineBaseUrl(getWebProtocol(req.get(HEADERS.FORWARDED_PROTO), req.protocol), req.get('host'), installPath); + function renderHTML(req, res) { + const base = combineBaseUrl(getWebProtocol(req.get(HEADERS.FORWARDED_PROTO), req.protocol), req.get('host'), config.url_prefix); const webPage = template .replace(/ToReplaceByVerdaccio/g, base) .replace(/ToReplaceByTitle/g, _.get(config, 'web.title') ? config.web.title : WEB_TITLE) @@ -64,6 +64,20 @@ module.exports = function(config, auth, storage) { res.setHeader('Content-Type', 'text/html'); res.send(webPage); + } + + router.get('/-/web/:pkg', function(req, res) { + renderHTML(req, res); + }); + + router.get('/-/verdaccio/logo', function(req, res) { + const installPath = _.get(config, 'url_prefix', ''); + + res.send(_.get(config, 'web.logo') || spliceURL(installPath, '/-/static/logo.png')); + }); + + router.get('/', function(req, res) { + renderHTML(req, res); }); return router; diff --git a/src/lib/bootstrap.js b/src/lib/bootstrap.js index 31b5dfe34..24d23bc26 100644 --- a/src/lib/bootstrap.js +++ b/src/lib/bootstrap.js @@ -48,7 +48,10 @@ function startVerdaccio(config: any, cliListen: string, configPath: string, pkgV // http 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); callback(webServer, addr, pkgName, pkgVersion); diff --git a/src/lib/constants.js b/src/lib/constants.js index c81c5fb26..77a538f08 100644 --- a/src/lib/constants.js +++ b/src/lib/constants.js @@ -102,8 +102,10 @@ export const API_ERROR = { CONFIG_BAD_FORMAT: 'config file must be an object', BAD_USERNAME_PASSWORD: 'bad username/password, access denied', NO_PACKAGE: 'no such package available', + PACKAGE_CANNOT_BE_ADDED: 'this package cannot be added', BAD_DATA: 'bad data', NOT_ALLOWED: 'not allowed to access package', + NOT_ALLOWED_PUBLISH: 'not allowed to publish package', INTERNAL_SERVER_ERROR: 'internal server error', UNKNOWN_ERROR: 'unknown error', NOT_PACKAGE_UPLINK: 'package does not exist on uplink', diff --git a/src/lib/local-storage.js b/src/lib/local-storage.js index 276bb4e36..c62f07e9c 100644 --- a/src/lib/local-storage.js +++ b/src/lib/local-storage.js @@ -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; change = true; } @@ -631,29 +631,6 @@ 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 diff --git a/src/lib/storage-utils.js b/src/lib/storage-utils.js index 5db683b1a..3676078e1 100644 --- a/src/lib/storage-utils.js +++ b/src/lib/storage-utils.js @@ -45,6 +45,10 @@ export function normalizePackage(pkg: Package) { pkg._rev = STORAGE.DEFAULT_REVISION; } + if (_.isString(pkg._id) === false) { + pkg._id = pkg.name; + } + // normalize dist-tags normalizeDistTags(pkg); @@ -93,7 +97,7 @@ export function normalizeContributors(contributors: Array): Array {isLoading ? ( ) : ( - - {this.renderHeader()} + {this.renderContent()} @@ -175,7 +175,11 @@ export default class App extends Component { return ( - + + {this.renderHeader()} +