diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml new file mode 100644 index 000000000..642382497 --- /dev/null +++ b/.github/workflows/ci-lint.yml @@ -0,0 +1,22 @@ +name: CI Lint + +on: [push, pull_request] + +jobs: + ci-lint: + name: Node Lint + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + - name: Use Node + uses: actions/setup-node@7c12f8017d5436eb855f1ed4399f037a36fbd9e8 # v2.5.2 + with: + node-version-file: '.nvmrc' + - name: Install + run: yarn install --immutable + - name: Format + run: yarn format:check + - name: Lint + run: yarn lint diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afe473f72..815cc5af1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,10 +21,6 @@ jobs: node-version: ${{ matrix.node_version }} - name: Install run: yarn install --immutable - - name: Format - run: yarn format:check - - name: Lint - run: yarn lint - name: Build run: yarn build - name: Types diff --git a/.github/workflows/smok-test-module-v12.yml b/.github/workflows/smok-test-module-v12.yml index adf685477..8b4e73b06 100644 --- a/.github/workflows/smok-test-module-v12.yml +++ b/.github/workflows/smok-test-module-v12.yml @@ -19,7 +19,7 @@ jobs: - name: login run: npx npm-cli-login -u test -p 1234 -e test@domain.test -r http://localhost:4873 - name: Build - run: yarn build + run: yarn && yarn build - name: Types run: yarn code:types - name: Bump up package diff --git a/.github/workflows/smok-test-module.yml b/.github/workflows/smok-test-module.yml index b9859ec2c..59e2f71ed 100644 --- a/.github/workflows/smok-test-module.yml +++ b/.github/workflows/smok-test-module.yml @@ -19,7 +19,7 @@ jobs: - name: login run: npx npm-cli-login -u test -p 1234 -e test@domain.test -r http://localhost:4873 - name: Build - run: yarn build + run: yarn && yarn build - name: Types run: yarn code:types - name: Bump up package diff --git a/.yarn/cache/@types-express-serve-static-core-npm-4.17.34-b1081fd10c-3b5242e7d6.zip b/.yarn/cache/@types-express-serve-static-core-npm-4.17.34-b1081fd10c-3b5242e7d6.zip deleted file mode 100644 index 786cb5dce..000000000 Binary files a/.yarn/cache/@types-express-serve-static-core-npm-4.17.34-b1081fd10c-3b5242e7d6.zip and /dev/null differ diff --git a/.yarn/cache/@types-express-serve-static-core-npm-4.17.35-c86e5f6e4a-cc8995d10c.zip b/.yarn/cache/@types-express-serve-static-core-npm-4.17.35-c86e5f6e4a-cc8995d10c.zip deleted file mode 100644 index 0e4636506..000000000 Binary files a/.yarn/cache/@types-express-serve-static-core-npm-4.17.35-c86e5f6e4a-cc8995d10c.zip and /dev/null differ diff --git a/.yarn/cache/@types-express-serve-static-core-npm-4.17.41-7d196a92fa-12750f6511.zip b/.yarn/cache/@types-express-serve-static-core-npm-4.17.41-7d196a92fa-12750f6511.zip new file mode 100644 index 000000000..91d2bc42e Binary files /dev/null and b/.yarn/cache/@types-express-serve-static-core-npm-4.17.41-7d196a92fa-12750f6511.zip differ diff --git a/.yarn/cache/@types-node-forge-npm-1.3.9-9ca80870d7-4ffab54136.zip b/.yarn/cache/@types-node-forge-npm-1.3.9-9ca80870d7-4ffab54136.zip new file mode 100644 index 000000000..811fcf05b Binary files /dev/null and b/.yarn/cache/@types-node-forge-npm-1.3.9-9ca80870d7-4ffab54136.zip differ diff --git a/.yarn/cache/@verdaccio-config-npm-7.0.0-next.3-403fbabaea-7e85a51164.zip b/.yarn/cache/@verdaccio-config-npm-7.0.0-next.4-581e879d20-a7fa01a372.zip similarity index 65% rename from .yarn/cache/@verdaccio-config-npm-7.0.0-next.3-403fbabaea-7e85a51164.zip rename to .yarn/cache/@verdaccio-config-npm-7.0.0-next.4-581e879d20-a7fa01a372.zip index a88805ff6..1b036f0ff 100644 Binary files a/.yarn/cache/@verdaccio-config-npm-7.0.0-next.3-403fbabaea-7e85a51164.zip and b/.yarn/cache/@verdaccio-config-npm-7.0.0-next.4-581e879d20-a7fa01a372.zip differ diff --git a/.yarn/cache/@verdaccio-core-npm-7.0.0-next.3-99bd24ecdc-b74bcf18da.zip b/.yarn/cache/@verdaccio-core-npm-7.0.0-next.4-d2396990e2-65ba31768c.zip similarity index 57% rename from .yarn/cache/@verdaccio-core-npm-7.0.0-next.3-99bd24ecdc-b74bcf18da.zip rename to .yarn/cache/@verdaccio-core-npm-7.0.0-next.4-d2396990e2-65ba31768c.zip index d2a112464..4df80e50b 100644 Binary files a/.yarn/cache/@verdaccio-core-npm-7.0.0-next.3-99bd24ecdc-b74bcf18da.zip and b/.yarn/cache/@verdaccio-core-npm-7.0.0-next.4-d2396990e2-65ba31768c.zip differ diff --git a/.yarn/cache/@verdaccio-logger-7-npm-7.0.0-next.3-3fcaa13869-8083b5522e.zip b/.yarn/cache/@verdaccio-logger-7-npm-7.0.0-next.4-c149345118-b2af46d415.zip similarity index 79% rename from .yarn/cache/@verdaccio-logger-7-npm-7.0.0-next.3-3fcaa13869-8083b5522e.zip rename to .yarn/cache/@verdaccio-logger-7-npm-7.0.0-next.4-c149345118-b2af46d415.zip index 444dd1dc9..a9fd958c1 100644 Binary files a/.yarn/cache/@verdaccio-logger-7-npm-7.0.0-next.3-3fcaa13869-8083b5522e.zip and b/.yarn/cache/@verdaccio-logger-7-npm-7.0.0-next.4-c149345118-b2af46d415.zip differ diff --git a/.yarn/cache/@verdaccio-logger-commons-npm-7.0.0-next.3-9fcac3ffe4-f630174bd3.zip b/.yarn/cache/@verdaccio-logger-commons-npm-7.0.0-next.3-9fcac3ffe4-f630174bd3.zip deleted file mode 100644 index 2c19aa281..000000000 Binary files a/.yarn/cache/@verdaccio-logger-commons-npm-7.0.0-next.3-9fcac3ffe4-f630174bd3.zip and /dev/null differ diff --git a/.yarn/cache/@verdaccio-logger-commons-npm-7.0.0-next.4-c4407e3d59-040fc30778.zip b/.yarn/cache/@verdaccio-logger-commons-npm-7.0.0-next.4-c4407e3d59-040fc30778.zip new file mode 100644 index 000000000..ade0c63e6 Binary files /dev/null and b/.yarn/cache/@verdaccio-logger-commons-npm-7.0.0-next.4-c4407e3d59-040fc30778.zip differ diff --git a/.yarn/cache/@verdaccio-middleware-npm-7.0.0-next.3-8a76b50d9b-58147c9e5b.zip b/.yarn/cache/@verdaccio-middleware-npm-7.0.0-next.4-a16cd55add-6cda89c180.zip similarity index 74% rename from .yarn/cache/@verdaccio-middleware-npm-7.0.0-next.3-8a76b50d9b-58147c9e5b.zip rename to .yarn/cache/@verdaccio-middleware-npm-7.0.0-next.4-a16cd55add-6cda89c180.zip index 0fbb5c221..870726a5b 100644 Binary files a/.yarn/cache/@verdaccio-middleware-npm-7.0.0-next.3-8a76b50d9b-58147c9e5b.zip and b/.yarn/cache/@verdaccio-middleware-npm-7.0.0-next.4-a16cd55add-6cda89c180.zip differ diff --git a/.yarn/cache/@verdaccio-signature-npm-7.0.0-next.1-98990413f5-4074125895.zip b/.yarn/cache/@verdaccio-signature-npm-7.0.0-next.1-98990413f5-4074125895.zip deleted file mode 100644 index a1ac0f077..000000000 Binary files a/.yarn/cache/@verdaccio-signature-npm-7.0.0-next.1-98990413f5-4074125895.zip and /dev/null differ diff --git a/.yarn/cache/@verdaccio-signature-npm-7.0.0-next.2-6a06dabbf3-ad7b304ffc.zip b/.yarn/cache/@verdaccio-signature-npm-7.0.0-next.2-6a06dabbf3-ad7b304ffc.zip new file mode 100644 index 000000000..f6d59850c Binary files /dev/null and b/.yarn/cache/@verdaccio-signature-npm-7.0.0-next.2-6a06dabbf3-ad7b304ffc.zip differ diff --git a/.yarn/cache/@verdaccio-tarball-npm-12.0.0-next.3-c779b9a97c-b039a3272b.zip b/.yarn/cache/@verdaccio-tarball-npm-12.0.0-next.4-5e25271842-4a8789550f.zip similarity index 59% rename from .yarn/cache/@verdaccio-tarball-npm-12.0.0-next.3-c779b9a97c-b039a3272b.zip rename to .yarn/cache/@verdaccio-tarball-npm-12.0.0-next.4-5e25271842-4a8789550f.zip index 8d61cfdcc..9629cc9fc 100644 Binary files a/.yarn/cache/@verdaccio-tarball-npm-12.0.0-next.3-c779b9a97c-b039a3272b.zip and b/.yarn/cache/@verdaccio-tarball-npm-12.0.0-next.4-5e25271842-4a8789550f.zip differ diff --git a/.yarn/cache/@verdaccio-ui-theme-npm-7.0.0-next.3-4a7b7d2d55-b0bb02c3f6.zip b/.yarn/cache/@verdaccio-ui-theme-npm-7.0.0-next.3-4a7b7d2d55-b0bb02c3f6.zip deleted file mode 100644 index f7b5bbf46..000000000 Binary files a/.yarn/cache/@verdaccio-ui-theme-npm-7.0.0-next.3-4a7b7d2d55-b0bb02c3f6.zip and /dev/null differ diff --git a/.yarn/cache/@verdaccio-ui-theme-npm-7.0.0-next.4-713599bdab-4cc7e6a8b7.zip b/.yarn/cache/@verdaccio-ui-theme-npm-7.0.0-next.4-713599bdab-4cc7e6a8b7.zip new file mode 100644 index 000000000..da5077bcd Binary files /dev/null and b/.yarn/cache/@verdaccio-ui-theme-npm-7.0.0-next.4-713599bdab-4cc7e6a8b7.zip differ diff --git a/.yarn/cache/@verdaccio-url-npm-12.0.0-next.3-6007984e44-41b85fd1b1.zip b/.yarn/cache/@verdaccio-url-npm-12.0.0-next.4-4978b8dd44-0cdccdcb5c.zip similarity index 63% rename from .yarn/cache/@verdaccio-url-npm-12.0.0-next.3-6007984e44-41b85fd1b1.zip rename to .yarn/cache/@verdaccio-url-npm-12.0.0-next.4-4978b8dd44-0cdccdcb5c.zip index 9ba0dd8df..2cd5a0b05 100644 Binary files a/.yarn/cache/@verdaccio-url-npm-12.0.0-next.3-6007984e44-41b85fd1b1.zip and b/.yarn/cache/@verdaccio-url-npm-12.0.0-next.4-4978b8dd44-0cdccdcb5c.zip differ diff --git a/.yarn/cache/@verdaccio-utils-npm-7.0.0-next.3-c31336cc02-24cb0490fd.zip b/.yarn/cache/@verdaccio-utils-npm-7.0.0-next.3-c31336cc02-24cb0490fd.zip deleted file mode 100644 index 79ec21e72..000000000 Binary files a/.yarn/cache/@verdaccio-utils-npm-7.0.0-next.3-c31336cc02-24cb0490fd.zip and /dev/null differ diff --git a/.yarn/cache/@verdaccio-utils-npm-7.0.0-next.4-607ed8f8af-76a757031b.zip b/.yarn/cache/@verdaccio-utils-npm-7.0.0-next.4-607ed8f8af-76a757031b.zip new file mode 100644 index 000000000..f83195201 Binary files /dev/null and b/.yarn/cache/@verdaccio-utils-npm-7.0.0-next.4-607ed8f8af-76a757031b.zip differ diff --git a/.yarn/cache/async-npm-3.2.5-f5dbdabdfc-5ec77f1312.zip b/.yarn/cache/async-npm-3.2.5-f5dbdabdfc-5ec77f1312.zip new file mode 100644 index 000000000..a0ee3e0fb Binary files /dev/null and b/.yarn/cache/async-npm-3.2.5-f5dbdabdfc-5ec77f1312.zip differ diff --git a/.yarn/cache/selfsigned-npm-2.1.1-311d9b0b6d-aa9ce2150a.zip b/.yarn/cache/selfsigned-npm-2.1.1-311d9b0b6d-aa9ce2150a.zip deleted file mode 100644 index 42d8556cb..000000000 Binary files a/.yarn/cache/selfsigned-npm-2.1.1-311d9b0b6d-aa9ce2150a.zip and /dev/null differ diff --git a/.yarn/cache/selfsigned-npm-2.4.1-1ca1b883c5-38b91c56f1.zip b/.yarn/cache/selfsigned-npm-2.4.1-1ca1b883c5-38b91c56f1.zip new file mode 100644 index 000000000..98424eb98 Binary files /dev/null and b/.yarn/cache/selfsigned-npm-2.4.1-1ca1b883c5-38b91c56f1.zip differ diff --git a/.yarn/cache/verdaccio-audit-npm-12.0.0-next.3-b0569c8ec8-c6d8e66794.zip b/.yarn/cache/verdaccio-audit-npm-12.0.0-next.3-b0569c8ec8-c6d8e66794.zip deleted file mode 100644 index 6bf0f3319..000000000 Binary files a/.yarn/cache/verdaccio-audit-npm-12.0.0-next.3-b0569c8ec8-c6d8e66794.zip and /dev/null differ diff --git a/.yarn/cache/verdaccio-audit-npm-12.0.0-next.4-2b6a730b01-d67bb8d7ad.zip b/.yarn/cache/verdaccio-audit-npm-12.0.0-next.4-2b6a730b01-d67bb8d7ad.zip new file mode 100644 index 000000000..3049cffbb Binary files /dev/null and b/.yarn/cache/verdaccio-audit-npm-12.0.0-next.4-2b6a730b01-d67bb8d7ad.zip differ diff --git a/.yarn/cache/verdaccio-htpasswd-npm-12.0.0-next.3-235f79caf6-8147e9606c.zip b/.yarn/cache/verdaccio-htpasswd-npm-12.0.0-next.3-235f79caf6-8147e9606c.zip deleted file mode 100644 index 37f2b2eec..000000000 Binary files a/.yarn/cache/verdaccio-htpasswd-npm-12.0.0-next.3-235f79caf6-8147e9606c.zip and /dev/null differ diff --git a/.yarn/cache/verdaccio-htpasswd-npm-12.0.0-next.4-c1bca72c00-dc95a81ff4.zip b/.yarn/cache/verdaccio-htpasswd-npm-12.0.0-next.4-c1bca72c00-dc95a81ff4.zip new file mode 100644 index 000000000..994c7e22d Binary files /dev/null and b/.yarn/cache/verdaccio-htpasswd-npm-12.0.0-next.4-c1bca72c00-dc95a81ff4.zip differ diff --git a/eslintrc.js b/eslintrc.cjs similarity index 100% rename from eslintrc.js rename to eslintrc.cjs diff --git a/package.json b/package.json index f1e15bd1b..e865719f0 100644 --- a/package.json +++ b/package.json @@ -19,20 +19,20 @@ "url": "https://opencollective.com/verdaccio" }, "dependencies": { - "@verdaccio/config": "7.0.0-next.3", - "@verdaccio/core": "7.0.0-next.3", + "@verdaccio/config": "7.0.0-next.4", + "@verdaccio/core": "7.0.0-next.4", "@verdaccio/local-storage": "10.3.3", - "@verdaccio/logger-7": "7.0.0-next.3", - "@verdaccio/middleware": "7.0.0-next.3", + "@verdaccio/logger-7": "7.0.0-next.4", + "@verdaccio/middleware": "7.0.0-next.4", "@verdaccio/search": "7.0.0-next.2", - "@verdaccio/signature": "7.0.0-next.1", + "@verdaccio/signature": "7.0.0-next.2", "@verdaccio/streams": "10.2.1", - "@verdaccio/tarball": "12.0.0-next.3", - "@verdaccio/ui-theme": "7.0.0-next.3", - "@verdaccio/url": "12.0.0-next.3", - "@verdaccio/utils": "7.0.0-next.3", + "@verdaccio/tarball": "12.0.0-next.4", + "@verdaccio/ui-theme": "7.0.0-next.4", + "@verdaccio/url": "12.0.0-next.4", + "@verdaccio/utils": "7.0.0-next.4", "JSONStream": "1.3.5", - "async": "3.2.4", + "async": "3.2.5", "clipanion": "3.2.1", "compression": "1.7.4", "cookies": "0.8.0", @@ -55,8 +55,8 @@ "request": "2.88.2", "semver": "7.5.4", "validator": "13.11.0", - "verdaccio-audit": "12.0.0-next.3", - "verdaccio-htpasswd": "12.0.0-next.3" + "verdaccio-audit": "12.0.0-next.4", + "verdaccio-htpasswd": "12.0.0-next.4" }, "devDependencies": { "@babel/cli": "7.23.0", @@ -126,7 +126,7 @@ "pinst": "2.1.6", "prettier": "3.0.3", "rimraf": "3.0.2", - "selfsigned": "2.1.1", + "selfsigned": "2.4.1", "standard-version": "9.5.0", "supertest": "6.3.3", "ts-node": "10.9.1", @@ -160,7 +160,7 @@ "test:all": "yarn run test && yarn run test:functional", "pre:ci": "yarn run lint", "lint:ts": "yarn run type-check", - "lint": "eslint \"**/*.{js,jsx,ts}\" --max-warnings 145 -c ./eslintrc.js", + "lint": "eslint \"**/*.{js,jsx,ts}\" --max-warnings 145 -c ./eslintrc.cjs", "lint:lockfile": "lockfile-lint --path yarn.lock --type yarn --validate-https --allowed-hosts verdaccio npm yarn", "start": "yarn babel-node --extensions \".ts,.tsx\" src/lib/cli --inspect", "start:brk": "yarn babel-node --extensions \".ts,.tsx\" src/lib/cli --inspect-brk", @@ -178,7 +178,8 @@ "preferGlobal": true, "license": "MIT", "resolutions": { - "@types/serve-static": "1.13.10" + "@types/serve-static": "1.13.10", + "@types/express-serve-static-core": "4.17.41" }, "collective": { "type": "opencollective", diff --git a/src/api/index.ts b/src/api/index.ts index 369f28cb7..8c8e1b674 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -5,7 +5,7 @@ import _ from 'lodash'; import { getUserAgent } from '@verdaccio/config'; import { pluginUtils } from '@verdaccio/core'; -import { final } from '@verdaccio/middleware'; +import { errorReportingMiddleware, final, handleError } from '@verdaccio/middleware'; import { log } from '@verdaccio/middleware'; import { SearchMemoryIndexer } from '@verdaccio/search'; import { Config as IConfig } from '@verdaccio/types'; @@ -20,7 +20,7 @@ import { ErrorCode } from '../lib/utils'; import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types'; import hookDebug from './debug'; import apiEndpoint from './endpoint'; -import { errorReportingMiddleware, handleError, serveFavicon } from './middleware'; +import { serveFavicon } from './middleware'; import webMiddleware from './web'; const { version } = require('../../package.json'); @@ -60,7 +60,7 @@ const defineAPI = async function (config: IConfig, storage: Storage): Promise= HTTP_STATUS.BAD_REQUEST && err.status < 600) { - if (!res.headersSent) { - res.status(err.status); - next({ error: err.message || API_ERROR.UNKNOWN_ERROR }); - } - } else { - logger.error({ err: err }, 'unexpected error: @{!err.message}\n@{err.stack}'); - if (!res.status || !res.send) { - logger.error('this is an error in express.js, please report this'); - res.destroy(); - } else if (!res.headersSent) { - res.status(HTTP_STATUS.INTERNAL_ERROR); - next({ error: API_ERROR.INTERNAL_SERVER_ERROR }); - } else { - // socket should be already closed - } - } - }; - - next(); -} diff --git a/test/helpers/initializeServer.ts b/test/helpers/initializeServer.ts index 71a1ea6cf..c356f931f 100644 --- a/test/helpers/initializeServer.ts +++ b/test/helpers/initializeServer.ts @@ -4,12 +4,12 @@ import os from 'os'; import path from 'path'; import { errorUtils } from '@verdaccio/core'; -import { final } from '@verdaccio/middleware'; +import { errorReportingMiddleware, final, handleError } from '@verdaccio/middleware'; import { generateRandomHexString } from '@verdaccio/utils'; -import { errorReportingMiddleware, handleError } from '../../src/api/middleware'; import Auth from '../../src/lib/auth'; import Config from '../../src/lib/config'; +import { logger } from '../../src/lib/logger'; const debug = buildDebug('verdaccio:tools:helpers:server'); @@ -34,7 +34,7 @@ export async function initializeServer( // TODO: this might not be need it, used in apiEndpoints app.use(express.json({ strict: false, limit: '100mb' })); // @ts-ignore - app.use(errorReportingMiddleware); + app.use(errorReportingMiddleware(logger)); for (let route of routesMiddleware) { if (route.async) { const middleware = await route.routes(config, auth, storage); @@ -50,7 +50,7 @@ export async function initializeServer( }); // @ts-ignore - app.use(handleError); + app.use(handleError(logger)); // @ts-ignore app.use(final); diff --git a/yarn.lock b/yarn.lock index 612b140b5..7f0e2f096 100644 Binary files a/yarn.lock and b/yarn.lock differ