diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ecb54cb4e..81c7cbaf3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - node_version: [10, 12, 14, 15] + node_version: [12, 14, 15] runs-on: ubuntu-latest diff --git a/.github/workflows/e2e-jest-workflow.yml b/.github/workflows/e2e-jest-workflow.yml index 158ff416f..4eeb80fc1 100644 --- a/.github/workflows/e2e-jest-workflow.yml +++ b/.github/workflows/e2e-jest-workflow.yml @@ -14,10 +14,10 @@ jobs: steps: - uses: actions/checkout@v2.3.3 - - name: 'Use Node.js 10.x' + - name: 'Use Node.js 12.x' uses: actions/setup-node@v2.1.5 with: - node-version: 10.x + node-version: 12.x - name: Install Dependencies run: yarn install - name: 'Run verdaccio in the background' @@ -45,10 +45,10 @@ jobs: steps: - uses: actions/checkout@v2.3.3 - - name: 'Use Node.js 10.x' + - name: 'Use Node.js 12.x' uses: actions/setup-node@v2.1.5 with: - node-version: 10.x + node-version: 12.x - name: Install Dependencies run: yarn install - name: 'Run verdaccio in the background' @@ -79,10 +79,10 @@ jobs: steps: - uses: actions/checkout@v2.3.3 - - name: 'Use Node.js 10.x' + - name: 'Use Node.js 12.x' uses: actions/setup-node@v2.1.5 with: - node-version: 10.x + node-version: 12.x - name: 'install latest npm' run: npm i -g npm@latest-6 - name: Install Dependencies @@ -112,10 +112,10 @@ jobs: steps: - uses: actions/checkout@v2.3.3 - - name: 'Use Node.js 10.x' + - name: 'Use Node.js 12.x' uses: actions/setup-node@v2.1.5 with: - node-version: 10.x + node-version: 12.x - name: 'install latest npm' run: npm i -g npm - name: Install Dependencies @@ -146,10 +146,10 @@ jobs: steps: - uses: actions/checkout@v2.3.3 - - name: 'Use Node.js 10.x' + - name: 'Use Node.js 12.x' uses: actions/setup-node@v2.1.5 with: - node-version: 10.x + node-version: 12.x - name: 'install latest pnpm' run: npm i -g pnpm - name: Install Dependencies diff --git a/babel.config.js b/babel.config.js index e785b9b9c..3722f2772 100644 --- a/babel.config.js +++ b/babel.config.js @@ -4,7 +4,7 @@ module.exports = { '@babel/env', { targets: { - node: '8' + node: '12', }, }, ], diff --git a/package.json b/package.json index 32614f9ff..2df9a4c39 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "express": "4.17.1", "handlebars": "4.7.7", "http-errors": "1.8.0", - "js-yaml": "3.14.1", + "js-yaml": "4.0.0", "jsonwebtoken": "8.5.1", "kleur": "4.1.4", "lodash": "4.17.21", @@ -44,7 +44,7 @@ "marked": "2.0.1", "mime": "2.5.2", "minimatch": "3.0.4", - "mkdirp": "0.5.5", + "mkdirp": "1.0.4", "mv": "2.1.1", "pkginfo": "0.4.1", "request": "2.88.0", @@ -74,8 +74,8 @@ "@babel/preset-typescript": "7.13.0", "@babel/register": "7.13.8", "@babel/runtime": "7.13.9", - "@commitlint/cli": "8.3.5", - "@commitlint/config-conventional": "8.3.4", + "@commitlint/cli": "12.0.1", + "@commitlint/config-conventional": "12.0.1", "@octokit/rest": "16.43.2", "@types/async": "3.2.4", "@types/bunyan": "1.8.6", @@ -113,7 +113,7 @@ "eslint-plugin-simple-import-sort": "7.0.0", "eslint-plugin-verdaccio": "9.6.1", "fs-extra": "9.1.0", - "get-stdin": "7.0.0", + "get-stdin": "8.0.0", "husky": "2.7.0", "in-publish": "2.0.1", "jest": "25.5.4", diff --git a/src/lib/cli.ts b/src/lib/cli.ts index 6ccac2927..0b0204d3e 100644 --- a/src/lib/cli.ts +++ b/src/lib/cli.ts @@ -13,21 +13,13 @@ import { parseConfigFile } from './utils'; require('pkginfo')(module); if (process.getuid && process.getuid() === 0) { - global.console.warn( - bgYellow().red( - "*** WARNING: Verdaccio doesn't need superuser privileges. Don't run it under root! ***" - ) - ); + global.console.warn(bgYellow().red("*** WARNING: Verdaccio doesn't need superuser privileges. Don't run it under root! ***")); } -const MIN_NODE_VERSION = '6.9.0'; +const MIN_NODE_VERSION = '12.0.0'; if (semver.satisfies(process.version, `>=${MIN_NODE_VERSION}`) === false) { - global.console.error( - bgRed( - `Verdaccio requires at least Node.js ${MIN_NODE_VERSION} or higher, please upgrade your Node.js distribution` - ) - ); + global.console.error(bgRed(`Verdaccio requires at least Node.js ${MIN_NODE_VERSION} or higher, please upgrade your Node.js distribution`)); process.exit(1); } @@ -68,19 +60,9 @@ function init() { logger.logger.warn({ file: configPathLocation }, 'config file - @{file}'); - startVerdaccio( - verdaccioConfiguration, - cliListener, - configPathLocation, - pkgVersion, - pkgName, - listenDefaultCallback - ); + startVerdaccio(verdaccioConfiguration, cliListener, configPathLocation, pkgVersion, pkgName, listenDefaultCallback); } catch (err) { - logger.logger.fatal( - { file: configPathLocation, err: err }, - 'cannot open config file @{file}: @{!err.message}' - ); + logger.logger.fatal({ file: configPathLocation, err: err }, 'cannot open config file @{file}: @{!err.message}'); process.exit(1); } } @@ -94,7 +76,7 @@ if (commander.info) { Binaries: ['Node', 'Yarn', 'npm'], Virtualization: ['Docker'], Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'], - npmGlobalPackages: ['verdaccio'] + npmGlobalPackages: ['verdaccio'], }); // eslint-disable-next-line no-console console.log(data); @@ -113,7 +95,7 @@ if (commander.info) { process.on('uncaughtException', function (err) { logger.logger.fatal( { - err: err + err: err, }, 'uncaught exception, please report this\n@{err.stack}' ); diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 3de685f03..9c2f3d129 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -12,29 +12,10 @@ import sanitizyReadme from '@verdaccio/readme'; import { Package, Version, Author } from '@verdaccio/types'; import { Request } from 'express'; -import { - getConflict, - getBadData, - getBadRequest, - getInternalError, - getUnauthorized, - getForbidden, - getServiceUnavailable, - getNotFound, - getCode -} from '@verdaccio/commons-api'; +import { getConflict, getBadData, getBadRequest, getInternalError, getUnauthorized, getForbidden, getServiceUnavailable, getNotFound, getCode } from '@verdaccio/commons-api'; import { generateGravatarUrl, GENERIC_AVATAR } from '../utils/user'; import { StringValue, AuthorAvatar } from '../../types'; -import { - APP_ERROR, - DEFAULT_PORT, - DEFAULT_DOMAIN, - DEFAULT_PROTOCOL, - CHARACTER_ENCODING, - HEADERS, - DIST_TAGS, - DEFAULT_USER -} from './constants'; +import { APP_ERROR, DEFAULT_PORT, DEFAULT_DOMAIN, DEFAULT_PROTOCOL, CHARACTER_ENCODING, HEADERS, DIST_TAGS, DEFAULT_USER } from './constants'; import { normalizeContributors } from './storage-utils'; @@ -139,11 +120,7 @@ export function validateMetadata(object: Package, name: string): Package { * Create base url for registry. * @return {String} base registry url */ -export function combineBaseUrl( - protocol: string, - host: string | void, - prefix?: string | void -): string { +export function combineBaseUrl(protocol: string, host: string | void, prefix?: string | void): string { const result = `${protocol}://${host}`; const prefixOnlySlash = prefix === '/'; @@ -174,11 +151,7 @@ export function extractTarballFromUrl(url: string): string { * @param {*} config * @return {String} a filtered package */ -export function convertDistRemoteToLocalTarballUrls( - pkg: Package, - req: Request, - urlPrefix: string | void -): Package { +export function convertDistRemoteToLocalTarballUrls(pkg: Package, req: Request, urlPrefix: string | void): Package { for (const ver in pkg.versions) { if (Object.prototype.hasOwnProperty.call(pkg.versions, ver)) { const distName = pkg.versions[ver].dist; @@ -196,12 +169,7 @@ export function convertDistRemoteToLocalTarballUrls( * @param {*} uri * @return {String} a parsed url */ -export function getLocalRegistryTarballUri( - uri: string, - pkgName: string, - req: Request, - urlPrefix: string | void -): string { +export function getLocalRegistryTarballUri(uri: string, pkgName: string, req: Request, urlPrefix: string | void): string { const currentHost = req.headers.host; if (!currentHost) { @@ -279,7 +247,7 @@ export function parseAddress(urlAddress: any): any { return { proto: urlPattern[2] || DEFAULT_PROTOCOL, host: urlPattern[6] || urlPattern[7] || DEFAULT_DOMAIN, - port: urlPattern[8] || DEFAULT_PORT + port: urlPattern[8] || DEFAULT_PORT, }; } @@ -288,7 +256,7 @@ export function parseAddress(urlAddress: any): any { if (urlPattern) { return { proto: urlPattern[2] || DEFAULT_PROTOCOL, - path: urlPattern[4] + path: urlPattern[4], }; } @@ -362,7 +330,7 @@ const parseIntervalTable = { d: 86400000, w: 7 * 86400000, M: 30 * 86400000, - y: 365 * 86400000 + y: 365 * 86400000, }; /** @@ -381,11 +349,7 @@ export function parseInterval(interval: any): number { return; } const m = x.match(/^((0|[1-9][0-9]*)(\.[0-9]+)?)(ms|s|m|h|d|w|M|y|)$/); - if ( - !m || - parseIntervalTable[m[4]] >= last_suffix || - (m[4] === '' && last_suffix !== Infinity) - ) { + if (!m || parseIntervalTable[m[4]] >= last_suffix || (m[4] === '' && last_suffix !== Infinity)) { throw Error('invalid interval: ' + interval); } last_suffix = parseIntervalTable[m[4]]; @@ -419,13 +383,13 @@ export const ErrorCode = { getForbidden, getServiceUnavailable, getNotFound, - getCode + getCode, }; export function parseConfigFile(configPath: string): any { try { if (/\.ya?ml$/i.test(configPath)) { - return YAML.safeLoad(fs.readFileSync(configPath, CHARACTER_ENCODING.UTF8)); + return YAML.load(fs.readFileSync(configPath, CHARACTER_ENCODING.UTF8)); } return require(configPath); } catch (e) { @@ -488,9 +452,7 @@ export function deleteProperties(propertiesToDelete: string[], objectItem: any): export function addGravatarSupport(pkgInfo: Package, online = true): AuthorAvatar { const pkgInfoCopy = { ...pkgInfo } as any; const author: any = _.get(pkgInfo, 'latest.author', null) as any; - const contributors: AuthorAvatar[] = normalizeContributors( - _.get(pkgInfo, 'latest.contributors', []) - ); + const contributors: AuthorAvatar[] = normalizeContributors(_.get(pkgInfo, 'latest.contributors', [])); const maintainers = _.get(pkgInfo, 'latest.maintainers', []); // for author. @@ -503,7 +465,7 @@ export function addGravatarSupport(pkgInfo: Package, online = true): AuthorAvata pkgInfoCopy.latest.author = { avatar: GENERIC_AVATAR, email: '', - author + author, }; } @@ -517,7 +479,7 @@ export function addGravatarSupport(pkgInfo: Package, online = true): AuthorAvata contributor = { avatar: GENERIC_AVATAR, email: contributor, - name: contributor + name: contributor, }; } @@ -580,7 +542,7 @@ export function formatAuthor(author: AuthorFormat): any { let authorDetails = { name: DEFAULT_USER, email: '', - url: '' + url: '', }; if (_.isNil(author)) { @@ -590,14 +552,14 @@ export function formatAuthor(author: AuthorFormat): any { if (_.isString(author)) { authorDetails = { ...authorDetails, - name: author as string + name: author as string, }; } if (_.isObject(author)) { authorDetails = { ...authorDetails, - ...(author as Author) + ...(author as Author), }; } diff --git a/test/unit/partials/config/yaml/api.web.spec.yaml b/test/unit/partials/config/yaml/api.web.spec.yaml index 8ee87bde1..4510a627e 100644 --- a/test/unit/partials/config/yaml/api.web.spec.yaml +++ b/test/unit/partials/config/yaml/api.web.spec.yaml @@ -17,4 +17,4 @@ packages: unpublish: xxx proxy: npmjs logs: - - { type: stdout, format: pretty, level: warn } + - { type: stdout, format: pretty, level: trace } diff --git a/yarn.lock b/yarn.lock index 5ceed0d39..fc553f22d 100644 Binary files a/yarn.lock and b/yarn.lock differ