diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ceed62d79..78b4fbe1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,8 @@ jobs: run: yarn install --immutable - name: Build run: yarn code:build + - name: Format + run: yarn format:check - name: Lint run: yarn lint - name: Test diff --git a/.pnp.js b/.pnp.js index 81a21d8cd..8b1e76735 100755 --- a/.pnp.js +++ b/.pnp.js @@ -63,6 +63,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@commitlint/cli", "npm:12.1.4"], ["@commitlint/config-conventional", "npm:12.1.4"], ["@octokit/rest", "npm:18.6.0"], + ["@trivago/prettier-plugin-sort-imports", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:3.1.1"], ["@types/async", "npm:3.2.9"], ["@types/express", "npm:4.17.11"], ["@types/express-rate-limit", "npm:5.1.3"], @@ -233,6 +234,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@babel/highlight", "npm:7.16.0"] ], "linkType": "HARD", + }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-code-frame-npm-7.16.7-093eb9e124-79eb7c3207.zip/node_modules/@babel/code-frame/", + "packageDependencies": [ + ["@babel/code-frame", "npm:7.16.7"], + ["@babel/highlight", "npm:7.16.7"] + ], + "linkType": "HARD", }] ]], ["@babel/compat-data", [ @@ -256,6 +265,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@babel/compat-data", "npm:7.16.0"] ], "linkType": "HARD", + }], + ["npm:7.16.4", { + "packageLocation": "./.yarn/cache/@babel-compat-data-npm-7.16.4-9128f11195-5735fb9156.zip/node_modules/@babel/compat-data/", + "packageDependencies": [ + ["@babel/compat-data", "npm:7.16.4"] + ], + "linkType": "HARD", }] ]], ["@babel/core", [ @@ -282,6 +298,29 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ], "linkType": "HARD", }], + ["npm:7.13.10", { + "packageLocation": "./.yarn/cache/@babel-core-npm-7.13.10-57ebf35dd5-728249a0ba.zip/node_modules/@babel/core/", + "packageDependencies": [ + ["@babel/core", "npm:7.13.10"], + ["@babel/code-frame", "npm:7.12.13"], + ["@babel/generator", "npm:7.16.7"], + ["@babel/helper-compilation-targets", "virtual:57ebf35dd5ea0b818591de63843e65e1ae44db4213e6c4a68ffa85ff9440503ed9f92d3f78b88fde641ad2fdb170f9a17c16f3d13d73ccaa697ab86ec9e7aa1c#npm:7.16.7"], + ["@babel/helper-module-transforms", "npm:7.16.7"], + ["@babel/helpers", "npm:7.16.7"], + ["@babel/parser", "npm:7.16.7"], + ["@babel/template", "npm:7.12.13"], + ["@babel/traverse", "npm:7.13.0"], + ["@babel/types", "npm:7.13.0"], + ["convert-source-map", "npm:1.7.0"], + ["debug", "virtual:24c0670a0dd5336de8e9d36ce94c8b696cc66bf2f157358e53a1649e6047bfc20104ef799a035ae68ee7761447ecfa64a6d54a5971d436f7ea6ab984abfab5de#npm:4.1.1"], + ["gensync", "npm:1.0.0-beta.2"], + ["json5", "npm:2.1.3"], + ["lodash", "npm:4.17.20"], + ["semver", "npm:6.3.0"], + ["source-map", "npm:0.5.7"] + ], + "linkType": "HARD", + }], ["npm:7.16.0", { "packageLocation": "./.yarn/cache/@babel-core-npm-7.16.0-5612f0ce31-ee30612e54.zip/node_modules/@babel/core/", "packageDependencies": [ @@ -357,6 +396,16 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["source-map", "npm:0.5.7"] ], "linkType": "HARD", + }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-generator-npm-7.16.7-3cf12729b6-1df435d689.zip/node_modules/@babel/generator/", + "packageDependencies": [ + ["@babel/generator", "npm:7.16.7"], + ["@babel/types", "npm:7.16.7"], + ["jsesc", "npm:2.5.2"], + ["source-map", "npm:0.5.7"] + ], + "linkType": "HARD", }] ]], ["@babel/helper-annotate-as-pure", [ @@ -403,6 +452,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ], "linkType": "SOFT", }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-helper-compilation-targets-npm-7.16.7-8031641957-f7da620a08.zip/node_modules/@babel/helper-compilation-targets/", + "packageDependencies": [ + ["@babel/helper-compilation-targets", "npm:7.16.7"] + ], + "linkType": "SOFT", + }], ["virtual:5612f0ce311a7844500ba5948d5d47b8376a902bfa55b1e3797dd916bf18f7512ba75518521ba3bc2f39f6565fb127bcb8fee5b440624dbebaf9ac5f3566ebd0#npm:7.16.0", { "packageLocation": "./.yarn/$$virtual/@babel-helper-compilation-targets-virtual-64c9734913/0/cache/@babel-helper-compilation-targets-npm-7.16.0-153c8450fa-5e1396ab10.zip/node_modules/@babel/helper-compilation-targets/", "packageDependencies": [ @@ -420,6 +476,23 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ], "linkType": "HARD", }], + ["virtual:57ebf35dd5ea0b818591de63843e65e1ae44db4213e6c4a68ffa85ff9440503ed9f92d3f78b88fde641ad2fdb170f9a17c16f3d13d73ccaa697ab86ec9e7aa1c#npm:7.16.7", { + "packageLocation": "./.yarn/$$virtual/@babel-helper-compilation-targets-virtual-6847cc1e9a/0/cache/@babel-helper-compilation-targets-npm-7.16.7-8031641957-f7da620a08.zip/node_modules/@babel/helper-compilation-targets/", + "packageDependencies": [ + ["@babel/helper-compilation-targets", "virtual:57ebf35dd5ea0b818591de63843e65e1ae44db4213e6c4a68ffa85ff9440503ed9f92d3f78b88fde641ad2fdb170f9a17c16f3d13d73ccaa697ab86ec9e7aa1c#npm:7.16.7"], + ["@babel/compat-data", "npm:7.16.4"], + ["@babel/core", "npm:7.13.10"], + ["@babel/helper-validator-option", "npm:7.16.7"], + ["@types/babel__core", null], + ["browserslist", "npm:4.19.1"], + ["semver", "npm:6.3.0"] + ], + "packagePeers": [ + "@babel/core", + "@types/babel__core" + ], + "linkType": "HARD", + }], ["virtual:b5039fc7c576fde82936c64bf3dfa10686342566681ea55522ff1adc0b716868cb771419d9bca4bcac8159bc70c523e3655f9f11e07d832f65be49230a8c85f3#npm:7.13.8", { "packageLocation": "./.yarn/$$virtual/@babel-helper-compilation-targets-virtual-0890edc99d/0/cache/@babel-helper-compilation-targets-npm-7.13.8-bd6cee5343-dbee371e5f.zip/node_modules/@babel/helper-compilation-targets/", "packageDependencies": [ @@ -543,6 +616,16 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD", }] ]], + ["@babel/helper-environment-visitor", [ + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-helper-environment-visitor-npm-7.16.7-3ee2ba2019-da3195cad9.zip/node_modules/@babel/helper-environment-visitor/", + "packageDependencies": [ + ["@babel/helper-environment-visitor", "npm:7.16.7"], + ["@babel/types", "npm:7.16.7"] + ], + "linkType": "HARD", + }] + ]], ["@babel/helper-explode-assignable-expression", [ ["npm:7.16.0", { "packageLocation": "./.yarn/cache/@babel-helper-explode-assignable-expression-npm-7.16.0-c7497452bc-97e5391bc8.zip/node_modules/@babel/helper-explode-assignable-expression/", @@ -593,6 +676,16 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@babel/types", "npm:7.16.0"] ], "linkType": "HARD", + }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-helper-function-name-npm-7.16.7-aa24c7b296-919e9f34f4.zip/node_modules/@babel/helper-function-name/", + "packageDependencies": [ + ["@babel/helper-function-name", "npm:7.16.7"], + ["@babel/helper-get-function-arity", "npm:7.16.7"], + ["@babel/template", "npm:7.16.7"], + ["@babel/types", "npm:7.16.7"] + ], + "linkType": "HARD", }] ]], ["@babel/helper-get-function-arity", [ @@ -627,6 +720,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@babel/types", "npm:7.16.0"] ], "linkType": "HARD", + }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-helper-get-function-arity-npm-7.16.7-987b1b1bed-1dfbdb56ef.zip/node_modules/@babel/helper-get-function-arity/", + "packageDependencies": [ + ["@babel/helper-get-function-arity", "npm:7.16.7"], + ["@babel/types", "npm:7.16.7"] + ], + "linkType": "HARD", }] ]], ["@babel/helper-hoist-variables", [ @@ -637,6 +738,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@babel/types", "npm:7.16.0"] ], "linkType": "HARD", + }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-helper-hoist-variables-npm-7.16.7-25cc3abba4-d9f544a8b9.zip/node_modules/@babel/helper-hoist-variables/", + "packageDependencies": [ + ["@babel/helper-hoist-variables", "npm:7.16.7"], + ["@babel/types", "npm:7.16.7"] + ], + "linkType": "HARD", }] ]], ["@babel/helper-member-expression-to-functions", [ @@ -681,6 +790,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@babel/types", "npm:7.16.0"] ], "linkType": "HARD", + }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-helper-module-imports-npm-7.16.7-19c74fd92b-5248e9ccce.zip/node_modules/@babel/helper-module-imports/", + "packageDependencies": [ + ["@babel/helper-module-imports", "npm:7.16.7"], + ["@babel/types", "npm:7.16.7"] + ], + "linkType": "HARD", }] ]], ["@babel/helper-module-transforms", [ @@ -712,6 +829,21 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@babel/types", "npm:7.16.0"] ], "linkType": "HARD", + }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-helper-module-transforms-npm-7.16.7-4b3d4b8254-79e70c79e6.zip/node_modules/@babel/helper-module-transforms/", + "packageDependencies": [ + ["@babel/helper-module-transforms", "npm:7.16.7"], + ["@babel/helper-environment-visitor", "npm:7.16.7"], + ["@babel/helper-module-imports", "npm:7.16.7"], + ["@babel/helper-simple-access", "npm:7.16.7"], + ["@babel/helper-split-export-declaration", "npm:7.16.7"], + ["@babel/helper-validator-identifier", "npm:7.16.7"], + ["@babel/template", "npm:7.16.7"], + ["@babel/traverse", "npm:7.16.7"], + ["@babel/types", "npm:7.16.7"] + ], + "linkType": "HARD", }] ]], ["@babel/helper-optimise-call-expression", [ @@ -825,6 +957,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@babel/types", "npm:7.16.0"] ], "linkType": "HARD", + }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-helper-simple-access-npm-7.16.7-c4dfb1f5e7-f7c7e1fa77.zip/node_modules/@babel/helper-simple-access/", + "packageDependencies": [ + ["@babel/helper-simple-access", "npm:7.16.7"], + ["@babel/types", "npm:7.16.7"] + ], + "linkType": "HARD", }] ]], ["@babel/helper-skip-transparent-expression-wrappers", [ @@ -877,6 +1017,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@babel/types", "npm:7.16.0"] ], "linkType": "HARD", + }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-helper-split-export-declaration-npm-7.16.7-5b9ae90171-a259453a63.zip/node_modules/@babel/helper-split-export-declaration/", + "packageDependencies": [ + ["@babel/helper-split-export-declaration", "npm:7.16.7"], + ["@babel/types", "npm:7.16.7"] + ], + "linkType": "HARD", }] ]], ["@babel/helper-validator-identifier", [ @@ -907,6 +1055,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@babel/helper-validator-identifier", "npm:7.15.7"] ], "linkType": "HARD", + }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-helper-validator-identifier-npm-7.16.7-8599fb00fc-43b4b4b721.zip/node_modules/@babel/helper-validator-identifier/", + "packageDependencies": [ + ["@babel/helper-validator-identifier", "npm:7.16.7"] + ], + "linkType": "HARD", }] ]], ["@babel/helper-validator-option", [ @@ -923,6 +1078,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@babel/helper-validator-option", "npm:7.14.5"] ], "linkType": "HARD", + }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-helper-validator-option-npm-7.16.7-d13e9c1d9e-e446b2cab7.zip/node_modules/@babel/helper-validator-option/", + "packageDependencies": [ + ["@babel/helper-validator-option", "npm:7.16.7"] + ], + "linkType": "HARD", }] ]], ["@babel/helper-wrap-function", [ @@ -958,6 +1120,16 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@babel/types", "npm:7.16.0"] ], "linkType": "HARD", + }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-helpers-npm-7.16.7-69d23ddac5-02775b84dd.zip/node_modules/@babel/helpers/", + "packageDependencies": [ + ["@babel/helpers", "npm:7.16.7"], + ["@babel/template", "npm:7.16.7"], + ["@babel/traverse", "npm:7.16.7"], + ["@babel/types", "npm:7.16.7"] + ], + "linkType": "HARD", }] ]], ["@babel/highlight", [ @@ -1000,6 +1172,16 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["js-tokens", "npm:4.0.0"] ], "linkType": "HARD", + }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-highlight-npm-7.16.7-c36734cd1b-fa1ee4f97f.zip/node_modules/@babel/highlight/", + "packageDependencies": [ + ["@babel/highlight", "npm:7.16.7"], + ["@babel/helper-validator-identifier", "npm:7.16.7"], + ["chalk", "npm:2.4.2"], + ["js-tokens", "npm:4.0.0"] + ], + "linkType": "HARD", }] ]], ["@babel/node", [ @@ -1063,6 +1245,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ], "linkType": "HARD", }], + ["npm:7.14.6", { + "packageLocation": "./.yarn/cache/@babel-parser-npm-7.14.6-c6c1f6245c-447ca2627e.zip/node_modules/@babel/parser/", + "packageDependencies": [ + ["@babel/parser", "npm:7.14.6"], + ["@babel/types", "npm:7.11.5"] + ], + "linkType": "HARD", + }], ["npm:7.16.2", { "packageLocation": "./.yarn/cache/@babel-parser-npm-7.16.2-2df15780e2-06a8f0d812.zip/node_modules/@babel/parser/", "packageDependencies": [ @@ -1070,6 +1260,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@babel/types", "npm:7.11.5"] ], "linkType": "HARD", + }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-parser-npm-7.16.7-276b590a17-30649fa885.zip/node_modules/@babel/parser/", + "packageDependencies": [ + ["@babel/parser", "npm:7.16.7"], + ["@babel/types", "npm:7.11.5"] + ], + "linkType": "HARD", }] ]], ["@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression", [ @@ -3467,6 +3665,16 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@babel/types", "npm:7.16.0"] ], "linkType": "HARD", + }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-template-npm-7.16.7-a18e444be8-bfc9a53563.zip/node_modules/@babel/template/", + "packageDependencies": [ + ["@babel/template", "npm:7.16.7"], + ["@babel/code-frame", "npm:7.16.7"], + ["@babel/parser", "npm:7.16.7"], + ["@babel/types", "npm:7.16.7"] + ], + "linkType": "HARD", }] ]], ["@babel/traverse", [ @@ -3549,6 +3757,23 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["globals", "npm:11.12.0"] ], "linkType": "HARD", + }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-traverse-npm-7.16.7-65523936f6-f76ac30150.zip/node_modules/@babel/traverse/", + "packageDependencies": [ + ["@babel/traverse", "npm:7.16.7"], + ["@babel/code-frame", "npm:7.16.7"], + ["@babel/generator", "npm:7.16.7"], + ["@babel/helper-environment-visitor", "npm:7.16.7"], + ["@babel/helper-function-name", "npm:7.16.7"], + ["@babel/helper-hoist-variables", "npm:7.16.7"], + ["@babel/helper-split-export-declaration", "npm:7.16.7"], + ["@babel/parser", "npm:7.16.7"], + ["@babel/types", "npm:7.16.7"], + ["debug", "virtual:24c0670a0dd5336de8e9d36ce94c8b696cc66bf2f157358e53a1649e6047bfc20104ef799a035ae68ee7761447ecfa64a6d54a5971d436f7ea6ab984abfab5de#npm:4.1.1"], + ["globals", "npm:11.12.0"] + ], + "linkType": "HARD", }] ]], ["@babel/types", [ @@ -3600,6 +3825,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["to-fast-properties", "npm:2.0.0"] ], "linkType": "HARD", + }], + ["npm:7.16.7", { + "packageLocation": "./.yarn/cache/@babel-types-npm-7.16.7-fa27eee382-72a6093b0a.zip/node_modules/@babel/types/", + "packageDependencies": [ + ["@babel/types", "npm:7.16.7"], + ["@babel/helper-validator-identifier", "npm:7.16.7"], + ["to-fast-properties", "npm:2.0.0"] + ], + "linkType": "HARD", }] ]], ["@bcoe/v8-coverage", [ @@ -4360,6 +4594,35 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD", }] ]], + ["@trivago/prettier-plugin-sort-imports", [ + ["npm:3.1.1", { + "packageLocation": "./.yarn/cache/@trivago-prettier-plugin-sort-imports-npm-3.1.1-3d238d3b28-291139fead.zip/node_modules/@trivago/prettier-plugin-sort-imports/", + "packageDependencies": [ + ["@trivago/prettier-plugin-sort-imports", "npm:3.1.1"] + ], + "linkType": "SOFT", + }], + ["virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:3.1.1", { + "packageLocation": "./.yarn/$$virtual/@trivago-prettier-plugin-sort-imports-virtual-da3d3a0781/0/cache/@trivago-prettier-plugin-sort-imports-npm-3.1.1-3d238d3b28-291139fead.zip/node_modules/@trivago/prettier-plugin-sort-imports/", + "packageDependencies": [ + ["@trivago/prettier-plugin-sort-imports", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:3.1.1"], + ["@babel/core", "npm:7.13.10"], + ["@babel/generator", "npm:7.13.9"], + ["@babel/parser", "npm:7.14.6"], + ["@babel/traverse", "npm:7.13.0"], + ["@babel/types", "npm:7.13.0"], + ["@types/prettier", null], + ["javascript-natural-sort", "npm:0.7.1"], + ["lodash", "npm:4.17.21"], + ["prettier", "npm:2.5.1"] + ], + "packagePeers": [ + "@types/prettier", + "prettier" + ], + "linkType": "HARD", + }] + ]], ["@tsconfig/node10", [ ["npm:1.0.8", { "packageLocation": "./.yarn/cache/@tsconfig-node10-npm-1.0.8-90a8cce25d-0336493b89.zip/node_modules/@tsconfig/node10/", @@ -6668,6 +6931,18 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["picocolors", "npm:1.0.0"] ], "linkType": "HARD", + }], + ["npm:4.19.1", { + "packageLocation": "./.yarn/cache/browserslist-npm-4.19.1-e9de2a4009-340af7f052.zip/node_modules/browserslist/", + "packageDependencies": [ + ["browserslist", "npm:4.19.1"], + ["caniuse-lite", "npm:1.0.30001298"], + ["electron-to-chromium", "npm:1.4.38"], + ["escalade", "npm:3.1.1"], + ["node-releases", "npm:2.0.1"], + ["picocolors", "npm:1.0.0"] + ], + "linkType": "HARD", }] ]], ["bser", [ @@ -6861,6 +7136,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["caniuse-lite", "npm:1.0.30001277"] ], "linkType": "HARD", + }], + ["npm:1.0.30001298", { + "packageLocation": "./.yarn/cache/caniuse-lite-npm-1.0.30001298-f7f894bcff-3f99e795cc.zip/node_modules/caniuse-lite/", + "packageDependencies": [ + ["caniuse-lite", "npm:1.0.30001298"] + ], + "linkType": "HARD", }] ]], ["capture-exit", [ @@ -8362,6 +8644,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["electron-to-chromium", "npm:1.3.888"] ], "linkType": "HARD", + }], + ["npm:1.4.38", { + "packageLocation": "./.yarn/cache/electron-to-chromium-npm-1.4.38-fccaeb9031-a37105253a.zip/node_modules/electron-to-chromium/", + "packageDependencies": [ + ["electron-to-chromium", "npm:1.4.38"] + ], + "linkType": "HARD", }] ]], ["emittery", [ @@ -11540,6 +11829,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD", }] ]], + ["javascript-natural-sort", [ + ["npm:0.7.1", { + "packageLocation": "./.yarn/cache/javascript-natural-sort-npm-0.7.1-9018625996-f097317419.zip/node_modules/javascript-natural-sort/", + "packageDependencies": [ + ["javascript-natural-sort", "npm:0.7.1"] + ], + "linkType": "HARD", + }] + ]], ["jest", [ ["npm:26.6.3", { "packageLocation": "./.yarn/cache/jest-npm-26.6.3-dafe93d52f-4ffcfefa2b.zip/node_modules/jest/", @@ -17540,6 +17838,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@commitlint/cli", "npm:12.1.4"], ["@commitlint/config-conventional", "npm:12.1.4"], ["@octokit/rest", "npm:18.6.0"], + ["@trivago/prettier-plugin-sort-imports", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:3.1.1"], ["@types/async", "npm:3.2.9"], ["@types/express", "npm:4.17.11"], ["@types/express-rate-limit", "npm:5.1.3"], diff --git a/.prettierrc.json b/.prettierrc.json deleted file mode 100644 index 96e3b8fbd..000000000 --- a/.prettierrc.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "endOfLine": "lf", - "useTabs": false, - "printWidth": 180, - "tabWidth": 2, - "singleQuote": true, - "bracketSpacing": true, - "jsxBracketSameLine": true, - "trailingComma": "es5", - "semi": true -} diff --git a/.yarn/cache/@babel-code-frame-npm-7.16.7-093eb9e124-79eb7c3207.zip b/.yarn/cache/@babel-code-frame-npm-7.16.7-093eb9e124-79eb7c3207.zip new file mode 100644 index 000000000..14fbea9b7 Binary files /dev/null and b/.yarn/cache/@babel-code-frame-npm-7.16.7-093eb9e124-79eb7c3207.zip differ diff --git a/.yarn/cache/@babel-compat-data-npm-7.16.4-9128f11195-5735fb9156.zip b/.yarn/cache/@babel-compat-data-npm-7.16.4-9128f11195-5735fb9156.zip new file mode 100644 index 000000000..bef1b2d60 Binary files /dev/null and b/.yarn/cache/@babel-compat-data-npm-7.16.4-9128f11195-5735fb9156.zip differ diff --git a/.yarn/cache/@babel-core-npm-7.13.10-57ebf35dd5-728249a0ba.zip b/.yarn/cache/@babel-core-npm-7.13.10-57ebf35dd5-728249a0ba.zip new file mode 100644 index 000000000..630900505 Binary files /dev/null and b/.yarn/cache/@babel-core-npm-7.13.10-57ebf35dd5-728249a0ba.zip differ diff --git a/.yarn/cache/@babel-generator-npm-7.16.7-3cf12729b6-1df435d689.zip b/.yarn/cache/@babel-generator-npm-7.16.7-3cf12729b6-1df435d689.zip new file mode 100644 index 000000000..9276275ec Binary files /dev/null and b/.yarn/cache/@babel-generator-npm-7.16.7-3cf12729b6-1df435d689.zip differ diff --git a/.yarn/cache/@babel-helper-compilation-targets-npm-7.16.7-8031641957-f7da620a08.zip b/.yarn/cache/@babel-helper-compilation-targets-npm-7.16.7-8031641957-f7da620a08.zip new file mode 100644 index 000000000..7888dd5c4 Binary files /dev/null and b/.yarn/cache/@babel-helper-compilation-targets-npm-7.16.7-8031641957-f7da620a08.zip differ diff --git a/.yarn/cache/@babel-helper-environment-visitor-npm-7.16.7-3ee2ba2019-da3195cad9.zip b/.yarn/cache/@babel-helper-environment-visitor-npm-7.16.7-3ee2ba2019-da3195cad9.zip new file mode 100644 index 000000000..9616a4da7 Binary files /dev/null and b/.yarn/cache/@babel-helper-environment-visitor-npm-7.16.7-3ee2ba2019-da3195cad9.zip differ diff --git a/.yarn/cache/@babel-helper-function-name-npm-7.16.7-aa24c7b296-919e9f34f4.zip b/.yarn/cache/@babel-helper-function-name-npm-7.16.7-aa24c7b296-919e9f34f4.zip new file mode 100644 index 000000000..8a05717c4 Binary files /dev/null and b/.yarn/cache/@babel-helper-function-name-npm-7.16.7-aa24c7b296-919e9f34f4.zip differ diff --git a/.yarn/cache/@babel-helper-get-function-arity-npm-7.16.7-987b1b1bed-1dfbdb56ef.zip b/.yarn/cache/@babel-helper-get-function-arity-npm-7.16.7-987b1b1bed-1dfbdb56ef.zip new file mode 100644 index 000000000..c5a4c6664 Binary files /dev/null and b/.yarn/cache/@babel-helper-get-function-arity-npm-7.16.7-987b1b1bed-1dfbdb56ef.zip differ diff --git a/.yarn/cache/@babel-helper-hoist-variables-npm-7.16.7-25cc3abba4-d9f544a8b9.zip b/.yarn/cache/@babel-helper-hoist-variables-npm-7.16.7-25cc3abba4-d9f544a8b9.zip new file mode 100644 index 000000000..27ea80669 Binary files /dev/null and b/.yarn/cache/@babel-helper-hoist-variables-npm-7.16.7-25cc3abba4-d9f544a8b9.zip differ diff --git a/.yarn/cache/@babel-helper-module-imports-npm-7.16.7-19c74fd92b-5248e9ccce.zip b/.yarn/cache/@babel-helper-module-imports-npm-7.16.7-19c74fd92b-5248e9ccce.zip new file mode 100644 index 000000000..dff2dd2a2 Binary files /dev/null and b/.yarn/cache/@babel-helper-module-imports-npm-7.16.7-19c74fd92b-5248e9ccce.zip differ diff --git a/.yarn/cache/@babel-helper-module-transforms-npm-7.16.7-4b3d4b8254-79e70c79e6.zip b/.yarn/cache/@babel-helper-module-transforms-npm-7.16.7-4b3d4b8254-79e70c79e6.zip new file mode 100644 index 000000000..8b9169661 Binary files /dev/null and b/.yarn/cache/@babel-helper-module-transforms-npm-7.16.7-4b3d4b8254-79e70c79e6.zip differ diff --git a/.yarn/cache/@babel-helper-simple-access-npm-7.16.7-c4dfb1f5e7-f7c7e1fa77.zip b/.yarn/cache/@babel-helper-simple-access-npm-7.16.7-c4dfb1f5e7-f7c7e1fa77.zip new file mode 100644 index 000000000..f596751a4 Binary files /dev/null and b/.yarn/cache/@babel-helper-simple-access-npm-7.16.7-c4dfb1f5e7-f7c7e1fa77.zip differ diff --git a/.yarn/cache/@babel-helper-split-export-declaration-npm-7.16.7-5b9ae90171-a259453a63.zip b/.yarn/cache/@babel-helper-split-export-declaration-npm-7.16.7-5b9ae90171-a259453a63.zip new file mode 100644 index 000000000..e062f0a74 Binary files /dev/null and b/.yarn/cache/@babel-helper-split-export-declaration-npm-7.16.7-5b9ae90171-a259453a63.zip differ diff --git a/.yarn/cache/@babel-helper-validator-identifier-npm-7.16.7-8599fb00fc-43b4b4b721.zip b/.yarn/cache/@babel-helper-validator-identifier-npm-7.16.7-8599fb00fc-43b4b4b721.zip new file mode 100644 index 000000000..78889cf38 Binary files /dev/null and b/.yarn/cache/@babel-helper-validator-identifier-npm-7.16.7-8599fb00fc-43b4b4b721.zip differ diff --git a/.yarn/cache/@babel-helper-validator-option-npm-7.16.7-d13e9c1d9e-e446b2cab7.zip b/.yarn/cache/@babel-helper-validator-option-npm-7.16.7-d13e9c1d9e-e446b2cab7.zip new file mode 100644 index 000000000..1c89f2e79 Binary files /dev/null and b/.yarn/cache/@babel-helper-validator-option-npm-7.16.7-d13e9c1d9e-e446b2cab7.zip differ diff --git a/.yarn/cache/@babel-helpers-npm-7.16.7-69d23ddac5-02775b84dd.zip b/.yarn/cache/@babel-helpers-npm-7.16.7-69d23ddac5-02775b84dd.zip new file mode 100644 index 000000000..b28689bde Binary files /dev/null and b/.yarn/cache/@babel-helpers-npm-7.16.7-69d23ddac5-02775b84dd.zip differ diff --git a/.yarn/cache/@babel-highlight-npm-7.16.7-c36734cd1b-fa1ee4f97f.zip b/.yarn/cache/@babel-highlight-npm-7.16.7-c36734cd1b-fa1ee4f97f.zip new file mode 100644 index 000000000..855182902 Binary files /dev/null and b/.yarn/cache/@babel-highlight-npm-7.16.7-c36734cd1b-fa1ee4f97f.zip differ diff --git a/.yarn/cache/@babel-parser-npm-7.14.6-c6c1f6245c-447ca2627e.zip b/.yarn/cache/@babel-parser-npm-7.14.6-c6c1f6245c-447ca2627e.zip new file mode 100644 index 000000000..bb3c8f282 Binary files /dev/null and b/.yarn/cache/@babel-parser-npm-7.14.6-c6c1f6245c-447ca2627e.zip differ diff --git a/.yarn/cache/@babel-parser-npm-7.16.7-276b590a17-30649fa885.zip b/.yarn/cache/@babel-parser-npm-7.16.7-276b590a17-30649fa885.zip new file mode 100644 index 000000000..7ff6c047c Binary files /dev/null and b/.yarn/cache/@babel-parser-npm-7.16.7-276b590a17-30649fa885.zip differ diff --git a/.yarn/cache/@babel-template-npm-7.16.7-a18e444be8-bfc9a53563.zip b/.yarn/cache/@babel-template-npm-7.16.7-a18e444be8-bfc9a53563.zip new file mode 100644 index 000000000..e094379a9 Binary files /dev/null and b/.yarn/cache/@babel-template-npm-7.16.7-a18e444be8-bfc9a53563.zip differ diff --git a/.yarn/cache/@babel-traverse-npm-7.16.7-65523936f6-f76ac30150.zip b/.yarn/cache/@babel-traverse-npm-7.16.7-65523936f6-f76ac30150.zip new file mode 100644 index 000000000..eb3dedc42 Binary files /dev/null and b/.yarn/cache/@babel-traverse-npm-7.16.7-65523936f6-f76ac30150.zip differ diff --git a/.yarn/cache/@babel-types-npm-7.16.7-fa27eee382-72a6093b0a.zip b/.yarn/cache/@babel-types-npm-7.16.7-fa27eee382-72a6093b0a.zip new file mode 100644 index 000000000..84828a287 Binary files /dev/null and b/.yarn/cache/@babel-types-npm-7.16.7-fa27eee382-72a6093b0a.zip differ diff --git a/.yarn/cache/@trivago-prettier-plugin-sort-imports-npm-3.1.1-3d238d3b28-291139fead.zip b/.yarn/cache/@trivago-prettier-plugin-sort-imports-npm-3.1.1-3d238d3b28-291139fead.zip new file mode 100644 index 000000000..9dbb22842 Binary files /dev/null and b/.yarn/cache/@trivago-prettier-plugin-sort-imports-npm-3.1.1-3d238d3b28-291139fead.zip differ diff --git a/.yarn/cache/browserslist-npm-4.19.1-e9de2a4009-340af7f052.zip b/.yarn/cache/browserslist-npm-4.19.1-e9de2a4009-340af7f052.zip new file mode 100644 index 000000000..6225c54ff Binary files /dev/null and b/.yarn/cache/browserslist-npm-4.19.1-e9de2a4009-340af7f052.zip differ diff --git a/.yarn/cache/caniuse-lite-npm-1.0.30001298-f7f894bcff-3f99e795cc.zip b/.yarn/cache/caniuse-lite-npm-1.0.30001298-f7f894bcff-3f99e795cc.zip new file mode 100644 index 000000000..2ef09fe35 Binary files /dev/null and b/.yarn/cache/caniuse-lite-npm-1.0.30001298-f7f894bcff-3f99e795cc.zip differ diff --git a/.yarn/cache/electron-to-chromium-npm-1.4.38-fccaeb9031-a37105253a.zip b/.yarn/cache/electron-to-chromium-npm-1.4.38-fccaeb9031-a37105253a.zip new file mode 100644 index 000000000..2eae6bb28 Binary files /dev/null and b/.yarn/cache/electron-to-chromium-npm-1.4.38-fccaeb9031-a37105253a.zip differ diff --git a/.yarn/cache/javascript-natural-sort-npm-0.7.1-9018625996-f097317419.zip b/.yarn/cache/javascript-natural-sort-npm-0.7.1-9018625996-f097317419.zip new file mode 100644 index 000000000..fe04bb284 Binary files /dev/null and b/.yarn/cache/javascript-natural-sort-npm-0.7.1-9018625996-f097317419.zip differ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 71c2e4bf7..8bb400b87 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo Examples of behavior that contributes to creating a positive environment include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting +- The use of sexualized language or imagery and unwelcome sexual attention or advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 90e674f04..942c56a70 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,13 +14,13 @@ Additional information is available on the - [How Do I Contribute?](#how-do-i-contribute) - [Development](#development) - [Reporting Bugs](#reporting-bugs) - - [Issue Search](#issue-search) - - [Check Website For Solution](#check-website-for-solution) - - [Chat](#chat) - - [Check If It's Been Fixed](#check-if-its-been-fixed) + - [Issue Search](#issue-search) + - [Check Website For Solution](#check-website-for-solution) + - [Chat](#chat) + - [Check If It's Been Fixed](#check-if-its-been-fixed) - [Request Features](#request-features) - - [Submitting a Pull Request](#submitting-a-pull-request) - - [Make Changes and Commit](#make-changes-and-commit) + - [Submitting a Pull Request](#submitting-a-pull-request) + - [Make Changes and Commit](#make-changes-and-commit) - [Update Tests](#update-tests) - [Develop Plugins](#develop-plugins) @@ -29,10 +29,10 @@ Additional information is available on the There are different ways to contribute, each with a different level of involvement and technical knowledge required, such as: -* [Reporting Bugs](#reporting-bugs) -* [Request Features](#request-features) -* [Develop Plugins](#develop-plugins) -* [Improve Documentation](http://www.verdaccio.org/docs/en/installation.html) +- [Reporting Bugs](#reporting-bugs) +- [Request Features](#request-features) +- [Develop Plugins](#develop-plugins) +- [Improve Documentation](http://www.verdaccio.org/docs/en/installation.html) **Please read this document carefully. It will help maintainers and readers in solving your issue(s), evaluating your feature request, etc.** @@ -41,8 +41,8 @@ in solving your issue(s), evaluating your feature request, etc.** Development guides can be found on the [wiki](https://github.com/verdaccio/verdaccio/wiki): -* [Building the project](https://github.com/verdaccio/verdaccio/wiki/Build-Source-Code) -* [Running, debugging, and testing](https://github.com/verdaccio/verdaccio/wiki/Running-and-Debugging-tests) +- [Building the project](https://github.com/verdaccio/verdaccio/wiki/Build-Source-Code) +- [Running, debugging, and testing](https://github.com/verdaccio/verdaccio/wiki/Running-and-Debugging-tests) ## Reporting Bugs @@ -51,7 +51,7 @@ We welcome clear, detailed bug reports. **Bugs are considered features that are not working as described in documentation.** -If you've found a bug in Verdaccio **that isn't a security risk**, please file +If you've found a bug in Verdaccio **that isn't a security risk**, please file a report in our [issue tracker](https://github.com/verdaccio/verdaccio/issues). **NOTE: Verdaccio still does not support all npm commands. Some were not @@ -66,7 +66,7 @@ Additionally, we have labelled questions for easy follow-up as [questions](https If so, up-vote it (using GitHub reactions) or add additional helpful details to the existing issue to show that it's affecting multiple people. - + ### Check Website For Solution Some of the most popular topics can be found in our website(http://www.verdaccio.org/docs/en/installation.html) @@ -89,10 +89,10 @@ the project. Then, detail your request, ensuring context and use case is provide **Please provide:** -* A detailed description the advantages of your request -* Whether or not it's compatible with `npm` and `yarn` -* A potential implementation or design -* Whatever else you have in your mind 🤓 +- A detailed description the advantages of your request +- Whether or not it's compatible with `npm` and `yarn` +- A potential implementation or design +- Whatever else you have in your mind 🤓 ### Submitting a Pull Request @@ -137,8 +137,8 @@ semantic versioning. For example: -* `feat: A new feature` -* `fix: A bug fix` +- `feat: A new feature` +- `fix: A bug fix` A commit of the type feat introduces a new feature to the codebase (this correlates with MINOR in semantic versioning). @@ -174,12 +174,13 @@ If you need help with how testing works, please [refer to the following guide](h features without tests will not be merged.** Things excluded from tests: -* Documentation -* Website -* Build -* Deployment -* Assets -* Flow types + +- Documentation +- Website +- Build +- Deployment +- Assets +- Flow types ## Develop Plugins @@ -188,7 +189,7 @@ Plugins are add-ons that extend the functionality of the application. If you want to develop your own plugin: 1. Check whether there is a legacy Sinopia plugin for the feature that you need - via [npmjs](https://www.npmjs.com/search?q=sinopia) + via [npmjs](https://www.npmjs.com/search?q=sinopia) 2. Keep in mind the [life-cycle to load a plugin](https://verdaccio.org/docs/en/dev-plugins) 3. You are free to host your plugin in your repository or ours (just ask) 4. Provide a detailed description of your plugin to help users understand it diff --git a/SECURITY.md b/SECURITY.md index 2fc709f8b..10236c3ce 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,13 +4,12 @@ The following table describes the versions of this project that are currently supported with security updates: -| Version | Supported | -| ------- | ------------------ | -| 2.x | :x: | -| 3.x | :x: | -| 4.x | :white_check_mark: (until 1st July 2021) | -| 5.x | :white_check_mark: | - +| Version | Supported | +| ------- | ---------------------------------------- | +| 2.x | :x: | +| 3.x | :x: | +| 4.x | :white_check_mark: (until 1st July 2021) | +| 5.x | :white_check_mark: | ## Responsible disclosure security policy @@ -28,11 +27,11 @@ At Verdaccio, we consider the security of our systems a top priority. But no mat If you discover a security vulnerability, please use one of the following means of communications to report it to us: -* Report the security issue to the Node.js Security WG through the [HackerOne program](https://hackerone.com/nodejs-ecosystem) for ecosystem modules on npm, or to [Snyk Security Team](https://snyk.io/vulnerability-disclosure). They will help triage the security issue and work with all involved parties to remediate and release a fix. +- Report the security issue to the Node.js Security WG through the [HackerOne program](https://hackerone.com/nodejs-ecosystem) for ecosystem modules on npm, or to [Snyk Security Team](https://snyk.io/vulnerability-disclosure). They will help triage the security issue and work with all involved parties to remediate and release a fix. Note that time-frame and processes are subject to each program’s own policy. -* Report the security issue to the project maintainers directly at verdaccio@pm.me. If the report contains highly sensitive information, please be advised to encrypt your findings using our [PGP key](https://verdaccio.nyc3.digitaloceanspaces.com/gpg/publickey.verdaccio@pm.me.asc) which is also available in this document. +- Report the security issue to the project maintainers directly at verdaccio@pm.me. If the report contains highly sensitive information, please be advised to encrypt your findings using our [PGP key](https://verdaccio.nyc3.digitaloceanspaces.com/gpg/publickey.verdaccio@pm.me.asc) which is also available in this document. Your efforts to responsibly disclose your findings are sincerely appreciated and will be taken into account to acknowledge your contributions. diff --git a/conf/README.md b/conf/README.md index 4be65ec55..d7d22ec41 100644 --- a/conf/README.md +++ b/conf/README.md @@ -2,8 +2,8 @@ This directory host the default configuration file, but you can find more here: -* [https://verdaccio.org/docs/en/installation](https://verdaccio.org/docs/en/installation) -* [Chat with us](http://chat.verdaccio.org) <- You need a Discord account -* [Follow us on Twitter](https://twitter.com/verdaccio_npm) +- [https://verdaccio.org/docs/en/installation](https://verdaccio.org/docs/en/installation) +- [Chat with us](http://chat.verdaccio.org) <- You need a Discord account +- [Follow us on Twitter](https://twitter.com/verdaccio_npm) Enjoy Verdaccio ! diff --git a/debug/bootstrap.js b/debug/bootstrap.js index 4ac9630fe..33a432cfb 100644 --- a/debug/bootstrap.js +++ b/debug/bootstrap.js @@ -1,6 +1,6 @@ // this file aims to help local debugging with hot transpilation // it requires BABEL_ENV=registry set as env variable require('@babel/register')({ - extensions: [".ts", ".js"] + extensions: ['.ts', '.js'], }); require('../src/lib/cli'); diff --git a/eslintrc.js b/eslintrc.js index 968d91420..34ed96bb5 100644 --- a/eslintrc.js +++ b/eslintrc.js @@ -1,100 +1,100 @@ module.exports = { - "extends": [ - "eslint:recommended", - "google", - "plugin:jest/recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "plugin:import/typescript", - "prettier" + extends: [ + 'eslint:recommended', + 'google', + 'plugin:jest/recommended', + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:import/typescript', + 'prettier', ], - "plugins": ["import", "jest"], - "env": { - "es6": true, - "node": true, - "jest": true + plugins: ['import', 'jest'], + env: { + es6: true, + node: true, + jest: true, }, - "globals": { - "__APP_VERSION__": true + globals: { + __APP_VERSION__: true, }, - "parserOptions": { - "allowImportExportEverywhere": true, - "sourceType": "module", - "ecmaVersion": 11, - "ecmaFeatures": { - "impliedStrict": true, - "jsx": true - } + parserOptions: { + allowImportExportEverywhere: true, + sourceType: 'module', + ecmaVersion: 11, + ecmaFeatures: { + impliedStrict: true, + jsx: true, + }, }, - "settings": { - "import/resolver": { - "node": { - "extensions": [".js", ".ts", ".tsx"] - } - } + settings: { + 'import/resolver': { + node: { + extensions: ['.js', '.ts', '.tsx'], + }, + }, }, - "parser": "@typescript-eslint/parser", - "rules": { - "curly": ["error", "all"], - "react/prop-types": 0, - "jest/no-export": 0, - "jest/no-test-callback": 0, - "jest/expect-expect": 0, - "jest/no-try-expect": 0, - "jest/no-done-callback": "off", - "jest/no-conditional-expect": "off", - "keyword-spacing": "off", - "no-tabs": "off", - "no-useless-escape": "off", - "padded-blocks": "off", - "require-jsdoc": "off", - "valid-jsdoc": "off", - "import/order": ["warn"], - "eol-last": "error", - "no-irregular-whitespace": "error", - "no-mixed-spaces-and-tabs": ["error", "smart-tabs"], - "no-trailing-spaces": "error", - "camelcase": "off", - "guard-for-in": "error", - "new-cap": "error", - "max-len": ["error", 180], - "no-console": ["error", { "allow": ["warn"] }], - "no-constant-condition": "error", - "no-debugger": "error", - "no-empty": "error", - "no-fallthrough": "error", - "no-invalid-this": "error", - "no-new-require": "error", - "no-undef": "error", - "no-unreachable": "error", - "no-var": "error", - "one-var": "error", - "prefer-rest-params": "error", - "prefer-spread": "error", - "handle-callback-err": 0, - "prefer-const": 0, - "@typescript-eslint/camelcase": 0, - "@typescript-eslint/ban-ts-ignore": 0, - "@typescript-eslint/no-var-requires": 0, - "@typescript-eslint/no-inferrable-types": 0, - "@typescript-eslint/no-empty-function": 0, - "@typescript-eslint/no-this-alias": 0, - "@typescript-eslint/no-use-before-define": 0, - "@typescript-eslint/array-type": ["error"], - "@typescript-eslint/no-explicit-any": 0, - "@typescript-eslint/indent": 0, - "@typescript-eslint/ban-ts-comment": 0, - "@typescript-eslint/ban-types": 0, - "@typescript-eslint/explicit-module-boundary-types": 0, + parser: '@typescript-eslint/parser', + rules: { + curly: ['error', 'all'], + 'react/prop-types': 0, + 'jest/no-export': 0, + 'jest/no-test-callback': 0, + 'jest/expect-expect': 0, + 'jest/no-try-expect': 0, + 'jest/no-done-callback': 'off', + 'jest/no-conditional-expect': 'off', + 'keyword-spacing': 'off', + 'no-tabs': 'off', + 'no-useless-escape': 'off', + 'padded-blocks': 'off', + 'require-jsdoc': 'off', + 'valid-jsdoc': 'off', + 'import/order': ['warn'], + 'eol-last': 'error', + 'no-irregular-whitespace': 'error', + 'no-mixed-spaces-and-tabs': ['error', 'smart-tabs'], + 'no-trailing-spaces': 'error', + camelcase: 'off', + 'guard-for-in': 'error', + 'new-cap': 'error', + 'max-len': ['error', 180], + 'no-console': ['error', { allow: ['warn'] }], + 'no-constant-condition': 'error', + 'no-debugger': 'error', + 'no-empty': 'error', + 'no-fallthrough': 'error', + 'no-invalid-this': 'error', + 'no-new-require': 'error', + 'no-undef': 'error', + 'no-unreachable': 'error', + 'no-var': 'error', + 'one-var': 'error', + 'prefer-rest-params': 'error', + 'prefer-spread': 'error', + 'handle-callback-err': 0, + 'prefer-const': 0, + '@typescript-eslint/camelcase': 0, + '@typescript-eslint/ban-ts-ignore': 0, + '@typescript-eslint/no-var-requires': 0, + '@typescript-eslint/no-inferrable-types': 0, + '@typescript-eslint/no-empty-function': 0, + '@typescript-eslint/no-this-alias': 0, + '@typescript-eslint/no-use-before-define': 0, + '@typescript-eslint/array-type': ['error'], + '@typescript-eslint/no-explicit-any': 0, + '@typescript-eslint/indent': 0, + '@typescript-eslint/ban-ts-comment': 0, + '@typescript-eslint/ban-types': 0, + '@typescript-eslint/explicit-module-boundary-types': 0, // rules to fix - "no-unused-vars": ["warn", { "vars": "all", "args": "none" }], - "jest/no-identical-title": ["warn"], - "prefer-promise-reject-errors": ["warn"], - "jest/no-disabled-tests": ["warn"], - "jest/no-commented-out-tests": ["warn"], - "@typescript-eslint/prefer-optional-chain": ["warn"], - "@typescript-eslint/explicit-member-accessibility": ["warn"], - "@typescript-eslint/no-unused-vars": ["warn"] - } -} + 'no-unused-vars': ['warn', { vars: 'all', args: 'none' }], + 'jest/no-identical-title': ['warn'], + 'prefer-promise-reject-errors': ['warn'], + 'jest/no-disabled-tests': ['warn'], + 'jest/no-commented-out-tests': ['warn'], + '@typescript-eslint/prefer-optional-chain': ['warn'], + '@typescript-eslint/explicit-member-accessibility': ['warn'], + '@typescript-eslint/no-unused-vars': ['warn'], + }, +}; diff --git a/index.js b/index.js index 86b45f8e8..1e9c3762b 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -export {default as startVerdaccio} from './build/index'; +export { default as startVerdaccio } from './build/index'; diff --git a/jest.config.js b/jest.config.js index de75148a8..698ba366b 100644 --- a/jest.config.js +++ b/jest.config.js @@ -4,14 +4,14 @@ module.exports = { name: 'verdaccio-unit-jest', verbose: true, collectCoverage: true, - reporters: ["default", ["jest-junit", { outputDirectory: 'reports' }]], + reporters: ['default', ['jest-junit', { outputDirectory: 'reports' }]], moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], testURL: 'http://localhost', testRegex: '(test/unit.*\\.spec)\\.ts', // Some unit tests rely on data folders that look like packages. This confuses jest-hast-map // when it tries to scan for package.json files. transform: { - '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest' + '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest', }, modulePathIgnorePatterns: [ '/test/unit/partials/mock-store/.*/package.json', @@ -31,14 +31,6 @@ module.exports = { '/build', '/.vscode/', ], - testPathIgnorePatterns: [ - '__snapshots__', - '/build', - ], - coveragePathIgnorePatterns: [ - 'node_modules', - 'fixtures', - '/src/api/debug', - '/test', - ] + testPathIgnorePatterns: ['__snapshots__', '/build'], + coveragePathIgnorePatterns: ['node_modules', 'fixtures', '/src/api/debug', '/test'], }; diff --git a/package.json b/package.json index 5ebb39a4e..8d2fdb68c 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,7 @@ "@commitlint/cli": "12.1.4", "@commitlint/config-conventional": "12.1.4", "@octokit/rest": "18.6.0", + "@trivago/prettier-plugin-sort-imports": "3.1.1", "@types/async": "3.2.9", "@types/express": "4.17.11", "@types/express-rate-limit": "5.1.3", @@ -157,8 +158,8 @@ "release": "standard-version -a -s", "type-check": "tsc --noEmit", "type-check:watch": "yarn run type-check -- --watch", - "format": "prettier --single-quote --trailing-comma none --write \"{src,test}/**/*.ts\"", - "format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,yml,yaml,md}\" --debug-check", + "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,yml,yaml,md}\"", + "format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,yml,yaml,md}\"", "test": "yarn run test:unit", "test:clean": "npx jest --clearCache", "test:unit": "cross-env NODE_ENV=test TZ=UTC FORCE_COLOR=1 jest --config ./jest.config.js --maxWorkers 2 --passWithNoTests", diff --git a/prettier.config.js b/prettier.config.js new file mode 100644 index 000000000..ec7f87246 --- /dev/null +++ b/prettier.config.js @@ -0,0 +1,15 @@ +module.exports = { + endOfLine: 'lf', + useTabs: false, + printWidth: 180, + tabWidth: 2, + singleQuote: true, + bracketSpacing: true, + trailingComma: 'es5', + semi: true, + plugins: [require('@trivago/prettier-plugin-sort-imports')], + importOrder: ['^@verdaccio/(.*)$', '^[./]'], + importOrderSeparation: true, + importOrderParserPlugins: ['typescript', 'classProperties', 'jsx'], + importOrderSortSpecifiers: true, +}; diff --git a/scripts/run-verdaccio.js b/scripts/run-verdaccio.js index 739f5d5be..ad796ffa4 100644 --- a/scripts/run-verdaccio.js +++ b/scripts/run-verdaccio.js @@ -3,6 +3,6 @@ // this file aims to help local debugging with hot transpilation // it requires BABEL_ENV=registry set as env variable require('@babel/register')({ - extensions: [".ts", ".js"] + extensions: ['.ts', '.js'], }); require('../src/lib/cli'); diff --git a/scripts/trigger-release.ts b/scripts/trigger-release.ts index 3cd89b07f..14e031fa6 100644 --- a/scripts/trigger-release.ts +++ b/scripts/trigger-release.ts @@ -1,7 +1,6 @@ /* eslint-disable no-console */ - -import { execSync } from 'child_process'; import { Octokit } from '@octokit/rest'; +import { execSync } from 'child_process'; const [, , /* node */ /* file */ tag] = process.argv; diff --git a/src/api/debug/index.ts b/src/api/debug/index.ts index 11c225240..a39317b82 100644 --- a/src/api/debug/index.ts +++ b/src/api/debug/index.ts @@ -1,26 +1,24 @@ -import { $ResponseExtend, $RequestExtend, $NextFunctionVer } from '../../../types'; -import _ from 'lodash'; import { Application } from 'express'; +import _ from 'lodash'; + +import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../../../types'; export default (app: Application, selfPath: string): void => { // Hook for tests only - app.get( - '/-/_debug', - function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void { - const doGarbabeCollector = _.isNil(global.gc) === false; + app.get('/-/_debug', function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void { + const doGarbabeCollector = _.isNil(global.gc) === false; - if (doGarbabeCollector) { - global.gc(); - } - - next({ - pid: process.pid, - // @ts-ignore - main: process.mainModule.filename, - conf: selfPath, - mem: process.memoryUsage(), - gc: doGarbabeCollector - }); + if (doGarbabeCollector) { + global.gc(); } - ); + + next({ + pid: process.pid, + // @ts-ignore + main: process.mainModule.filename, + conf: selfPath, + mem: process.memoryUsage(), + gc: doGarbabeCollector, + }); + }); }; diff --git a/src/api/endpoint/api/dist-tags.ts b/src/api/endpoint/api/dist-tags.ts index 465566368..4fbc841e7 100644 --- a/src/api/endpoint/api/dist-tags.ts +++ b/src/api/endpoint/api/dist-tags.ts @@ -1,25 +1,17 @@ -import { media, allow } from '../../middleware'; -import { - IAuth, - $ResponseExtend, - $RequestExtend, - $NextFunctionVer, - IStorageHandler -} from '../../../../types'; -import { API_MESSAGE, HTTP_STATUS, DIST_TAGS } from '../../../lib/constants'; -import mime from 'mime'; -import _ from 'lodash'; import { Router } from 'express'; +import _ from 'lodash'; +import mime from 'mime'; + import { VerdaccioError } from '@verdaccio/commons-api'; import { Package } from '@verdaccio/types'; +import { $NextFunctionVer, $RequestExtend, $ResponseExtend, IAuth, IStorageHandler } from '../../../../types'; +import { API_MESSAGE, DIST_TAGS, HTTP_STATUS } from '../../../lib/constants'; +import { allow, media } from '../../middleware'; + export default function (route: Router, auth: IAuth, storage: IStorageHandler): void { const can = allow(auth); - const tag_package_version = function ( - req: $RequestExtend, - res: $ResponseExtend, - next: $NextFunctionVer - ): $NextFunctionVer { + const tag_package_version = function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): $NextFunctionVer { if (_.isString(req.body) === false) { return next('route'); } @@ -38,74 +30,48 @@ export default function (route: Router, auth: IAuth, storage: IStorageHandler): // tagging a package route.put('/:package/:tag', can('publish'), media(mime.getType('json')), tag_package_version); - route.post( - '/-/package/:package/dist-tags/:tag', - can('publish'), - media(mime.getType('json')), - tag_package_version - ); + route.post('/-/package/:package/dist-tags/:tag', can('publish'), media(mime.getType('json')), tag_package_version); - route.put( - '/-/package/:package/dist-tags/:tag', - can('publish'), - media(mime.getType('json')), - tag_package_version - ); + route.put('/-/package/:package/dist-tags/:tag', can('publish'), media(mime.getType('json')), tag_package_version); - route.delete( - '/-/package/:package/dist-tags/:tag', - can('publish'), - function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void { - const tags = {}; - tags[req.params.tag] = null; - storage.mergeTags(req.params.package, tags, function (err: VerdaccioError): $NextFunctionVer { + route.delete('/-/package/:package/dist-tags/:tag', can('publish'), function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void { + const tags = {}; + tags[req.params.tag] = null; + storage.mergeTags(req.params.package, tags, function (err: VerdaccioError): $NextFunctionVer { + if (err) { + return next(err); + } + res.status(HTTP_STATUS.CREATED); + return next({ + ok: API_MESSAGE.TAG_REMOVED, + }); + }); + }); + + route.get('/-/package/:package/dist-tags', can('access'), function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void { + storage.getPackage({ + name: req.params.package, + uplinksLook: true, + req, + callback: function (err: VerdaccioError, info: Package): $NextFunctionVer { if (err) { return next(err); } - res.status(HTTP_STATUS.CREATED); - return next({ - ok: API_MESSAGE.TAG_REMOVED - }); + + next(info[DIST_TAGS]); + }, + }); + }); + + route.post('/-/package/:package/dist-tags', can('publish'), function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void { + storage.mergeTags(req.params.package, req.body, function (err: VerdaccioError): $NextFunctionVer { + if (err) { + return next(err); + } + res.status(HTTP_STATUS.CREATED); + return next({ + ok: API_MESSAGE.TAG_UPDATED, }); - } - ); - - route.get( - '/-/package/:package/dist-tags', - can('access'), - function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void { - storage.getPackage({ - name: req.params.package, - uplinksLook: true, - req, - callback: function (err: VerdaccioError, info: Package): $NextFunctionVer { - if (err) { - return next(err); - } - - next(info[DIST_TAGS]); - } - }); - } - ); - - route.post( - '/-/package/:package/dist-tags', - can('publish'), - function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void { - storage.mergeTags( - req.params.package, - req.body, - function (err: VerdaccioError): $NextFunctionVer { - if (err) { - return next(err); - } - res.status(HTTP_STATUS.CREATED); - return next({ - ok: API_MESSAGE.TAG_UPDATED - }); - } - ); - } - ); + }); + }); } diff --git a/src/api/endpoint/api/package.ts b/src/api/endpoint/api/package.ts index 5c0245f35..89856b57a 100644 --- a/src/api/endpoint/api/package.ts +++ b/src/api/endpoint/api/package.ts @@ -1,24 +1,14 @@ -import { allow } from '../../middleware'; -import { convertDistRemoteToLocalTarballUrls, getVersion, ErrorCode } from '../../../lib/utils'; -import { HEADERS, DIST_TAGS, API_ERROR } from '../../../lib/constants'; -import { - IAuth, - $ResponseExtend, - $RequestExtend, - $NextFunctionVer, - IStorageHandler -} from '../../../../types'; -import { Config, Package } from '@verdaccio/types'; import { Router } from 'express'; import _ from 'lodash'; -const downloadStream = ( - packageName: string, - filename: string, - storage: any, - req: $RequestExtend, - res: $ResponseExtend -): void => { +import { Config, Package } from '@verdaccio/types'; + +import { $NextFunctionVer, $RequestExtend, $ResponseExtend, IAuth, IStorageHandler } from '../../../../types'; +import { API_ERROR, DIST_TAGS, HEADERS } from '../../../lib/constants'; +import { ErrorCode, convertDistRemoteToLocalTarballUrls, getVersion } from '../../../lib/utils'; +import { allow } from '../../middleware'; + +const downloadStream = (packageName: string, filename: string, storage: any, req: $RequestExtend, res: $ResponseExtend): void => { const stream = storage.getTarball(packageName, filename); stream.on('content-length', function (content): void { @@ -33,101 +23,78 @@ const downloadStream = ( stream.pipe(res); }; -const redirectOrDownloadStream = ( - packageName: string, - filename: string, - storage: any, - req: $RequestExtend, - res: $ResponseExtend, - config: Config -): void => { +const redirectOrDownloadStream = (packageName: string, filename: string, storage: any, req: $RequestExtend, res: $ResponseExtend, config: Config): void => { const tarballUrlRedirect = _.get(config, 'experiments.tarball_url_redirect'); - storage.hasLocalTarball(packageName, filename).then(hasLocalTarball => { - if (hasLocalTarball) { - const context = { packageName, filename }; - const tarballUrl = typeof tarballUrlRedirect === 'function' - ? tarballUrlRedirect(context) - : _.template(tarballUrlRedirect)(context); - res.redirect(tarballUrl); - } else { - downloadStream(packageName, filename, storage, req, res) - } - }).catch(err => { - res.locals.report_error(err); - }); -} + storage + .hasLocalTarball(packageName, filename) + .then((hasLocalTarball) => { + if (hasLocalTarball) { + const context = { packageName, filename }; + const tarballUrl = typeof tarballUrlRedirect === 'function' ? tarballUrlRedirect(context) : _.template(tarballUrlRedirect)(context); + res.redirect(tarballUrl); + } else { + downloadStream(packageName, filename, storage, req, res); + } + }) + .catch((err) => { + res.locals.report_error(err); + }); +}; -export default function ( - route: Router, - auth: IAuth, - storage: IStorageHandler, - config: Config -): void { +export default function (route: Router, auth: IAuth, storage: IStorageHandler, config: Config): void { const can = allow(auth); // TODO: anonymous user? - route.get( - '/:package/:version?', - can('access'), - function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void { - const getPackageMetaCallback = function (err, metadata: Package): void { - if (err) { - return next(err); - } - metadata = convertDistRemoteToLocalTarballUrls(metadata, req, config.url_prefix); + route.get('/:package/:version?', can('access'), function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void { + const getPackageMetaCallback = function (err, metadata: Package): void { + if (err) { + return next(err); + } + metadata = convertDistRemoteToLocalTarballUrls(metadata, req, config.url_prefix); - let queryVersion = req.params.version; - if (_.isNil(queryVersion)) { - return next(metadata); - } + let queryVersion = req.params.version; + if (_.isNil(queryVersion)) { + return next(metadata); + } - let version = getVersion(metadata, queryVersion); - if (_.isNil(version) === false) { - return next(version); - } + let version = getVersion(metadata, queryVersion); + if (_.isNil(version) === false) { + return next(version); + } - if (_.isNil(metadata[DIST_TAGS]) === false) { - if (_.isNil(metadata[DIST_TAGS][queryVersion]) === false) { - queryVersion = metadata[DIST_TAGS][queryVersion]; - version = getVersion(metadata, queryVersion); - if (_.isNil(version) === false) { - return next(version); - } + if (_.isNil(metadata[DIST_TAGS]) === false) { + if (_.isNil(metadata[DIST_TAGS][queryVersion]) === false) { + queryVersion = metadata[DIST_TAGS][queryVersion]; + version = getVersion(metadata, queryVersion); + if (_.isNil(version) === false) { + return next(version); } } - return next(ErrorCode.getNotFound(`${API_ERROR.VERSION_NOT_EXIST}: ${req.params.version}`)); - }; - - storage.getPackage({ - name: req.params.package, - uplinksLook: true, - req, - callback: getPackageMetaCallback - }); - } - ); - - route.get( - '/:scopedPackage/-/:scope/:filename', - can('access'), - function (req: $RequestExtend, res: $ResponseExtend): void { - const { scopedPackage, filename } = req.params; - if (_.get(config, 'experiments.tarball_url_redirect') === undefined) { - downloadStream(scopedPackage, filename, storage, req, res); - } else { - redirectOrDownloadStream(scopedPackage, filename, storage, req, res, config); } - } - ); + return next(ErrorCode.getNotFound(`${API_ERROR.VERSION_NOT_EXIST}: ${req.params.version}`)); + }; - route.get( - '/:package/-/:filename', - can('access'), - function (req: $RequestExtend, res: $ResponseExtend): void { - if (_.get(config, 'experiments.tarball_url_redirect') === undefined) { - downloadStream(req.params.package, req.params.filename, storage, req, res); - } else { - redirectOrDownloadStream(req.params.package, req.params.filename, storage, req, res, config); - } + storage.getPackage({ + name: req.params.package, + uplinksLook: true, + req, + callback: getPackageMetaCallback, + }); + }); + + route.get('/:scopedPackage/-/:scope/:filename', can('access'), function (req: $RequestExtend, res: $ResponseExtend): void { + const { scopedPackage, filename } = req.params; + if (_.get(config, 'experiments.tarball_url_redirect') === undefined) { + downloadStream(scopedPackage, filename, storage, req, res); + } else { + redirectOrDownloadStream(scopedPackage, filename, storage, req, res, config); } - ); + }); + + route.get('/:package/-/:filename', can('access'), function (req: $RequestExtend, res: $ResponseExtend): void { + if (_.get(config, 'experiments.tarball_url_redirect') === undefined) { + downloadStream(req.params.package, req.params.filename, storage, req, res); + } else { + redirectOrDownloadStream(req.params.package, req.params.filename, storage, req, res, config); + } + }); } diff --git a/src/api/endpoint/api/ping.ts b/src/api/endpoint/api/ping.ts index b9810a37c..8f49bbb22 100644 --- a/src/api/endpoint/api/ping.ts +++ b/src/api/endpoint/api/ping.ts @@ -2,15 +2,12 @@ * @prettier * @flow */ - -import { $RequestExtend, $ResponseExtend, $NextFunctionVer } from '../../../../types'; import { Router } from 'express'; +import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../../../../types'; + export default function (route: Router): void { - route.get( - '/-/ping', - function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) { - next({}); - } - ); + route.get('/-/ping', function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) { + next({}); + }); } diff --git a/src/api/endpoint/api/publish.ts b/src/api/endpoint/api/publish.ts index 51f2e3eaf..3c96c4cc1 100644 --- a/src/api/endpoint/api/publish.ts +++ b/src/api/endpoint/api/publish.ts @@ -1,19 +1,19 @@ +import buildDebug from 'debug'; +import { Router } from 'express'; +import _ from 'lodash'; +import mime from 'mime'; import Path from 'path'; -import { API_MESSAGE, HEADERS, DIST_TAGS, API_ERROR, HTTP_STATUS } from '../../../lib/constants'; -import { validateMetadata, isObject, ErrorCode, hasDiffOneKey, isRelatedToDeprecation } from '../../../lib/utils'; -import { media, expectJson, allow } from '../../middleware'; -import { notify } from '../../../lib/notify'; +import { Callback, Config, MergeTags, Package, Version } from '@verdaccio/types'; -import { IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler } from '../../../../types'; +import { $NextFunctionVer, $RequestExtend, $ResponseExtend, IAuth, IStorageHandler } from '../../../../types'; +import { API_ERROR, API_MESSAGE, DIST_TAGS, HEADERS, HTTP_STATUS } from '../../../lib/constants'; import { logger } from '../../../lib/logger'; +import { notify } from '../../../lib/notify'; import { isPublishablePackage } from '../../../lib/storage-utils'; +import { ErrorCode, hasDiffOneKey, isObject, isRelatedToDeprecation, validateMetadata } from '../../../lib/utils'; +import { allow, expectJson, media } from '../../middleware'; import star from './star'; -import { Config, Callback, MergeTags, Version, Package } from '@verdaccio/types'; -import { Router } from 'express'; -import mime from 'mime'; -import buildDebug from 'debug'; -import _ from 'lodash'; const debug = buildDebug('verdaccio:publish'); diff --git a/src/api/endpoint/api/star.ts b/src/api/endpoint/api/star.ts index 25d59aeaa..fe0cd07c1 100644 --- a/src/api/endpoint/api/star.ts +++ b/src/api/endpoint/api/star.ts @@ -1,11 +1,11 @@ // @flow - -import { USERS, HTTP_STATUS } from '../../../lib/constants'; -import { $RequestExtend, $NextFunctionVer, IStorageHandler } from '../../../../types'; -import { logger } from '../../../lib/logger'; +import buildDebug from 'debug'; import { Response } from 'express'; import _ from 'lodash'; -import buildDebug from 'debug'; + +import { $NextFunctionVer, $RequestExtend, IStorageHandler } from '../../../../types'; +import { HTTP_STATUS, USERS } from '../../../lib/constants'; +import { logger } from '../../../lib/logger'; const debug = buildDebug('verdaccio:star'); export default function (storage: IStorageHandler): (req: $RequestExtend, res: Response, next: $NextFunctionVer) => void { diff --git a/src/api/endpoint/api/stars.ts b/src/api/endpoint/api/stars.ts index 2978e2adb..802c87b46 100644 --- a/src/api/endpoint/api/stars.ts +++ b/src/api/endpoint/api/stars.ts @@ -2,36 +2,33 @@ * @prettier */ -import { USERS, HTTP_STATUS } from '../../../lib/constants'; -import { $RequestExtend, $NextFunctionVer, IStorageHandler } from '../../../../types'; -import _ from 'lodash'; import { Response, Router } from 'express'; +import _ from 'lodash'; + import { Package } from '@verdaccio/types'; +import { $NextFunctionVer, $RequestExtend, IStorageHandler } from '../../../../types'; +import { HTTP_STATUS, USERS } from '../../../lib/constants'; + type Packages = Package[]; export default function (route: Router, storage: IStorageHandler): void { - route.get( - '/-/_view/starredByUser', - (req: $RequestExtend, res: Response, next: $NextFunctionVer): void => { - const remoteUsername = req.remote_user.name; + route.get('/-/_view/starredByUser', (req: $RequestExtend, res: Response, next: $NextFunctionVer): void => { + const remoteUsername = req.remote_user.name; - storage.getLocalDatabase((err, localPackages: Packages) => { - if (err) { - return next(err); - } + storage.getLocalDatabase((err, localPackages: Packages) => { + if (err) { + return next(err); + } - const filteredPackages: Packages = localPackages.filter((localPackage: Package) => - _.keys(localPackage[USERS]).includes(remoteUsername) - ); + const filteredPackages: Packages = localPackages.filter((localPackage: Package) => _.keys(localPackage[USERS]).includes(remoteUsername)); - res.status(HTTP_STATUS.OK); - next({ - rows: filteredPackages.map((filteredPackage: Package) => ({ - value: filteredPackage.name - })) - }); + res.status(HTTP_STATUS.OK); + next({ + rows: filteredPackages.map((filteredPackage: Package) => ({ + value: filteredPackage.name, + })), }); - } - ); + }); + }); } diff --git a/src/api/endpoint/api/user.ts b/src/api/endpoint/api/user.ts index 10b75d2df..33c2d82a7 100644 --- a/src/api/endpoint/api/user.ts +++ b/src/api/endpoint/api/user.ts @@ -1,16 +1,16 @@ - -import { ErrorCode } from '../../../lib/utils'; -import { API_ERROR, API_MESSAGE, HEADERS, HTTP_STATUS } from '../../../lib/constants'; -import { createRemoteUser, createSessionToken, getApiToken, getAuthenticatedMessage, validatePassword } from '../../../lib/auth-utils'; -import { logger } from '../../../lib/logger'; - -import { $RequestExtend, $ResponseExtend, $NextFunctionVer, IAuth } from '../../../../types'; -import { limiter } from '../../rate-limiter'; -import express, { Response, Router } from 'express'; -import { Config, RemoteUser } from '@verdaccio/types'; import Cookies from 'cookies'; +import express, { Response, Router } from 'express'; import _ from 'lodash'; +import { Config, RemoteUser } from '@verdaccio/types'; + +import { $NextFunctionVer, $RequestExtend, $ResponseExtend, IAuth } from '../../../../types'; +import { createRemoteUser, createSessionToken, getApiToken, getAuthenticatedMessage, validatePassword } from '../../../lib/auth-utils'; +import { API_ERROR, API_MESSAGE, HEADERS, HTTP_STATUS } from '../../../lib/constants'; +import { logger } from '../../../lib/logger'; +import { ErrorCode } from '../../../lib/utils'; +import { limiter } from '../../rate-limiter'; + export default function (route: Router, auth: IAuth, config: Config): void { /* eslint new-cap:off */ const userRouter = express.Router(); diff --git a/src/api/endpoint/api/v1/index.ts b/src/api/endpoint/api/v1/index.ts index 17b75d049..aec08ffdb 100644 --- a/src/api/endpoint/api/v1/index.ts +++ b/src/api/endpoint/api/v1/index.ts @@ -1,6 +1,7 @@ +import { Response, Router } from 'express'; + import profile from './profile'; import token from './token'; -import { Response, Router } from 'express'; export default (auth, storage, config) => { const route = Router(); /* eslint new-cap: 0 */ diff --git a/src/api/endpoint/api/v1/profile.ts b/src/api/endpoint/api/v1/profile.ts index e5b8691da..25fe10b49 100644 --- a/src/api/endpoint/api/v1/profile.ts +++ b/src/api/endpoint/api/v1/profile.ts @@ -1,12 +1,12 @@ -import { API_ERROR, APP_ERROR, HTTP_STATUS, SUPPORT_ERRORS } from '../../../../lib/constants'; -import { ErrorCode } from '../../../../lib/utils'; -import { validatePassword } from '../../../../lib/auth-utils'; - -import { $NextFunctionVer, $RequestExtend, IAuth } from '../../../../../types'; -import { limiter } from '../../../rate-limiter'; import { Response, Router } from 'express'; import _ from 'lodash'; +import { $NextFunctionVer, $RequestExtend, IAuth } from '../../../../../types'; +import { validatePassword } from '../../../../lib/auth-utils'; +import { API_ERROR, APP_ERROR, HTTP_STATUS, SUPPORT_ERRORS } from '../../../../lib/constants'; +import { ErrorCode } from '../../../../lib/utils'; +import { limiter } from '../../../rate-limiter'; + export interface Profile { tfa: boolean; name: string; diff --git a/src/api/endpoint/api/v1/search.ts b/src/api/endpoint/api/v1/search.ts index 617ec23d7..782619392 100644 --- a/src/api/endpoint/api/v1/search.ts +++ b/src/api/endpoint/api/v1/search.ts @@ -1,9 +1,11 @@ -import { logger } from '../../../../lib/logger'; -import { HTTP_STATUS } from '../../../../lib/constants'; -import semver from 'semver'; import _ from 'lodash'; +import semver from 'semver'; + import { Package } from '@verdaccio/types'; +import { HTTP_STATUS } from '../../../../lib/constants'; +import { logger } from '../../../../lib/logger'; + type PublisherMaintainer = { username: string; email: string; diff --git a/src/api/endpoint/api/v1/token.ts b/src/api/endpoint/api/v1/token.ts index 592407b31..8d4217028 100644 --- a/src/api/endpoint/api/v1/token.ts +++ b/src/api/endpoint/api/v1/token.ts @@ -1,15 +1,16 @@ -import { HEADERS, HTTP_STATUS, SUPPORT_ERRORS } from '../../../../lib/constants'; -import { ErrorCode, mask } from '../../../../lib/utils'; -import { getApiToken } from '../../../../lib/auth-utils'; -import { stringToMD5 } from '../../../../lib/crypto-utils'; -import { logger } from '../../../../lib/logger'; +import buildDebug from 'debug'; +import { Response, Router } from 'express'; +import _ from 'lodash'; + +import { Config, RemoteUser, Token } from '@verdaccio/types'; import { $NextFunctionVer, $RequestExtend, IAuth, IStorageHandler } from '../../../../../types'; +import { getApiToken } from '../../../../lib/auth-utils'; +import { HEADERS, HTTP_STATUS, SUPPORT_ERRORS } from '../../../../lib/constants'; +import { stringToMD5 } from '../../../../lib/crypto-utils'; +import { logger } from '../../../../lib/logger'; +import { ErrorCode, mask } from '../../../../lib/utils'; import { limiter } from '../../../rate-limiter'; -import { Config, RemoteUser, Token } from '@verdaccio/types'; -import { Response, Router } from 'express'; -import buildDebug from 'debug'; -import _ from 'lodash'; const debug = buildDebug('verdaccio:token'); export type NormalizeToken = Token & { diff --git a/src/api/endpoint/api/whoami.ts b/src/api/endpoint/api/whoami.ts index 17aac2097..89345c32f 100644 --- a/src/api/endpoint/api/whoami.ts +++ b/src/api/endpoint/api/whoami.ts @@ -1,6 +1,7 @@ -import { $RequestExtend, $NextFunctionVer } from '../../../../types'; import { Response, Router } from 'express'; +import { $NextFunctionVer, $RequestExtend } from '../../../../types'; + export default function (route: Router): void { route.get('/whoami', (req: $RequestExtend, res: Response, next: $NextFunctionVer): void => { if (req.get('referer') === 'whoami') { diff --git a/src/api/endpoint/index.ts b/src/api/endpoint/index.ts index dcf8cf1a7..2ebda3031 100644 --- a/src/api/endpoint/index.ts +++ b/src/api/endpoint/index.ts @@ -1,19 +1,21 @@ -import { IAuth, IStorageHandler } from '../../../types'; -import whoami from './api/whoami'; -import ping from './api/ping'; -import user from './api/user'; -import distTags from './api/dist-tags'; -import publish from './api/publish'; -import search from './api/search'; -import pkg from './api/package'; -import stars from './api/stars'; -import npmV1 from './api/v1'; -import v1Search from './api/v1/search'; import bodyParser from 'body-parser'; import express from 'express'; import _ from 'lodash'; + import { Config } from '@verdaccio/types'; +import { IAuth, IStorageHandler } from '../../../types'; +import distTags from './api/dist-tags'; +import pkg from './api/package'; +import ping from './api/ping'; +import publish from './api/publish'; +import search from './api/search'; +import stars from './api/stars'; +import user from './api/user'; +import npmV1 from './api/v1'; +import v1Search from './api/v1/search'; +import whoami from './api/whoami'; + const { match, validateName, validatePackage, encodeScopePackage, antiLoop } = require('../middleware'); export default function (config: Config, auth: IAuth, storage: IStorageHandler) { diff --git a/src/api/index.ts b/src/api/index.ts index dc6ab9d06..2f7ee032c 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,23 +1,25 @@ -import Storage from '../lib/storage'; -import loadPlugin from '../lib/plugin-loader'; -import Auth from '../lib/auth'; -import { ErrorCode, getUserAgent } from '../lib/utils'; -import { API_ERROR, HTTP_STATUS } from '../lib/constants'; -import AppConfig from '../lib/config'; -import { $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler, IAuth } from '../../types'; -import { setup, logger } from '../lib/logger'; -import webAPI from './web/api'; -import web from './web'; -import apiEndpoint from './endpoint'; -import hookDebug from './debug'; -import { log, final, errorReportingMiddleware, serveFavicon } from './middleware'; -import { Config as IConfig, IPluginMiddleware, IPluginStorageFilter } from '@verdaccio/types'; -import { HttpError } from 'http-errors'; -import cors from 'cors'; import compression from 'compression'; +import cors from 'cors'; import express, { Application } from 'express'; +import { HttpError } from 'http-errors'; import _ from 'lodash'; +import { Config as IConfig, IPluginMiddleware, IPluginStorageFilter } from '@verdaccio/types'; + +import { $NextFunctionVer, $RequestExtend, $ResponseExtend, IAuth, IStorageHandler } from '../../types'; +import Auth from '../lib/auth'; +import AppConfig from '../lib/config'; +import { API_ERROR, HTTP_STATUS } from '../lib/constants'; +import { logger, setup } from '../lib/logger'; +import loadPlugin from '../lib/plugin-loader'; +import Storage from '../lib/storage'; +import { ErrorCode, getUserAgent } from '../lib/utils'; +import hookDebug from './debug'; +import apiEndpoint from './endpoint'; +import { errorReportingMiddleware, final, log, serveFavicon } from './middleware'; +import web from './web'; +import webAPI from './web/api'; + const defineAPI = function (config: IConfig, storage: IStorageHandler): any { const auth: IAuth = new Auth(config); const app: Application = express(); diff --git a/src/api/middleware.ts b/src/api/middleware.ts index 371d76cb9..b2f4da479 100644 --- a/src/api/middleware.ts +++ b/src/api/middleware.ts @@ -1,16 +1,17 @@ -import fs from 'fs'; -import path from 'path'; -import { validateName as utilValidateName, validatePackage as utilValidatePackage, getVersionFromTarball, isObject, ErrorCode } from '../lib/utils'; -import { API_ERROR, HEADER_TYPE, HEADERS, HTTP_STATUS, TOKEN_BASIC, TOKEN_BEARER } from '../lib/constants'; -import { stringToMD5 } from '../lib/crypto-utils'; -import { $ResponseExtend, $RequestExtend, $NextFunctionVer, IAuth } from '../../types'; -import { logger } from '../lib/logger'; -import _ from 'lodash'; import buildDebug from 'debug'; +import fs from 'fs'; +import _ from 'lodash'; +import path from 'path'; import validator from 'validator'; -import { Config, Package, RemoteUser } from '@verdaccio/types'; import { VerdaccioError } from '@verdaccio/commons-api'; +import { Config, Package, RemoteUser } from '@verdaccio/types'; + +import { $NextFunctionVer, $RequestExtend, $ResponseExtend, IAuth } from '../../types'; +import { API_ERROR, HEADERS, HEADER_TYPE, HTTP_STATUS, TOKEN_BASIC, TOKEN_BEARER } from '../lib/constants'; +import { stringToMD5 } from '../lib/crypto-utils'; +import { logger } from '../lib/logger'; +import { ErrorCode, getVersionFromTarball, isObject, validateName as utilValidateName, validatePackage as utilValidatePackage } from '../lib/utils'; const debug = buildDebug('verdaccio'); diff --git a/src/api/rate-limiter.ts b/src/api/rate-limiter.ts index 7b1779197..667e5d69d 100644 --- a/src/api/rate-limiter.ts +++ b/src/api/rate-limiter.ts @@ -1,4 +1,5 @@ import RateLimit from 'express-rate-limit'; + import { RateLimit as RateLimitType } from '@verdaccio/types'; const limiter = (rateLimitOptions: RateLimitType) => { diff --git a/src/api/web/api.ts b/src/api/web/api.ts index 5b1c9eaf2..86c0cb960 100644 --- a/src/api/web/api.ts +++ b/src/api/web/api.ts @@ -1,11 +1,13 @@ -import Search from '../../lib/search'; -import { match, validateName, validatePackage, setSecurityWebHeaders } from '../middleware'; -import { IAuth, IStorageHandler } from '../../../types'; -import webApi from './endpoint'; -import { Config } from '@verdaccio/types'; import bodyParser from 'body-parser'; import { Router } from 'express'; +import { Config } from '@verdaccio/types'; + +import { IAuth, IStorageHandler } from '../../../types'; +import Search from '../../lib/search'; +import { match, setSecurityWebHeaders, validateName, validatePackage } from '../middleware'; +import webApi from './endpoint'; + const route = Router(); /* eslint new-cap: 0 */ /* diff --git a/src/api/web/endpoint/index.ts b/src/api/web/endpoint/index.ts index 4bb346dfb..d5c3e77db 100644 --- a/src/api/web/endpoint/index.ts +++ b/src/api/web/endpoint/index.ts @@ -1,8 +1,9 @@ +import { Response, Router } from 'express'; + import { limiter } from '../../rate-limiter'; import packageApi from './package'; import search from './search'; import user from './user'; -import { Response, Router } from 'express'; export default (auth, storage, config) => { const route = Router(); /* eslint new-cap: 0 */ diff --git a/src/api/web/endpoint/package.ts b/src/api/web/endpoint/package.ts index f809a5499..b4e21df3f 100644 --- a/src/api/web/endpoint/package.ts +++ b/src/api/web/endpoint/package.ts @@ -1,24 +1,26 @@ -import { - addScope, - addGravatarSupport, - deleteProperties, - sortByName, - parseReadme, - formatAuthor, - convertDistRemoteToLocalTarballUrls, - getLocalRegistryTarballUri, - isVersionValid, - ErrorCode, -} from '../../../lib/utils'; -import { allow } from '../../middleware'; -import { DIST_TAGS, HEADER_TYPE, HEADERS, HTTP_STATUS } from '../../../lib/constants'; -import { generateGravatarUrl } from '../../../utils/user'; -import { logger } from '../../../lib/logger'; -import { IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler, $SidebarPackage } from '../../../../types'; -import { Config, Package } from '@verdaccio/types'; import { Router } from 'express'; import _ from 'lodash'; +import { Config, Package } from '@verdaccio/types'; + +import { $NextFunctionVer, $RequestExtend, $ResponseExtend, $SidebarPackage, IAuth, IStorageHandler } from '../../../../types'; +import { DIST_TAGS, HEADERS, HEADER_TYPE, HTTP_STATUS } from '../../../lib/constants'; +import { logger } from '../../../lib/logger'; +import { + ErrorCode, + addGravatarSupport, + addScope, + convertDistRemoteToLocalTarballUrls, + deleteProperties, + formatAuthor, + getLocalRegistryTarballUri, + isVersionValid, + parseReadme, + sortByName, +} from '../../../lib/utils'; +import { generateGravatarUrl } from '../../../utils/user'; +import { allow } from '../../middleware'; + const getOrder = (order = 'asc') => { return order === 'asc'; }; diff --git a/src/api/web/endpoint/search.ts b/src/api/web/endpoint/search.ts index dd0216910..00c332c87 100644 --- a/src/api/web/endpoint/search.ts +++ b/src/api/web/endpoint/search.ts @@ -2,13 +2,14 @@ * @prettier * @flow */ - -import Search from '../../../lib/search'; -import { DIST_TAGS } from '../../../lib/constants'; -import { IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler } from '../../../../types'; -import { Package } from '@verdaccio/types'; import { Router } from 'express'; +import { Package } from '@verdaccio/types'; + +import { $NextFunctionVer, $RequestExtend, $ResponseExtend, IAuth, IStorageHandler } from '../../../../types'; +import { DIST_TAGS } from '../../../lib/constants'; +import Search from '../../../lib/search'; + function addSearchWebApi(storage: IStorageHandler, auth: IAuth): Router { const route = Router(); /* eslint new-cap: 0 */ // Search package diff --git a/src/api/web/endpoint/user.ts b/src/api/web/endpoint/user.ts index f40660344..4d5fe94ff 100644 --- a/src/api/web/endpoint/user.ts +++ b/src/api/web/endpoint/user.ts @@ -1,15 +1,16 @@ /** * @prettier */ - -import { API_ERROR, APP_ERROR, HEADERS, HTTP_STATUS } from '../../../lib/constants'; -import { IAuth, $NextFunctionVer } from '../../../../types'; -import { ErrorCode } from '../../../lib/utils'; -import { getSecurity, validatePassword } from '../../../lib/auth-utils'; -import { Config, RemoteUser, JWTSignOptions } from '@verdaccio/types'; -import express, { Router, Response, Request } from 'express'; +import express, { Request, Response, Router } from 'express'; import _ from 'lodash'; +import { Config, JWTSignOptions, RemoteUser } from '@verdaccio/types'; + +import { $NextFunctionVer, IAuth } from '../../../../types'; +import { getSecurity, validatePassword } from '../../../lib/auth-utils'; +import { API_ERROR, APP_ERROR, HEADERS, HTTP_STATUS } from '../../../lib/constants'; +import { ErrorCode } from '../../../lib/utils'; + function addUserAuthApi(auth: IAuth, config: Config): Router { const route = Router(); /* eslint new-cap: 0 */ route.post('/login', function (req: Request, res: Response, next: $NextFunctionVer): void { diff --git a/src/api/web/html/renderHTML.ts b/src/api/web/html/renderHTML.ts index ddf24a873..8f862fc8d 100644 --- a/src/api/web/html/renderHTML.ts +++ b/src/api/web/html/renderHTML.ts @@ -1,12 +1,13 @@ -import { URL } from 'url'; -import path from 'path'; -import { getPublicUrl, isHTTPProtocol } from '../../../lib/utils'; -import { WEB_TITLE } from '../../../lib/constants'; -import renderTemplate from './template'; import buildDebug from 'debug'; import LRU from 'lru-cache'; +import path from 'path'; +import { URL } from 'url'; + import { HEADERS } from '@verdaccio/commons-api'; +import { WEB_TITLE } from '../../../lib/constants'; +import { getPublicUrl, isHTTPProtocol } from '../../../lib/utils'; +import renderTemplate from './template'; const pkgJSON = require('../../../../package.json'); const DEFAULT_LANGUAGE = 'es-US'; diff --git a/src/api/web/html/template.ts b/src/api/web/html/template.ts index 94a98c5f7..0b53a2a83 100644 --- a/src/api/web/html/template.ts +++ b/src/api/web/html/template.ts @@ -1,6 +1,7 @@ -import { getManifestValue, Manifest } from './manifest'; import buildDebug from 'debug'; +import { Manifest, getManifestValue } from './manifest'; + const debug = buildDebug('verdaccio'); export type TemplateUIOptions = { @@ -52,7 +53,9 @@ export default function renderTemplate(template: Template, manifest: WebpackMani ${template?.scriptsbodyBefore ? template.scriptsbodyBefore.join('') : ''}
- ${getManifestValue(template.manifest.js, manifest, template?.options.base).map((item) => ``).join('')} + ${getManifestValue(template.manifest.js, manifest, template?.options.base) + .map((item) => ``) + .join('')} ${template?.scriptsBodyAfter ? template.scriptsBodyAfter.join('') : ''} diff --git a/src/api/web/index.ts b/src/api/web/index.ts index 8584d5fd9..21d390a5c 100644 --- a/src/api/web/index.ts +++ b/src/api/web/index.ts @@ -1,18 +1,17 @@ -import fs from 'fs'; -import path from 'path'; - - - -import Search from '../../lib/search'; -import { HTTP_STATUS } from '../../lib/constants'; -import loadPlugin from '../../lib/plugin-loader'; -import { isHTTPProtocol } from '../../lib/utils'; -import { logger } from '../../lib/logger'; -import renderHTML from './html/renderHTML'; -import { Config } from '@verdaccio/types'; import buildDebug from 'debug'; import express from 'express'; +import fs from 'fs'; import _ from 'lodash'; +import path from 'path'; + +import { Config } from '@verdaccio/types'; + +import { HTTP_STATUS } from '../../lib/constants'; +import { logger } from '../../lib/logger'; +import loadPlugin from '../../lib/plugin-loader'; +import Search from '../../lib/search'; +import { isHTTPProtocol } from '../../lib/utils'; +import renderHTML from './html/renderHTML'; const { setSecurityWebHeaders } = require('../middleware'); diff --git a/src/config/env.ts b/src/config/env.ts index 4f1620400..b488602b7 100644 --- a/src/config/env.ts +++ b/src/config/env.ts @@ -9,5 +9,5 @@ const APP_ROOT = path.resolve(__dirname, '../../'); module.exports = { APP_ROOT, SRC_ROOT: path.resolve(APP_ROOT, 'src/'), - DIST_PATH: path.resolve(APP_ROOT, 'static/') + DIST_PATH: path.resolve(APP_ROOT, 'static/'), }; diff --git a/src/index.ts b/src/index.ts index e41843bd6..7db5be615 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,4 @@ // @flow - import { startVerdaccio } from './lib/bootstrap'; export default startVerdaccio; diff --git a/src/lib/auth-utils.ts b/src/lib/auth-utils.ts index be5664c78..3f1e0c5d5 100644 --- a/src/lib/auth-utils.ts +++ b/src/lib/auth-utils.ts @@ -1,12 +1,14 @@ -import { CookieSessionToken, IAuthWebUI, AuthMiddlewarePayload, AuthTokenHeader, BasicPayload } from '../../types'; -import { logger } from '../lib/logger'; -import { convertPayloadToBase64, ErrorCode } from './utils'; -import { API_ERROR, HTTP_STATUS, ROLES, TIME_EXPIRATION_1H, TOKEN_BASIC, TOKEN_BEARER, DEFAULT_MIN_LIMIT_PASSWORD } from './constants'; -import { aesDecrypt, verifyPayload } from './crypto-utils'; -import { RemoteUser, Package, Callback, Config, Security, APITokenOptions, JWTOptions, IPluginAuth } from '@verdaccio/types'; import buildDebug from 'debug'; import _ from 'lodash'; +import { APITokenOptions, Callback, Config, IPluginAuth, JWTOptions, Package, RemoteUser, Security } from '@verdaccio/types'; + +import { AuthMiddlewarePayload, AuthTokenHeader, BasicPayload, CookieSessionToken, IAuthWebUI } from '../../types'; +import { logger } from '../lib/logger'; +import { API_ERROR, DEFAULT_MIN_LIMIT_PASSWORD, HTTP_STATUS, ROLES, TIME_EXPIRATION_1H, TOKEN_BASIC, TOKEN_BEARER } from './constants'; +import { aesDecrypt, verifyPayload } from './crypto-utils'; +import { ErrorCode, convertPayloadToBase64 } from './utils'; + const debug = buildDebug('verdaccio'); export function validatePassword( diff --git a/src/lib/auth.ts b/src/lib/auth.ts index a09947f04..3ba469e25 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -1,27 +1,29 @@ +import buildDebug from 'debug'; +import { NextFunction } from 'express'; +import _ from 'lodash'; + +import { VerdaccioError } from '@verdaccio/commons-api'; +import { AllowAccess, AuthPluginPackage, Callback, Config, IPluginAuth, JWTSignOptions, Logger, PackageAccess, RemoteUser, Security } from '@verdaccio/types'; + +import { $RequestExtend, $ResponseExtend, AESPayload, IAuth } from '../../types'; import loadPlugin from '../lib/plugin-loader'; -import { $RequestExtend, $ResponseExtend, IAuth, AESPayload } from '../../types'; +import { + createAnonymousRemoteUser, + createRemoteUser, + getDefaultPlugins, + getMiddlewareCredentials, + getSecurity, + isAESLegacy, + isAuthHeaderValid, + parseAuthTokenHeader, + parseBasicPayload, + verifyJWTPayload, +} from './auth-utils'; +import { getMatchedPackagesSpec } from './config-utils'; import { API_ERROR, SUPPORT_ERRORS, TOKEN_BASIC, TOKEN_BEARER } from './constants'; import { aesEncrypt, signPayload } from './crypto-utils'; import { logger } from './logger'; -import { - getDefaultPlugins, - getMiddlewareCredentials, - verifyJWTPayload, - createAnonymousRemoteUser, - isAuthHeaderValid, - getSecurity, - isAESLegacy, - parseAuthTokenHeader, - parseBasicPayload, - createRemoteUser, -} from './auth-utils'; -import { convertPayloadToBase64, ErrorCode } from './utils'; -import { getMatchedPackagesSpec } from './config-utils'; -import { NextFunction } from 'express'; -import { Config, Logger, Callback, IPluginAuth, RemoteUser, JWTSignOptions, Security, AuthPluginPackage, AllowAccess, PackageAccess } from '@verdaccio/types'; -import buildDebug from 'debug'; -import { VerdaccioError } from '@verdaccio/commons-api'; -import _ from 'lodash'; +import { ErrorCode, convertPayloadToBase64 } from './utils'; const debug = buildDebug('verdaccio:auth'); diff --git a/src/lib/bootstrap.ts b/src/lib/bootstrap.ts index fa2b8ae10..8d8f60e80 100644 --- a/src/lib/bootstrap.ts +++ b/src/lib/bootstrap.ts @@ -1,16 +1,17 @@ -import URL from 'url'; +import constants from 'constants'; +import express from 'express'; +import { Application } from 'express'; import fs from 'fs'; import http from 'http'; import https from 'https'; -import constants from 'constants'; -import endPointAPI from '../api/index'; -import { API_ERROR, certPem, csrPem, keyPem } from './constants'; -import { getListListenAddresses, resolveConfigPath } from './cli/utils'; -import express from 'express'; -import { assign, isObject, isFunction } from 'lodash'; +import { assign, isFunction, isObject } from 'lodash'; +import URL from 'url'; import { Callback, ConfigWithHttps, HttpsConfKeyCert, HttpsConfPfx } from '@verdaccio/types'; -import { Application } from 'express'; + +import endPointAPI from '../api/index'; +import { getListListenAddresses, resolveConfigPath } from './cli/utils'; +import { API_ERROR, certPem, csrPem, keyPem } from './constants'; const logger = require('./logger'); diff --git a/src/lib/cli/cli.ts b/src/lib/cli/cli.ts index df93462cb..3771961cc 100644 --- a/src/lib/cli/cli.ts +++ b/src/lib/cli/cli.ts @@ -1,8 +1,9 @@ +import { Cli } from 'clipanion'; + import { InfoCommand } from './commands/info'; import { InitCommand } from './commands/init'; -import { isVersionValid, MIN_NODE_VERSION } from './utils'; import { VersionCommand } from './commands/version'; -import { Cli } from 'clipanion'; +import { MIN_NODE_VERSION, isVersionValid } from './utils'; require('pkginfo')(module); const pkgVersion = module.exports.version; diff --git a/src/lib/cli/commands/info.ts b/src/lib/cli/commands/info.ts index 89d092742..e4d803759 100644 --- a/src/lib/cli/commands/info.ts +++ b/src/lib/cli/commands/info.ts @@ -1,5 +1,5 @@ -import envinfo from 'envinfo'; import { Command } from 'clipanion'; +import envinfo from 'envinfo'; export class InfoCommand extends Command { static paths = [[`--info`], [`-i`]]; diff --git a/src/lib/cli/commands/init.ts b/src/lib/cli/commands/init.ts index 1c0162d65..306c2d103 100644 --- a/src/lib/cli/commands/init.ts +++ b/src/lib/cli/commands/init.ts @@ -1,9 +1,9 @@ +import { Command, Option } from 'clipanion'; import path from 'path'; -import { startVerdaccio, listenDefaultCallback } from '../../bootstrap'; +import { listenDefaultCallback, startVerdaccio } from '../../bootstrap'; import findConfigFile from '../../config-path'; import { parseConfigFile } from '../../utils'; -import { Command, Option } from 'clipanion'; require('pkginfo')(module); const pkgVersion = module.exports.version; diff --git a/src/lib/cli/commands/version.ts b/src/lib/cli/commands/version.ts index e77a0ac1d..3de4ffd4d 100644 --- a/src/lib/cli/commands/version.ts +++ b/src/lib/cli/commands/version.ts @@ -1,4 +1,5 @@ import { Command } from 'clipanion'; + require('pkginfo')(module); const pkgVersion = module.exports.version; diff --git a/src/lib/cli/utils.ts b/src/lib/cli/utils.ts index 35de63f65..16ad9b6da 100644 --- a/src/lib/cli/utils.ts +++ b/src/lib/cli/utils.ts @@ -1,9 +1,9 @@ import path from 'path'; - -import { parseAddress } from '../utils'; -import { DEFAULT_PORT } from '../constants'; import semver from 'semver'; +import { DEFAULT_PORT } from '../constants'; +import { parseAddress } from '../utils'; + const logger = require('../logger'); export const resolveConfigPath = function (storageLocation: string, file: string) { @@ -16,7 +16,6 @@ export function isVersionValid(version) { return semver.satisfies(version, `>=${MIN_NODE_VERSION}`); } - /** * Retrieve all addresses defined in the config file. * Verdaccio is able to listen multiple ports @@ -48,9 +47,7 @@ export function getListListenAddresses(argListen: string, configListen: any): an if (!parsedAddr) { logger.logger.warn( { addr: addr }, - 'invalid address - @{addr}, we expect a port (e.g. "4873"),' + - ' host:port (e.g. "localhost:4873") or full url' + - ' (e.g. "http://localhost:4873/")' + 'invalid address - @{addr}, we expect a port (e.g. "4873"),' + ' host:port (e.g. "localhost:4873") or full url' + ' (e.g. "http://localhost:4873/")' ); } diff --git a/src/lib/config-path.ts b/src/lib/config-path.ts index 3947b5304..16bf50926 100644 --- a/src/lib/config-path.ts +++ b/src/lib/config-path.ts @@ -1,11 +1,11 @@ import fs from 'fs'; -import Path from 'path'; -import { logger } from './logger'; - -import { folderExists, fileExists } from './utils'; -import { CHARACTER_ENCODING } from './constants'; -import mkdirp from 'mkdirp'; import _ from 'lodash'; +import mkdirp from 'mkdirp'; +import Path from 'path'; + +import { CHARACTER_ENCODING } from './constants'; +import { logger } from './logger'; +import { fileExists, folderExists } from './utils'; const CONFIG_FILE = 'config.yaml'; const XDG = 'xdg'; @@ -34,9 +34,7 @@ function findConfigFile(configPath: string): string { throw new Error('no configuration files can be processed'); } - const primaryConf: any = _.find(configPaths, (configLocation: any) => - fileExists(configLocation.path) - ); + const primaryConf: any = _.find(configPaths, (configLocation: any) => fileExists(configLocation.path)); if (_.isNil(primaryConf) === false) { return primaryConf.path; } @@ -71,8 +69,7 @@ function updateStorageLinks(configLocation, defaultConfig): string { // $XDG_DATA_HOME defines the base directory relative to which user specific data files should be stored, // If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used. // $FlowFixMe - let dataDir = - process.env.XDG_DATA_HOME || Path.join(process.env.HOME as string, '.local', 'share'); + let dataDir = process.env.XDG_DATA_HOME || Path.join(process.env.HOME as string, '.local', 'share'); if (folderExists(dataDir)) { dataDir = Path.resolve(Path.join(dataDir, pkgJSON.name, 'storage')); return defaultConfig.replace(/^storage: .\/storage$/m, `storage: ${dataDir}`); @@ -81,17 +78,16 @@ function updateStorageLinks(configLocation, defaultConfig): string { } function getConfigPaths(): SetupDirectory[] { - const listPaths: SetupDirectory[] = [ - getXDGDirectory(), - getWindowsDirectory(), - getRelativeDefaultDirectory(), - getOldDirectory() - ].reduce(function (acc, currentValue: any): SetupDirectory[] { + const listPaths: SetupDirectory[] = [getXDGDirectory(), getWindowsDirectory(), getRelativeDefaultDirectory(), getOldDirectory()].reduce(function ( + acc, + currentValue: any + ): SetupDirectory[] { if (_.isUndefined(currentValue) === false) { acc.push(currentValue); } return acc; - }, [] as SetupDirectory[]); + }, + [] as SetupDirectory[]); return listPaths; } @@ -102,7 +98,7 @@ const getXDGDirectory = (): SetupDirectory | void => { if (XDGConfig && folderExists(XDGConfig)) { return { path: Path.join(XDGConfig, pkgJSON.name, CONFIG_FILE), - type: XDG + type: XDG, }; } }; @@ -113,7 +109,7 @@ const getWindowsDirectory = (): SetupDirectory | void => { if (process.platform === WIN32 && process.env.APPDATA && folderExists(process.env.APPDATA)) { return { path: Path.resolve(Path.join(process.env.APPDATA, pkgJSON.name, CONFIG_FILE)), - type: WIN + type: WIN, }; } }; @@ -121,14 +117,14 @@ const getWindowsDirectory = (): SetupDirectory | void => { const getRelativeDefaultDirectory = (): SetupDirectory => { return { path: Path.resolve(Path.join('.', pkgJSON.name, CONFIG_FILE)), - type: 'def' + type: 'def', }; }; const getOldDirectory = (): SetupDirectory => { return { path: Path.resolve(Path.join('.', CONFIG_FILE)), - type: 'old' + type: 'old', }; }; diff --git a/src/lib/config-utils.ts b/src/lib/config-utils.ts index 1e37cddfb..557a60074 100644 --- a/src/lib/config-utils.ts +++ b/src/lib/config-utils.ts @@ -2,21 +2,21 @@ * @prettier * @flow */ - import assert from 'assert'; -import { MatchedPackage, LegacyPackageList } from '../../types'; -import { ErrorCode } from './utils'; import _ from 'lodash'; import minimatch from 'minimatch'; import { PackageList, UpLinksConfList } from '@verdaccio/types'; +import { LegacyPackageList, MatchedPackage } from '../../types'; +import { ErrorCode } from './utils'; + const BLACKLIST = { all: true, anonymous: true, undefined: true, owner: true, - none: true + none: true, }; /** @@ -38,18 +38,13 @@ export function normalizeUserList(oldFormat: any, newFormat: any): any { } else if (Array.isArray(arguments[i])) { result.push(arguments[i]); } else { - throw ErrorCode.getInternalError( - 'CONFIG: bad package acl (array or string expected): ' + JSON.stringify(arguments[i]) - ); + throw ErrorCode.getInternalError('CONFIG: bad package acl (array or string expected): ' + JSON.stringify(arguments[i])); } } return _.flatten(result); } -export function uplinkSanityCheck( - uplinks: UpLinksConfList, - users: any = BLACKLIST -): UpLinksConfList { +export function uplinkSanityCheck(uplinks: UpLinksConfList, users: any = BLACKLIST): UpLinksConfList { const newUplinks = _.clone(uplinks); let newUsers = _.clone(users); @@ -66,14 +61,7 @@ export function uplinkSanityCheck( } export function sanityCheckNames(item: string, users: any): any { - assert( - item !== 'all' && - item !== 'owner' && - item !== 'anonymous' && - item !== 'undefined' && - item !== 'none', - 'CONFIG: reserved uplink name: ' + item - ); + assert(item !== 'all' && item !== 'owner' && item !== 'anonymous' && item !== 'undefined' && item !== 'none', 'CONFIG: reserved uplink name: ' + item); assert(!item.match(/\s/), 'CONFIG: invalid uplink name: ' + item); assert(_.isNil(users[item]), 'CONFIG: duplicate uplink name: ' + item); users[item] = true; @@ -126,29 +114,15 @@ export function normalisePackageAccess(packages: LegacyPackageList): LegacyPacka for (const pkg in packages) { if (Object.prototype.hasOwnProperty.call(packages, pkg)) { - assert( - _.isObject(packages[pkg]) && _.isArray(packages[pkg]) === false, - `CONFIG: bad "'${pkg}'" package description (object expected)` - ); - normalizedPkgs[pkg].access = normalizeUserList( - packages[pkg].allow_access, - packages[pkg].access - ); + assert(_.isObject(packages[pkg]) && _.isArray(packages[pkg]) === false, `CONFIG: bad "'${pkg}'" package description (object expected)`); + normalizedPkgs[pkg].access = normalizeUserList(packages[pkg].allow_access, packages[pkg].access); delete normalizedPkgs[pkg].allow_access; - normalizedPkgs[pkg].publish = normalizeUserList( - packages[pkg].allow_publish, - packages[pkg].publish - ); + normalizedPkgs[pkg].publish = normalizeUserList(packages[pkg].allow_publish, packages[pkg].publish); delete normalizedPkgs[pkg].allow_publish; - normalizedPkgs[pkg].proxy = normalizeUserList( - packages[pkg].proxy_access, - packages[pkg].proxy - ); + normalizedPkgs[pkg].proxy = normalizeUserList(packages[pkg].proxy_access, packages[pkg].proxy); delete normalizedPkgs[pkg].proxy_access; // if unpublish is not defined, we set to false to fallback in publish access - normalizedPkgs[pkg].unpublish = _.isUndefined(packages[pkg].unpublish) - ? false - : normalizeUserList([], packages[pkg].unpublish); + normalizedPkgs[pkg].unpublish = _.isUndefined(packages[pkg].unpublish) ? false : normalizeUserList([], packages[pkg].unpublish); } } diff --git a/src/lib/config.ts b/src/lib/config.ts index 40b9a1d22..168922346 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -1,13 +1,14 @@ import assert from 'assert'; +import _ from 'lodash'; + +import { Config as AppConfig, Logger, PackageList, RateLimit, Security } from '@verdaccio/types'; import { MatchedPackage, StartUpConfig } from '../../types'; -import { generateRandomHexString } from './crypto-utils'; -import { getMatchedPackagesSpec, normalisePackageAccess, sanityCheckUplinksProps, uplinkSanityCheck } from './config-utils'; -import { getUserAgent, isObject } from './utils'; -import { APP_ERROR } from './constants'; import { defaultUserRateLimiting } from './auth-utils'; -import { PackageList, Config as AppConfig, Security, Logger, RateLimit } from '@verdaccio/types'; -import _ from 'lodash'; +import { getMatchedPackagesSpec, normalisePackageAccess, sanityCheckUplinksProps, uplinkSanityCheck } from './config-utils'; +import { APP_ERROR } from './constants'; +import { generateRandomHexString } from './crypto-utils'; +import { getUserAgent, isObject } from './utils'; const LoggerApi = require('./logger'); const strategicConfigProps = ['uplinks', 'packages']; diff --git a/src/lib/crypto-utils.ts b/src/lib/crypto-utils.ts index 21bd4167f..8a7f4db83 100644 --- a/src/lib/crypto-utils.ts +++ b/src/lib/crypto-utils.ts @@ -1,4 +1,4 @@ -import { createDecipher, createCipher, createHash, pseudoRandomBytes, Hash } from 'crypto'; +import { Hash, createCipher, createDecipher, createHash, pseudoRandomBytes } from 'crypto'; import jwt from 'jsonwebtoken'; import { JWTSignOptions, RemoteUser } from '@verdaccio/types'; @@ -49,18 +49,14 @@ export function generateRandomHexString(length = 8): string { return pseudoRandomBytes(length).toString('hex'); } -export async function signPayload( - payload: RemoteUser, - secretOrPrivateKey: string, - options: JWTSignOptions -): Promise { +export async function signPayload(payload: RemoteUser, secretOrPrivateKey: string, options: JWTSignOptions): Promise { return new Promise(function (resolve, reject): Promise { return jwt.sign( payload, secretOrPrivateKey, { notBefore: '1', // Make sure the time will not rollback :) - ...options + ...options, }, (error, token) => (error ? reject(error) : resolve(token)) ); diff --git a/src/lib/local-storage.ts b/src/lib/local-storage.ts index 1a0c85415..081824c35 100644 --- a/src/lib/local-storage.ts +++ b/src/lib/local-storage.ts @@ -1,37 +1,39 @@ import assert from 'assert'; +import builDebug from 'debug'; +import _ from 'lodash'; import UrlNode from 'url'; -import loadPlugin from '../lib/plugin-loader'; -import { IStorage, StringValue } from '../../types'; -import { ErrorCode, isObject, getLatestVersion, tagVersion, validateName } from './utils'; -import { generatePackageTemplate, normalizePackage, generateRevision, getLatestReadme, cleanUpReadme, normalizeContributors } from './storage-utils'; -import { API_ERROR, DIST_TAGS, HTTP_STATUS, STORAGE, SUPPORT_ERRORS, USERS } from './constants'; -import { createTarballHash } from './crypto-utils'; -import { prepareSearchPackage } from './storage-utils'; + import { VerdaccioError } from '@verdaccio/commons-api'; +import LocalDatabase from '@verdaccio/local-storage'; +import { ReadTarball, UploadTarball } from '@verdaccio/streams'; import { + Author, + Callback, + CallbackAction, + Config, + DistFile, + IPackageStorage, + IPluginStorage, + IReadTarball, + IUploadTarball, + Logger, + MergeTags, + Package, + StorageUpdateCallback, Token, TokenFilter, - Package, - Config, - IUploadTarball, - IReadTarball, - MergeTags, Version, - DistFile, - Callback, - Logger, - IPluginStorage, - IPackageStorage, - Author, - CallbackAction, - onSearchPackage, onEndSearchPackage, - StorageUpdateCallback, + onSearchPackage, } from '@verdaccio/types'; -import { UploadTarball, ReadTarball } from '@verdaccio/streams'; -import LocalDatabase from '@verdaccio/local-storage'; -import _ from 'lodash'; -import builDebug from 'debug'; + +import { IStorage, StringValue } from '../../types'; +import loadPlugin from '../lib/plugin-loader'; +import { API_ERROR, DIST_TAGS, HTTP_STATUS, STORAGE, SUPPORT_ERRORS, USERS } from './constants'; +import { createTarballHash } from './crypto-utils'; +import { cleanUpReadme, generatePackageTemplate, generateRevision, getLatestReadme, normalizeContributors, normalizePackage } from './storage-utils'; +import { prepareSearchPackage } from './storage-utils'; +import { ErrorCode, getLatestVersion, isObject, tagVersion, validateName } from './utils'; const debug = builDebug('verdaccio:local-storage'); /** @@ -842,14 +844,9 @@ class LocalStorage implements IStorage { }; // eslint-disable-next-line max-len - const plugins: IPluginStorage[] = loadPlugin>( - this.config, - this.config.store, - plugin_params, - (plugin): IPluginStorage => { - return plugin.getPackageStorage; - } - ); + const plugins: IPluginStorage[] = loadPlugin>(this.config, this.config.store, plugin_params, (plugin): IPluginStorage => { + return plugin.getPackageStorage; + }); return _.head(plugins); } diff --git a/src/lib/logger/formatter/index.ts b/src/lib/logger/formatter/index.ts index a695416b6..266db296b 100644 --- a/src/lib/logger/formatter/index.ts +++ b/src/lib/logger/formatter/index.ts @@ -1,4 +1,4 @@ -import { printMessage, PrettyOptionsExtended } from './prettifier'; +import { PrettyOptionsExtended, printMessage } from './prettifier'; export type PrettyFactory = (param) => string; diff --git a/src/lib/logger/formatter/prettifier.ts b/src/lib/logger/formatter/prettifier.ts index 43f30e8fa..469ff0af4 100644 --- a/src/lib/logger/formatter/prettifier.ts +++ b/src/lib/logger/formatter/prettifier.ts @@ -1,27 +1,27 @@ -import { inspect } from 'util'; -import {calculateLevel, LevelCode, levelsColors, subSystemLevels} from "../levels"; -import { padLeft, padRight } from '../utils'; -import { white, red, green } from 'kleur'; -import _ from 'lodash'; import dayjs from 'dayjs'; -import {PrettyOptions} from "pino"; +import { green, red, white } from 'kleur'; +import _ from 'lodash'; +import { PrettyOptions } from 'pino'; +import { inspect } from 'util'; +import { LevelCode, calculateLevel, levelsColors, subSystemLevels } from '../levels'; +import { padLeft, padRight } from '../utils'; export const CUSTOM_PAD_LENGTH = 1; export const FORMAT_DATE = 'YYYY-MM-DD HH:mm:ss'; export function isObject(obj: unknown): boolean { - return _.isObject(obj) && _.isNull(obj) === false && _.isArray(obj) === false; + return _.isObject(obj) && _.isNull(obj) === false && _.isArray(obj) === false; } export function formatLoggingDate(time: number, message): string { - const timeFormatted = dayjs(time).format(FORMAT_DATE); + const timeFormatted = dayjs(time).format(FORMAT_DATE); - return `[${timeFormatted}]${message}`; + return `[${timeFormatted}]${message}`; } -export interface PrettyOptionsExtended extends PrettyOptions { - prettyStamp: boolean; +export interface PrettyOptionsExtended extends PrettyOptions { + prettyStamp: boolean; } let LEVEL_VALUE_MAX = 0; // eslint-disable-next-line guard-for-in @@ -42,7 +42,6 @@ export function fillInMsgTemplate(msg, templateOptions: ObjectTemplate, colors): const templateRegex = /@{(!?[$A-Za-z_][$0-9A-Za-z\._]*)}/g; return msg.replace(templateRegex, (_, name): string => { - let str = templateOptions; let isError; if (name[0] === ERROR_FLAG) { @@ -87,10 +86,7 @@ function getMessage(debugLevel, msg, sub, templateObjects, hasColors) { return padRight(logString); } -export function printMessage( - templateObjects: ObjectTemplate, - options: PrettyOptionsExtended, - hasColors = true): string { +export function printMessage(templateObjects: ObjectTemplate, options: PrettyOptionsExtended, hasColors = true): string { const { prettyStamp } = options; const { level, msg, sub } = templateObjects; const debugLevel = calculateLevel(level); diff --git a/src/lib/logger/levels.ts b/src/lib/logger/levels.ts index 1defad37e..a8f4a0db8 100644 --- a/src/lib/logger/levels.ts +++ b/src/lib/logger/levels.ts @@ -1,58 +1,58 @@ -import { yellow, green, red, magenta, black, blue, cyan, white } from 'kleur'; +import { black, blue, cyan, green, magenta, red, white, yellow } from 'kleur'; export type LogLevel = 'trace' | 'debug' | 'info' | 'http' | 'warn' | 'error' | 'fatal'; export type LevelCode = number; export function calculateLevel(levelCode: LevelCode): LogLevel { - switch (true) { - case levelCode === 10: - return 'trace'; - case levelCode === 20: - return 'debug'; - case levelCode === 25: - return 'http'; - case levelCode === 30: - return 'info'; - case levelCode === 40: - return 'warn'; - case levelCode === 50: - return 'error'; - case levelCode === 60: - return 'fatal'; - default: - return 'fatal'; - } + switch (true) { + case levelCode === 10: + return 'trace'; + case levelCode === 20: + return 'debug'; + case levelCode === 25: + return 'http'; + case levelCode === 30: + return 'info'; + case levelCode === 40: + return 'warn'; + case levelCode === 50: + return 'error'; + case levelCode === 60: + return 'fatal'; + default: + return 'fatal'; + } } export const levelsColors = { - fatal: red, - error: red, - warn: yellow, - http: magenta, - info: cyan, - debug: green, - trace: white, + fatal: red, + error: red, + warn: yellow, + http: magenta, + info: cyan, + debug: green, + trace: white, }; enum ARROWS { LEFT = '<--', RIGHT = '-->', EQUAL = '-=-', - NEUTRAL = '---' + NEUTRAL = '---', } export const subSystemLevels = { color: { - in: green(ARROWS.LEFT), - out: yellow(ARROWS.RIGHT), - fs: black(ARROWS.EQUAL), - default: blue(ARROWS.NEUTRAL), + in: green(ARROWS.LEFT), + out: yellow(ARROWS.RIGHT), + fs: black(ARROWS.EQUAL), + default: blue(ARROWS.NEUTRAL), }, white: { - in: ARROWS.LEFT, - out: ARROWS.RIGHT, - fs: ARROWS.EQUAL, - default: ARROWS.NEUTRAL, + in: ARROWS.LEFT, + out: ARROWS.RIGHT, + fs: ARROWS.EQUAL, + default: ARROWS.NEUTRAL, }, }; diff --git a/src/lib/logger/logger.ts b/src/lib/logger/logger.ts index c98018731..5a25f106e 100644 --- a/src/lib/logger/logger.ts +++ b/src/lib/logger/logger.ts @@ -1,8 +1,9 @@ -import { padLeft } from './utils'; -import pino from 'pino'; -import _ from 'lodash'; import buildDebug from 'debug'; import { yellow } from 'kleur'; +import _ from 'lodash'; +import pino from 'pino'; + +import { padLeft } from './utils'; function isProd() { return process.env.NODE_ENV === 'production'; @@ -21,7 +22,7 @@ export type LogType = 'file' | 'stdout'; export type LogFormat = 'json' | 'pretty-timestamped' | 'pretty'; export function createLogger( - options = {level: 'http'}, + options = { level: 'http' }, destination = pino.destination(1), format: LogFormat = DEFAULT_LOG_FORMAT, prettyPrintOptions = { @@ -63,10 +64,10 @@ export function createLogger( } const logger = pino(pinoConfig, destination); - if(process.env.DEBUG) { + if (process.env.DEBUG) { logger.on('level-change', (lvl, val, prevLvl, prevVal) => { debug('%s (%d) was changed to %s (%d)', lvl, val, prevLvl, prevVal); - }) + }); } return logger; @@ -110,9 +111,13 @@ export function setup(options: LoggerConfig | LoggerConfigItem = [DEFAULT_LOGGER // next major will thrown an error let loggerConfig = isLegacyConf ? options[0] : options; if (!loggerConfig?.level) { - loggerConfig = Object.assign({}, { - level: 'http', - }, loggerConfig); + loggerConfig = Object.assign( + {}, + { + level: 'http', + }, + loggerConfig + ); } const pinoConfig = { level: loggerConfig.level }; if (loggerConfig.type === 'file') { diff --git a/src/lib/logger/utils.ts b/src/lib/logger/utils.ts index fed81d2b6..76edb0d29 100644 --- a/src/lib/logger/utils.ts +++ b/src/lib/logger/utils.ts @@ -11,6 +11,6 @@ export function padLeft(message: string) { return message.padStart(message.length + CUSTOM_PAD_LENGTH, ' '); } -export function padRight(message: string, max = message.length + CUSTOM_PAD_LENGTH ) { +export function padRight(message: string, max = message.length + CUSTOM_PAD_LENGTH) { return message.padEnd(max, ' '); } diff --git a/src/lib/metadata-utils.ts b/src/lib/metadata-utils.ts index 37b7bf73d..d738f997d 100644 --- a/src/lib/metadata-utils.ts +++ b/src/lib/metadata-utils.ts @@ -2,11 +2,12 @@ * @prettier * @flow */ +import _ from 'lodash'; +import semver from 'semver'; + +import { Package } from '@verdaccio/types'; import { DIST_TAGS } from './constants'; -import semver from 'semver'; -import _ from 'lodash'; -import { Package } from '@verdaccio/types'; /** * Function gets a local info and an info from uplinks and tries to merge it diff --git a/src/lib/notify/index.ts b/src/lib/notify/index.ts index cd83a7d85..ad0e96dd1 100644 --- a/src/lib/notify/index.ts +++ b/src/lib/notify/index.ts @@ -1,18 +1,14 @@ -import { notifyRequest } from './notify-request'; import Handlebars from 'handlebars'; import _ from 'lodash'; - import { OptionsWithUrl } from 'request'; + import { Config, Package, RemoteUser } from '@verdaccio/types'; +import { notifyRequest } from './notify-request'; + type TemplateMetadata = Package & { publishedPackage: string }; -export function handleNotify( - metadata: Package, - notifyEntry, - remoteUser: RemoteUser, - publishedPackage: string -): Promise | void { +export function handleNotify(metadata: Package, notifyEntry, remoteUser: RemoteUser, publishedPackage: string): Promise | void { let regex; if (metadata.name && notifyEntry.packagePattern) { regex = new RegExp(notifyEntry.packagePattern, notifyEntry.packagePatternFlags || ''); @@ -35,7 +31,7 @@ export function handleNotify( const options: OptionsWithUrl = { body: content, - url: '' + url: '', }; // provides fallback support, it's accept an Object {} and Array of {} @@ -65,34 +61,17 @@ export function handleNotify( return notifyRequest(options, content); } -export function sendNotification( - metadata: Package, - notify: any, - remoteUser: RemoteUser, - publishedPackage: string -): Promise { +export function sendNotification(metadata: Package, notify: any, remoteUser: RemoteUser, publishedPackage: string): Promise { return handleNotify(metadata, notify, remoteUser, publishedPackage) as Promise; } -export function notify( - metadata: Package, - config: Config, - remoteUser: RemoteUser, - publishedPackage: string -): Promise | void { +export function notify(metadata: Package, config: Config, remoteUser: RemoteUser, publishedPackage: string): Promise | void { if (config.notify) { if (config.notify.content) { - return sendNotification( - metadata, - (config.notify as unknown) as any, - remoteUser, - publishedPackage - ); + return sendNotification(metadata, config.notify as unknown as any, remoteUser, publishedPackage); } // multiple notifications endpoints PR #108 - return Promise.all( - _.map(config.notify, (key) => sendNotification(metadata, key, remoteUser, publishedPackage)) - ); + return Promise.all(_.map(config.notify, (key) => sendNotification(metadata, key, remoteUser, publishedPackage))); } return Promise.resolve(); diff --git a/src/lib/notify/notify-request.ts b/src/lib/notify/notify-request.ts index a2e733991..c72cb6e8b 100644 --- a/src/lib/notify/notify-request.ts +++ b/src/lib/notify/notify-request.ts @@ -1,9 +1,10 @@ -import { logger } from '../logger'; -import { HTTP_STATUS } from '../constants'; -import isNil from 'lodash/isNil'; import buildDebug from 'debug'; +import isNil from 'lodash/isNil'; import request, { RequiredUriUrl } from 'request'; +import { HTTP_STATUS } from '../constants'; +import { logger } from '../logger'; + const debug = buildDebug('verdaccio:notify-request'); export function notifyRequest(options: RequiredUriUrl, content): Promise { return new Promise((resolve, reject): void => { diff --git a/src/lib/plugin-loader.ts b/src/lib/plugin-loader.ts index 31d5cbaaa..4065a96d5 100644 --- a/src/lib/plugin-loader.ts +++ b/src/lib/plugin-loader.ts @@ -1,9 +1,11 @@ -import Path from 'path'; -import { logger } from './logger'; -import { MODULE_NOT_FOUND } from './constants'; import _ from 'lodash'; +import Path from 'path'; + import { Config, IPlugin } from '@verdaccio/types'; +import { MODULE_NOT_FOUND } from './constants'; +import { logger } from './logger'; + /** * Requires a module. * @param {*} path the module's path @@ -46,96 +48,74 @@ function isES6(plugin): boolean { * @param {*} sanityCheck callback that check the shape that should fulfill the plugin * @return {Array} list of plugins */ -export default function loadPlugin>( - config: Config, - pluginConfigs: any = {}, - params: any, - sanityCheck: any, - prefix: string = 'verdaccio' -): any[] { - return Object.keys(pluginConfigs).map( - (pluginId: string): IPlugin => { - let plugin; +export default function loadPlugin>(config: Config, pluginConfigs: any = {}, params: any, sanityCheck: any, prefix: string = 'verdaccio'): any[] { + return Object.keys(pluginConfigs).map((pluginId: string): IPlugin => { + let plugin; - const localPlugin = Path.resolve(__dirname + '/../plugins', pluginId); - // try local plugins first - plugin = tryLoad(localPlugin); + const localPlugin = Path.resolve(__dirname + '/../plugins', pluginId); + // try local plugins first + plugin = tryLoad(localPlugin); - // try the external plugin directory - if (plugin === null && config.plugins) { - const pluginDir = config.plugins; - const externalFilePlugin = Path.resolve(pluginDir, pluginId); - plugin = tryLoad(externalFilePlugin); - - // npm package - if (plugin === null && pluginId.match(/^[^\.\/]/)) { - plugin = tryLoad(Path.resolve(pluginDir, `${prefix}-${pluginId}`)); - // compatibility for old sinopia plugins - if (!plugin) { - plugin = tryLoad(Path.resolve(pluginDir, `sinopia-${pluginId}`)); - } - } - } + // try the external plugin directory + if (plugin === null && config.plugins) { + const pluginDir = config.plugins; + const externalFilePlugin = Path.resolve(pluginDir, pluginId); + plugin = tryLoad(externalFilePlugin); // npm package if (plugin === null && pluginId.match(/^[^\.\/]/)) { - plugin = tryLoad(`${prefix}-${pluginId}`); + plugin = tryLoad(Path.resolve(pluginDir, `${prefix}-${pluginId}`)); // compatibility for old sinopia plugins if (!plugin) { - plugin = tryLoad(`sinopia-${pluginId}`); + plugin = tryLoad(Path.resolve(pluginDir, `sinopia-${pluginId}`)); } } - - if (plugin === null) { - plugin = tryLoad(pluginId); - } - - // relative to config path - if (plugin === null && pluginId.match(/^\.\.?($|\/)/)) { - plugin = tryLoad(Path.resolve(Path.dirname(config.self_path), pluginId)); - } - - if (plugin === null) { - logger.error( - { content: pluginId, prefix }, - 'plugin not found. try npm install @{prefix}-@{content}' - ); - throw Error(` - ${prefix}-${pluginId} plugin not found. try "npm install ${prefix}-${pluginId}"`); - } - - if (!isValid(plugin)) { - logger.error( - { content: pluginId }, - '@{prefix}-@{content} plugin does not have the right code structure' - ); - throw Error(`"${pluginId}" plugin does not have the right code structure`); - } - - /* eslint new-cap:off */ - try { - plugin = isES6(plugin) - ? new plugin.default(mergeConfig(config, pluginConfigs[pluginId]), params) - : plugin(pluginConfigs[pluginId], params); - } catch (error) { - plugin = null; - logger.error({ error, pluginId }, 'error loading a plugin @{pluginId}: @{error}'); - } - /* eslint new-cap:off */ - - if (plugin === null || !sanityCheck(plugin)) { - logger.error( - { content: pluginId, prefix }, - "@{prefix}-@{content} doesn't look like a valid plugin" - ); - throw Error(`sanity check has failed, "${pluginId}" is not a valid plugin`); - } - - logger.warn( - { content: pluginId, prefix }, - 'Plugin successfully loaded: @{prefix}-@{content}' - ); - return plugin; } - ); + + // npm package + if (plugin === null && pluginId.match(/^[^\.\/]/)) { + plugin = tryLoad(`${prefix}-${pluginId}`); + // compatibility for old sinopia plugins + if (!plugin) { + plugin = tryLoad(`sinopia-${pluginId}`); + } + } + + if (plugin === null) { + plugin = tryLoad(pluginId); + } + + // relative to config path + if (plugin === null && pluginId.match(/^\.\.?($|\/)/)) { + plugin = tryLoad(Path.resolve(Path.dirname(config.self_path), pluginId)); + } + + if (plugin === null) { + logger.error({ content: pluginId, prefix }, 'plugin not found. try npm install @{prefix}-@{content}'); + throw Error(` + ${prefix}-${pluginId} plugin not found. try "npm install ${prefix}-${pluginId}"`); + } + + if (!isValid(plugin)) { + logger.error({ content: pluginId }, '@{prefix}-@{content} plugin does not have the right code structure'); + throw Error(`"${pluginId}" plugin does not have the right code structure`); + } + + /* eslint new-cap:off */ + try { + plugin = isES6(plugin) ? new plugin.default(mergeConfig(config, pluginConfigs[pluginId]), params) : plugin(pluginConfigs[pluginId], params); + } catch (error) { + plugin = null; + logger.error({ error, pluginId }, 'error loading a plugin @{pluginId}: @{error}'); + } + /* eslint new-cap:off */ + + if (plugin === null || !sanityCheck(plugin)) { + logger.error({ content: pluginId, prefix }, "@{prefix}-@{content} doesn't look like a valid plugin"); + throw Error(`sanity check has failed, "${pluginId}" is not a valid plugin`); + } + + logger.warn({ content: pluginId, prefix }, 'Plugin successfully loaded: @{prefix}-@{content}'); + return plugin; + }); } diff --git a/src/lib/search.ts b/src/lib/search.ts index 84bf547fe..34173f150 100644 --- a/src/lib/search.ts +++ b/src/lib/search.ts @@ -1,8 +1,10 @@ // eslint-disable no-invalid-this - -import { IStorageHandler, IWebSearch, IStorage } from '../../types'; import lunrMutable from 'lunr-mutable-indexes'; + import { Version } from '@verdaccio/types'; + +import { IStorage, IStorageHandler, IWebSearch } from '../../types'; + /** * Handle the search Indexer. */ @@ -49,17 +51,16 @@ class Search implements IWebSearch { query = query.replace('@', ''); } - const results = query === '*' - ? localStorage.storagePlugin.get((items): any => { - items.map(function (pkg): any { - return { ref: pkg, score: 1 }; - }); - }) - : this.index.search(`*${query}*`); + const results = + query === '*' + ? localStorage.storagePlugin.get((items): any => { + items.map(function (pkg): any { + return { ref: pkg, score: 1 }; + }); + }) + : this.index.search(`*${query}*`); - return hasScope - ? results.filter(({ ref }) => ref.startsWith('@')) - : results; + return hasScope ? results.filter(({ ref }) => ref.startsWith('@')) : results; } /** @@ -73,7 +74,7 @@ class Search implements IWebSearch { description: pkg.description, version: `v${pkg.version}`, keywords: pkg.keywords, - author: pkg._npmUser ? pkg._npmUser.name : '???' + author: pkg._npmUser ? pkg._npmUser.name : '???', }); } diff --git a/src/lib/storage-utils.ts b/src/lib/storage-utils.ts index 999d3196e..645248482 100644 --- a/src/lib/storage-utils.ts +++ b/src/lib/storage-utils.ts @@ -1,12 +1,13 @@ -import { generateRandomHexString } from '../lib/crypto-utils'; -import { IStorage } from '../../types'; -import { ErrorCode, isObject, normalizeDistTags, semverSort } from './utils'; -import Search from './search'; - -import { API_ERROR, HTTP_STATUS, DIST_TAGS, USERS, STORAGE } from './constants'; -import { Package, Version, Author } from '@verdaccio/types'; import _ from 'lodash'; +import { Author, Package, Version } from '@verdaccio/types'; + +import { IStorage } from '../../types'; +import { generateRandomHexString } from '../lib/crypto-utils'; +import { API_ERROR, DIST_TAGS, HTTP_STATUS, STORAGE, USERS } from './constants'; +import Search from './search'; +import { ErrorCode, isObject, normalizeDistTags, semverSort } from './utils'; + export function generatePackageTemplate(name: string): Package { return { // standard things @@ -18,7 +19,7 @@ export function generatePackageTemplate(name: string): Package { _uplinks: {}, _distfiles: {}, _attachments: {}, - _rev: '' + _rev: '', }; } @@ -98,24 +99,15 @@ export function normalizeContributors(contributors: Author[]): Author[] { } else if (_.isString(contributors)) { return [ { - name: contributors - } + name: contributors, + }, ]; } return contributors; } -export const WHITELIST = [ - '_rev', - 'name', - 'versions', - 'dist-tags', - 'readme', - 'time', - '_id', - 'users' -]; +export const WHITELIST = ['_rev', 'name', 'versions', 'dist-tags', 'readme', 'time', '_id', 'users']; export function cleanUpLinksRef(keepUpLinkData: boolean, result: Package): Package { const propertyToKeep = [...WHITELIST]; @@ -165,11 +157,7 @@ export function publishPackage(name: string, metadata: any, localStorage: IStora }); } -export function checkPackageRemote( - name: string, - isAllowPublishOffline: boolean, - syncMetadata: Function -): Promise { +export function checkPackageRemote(name: string, isAllowPublishOffline: boolean, syncMetadata: Function): Promise { return new Promise((resolve, reject): void => { syncMetadata(name, null, {}, (err, packageJsonLocal, upLinksErrors): void => { // something weird @@ -212,8 +200,7 @@ export function mergeUplinkTimeIntoLocal(localMetadata: Package, remoteMetadata: export function prepareSearchPackage(data: Package, time: unknown): any { const listVersions: string[] = Object.keys(data.versions); const versions: string[] = semverSort(listVersions); - const latest: string | undefined = - data[DIST_TAGS] && data[DIST_TAGS].latest ? data[DIST_TAGS].latest : versions.pop(); + const latest: string | undefined = data[DIST_TAGS] && data[DIST_TAGS].latest ? data[DIST_TAGS].latest : versions.pop(); if (latest && data.versions[latest]) { const version: Version = data.versions[latest]; @@ -231,9 +218,9 @@ export function prepareSearchPackage(data: Package, time: unknown): any { bugs: version.bugs, license: version.license, time: { - modified: time + modified: time, }, - versions + versions, }; return pkg; diff --git a/src/lib/storage.ts b/src/lib/storage.ts index e667d64e7..9819b648d 100644 --- a/src/lib/storage.ts +++ b/src/lib/storage.ts @@ -1,22 +1,24 @@ import assert from 'assert'; -import Stream from 'stream'; -import { IStorage, IProxy, IStorageHandler, ProxyList, StringValue, IGetPackageOptions, ISyncUplinks, IPluginFilters } from '../../types'; -import { logger } from '../lib/logger'; -import ProxyStorage from './up-storage'; -import Search from './search'; -import { API_ERROR, HTTP_STATUS, DIST_TAGS } from './constants'; -import LocalStorage from './local-storage'; -import { checkPackageLocal, publishPackage, checkPackageRemote, cleanUpLinksRef, mergeUplinkTimeIntoLocal, generatePackageTemplate } from './storage-utils'; -import { setupUpLinks, updateVersionsHiddenUpLink } from './uplink-util'; -import { mergeVersions } from './metadata-utils'; -import { ErrorCode, normalizeDistTags, validateMetadata, isObject } from './utils'; -import { hasProxyTo } from './config-utils'; -import { VerdaccioError } from '@verdaccio/commons-api'; -import { GenericBody, TokenFilter, Token } from '@verdaccio/types'; -import { IReadTarball, IUploadTarball, Versions, Package, Config, MergeTags, Version, DistFile, Callback, Logger } from '@verdaccio/types'; -import { ReadTarball } from '@verdaccio/streams'; import async, { AsyncResultArrayCallback } from 'async'; import _ from 'lodash'; +import Stream from 'stream'; + +import { VerdaccioError } from '@verdaccio/commons-api'; +import { ReadTarball } from '@verdaccio/streams'; +import { GenericBody, Token, TokenFilter } from '@verdaccio/types'; +import { Callback, Config, DistFile, IReadTarball, IUploadTarball, Logger, MergeTags, Package, Version, Versions } from '@verdaccio/types'; + +import { IGetPackageOptions, IPluginFilters, IProxy, IStorage, IStorageHandler, ISyncUplinks, ProxyList, StringValue } from '../../types'; +import { logger } from '../lib/logger'; +import { hasProxyTo } from './config-utils'; +import { API_ERROR, DIST_TAGS, HTTP_STATUS } from './constants'; +import LocalStorage from './local-storage'; +import { mergeVersions } from './metadata-utils'; +import Search from './search'; +import { checkPackageLocal, checkPackageRemote, cleanUpLinksRef, generatePackageTemplate, mergeUplinkTimeIntoLocal, publishPackage } from './storage-utils'; +import ProxyStorage from './up-storage'; +import { setupUpLinks, updateVersionsHiddenUpLink } from './uplink-util'; +import { ErrorCode, isObject, normalizeDistTags, validateMetadata } from './utils'; class Storage implements IStorageHandler { public localStorage: IStorage; diff --git a/src/lib/up-storage.ts b/src/lib/up-storage.ts index f98aa2cd0..fe17d964d 100644 --- a/src/lib/up-storage.ts +++ b/src/lib/up-storage.ts @@ -1,16 +1,18 @@ -import zlib from 'zlib'; -import Stream from 'stream'; -import URL, { UrlWithStringQuery } from 'url'; -import { IProxy, UpLinkConfLocal } from '../../types'; -import { parseInterval, isObject, ErrorCode, buildToken, isObjectOrArray } from './utils'; -import { logger } from './logger'; -import { ERROR_CODE, TOKEN_BASIC, TOKEN_BEARER, HEADERS, HTTP_STATUS, API_ERROR, HEADER_TYPE, CHARACTER_ENCODING } from './constants'; import JSONStream from 'JSONStream'; import buildDebug from 'debug'; import _ from 'lodash'; import request from 'request'; +import Stream from 'stream'; +import URL, { UrlWithStringQuery } from 'url'; +import zlib from 'zlib'; + import { ReadTarball } from '@verdaccio/streams'; -import { Config, Callback, Headers, Logger, Package } from '@verdaccio/types'; +import { Callback, Config, Headers, Logger, Package } from '@verdaccio/types'; + +import { IProxy, UpLinkConfLocal } from '../../types'; +import { API_ERROR, CHARACTER_ENCODING, ERROR_CODE, HEADERS, HEADER_TYPE, HTTP_STATUS, TOKEN_BASIC, TOKEN_BEARER } from './constants'; +import { logger } from './logger'; +import { ErrorCode, buildToken, isObject, isObjectOrArray, parseInterval } from './utils'; const debug = buildDebug('verdaccio:up-storage'); diff --git a/src/lib/uplink-util.ts b/src/lib/uplink-util.ts index 635c62d99..1a4944f4d 100644 --- a/src/lib/uplink-util.ts +++ b/src/lib/uplink-util.ts @@ -1,6 +1,7 @@ +import { Config, Versions } from '@verdaccio/types'; + import { IProxy, ProxyList } from '../../types'; import ProxyStorage from './up-storage'; -import { Versions, Config } from '@verdaccio/types'; /** * Set up the Up Storage for each link. diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 30d827c94..03759263d 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,25 +1,24 @@ -import fs from 'fs'; import assert from 'assert'; -import DefaultURL, { URL } from 'url'; -import { generateGravatarUrl, GENERIC_AVATAR } from '../utils/user'; -import { StringValue, AuthorAvatar } from '../../types'; -import { APP_ERROR, DEFAULT_PORT, DEFAULT_DOMAIN, DEFAULT_PROTOCOL, HEADERS, DIST_TAGS, DEFAULT_USER } from './constants'; -import { normalizeContributors } from './storage-utils'; -import { logger } from './logger'; -import _ from 'lodash'; import buildDebug from 'debug'; -import semver from 'semver'; -import YAML from 'js-yaml'; -import validator from 'validator'; -import memoizee from 'memoizee'; -import sanitizyReadme from '@verdaccio/readme'; - -import { Package, Version, Author } from '@verdaccio/types'; import { Request } from 'express'; +import fs from 'fs'; +import YAML from 'js-yaml'; +import _ from 'lodash'; +import memoizee from 'memoizee'; +import semver from 'semver'; +import DefaultURL, { URL } from 'url'; +import validator from 'validator'; + // eslint-disable-next-line max-len -import { getConflict, getBadData, getBadRequest, getInternalError, getUnauthorized, getForbidden, getServiceUnavailable, getNotFound, getCode } from '@verdaccio/commons-api'; - +import { getBadData, getBadRequest, getCode, getConflict, getForbidden, getInternalError, getNotFound, getServiceUnavailable, getUnauthorized } from '@verdaccio/commons-api'; +import sanitizyReadme from '@verdaccio/readme'; +import { Author, Package, Version } from '@verdaccio/types'; +import { AuthorAvatar, StringValue } from '../../types'; +import { GENERIC_AVATAR, generateGravatarUrl } from '../utils/user'; +import { APP_ERROR, DEFAULT_DOMAIN, DEFAULT_PORT, DEFAULT_PROTOCOL, DEFAULT_USER, DIST_TAGS, HEADERS } from './constants'; +import { logger } from './logger'; +import { normalizeContributors } from './storage-utils'; const debug = buildDebug('verdaccio'); diff --git a/src/utils/user.ts b/src/utils/user.ts index fc7d9639e..5a05497d1 100644 --- a/src/utils/user.ts +++ b/src/utils/user.ts @@ -1,7 +1,8 @@ // @flow -import { stringToMD5 } from '../lib/crypto-utils'; import _ from 'lodash'; +import { stringToMD5 } from '../lib/crypto-utils'; + // this is a generic avatar // https://www.iconfinder.com/icons/403017/anonym_avatar_default_head_person_unknown_user_icon // license: free commercial usage diff --git a/test/README.md b/test/README.md index fda4d5496..11cfbb006 100644 --- a/test/README.md +++ b/test/README.md @@ -8,15 +8,15 @@ First of all, we should explain the testing frameworks being used. We use `jest` We go along with the following rules in order to be consistent with all tests which will make your code review smooth and fast: -* We **type** all our tests. eg `const foo: number = 3;` -* **Each test should be as small as possible**: You should use the `test()` block to test only one thing and do not depend on other tests. If the test requires different steps, group them with a `describe()` block. -* All `test()` **headers titles** should begin with `test('should test ...')`: For consistency with reporting tools, this makes it easier to match the test with the feature needed to be tested. -* **Any mock data** should be located in the `partials` folder in each section. -* Use `yaml` for **configuration files examples** instead of JSON. -* If you use a **file based mock storage**, it should be located in the `store` folder in each section. -* All tests **MUST NOT** rely on external sources and must be able to run them **offline**. -* Tests **must run on the following Operating Systems**: Unix (Mac, Linux) and Windows (7 -> latest). -* If you are creating mock data file which use the state and need a clean state, use `rimraf` to remove folders. +- We **type** all our tests. eg `const foo: number = 3;` +- **Each test should be as small as possible**: You should use the `test()` block to test only one thing and do not depend on other tests. If the test requires different steps, group them with a `describe()` block. +- All `test()` **headers titles** should begin with `test('should test ...')`: For consistency with reporting tools, this makes it easier to match the test with the feature needed to be tested. +- **Any mock data** should be located in the `partials` folder in each section. +- Use `yaml` for **configuration files examples** instead of JSON. +- If you use a **file based mock storage**, it should be located in the `store` folder in each section. +- All tests **MUST NOT** rely on external sources and must be able to run them **offline**. +- Tests **must run on the following Operating Systems**: Unix (Mac, Linux) and Windows (7 -> latest). +- If you are creating mock data file which use the state and need a clean state, use `rimraf` to remove folders. ## Testing sections @@ -24,11 +24,11 @@ Verdaccio testing is split in 3 sections, each of them has different setup and s If you are adding new tests, comply with the following: -* If you add a new API endpoint, unit and functional tests are mandatory. -* If you add a utility, unit test is mandatory. -* If you are adding a new web API endpoint, the unit test, functional test and if such endpoint has new changes in the UI, E2E test is also mandatory. -* If you add or refactor a core class, unit test is mandatory. -* If you fix a bug, you **must** add a new `test()` block to prove that the patch fixes the bug. +- If you add a new API endpoint, unit and functional tests are mandatory. +- If you add a utility, unit test is mandatory. +- If you are adding a new web API endpoint, the unit test, functional test and if such endpoint has new changes in the UI, E2E test is also mandatory. +- If you add or refactor a core class, unit test is mandatory. +- If you fix a bug, you **must** add a new `test()` block to prove that the patch fixes the bug. ## Unit test @@ -40,14 +40,14 @@ Unit tests aim to test the CLI API and the Web API. The configuration file is lo We have prepared a template at `test/unit/api/api.__test.template.spec.ts` that you can follow to create your own unit test. Only the tests are appended with `.spec.ts` which will be found and used by `jest`. -> Feel free to suggest improvements to the template, there is still a lot of room for improvement. +> Feel free to suggest improvements to the template, there is still a lot of room for improvement. We recommend the following approach when you create a unit test: -* For new utilities, we recommend creating a new spec. -* For existing utilities, if the method is already being tested, just add a new `test()` block. -* Notice that all API spec files are appended with `api.[feature].spec.js`, we recommend to follow the same approach. eg: `api.[deprecate].spec.js`. -* Don't mix utilities with API tests. +- For new utilities, we recommend creating a new spec. +- For existing utilities, if the method is already being tested, just add a new `test()` block. +- Notice that all API spec files are appended with `api.[feature].spec.js`, we recommend to follow the same approach. eg: `api.[deprecate].spec.js`. +- Don't mix utilities with API tests. ### How the mockServer works? @@ -86,29 +86,29 @@ const configForTest = configDefault({ The `configDefault({}, 'myConfig.yaml)` function is a method that returns a configuration file that will be the config used for your test. -* The *first argument* allows you to override/extend the default configuration located `/test/unit/partials/config/yaml/default.yaml`. -* The *second argument*s is being used to override the base configuration file, you only need to set the name `api.spec.yaml` you are willing to use, the relative location will be `test/unit/partials/config/yaml/` and will be prefixed on runtime. +- The _first argument_ allows you to override/extend the default configuration located `/test/unit/partials/config/yaml/default.yaml`. +- The *second argument*s is being used to override the base configuration file, you only need to set the name `api.spec.yaml` you are willing to use, the relative location will be `test/unit/partials/config/yaml/` and will be prefixed on runtime. > **The generated object will be used for run your test, not for mock the mock server.** The `app = await endPointAPI(configForTest);` is the server that you are about to run your test against. The `app` object is used to call the endoints, for instance: -```js +```js test('should fetch jquery package from remote uplink', (done) => { - request(app) - .get('/jquery') - .set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET) - .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET) - .expect(HTTP_STATUS.OK) - .end(function(err, res) { - if (err) { - return done(err); - } + request(app) + .get('/jquery') + .set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET) + .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET) + .expect(HTTP_STATUS.OK) + .end(function (err, res) { + if (err) { + return done(err); + } - expect(res.body).toBeDefined(); - expect(res.body.name).toMatch(/jquery/); - done(); - }); + expect(res.body).toBeDefined(); + expect(res.body.name).toMatch(/jquery/); + done(); + }); }); ``` @@ -118,7 +118,7 @@ In the previous example, we are fetching `jquery` metadata from our server, we c The `mockRegistry = await mockServer(mockServerPort).init();` mock registry will be used as `uplink` for the `app` object described above, **this is optional**, but, the most of the tests are using this approach for increase the number of tested scenarios. -The *mock server* has a static storage which is located `test/unit/partials/mock-store`, if you need add new packages, those must be commited in such folder. **Any modification in the mock server might affect other test, since is a shared context**. +The _mock server_ has a static storage which is located `test/unit/partials/mock-store`, if you need add new packages, those must be commited in such folder. **Any modification in the mock server might affect other test, since is a shared context**. > It is not possible yet to override the mocks configuration server. @@ -127,7 +127,6 @@ The *mock server* has a static storage which is located `test/unit/partials/mock > The `const mockServerPort = 55549;` mock server must be added manually, be careful and try to define a port that is not being used by another test, there is not automation here yet. > To increase debugging you might override the `logs` property using `{ type: 'stdout', format: 'pretty', level: 'trace' }` level **trace**, thus the test will display the server request in your terminal, try to keep it in **warn** by default to avoid noise on run all your test. -> #### Running a single Unit Test @@ -137,7 +136,7 @@ To run a single test, use the following command: yarn jest test/unit/modules/api/api.spec.ts --coverage=false ``` -You might use the *jest* feature `.only` to limit the test suites you want to run, for instance. +You might use the _jest_ feature `.only` to limit the test suites you want to run, for instance. ```js describe.only('should test package api', () => { @@ -199,62 +198,58 @@ Ran all test suites matching /test\/unit\/modules\/api\/api.spec.ts/i. debug-=- updating package jquery info http <-- 200, user: null(::ffff:127.0.0.1), req: 'GET /jquery', bytes: 0/10300 ``` + The debug display request headers and other handy information about what is happening between your test and the mock server. ## Functional tests The functional tests aim to run only **cli endpoint** and **web point** using real request to an existing and compiled running Verdaccio server. -> Be aware if you change something in the `{root}/src` source code, you must run `yarn code:build` before to be able to see your changes because functional tests use the transpiled code. +> Be aware if you change something in the `{root}/src` source code, you must run `yarn code:build` before to be able to see your changes because functional tests use the transpiled code. All tests must be included in the `test/functional/index.spec.ts` file, which bootstraps the whole process. There is only one spec file and **must be only one**. The jest configuration file is defined in `test/jest.config.functional.js`. The configuration will create a custom environment launching 3 Verdaccio servers with different configurations. -The servers are linked as follows: +The servers are linked as follows: -* Server 1 - * -> Server 2 - * -> Server 3 -* Server 2 - * -> Server 1 -* Server 3 - * -> Server 2 - * -> Server 1 -* Express app: (if you need to emulate any external endpoint, use the express app) +- Server 1 + - -> Server 2 + - -> Server 3 +- Server 2 + - -> Server 1 +- Server 3 + - -> Server 2 + - -> Server 1 +- Express app: (if you need to emulate any external endpoint, use the express app) Server 1 runs on port `55551`, Server 2 on port `55552` and Server 3 on port `55553`. > If you have the need to increase the number of servers running, it is possible, but please discuss with the team before you go in that path. - #### Adding a new block -To add a new feature you need to export the feature as a function that take as an argument any of the servers you want to interact. - +To add a new feature you need to export the feature as a function that take as an argument any of the servers you want to interact. ```js // newFeature.ts -export default function(server) { - +export default function (server) { describe('package access control', () => { test('should ...', (done) => { done(); }); }); - } ``` -Then import the feature and run the function within the main `describe` block. +Then import the feature and run the function within the main `describe` block. ```js // index.spec.ts - import newFeature from './newFeature'; -describe('functional test verdaccio', function() { +describe('functional test verdaccio', function () { // test are fast, but do not change this time out, 10 seconds should be more than enough jest.setTimeout(10000); // servers are accessed via a global jest state. @@ -272,39 +267,33 @@ Functional tests run over one single file, thus, it is not possible at this stag ## E2E Test -Verdaccio includes a Web User Interface that must be tested. We use End-to-End testing to run some mock tests against the web API using the UI Theme +Verdaccio includes a Web User Interface that must be tested. We use End-to-End testing to run some mock tests against the web API using the UI Theme include by default. ```bash yarn lint && yarn test:all ``` -The test does not have aim to test the integrity of the page, mostly, ensure the basic functionality still works. If you add or modify +The test does not have aim to test the integrity of the page, mostly, ensure the basic functionality still works. If you add or modify a UI feature, the tests must be updated. > The tests rely on CSS classes naming convention, so, it is required some sort of coordination with the **verdaccio/ui** project. -We uses `puppeteer`, you can find more information about how to use it in their website. +We uses `puppeteer`, you can find more information about how to use it in their website. ## Before commit -We recommend run your tests and linters before commit. +We recommend run your tests and linters before commit. ```bash yarn lint && yarn test:all ``` - You can find more in our [guide about run and debugging test](https://github.com/verdaccio/verdaccio/wiki/Running-and-Debugging-tests#running-the-test). ## Continuous Integration Verdaccio uses [CircleCI](https://circleci.com/gh/verdaccio) as its primary Continuous Integration tool. We run the tests against the most common Node.js versions available. Among them is LTS and the latest release. Before the PR is being merged, all checks must be green. -Node.js versions available, LTS and the latest release. Before the PR is being merged, all check must be green. - -> You need a CircleCI account to be able see the test running - - - - +Node.js versions available, LTS and the latest release. Before the PR is being merged, all check must be green. +> You need a CircleCI account to be able see the test running diff --git a/test/e2e-cli/env_babel.js b/test/e2e-cli/env_babel.js index eddce9aa3..93ed7b81a 100644 --- a/test/e2e-cli/env_babel.js +++ b/test/e2e-cli/env_babel.js @@ -1,4 +1,4 @@ require('@babel/register')({ - extensions: [".ts", ".js"] + extensions: ['.ts', '.js'], }); module.exports = require('./setup/test_environment'); diff --git a/test/e2e-cli/env_setup.js b/test/e2e-cli/env_setup.js index 222f7183e..dc96b42dc 100644 --- a/test/e2e-cli/env_setup.js +++ b/test/e2e-cli/env_setup.js @@ -1,4 +1,4 @@ require('@babel/register')({ - extensions: [".ts", ".js"] + extensions: ['.ts', '.js'], }); module.exports = require('./setup/setup'); diff --git a/test/e2e-cli/env_teardown.js b/test/e2e-cli/env_teardown.js index 75165a7c7..07f353212 100644 --- a/test/e2e-cli/env_teardown.js +++ b/test/e2e-cli/env_teardown.js @@ -1,4 +1,4 @@ require('@babel/register')({ - extensions: [".ts", ".js"] + extensions: ['.ts', '.js'], }); module.exports = require('./setup/teardown'); diff --git a/test/e2e-cli/jest.config.e2e.cli.js b/test/e2e-cli/jest.config.e2e.cli.js index 5cec14386..aa679f747 100644 --- a/test/e2e-cli/jest.config.e2e.cli.js +++ b/test/e2e-cli/jest.config.e2e.cli.js @@ -8,5 +8,5 @@ module.exports = { testEnvironment: './env_babel.js', globalSetup: './env_setup.js', globalTeardown: './env_teardown.js', - testRegex: '(/test/e2e.*\\.spec)\\.ts' + testRegex: '(/test/e2e.*\\.spec)\\.ts', }; diff --git a/test/e2e-cli/projects/basic/index.js b/test/e2e-cli/projects/basic/index.js index dee6a3383..ba03ef876 100644 --- a/test/e2e-cli/projects/basic/index.js +++ b/test/e2e-cli/projects/basic/index.js @@ -1,5 +1,5 @@ -module.exports = function() { - const message = "this is a basic project"; +module.exports = function () { + const message = 'this is a basic project'; // eslint-disable-next-line no-console console.log(message); diff --git a/test/e2e-cli/projects/scoped_basic/index.js b/test/e2e-cli/projects/scoped_basic/index.js index 43e94ca45..216b71160 100644 --- a/test/e2e-cli/projects/scoped_basic/index.js +++ b/test/e2e-cli/projects/scoped_basic/index.js @@ -1,5 +1,5 @@ -module.exports = function() { - const message = "this is a scoped basic project"; +module.exports = function () { + const message = 'this is a scoped basic project'; // eslint-disable-next-line no-console console.log(message); diff --git a/test/e2e-cli/projects/scoped_basic/package.json b/test/e2e-cli/projects/scoped_basic/package.json index bfa5b01de..233bb9c81 100644 --- a/test/e2e-cli/projects/scoped_basic/package.json +++ b/test/e2e-cli/projects/scoped_basic/package.json @@ -6,7 +6,11 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, - "keywords": ["verdaccio", "sample", "scoped"], + "keywords": [ + "verdaccio", + "sample", + "scoped" + ], "dependencies": { "verdaccio": "latest" }, diff --git a/test/e2e-cli/setup/setup.ts b/test/e2e-cli/setup/setup.ts index b23d7a7df..21f10fd8a 100644 --- a/test/e2e-cli/setup/setup.ts +++ b/test/e2e-cli/setup/setup.ts @@ -1,12 +1,12 @@ /* eslint-disable no-console */ - -import fs from 'fs'; -import path from 'path'; -import os from 'os'; import { spawn } from 'child_process'; -import { npm } from '../utils/process'; -import * as __global from '../utils/global.js'; +import fs from 'fs'; import { green } from 'kleur'; +import os from 'os'; +import path from 'path'; + +import * as __global from '../utils/global.js'; +import { npm } from '../utils/process'; module.exports = async () => { const tempRoot = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), 'verdaccio-cli-e2e-')); diff --git a/test/e2e-cli/setup/test_environment.ts b/test/e2e-cli/setup/test_environment.ts index d8dbeba51..f36099003 100644 --- a/test/e2e-cli/setup/test_environment.ts +++ b/test/e2e-cli/setup/test_environment.ts @@ -1,6 +1,7 @@ +import NodeEnvironment from 'jest-environment-node'; import os from 'os'; import path from 'path'; -import NodeEnvironment from 'jest-environment-node'; + const fs = require('fs'); const __global = require('../utils/global'); // import { npm } from '../utils/process'; @@ -11,9 +12,7 @@ class E2ECliTestEnvironment extends NodeEnvironment { } async setup() { - const tempRoot = fs.mkdtempSync( - path.join(fs.realpathSync(os.tmpdir()), 'verdaccio-suite-test-') - ); + const tempRoot = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), 'verdaccio-suite-test-')); __global.addItem('dir-root', tempRoot); this.global.__namespace = __global; // eslint-disable-next-line no-console diff --git a/test/e2e-cli/test/__partials/npm_commands.ts b/test/e2e-cli/test/__partials/npm_commands.ts index 19c221c0e..826f9fc81 100644 --- a/test/e2e-cli/test/__partials/npm_commands.ts +++ b/test/e2e-cli/test/__partials/npm_commands.ts @@ -1,14 +1,5 @@ import { silentNpm } from '../../utils/process'; export function installVerdaccio(verdaccioInstall) { - return silentNpm( - 'install', - '--prefix', - verdaccioInstall, - 'verdaccio', - '--registry', - 'http://localhost:4873', - '--no-package-lock', - '--verbose' - ); + return silentNpm('install', '--prefix', verdaccioInstall, 'verdaccio', '--registry', 'http://localhost:4873', '--no-package-lock', '--verbose'); } diff --git a/test/e2e-cli/test/core/info.spec.ts b/test/e2e-cli/test/core/info.spec.ts index deb91d9c9..413077e11 100644 --- a/test/e2e-cli/test/core/info.spec.ts +++ b/test/e2e-cli/test/core/info.spec.ts @@ -1,4 +1,5 @@ import path from 'path'; + import { runVerdaccio } from '../../utils/process'; import { installVerdaccio } from '../__partials/npm_commands'; @@ -14,14 +15,9 @@ describe('verdaccio info', () => { test('should run verdaccio info command', async () => { const pathVerdaccioModule = require.resolve('verdaccio/bin/verdaccio', { - paths: [verdaccioInstall] + paths: [verdaccioInstall], }); - const hasMatch = await runVerdaccio( - pathVerdaccioModule, - verdaccioInstall, - ['--info'], - /Environment/ - ); + const hasMatch = await runVerdaccio(pathVerdaccioModule, verdaccioInstall, ['--info'], /Environment/); expect(hasMatch.ok).toBeTruthy(); }, 20000); diff --git a/test/e2e-cli/test/core/listen.spec.ts b/test/e2e-cli/test/core/listen.spec.ts index 322795f41..8dd979396 100644 --- a/test/e2e-cli/test/core/listen.spec.ts +++ b/test/e2e-cli/test/core/listen.spec.ts @@ -1,8 +1,9 @@ -import path from 'path'; import fs from 'fs'; -import { installVerdaccio } from '../__partials/npm_commands'; +import path from 'path'; + import { spawnRegistry } from '../../utils/registry'; import { callRegistry } from '../../utils/web'; +import { installVerdaccio } from '../__partials/npm_commands'; describe('npm install', () => { jest.setTimeout(90000); @@ -21,12 +22,12 @@ describe('npm install', () => { test('should match the listing port and load metadata', async () => { const pathVerdaccioModule = require.resolve('verdaccio/bin/verdaccio', { - paths: [verdaccioInstall] + paths: [verdaccioInstall], }); registryProcess = await spawnRegistry(pathVerdaccioModule, ['-c', configPath, '-l', port], { cwd: verdaccioInstall, - silent: false + silent: false, }); const body = await callRegistry(`http://localhost:${port}/verdaccio`); diff --git a/test/e2e-cli/test/install/install.spec.ts b/test/e2e-cli/test/install/install.spec.ts index 8767d1d93..2be4fa02c 100644 --- a/test/e2e-cli/test/install/install.spec.ts +++ b/test/e2e-cli/test/install/install.spec.ts @@ -1,10 +1,11 @@ -import path from 'path'; import fs from 'fs'; -import * as __global from '../../utils/global'; -import { spawnRegistry } from '../../utils/registry'; -import { execAndWaitForOutputToMatch } from '../../utils/process'; -import { installVerdaccio } from '../__partials/npm_commands'; +import path from 'path'; + import { expectFileToExist } from '../../utils/expect'; +import * as __global from '../../utils/global'; +import { execAndWaitForOutputToMatch } from '../../utils/process'; +import { spawnRegistry } from '../../utils/registry'; +import { installVerdaccio } from '../__partials/npm_commands'; describe('npm install', () => { jest.setTimeout(90000); @@ -23,39 +24,28 @@ describe('npm install', () => { // @ts-ignore global.__namespace = __global; const pathVerdaccioModule = require.resolve('verdaccio/bin/verdaccio', { - paths: [verdaccioInstall] + paths: [verdaccioInstall], }); registryProcess = await spawnRegistry(pathVerdaccioModule, ['-c', configPath, '-l', port], { cwd: verdaccioInstall, - silent: true + silent: true, }); }); test('should match on npm info verdaccio', async () => { // FIXME: not the best match, looking for a better way to match the terminal output - const output = await execAndWaitForOutputToMatch( - 'npm', - ['info', 'verdaccio', '--registry'], - /A lightweight private npm proxy registry/ - ); + const output = await execAndWaitForOutputToMatch('npm', ['info', 'verdaccio', '--registry'], /A lightweight private npm proxy registry/); expect(output.ok).toBeTruthy(); }); test('should install jquery', async () => { const testCwd = path.join(tempRootFolder, '_jquery_'); - await execAndWaitForOutputToMatch( - 'npm', - ['install', '--prefix', testCwd, 'jquery', '--registry', `http://localhost:${port}`], - /''/, - { - cwd: verdaccioInstall - } - ); + await execAndWaitForOutputToMatch('npm', ['install', '--prefix', testCwd, 'jquery', '--registry', `http://localhost:${port}`], /''/, { + cwd: verdaccioInstall, + }); - const exist = await expectFileToExist( - path.join(testCwd, 'node_modules', 'jquery', 'package.json') - ); + const exist = await expectFileToExist(path.join(testCwd, 'node_modules', 'jquery', 'package.json')); expect(exist).toBeTruthy(); }); diff --git a/test/e2e-cli/test/search/search.spec.ts b/test/e2e-cli/test/search/search.spec.ts index 25a42725e..27b76556e 100644 --- a/test/e2e-cli/test/search/search.spec.ts +++ b/test/e2e-cli/test/search/search.spec.ts @@ -1,10 +1,11 @@ -import path from 'path'; import fs from 'fs'; -import * as __global from '../../utils/global'; -import { spawnRegistry } from '../../utils/registry'; -import { execAndWaitForOutputToMatch } from '../../utils/process'; -import { installVerdaccio } from '../__partials/npm_commands'; +import path from 'path'; + import { expectFileToExist } from '../../utils/expect'; +import * as __global from '../../utils/global'; +import { execAndWaitForOutputToMatch } from '../../utils/process'; +import { spawnRegistry } from '../../utils/registry'; +import { installVerdaccio } from '../__partials/npm_commands'; describe('npm search', () => { jest.setTimeout(90000); diff --git a/test/e2e-cli/utils/global.js b/test/e2e-cli/utils/global.js index ad398360a..57afc2dfa 100644 --- a/test/e2e-cli/utils/global.js +++ b/test/e2e-cli/utils/global.js @@ -2,15 +2,15 @@ const namespace = Object.create(null); -exports.addItem = function(name, value) { +exports.addItem = function (name, value) { namespace[name] = value; -} +}; -exports.getItem = function(name) { - console.log("get-item", name, namespace); +exports.getItem = function (name) { + console.log('get-item', name, namespace); if (!(name in namespace)) { - throw new Error("The item ".concat(name, " does exist in the namespace")); + throw new Error('The item '.concat(name, ' does exist in the namespace')); } return namespace[name]; -} +}; diff --git a/test/e2e-cli/utils/process.ts b/test/e2e-cli/utils/process.ts index 66c2374f7..8845d0cfd 100644 --- a/test/e2e-cli/utils/process.ts +++ b/test/e2e-cli/utils/process.ts @@ -1,5 +1,4 @@ /* eslint-disable no-console */ - import * as child_process from 'child_process'; import { SpawnOptions } from 'child_process'; @@ -14,7 +13,7 @@ export async function _exec(options, cmd, args) { console.log(`ENV: ${JSON.stringify(env)}`); const spawnOptions = { cwd, - ...(env ? { env } : {}) + ...(env ? { env } : {}), }; if (process.platform.startsWith('win')) { @@ -78,12 +77,7 @@ export async function _exec(options, cmd, args) { }); } -export function execAndWaitForOutputToMatch( - cmd: string, - args: string[], - match: RegExp, - spawnOptions: SpawnOptions = {} -): any { +export function execAndWaitForOutputToMatch(cmd: string, args: string[], match: RegExp, spawnOptions: SpawnOptions = {}): any { return _exec({ waitForMatch: match, ...spawnOptions, silence: true }, cmd, args); } diff --git a/test/e2e-cli/utils/registry.ts b/test/e2e-cli/utils/registry.ts index 94b9cd9e5..4b0a29b7e 100644 --- a/test/e2e-cli/utils/registry.ts +++ b/test/e2e-cli/utils/registry.ts @@ -8,7 +8,7 @@ export function spawnRegistry(verdaccioPath: string, args: string[], childOption const childFork = fork(verdaccioPath, args, _childOptions); - childFork.on('message', (msg: {verdaccio_started: boolean}) => { + childFork.on('message', (msg: { verdaccio_started: boolean }) => { if (msg.verdaccio_started) { resolve(childFork); } diff --git a/test/e2e-cli/utils/utils.ts b/test/e2e-cli/utils/utils.ts index e648a3bba..6dd4e025f 100644 --- a/test/e2e-cli/utils/utils.ts +++ b/test/e2e-cli/utils/utils.ts @@ -1,5 +1,5 @@ -import path from 'path'; import fs from 'fs'; +import path from 'path'; export function copyConfigFile(rootFolder, configTemplate): string { const configPath = path.join(rootFolder, 'verdaccio.yaml'); diff --git a/test/e2e-cli/utils/web.ts b/test/e2e-cli/utils/web.ts index 3d300e5fe..272e0cc46 100644 --- a/test/e2e-cli/utils/web.ts +++ b/test/e2e-cli/utils/web.ts @@ -5,7 +5,7 @@ export function callRegistry(url: string): Promise { return new Promise((resolve, reject) => { let options = { url: url, - headers: { Accept: 'application/json' } + headers: { Accept: 'application/json' }, }; // @ts-ignore request(options, (error: any, response: IncomingMessage, body: string) => { diff --git a/test/e2e/partials/pkg-protected.js b/test/e2e/partials/pkg-protected.js index fb1d1b880..eb5e960fb 100644 --- a/test/e2e/partials/pkg-protected.js +++ b/test/e2e/partials/pkg-protected.js @@ -1,54 +1,50 @@ const json = { - "_id": "protected-pkg", - "name": "protected-pkg", - "description": "", - "dist-tags": { - "latest": "5.0.5" + _id: 'protected-pkg', + name: 'protected-pkg', + description: '', + 'dist-tags': { + latest: '5.0.5', }, - "versions": { - "5.0.5": { - "name": "protected-pkg", - "version": "5.0.5", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + versions: { + '5.0.5': { + name: 'protected-pkg', + version: '5.0.5', + description: '', + main: 'index.js', + scripts: { + test: 'echo "Error: no test specified" && exit 1', }, - "keywords": [ - - ], - "author": { - "name": "User NPM", - "email": "user@domain.com" + keywords: [], + author: { + name: 'User NPM', + email: 'user@domain.com', }, - "license": "ISC", - "dependencies": { - "verdaccio": "^2.7.2" + license: 'ISC', + dependencies: { + verdaccio: '^2.7.2', }, - "readme": "# test", - "readmeFilename": "README.md", - "_id": "protected-pkg@5.0.5", - "_npmVersion": "5.5.1", - "_nodeVersion": "8.7.0", - "_npmUser": { - + readme: '# test', + readmeFilename: 'README.md', + _id: 'protected-pkg@5.0.5', + _npmVersion: '5.5.1', + _nodeVersion: '8.7.0', + _npmUser: {}, + dist: { + integrity: 'sha512-6gHiERpiDgtb3hjqpQH5/i7zRmvYi9pmCjQf2ZMy3QEa9wVk9RgdZaPWUt7ZOnWUPFjcr9cmE6dUBf+XoPoH4g==', + shasum: '2c03764f651a9f016ca0b7620421457b619151b9', + tarball: 'http://localhost:5555/protected-pkg/-/protected-pkg-5.0.5.tgz', }, - "dist": { - "integrity": "sha512-6gHiERpiDgtb3hjqpQH5\/i7zRmvYi9pmCjQf2ZMy3QEa9wVk9RgdZaPWUt7ZOnWUPFjcr9cmE6dUBf+XoPoH4g==", - "shasum": "2c03764f651a9f016ca0b7620421457b619151b9", - "tarball": "http:\/\/localhost:5555\/protected-pkg\/-\/protected-pkg-5.0.5.tgz" - } - } + }, }, - "readme": "# test", - "_attachments": { - "protected-pkg-5.0.5.tgz": { - "content_type": "application\/octet-stream", + readme: '# test', + _attachments: { + 'protected-pkg-5.0.5.tgz': { + content_type: 'application/octet-stream', // eslint-disable-next-line max-len - "data": "H4sIAAAAAAAAE+2W32vbMBDH85y\/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo\/\/79KPeQsnIw5KUDX\/9IOvurLuz\/DHSjK\/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF\/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI\/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS\/pLQe+D+FIv\/agIWI6GX66kFuIhT+1gDjrp\/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0\/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi\/IHpU9fz3\/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6\/f88f\/Pu47zomiPk2Lv\/dOv8h+P\/34\/D\/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=", - "length": 512 - } - } -} + data: 'H4sIAAAAAAAAE+2W32vbMBDH85y/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo//79KPeQsnIw5KUDX/9IOvurLuz/DHSjK/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS/pLQe+D+FIv/agIWI6GX66kFuIhT+1gDjrp/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi/IHpU9fz3/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6/f88f/Pu47zomiPk2Lv/dOv8h+P/34/D/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=', + length: 512, + }, + }, +}; module.exports = json; diff --git a/test/e2e/partials/pkg-scoped.js b/test/e2e/partials/pkg-scoped.js index 858cff451..c0c2f8449 100644 --- a/test/e2e/partials/pkg-scoped.js +++ b/test/e2e/partials/pkg-scoped.js @@ -1,54 +1,50 @@ const json = { - "_id": "@scope\/pk1-test", - "name": "@scope\/pk1-test", - "description": "", - "dist-tags": { - "latest": "1.0.6" + _id: '@scope/pk1-test', + name: '@scope/pk1-test', + description: '', + 'dist-tags': { + latest: '1.0.6', }, - "versions": { - "1.0.6": { - "name": "@scope\/pk1-test", - "version": "1.0.6", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + versions: { + '1.0.6': { + name: '@scope/pk1-test', + version: '1.0.6', + description: '', + main: 'index.js', + scripts: { + test: 'echo "Error: no test specified" && exit 1', }, - "keywords": [ - - ], - "author": { - "name": "User NPM", - "email": "user@domain.com" + keywords: [], + author: { + name: 'User NPM', + email: 'user@domain.com', }, - "license": "ISC", - "dependencies": { - "verdaccio": "^2.7.2" + license: 'ISC', + dependencies: { + verdaccio: '^2.7.2', }, - "readme": "# test", - "readmeFilename": "README.md", - "_id": "@scope\/pk1-test@1.0.6", - "_npmVersion": "5.5.1", - "_nodeVersion": "8.7.0", - "_npmUser": { - + readme: '# test', + readmeFilename: 'README.md', + _id: '@scope/pk1-test@1.0.6', + _npmVersion: '5.5.1', + _nodeVersion: '8.7.0', + _npmUser: {}, + dist: { + integrity: 'sha512-6gHiERpiDgtb3hjqpQH5/i7zRmvYi9pmCjQf2ZMy3QEa9wVk9RgdZaPWUt7ZOnWUPFjcr9cmE6dUBf+XoPoH4g==', + shasum: '2c03764f651a9f016ca0b7620421457b619151b9', + tarball: 'http://localhost:5555/@scope/pk1-test/-/@scope/pk1-test-1.0.6.tgz', }, - "dist": { - "integrity": "sha512-6gHiERpiDgtb3hjqpQH5\/i7zRmvYi9pmCjQf2ZMy3QEa9wVk9RgdZaPWUt7ZOnWUPFjcr9cmE6dUBf+XoPoH4g==", - "shasum": "2c03764f651a9f016ca0b7620421457b619151b9", - "tarball": "http:\/\/localhost:5555\/@scope\/pk1-test\/-\/@scope\/pk1-test-1.0.6.tgz" - } - } + }, }, - "readme": "# test", - "_attachments": { - "@scope\/pk1-test-1.0.6.tgz": { - "content_type": "application\/octet-stream", + readme: '# test', + _attachments: { + '@scope/pk1-test-1.0.6.tgz': { + content_type: 'application/octet-stream', // eslint-disable-next-line max-len - "data": "H4sIAAAAAAAAE+2W32vbMBDH85y\/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo\/\/79KPeQsnIw5KUDX\/9IOvurLuz\/DHSjK\/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF\/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI\/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS\/pLQe+D+FIv\/agIWI6GX66kFuIhT+1gDjrp\/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0\/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi\/IHpU9fz3\/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6\/f88f\/Pu47zomiPk2Lv\/dOv8h+P\/34\/D\/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=", - "length": 512 - } - } -} + data: 'H4sIAAAAAAAAE+2W32vbMBDH85y/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo//79KPeQsnIw5KUDX/9IOvurLuz/DHSjK/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS/pLQe+D+FIv/agIWI6GX66kFuIhT+1gDjrp/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi/IHpU9fz3/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6/f88f/Pu47zomiPk2Lv/dOv8h+P/34/D/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=', + length: 512, + }, + }, +}; module.exports = json; diff --git a/test/e2e/pre-setup.js b/test/e2e/pre-setup.js index 1a5055183..fc9e89437 100644 --- a/test/e2e/pre-setup.js +++ b/test/e2e/pre-setup.js @@ -1,4 +1,4 @@ require('@babel/register')({ - extensions: [".ts", ".js"] + extensions: ['.ts', '.js'], }); module.exports = require('./setup'); diff --git a/test/e2e/puppeteer_environment.js b/test/e2e/puppeteer_environment.js index c5f922003..ecae406d2 100644 --- a/test/e2e/puppeteer_environment.js +++ b/test/e2e/puppeteer_environment.js @@ -4,26 +4,23 @@ const fs = require('fs'); const os = require('os'); const path = require('path'); -const {VerdaccioConfig} = require("../lib/verdaccio-server"); -const VerdaccioProcess = require("../lib/server_process"); -const Server = require("../lib/server"); +const { VerdaccioConfig } = require('../lib/verdaccio-server'); +const VerdaccioProcess = require('../lib/server_process'); +const Server = require('../lib/server'); const { yellow } = require('kleur'); const NodeEnvironment = require('jest-environment-node'); const puppeteer = require('puppeteer'); - const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup'); class PuppeteerEnvironment extends NodeEnvironment { constructor(config) { - super(config) + super(config); } async setup() { - const config1 = new VerdaccioConfig(path.join(__dirname, './store-e2e'), - path.join(__dirname, './config/config-scoped-e2e.yaml'), 'http://0.0.0.0:55558/', 55558); - const config2 = new VerdaccioConfig(path.join(__dirname, './store-e2e'), - path.join(__dirname, './config/config-protected-e2e.yaml'), 'http://0.0.0.0:55552/', 55552); + const config1 = new VerdaccioConfig(path.join(__dirname, './store-e2e'), path.join(__dirname, './config/config-scoped-e2e.yaml'), 'http://0.0.0.0:55558/', 55558); + const config2 = new VerdaccioConfig(path.join(__dirname, './store-e2e'), path.join(__dirname, './config/config-protected-e2e.yaml'), 'http://0.0.0.0:55552/', 55552); const server1 = new Server.default(config1.domainPath); const server2 = new Server.default(config2.domainPath); const process1 = new VerdaccioProcess.default(config1, server1, false); @@ -37,13 +34,13 @@ class PuppeteerEnvironment extends NodeEnvironment { await super.setup(); const wsEndpoint = fs.readFileSync(path.join(DIR, 'wsEndpoint'), 'utf8'); if (!wsEndpoint) { - throw new Error('wsEndpoint not found') + throw new Error('wsEndpoint not found'); } this.global.__SERVER__ = server1; this.global.__SERVER_PROTECTED__ = server2; this.global.__BROWSER__ = await puppeteer.connect({ browserWSEndpoint: wsEndpoint, - }) + }); } async teardown() { diff --git a/test/e2e/teardown.js b/test/e2e/teardown.js index ee5a69828..7ebe14be8 100644 --- a/test/e2e/teardown.js +++ b/test/e2e/teardown.js @@ -7,8 +7,8 @@ const rimraf = require('rimraf'); const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup'); -module.exports = async function() { +module.exports = async function () { console.log(green('Teardown Puppeteer')); await global.__BROWSER__.close(); - rimraf.sync(DIR) + rimraf.sync(DIR); }; diff --git a/test/functional/adduser/adduser.js b/test/functional/adduser/adduser.js index ce9adea42..50001af76 100644 --- a/test/functional/adduser/adduser.js +++ b/test/functional/adduser/adduser.js @@ -1,12 +1,13 @@ -import {API_ERROR, HTTP_STATUS} from "../../../src/lib/constants"; +import { API_ERROR, HTTP_STATUS } from '../../../src/lib/constants'; -export default function(server) { +export default function (server) { describe('npm adduser', () => { const user = String(Math.random()); const pass = String(Math.random()); - beforeAll(function() { - return server.auth(user, pass) + beforeAll(function () { + return server + .auth(user, pass) .status(HTTP_STATUS.CREATED) .body_ok(/user .* created/); }); @@ -14,15 +15,14 @@ export default function(server) { test('should create new user', () => {}); test('should log in', () => { - return server.auth(user, pass) + return server + .auth(user, pass) .status(HTTP_STATUS.CREATED) .body_ok(/you are authenticated as/); }); test('should not register more users', () => { - return server.auth(String(Math.random()), String(Math.random())) - .status(HTTP_STATUS.CONFLICT) - .body_error(API_ERROR.MAX_USERS_REACHED); + return server.auth(String(Math.random()), String(Math.random())).status(HTTP_STATUS.CONFLICT).body_error(API_ERROR.MAX_USERS_REACHED); }); }); } diff --git a/test/functional/adduser/logout.js b/test/functional/adduser/logout.js index 89f70ad99..f57a785d0 100644 --- a/test/functional/adduser/logout.js +++ b/test/functional/adduser/logout.js @@ -1,10 +1,10 @@ -import {HTTP_STATUS} from "../../../src/lib/constants"; - -export default function(server) { +import { HTTP_STATUS } from '../../../src/lib/constants'; +export default function (server) { describe('logout', () => { test('should log out', () => { - return server.logout('some-token') + return server + .logout('some-token') .status(HTTP_STATUS.OK) .body_ok(/Logged out/); }); diff --git a/test/functional/basic/basic.ts b/test/functional/basic/basic.ts index f10292747..d85aa7812 100644 --- a/test/functional/basic/basic.ts +++ b/test/functional/basic/basic.ts @@ -1,17 +1,12 @@ import fs from 'fs'; import path from 'path'; + +import { DIST_TAGS, HTTP_STATUS } from '../../../src/lib/constants'; import { createTarballHash } from '../../../src/lib/crypto-utils'; -import { HTTP_STATUS, DIST_TAGS } from '../../../src/lib/constants'; -import { - CREDENTIALS, - DOMAIN_SERVERS, - PORT_SERVER_1, - PORT_SERVER_2, - TARBALL -} from '../config.functional'; +import { CREDENTIALS, DOMAIN_SERVERS, PORT_SERVER_1, PORT_SERVER_2, TARBALL } from '../config.functional'; import fixturePkg from '../fixtures/package'; -import whoIam from './whoIam'; import ping from './ping'; +import whoIam from './whoIam'; function readfile(folderPath) { return fs.readFileSync(path.join(__dirname, '/', folderPath)); @@ -57,27 +52,16 @@ export default function (server: any, server2: any) { }); test('uploading incomplete tarball', () => { - return server.putTarballIncomplete( - PKG_NAME, - 'blahblah1', - readfile('../fixtures/binary'), - 3000 - ); + return server.putTarballIncomplete(PKG_NAME, 'blahblah1', readfile('../fixtures/binary'), 3000); }); describe('publishing package', () => { beforeAll(function () { - return server - .putTarball(PKG_NAME, TARBALL, readfile('../fixtures/binary')) - .status(HTTP_STATUS.CREATED) - .body_ok(/.*/); + return server.putTarball(PKG_NAME, TARBALL, readfile('../fixtures/binary')).status(HTTP_STATUS.CREATED).body_ok(/.*/); }); beforeAll(function () { - return server - .putTarball('testpkg-single-tarball', 'single', readfile('../fixtures/binary')) - .status(HTTP_STATUS.CREATED) - .body_ok(/.*/); + return server.putTarball('testpkg-single-tarball', 'single', readfile('../fixtures/binary')).status(HTTP_STATUS.CREATED).body_ok(/.*/); }); afterAll(function () { @@ -103,9 +87,7 @@ export default function (server: any, server2: any) { // testexp-incomplete test('remove existing single tarball', () => { - return server - .removeSingleTarball('testpkg-single-tarball', 'single') - .status(HTTP_STATUS.CREATED); + return server.removeSingleTarball('testpkg-single-tarball', 'single').status(HTTP_STATUS.CREATED); }); // testexp-incomplete @@ -133,9 +115,7 @@ export default function (server: any, server2: any) { beforeAll(function () { const pkg = getPackage(PKG_NAME); - pkg.dist.shasum = createTarballHash() - .update(readfile('../fixtures/binary')) - .digest('hex'); + pkg.dist.shasum = createTarballHash().update(readfile('../fixtures/binary')).digest('hex'); return server .putVersion(PKG_NAME, PKG_VERSION, pkg) .status(HTTP_STATUS.CREATED) @@ -144,10 +124,7 @@ export default function (server: any, server2: any) { describe('should download a package', () => { beforeAll(function () { - return server - .auth(CREDENTIALS.user, CREDENTIALS.password) - .status(HTTP_STATUS.CREATED) - .body_ok(new RegExp(CREDENTIALS.user)); + return server.auth(CREDENTIALS.user, CREDENTIALS.password).status(HTTP_STATUS.CREATED).body_ok(new RegExp(CREDENTIALS.user)); }); test('should download a newly created package from server1', () => { @@ -157,11 +134,9 @@ export default function (server: any, server2: any) { .then(function (body) { expect(body.name).toEqual(PKG_NAME); expect(body.versions[PKG_VERSION].name).toEqual(PKG_NAME); - expect(body.versions[PKG_VERSION].dist.tarball).toEqual( - `http://${DOMAIN_SERVERS}:${PORT_SERVER_1}/${PKG_NAME}/-/${TARBALL}` - ); + expect(body.versions[PKG_VERSION].dist.tarball).toEqual(`http://${DOMAIN_SERVERS}:${PORT_SERVER_1}/${PKG_NAME}/-/${TARBALL}`); expect(body[DIST_TAGS]).toEqual({ - latest: PKG_VERSION + latest: PKG_VERSION, }); }); }); @@ -173,11 +148,9 @@ export default function (server: any, server2: any) { .then(function (body) { expect(body.name).toEqual(PKG_NAME); expect(body.versions[PKG_VERSION].name).toEqual(PKG_NAME); - expect(body.versions[PKG_VERSION].dist.tarball).toEqual( - `http://${DOMAIN_SERVERS}:${PORT_SERVER_2}/${PKG_NAME}/-/${TARBALL}` - ); + expect(body.versions[PKG_VERSION].dist.tarball).toEqual(`http://${DOMAIN_SERVERS}:${PORT_SERVER_2}/${PKG_NAME}/-/${TARBALL}`); expect(body[DIST_TAGS]).toEqual({ - latest: PKG_VERSION + latest: PKG_VERSION, }); }); }); diff --git a/test/functional/config.functional.js b/test/functional/config.functional.js index 5fc094358..f74c68003 100644 --- a/test/functional/config.functional.js +++ b/test/functional/config.functional.js @@ -1,8 +1,8 @@ -import {DOMAIN_SERVERS as localhost} from '../test.conf'; +import { DOMAIN_SERVERS as localhost } from '../test.conf'; export const CREDENTIALS = { user: 'test', - password: 'test' + password: 'test', }; export const TARBALL = 'tarball-blahblah-file.name'; diff --git a/test/functional/fixtures/package.ts b/test/functional/fixtures/package.ts index 11abd027d..c124c12ae 100644 --- a/test/functional/fixtures/package.ts +++ b/test/functional/fixtures/package.ts @@ -1,20 +1,13 @@ import { DOMAIN_SERVERS, PORT_SERVER_1, TARBALL } from '../config.functional'; -export default function ( - name, - version = '0.0.0', - port = PORT_SERVER_1, - domain = `http://${DOMAIN_SERVERS}:${port}`, - fileName = TARBALL, - readme = 'this is a readme' -): any { +export default function (name, version = '0.0.0', port = PORT_SERVER_1, domain = `http://${DOMAIN_SERVERS}:${port}`, fileName = TARBALL, readme = 'this is a readme'): any { return { name, version, readme, dist: { shasum: 'fake', - tarball: `${domain}/${encodeURIComponent(name)}/-/${fileName}` - } + tarball: `${domain}/${encodeURIComponent(name)}/-/${fileName}`, + }, }; } diff --git a/test/functional/fixtures/plugins/middlewares.es6.js b/test/functional/fixtures/plugins/middlewares.es6.js index 0d17e46a3..c98af136c 100644 --- a/test/functional/fixtures/plugins/middlewares.es6.js +++ b/test/functional/fixtures/plugins/middlewares.es6.js @@ -29,28 +29,24 @@ 'use strict'; -Object.defineProperty(exports, "__esModule", { - value: true +Object.defineProperty(exports, '__esModule', { + value: true, }); class PluginES6 { - constructor(config, stuff) { this._config = config; this._logger = stuff.logger; } - register_middlewares(app, /* auth, storage */) { + register_middlewares(app /* auth, storage */) { const message = this._config.message; - app.get('/test/route/es6', function (req, res, next) { res.status(200); return next({ ok: message }); }); } - } exports.default = PluginES6; - diff --git a/test/functional/fixtures/plugins/middlewares.js b/test/functional/fixtures/plugins/middlewares.js index cdeee39ce..2bb52562b 100644 --- a/test/functional/fixtures/plugins/middlewares.js +++ b/test/functional/fixtures/plugins/middlewares.js @@ -7,12 +7,11 @@ function Plugin(config, pluginOptions) { } Plugin.prototype.register_middlewares = function (app) { - - const {message} = this._config; + const { message } = this._config; app.get('/test/route', function (req, res, next) { res.status(200); - return next({ ok: message }) + return next({ ok: message }); }); }; diff --git a/test/functional/fixtures/plugins/middlewares.uplink.js b/test/functional/fixtures/plugins/middlewares.uplink.js index 24381eaf9..11e141607 100644 --- a/test/functional/fixtures/plugins/middlewares.uplink.js +++ b/test/functional/fixtures/plugins/middlewares.uplink.js @@ -8,7 +8,6 @@ function Plugin(config) { } Plugin.prototype.register_middlewares = function (app) { - app.get('/test-uplink-timeout-*', function (req, res, next) { // https://github.com/nock/nock#readme nock('http://localhost:55552') @@ -21,7 +20,6 @@ Plugin.prototype.register_middlewares = function (app) { next(); }); - }; module.exports = Plugin; diff --git a/test/functional/fixtures/tags.json b/test/functional/fixtures/tags.json index 4930e215e..9d05cc9f8 100644 --- a/test/functional/fixtures/tags.json +++ b/test/functional/fixtures/tags.json @@ -1,48 +1,48 @@ { - "name": "__NAME__", - "versions": { - "0.1.0": { - "name": "__NAME__", - "version": "0.1.0", - "dist": { - "shasum": "fake", - "tarball": "http://localhost:55551/__NAME__/-/blahblah" - } - }, - "0.1.1alpha": { - "name": "__NAME__", - "version": "0.1.1alpha", - "dist": { - "shasum": "fake", - "tarball": "http://localhost:55551/__NAME__/-/blahblah" - } - }, - "0.1.2": { - "name": "__NAME__", - "version": "0.1.2", - "dist": { - "shasum": "fake", - "tarball": "http://localhost:55551/__NAME__/-/blahblah" - } - }, - "0.1.3alpha": { - "name": "__NAME__", - "version": "0.1.3alpha", - "dist": { - "shasum": "fake", - "tarball": "http://localhost:55551/__NAME__/-/blahblah" - } - }, - "1.1.0": { - "name": "__NAME__", - "version": "1.1.0", - "dist": { - "shasum": "fake", - "tarball": "http://localhost:55551/__NAME__/-/blahblah" - } - } - }, - "dist-tags": { - "latest": "1.1.0" - } + "name": "__NAME__", + "versions": { + "0.1.0": { + "name": "__NAME__", + "version": "0.1.0", + "dist": { + "shasum": "fake", + "tarball": "http://localhost:55551/__NAME__/-/blahblah" + } + }, + "0.1.1alpha": { + "name": "__NAME__", + "version": "0.1.1alpha", + "dist": { + "shasum": "fake", + "tarball": "http://localhost:55551/__NAME__/-/blahblah" + } + }, + "0.1.2": { + "name": "__NAME__", + "version": "0.1.2", + "dist": { + "shasum": "fake", + "tarball": "http://localhost:55551/__NAME__/-/blahblah" + } + }, + "0.1.3alpha": { + "name": "__NAME__", + "version": "0.1.3alpha", + "dist": { + "shasum": "fake", + "tarball": "http://localhost:55551/__NAME__/-/blahblah" + } + }, + "1.1.0": { + "name": "__NAME__", + "version": "1.1.0", + "dist": { + "shasum": "fake", + "tarball": "http://localhost:55551/__NAME__/-/blahblah" + } + } + }, + "dist-tags": { + "latest": "1.1.0" + } } diff --git a/test/functional/index.spec.ts b/test/functional/index.spec.ts index 80760d520..6fc65b68f 100644 --- a/test/functional/index.spec.ts +++ b/test/functional/index.spec.ts @@ -1,34 +1,32 @@ // we need this for notifications import { setup } from '../../src/lib/logger'; - -setup({}); - import { IServerBridge } from '../types'; - +import adduser from './adduser/adduser'; +import logout from './adduser/logout'; import basic from './basic/basic'; +import notify from './notifications/notify'; import packageAccess from './package/access'; import packageGzip from './package/gzip'; import packageScoped from './package/scoped'; -import tags from './tags/tags'; -import distTagsMerge from './tags/dist-tags-merge'; -import addtag from './tags/addtag'; -import adduser from './adduser/adduser'; -import logout from './adduser/logout'; -import notify from './notifications/notify'; -import incomplete from './sanity/incomplete'; -import mirror from './sanity/mirror'; -import readme from './readme/readme'; -import gh29 from './scenarios/gh29'; -import nullstorage from './sanity/nullstorage'; -import simpleSearch from './search/simple.search'; -import racycrash from './sanity/racycrash'; -import security from './sanity/security'; import race from './performance/race'; import pluginsAuth from './plugins/auth'; import middleware from './plugins/middleware'; +import readme from './readme/readme'; +import incomplete from './sanity/incomplete'; +import mirror from './sanity/mirror'; +import nullstorage from './sanity/nullstorage'; +import racycrash from './sanity/racycrash'; +import security from './sanity/security'; +import gh29 from './scenarios/gh29'; +import simpleSearch from './search/simple.search'; +import addtag from './tags/addtag'; +import distTagsMerge from './tags/dist-tags-merge'; +import tags from './tags/tags'; import upLinkCache from './uplinks/cache'; import uplinkTimeout from './uplinks/timeout'; +setup({}); + describe('functional test verdaccio', function () { jest.setTimeout(20000); // @ts-ignore diff --git a/test/functional/lib/environment.ts b/test/functional/lib/environment.ts index 0a5037024..125c9d649 100644 --- a/test/functional/lib/environment.ts +++ b/test/functional/lib/environment.ts @@ -1,14 +1,14 @@ /* eslint-disable no-console */ - +import NodeEnvironment from 'jest-environment-node'; +import { blue, green, magenta, yellow } from 'kleur'; import path from 'path'; -import { VerdaccioConfig } from '../../lib/verdaccio-server'; -import VerdaccioProcess from '../../lib/server_process'; + import Server from '../../lib/server'; +import VerdaccioProcess from '../../lib/server_process'; +import { VerdaccioConfig } from '../../lib/verdaccio-server'; import { IServerBridge } from '../../types'; import { DOMAIN_SERVERS, PORT_SERVER_1, PORT_SERVER_2, PORT_SERVER_3 } from '../config.functional'; import ExpressServer from './simple_server'; -import NodeEnvironment from 'jest-environment-node'; -import { yellow, green, blue, magenta } from 'kleur'; const EXPRESS_PORT = 55550; @@ -28,9 +28,7 @@ class FunctionalEnvironment extends NodeEnvironment { public async setup() { const SILENCE_LOG = !process.env.VERDACCIO_DEBUG; // @ts-ignore - const DEBUG_INJECT: boolean = process.env.VERDACCIO_DEBUG_INJECT - ? process.env.VERDACCIO_DEBUG_INJECT - : false; + const DEBUG_INJECT: boolean = process.env.VERDACCIO_DEBUG_INJECT ? process.env.VERDACCIO_DEBUG_INJECT : false; const forkList: any[] = []; const serverList: IServerBridge[] = []; const pathStore = path.join(__dirname, '../store'); @@ -38,18 +36,18 @@ class FunctionalEnvironment extends NodeEnvironment { { port: PORT_SERVER_1, config: '/config-1.yaml', - storage: '/test-storage' + storage: '/test-storage', }, { port: PORT_SERVER_2, config: '/config-2.yaml', - storage: '/test-storage2' + storage: '/test-storage2', }, { port: PORT_SERVER_3, config: '/config-3.yaml', - storage: '/test-storage3' - } + storage: '/test-storage3', + }, ]; console.log(green('Setup Verdaccio Servers')); diff --git a/test/functional/lib/simple_server.ts b/test/functional/lib/simple_server.ts index 3a9e13337..4ea6e968a 100644 --- a/test/functional/lib/simple_server.ts +++ b/test/functional/lib/simple_server.ts @@ -1,5 +1,5 @@ -import express from 'express'; import bodyParser from 'body-parser'; +import express from 'express'; /** * Simple Server @@ -28,7 +28,7 @@ export default class ExpressServer { this.app.use(bodyParser.json()); this.app.use( bodyParser.urlencoded({ - extended: true + extended: true, }) ); diff --git a/test/functional/notifications/notify.ts b/test/functional/notifications/notify.ts index 80c7931d0..b8d3874ca 100644 --- a/test/functional/notifications/notify.ts +++ b/test/functional/notifications/notify.ts @@ -1,9 +1,10 @@ +import _ from 'lodash'; + +import { RemoteUser } from '@verdaccio/types'; import { HEADERS } from '../../../src/lib/constants'; import { notify } from '../../../src/lib/notify'; import { DOMAIN_SERVERS, PORT_SERVER_APP } from '../config.functional'; -import { RemoteUser } from '@verdaccio/types'; -import _ from 'lodash'; export default function (express) { const config = { @@ -11,19 +12,19 @@ export default function (express) { method: 'POST', headers: [ { - 'Content-Type': HEADERS.JSON - } + 'Content-Type': HEADERS.JSON, + }, ], endpoint: `http://${DOMAIN_SERVERS}:${PORT_SERVER_APP}/api/notify`, // eslint-disable-next-line max-len - content: `{"color":"green","message":"New package published: * {{ name }}*. Publisher name: * {{ publisher.name }} *.","notify":true,"message_format":"text"}` - } + content: `{"color":"green","message":"New package published: * {{ name }}*. Publisher name: * {{ publisher.name }} *.","notify":true,"message_format":"text"}`, + }, }; const publisherInfo: RemoteUser = { name: 'publisher-name-test', real_groups: [], - groups: [] + groups: [], }; describe('notifications', () => { @@ -45,16 +46,14 @@ export default function (express) { test('notification should be send', (done) => { const metadata = { - name: 'pkg-test' + name: 'pkg-test', }; // @ts-ignore notify(metadata, config, publisherInfo, 'foo').then( function (body) { const jsonBody = parseBody(body); - expect( - `New package published: * ${metadata.name}*. Publisher name: * ${publisherInfo.name} *.` - ).toBe(jsonBody.message); + expect(`New package published: * ${metadata.name}*. Publisher name: * ${publisherInfo.name} *.`).toBe(jsonBody.message); done(); }, function (err) { @@ -66,22 +65,20 @@ export default function (express) { test('notification should be send single header', (done) => { const metadata = { - name: 'pkg-test' + name: 'pkg-test', }; const configMultipleHeader = _.cloneDeep(config); configMultipleHeader.notify.headers = { // @ts-ignore - 'Content-Type': HEADERS.JSON + 'Content-Type': HEADERS.JSON, }; // @ts-ignore notify(metadata, configMultipleHeader, publisherInfo).then( function (body) { const jsonBody = parseBody(body); - expect( - `New package published: * ${metadata.name}*. Publisher name: * ${publisherInfo.name} *.` - ).toBe(jsonBody.message); + expect(`New package published: * ${metadata.name}*. Publisher name: * ${publisherInfo.name} *.`).toBe(jsonBody.message); done(); }, function (err) { @@ -93,12 +90,12 @@ export default function (express) { test('notification should be send multiple notifications endpoints', (done) => { const metadata = { - name: 'pkg-test' + name: 'pkg-test', }; // let notificationsCounter = 0; const multipleNotificationsEndpoint = { - notify: [] + notify: [], }; for (let i = 0; i < 10; i++) { @@ -116,9 +113,7 @@ export default function (express) { function (body) { body.forEach(function (notification) { const jsonBody = parseBody(notification); - expect( - `New package published: * ${metadata.name}*. Publisher name: * ${publisherInfo.name} *.` - ).toBe(jsonBody.message); + expect(`New package published: * ${metadata.name}*. Publisher name: * ${publisherInfo.name} *.`).toBe(jsonBody.message); }); done(); }, @@ -131,7 +126,7 @@ export default function (express) { test('notification should fails', (done) => { const metadata = { - name: 'pkg-test' + name: 'pkg-test', }; const configFail = _.cloneDeep(config); configFail.notify.endpoint = `http://${DOMAIN_SERVERS}:${PORT_SERVER_APP}/api/notify/bad`; @@ -153,17 +148,15 @@ export default function (express) { const metadata = { name: 'pkg-test', publisher: { - name: 'existing-publisher-name' - } + name: 'existing-publisher-name', + }, }; // @ts-ignore notify(metadata, config, publisherInfo).then( function (body) { const jsonBody = parseBody(body); - expect( - `New package published: * ${metadata.name}*. Publisher name: * ${metadata.publisher.name} *.` - ).toBe(jsonBody.message); + expect(`New package published: * ${metadata.name}*. Publisher name: * ${metadata.publisher.name} *.`).toBe(jsonBody.message); done(); }, function (err) { diff --git a/test/functional/package/access.ts b/test/functional/package/access.ts index 16a822751..7489570fa 100644 --- a/test/functional/package/access.ts +++ b/test/functional/package/access.ts @@ -1,5 +1,5 @@ -import { buildToken } from '../../../src/lib/utils'; import { API_ERROR, HTTP_STATUS, TOKEN_BASIC } from '../../../src/lib/constants'; +import { buildToken } from '../../../src/lib/utils'; import { CREDENTIALS } from '../config.functional'; import fixturePkg from '../fixtures/package'; diff --git a/test/functional/package/gzip.ts b/test/functional/package/gzip.ts index f9c050b6c..adaa16980 100644 --- a/test/functional/package/gzip.ts +++ b/test/functional/package/gzip.ts @@ -1,7 +1,8 @@ /* eslint-disable jest/no-standalone-expect */ import zlib from 'zlib'; + +import { CHARACTER_ENCODING, HEADERS, HEADER_TYPE, HTTP_STATUS } from '../../../src/lib/constants'; import { readFile } from '../lib/test.utils'; -import { HEADER_TYPE, HEADERS, HTTP_STATUS, CHARACTER_ENCODING } from '../../../src/lib/constants'; export default function (server, express) { const PKG_NAME = 'testexp_gzip'; @@ -64,9 +65,9 @@ export default function (server, express) { uri: `/${PKG_NAME}`, encoding: null, headers: { - [HEADER_TYPE.ACCEPT_ENCODING]: HEADERS.GZIP + [HEADER_TYPE.ACCEPT_ENCODING]: HEADERS.GZIP, }, - json: false + json: false, }) .status(HTTP_STATUS.OK) .response(function (res) { diff --git a/test/functional/package/scoped.json b/test/functional/package/scoped.json index 71de0d2df..0ac1d2d49 100644 --- a/test/functional/package/scoped.json +++ b/test/functional/package/scoped.json @@ -1,13 +1,13 @@ { - "_id": "@test\/scoped", - "name": "@test\/scoped", + "_id": "@test/scoped", + "name": "@test/scoped", "description": "test... test... test...", "dist-tags": { "latest": "1.0.0" }, "versions": { "1.0.0": { - "name": "@test\/scoped", + "name": "@test/scoped", "version": "1.0.0", "description": "test... test... test...", "main": "index.js", @@ -17,25 +17,23 @@ "author": "", "license": "ISC", "readme": "ERROR: No README data found!", - "_id": "@test\/scoped@1.0.0", + "_id": "@test/scoped@1.0.0", "_shasum": "6e67b14e2c0e450b942e2bc8086b49e90f594790", "_from": ".", "_npmVersion": "2.0.1", "_nodeVersion": "0.10.25", - "_npmUser": { - - }, + "_npmUser": {}, "dist": { "shasum": "6e67b14e2c0e450b942e2bc8086b49e90f594790", - "tarball": "http:\/\/localhost:4873\/@test\/scoped\/-\/@test\/scoped-1.0.0.tgz" + "tarball": "http://localhost:4873/@test/scoped/-/@test/scoped-1.0.0.tgz" } } }, "readme": "ERROR: No README data found!", "_attachments": { - "@test\/scoped-1.0.0.tgz": { - "content_type": "application\/octet-stream", - "data": "H4sIAAAAAAAAAytITM5OTE\/VL4DQelnF+XkMVAYGBgZmZiYKQNrQ3NQAmQYDYwMg29DIxMTY2Mzc1NSYwcDQ2MDIDChPbYdgA6XFJYlFQKdQag7ELwpweoiAaqW8xNxUJSslh5LU4hL94uT8gtQUJR2lstSi4sz8PKCEoZ6BngFQJCW1OLkos6AEIgpSraenp4BGA9XlJmaCFGTmpaRWAJMTUASir1jJqhqsDSiZmpyRrxCj5FpUlF9kpZCXD9auUFyQmpyZlpmaEqOkoKamkFqRWaJgqFSro5RYWpKRXwTUBzQsJzM5Na8Y5GLPYGel2oEOv6EOCtDyf2Vibg617SCQ\/41MzZHyv+Fo\/qcnAOV+KwXU3M8FzfxWCuC8z4WU863QMzyM5gJleysFWK7nguZ5Ky4FsAqgFaTkeS5IjgfqUuKCZngrBWB+5xro4Bp2AJb\/QZGhC4l\/XXCs65WkV1HJDgL539QAOf8bmwHzv4khWD2V7McLRnj+l+\/mgDCY307enXXYQKTN+LUmn5QRq\/u+5mVOLy\/szBZTXN1764bRpKAgp3t7j08XuS7itTLT4+P+P49iligvXC\/2ydVmZendyg9vfLbOiOjZqOPNYHsm2OxLmOHhUglVT5n0Sql0brFjOqcM7b8qxGe+37PB4lT+95fvmOTrVK0ueU3pKqp6PPVztrrvWq5di9afssrV8mlh5JZw43q65OrW94t8SwVYDIrWaLfmcZWErmCuU+8pqe37lHy7zVN1O5vZl3NRyZYhy3LZw7VXym\/VMhOZ5h3A\/lZxyXJR0er9pmK\/CzbPnbaq6OyR7\/zbv5S8\/L677Kryv\/suO2f\/6sn\/0X+p5kC9RPmfdOP\/9Qvb6vjmv1S3\/SMT9e1kQ40d2783Sw7OOzyz6pLxec4tohVH\/Geoy3684erJb8P+ZG7Mr51pZ2eZvr7\/QpbVdU4yA8\/ARuEoGAWjYBSQBQDM0BedABAAAA==", + "@test/scoped-1.0.0.tgz": { + "content_type": "application/octet-stream", + "data": "H4sIAAAAAAAAAytITM5OTE/VL4DQelnF+XkMVAYGBgZmZiYKQNrQ3NQAmQYDYwMg29DIxMTY2Mzc1NSYwcDQ2MDIDChPbYdgA6XFJYlFQKdQag7ELwpweoiAaqW8xNxUJSslh5LU4hL94uT8gtQUJR2lstSi4sz8PKCEoZ6BngFQJCW1OLkos6AEIgpSraenp4BGA9XlJmaCFGTmpaRWAJMTUASir1jJqhqsDSiZmpyRrxCj5FpUlF9kpZCXD9auUFyQmpyZlpmaEqOkoKamkFqRWaJgqFSro5RYWpKRXwTUBzQsJzM5Na8Y5GLPYGel2oEOv6EOCtDyf2Vibg617SCQ/41MzZHyv+Fo/qcnAOV+KwXU3M8FzfxWCuC8z4WU863QMzyM5gJleysFWK7nguZ5Ky4FsAqgFaTkeS5IjgfqUuKCZngrBWB+5xro4Bp2AJb/QZGhC4l/XXCs65WkV1HJDgL539QAOf8bmwHzv4khWD2V7McLRnj+l+/mgDCY307enXXYQKTN+LUmn5QRq/u+5mVOLy/szBZTXN1764bRpKAgp3t7j08XuS7itTLT4+P+P49iligvXC/2ydVmZendyg9vfLbOiOjZqOPNYHsm2OxLmOHhUglVT5n0Sql0brFjOqcM7b8qxGe+37PB4lT+95fvmOTrVK0ueU3pKqp6PPVztrrvWq5di9afssrV8mlh5JZw43q65OrW94t8SwVYDIrWaLfmcZWErmCuU+8pqe37lHy7zVN1O5vZl3NRyZYhy3LZw7VXym/VMhOZ5h3A/lZxyXJR0er9pmK/CzbPnbaq6OyR7/zbv5S8/L677Kryv/suO2f/6sn/0X+p5kC9RPmfdOP/9Qvb6vjmv1S3/SMT9e1kQ40d2783Sw7OOzyz6pLxec4tohVH/Geoy3684erJb8P+ZG7Mr51pZ2eZvr7/QpbVdU4yA8/ARuEoGAWjYBSQBQDM0BedABAAAA==", "length": 736 } } diff --git a/test/functional/package/scoped.ts b/test/functional/package/scoped.ts index 12605d965..fb2cb6c62 100644 --- a/test/functional/package/scoped.ts +++ b/test/functional/package/scoped.ts @@ -1,7 +1,7 @@ import { HEADERS, HTTP_STATUS } from '../../../src/lib/constants'; +import { DIST_TAGS } from '../../../src/lib/constants'; import { DOMAIN_SERVERS, PORT_SERVER_1, PORT_SERVER_2 } from '../config.functional'; import { generateSha } from '../lib/test.utils'; -import { DIST_TAGS } from '../../../src/lib/constants'; export default function (server, server2) { const SCOPE = '@test/scoped'; @@ -14,10 +14,10 @@ export default function (server, server2) { .request({ uri: '/@test%2fscoped', headers: { - 'content-type': HEADERS.JSON + 'content-type': HEADERS.JSON, }, method: 'PUT', - json: require('./scoped.json') + json: require('./scoped.json'), }) .status(HTTP_STATUS.CREATED); }); @@ -52,9 +52,7 @@ export default function (server, server2) { .then(function (body) { expect(body.name).toBe(SCOPE); expect(body.versions[PKG_VERSION].name).toBe(SCOPE); - expect(body.versions[PKG_VERSION].dist.tarball).toBe( - `http://${DOMAIN_SERVERS}:${port}/@test%2fscoped/-/${PKG_NAME}-${PKG_VERSION}.tgz` - ); + expect(body.versions[PKG_VERSION].dist.tarball).toBe(`http://${DOMAIN_SERVERS}:${port}/@test%2fscoped/-/${PKG_NAME}-${PKG_VERSION}.tgz`); expect(body[DIST_TAGS]).toEqual({ latest: PKG_VERSION }); }); @@ -66,14 +64,12 @@ export default function (server, server2) { test('should work nginx workaround', () => { return server2 .request({ - uri: '/@test/scoped/1.0.0' + uri: '/@test/scoped/1.0.0', }) .status(HTTP_STATUS.OK) .then(function (body) { expect(body.name).toEqual(SCOPE); - expect(body.dist.tarball).toEqual( - `http://${DOMAIN_SERVERS}:${PORT_SERVER_2}/@test%2fscoped/-/${PKG_NAME}-${PKG_VERSION}.tgz` - ); + expect(body.dist.tarball).toEqual(`http://${DOMAIN_SERVERS}:${PORT_SERVER_2}/@test%2fscoped/-/${PKG_NAME}-${PKG_VERSION}.tgz`); }); }); }); diff --git a/test/functional/performance/race.ts b/test/functional/performance/race.ts index 8d6877813..3b922015d 100644 --- a/test/functional/performance/race.ts +++ b/test/functional/performance/race.ts @@ -1,9 +1,9 @@ import async from 'async'; import { HTTP_STATUS } from '../../../src/lib/constants'; +import racePkg from '../fixtures/package'; let okTotalSum = 0; -import racePkg from '../fixtures/package'; export default function (server) { describe('should test race condition on publish packages', () => { @@ -61,10 +61,7 @@ export default function (server) { failCount++; } - if ( - resp.statusCode === HTTP_STATUS.SERVICE_UNAVAILABLE && - ~body.error.indexOf(UNAVAILABLE) - ) { + if (resp.statusCode === HTTP_STATUS.SERVICE_UNAVAILABLE && ~body.error.indexOf(UNAVAILABLE)) { failCount++; } }); @@ -112,10 +109,7 @@ export default function (server) { if (response.statusCode === HTTP_STATUS.CONFLICT && ~body.error.indexOf(PRESENT)) { failcount++; } - if ( - response.statusCode === HTTP_STATUS.SERVICE_UNAVAILABLE && - ~body.error.indexOf(UNAVAILABLE) - ) { + if (response.statusCode === HTTP_STATUS.SERVICE_UNAVAILABLE && ~body.error.indexOf(UNAVAILABLE)) { failcount++; } }); diff --git a/test/functional/plugins/auth.ts b/test/functional/plugins/auth.ts index cb4f1b9c3..5879d29e4 100644 --- a/test/functional/plugins/auth.ts +++ b/test/functional/plugins/auth.ts @@ -1,4 +1,4 @@ -import { HTTP_STATUS, API_ERROR } from '../../../src/lib/constants'; +import { API_ERROR, HTTP_STATUS } from '../../../src/lib/constants'; export default function (server2) { // credentials @@ -40,21 +40,11 @@ export default function (server2) { describe('plugin authentication', () => { describe('test users authentication', () => { test('should not authenticate user1 with wrong password', () => { - return requestAuthFail( - USER1, - WRONG_PASSWORD, - "i don't like your password", - HTTP_STATUS.UNAUTHORIZED - ); + return requestAuthFail(USER1, WRONG_PASSWORD, "i don't like your password", HTTP_STATUS.UNAUTHORIZED); }); test('should not authenticate user2 with wrong password', () => { - return requestAuthFail( - USER2, - WRONG_PASSWORD, - "i don't like your password", - HTTP_STATUS.UNAUTHORIZED - ); + return requestAuthFail(USER2, WRONG_PASSWORD, "i don't like your password", HTTP_STATUS.UNAUTHORIZED); }); test('should right user2 password handled by plugin', () => { @@ -69,61 +59,37 @@ export default function (server2) { describe('test package access authorization', () => { describe(`access with user ${USER1} on server2`, () => { beforeAll(function () { - return server2 - .auth(USER1, CORRECT_PASSWORD) - .status(HTTP_STATUS.CREATED) - .body_ok(new RegExp(USER1)); + return server2.auth(USER1, CORRECT_PASSWORD).status(HTTP_STATUS.CREATED).body_ok(new RegExp(USER1)); }); test(`should fails (404) on access ${UNEXISTING_PKG_NAME}`, () => { - return server2 - .getPackage(UNEXISTING_PKG_NAME) - .status(HTTP_STATUS.NOT_FOUND) - .body_error(API_ERROR.NO_PACKAGE); + return server2.getPackage(UNEXISTING_PKG_NAME).status(HTTP_STATUS.NOT_FOUND).body_error(API_ERROR.NO_PACKAGE); }); test(`should fails (403) access ${ONLY_ACCESS_BY_USER_2}`, () => { - return server2 - .getPackage(ONLY_ACCESS_BY_USER_2) - .status(HTTP_STATUS.FORBIDDEN) - .body_error(API_ERROR.NOT_ALLOWED); + return server2.getPackage(ONLY_ACCESS_BY_USER_2).status(HTTP_STATUS.FORBIDDEN).body_error(API_ERROR.NOT_ALLOWED); }); test(`should fails (404) access ${AUTH_PKG_ACCESS_NAME}`, () => { - return server2 - .getPackage(AUTH_PKG_ACCESS_NAME) - .status(HTTP_STATUS.NOT_FOUND) - .body_error(API_ERROR.NO_PACKAGE); + return server2.getPackage(AUTH_PKG_ACCESS_NAME).status(HTTP_STATUS.NOT_FOUND).body_error(API_ERROR.NO_PACKAGE); }); }); describe(`access with user ${USER2} on server2`, () => { beforeAll(function () { - return server2 - .auth(USER2, CORRECT_PASSWORD) - .status(HTTP_STATUS.CREATED) - .body_ok(new RegExp(USER2)); + return server2.auth(USER2, CORRECT_PASSWORD).status(HTTP_STATUS.CREATED).body_ok(new RegExp(USER2)); }); test(`should fails (403) on access ${UNEXISTING_PKG_NAME}`, () => { - return server2 - .getPackage(UNEXISTING_PKG_NAME) - .status(HTTP_STATUS.FORBIDDEN) - .body_error(API_ERROR.NOT_ALLOWED); + return server2.getPackage(UNEXISTING_PKG_NAME).status(HTTP_STATUS.FORBIDDEN).body_error(API_ERROR.NOT_ALLOWED); }); test(`should fails (403) on access ${DENY_PKG_NAME}`, () => { - return server2 - .getPackage(DENY_PKG_NAME) - .status(HTTP_STATUS.FORBIDDEN) - .body_error(API_ERROR.NOT_ALLOWED); + return server2.getPackage(DENY_PKG_NAME).status(HTTP_STATUS.FORBIDDEN).body_error(API_ERROR.NOT_ALLOWED); }); test(`should fails (404) access ${AUTH_PKG_ACCESS_NAME}`, () => { - return server2 - .getPackage(AUTH_PKG_ACCESS_NAME) - .status(HTTP_STATUS.NOT_FOUND) - .body_error(API_ERROR.NO_PACKAGE); + return server2.getPackage(AUTH_PKG_ACCESS_NAME).status(HTTP_STATUS.NOT_FOUND).body_error(API_ERROR.NO_PACKAGE); }); }); }); diff --git a/test/functional/plugins/middleware.ts b/test/functional/plugins/middleware.ts index 49f88c56f..81dd64da9 100644 --- a/test/functional/plugins/middleware.ts +++ b/test/functional/plugins/middleware.ts @@ -6,7 +6,7 @@ export default function (server2) { return server2 .request({ uri: '/test/route', - method: 'GET' + method: 'GET', }) .status(HTTP_STATUS.OK) .body_ok('this is a custom route'); @@ -16,7 +16,7 @@ export default function (server2) { return server2 .request({ uri: '/test/route/es6', - method: 'GET' + method: 'GET', }) .status(HTTP_STATUS.OK) .body_ok('this is a custom route es6'); diff --git a/test/functional/pre-setup.js b/test/functional/pre-setup.js index 19decbf84..31af75e4d 100644 --- a/test/functional/pre-setup.js +++ b/test/functional/pre-setup.js @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-var-requires */ require('@babel/register')({ - extensions: [".ts", ".js"] + extensions: ['.ts', '.js'], }); module.exports = require('./lib/setup'); diff --git a/test/functional/readme/pkg-no-readme.json b/test/functional/readme/pkg-no-readme.json index cd595ffbd..2fd65d246 100644 --- a/test/functional/readme/pkg-no-readme.json +++ b/test/functional/readme/pkg-no-readme.json @@ -24,7 +24,7 @@ "_id": "test-readme@0.0.0", "dist": { "shasum": "8ee7331cbc641581b1a8cecd9d38d744a8feb863", - "tarball": "http:\/\/localhost:1234\/test-readme\/-\/test-readme-0.0.0.tgz" + "tarball": "http://localhost:1234/test-readme/-/test-readme-0.0.0.tgz" }, "_from": ".", "_npmVersion": "1.3.1", @@ -48,8 +48,8 @@ ], "_attachments": { "test-readme-0.0.0.tgz": { - "content_type": "application\/octet-stream", - "data": "H4sIAAAAAAAAA+2TsW7CMBCGM\/spTh6YKHUSIJLXqkPnrixWcIMLsS3btCDEu\/fs0Ba1SFVVVISUP8Odzqf\/zlY+K+qlaOSt7eLo2RudnVmMsel4DBjzasKOY1JZlJDlRVkU5aSspnnG8pIVOZ6fe5FTWvsgHK7yV5\/uLvARr0Q7qkUrKadB+mCXzY2Wr9q2TjZ0SF+k88poPGUj\/LAyl752yoauioVWqJgpPZcb\/Hmw0jV4ynfJEw9lvTAwo\/fOGcdBG4h18FbW6knJ+YzCYAByowLkdD+kTlrjVTBumzy2Nq7XqIDea7eKY7FJrMPCuG6Hlaql9rHr4fGO7i\/9pFcl+4X\/rWhX557xA\/9FVZ3gv+j5\/w9F+jl8g58c0OeQyCdH3HOglETsObxTTw7McwLJClt+wzz5JD45IPEcEHjMEfg0r8M9pQfaOSDs5NLP16tXr15XqzeJD6m5AAwAAA==", + "content_type": "application/octet-stream", + "data": "H4sIAAAAAAAAA+2TsW7CMBCGM/spTh6YKHUSIJLXqkPnrixWcIMLsS3btCDEu/fs0Ba1SFVVVISUP8Odzqf/zlY+K+qlaOSt7eLo2RudnVmMsel4DBjzasKOY1JZlJDlRVkU5aSspnnG8pIVOZ6fe5FTWvsgHK7yV5/uLvARr0Q7qkUrKadB+mCXzY2Wr9q2TjZ0SF+k88poPGUj/LAyl752yoauioVWqJgpPZcb/Hmw0jV4ynfJEw9lvTAwo/fOGcdBG4h18FbW6knJ+YzCYAByowLkdD+kTlrjVTBumzy2Nq7XqIDea7eKY7FJrMPCuG6Hlaql9rHr4fGO7i/9pFcl+4X/rWhX557xA/9FVZ3gv+j5/w9F+jl8g58c0OeQyCdH3HOglETsObxTTw7McwLJClt+wzz5JD45IPEcEHjMEfg0r8M9pQfaOSDs5NLP16tXr15XqzeJD6m5AAwAAA==", "length": 352 } } diff --git a/test/functional/readme/pkg-readme-npm6.json b/test/functional/readme/pkg-readme-npm6.json index 873486610..014b0cfa6 100644 --- a/test/functional/readme/pkg-readme-npm6.json +++ b/test/functional/readme/pkg-readme-npm6.json @@ -24,7 +24,7 @@ "_id": "test-readme@0.0.0", "dist": { "shasum": "8ee7331cbc641581b1a8cecd9d38d744a8feb863", - "tarball": "http:\/\/localhost:1234\/test-readme\/-\/test-readme-0.0.0.tgz" + "tarball": "http://localhost:1234/test-readme/-/test-readme-0.0.0.tgz" }, "_from": ".", "_npmVersion": "1.3.1", @@ -49,8 +49,8 @@ ], "_attachments": { "test-readme-0.0.0.tgz": { - "content_type": "application\/octet-stream", - "data": "H4sIAAAAAAAAA+2TsW7CMBCGM\/spTh6YKHUSIJLXqkPnrixWcIMLsS3btCDEu\/fs0Ba1SFVVVISUP8Odzqf\/zlY+K+qlaOSt7eLo2RudnVmMsel4DBjzasKOY1JZlJDlRVkU5aSspnnG8pIVOZ6fe5FTWvsgHK7yV5\/uLvARr0Q7qkUrKadB+mCXzY2Wr9q2TjZ0SF+k88poPGUj\/LAyl752yoauioVWqJgpPZcb\/Hmw0jV4ynfJEw9lvTAwo\/fOGcdBG4h18FbW6knJ+YzCYAByowLkdD+kTlrjVTBumzy2Nq7XqIDea7eKY7FJrMPCuG6Hlaql9rHr4fGO7i\/9pFcl+4X\/rWhX557xA\/9FVZ3gv+j5\/w9F+jl8g58c0OeQyCdH3HOglETsObxTTw7McwLJClt+wzz5JD45IPEcEHjMEfg0r8M9pQfaOSDs5NLP16tXr15XqzeJD6m5AAwAAA==", + "content_type": "application/octet-stream", + "data": "H4sIAAAAAAAAA+2TsW7CMBCGM/spTh6YKHUSIJLXqkPnrixWcIMLsS3btCDEu/fs0Ba1SFVVVISUP8Odzqf/zlY+K+qlaOSt7eLo2RudnVmMsel4DBjzasKOY1JZlJDlRVkU5aSspnnG8pIVOZ6fe5FTWvsgHK7yV5/uLvARr0Q7qkUrKadB+mCXzY2Wr9q2TjZ0SF+k88poPGUj/LAyl752yoauioVWqJgpPZcb/Hmw0jV4ynfJEw9lvTAwo/fOGcdBG4h18FbW6knJ+YzCYAByowLkdD+kTlrjVTBumzy2Nq7XqIDea7eKY7FJrMPCuG6Hlaql9rHr4fGO7i/9pFcl+4X/rWhX557xA/9FVZ3gv+j5/w9F+jl8g58c0OeQyCdH3HOglETsObxTTw7McwLJClt+wzz5JD45IPEcEHjMEfg0r8M9pQfaOSDs5NLP16tXr15XqzeJD6m5AAwAAA==", "length": 352 } } diff --git a/test/functional/readme/pkg-readme.json b/test/functional/readme/pkg-readme.json index 145b8686e..d7528a6df 100644 --- a/test/functional/readme/pkg-readme.json +++ b/test/functional/readme/pkg-readme.json @@ -25,7 +25,7 @@ "_id": "test-readme@0.0.0", "dist": { "shasum": "8ee7331cbc641581b1a8cecd9d38d744a8feb863", - "tarball": "http:\/\/localhost:1234\/test-readme\/-\/test-readme-0.0.0.tgz" + "tarball": "http://localhost:1234/test-readme/-/test-readme-0.0.0.tgz" }, "_from": ".", "_npmVersion": "1.3.1", @@ -50,8 +50,8 @@ ], "_attachments": { "test-readme-0.0.0.tgz": { - "content_type": "application\/octet-stream", - "data": "H4sIAAAAAAAAA+2TsW7CMBCGM\/spTh6YKHUSIJLXqkPnrixWcIMLsS3btCDEu\/fs0Ba1SFVVVISUP8Odzqf\/zlY+K+qlaOSt7eLo2RudnVmMsel4DBjzasKOY1JZlJDlRVkU5aSspnnG8pIVOZ6fe5FTWvsgHK7yV5\/uLvARr0Q7qkUrKadB+mCXzY2Wr9q2TjZ0SF+k88poPGUj\/LAyl752yoauioVWqJgpPZcb\/Hmw0jV4ynfJEw9lvTAwo\/fOGcdBG4h18FbW6knJ+YzCYAByowLkdD+kTlrjVTBumzy2Nq7XqIDea7eKY7FJrMPCuG6Hlaql9rHr4fGO7i\/9pFcl+4X\/rWhX557xA\/9FVZ3gv+j5\/w9F+jl8g58c0OeQyCdH3HOglETsObxTTw7McwLJClt+wzz5JD45IPEcEHjMEfg0r8M9pQfaOSDs5NLP16tXr15XqzeJD6m5AAwAAA==", + "content_type": "application/octet-stream", + "data": "H4sIAAAAAAAAA+2TsW7CMBCGM/spTh6YKHUSIJLXqkPnrixWcIMLsS3btCDEu/fs0Ba1SFVVVISUP8Odzqf/zlY+K+qlaOSt7eLo2RudnVmMsel4DBjzasKOY1JZlJDlRVkU5aSspnnG8pIVOZ6fe5FTWvsgHK7yV5/uLvARr0Q7qkUrKadB+mCXzY2Wr9q2TjZ0SF+k88poPGUj/LAyl752yoauioVWqJgpPZcb/Hmw0jV4ynfJEw9lvTAwo/fOGcdBG4h18FbW6knJ+YzCYAByowLkdD+kTlrjVTBumzy2Nq7XqIDea7eKY7FJrMPCuG6Hlaql9rHr4fGO7i/9pFcl+4X/rWhX557xA/9FVZ3gv+j5/w9F+jl8g58c0OeQyCdH3HOglETsObxTTw7McwLJClt+wzz5JD45IPEcEHjMEfg0r8M9pQfaOSDs5NLP16tXr15XqzeJD6m5AAwAAA==", "length": 352 } } diff --git a/test/functional/readme/readme.ts b/test/functional/readme/readme.ts index 96f708874..4d532d980 100644 --- a/test/functional/readme/readme.ts +++ b/test/functional/readme/readme.ts @@ -1,8 +1,7 @@ import { DEFAULT_NO_README, HTTP_STATUS } from '../../../src/lib/constants'; - -import pkgReadmeJSON from './pkg-readme.json'; import pkgNoReadmeJSON from './pkg-no-readme.json'; import pkgNoReadmeJSONOldFormat from './pkg-readme-npm6.json'; +import pkgReadmeJSON from './pkg-readme.json'; export default function (server, server2) { describe('should test readme', () => { @@ -23,7 +22,7 @@ export default function (server, server2) { const matchReadme = (serverRef, pkgName = README_PKG1, readmeMessage = README_MESSAGE) => { return serverRef .request({ - uri: `/-/verdaccio/package/readme/${pkgName}` + uri: `/-/verdaccio/package/readme/${pkgName}`, }) .status(HTTP_STATUS.OK) .then(function (body) { diff --git a/test/functional/sanity/incomplete.ts b/test/functional/sanity/incomplete.ts index d3c890e12..0fa3ddfda 100644 --- a/test/functional/sanity/incomplete.ts +++ b/test/functional/sanity/incomplete.ts @@ -9,18 +9,18 @@ const defaultPkg = { version: '0.1.0', dist: { shasum: 'fake', - tarball: `http://${DOMAIN_SERVERS}:${PORT_SERVER_APP}/testexp-incomplete/-/content-length.tar.gz` - } + tarball: `http://${DOMAIN_SERVERS}:${PORT_SERVER_APP}/testexp-incomplete/-/content-length.tar.gz`, + }, }, '0.1.1': { name: 'testexp_tags', version: '0.1.1', dist: { shasum: 'fake', - tarball: `http://${DOMAIN_SERVERS}:${PORT_SERVER_APP}/testexp-incomplete/-/chunked.tar.gz` - } - } - } + tarball: `http://${DOMAIN_SERVERS}:${PORT_SERVER_APP}/testexp-incomplete/-/chunked.tar.gz`, + }, + }, + }, }; export default function (server, express) { diff --git a/test/functional/sanity/mirror.ts b/test/functional/sanity/mirror.ts index f06d5f318..3274ba134 100644 --- a/test/functional/sanity/mirror.ts +++ b/test/functional/sanity/mirror.ts @@ -1,7 +1,7 @@ -import { readFile } from '../lib/test.utils'; import { API_MESSAGE, HTTP_STATUS } from '../../../src/lib/constants'; -import generatePkg from '../fixtures/package'; import { TARBALL } from '../config.functional'; +import generatePkg from '../fixtures/package'; +import { readFile } from '../lib/test.utils'; const getBinary = () => readFile('../fixtures/binary'); @@ -24,10 +24,7 @@ export default function (server, server2) { describe(`testing mirror for ${pkg}`, () => { beforeAll(function () { - return server2 - .putPackage(pkg, generatePkg(pkg)) - .status(HTTP_STATUS.CREATED) - .body_ok(API_MESSAGE.PKG_CREATED); + return server2.putPackage(pkg, generatePkg(pkg)).status(HTTP_STATUS.CREATED).body_ok(API_MESSAGE.PKG_CREATED); }); test(prefix + 'creating new package', () => {}); @@ -48,10 +45,7 @@ export default function (server, server2) { describe('should put a tarball', () => { beforeAll(function () { - return server2 - .putTarball(pkg, TARBALL, getBinary()) - .status(HTTP_STATUS.CREATED) - .body_ok(/.*/); + return server2.putTarball(pkg, TARBALL, getBinary()).status(HTTP_STATUS.CREATED).body_ok(/.*/); }); test(`should ${prefix} uploading new tarball`, () => {}); diff --git a/test/functional/sanity/nullstorage.ts b/test/functional/sanity/nullstorage.ts index 8e510279a..fd9b4f5c1 100644 --- a/test/functional/sanity/nullstorage.ts +++ b/test/functional/sanity/nullstorage.ts @@ -1,9 +1,9 @@ -import { readFile } from '../lib/test.utils'; -import { createTarballHash } from '../../../src/lib/crypto-utils'; import { API_ERROR, HTTP_STATUS } from '../../../src/lib/constants'; +import { DIST_TAGS } from '../../../src/lib/constants'; +import { createTarballHash } from '../../../src/lib/crypto-utils'; import { DOMAIN_SERVERS, PORT_SERVER_1, TARBALL } from '../config.functional'; import generatePkg from '../fixtures/package'; -import { DIST_TAGS } from '../../../src/lib/constants'; +import { readFile } from '../lib/test.utils'; function getBinary() { return readFile('../fixtures/binary'); @@ -17,10 +17,7 @@ export default function (server, server2) { describe('should test a scenario when tarball is being fetch from uplink', () => { describe(`should check whether ${PKG_NAME} is on server1`, () => { test('should fails on fetch non-existent package on server1', () => { - return server - .getPackage('test-nullstorage-nonexist') - .status(HTTP_STATUS.NOT_FOUND) - .body_error(API_ERROR.NO_PACKAGE); + return server.getPackage('test-nullstorage-nonexist').status(HTTP_STATUS.NOT_FOUND).body_error(API_ERROR.NO_PACKAGE); }); }); @@ -42,10 +39,7 @@ export default function (server, server2) { describe(`should succesfully publish ${PKG_NAME} package on server2`, () => { beforeAll(function () { - return server2 - .putTarball(PKG_NAME, TARBALL, getBinary()) - .status(HTTP_STATUS.CREATED) - .body_ok(/.*/); + return server2.putTarball(PKG_NAME, TARBALL, getBinary()).status(HTTP_STATUS.CREATED).body_ok(/.*/); }); beforeAll(function () { @@ -77,9 +71,7 @@ export default function (server, server2) { .then(function (body) { expect(body.name).toBe(PKG_NAME); expect(body.versions[PKG_VERSION].name).toBe(PKG_NAME); - expect(body.versions[PKG_VERSION].dist.tarball).toBe( - `http://${DOMAIN_SERVERS}:${PORT_SERVER_1}/${PKG_NAME}/-/${TARBALL}` - ); + expect(body.versions[PKG_VERSION].dist.tarball).toBe(`http://${DOMAIN_SERVERS}:${PORT_SERVER_1}/${PKG_NAME}/-/${TARBALL}`); expect(body[DIST_TAGS]).toEqual({ latest: PKG_VERSION }); }); }); diff --git a/test/functional/sanity/racycrash.ts b/test/functional/sanity/racycrash.ts index 86a303bd3..eb0d4363a 100644 --- a/test/functional/sanity/racycrash.ts +++ b/test/functional/sanity/racycrash.ts @@ -1,5 +1,5 @@ -import { DOMAIN_SERVERS, PORT_SERVER_APP } from '../config.functional'; import { API_ERROR, HEADER_TYPE, HTTP_STATUS } from '../../../src/lib/constants'; +import { DOMAIN_SERVERS, PORT_SERVER_APP } from '../config.functional'; export default function (server, express) { describe('shoul test for unexpected client hangs', () => { @@ -15,10 +15,10 @@ export default function (server, express) { version: '0.1.0', dist: { shasum: 'fake', - tarball: `http://${DOMAIN_SERVERS}:${PORT_SERVER_APP}/testexp-racycrash/-/test.tar.gz` - } - } - } + tarball: `http://${DOMAIN_SERVERS}:${PORT_SERVER_APP}/testexp-racycrash/-/test.tar.gz`, + }, + }, + }, }); }); @@ -59,9 +59,7 @@ export default function (server, express) { res.socket.destroy(); }; - return server - .request({ uri: '/testexp-racycrash/-/test.tar.gz' }) - .body_error(API_ERROR.INTERNAL_SERVER_ERROR); + return server.request({ uri: '/testexp-racycrash/-/test.tar.gz' }).body_error(API_ERROR.INTERNAL_SERVER_ERROR); }); }); } diff --git a/test/functional/sanity/security.ts b/test/functional/sanity/security.ts index 3552f5239..c2171d5ca 100644 --- a/test/functional/sanity/security.ts +++ b/test/functional/sanity/security.ts @@ -1,6 +1,7 @@ -import { HTTP_STATUS } from '../../../src/lib/constants'; import _ from 'lodash'; +import { HTTP_STATUS } from '../../../src/lib/constants'; + export default function (server) { describe('should test security on endpoints', () => { beforeAll(function () { @@ -39,16 +40,13 @@ export default function (server) { }); test('should fails on fetch silly things - reading #1', () => { - return server - .request({ uri: '/testpkg-sec/-/../../../../../../../../etc/passwd' }) - .status(HTTP_STATUS.NOT_FOUND); + return server.request({ uri: '/testpkg-sec/-/../../../../../../../../etc/passwd' }).status(HTTP_STATUS.NOT_FOUND); }); test('should fails on fetch silly things - reading #2', () => { return server .request({ - uri: - '/testpkg-sec/-/%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2fetc%2fpasswd' + uri: '/testpkg-sec/-/%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2fetc%2fpasswd', }) .status(HTTP_STATUS.FORBIDDEN) .body_error(/invalid filename/); diff --git a/test/functional/scenarios/gh29.ts b/test/functional/scenarios/gh29.ts index 49b5135b6..70d6cb59d 100644 --- a/test/functional/scenarios/gh29.ts +++ b/test/functional/scenarios/gh29.ts @@ -1,8 +1,9 @@ import fs from 'fs'; import path from 'path'; -import { TARBALL } from '../config.functional'; + import { HTTP_STATUS } from '../../../src/lib/constants'; import { createTarballHash } from '../../../src/lib/crypto-utils'; +import { TARBALL } from '../config.functional'; import requirePackage from '../fixtures/package'; function readfile(filePath) { @@ -43,10 +44,7 @@ export default function (server, server2) { describe('tarball', () => { beforeAll(function () { - return server - .putTarball(pkgName, TARBALL, readfile(binary)) - .status(HTTP_STATUS.CREATED) - .body_ok(/.*/); + return server.putTarball(pkgName, TARBALL, readfile(binary)).status(HTTP_STATUS.CREATED).body_ok(/.*/); }); test('uploading new tarball / srv1', () => {}); diff --git a/test/functional/search/search.json b/test/functional/search/search.json index f121ed6af..7449ae781 100644 --- a/test/functional/search/search.json +++ b/test/functional/search/search.json @@ -24,7 +24,7 @@ "_id": "testpkg-search@0.0.1", "dist": { "shasum": "8ee7331cbc641581b1a8cecd9d38d744a8feb863", - "tarball": "http:\/\/localhost:1234\/testpkg-search\/-\/testpkg-search-0.0.1.tgz" + "tarball": "http://localhost:1234/testpkg-search/-/testpkg-search-0.0.1.tgz" }, "_from": ".", "_npmVersion": "1.3.1", @@ -49,8 +49,8 @@ ], "_attachments": { "testpkg-search-0.0.1.tgz": { - "content_type": "application\/octet-stream", - "data": "H4sIAAAAAAAAA+2TsW7CMBCGM\/spTh6YKHUSIJLXqkPnrixWcIMLsS3btCDEu\/fs0Ba1SFVVVISUP8Odzqf\/zlY+K+qlaOSt7eLo2RudnVmMsel4DBjzasKOY1JZlJDlRVkU5aSspnnG8pIVOZ6fe5FTWvsgHK7yV5\/uLvARr0Q7qkUrKadB+mCXzY2Wr9q2TjZ0SF+k88poPGUj\/LAyl752yoauioVWqJgpPZcb\/Hmw0jV4ynfJEw9lvTAwo\/fOGcdBG4h18FbW6knJ+YzCYAByowLkdD+kTlrjVTBumzy2Nq7XqIDea7eKY7FJrMPCuG6Hlaql9rHr4fGO7i\/9pFcl+4X\/rWhX557xA\/9FVZ3gv+j5\/w9F+jl8g58c0OeQyCdH3HOglETsObxTTw7McwLJClt+wzz5JD45IPEcEHjMEfg0r8M9pQfaOSDs5NLP16tXr15XqzeJD6m5AAwAAA==", + "content_type": "application/octet-stream", + "data": "H4sIAAAAAAAAA+2TsW7CMBCGM/spTh6YKHUSIJLXqkPnrixWcIMLsS3btCDEu/fs0Ba1SFVVVISUP8Odzqf/zlY+K+qlaOSt7eLo2RudnVmMsel4DBjzasKOY1JZlJDlRVkU5aSspnnG8pIVOZ6fe5FTWvsgHK7yV5/uLvARr0Q7qkUrKadB+mCXzY2Wr9q2TjZ0SF+k88poPGUj/LAyl752yoauioVWqJgpPZcb/Hmw0jV4ynfJEw9lvTAwo/fOGcdBG4h18FbW6knJ+YzCYAByowLkdD+kTlrjVTBumzy2Nq7XqIDea7eKY7FJrMPCuG6Hlaql9rHr4fGO7i/9pFcl+4X/rWhX557xA/9FVZ3gv+j5/w9F+jl8g58c0OeQyCdH3HOglETsObxTTw7McwLJClt+wzz5JD45IPEcEHjMEfg0r8M9pQfaOSDs5NLP16tXr15XqzeJD6m5AAwAAA==", "length": 352 } } diff --git a/test/functional/search/simple.search.ts b/test/functional/search/simple.search.ts index 6544859aa..3cbc5ce9e 100644 --- a/test/functional/search/simple.search.ts +++ b/test/functional/search/simple.search.ts @@ -6,10 +6,7 @@ export default function (server, server2, express) { const PKG_NAME = 'testpkg-search'; beforeAll(function () { - return server - .putPackage(PKG_NAME, pkgExample) - .status(HTTP_STATUS.CREATED) - .body_ok(API_MESSAGE.PKG_CREATED); + return server.putPackage(PKG_NAME, pkgExample).status(HTTP_STATUS.CREATED).body_ok(API_MESSAGE.PKG_CREATED); }); describe('should test simple search', () => { @@ -21,25 +18,25 @@ export default function (server, server2, express) { author: '', license: 'ISC', 'dist-tags': { - latest: '0.0.1' + latest: '0.0.1', }, maintainers: [ { name: 'alex', - email: 'user@domain.com' - } + email: 'user@domain.com', + }, ], readmeFilename: '', time: { - modified: '2014-10-02T07:07:51.000Z' + modified: '2014-10-02T07:07:51.000Z', }, versions: { - '0.0.1': 'latest' + '0.0.1': 'latest', }, repository: { type: 'git', - url: '' - } + url: '', + }, }); }; diff --git a/test/functional/tags/addtag.ts b/test/functional/tags/addtag.ts index f154b490d..60c17607b 100644 --- a/test/functional/tags/addtag.ts +++ b/test/functional/tags/addtag.ts @@ -1,5 +1,5 @@ -import { readFile } from '../lib/test.utils'; import { API_ERROR, HTTP_STATUS } from '../../../src/lib/constants'; +import { readFile } from '../lib/test.utils'; const readTags = () => readFile('../fixtures/publish.json5'); @@ -9,10 +9,7 @@ export default function (server) { const PKG_VERSION = '0.0.1'; test('should fails on add tag to non existing package', () => { - return server - .addTag(PKG_NAME, 'tagtagtag', PKG_VERSION) - .status(HTTP_STATUS.NOT_FOUND) - .body_error(API_ERROR.NO_PACKAGE); + return server.addTag(PKG_NAME, 'tagtagtag', PKG_VERSION).status(HTTP_STATUS.NOT_FOUND).body_error(API_ERROR.NO_PACKAGE); }); describe('should test add tag to a package', () => { @@ -32,10 +29,7 @@ export default function (server) { describe('should test valid formats tags', () => { test('should fails on add a tag that do not exist', () => { - return server - .addTag(PKG_NAME, 'tagtagtag', '4.0.0-no-exist') - .status(HTTP_STATUS.NOT_FOUND) - .body_error(API_ERROR.VERSION_NOT_EXIST); + return server.addTag(PKG_NAME, 'tagtagtag', '4.0.0-no-exist').status(HTTP_STATUS.NOT_FOUND).body_error(API_ERROR.VERSION_NOT_EXIST); }); test('should add tag succesfully minor version', () => { diff --git a/test/functional/tags/dist-tags-merge.json b/test/functional/tags/dist-tags-merge.json index 88f403f8c..22bbf14e0 100644 --- a/test/functional/tags/dist-tags-merge.json +++ b/test/functional/tags/dist-tags-merge.json @@ -24,7 +24,7 @@ "_id": "testpkg-preserve@0.0.1", "dist": { "shasum": "8ee7331cbc641581b1a8cecd9d38d744a8feb863", - "tarball": "http:\/\/localhost:1234\/testpkg-preserve\/-\/testpkg-preserve-0.0.1.tgz" + "tarball": "http://localhost:1234/testpkg-preserve/-/testpkg-preserve-0.0.1.tgz" }, "_from": ".", "_npmVersion": "1.3.1", @@ -49,8 +49,8 @@ ], "_attachments": { "testpkg-preserve-0.0.1.tgz": { - "content_type": "application\/octet-stream", - "data": "H4sIAAAAAAAAA+2TsW7CMBCGM\/spTh6YKHUSIJLXqkPnrixWcIMLsS3btCDEu\/fs0Ba1SFVVVISUP8Odzqf\/zlY+K+qlaOSt7eLo2RudnVmMsel4DBjzasKOY1JZlJDlRVkU5aSspnnG8pIVOZ6fe5FTWvsgHK7yV5\/uLvARr0Q7qkUrKadB+mCXzY2Wr9q2TjZ0SF+k88poPGUj\/LAyl752yoauioVWqJgpPZcb\/Hmw0jV4ynfJEw9lvTAwo\/fOGcdBG4h18FbW6knJ+YzCYAByowLkdD+kTlrjVTBumzy2Nq7XqIDea7eKY7FJrMPCuG6Hlaql9rHr4fGO7i\/9pFcl+4X\/rWhX557xA\/9FVZ3gv+j5\/w9F+jl8g58c0OeQyCdH3HOglETsObxTTw7McwLJClt+wzz5JD45IPEcEHjMEfg0r8M9pQfaOSDs5NLP16tXr15XqzeJD6m5AAwAAA==", + "content_type": "application/octet-stream", + "data": "H4sIAAAAAAAAA+2TsW7CMBCGM/spTh6YKHUSIJLXqkPnrixWcIMLsS3btCDEu/fs0Ba1SFVVVISUP8Odzqf/zlY+K+qlaOSt7eLo2RudnVmMsel4DBjzasKOY1JZlJDlRVkU5aSspnnG8pIVOZ6fe5FTWvsgHK7yV5/uLvARr0Q7qkUrKadB+mCXzY2Wr9q2TjZ0SF+k88poPGUj/LAyl752yoauioVWqJgpPZcb/Hmw0jV4ynfJEw9lvTAwo/fOGcdBG4h18FbW6knJ+YzCYAByowLkdD+kTlrjVTBumzy2Nq7XqIDea7eKY7FJrMPCuG6Hlaql9rHr4fGO7i/9pFcl+4X/rWhX557xA/9FVZ3gv+j5/w9F+jl8g58c0OeQyCdH3HOglETsObxTTw7McwLJClt+wzz5JD45IPEcEHjMEfg0r8M9pQfaOSDs5NLP16tXr15XqzeJD6m5AAwAAA==", "length": 352 } } diff --git a/test/functional/tags/dist-tags-merge.ts b/test/functional/tags/dist-tags-merge.ts index 4dacb3d06..be1368af5 100644 --- a/test/functional/tags/dist-tags-merge.ts +++ b/test/functional/tags/dist-tags-merge.ts @@ -1,7 +1,7 @@ -import { generateSha } from '../lib/test.utils'; import { API_MESSAGE, HTTP_STATUS } from '../../../src/lib/constants'; -import { DOMAIN_SERVERS, PORT_SERVER_1, PORT_SERVER_2, PORT_SERVER_3 } from '../config.functional'; import { DIST_TAGS } from '../../../src/lib/constants'; +import { DOMAIN_SERVERS, PORT_SERVER_1, PORT_SERVER_2, PORT_SERVER_3 } from '../config.functional'; +import { generateSha } from '../lib/test.utils'; import pkgExample from './dist-tags-merge.json'; export default function (server, server2, server3) { @@ -10,10 +10,7 @@ export default function (server, server2, server3) { const PKG_VERSION = '0.0.1'; beforeAll(function () { - return server - .putPackage(PKG_NAME, pkgExample) - .status(HTTP_STATUS.CREATED) - .body_ok(API_MESSAGE.PKG_CREATED); + return server.putPackage(PKG_NAME, pkgExample).status(HTTP_STATUS.CREATED).body_ok(API_MESSAGE.PKG_CREATED); }); describe('should check sha integrity', () => { @@ -27,10 +24,8 @@ export default function (server, server2, server3) { }); }; - test('server1 should match with sha key from published package', () => - matchTarBallSha(server)); - test('server2 should match with sha key from published package', () => - matchTarBallSha(server2)); + test('server1 should match with sha key from published package', () => matchTarBallSha(server)); + test('server2 should match with sha key from published package', () => matchTarBallSha(server2)); }); describe('should match dist-tags', () => { @@ -44,9 +39,7 @@ export default function (server, server2, server3) { expect(body.time[PKG_VERSION]).toBeDefined(); expect(body.time).toBeDefined(); expect(body.versions[PKG_VERSION].name).toBe(PKG_NAME); - expect(body.versions[PKG_VERSION].dist.tarball).toBe( - `http://${DOMAIN_SERVERS}:${port}/${PKG_NAME}/-/${PKG_NAME}-${PKG_VERSION}.tgz` - ); + expect(body.versions[PKG_VERSION].dist.tarball).toBe(`http://${DOMAIN_SERVERS}:${port}/${PKG_NAME}/-/${PKG_NAME}-${PKG_VERSION}.tgz`); expect(body[DIST_TAGS]).toEqual({ foo: PKG_VERSION, latest: PKG_VERSION }); }); }; diff --git a/test/functional/tags/tags.ts b/test/functional/tags/tags.ts index c0fc88604..edff65fb0 100644 --- a/test/functional/tags/tags.ts +++ b/test/functional/tags/tags.ts @@ -1,7 +1,8 @@ -import { readFile } from '../lib/test.utils'; -import { HTTP_STATUS } from '../../../src/lib/constants'; import _ from 'lodash'; +import { HTTP_STATUS } from '../../../src/lib/constants'; +import { readFile } from '../lib/test.utils'; + const readTags = () => readFile('../fixtures/tags.json'); export default function (server, express) { @@ -70,12 +71,12 @@ export default function (server, express) { return server .request({ method: 'GET', - uri: '/-/package/testexp_tags2/dist-tags' + uri: '/-/package/testexp_tags2/dist-tags', }) .status(200) .then(function (body) { const expected = { - latest: '1.1.0' + latest: '1.1.0', }; expect(body).toEqual(expected); @@ -89,8 +90,8 @@ export default function (server, express) { uri: '/-/package/testexp_tags2/dist-tags', json: { foo: '0.1.2', - quux: '0.1.0' - } + quux: '0.1.0', + }, }) .status(201) .body_ok(/updated/) @@ -98,14 +99,14 @@ export default function (server, express) { return server .request({ method: 'GET', - uri: '/-/package/testexp_tags2/dist-tags' + uri: '/-/package/testexp_tags2/dist-tags', }) .status(200) .then(function (body) { const expected = { latest: '1.1.0', foo: '0.1.2', - quux: '0.1.0' + quux: '0.1.0', }; expect(body).toEqual(expected); @@ -118,7 +119,7 @@ export default function (server, express) { .request({ method: 'PUT', uri: '/-/package/testexp_tags2/dist-tags/foo', - json: '0.1.3alpha' + json: '0.1.3alpha', }) .status(201) .body_ok(/tagged/) @@ -126,14 +127,14 @@ export default function (server, express) { return server .request({ method: 'GET', - uri: '/-/package/testexp_tags2/dist-tags' + uri: '/-/package/testexp_tags2/dist-tags', }) .status(200) .then(function (body) { const expected = { foo: '0.1.3alpha', quux: '0.1.0', - latest: '1.1.0' + latest: '1.1.0', }; expect(body).toEqual(expected); @@ -145,7 +146,7 @@ export default function (server, express) { return server .request({ method: 'DELETE', - uri: '/-/package/testexp_tags2/dist-tags/latest' + uri: '/-/package/testexp_tags2/dist-tags/latest', }) .status(201) .body_ok(/removed/) @@ -153,14 +154,14 @@ export default function (server, express) { return server .request({ method: 'GET', - uri: '/-/package/testexp_tags2/dist-tags' + uri: '/-/package/testexp_tags2/dist-tags', }) .status(200) .then(function (body) { const expected = { latest: '1.1.0', quux: '0.1.0', - foo: '0.1.3alpha' + foo: '0.1.3alpha', }; expect(body).toEqual(expected); @@ -172,7 +173,7 @@ export default function (server, express) { return server .request({ method: 'DELETE', - uri: '/-/package/testexp_tags2/dist-tags/foo' + uri: '/-/package/testexp_tags2/dist-tags/foo', }) .status(201) .body_ok(/removed/) @@ -180,13 +181,13 @@ export default function (server, express) { return server .request({ method: 'GET', - uri: '/-/package/testexp_tags2/dist-tags' + uri: '/-/package/testexp_tags2/dist-tags', }) .status(200) .then(function (body) { const expected = { latest: '1.1.0', - quux: '0.1.0' + quux: '0.1.0', }; expect(body).toEqual(expected); diff --git a/test/functional/teardown.js b/test/functional/teardown.js index e5392aeea..9c56fae71 100644 --- a/test/functional/teardown.js +++ b/test/functional/teardown.js @@ -1,4 +1,4 @@ -module.exports = async function() { +module.exports = async function () { // console.log(green('Teardown Verdaccio Functional')); // console.log(blue('Teardown:: all server were closed')); }; diff --git a/test/functional/test-environment.js b/test/functional/test-environment.js index 4f37edfd8..7a01efc0b 100644 --- a/test/functional/test-environment.js +++ b/test/functional/test-environment.js @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-var-requires */ require('@babel/register')({ - extensions: [".ts", ".js"] + extensions: ['.ts', '.js'], }); module.exports = require('./lib/environment'); diff --git a/test/functional/uplinks/cache.ts b/test/functional/uplinks/cache.ts index bdabae169..b43657f04 100644 --- a/test/functional/uplinks/cache.ts +++ b/test/functional/uplinks/cache.ts @@ -1,11 +1,12 @@ +import crypto from 'crypto'; import fs from 'fs'; import path from 'path'; -import crypto from 'crypto'; -import { readFile } from '../lib/test.utils'; + import { HTTP_STATUS } from '../../../src/lib/constants'; -import { TARBALL } from '../config.functional'; import { createTarballHash } from '../../../src/lib/crypto-utils'; +import { TARBALL } from '../config.functional'; import requirePackage from '../fixtures/package'; +import { readFile } from '../lib/test.utils'; function getBinary() { return readFile('../fixtures/binary'); @@ -29,10 +30,7 @@ export default function (server, server2, server3) { }); beforeAll(function () { - return server - .putTarball(PKG_GH131, TARBALL, getBinary()) - .status(HTTP_STATUS.CREATED) - .body_ok(/.*/); + return server.putTarball(PKG_GH131, TARBALL, getBinary()).status(HTTP_STATUS.CREATED).body_ok(/.*/); }); beforeAll(function () { @@ -62,10 +60,7 @@ export default function (server, server2, server3) { }); beforeAll(function () { - return server2 - .putTarball(PKG_GH1312, TARBALL, getBinary()) - .status(HTTP_STATUS.CREATED) - .body_ok(/.*/); + return server2.putTarball(PKG_GH1312, TARBALL, getBinary()).status(HTTP_STATUS.CREATED).body_ok(/.*/); }); beforeAll(function () { diff --git a/test/jest.config.e2e.js b/test/jest.config.e2e.js index c64b29ebe..4165013b2 100644 --- a/test/jest.config.e2e.js +++ b/test/jest.config.e2e.js @@ -25,5 +25,5 @@ module.exports = { 'functional/store/.*/package.json', '/../build', '/../.vscode/', - ] + ], }; diff --git a/test/jest.config.functional.js b/test/jest.config.functional.js index cf896b04a..9c42538f4 100644 --- a/test/jest.config.functional.js +++ b/test/jest.config.functional.js @@ -27,5 +27,5 @@ module.exports = { '/../build', '/../.vscode/', ], - collectCoverage: false + collectCoverage: false, }; diff --git a/test/lib/request.ts b/test/lib/request.ts index b27fec39c..891957d56 100644 --- a/test/lib/request.ts +++ b/test/lib/request.ts @@ -1,8 +1,9 @@ import assert from 'assert'; -import { IRequestPromise } from '../types'; import _ from 'lodash'; import request from 'request'; +import { IRequestPromise } from '../types'; + const requestData = Symbol('smart_request_data'); export class PromiseAssert extends Promise implements IRequestPromise { diff --git a/test/lib/server.ts b/test/lib/server.ts index af552a5c8..688e945ce 100644 --- a/test/lib/server.ts +++ b/test/lib/server.ts @@ -1,11 +1,12 @@ import assert from 'assert'; -import { IServerBridge } from '../types'; +import _ from 'lodash'; + import { API_MESSAGE, HEADERS, HTTP_STATUS, TOKEN_BASIC } from '../../src/lib/constants'; import { buildToken } from '../../src/lib/utils'; import { CREDENTIALS } from '../functional/config.functional'; import getPackage from '../functional/fixtures/package'; +import { IServerBridge } from '../types'; import smartRequest from './request'; -import _ from 'lodash'; const buildAuthHeader = (user, pass): string => { return buildToken(TOKEN_BASIC, Buffer.from(`${user}:${pass}`).toString('base64')); @@ -35,7 +36,7 @@ export default class Server implements IServerBridge { method: options.method || 'GET', headers: headers, encoding: options.encoding, - json: _.isNil(options.json) === false ? options.json : true + json: _.isNil(options.json) === false ? options.json : true, }); } @@ -51,22 +52,22 @@ export default class Server implements IServerBridge { _id: `org.couchdb.user:${name}`, type: 'user', roles: [], - date: new Date() - } + date: new Date(), + }, }); } public logout(token: string) { return this.request({ uri: `/-/user/token/${encodeURIComponent(token)}`, - method: 'DELETE' + method: 'DELETE', }); } public getPackage(name: string) { return this.request({ uri: `/${encodeURIComponent(name)}`, - method: 'GET' + method: 'GET', }); } @@ -79,8 +80,8 @@ export default class Server implements IServerBridge { uri: `/${encodeURIComponent(name)}`, method: 'PUT', headers: { - [HEADERS.CONTENT_TYPE]: HEADERS.JSON - } + [HEADERS.CONTENT_TYPE]: HEADERS.JSON, + }, }).send(data); } @@ -93,8 +94,8 @@ export default class Server implements IServerBridge { uri: `/${encodeURIComponent(name)}/${encodeURIComponent(version)}/-tag/latest`, method: 'PUT', headers: { - [HEADERS.CONTENT_TYPE]: HEADERS.JSON - } + [HEADERS.CONTENT_TYPE]: HEADERS.JSON, + }, }).send(data); } @@ -102,7 +103,7 @@ export default class Server implements IServerBridge { return this.request({ uri: `/${encodeURIComponent(name)}/-/${encodeURIComponent(filename)}`, method: 'GET', - encoding: null + encoding: null, }); } @@ -111,8 +112,8 @@ export default class Server implements IServerBridge { uri: `/${encodeURIComponent(name)}/-/${encodeURIComponent(filename)}/whatever`, method: 'PUT', headers: { - [HEADERS.CONTENT_TYPE]: HEADERS.OCTET_STREAM - } + [HEADERS.CONTENT_TYPE]: HEADERS.OCTET_STREAM, + }, }).send(data); } @@ -121,8 +122,8 @@ export default class Server implements IServerBridge { uri: `/${encodeURIComponent(name)}/-rev/whatever`, method: 'DELETE', headers: { - [HEADERS.CONTENT_TYPE]: HEADERS.JSON_CHARSET - } + [HEADERS.CONTENT_TYPE]: HEADERS.JSON_CHARSET, + }, }); } @@ -131,8 +132,8 @@ export default class Server implements IServerBridge { uri: `/${encodeURIComponent(name)}/-/${filename}/-rev/whatever`, method: 'DELETE', headers: { - [HEADERS.CONTENT_TYPE]: HEADERS.JSON_CHARSET - } + [HEADERS.CONTENT_TYPE]: HEADERS.JSON_CHARSET, + }, }); } @@ -141,25 +142,20 @@ export default class Server implements IServerBridge { uri: `/${encodeURIComponent(name)}/${encodeURIComponent(tag)}`, method: 'PUT', headers: { - [HEADERS.CONTENT_TYPE]: HEADERS.JSON - } + [HEADERS.CONTENT_TYPE]: HEADERS.JSON, + }, }).send(JSON.stringify(version)); } - public putTarballIncomplete( - pkgName: string, - filename: string, - data: any, - headerContentSize: number - ): Promise { + public putTarballIncomplete(pkgName: string, filename: string, data: any, headerContentSize: number): Promise { let promise = this.request({ uri: `/${encodeURIComponent(pkgName)}/-/${encodeURIComponent(filename)}/whatever`, method: 'PUT', headers: { [HEADERS.CONTENT_TYPE]: HEADERS.OCTET_STREAM, - [HEADERS.CONTENT_LENGTH]: headerContentSize + [HEADERS.CONTENT_LENGTH]: headerContentSize, }, - timeout: 1000 + timeout: 1000, }); promise.request(function (req) { @@ -187,14 +183,12 @@ export default class Server implements IServerBridge { } public addPackage(name: string) { - return this.putPackage(name, getPackage(name)) - .status(HTTP_STATUS.CREATED) - .body_ok(API_MESSAGE.PKG_CREATED); + return this.putPackage(name, getPackage(name)).status(HTTP_STATUS.CREATED).body_ok(API_MESSAGE.PKG_CREATED); } public whoami() { return this.request({ - uri: '/-/whoami' + uri: '/-/whoami', }) .status(HTTP_STATUS.OK) .then(function (body) { @@ -204,7 +198,7 @@ export default class Server implements IServerBridge { public ping() { return this.request({ - uri: '/-/ping' + uri: '/-/ping', }) .status(HTTP_STATUS.OK) .then(function (body) { @@ -217,8 +211,8 @@ export default class Server implements IServerBridge { uri: '/-/_debug', method: 'GET', headers: { - [HEADERS.CONTENT_TYPE]: HEADERS.JSON - } + [HEADERS.CONTENT_TYPE]: HEADERS.JSON, + }, }); } } diff --git a/test/lib/server_process.ts b/test/lib/server_process.ts index 97eddbb62..0718f1ddf 100644 --- a/test/lib/server_process.ts +++ b/test/lib/server_process.ts @@ -1,10 +1,11 @@ -import path from 'path'; import { fork } from 'child_process'; -import { CREDENTIALS } from '../functional/config.functional'; -import { HTTP_STATUS } from '../../src/lib/constants'; -import { IVerdaccioConfig, IServerBridge, IServerProcess } from '../types'; -import rimRaf from 'rimraf'; import _ from 'lodash'; +import path from 'path'; +import rimRaf from 'rimraf'; + +import { HTTP_STATUS } from '../../src/lib/constants'; +import { CREDENTIALS } from '../functional/config.functional'; +import { IServerBridge, IServerProcess, IVerdaccioConfig } from '../types'; export default class VerdaccioProcess implements IServerProcess { private bridge: IServerBridge; @@ -14,13 +15,7 @@ export default class VerdaccioProcess implements IServerProcess { private silence: boolean; private cleanStore: boolean; - public constructor( - config: IVerdaccioConfig, - bridge: IServerBridge, - silence = true, - isDebug = false, - cleanStore = true - ) { + public constructor(config: IVerdaccioConfig, bridge: IServerBridge, silence = true, isDebug = false, cleanStore = true) { this.config = config; this.bridge = bridge; this.silence = silence; @@ -47,7 +42,7 @@ export default class VerdaccioProcess implements IServerProcess { private _start(verdaccioPath: string, resolve: Function, reject: Function) { const verdaccioRegisterWrap: string = path.join(__dirname, verdaccioPath); let childOptions = { - silent: true + silent: true, }; if (this.isDebug) { @@ -55,16 +50,12 @@ export default class VerdaccioProcess implements IServerProcess { const debugPort = parseInt(this.config.port, 10) + 5; childOptions = Object.assign({}, childOptions, { - execArgv: [`--inspect=${debugPort}`] + execArgv: [`--inspect=${debugPort}`], }); } const { configPath, port } = this.config; - this.childFork = fork( - verdaccioRegisterWrap, - ['-c', configPath, '-l', port as string], - childOptions - ); + this.childFork = fork(verdaccioRegisterWrap, ['-c', configPath, '-l', port as string], childOptions); this.childFork.on('message', (msg) => { // verdaccio_started is a message that comes from verdaccio in debug mode that notify has been started diff --git a/test/lib/utils-test.ts b/test/lib/utils-test.ts index 831da540d..a40a39296 100644 --- a/test/lib/utils-test.ts +++ b/test/lib/utils-test.ts @@ -1,10 +1,6 @@ import { Version } from '@verdaccio/types'; -export function generateNewVersion( - pkgName: string, - version: string, - shashum = '238e7641e59508dc9c20eb4ad37a8aa57ab777b4' -): Version { +export function generateNewVersion(pkgName: string, version: string, shashum = '238e7641e59508dc9c20eb4ad37a8aa57ab777b4'): Version { // $FlowFixMe return { name: pkgName, @@ -12,7 +8,7 @@ export function generateNewVersion( description: '', main: 'index.js', dependencies: { - test: '^1.4.1' + test: '^1.4.1', }, author: '', license: 'ISC', @@ -20,13 +16,12 @@ export function generateNewVersion( _id: `${pkgName}@${version}`, _npmVersion: '5.5.1', _npmUser: { - name: 'Foo' + name: 'Foo', }, dist: { - integrity: - 'sha512-zVEqt1JUCOPsash9q4wMkJEDPD+QCx95TRhQII+JnoS31uBUKoZxhzvvUJCcLVy2CQG4QdwXARU7dYWPnrwhGg==', + integrity: 'sha512-zVEqt1JUCOPsash9q4wMkJEDPD+QCx95TRhQII+JnoS31uBUKoZxhzvvUJCcLVy2CQG4QdwXARU7dYWPnrwhGg==', shasum: shashum, - tarball: `http:\/\/localhost:4873\/${pkgName}\/-\/${pkgName}-${version}.tgz` - } + tarball: `http:\/\/localhost:4873\/${pkgName}\/-\/${pkgName}-${version}.tgz`, + }, }; } diff --git a/test/types-test/README.md b/test/types-test/README.md index e131b4a15..66149bfe2 100644 --- a/test/types-test/README.md +++ b/test/types-test/README.md @@ -4,4 +4,4 @@ This folder is intended to check whether any type update might break plugin impl ## Contribute -- Add more scenarios, middleware, plugins, filters etc. \ No newline at end of file +- Add more scenarios, middleware, plugins, filters etc. diff --git a/test/types-test/plugins/auth/example.auth.plugin.ts b/test/types-test/plugins/auth/example.auth.plugin.ts index b7fcb983a..e0944b9c4 100644 --- a/test/types-test/plugins/auth/example.auth.plugin.ts +++ b/test/types-test/plugins/auth/example.auth.plugin.ts @@ -1,17 +1,9 @@ // this file is not aim to be tested, just to check flow definitions +import { Callback } from '@verdaccio/types'; +import { Config as AppConfig, IPluginAuth, Logger, PackageAccess, PluginOptions, RemoteUser } from '@verdaccio/types'; import Config from '../../../../src/lib/config'; import { logger } from '../../../../src/lib/logger'; -import { Callback } from '@verdaccio/types'; -import { - Config as AppConfig, - PackageAccess, - IPluginAuth, - RemoteUser, - Logger, - PluginOptions -} from '@verdaccio/types'; - class ExampleAuthPlugin implements IPluginAuth<{}> { config: AppConfig; @@ -22,7 +14,8 @@ class ExampleAuthPlugin implements IPluginAuth<{}> { this.logger = options.logger; } - adduser(user: string, password: string, cb: Callback): void { // pragma: allowlist secret + adduser(user: string, password: string, cb: Callback): void { + // pragma: allowlist secret cb(); } @@ -30,7 +23,8 @@ class ExampleAuthPlugin implements IPluginAuth<{}> { cb(); } - authenticate(user: string, password: string, cb: Callback): void { // pragma: allowlist secret + authenticate(user: string, password: string, cb: Callback): void { + // pragma: allowlist secret cb(); } @@ -79,12 +73,12 @@ class ExampleAuthCustomPlugin implements IPluginAuth<{}> { const config1: AppConfig = new Config({ storage: './storage', - self_path: '/home/sotrage' + self_path: '/home/sotrage', }); const options: PluginOptions<{}> = { config: config1, - logger: logger.child({sub: 'out'}) + logger: logger.child({ sub: 'out' }), }; const auth = new ExampleAuthPlugin(config1, options); @@ -92,7 +86,7 @@ const authSub = new ExampleAuthCustomPlugin(config1, options); const remoteUser: RemoteUser = { groups: [], real_groups: [], - name: 'test' + name: 'test', }; auth.authenticate('user', 'pass', () => {}); diff --git a/test/types-test/plugins/middleware/example.middleware.plugin.ts b/test/types-test/plugins/middleware/example.middleware.plugin.ts index da76132ee..6a74f59b0 100644 --- a/test/types-test/plugins/middleware/example.middleware.plugin.ts +++ b/test/types-test/plugins/middleware/example.middleware.plugin.ts @@ -1,30 +1,25 @@ // this file is not aim to be tested, just to check typescript definitions + /* eslint-disable @typescript-eslint/no-unused-vars */ + /* eslint-disable no-unused-vars */ -import { IUploadTarball, IReadTarball } from '@verdaccio/streams'; -import { - Config as AppConfig, - IPluginMiddleware, - IStorageManager, - RemoteUser, - IBasicAuth -} from '@verdaccio/types'; +import { IReadTarball, IUploadTarball } from '@verdaccio/streams'; +import { Config as AppConfig, IBasicAuth, IPluginMiddleware, IStorageManager, RemoteUser } from '@verdaccio/types'; import { Package } from '@verdaccio/types'; import Config from '../../../../src/lib/config'; import { generatePackageTemplate } from '../../../../src/lib/storage-utils'; import { readFile } from '../../../functional/lib/test.utils'; - -const readMetadata = (fileName: string): Package => - JSON.parse(readFile(`../../unit/partials/${fileName}`).toString()) as Package; - import { generateVersion } from '../../../unit/__helper/utils'; + +const readMetadata = (fileName: string): Package => JSON.parse(readFile(`../../unit/partials/${fileName}`).toString()) as Package; + export default class ExampleMiddlewarePlugin implements IPluginMiddleware<{}> { register_middlewares(app: any, auth: IBasicAuth<{}>, storage: IStorageManager<{}>): void { const remoteUser: RemoteUser = { groups: [], real_groups: [], - name: 'test' + name: 'test', }; auth.authenticate('user', 'password', () => {}); auth.allow_access({ packageName: 'packageName' }, remoteUser, () => {}); @@ -40,7 +35,7 @@ export default class ExampleMiddlewarePlugin implements IPluginMiddleware<{}> { storage.removeTarball('name', 'filename', 'revision', () => {}); const config1: AppConfig = new Config({ storage: './storage', - self_path: '/home/sotrage' + self_path: '/home/sotrage', }); const add: IUploadTarball = storage.addTarball('name', 'filename'); storage.getTarball('name', 'filename'); diff --git a/test/types-test/plugins/storage/example.storage.plugin.ts b/test/types-test/plugins/storage/example.storage.plugin.ts index 7df70f83d..85d6d4ed5 100644 --- a/test/types-test/plugins/storage/example.storage.plugin.ts +++ b/test/types-test/plugins/storage/example.storage.plugin.ts @@ -1,22 +1,11 @@ // this file is not aim to be tested, just to check typescript definitions +import { ReadTarball, UploadTarball } from '@verdaccio/streams'; +import { Config as AppConfig, Callback, IReadTarball, IUploadTarball, Logger, Package, Token, TokenFilter } from '@verdaccio/types'; +import { IPackageStorage, IPackageStorageManager, IPluginStorage } from '@verdaccio/types'; import Config from '../../../../src/lib/config'; import { logger } from '../../../../src/lib/logger'; import { generatePackageTemplate } from '../../../../src/lib/storage-utils'; -import { - Callback, - Config as AppConfig, - Logger, - Package, - Token, - TokenFilter, - IUploadTarball, - IReadTarball -} from '@verdaccio/types'; - -import { IPluginStorage, IPackageStorageManager, IPackageStorage } from '@verdaccio/types'; -import { UploadTarball, ReadTarball } from '@verdaccio/streams'; - class PackageStorage implements IPackageStorageManager { path: string; @@ -27,13 +16,7 @@ class PackageStorage implements IPackageStorageManager { this.logger = logger; } - updatePackage( - name: string, - updateHandler: Callback, - onWrite: Callback, - transformPackage: Function, - onEnd: Callback - ) { + updatePackage(name: string, updateHandler: Callback, onWrite: Callback, transformPackage: Function, onEnd: Callback) { onEnd(); } @@ -106,7 +89,7 @@ class ExampleStoragePlugin implements IPluginStorage<{}> { key: '12312', token: '12321', // pragma: allowlist secret readonly: false, - created: '123232' + created: '123232', }; return Promise.resolve([token, token]); @@ -146,7 +129,7 @@ export default ExampleStoragePlugin; const config1: AppConfig = new Config({ storage: './storage', - self_path: '/home/sotrage' + self_path: '/home/sotrage', }); const storage = new ExampleStoragePlugin(config1, logger.child()); diff --git a/test/types/index.ts b/test/types/index.ts index 9985e2726..b13044894 100644 --- a/test/types/index.ts +++ b/test/types/index.ts @@ -40,13 +40,7 @@ export interface IServerBridge { removeTarball(name: string): Promise; removeSingleTarball(name: string, filename: string): Promise; addTag(name: string, tag: string, version: string): Promise; - putTarballIncomplete( - name: string, - filename: string, - data: any, - size: number, - cb: Function - ): Promise; + putTarballIncomplete(name: string, filename: string, data: any, size: number, cb: Function): Promise; addPackage(name: string): Promise; whoami(): Promise; ping(): Promise; diff --git a/test/unit/__helper/api.ts b/test/unit/__helper/api.ts index 132336a13..d31f177ce 100644 --- a/test/unit/__helper/api.ts +++ b/test/unit/__helper/api.ts @@ -1,11 +1,12 @@ - -import { HEADER_TYPE, HEADERS, HTTP_STATUS, TOKEN_BEARER } from '../../../src/lib/constants'; -import { buildToken, encodeScopedUri } from '../../../src/lib/utils'; -import { generateRandomHexString } from '../../../src/lib/crypto-utils'; -import { getTaggedVersionFromPackage } from './expects'; -import { Package } from '@verdaccio/types'; -import request from 'supertest'; import _ from 'lodash'; +import request from 'supertest'; + +import { Package } from '@verdaccio/types'; + +import { HEADERS, HEADER_TYPE, HTTP_STATUS, TOKEN_BEARER } from '../../../src/lib/constants'; +import { generateRandomHexString } from '../../../src/lib/crypto-utils'; +import { buildToken, encodeScopedUri } from '../../../src/lib/utils'; +import { getTaggedVersionFromPackage } from './expects'; // API Helpers @@ -15,17 +16,9 @@ import _ from 'lodash'; // - Encourage using constants or create new ones if it's needed // - // @ts-ignore or any is fine if there is no other way -export function putPackage( - request: any, - pkgName: string, - publishMetadata: Package, - token?: string -): Promise { +export function putPackage(request: any, pkgName: string, publishMetadata: Package, token?: string): Promise { return new Promise((resolve) => { - let put = request - .put(pkgName) - .set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON) - .send(JSON.stringify(publishMetadata)); + let put = request.put(pkgName).set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON).send(JSON.stringify(publishMetadata)); if (_.isEmpty(token) === false) { expect(token).toBeDefined(); @@ -44,9 +37,7 @@ export function putPackage( export function deletePackage(request: any, pkgName: string, token?: string): Promise { return new Promise((resolve) => { - let del = request - .put(`/${encodeScopedUri(pkgName)}/-rev/${generateRandomHexString(8)}`) - .set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON); + let del = request.put(`/${encodeScopedUri(pkgName)}/-rev/${generateRandomHexString(8)}`).set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON); if (_.isNil(token) === false) { del.set(HEADERS.AUTHORIZATION, buildToken(TOKEN_BEARER, token as string)); @@ -61,12 +52,7 @@ export function deletePackage(request: any, pkgName: string, token?: string): Pr }); } -export function getPackage( - request: any, - token: string, - pkgName: string, - statusCode: number = HTTP_STATUS.OK -): Promise { +export function getPackage(request: any, token: string, pkgName: string, statusCode: number = HTTP_STATUS.OK): Promise { return new Promise((resolve) => { let getRequest = request.get(`/${pkgName}`); @@ -84,13 +70,7 @@ export function getPackage( }); } -export function loginUserToken( - request: any, - user: string, - credentials: any, - token: string, - statusCode: number = HTTP_STATUS.CREATED -): Promise { +export function loginUserToken(request: any, user: string, credentials: any, token: string, statusCode: number = HTTP_STATUS.CREATED): Promise { // $FlowFixMe return new Promise((resolve) => { request @@ -105,12 +85,7 @@ export function loginUserToken( }); } -export function addUser( - request: any, - user: string, - credentials: any, - statusCode: number = HTTP_STATUS.CREATED -): Promise { +export function addUser(request: any, user: string, credentials: any, statusCode: number = HTTP_STATUS.CREATED): Promise { // $FlowFixMe return new Promise((resolve) => { request @@ -137,11 +112,7 @@ export async function getNewToken(request: any, credentials: any): Promise { +export function getProfile(request: any, token: string, statusCode: number = HTTP_STATUS.OK): Promise { // $FlowFixMe return new Promise((resolve) => { request @@ -155,12 +126,7 @@ export function getProfile( }); } -export function postProfile( - request: any, - body: any, - token: string, - statusCode: number = HTTP_STATUS.OK -): Promise { +export function postProfile(request: any, body: any, token: string, statusCode: number = HTTP_STATUS.OK): Promise { // $FlowFixMe return new Promise((resolve) => { request @@ -175,13 +141,7 @@ export function postProfile( }); } -export async function fetchPackageByVersionAndTag( - app, - encodedPkgName, - pkgName, - version, - tag = 'latest' -) { +export async function fetchPackageByVersionAndTag(app, encodedPkgName, pkgName, version, tag = 'latest') { // we retrieve the package to verify const [err, resp] = await getPackage(request(app), '', encodedPkgName); @@ -198,12 +158,7 @@ export async function isExistPackage(app, packageName) { } export async function verifyPackageVersionDoesExist(app, packageName, version, token?: string) { - const [, res] = await getPackage( - request(app), - token as string, - encodeScopedUri(packageName), - HTTP_STATUS.OK - ); + const [, res] = await getPackage(request(app), token as string, encodeScopedUri(packageName), HTTP_STATUS.OK); const { versions } = res.body; const versionsKeys = Object.keys(versions); diff --git a/test/unit/__helper/mock.ts b/test/unit/__helper/mock.ts index 705c72e90..044a82485 100644 --- a/test/unit/__helper/mock.ts +++ b/test/unit/__helper/mock.ts @@ -1,8 +1,9 @@ import path from 'path'; + import { DOMAIN_SERVERS } from '../../functional/config.functional'; +import Server from '../../lib/server'; import VerdaccioProcess from '../../lib/server_process'; import { VerdaccioConfig } from '../../lib/verdaccio-server'; -import Server from '../../lib/server'; import { IServerBridge } from '../../types'; /** @@ -53,12 +54,7 @@ export function mockServer(port: number) { const storePath = path.join(pathStore, '/mock-store'); const configPath = path.join(pathStore, '/config-unit-mock-server-test.yaml'); - const verdaccioConfig = new VerdaccioConfig( - storePath, - configPath, - `http://${DOMAIN_SERVERS}:${port}/`, - port - ); + const verdaccioConfig = new VerdaccioConfig(storePath, configPath, `http://${DOMAIN_SERVERS}:${port}/`, port); const server: IServerBridge = new Server(verdaccioConfig.domainPath); diff --git a/test/unit/__helper/utils.ts b/test/unit/__helper/utils.ts index bb7d74ba3..9f1e83c3e 100644 --- a/test/unit/__helper/utils.ts +++ b/test/unit/__helper/utils.ts @@ -1,13 +1,11 @@ /* eslint-disable max-len */ - import { Package } from '@verdaccio/types'; export function generateAttachment() { return { content_type: 'application/octet-stream', - data: - 'H4sIAAAAAAAAE+2W32vbMBDH85y/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo//79KPeQsnIw5KUDX/9IOvurLuz/DHSjK/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS/pLQe+D+FIv/agIWI6GX66kFuIhT+1gDjrp/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi/IHpU9fz3/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6/f88f/Pu47zomiPk2Lv/dOv8h+P/34/D/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=', - length: 512 + data: 'H4sIAAAAAAAAE+2W32vbMBDH85y/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo//79KPeQsnIw5KUDX/9IOvurLuz/DHSjK/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS/pLQe+D+FIv/agIWI6GX66kFuIhT+1gDjrp/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi/IHpU9fz3/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6/f88f/Pu47zomiPk2Lv/dOv8h+P/34/D/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=', + length: 512, }; } @@ -18,30 +16,29 @@ export function generateVersion(pkgName, version) { description: 'some foo dependency', main: 'index.js', scripts: { - test: 'echo "Error: no test specified" && exit 1' + test: 'echo "Error: no test specified" && exit 1', }, keywords: [], author: { name: 'User NPM', - email: 'user@domain.com' + email: 'user@domain.com', }, license: 'ISC', dependencies: { - verdaccio: '^4.0.0' + verdaccio: '^4.0.0', }, readme: '# test', readmeFilename: 'README.md', _id: `${pkgName}@${version}`, _npmVersion: '5.5.1', _npmUser: { - name: 'foo' + name: 'foo', }, dist: { - integrity: - 'sha512-6gHiERpiDgtb3hjqpQH5/i7zRmvYi9pmCjQf2ZMy3QEa9wVk9RgdZaPWUt7ZOnWUPFjcr9cmE6dUBf+XoPoH4g==', + integrity: 'sha512-6gHiERpiDgtb3hjqpQH5/i7zRmvYi9pmCjQf2ZMy3QEa9wVk9RgdZaPWUt7ZOnWUPFjcr9cmE6dUBf+XoPoH4g==', shasum: '2c03764f651a9f016ca0b7620421457b619151b9', // pragma: allowlist secret - tarball: `http:\/\/localhost:5555\/${pkgName}\/-\/${pkgName}-${version}.tgz` - } + tarball: `http:\/\/localhost:5555\/${pkgName}\/-\/${pkgName}-${version}.tgz`, + }, }; } @@ -68,10 +65,10 @@ export function generatePackageBody(pkgName: string, _versions: string[] = ['1.0 name: pkgName, readme: '# test', 'dist-tags': { - latest: latest + latest: latest, }, versions: versions, - _attachments: attachtment + _attachments: attachtment, }; } @@ -81,10 +78,7 @@ export function generatePackageBody(pkgName: string, _versions: string[] = ['1.0 * @param pkgName * @param _versions */ -export function generatePackageUnpublish( - pkgName: string, - _versions: string[] = ['1.0.0'] -): Package { +export function generatePackageUnpublish(pkgName: string, _versions: string[] = ['1.0.0']): Package { const latest: string = _versions[_versions.length - 1]; const versions = _versions.reduce((cat, version) => { cat[version] = generateVersion(pkgName, version); @@ -99,9 +93,9 @@ export function generatePackageUnpublish( // users usually is present when run npm star [pkg] users: {}, 'dist-tags': { - latest: latest + latest: latest, }, - versions: versions + versions: versions, }; } @@ -109,7 +103,7 @@ export function generateStarMedatada(pkgName: string, users): any { return { _id: pkgName, _rev: '3-b0cdaefc9bdb77c8', - users: users + users: users, }; } @@ -119,7 +113,7 @@ export function generatePackageMetadata(pkgName: string, version = '1.0.0'): Pac _id: pkgName, name: pkgName, 'dist-tags': { - latest: version + latest: version, }, versions: { [version]: { @@ -128,52 +122,46 @@ export function generatePackageMetadata(pkgName: string, version = '1.0.0'): Pac description: '', main: 'index.js', scripts: { - test: 'echo "Error: no test specified" && exit 1' + test: 'echo "Error: no test specified" && exit 1', }, keywords: [], author: { name: 'User NPM', - email: 'user@domain.com' + email: 'user@domain.com', }, license: 'ISC', dependencies: { - verdaccio: '^2.7.2' + verdaccio: '^2.7.2', }, readme: '# test', readmeFilename: 'README.md', _id: `${pkgName}@${version}`, _npmVersion: '5.5.1', _npmUser: { - name: 'foo' + name: 'foo', }, dist: { - integrity: - 'sha512-6gHiERpiDgtb3hjqpQH5/i7zRmvYi9pmCjQf2ZMy3QEa9wVk9RgdZaPWUt7ZOnWUPFjcr9cmE6dUBf+XoPoH4g==', + integrity: 'sha512-6gHiERpiDgtb3hjqpQH5/i7zRmvYi9pmCjQf2ZMy3QEa9wVk9RgdZaPWUt7ZOnWUPFjcr9cmE6dUBf+XoPoH4g==', shasum: '2c03764f651a9f016ca0b7620421457b619151b9', // pragma: allowlist secret - tarball: `http:\/\/localhost:5555\/${pkgName}\/-\/${pkgName}-${version}.tgz` - } - } + tarball: `http:\/\/localhost:5555\/${pkgName}\/-\/${pkgName}-${version}.tgz`, + }, + }, }, readme: '# test', _attachments: { [`${pkgName}-${version}.tgz`]: { content_type: 'application/octet-stream', - data: - 'H4sIAAAAAAAAE+2W32vbMBDH85y/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo//79KPeQsnIw5KUDX/9IOvurLuz/DHSjK/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS/pLQe+D+FIv/agIWI6GX66kFuIhT+1gDjrp/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi/IHpU9fz3/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6/f88f/Pu47zomiPk2Lv/dOv8h+P/34/D/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=', - length: 512 - } - } + data: 'H4sIAAAAAAAAE+2W32vbMBDH85y/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo//79KPeQsnIw5KUDX/9IOvurLuz/DHSjK/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS/pLQe+D+FIv/agIWI6GX66kFuIhT+1gDjrp/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi/IHpU9fz3/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6/f88f/Pu47zomiPk2Lv/dOv8h+P/34/D/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=', + length: 512, + }, + }, }; } -export function generateDeprecateMetadata( - pkgName: string, - version = '1.0.0', - deprecated: string = '' -): Package { +export function generateDeprecateMetadata(pkgName: string, version = '1.0.0', deprecated: string = ''): Package { const res = { ...generatePackageMetadata(pkgName, version), - _attachments: {} + _attachments: {}, }; res.versions[version].deprecated = deprecated; return res; diff --git a/test/unit/functionalLibs/request.spec.ts b/test/unit/functionalLibs/request.spec.ts index 1f6e98d98..6d0997524 100644 --- a/test/unit/functionalLibs/request.spec.ts +++ b/test/unit/functionalLibs/request.spec.ts @@ -1,10 +1,12 @@ -import smartRequest, { PromiseAssert } from '../../lib/request'; -import { mockServer } from '../__helper/mock'; -import { HTTP_STATUS } from '../../../src/lib/constants'; -import { IRequestPromise } from '../../types'; -import { VerdaccioError } from '@verdaccio/commons-api'; import _ from 'lodash'; +import { VerdaccioError } from '@verdaccio/commons-api'; + +import { HTTP_STATUS } from '../../../src/lib/constants'; +import smartRequest, { PromiseAssert } from '../../lib/request'; +import { IRequestPromise } from '../../types'; +import { mockServer } from '../__helper/mock'; + describe('Request Functional', () => { jest.setTimeout(20000); const mockServerPort = 55547; @@ -40,7 +42,7 @@ describe('Request Functional', () => { test('basic rest', (done) => { const options: any = { url: restTest, - method: 'GET' + method: 'GET', }; smartRequest(options).then((result) => { @@ -53,7 +55,7 @@ describe('Request Functional', () => { test('basic check status 200', (done) => { const options: any = { url: restTest, - method: 'GET' + method: 'GET', }; // @ts-ignore smartRequest(options) @@ -68,7 +70,7 @@ describe('Request Functional', () => { test('basic check status 404', (done) => { const options: any = { url: 'http://www.google.fake', - method: 'GET' + method: 'GET', }; // @ts-ignore smartRequest(options) diff --git a/test/unit/modules/access/pkg.access.spec.ts b/test/unit/modules/access/pkg.access.spec.ts index d1e3655fb..f32fcf791 100644 --- a/test/unit/modules/access/pkg.access.spec.ts +++ b/test/unit/modules/access/pkg.access.spec.ts @@ -1,17 +1,16 @@ import path from 'path'; -import request from 'supertest'; import rimraf from 'rimraf'; +import request from 'supertest'; +import endPointAPI from '../../../../src/api'; +import { HEADERS, HTTP_STATUS } from '../../../../src/lib/constants'; import { setup } from '../../../../src/lib/logger'; +import { DOMAIN_SERVERS } from '../../../functional/config.functional'; +import { mockServer } from '../../__helper/mock'; +import configDefault from '../../partials/config'; setup([]); -import { HEADERS, HTTP_STATUS } from '../../../../src/lib/constants'; -import configDefault from '../../partials/config'; -import endPointAPI from '../../../../src/api'; -import { mockServer } from '../../__helper/mock'; -import { DOMAIN_SERVERS } from '../../../functional/config.functional'; - require('../../../../src/lib/logger').setup([]); describe('api with no limited access configuration', () => { @@ -28,16 +27,16 @@ describe('api with no limited access configuration', () => { { auth: { htpasswd: { - file: './access-storage/htpasswd-pkg-access' - } + file: './access-storage/htpasswd-pkg-access', + }, }, self_path: store, uplinks: { remote: { - url: `http://${DOMAIN_SERVERS}:${mockServerPort}` - } + url: `http://${DOMAIN_SERVERS}:${mockServerPort}`, + }, }, - logs: [{ type: 'stdout', format: 'pretty', level: 'warn' }] + logs: [{ type: 'stdout', format: 'pretty', level: 'warn' }], }, 'pkg.access.spec.yaml' ); diff --git a/test/unit/modules/api/api.search.spec.ts b/test/unit/modules/api/api.search.spec.ts index 83314d7a8..0f45af9c4 100644 --- a/test/unit/modules/api/api.search.spec.ts +++ b/test/unit/modules/api/api.search.spec.ts @@ -1,20 +1,19 @@ +import _ from 'lodash'; +import nock from 'nock'; import path from 'path'; +import rimraf from 'rimraf'; import { Readable } from 'stream'; +import request from 'supertest'; +import endPointAPI from '../../../../src/api'; +import { API_ERROR, API_MESSAGE, HEADERS, HEADER_TYPE, HTTP_STATUS, TOKEN_BEARER } from '../../../../src/lib/constants'; +import { buildToken, encodeScopedUri } from '../../../../src/lib/utils'; +import { DOMAIN_SERVERS } from '../../../functional/config.functional'; +import { generateUnPublishURI, getNewToken, getPackage, putPackage, verifyPackageVersionDoesExist } from '../../__helper/api'; +import { mockServer } from '../../__helper/mock'; +import { generateDeprecateMetadata, generatePackageMetadata, generatePackageUnpublish, generateStarMedatada, generateVersion } from '../../__helper/utils'; import configDefault from '../../partials/config'; import publishMetadata from '../../partials/publish-api'; -import endPointAPI from '../../../../src/api'; - -import { HEADERS, API_ERROR, HTTP_STATUS, HEADER_TYPE, API_MESSAGE, TOKEN_BEARER } from '../../../../src/lib/constants'; -import { mockServer } from '../../__helper/mock'; -import { DOMAIN_SERVERS } from '../../../functional/config.functional'; -import { buildToken, encodeScopedUri } from '../../../../src/lib/utils'; -import { getNewToken, getPackage, putPackage, verifyPackageVersionDoesExist, generateUnPublishURI } from '../../__helper/api'; -import { generatePackageMetadata, generatePackageUnpublish, generateStarMedatada, generateDeprecateMetadata, generateVersion } from '../../__helper/utils'; -import nock from 'nock'; -import rimraf from 'rimraf'; -import _ from 'lodash'; -import request from 'supertest'; const sleep = (delay) => { return new Promise((resolve) => { diff --git a/test/unit/modules/api/api.spec.ts b/test/unit/modules/api/api.spec.ts index e3b4aef5f..1d156e007 100644 --- a/test/unit/modules/api/api.spec.ts +++ b/test/unit/modules/api/api.spec.ts @@ -1,20 +1,19 @@ +import _ from 'lodash'; +import nock from 'nock'; import path from 'path'; +import rimraf from 'rimraf'; import { Readable } from 'stream'; +import request from 'supertest'; +import endPointAPI from '../../../../src/api'; +import { API_ERROR, API_MESSAGE, HEADERS, HEADER_TYPE, HTTP_STATUS, TOKEN_BEARER } from '../../../../src/lib/constants'; +import { buildToken, encodeScopedUri } from '../../../../src/lib/utils'; +import { DOMAIN_SERVERS } from '../../../functional/config.functional'; +import { generateUnPublishURI, getNewToken, getPackage, putPackage, verifyPackageVersionDoesExist } from '../../__helper/api'; +import { mockServer } from '../../__helper/mock'; +import { generateDeprecateMetadata, generatePackageMetadata, generatePackageUnpublish, generateStarMedatada, generateVersion } from '../../__helper/utils'; import configDefault from '../../partials/config'; import publishMetadata from '../../partials/publish-api'; -import endPointAPI from '../../../../src/api'; - -import { HEADERS, API_ERROR, HTTP_STATUS, HEADER_TYPE, API_MESSAGE, TOKEN_BEARER } from '../../../../src/lib/constants'; -import { mockServer } from '../../__helper/mock'; -import { DOMAIN_SERVERS } from '../../../functional/config.functional'; -import { buildToken, encodeScopedUri } from '../../../../src/lib/utils'; -import { getNewToken, getPackage, putPackage, verifyPackageVersionDoesExist, generateUnPublishURI } from '../../__helper/api'; -import { generatePackageMetadata, generatePackageUnpublish, generateStarMedatada, generateDeprecateMetadata, generateVersion } from '../../__helper/utils'; -import nock from 'nock'; -import rimraf from 'rimraf'; -import _ from 'lodash'; -import request from 'supertest'; const sleep = (delay) => { return new Promise((resolve) => { diff --git a/test/unit/modules/api/partials/search-all.json b/test/unit/modules/api/partials/search-all.json index 2e94e6f89..f39dc38f0 100644 --- a/test/unit/modules/api/partials/search-all.json +++ b/test/unit/modules/api/partials/search-all.json @@ -1,1539 +1,1539 @@ [ { - "name": "verdaccio", - "description": "A lightweight private npm proxy registry", - "dist-tags": [], - "maintainers": [ - { - "name": "jotadeveloper" - }, - { - "name": "ayusharma" - }, - { - "name": "trentearl" - }, - { - "name": "jmwilkinson" - }, - { - "name": "sergiohgz" - }, - { - "name": "verdaccio.npm" - } - ], - "author": { - "name": "Verdaccio Maintainers", - "email": "verdaccio.npm@gmail.com", - "username": "verdaccio.npm" + "name": "verdaccio", + "description": "A lightweight private npm proxy registry", + "dist-tags": [], + "maintainers": [ + { + "name": "jotadeveloper" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-04-28T05:24:23.696Z" + { + "name": "ayusharma" }, - "versions": { - "5.0.4": "latest" + { + "name": "trentearl" + }, + { + "name": "jmwilkinson" + }, + { + "name": "sergiohgz" + }, + { + "name": "verdaccio.npm" } + ], + "author": { + "name": "Verdaccio Maintainers", + "email": "verdaccio.npm@gmail.com", + "username": "verdaccio.npm" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-04-28T05:24:23.696Z" + }, + "versions": { + "5.0.4": "latest" + } }, { - "name": "verdaccio-bitbucket", - "description": "Verdaccio module to authenticate users via Bitbucket", - "dist-tags": [], - "maintainers": [ - { - "name": "idangozlan" - } - ], - "author": { - "name": "Idan Gozlan", - "email": "idangozlan@gmail.com", - "username": "idangozlan" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2020-11-17T18:31:50.893Z" - }, - "versions": { - "3.0.1": "latest" + "name": "verdaccio-bitbucket", + "description": "Verdaccio module to authenticate users via Bitbucket", + "dist-tags": [], + "maintainers": [ + { + "name": "idangozlan" } + ], + "author": { + "name": "Idan Gozlan", + "email": "idangozlan@gmail.com", + "username": "idangozlan" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2020-11-17T18:31:50.893Z" + }, + "versions": { + "3.0.1": "latest" + } }, { - "name": "@verdaccio/streams", - "description": "Stream extension for Verdaccio", - "dist-tags": [], - "maintainers": [ - { - "name": "sergiohgz" - }, - { - "name": "verdaccio.npm" - }, - { - "name": "jotadeveloper" - }, - { - "name": "ayusharma" - } - ], - "author": { - "name": "Juan Picado", - "email": "juanpicado19@gmail.com", - "username": "jotadeveloper" + "name": "@verdaccio/streams", + "description": "Stream extension for Verdaccio", + "dist-tags": [], + "maintainers": [ + { + "name": "sergiohgz" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-29T13:01:49.263Z" + { + "name": "verdaccio.npm" }, - "versions": { - "10.0.0": "latest" + { + "name": "jotadeveloper" + }, + { + "name": "ayusharma" } + ], + "author": { + "name": "Juan Picado", + "email": "juanpicado19@gmail.com", + "username": "jotadeveloper" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-29T13:01:49.263Z" + }, + "versions": { + "10.0.0": "latest" + } }, { - "name": "@verdaccio/commons-api", - "description": "Commons API utilities for Verdaccio", - "dist-tags": [], - "maintainers": [ - { - "name": "sergiohgz" - }, - { - "name": "verdaccio.npm" - }, - { - "name": "jotadeveloper" - }, - { - "name": "ayusharma" - } - ], - "author": { - "name": "Juan Picado", - "email": "juanpicado19@gmail.com", - "username": "jotadeveloper" + "name": "@verdaccio/commons-api", + "description": "Commons API utilities for Verdaccio", + "dist-tags": [], + "maintainers": [ + { + "name": "sergiohgz" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-29T13:01:51.477Z" + { + "name": "verdaccio.npm" }, - "versions": { - "10.0.0": "latest" + { + "name": "jotadeveloper" + }, + { + "name": "ayusharma" } + ], + "author": { + "name": "Juan Picado", + "email": "juanpicado19@gmail.com", + "username": "jotadeveloper" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-29T13:01:51.477Z" + }, + "versions": { + "10.0.0": "latest" + } }, { - "name": "verdaccio-audit", - "description": "Verdaccio Middleware plugin to bypass npmjs audit", - "dist-tags": [], - "maintainers": [ - { - "name": "jotadeveloper" - }, - { - "name": "ayusharma" - }, - { - "name": "verdaccio.npm" - } - ], - "author": { - "name": "Juan Picado", - "email": "juanpicado19@gmail.com", - "username": "jotadeveloper" + "name": "verdaccio-audit", + "description": "Verdaccio Middleware plugin to bypass npmjs audit", + "dist-tags": [], + "maintainers": [ + { + "name": "jotadeveloper" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-29T13:01:49.126Z" + { + "name": "ayusharma" }, - "versions": { - "10.0.0": "latest" + { + "name": "verdaccio.npm" } + ], + "author": { + "name": "Juan Picado", + "email": "juanpicado19@gmail.com", + "username": "jotadeveloper" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-29T13:01:49.126Z" + }, + "versions": { + "10.0.0": "latest" + } }, { - "name": "verdaccio-auth-bitbucket", - "description": "Verdaccio module to authenticate users via Bitbucket", - "dist-tags": [], - "maintainers": [ - { - "name": "tomamatics" - } - ], - "author": { - "name": "Tom Pachtner", - "email": "tompachtner@gmail.com" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2020-11-12T16:44:32.807Z" - }, - "versions": { - "2.0.3": "latest" + "name": "verdaccio-auth-bitbucket", + "description": "Verdaccio module to authenticate users via Bitbucket", + "dist-tags": [], + "maintainers": [ + { + "name": "tomamatics" } + ], + "author": { + "name": "Tom Pachtner", + "email": "tompachtner@gmail.com" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2020-11-12T16:44:32.807Z" + }, + "versions": { + "2.0.3": "latest" + } }, { - "name": "@verdaccio/ui-theme", - "description": "Verdaccio User Interface", - "dist-tags": [], - "maintainers": [ - { - "name": "sergiohgz" - }, - { - "name": "verdaccio.npm" - }, - { - "name": "jotadeveloper" - }, - { - "name": "ayusharma" - } - ], - "author": { - "name": "Verdaccio Core Team", - "email": "verdaccio.npm@gmail.com", - "username": "verdaccio.npm" + "name": "@verdaccio/ui-theme", + "description": "Verdaccio User Interface", + "dist-tags": [], + "maintainers": [ + { + "name": "sergiohgz" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-04-27T20:14:01.392Z" + { + "name": "verdaccio.npm" }, - "versions": { - "3.1.0": "latest" + { + "name": "jotadeveloper" + }, + { + "name": "ayusharma" } + ], + "author": { + "name": "Verdaccio Core Team", + "email": "verdaccio.npm@gmail.com", + "username": "verdaccio.npm" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-04-27T20:14:01.392Z" + }, + "versions": { + "3.1.0": "latest" + } }, { - "name": "@verdaccio/local-storage", - "description": "Local storage implementation", - "dist-tags": [], - "maintainers": [ - { - "name": "sergiohgz" - }, - { - "name": "verdaccio.npm" - }, - { - "name": "jotadeveloper" - }, - { - "name": "ayusharma" - } - ], - "author": { - "name": "Juan Picado", - "email": "juanpicado19@gmail.com", - "username": "jotadeveloper" + "name": "@verdaccio/local-storage", + "description": "Local storage implementation", + "dist-tags": [], + "maintainers": [ + { + "name": "sergiohgz" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-05-01T07:51:30.546Z" + { + "name": "verdaccio.npm" }, - "versions": { - "10.0.6": "latest" + { + "name": "jotadeveloper" + }, + { + "name": "ayusharma" } + ], + "author": { + "name": "Juan Picado", + "email": "juanpicado19@gmail.com", + "username": "jotadeveloper" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-05-01T07:51:30.546Z" + }, + "versions": { + "10.0.6": "latest" + } }, { - "name": "@verdaccio/file-locking", - "description": "library that handle file locking", - "dist-tags": [], - "maintainers": [ - { - "name": "sergiohgz" - }, - { - "name": "verdaccio.npm" - }, - { - "name": "jotadeveloper" - }, - { - "name": "ayusharma" - } - ], - "author": { - "name": "Juan Picado", - "email": "juanpicado19@gmail.com", - "username": "jotadeveloper" + "name": "@verdaccio/file-locking", + "description": "library that handle file locking", + "dist-tags": [], + "maintainers": [ + { + "name": "sergiohgz" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-29T13:01:49.338Z" + { + "name": "verdaccio.npm" }, - "versions": { - "10.0.0": "latest" + { + "name": "jotadeveloper" + }, + { + "name": "ayusharma" } + ], + "author": { + "name": "Juan Picado", + "email": "juanpicado19@gmail.com", + "username": "jotadeveloper" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-29T13:01:49.338Z" + }, + "versions": { + "10.0.0": "latest" + } }, { - "name": "verdaccio-htpasswd", - "description": "htpasswd auth plugin for Verdaccio", - "dist-tags": [], - "maintainers": [ - { - "name": "jotadeveloper" - }, - { - "name": "ayusharma" - }, - { - "name": "verdaccio.npm" - } - ], - "author": { - "name": "Ayush Sharma", - "email": "ayush.aceit@gmail.com", - "username": "ayusharma" + "name": "verdaccio-htpasswd", + "description": "htpasswd auth plugin for Verdaccio", + "dist-tags": [], + "maintainers": [ + { + "name": "jotadeveloper" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-29T13:01:56.726Z" + { + "name": "ayusharma" }, - "versions": { - "10.0.0": "latest" + { + "name": "verdaccio.npm" } + ], + "author": { + "name": "Ayush Sharma", + "email": "ayush.aceit@gmail.com", + "username": "ayusharma" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-29T13:01:56.726Z" + }, + "versions": { + "10.0.0": "latest" + } }, { - "name": "verdaccio-badger", - "description": "verdaccio middleware plugin to serve svg badges", - "dist-tags": [], - "maintainers": [ - { - "name": "paddek" - } - ], - "author": { - "name": "Patrick Klös", - "email": "pkloes@web.de", - "username": "paddek" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2020-08-02T18:08:10.321Z" - }, - "versions": { - "1.0.0": "latest" + "name": "verdaccio-badger", + "description": "verdaccio middleware plugin to serve svg badges", + "dist-tags": [], + "maintainers": [ + { + "name": "paddek" } + ], + "author": { + "name": "Patrick Klös", + "email": "pkloes@web.de", + "username": "paddek" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2020-08-02T18:08:10.321Z" + }, + "versions": { + "1.0.0": "latest" + } }, { - "name": "@verdaccio/readme", - "description": "Readme markdown parser", - "dist-tags": [], - "maintainers": [ - { - "name": "sergiohgz" - }, - { - "name": "verdaccio.npm" - }, - { - "name": "jotadeveloper" - }, - { - "name": "ayusharma" - } - ], - "author": { - "name": "Juan Picado", - "email": "juanpicado19@gmail.com", - "username": "jotadeveloper" + "name": "@verdaccio/readme", + "description": "Readme markdown parser", + "dist-tags": [], + "maintainers": [ + { + "name": "sergiohgz" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-29T13:01:49.184Z" + { + "name": "verdaccio.npm" }, - "versions": { - "10.0.0": "latest" + { + "name": "jotadeveloper" + }, + { + "name": "ayusharma" } + ], + "author": { + "name": "Juan Picado", + "email": "juanpicado19@gmail.com", + "username": "jotadeveloper" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-29T13:01:49.184Z" + }, + "versions": { + "10.0.0": "latest" + } }, { - "name": "verdaccio-dynamodb", - "description": "Verdaccio DynamoDB Auth Plugin", - "dist-tags": [], - "maintainers": [ - { - "name": "cwilson" - } - ], - "author": { - "name": "Corey Wilson", - "email": "corey@eastcodes.com", - "username": "cwilson" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2020-06-24T00:27:56.073Z" - }, - "versions": { - "1.1.8": "latest" + "name": "verdaccio-dynamodb", + "description": "Verdaccio DynamoDB Auth Plugin", + "dist-tags": [], + "maintainers": [ + { + "name": "cwilson" } + ], + "author": { + "name": "Corey Wilson", + "email": "corey@eastcodes.com", + "username": "cwilson" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2020-06-24T00:27:56.073Z" + }, + "versions": { + "1.1.8": "latest" + } }, { - "name": "@outcome-co/verdaccio-github-auth", - "description": "Verdaccio Github Authentication Plugin", - "dist-tags": [], - "maintainers": [ - { - "name": "d-tw" - } - ], - "author": { - "name": "Outcome Engineering", - "email": "engineering@outcome.co", - "url": "https://outcome.co" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-05-05T09:20:40.658Z" - }, - "versions": { - "2.0.9": "latest" + "name": "@outcome-co/verdaccio-github-auth", + "description": "Verdaccio Github Authentication Plugin", + "dist-tags": [], + "maintainers": [ + { + "name": "d-tw" } + ], + "author": { + "name": "Outcome Engineering", + "email": "engineering@outcome.co", + "url": "https://outcome.co" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-05-05T09:20:40.658Z" + }, + "versions": { + "2.0.9": "latest" + } }, { - "name": "verdaccio-memory", - "description": "Storage implementation in memory", - "dist-tags": [], - "maintainers": [ - { - "name": "jotadeveloper" - }, - { - "name": "ayusharma" - }, - { - "name": "verdaccio.npm" - } - ], - "author": { - "name": "Juan Picado", - "email": "juanpicado19@gmail.com", - "username": "jotadeveloper" + "name": "verdaccio-memory", + "description": "Storage implementation in memory", + "dist-tags": [], + "maintainers": [ + { + "name": "jotadeveloper" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-29T13:01:59.285Z" + { + "name": "ayusharma" }, - "versions": { - "10.0.0": "latest" + { + "name": "verdaccio.npm" } + ], + "author": { + "name": "Juan Picado", + "email": "juanpicado19@gmail.com", + "username": "jotadeveloper" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-29T13:01:59.285Z" + }, + "versions": { + "10.0.0": "latest" + } }, { - "name": "@verdaccio/types", - "description": "verdaccio types definitions", - "dist-tags": [], - "maintainers": [ - { - "name": "sergiohgz" - }, - { - "name": "verdaccio.npm" - }, - { - "name": "jotadeveloper" - }, - { - "name": "ayusharma" - } - ], - "author": { - "name": "Juan Picado", - "email": "juanpicado19@gmail.com", - "username": "jotadeveloper" + "name": "@verdaccio/types", + "description": "verdaccio types definitions", + "dist-tags": [], + "maintainers": [ + { + "name": "sergiohgz" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-29T13:01:49.294Z" + { + "name": "verdaccio.npm" }, - "versions": { - "10.0.0": "latest" + { + "name": "jotadeveloper" + }, + { + "name": "ayusharma" } + ], + "author": { + "name": "Juan Picado", + "email": "juanpicado19@gmail.com", + "username": "jotadeveloper" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-29T13:01:49.294Z" + }, + "versions": { + "10.0.0": "latest" + } }, { - "name": "verdaccio-auth-memory", - "description": "Auth plugin for Verdaccio that keeps users in memory", - "dist-tags": [], - "maintainers": [ - { - "name": "jotadeveloper" - }, - { - "name": "ayusharma" - }, - { - "name": "verdaccio.npm" - } - ], - "author": { - "name": "Juan Picado", - "email": "juanpicado19@gmail.com", - "username": "jotadeveloper" + "name": "verdaccio-auth-memory", + "description": "Auth plugin for Verdaccio that keeps users in memory", + "dist-tags": [], + "maintainers": [ + { + "name": "jotadeveloper" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-29T13:02:02.215Z" + { + "name": "ayusharma" }, - "versions": { - "10.0.0": "latest" + { + "name": "verdaccio.npm" } + ], + "author": { + "name": "Juan Picado", + "email": "juanpicado19@gmail.com", + "username": "jotadeveloper" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-29T13:02:02.215Z" + }, + "versions": { + "10.0.0": "latest" + } }, { - "name": "generator-verdaccio-plugin", - "description": "plugin generator for verdaccio", - "dist-tags": [], - "maintainers": [ - { - "name": "jotadeveloper" - }, - { - "name": "verdaccio.npm" - } - ], - "author": { - "name": "Juan Picado", - "email": "@jotadeveloper", - "url": "https://github.com/verdaccio/generator-verdaccio-plugin" + "name": "generator-verdaccio-plugin", + "description": "plugin generator for verdaccio", + "dist-tags": [], + "maintainers": [ + { + "name": "jotadeveloper" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2020-12-23T10:31:29.150Z" - }, - "versions": { - "3.0.1": "latest" + { + "name": "verdaccio.npm" } + ], + "author": { + "name": "Juan Picado", + "email": "@jotadeveloper", + "url": "https://github.com/verdaccio/generator-verdaccio-plugin" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2020-12-23T10:31:29.150Z" + }, + "versions": { + "3.0.1": "latest" + } }, { - "name": "verdaccio-bitbucket-server", - "description": "Verdaccio Authentication Plugin via Bitbucket Server", - "dist-tags": [], - "maintainers": [ - { - "name": "oeph" - } - ], - "author": { - "name": "oeph" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2020-09-24T18:02:25.638Z" - }, - "versions": { - "1.3.1": "latest" + "name": "verdaccio-bitbucket-server", + "description": "Verdaccio Authentication Plugin via Bitbucket Server", + "dist-tags": [], + "maintainers": [ + { + "name": "oeph" } + ], + "author": { + "name": "oeph" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2020-09-24T18:02:25.638Z" + }, + "versions": { + "1.3.1": "latest" + } }, { - "name": "verdaccio-theme-hilio", - "description": "Verdaccio User Interface", - "dist-tags": [], - "maintainers": [ - { - "name": "joebnb" - } - ], - "author": { - "name": "Verdaccio Core Team", - "email": "verdaccio.npm@gmail.com" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-01-12T05:48:12.643Z" - }, - "versions": { - "1.14.5": "latest" + "name": "verdaccio-theme-hilio", + "description": "Verdaccio User Interface", + "dist-tags": [], + "maintainers": [ + { + "name": "joebnb" } + ], + "author": { + "name": "Verdaccio Core Team", + "email": "verdaccio.npm@gmail.com" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-01-12T05:48:12.643Z" + }, + "versions": { + "1.14.5": "latest" + } }, { - "name": "verdaccio-aws-s3-storage", - "description": "AWS S3 storage implementation for Verdaccio", - "dist-tags": [], - "maintainers": [ - { - "name": "jotadeveloper" - }, - { - "name": "verdaccio.npm" - } - ], - "author": { - "name": "Juan Picado", - "email": "juanpicado19@gmail.com", - "username": "jotadeveloper" + "name": "verdaccio-aws-s3-storage", + "description": "AWS S3 storage implementation for Verdaccio", + "dist-tags": [], + "maintainers": [ + { + "name": "jotadeveloper" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-05-13T15:11:10.819Z" - }, - "versions": { - "10.1.1": "latest" + { + "name": "verdaccio.npm" } + ], + "author": { + "name": "Juan Picado", + "email": "juanpicado19@gmail.com", + "username": "jotadeveloper" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-05-13T15:11:10.819Z" + }, + "versions": { + "10.1.1": "latest" + } }, { - "name": "verdaccio-minio", - "description": "A verdaccio plugin for storing data in Minio", - "dist-tags": [], - "maintainers": [ - { - "name": "barolab" - } - ], - "author": { - "name": "Romain Bailly", - "email": "rbailly17000@gmail.com", - "username": "barolab" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2020-03-16T08:49:58.248Z" - }, - "versions": { - "0.2.5": "latest" + "name": "verdaccio-minio", + "description": "A verdaccio plugin for storing data in Minio", + "dist-tags": [], + "maintainers": [ + { + "name": "barolab" } + ], + "author": { + "name": "Romain Bailly", + "email": "rbailly17000@gmail.com", + "username": "barolab" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2020-03-16T08:49:58.248Z" + }, + "versions": { + "0.2.5": "latest" + } }, { - "name": "p3x-verdaccio-cli", - "description": "🍶 Verdaccio CLI", - "dist-tags": [], - "maintainers": [ - { - "name": "patrikx3" - } - ], - "author": { - "name": "Patrik Laszlo", - "email": "alabard@gmail.com", - "username": "patrikx3" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-05-11T10:11:33.476Z" - }, - "versions": { - "2021.4.116": "latest" + "name": "p3x-verdaccio-cli", + "description": "🍶 Verdaccio CLI", + "dist-tags": [], + "maintainers": [ + { + "name": "patrikx3" } + ], + "author": { + "name": "Patrik Laszlo", + "email": "alabard@gmail.com", + "username": "patrikx3" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-05-11T10:11:33.476Z" + }, + "versions": { + "2021.4.116": "latest" + } }, { - "name": "verdaccio-theme-xdf", - "description": "Verdaccio User Interface", - "dist-tags": [], - "maintainers": [ - { - "name": "likaizhu" - } - ], - "author": { - "name": "likaizhu", - "email": "likaizhu@xdf.cn" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2020-11-25T03:24:41.890Z" - }, - "versions": { - "1.0.0": "latest" + "name": "verdaccio-theme-xdf", + "description": "Verdaccio User Interface", + "dist-tags": [], + "maintainers": [ + { + "name": "likaizhu" } + ], + "author": { + "name": "likaizhu", + "email": "likaizhu@xdf.cn" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2020-11-25T03:24:41.890Z" + }, + "versions": { + "1.0.0": "latest" + } }, { - "name": "kiss-verdaccio-types", - "description": "verdaccio types definitions", - "dist-tags": [], - "maintainers": [ - { - "name": "qd397" - } - ], - "author": { - "name": "Juan Picado", - "email": "juanpicado19@gmail.com" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-02-22T10:46:54.122Z" - }, - "versions": { - "9.7.3": "latest" + "name": "kiss-verdaccio-types", + "description": "verdaccio types definitions", + "dist-tags": [], + "maintainers": [ + { + "name": "qd397" } + ], + "author": { + "name": "Juan Picado", + "email": "juanpicado19@gmail.com" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-02-22T10:46:54.122Z" + }, + "versions": { + "9.7.3": "latest" + } }, { - "name": "@verdaccio/testing-utilities", - "description": "Utils for Verdaccio", - "dist-tags": [], - "maintainers": [ - { - "name": "sergiohgz" - }, - { - "name": "verdaccio.npm" - }, - { - "name": "jotadeveloper" - }, - { - "name": "ayusharma" - } - ], - "author": { - "name": "Juan Picado", - "email": "juanpicado19@gmail.com", - "username": "jotadeveloper" + "name": "@verdaccio/testing-utilities", + "description": "Utils for Verdaccio", + "dist-tags": [], + "maintainers": [ + { + "name": "sergiohgz" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-29T13:01:49.257Z" + { + "name": "verdaccio.npm" }, - "versions": { - "10.0.0": "latest" + { + "name": "jotadeveloper" + }, + { + "name": "ayusharma" } + ], + "author": { + "name": "Juan Picado", + "email": "juanpicado19@gmail.com", + "username": "jotadeveloper" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-29T13:01:49.257Z" + }, + "versions": { + "10.0.0": "latest" + } }, { - "name": "verdaccio-git", - "description": "Publish packages to git repositories.", - "dist-tags": [], - "maintainers": [ - { - "name": "amazeelabs" - } - ], - "author": { - "name": "Philipp Melab", - "email": "philipp.melab@amazee.com" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-01T12:28:51.911Z" - }, - "versions": { - "0.1.29": "latest" + "name": "verdaccio-git", + "description": "Publish packages to git repositories.", + "dist-tags": [], + "maintainers": [ + { + "name": "amazeelabs" } + ], + "author": { + "name": "Philipp Melab", + "email": "philipp.melab@amazee.com" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-01T12:28:51.911Z" + }, + "versions": { + "0.1.29": "latest" + } }, { - "name": "eslint-plugin-verdaccio", - "description": "Verdaccio code guidelines", - "dist-tags": [], - "maintainers": [ - { - "name": "jotadeveloper" - }, - { - "name": "verdaccio.npm" - } - ], - "author": { - "name": "Juan Picado", - "email": "juanpicado19@gmail.com", - "username": "jotadeveloper" + "name": "eslint-plugin-verdaccio", + "description": "Verdaccio code guidelines", + "dist-tags": [], + "maintainers": [ + { + "name": "jotadeveloper" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-29T13:01:49.142Z" - }, - "versions": { - "10.0.0": "latest" + { + "name": "verdaccio.npm" } + ], + "author": { + "name": "Juan Picado", + "email": "juanpicado19@gmail.com", + "username": "jotadeveloper" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-29T13:01:49.142Z" + }, + "versions": { + "10.0.0": "latest" + } }, { - "name": "@verdaccio/active-directory", - "description": "Active Directory authentication plugin for Verdaccio", - "dist-tags": [], - "maintainers": [ - { - "name": "sergiohgz" - }, - { - "name": "verdaccio.npm" - }, - { - "name": "jotadeveloper" - }, - { - "name": "ayusharma" - } - ], - "author": { - "name": "Sergio Herrera", - "email": "sergio@sergiohgz.eu", - "username": "sergiohgz" + "name": "@verdaccio/active-directory", + "description": "Active Directory authentication plugin for Verdaccio", + "dist-tags": [], + "maintainers": [ + { + "name": "sergiohgz" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-29T13:02:05.483Z" + { + "name": "verdaccio.npm" }, - "versions": { - "10.0.0": "latest" + { + "name": "jotadeveloper" + }, + { + "name": "ayusharma" } + ], + "author": { + "name": "Sergio Herrera", + "email": "sergio@sergiohgz.eu", + "username": "sergiohgz" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-29T13:02:05.483Z" + }, + "versions": { + "10.0.0": "latest" + } }, { - "name": "verdaccio-google-cloud", - "description": "Google Cloud storage implementation for Verdaccio", - "dist-tags": [], - "maintainers": [ - { - "name": "jotadeveloper" - }, - { - "name": "verdaccio.npm" - } - ], - "author": { - "name": "Juan Picado", - "email": "juanpicado19@gmail.com", - "username": "jotadeveloper" + "name": "verdaccio-google-cloud", + "description": "Google Cloud storage implementation for Verdaccio", + "dist-tags": [], + "maintainers": [ + { + "name": "jotadeveloper" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-29T13:01:59.419Z" - }, - "versions": { - "10.0.0": "latest" + { + "name": "verdaccio.npm" } + ], + "author": { + "name": "Juan Picado", + "email": "juanpicado19@gmail.com", + "username": "jotadeveloper" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-29T13:01:59.419Z" + }, + "versions": { + "10.0.0": "latest" + } }, { - "name": "verdaccio-pacman", - "description": "Verdaccio Middleware Plugin to manage tags and versions of packages", - "dist-tags": [], - "maintainers": [ - { - "name": "paddek" - } - ], - "author": { - "name": "Patrick Klös", - "email": "pkloes@web.de", - "username": "paddek" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2020-10-07T16:30:52.919Z" - }, - "versions": { - "1.1.1": "latest" + "name": "verdaccio-pacman", + "description": "Verdaccio Middleware Plugin to manage tags and versions of packages", + "dist-tags": [], + "maintainers": [ + { + "name": "paddek" } + ], + "author": { + "name": "Patrick Klös", + "email": "pkloes@web.de", + "username": "paddek" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2020-10-07T16:30:52.919Z" + }, + "versions": { + "1.1.1": "latest" + } }, { - "name": "verdaccio-ldap-memcached", - "description": "LDAP auth plugin for verdaccio", - "dist-tags": [], - "maintainers": [ - { - "name": "therippa" - } - ], - "author": { - "name": "Alexandre L." - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2018-02-02T21:34:37.002Z" - }, - "versions": { - "1.4.1": "latest" + "name": "verdaccio-ldap-memcached", + "description": "LDAP auth plugin for verdaccio", + "dist-tags": [], + "maintainers": [ + { + "name": "therippa" } + ], + "author": { + "name": "Alexandre L." + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2018-02-02T21:34:37.002Z" + }, + "versions": { + "1.4.1": "latest" + } }, { - "name": "@verdaccio/eslint-config", - "description": "Verdaccio ESLint shareable config", - "dist-tags": [], - "maintainers": [ - { - "name": "sergiohgz" - }, - { - "name": "verdaccio.npm" - }, - { - "name": "jotadeveloper" - }, - { - "name": "ayusharma" - } - ], - "author": { - "name": "Juan Picado", - "email": "juanpicado19@gmail.com", - "username": "jotadeveloper" + "name": "@verdaccio/eslint-config", + "description": "Verdaccio ESLint shareable config", + "dist-tags": [], + "maintainers": [ + { + "name": "sergiohgz" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-29T13:01:49.275Z" + { + "name": "verdaccio.npm" }, - "versions": { - "10.0.0": "latest" + { + "name": "jotadeveloper" + }, + { + "name": "ayusharma" } + ], + "author": { + "name": "Juan Picado", + "email": "juanpicado19@gmail.com", + "username": "jotadeveloper" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-29T13:01:49.275Z" + }, + "versions": { + "10.0.0": "latest" + } }, { - "name": "@verdaccio/babel-preset", - "description": "A common preset for Verdaccio projects", - "dist-tags": [], - "maintainers": [ - { - "name": "sergiohgz" - }, - { - "name": "verdaccio.npm" - }, - { - "name": "jotadeveloper" - }, - { - "name": "ayusharma" - } - ], - "author": { - "name": "Juan Picado", - "email": "juanpicado19@gmail.com", - "username": "jotadeveloper" + "name": "@verdaccio/babel-preset", + "description": "A common preset for Verdaccio projects", + "dist-tags": [], + "maintainers": [ + { + "name": "sergiohgz" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-29T13:01:49.979Z" + { + "name": "verdaccio.npm" }, - "versions": { - "10.0.0": "latest" + { + "name": "jotadeveloper" + }, + { + "name": "ayusharma" } + ], + "author": { + "name": "Juan Picado", + "email": "juanpicado19@gmail.com", + "username": "jotadeveloper" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-29T13:01:49.979Z" + }, + "versions": { + "10.0.0": "latest" + } }, { - "name": "verdaccio-gitlab-hilio", - "description": "private npm registry (Verdaccio) using gitlab-ce as authentication and authorization provider", - "dist-tags": [], - "maintainers": [ - { - "name": "joebnb" - } - ], - "author": { - "name": "Roger Meier", - "email": "roger@bufferoverflow.ch" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-04-07T08:57:08.622Z" - }, - "versions": { - "1.1.17": "latest" + "name": "verdaccio-gitlab-hilio", + "description": "private npm registry (Verdaccio) using gitlab-ce as authentication and authorization provider", + "dist-tags": [], + "maintainers": [ + { + "name": "joebnb" } + ], + "author": { + "name": "Roger Meier", + "email": "roger@bufferoverflow.ch" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-04-07T08:57:08.622Z" + }, + "versions": { + "1.1.17": "latest" + } }, { - "name": "uino-verdaccio", - "description": "A lightweight private npm proxy registry", - "dist-tags": [], - "maintainers": [ - { - "name": "qd397" - } - ], - "author": { - "name": "Verdaccio Maintainers", - "email": "verdaccio.npm@gmail.com" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-02-22T12:58:21.898Z" - }, - "versions": { - "4.8.5": "latest" + "name": "uino-verdaccio", + "description": "A lightweight private npm proxy registry", + "dist-tags": [], + "maintainers": [ + { + "name": "qd397" } + ], + "author": { + "name": "Verdaccio Maintainers", + "email": "verdaccio.npm@gmail.com" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-02-22T12:58:21.898Z" + }, + "versions": { + "4.8.5": "latest" + } }, { - "name": "verdaccio-ldap", - "description": "LDAP auth plugin for verdaccio", - "dist-tags": [], - "maintainers": [ - { - "name": "alexandre-io" - } - ], - "author": { - "name": "Alexandre L." - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2020-08-15T13:22:01.193Z" - }, - "versions": { - "4.2.0": "latest" + "name": "verdaccio-ldap", + "description": "LDAP auth plugin for verdaccio", + "dist-tags": [], + "maintainers": [ + { + "name": "alexandre-io" } + ], + "author": { + "name": "Alexandre L." + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2020-08-15T13:22:01.193Z" + }, + "versions": { + "4.2.0": "latest" + } }, { - "name": "verdaccio-github-oauth-ui", - "description": "

📦🔐 Verdaccio GitHub OAuth - With UI Support

", - "dist-tags": [], - "maintainers": [ - { - "name": "abraham-schilling" - } - ], - "author": { - "name": "Abraham Schilling" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-05-02T17:48:18.912Z" - }, - "versions": { - "3.0.0": "latest" + "name": "verdaccio-github-oauth-ui", + "description": "

📦🔐 Verdaccio GitHub OAuth - With UI Support

", + "dist-tags": [], + "maintainers": [ + { + "name": "abraham-schilling" } + ], + "author": { + "name": "Abraham Schilling" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-05-02T17:48:18.912Z" + }, + "versions": { + "3.0.0": "latest" + } }, { - "name": "verdaccio-https", - "description": "verdaccio middleware plugin to redirect to https", - "dist-tags": [], - "maintainers": [ - { - "name": "honzahommer" - } - ], - "author": { - "name": "Honza Hommer", - "email": "honza@hommer.cz", - "username": "honzahommer" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2019-10-19T21:30:42.977Z" - }, - "versions": { - "1.0.11": "latest" + "name": "verdaccio-https", + "description": "verdaccio middleware plugin to redirect to https", + "dist-tags": [], + "maintainers": [ + { + "name": "honzahommer" } + ], + "author": { + "name": "Honza Hommer", + "email": "honza@hommer.cz", + "username": "honzahommer" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2019-10-19T21:30:42.977Z" + }, + "versions": { + "1.0.11": "latest" + } }, { - "name": "mlc-verdaccio-s3-archiver", - "description": "Builds an archive of your verdaccio instance, then backup it to AWS S3.", - "dist-tags": [], - "maintainers": [ - { - "name": "moonlight-coding" - } - ], - "author": { - "name": "Pierre-Emmanuel Lallemant", - "email": "pe.lallemant@hotmail.fr", - "username": "moonlight-coding" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2020-05-17T17:45:33.532Z" - }, - "versions": { - "1.0.3": "latest" + "name": "mlc-verdaccio-s3-archiver", + "description": "Builds an archive of your verdaccio instance, then backup it to AWS S3.", + "dist-tags": [], + "maintainers": [ + { + "name": "moonlight-coding" } + ], + "author": { + "name": "Pierre-Emmanuel Lallemant", + "email": "pe.lallemant@hotmail.fr", + "username": "moonlight-coding" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2020-05-17T17:45:33.532Z" + }, + "versions": { + "1.0.3": "latest" + } }, { - "name": "verdaccio-pg-storage", - "description": "Storage plugin to host packages PostgreSQL", - "dist-tags": [], - "maintainers": [ - { - "name": "yckao" - } - ], - "author": { - "name": "yckao", - "email": "yckaokarl@gmail.com", - "username": "yckao" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2020-06-24T11:03:49.163Z" - }, - "versions": { - "1.0.3": "latest" + "name": "verdaccio-pg-storage", + "description": "Storage plugin to host packages PostgreSQL", + "dist-tags": [], + "maintainers": [ + { + "name": "yckao" } + ], + "author": { + "name": "yckao", + "email": "yckaokarl@gmail.com", + "username": "yckao" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2020-06-24T11:03:49.163Z" + }, + "versions": { + "1.0.3": "latest" + } }, { - "name": "verdaccio-apm-server", - "description": "An amazing verdaccio plugin", - "dist-tags": [], - "maintainers": [ - { - "name": "soul741" - } - ], - "author": { - "name": "Hasan", - "email": "hasancangedik@hotmail.com", - "username": "soul741" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2020-09-28T09:16:04.557Z" - }, - "versions": { - "1.0.14": "latest" + "name": "verdaccio-apm-server", + "description": "An amazing verdaccio plugin", + "dist-tags": [], + "maintainers": [ + { + "name": "soul741" } + ], + "author": { + "name": "Hasan", + "email": "hasancangedik@hotmail.com", + "username": "soul741" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2020-09-28T09:16:04.557Z" + }, + "versions": { + "1.0.14": "latest" + } }, { - "name": "verdaccio-openmetrics", - "description": "Verdaccio plugin exposing an OpenMetrics/Prometheus endpoint with health and traffic metrics", - "dist-tags": [], - "maintainers": [ - { - "name": "freightbot" - } - ], - "author": { - "name": "Daniel Lamando", - "email": "daniel.lamando@forto.com" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-22T16:32:11.445Z" - }, - "versions": { - "1.1.0": "latest" + "name": "verdaccio-openmetrics", + "description": "Verdaccio plugin exposing an OpenMetrics/Prometheus endpoint with health and traffic metrics", + "dist-tags": [], + "maintainers": [ + { + "name": "freightbot" } + ], + "author": { + "name": "Daniel Lamando", + "email": "daniel.lamando@forto.com" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-22T16:32:11.445Z" + }, + "versions": { + "1.1.0": "latest" + } }, { - "name": "verdaccio-local-storage-with-cache-db", - "description": "Local storage implementation", - "dist-tags": [], - "maintainers": [ - { - "name": "joebnb" - } - ], - "author": { - "name": "Juan Picado", - "email": "juanpicado19@gmail.com" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2020-11-28T03:11:03.871Z" - }, - "versions": { - "9.7.5": "latest" + "name": "verdaccio-local-storage-with-cache-db", + "description": "Local storage implementation", + "dist-tags": [], + "maintainers": [ + { + "name": "joebnb" } + ], + "author": { + "name": "Juan Picado", + "email": "juanpicado19@gmail.com" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2020-11-28T03:11:03.871Z" + }, + "versions": { + "9.7.5": "latest" + } }, { - "name": "verdaccio-azure-ad-login", - "description": "Let your users authenticate into Verdaccio using Azure AD OAuth", - "dist-tags": [], - "maintainers": [ - { - "name": "ihton" - } - ], - "author": { - "name": "Antonio Terrero Algaba", - "email": "atalgaba@gmail.com", - "username": "ihton" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-02-25T08:51:52.652Z" - }, - "versions": { - "1.0.5": "latest" + "name": "verdaccio-azure-ad-login", + "description": "Let your users authenticate into Verdaccio using Azure AD OAuth", + "dist-tags": [], + "maintainers": [ + { + "name": "ihton" } + ], + "author": { + "name": "Antonio Terrero Algaba", + "email": "atalgaba@gmail.com", + "username": "ihton" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-02-25T08:51:52.652Z" + }, + "versions": { + "1.0.5": "latest" + } }, { - "name": "@freighthub/verdaccio-openmetrics", - "description": "Verdaccio plugin exposing an OpenMetrics/Prometheus endpoint with health and traffic metrics", - "dist-tags": [], - "maintainers": [ - { - "name": "pallavimalik" - }, - { - "name": "lydia.seidlitz" - }, - { - "name": "michelle.chua" - }, - { - "name": "rodmatos" - }, - { - "name": "danopia" - }, - { - "name": "diogocostaferraz" - }, - { - "name": "namit1211" - }, - { - "name": "matang.dave" - }, - { - "name": "wes.lim" - }, - { - "name": "orinelin" - }, - { - "name": "beheim" - }, - { - "name": "erikmuttersbach" - }, - { - "name": "justgoscha" - }, - { - "name": "firellon" - }, - { - "name": "l-oris" - }, - { - "name": "artfwo" - }, - { - "name": "pravinbashyal" - }, - { - "name": "freightbot" - }, - { - "name": "milos.mircov" - }, - { - "name": "unsal.gokdag" - }, - { - "name": "norocketscientist" - }, - { - "name": "sid23" - }, - { - "name": "vedpbharti" - }, - { - "name": "fr-yp" - }, - { - "name": "prabhakalaivani" - }, - { - "name": "baptlesta" - }, - { - "name": "luisantunesdeveloper" - }, - { - "name": "blueyedgeek" - }, - { - "name": "rashidfh" - }, - { - "name": "ulymarins" - }, - { - "name": "pedrock" - }, - { - "name": "jose.suero" - }, - { - "name": "sidoshi" - }, - { - "name": "mridulmeh" - }, - { - "name": "dhayanand" - }, - { - "name": "avijit.gupta" - }, - { - "name": "dijia" - }, - { - "name": "batuhandirek" - }, - { - "name": "dayemsiddiqui" - }, - { - "name": "eruditespirit" - }, - { - "name": "ajayvarghese003" - }, - { - "name": "ortserga" - }, - { - "name": "fmueller_bln" - }, - { - "name": "imartyn" - }, - { - "name": "sabbir.ahmmed" - }, - { - "name": "aditya337" - }, - { - "name": "ranyardmforto" - }, - { - "name": "mtrabelsi" - }, - { - "name": "lsamayoa-forto" - }, - { - "name": "nitesh-forto" - }, - { - "name": "albertvp" - }, - { - "name": "aliasgarhada" - }, - { - "name": "ruizmurcia" - }, - { - "name": "micszym" - }, - { - "name": "b3nshi" - }, - { - "name": "dawidmf" - } - ], - "author": { - "name": "Daniel Lamando", - "email": "daniel.lamando@forto.com" + "name": "@freighthub/verdaccio-openmetrics", + "description": "Verdaccio plugin exposing an OpenMetrics/Prometheus endpoint with health and traffic metrics", + "dist-tags": [], + "maintainers": [ + { + "name": "pallavimalik" }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-01-12T15:06:00.719Z" + { + "name": "lydia.seidlitz" }, - "versions": { - "1.0.1": "latest" + { + "name": "michelle.chua" + }, + { + "name": "rodmatos" + }, + { + "name": "danopia" + }, + { + "name": "diogocostaferraz" + }, + { + "name": "namit1211" + }, + { + "name": "matang.dave" + }, + { + "name": "wes.lim" + }, + { + "name": "orinelin" + }, + { + "name": "beheim" + }, + { + "name": "erikmuttersbach" + }, + { + "name": "justgoscha" + }, + { + "name": "firellon" + }, + { + "name": "l-oris" + }, + { + "name": "artfwo" + }, + { + "name": "pravinbashyal" + }, + { + "name": "freightbot" + }, + { + "name": "milos.mircov" + }, + { + "name": "unsal.gokdag" + }, + { + "name": "norocketscientist" + }, + { + "name": "sid23" + }, + { + "name": "vedpbharti" + }, + { + "name": "fr-yp" + }, + { + "name": "prabhakalaivani" + }, + { + "name": "baptlesta" + }, + { + "name": "luisantunesdeveloper" + }, + { + "name": "blueyedgeek" + }, + { + "name": "rashidfh" + }, + { + "name": "ulymarins" + }, + { + "name": "pedrock" + }, + { + "name": "jose.suero" + }, + { + "name": "sidoshi" + }, + { + "name": "mridulmeh" + }, + { + "name": "dhayanand" + }, + { + "name": "avijit.gupta" + }, + { + "name": "dijia" + }, + { + "name": "batuhandirek" + }, + { + "name": "dayemsiddiqui" + }, + { + "name": "eruditespirit" + }, + { + "name": "ajayvarghese003" + }, + { + "name": "ortserga" + }, + { + "name": "fmueller_bln" + }, + { + "name": "imartyn" + }, + { + "name": "sabbir.ahmmed" + }, + { + "name": "aditya337" + }, + { + "name": "ranyardmforto" + }, + { + "name": "mtrabelsi" + }, + { + "name": "lsamayoa-forto" + }, + { + "name": "nitesh-forto" + }, + { + "name": "albertvp" + }, + { + "name": "aliasgarhada" + }, + { + "name": "ruizmurcia" + }, + { + "name": "micszym" + }, + { + "name": "b3nshi" + }, + { + "name": "dawidmf" } + ], + "author": { + "name": "Daniel Lamando", + "email": "daniel.lamando@forto.com" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-01-12T15:06:00.719Z" + }, + "versions": { + "1.0.1": "latest" + } }, { - "name": "bulk-npm-publish", - "description": "Publish Multiple NPM packages from verdaccio storage", - "dist-tags": [], - "maintainers": [ - { - "name": "rluvaton" - } - ], - "author": { - "name": "Raz Luvaton", - "email": "rluvaton@gmail.com", - "username": "rluvaton" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-03-15T19:09:02.964Z" - }, - "versions": { - "3.0.2": "latest" + "name": "bulk-npm-publish", + "description": "Publish Multiple NPM packages from verdaccio storage", + "dist-tags": [], + "maintainers": [ + { + "name": "rluvaton" } + ], + "author": { + "name": "Raz Luvaton", + "email": "rluvaton@gmail.com", + "username": "rluvaton" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-03-15T19:09:02.964Z" + }, + "versions": { + "3.0.2": "latest" + } }, { - "name": "verdaccio-acl-plugin", - "description": "Plugin to simplify group permissions management", - "dist-tags": [], - "maintainers": [ - { - "name": "t3o-it" - } - ], - "author": { - "name": "Matteo Gazzin", - "email": "gazz10@gmail.com", - "username": "t3o-it" - }, - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-02-01T09:29:20.521Z" - }, - "versions": { - "1.0.1": "latest" + "name": "verdaccio-acl-plugin", + "description": "Plugin to simplify group permissions management", + "dist-tags": [], + "maintainers": [ + { + "name": "t3o-it" } + ], + "author": { + "name": "Matteo Gazzin", + "email": "gazz10@gmail.com", + "username": "t3o-it" + }, + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-02-01T09:29:20.521Z" + }, + "versions": { + "1.0.1": "latest" + } }, { - "name": "verdaccio-openid-connect", - "description": "Verdaccio authentication plugin for OpenID Connect. When installed, `npm login --registry ...` command will open the browser to start login flow.", - "dist-tags": [], - "maintainers": [ - { - "name": "aikoven" - } - ], - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-01-31T06:59:29.589Z" - }, - "versions": { - "1.0.2": "latest" + "name": "verdaccio-openid-connect", + "description": "Verdaccio authentication plugin for OpenID Connect. When installed, `npm login --registry ...` command will open the browser to start login flow.", + "dist-tags": [], + "maintainers": [ + { + "name": "aikoven" } + ], + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-01-31T06:59:29.589Z" + }, + "versions": { + "1.0.2": "latest" + } }, { - "name": "verdaccio-groups2", - "description": "- 一个verdaccio group管理插件(auth插件)", - "dist-tags": [], - "maintainers": [ - { - "name": "jeffery0211" - } - ], - "homepage": "", - "keywords": [], - "repository": {}, - "readmeFilename": "", - "time": { - "modified": "2021-01-02T17:00:51.883Z" - }, - "versions": { - "1.0.2": "latest" + "name": "verdaccio-groups2", + "description": "- 一个verdaccio group管理插件(auth插件)", + "dist-tags": [], + "maintainers": [ + { + "name": "jeffery0211" } + ], + "homepage": "", + "keywords": [], + "repository": {}, + "readmeFilename": "", + "time": { + "modified": "2021-01-02T17:00:51.883Z" + }, + "versions": { + "1.0.2": "latest" + } } ] diff --git a/test/unit/modules/api/partials/search-v1-empty.json b/test/unit/modules/api/partials/search-v1-empty.json index 7200ebe4c..7d3f27167 100644 --- a/test/unit/modules/api/partials/search-v1-empty.json +++ b/test/unit/modules/api/partials/search-v1-empty.json @@ -1,5 +1,5 @@ { - "objects": [], - "total": 0, - "time": "Fri May 14 2021 21:51:36 GMT+0000 (UTC)" + "objects": [], + "total": 0, + "time": "Fri May 14 2021 21:51:36 GMT+0000 (UTC)" } diff --git a/test/unit/modules/api/partials/search-v1-forbidden.json b/test/unit/modules/api/partials/search-v1-forbidden.json index d08b61eda..e86a0032b 100644 --- a/test/unit/modules/api/partials/search-v1-forbidden.json +++ b/test/unit/modules/api/partials/search-v1-forbidden.json @@ -1,195 +1,180 @@ { - "objects": [ - { - "package": { - "name": "react", - "scope": "unscoped", - "version": "17.0.2", - "description": "React is a JavaScript library for building user interfaces.", - "keywords": [ - "react" - ], - "date": "2021-03-22T21:56:19.536Z", - "links": { - "npm": "https://www.npmjs.com/package/react", - "homepage": "https://reactjs.org/", - "repository": "https://github.com/facebook/react", - "bugs": "https://github.com/facebook/react/issues" - }, - "publisher": { - "username": "gaearon", - "email": "dan.abramov@gmail.com" - }, - "maintainers": [ - { - "username": "sebmarkbage", - "email": "sebastian@calyptus.eu" - }, - { - "username": "gaearon", - "email": "dan.abramov@gmail.com" - }, - { - "username": "acdlite", - "email": "npm@andrewclark.io" - }, - { - "username": "brianvaughn", - "email": "briandavidvaughn@gmail.com" - }, - { - "username": "fb", - "email": "opensource+npm@fb.com" - }, - { - "username": "trueadm", - "email": "dg@domgan.com" - }, - { - "username": "sophiebits", - "email": "npm@sophiebits.com" - }, - { - "username": "lunaruan", - "email": "lunaris.ruan@gmail.com" - } - ] - }, - "score": { - "final": 0.5866871996642231, - "detail": { - "quality": 0.5243673868446629, - "popularity": 0.8934580484118788, - "maintenance": 0.3333333333333333 - } - }, - "searchScore": 100000.65 + "objects": [ + { + "package": { + "name": "react", + "scope": "unscoped", + "version": "17.0.2", + "description": "React is a JavaScript library for building user interfaces.", + "keywords": ["react"], + "date": "2021-03-22T21:56:19.536Z", + "links": { + "npm": "https://www.npmjs.com/package/react", + "homepage": "https://reactjs.org/", + "repository": "https://github.com/facebook/react", + "bugs": "https://github.com/facebook/react/issues" }, - { - "package": { - "name": "rxjs", - "scope": "unscoped", - "version": "7.0.1", - "description": "Reactive Extensions for modern JavaScript", - "keywords": [ - "Rx", - "RxJS", - "ReactiveX", - "ReactiveExtensions", - "Streams", - "Observables", - "Observable", - "Stream", - "ES6", - "ES2015" - ], - "date": "2021-05-12T02:26:13.432Z", - "links": { - "npm": "https://www.npmjs.com/package/rxjs", - "homepage": "https://rxjs.dev", - "repository": "https://github.com/reactivex/rxjs", - "bugs": "https://github.com/ReactiveX/RxJS/issues" - }, - "author": { - "name": "Ben Lesh", - "email": "ben@benlesh.com", - "username": "blesh" - }, - "publisher": { - "username": "blesh", - "email": "ben@benlesh.com" - }, - "maintainers": [ - { - "username": "blesh", - "email": "ben@benlesh.com" - }, - { - "username": "jeffbcross", - "email": "middlefloor@gmail.com" - } - ] - }, - "score": { - "final": 0.6836223477625805, - "detail": { - "quality": 0.9291959177173365, - "popularity": 0.8234197308020366, - "maintenance": 0.3333333333333333 - } - }, - "searchScore": 0.4475699 + "publisher": { + "username": "gaearon", + "email": "dan.abramov@gmail.com" }, - { - "package": { - "name": "react-dom", - "scope": "unscoped", - "version": "17.0.2", - "description": "React package for working with the DOM.", - "keywords": [ - "react" - ], - "date": "2021-03-22T21:56:33.089Z", - "links": { - "npm": "https://www.npmjs.com/package/react-dom", - "homepage": "https://reactjs.org/", - "repository": "https://github.com/facebook/react", - "bugs": "https://github.com/facebook/react/issues" - }, - "publisher": { - "username": "gaearon", - "email": "dan.abramov@gmail.com" - }, - "maintainers": [ - { - "username": "sebmarkbage", - "email": "sebastian@calyptus.eu" - }, - { - "username": "gaearon", - "email": "dan.abramov@gmail.com" - }, - { - "username": "zpao", - "email": "paul@oshannessy.com" - }, - { - "username": "acdlite", - "email": "npm@andrewclark.io" - }, - { - "username": "brianvaughn", - "email": "briandavidvaughn@gmail.com" - }, - { - "username": "fb", - "email": "opensource+npm@fb.com" - }, - { - "username": "trueadm", - "email": "dg@domgan.com" - }, - { - "username": "sophiebits", - "email": "npm@sophiebits.com" - }, - { - "username": "lunaruan", - "email": "lunaris.ruan@gmail.com" - } - ] - }, - "score": { - "final": 0.5654772997237696, - "detail": { - "quality": 0.5243673868446629, - "popularity": 0.8328583342962974, - "maintenance": 0.3333333333333333 - } - }, - "searchScore": 0.27131972 + "maintainers": [ + { + "username": "sebmarkbage", + "email": "sebastian@calyptus.eu" + }, + { + "username": "gaearon", + "email": "dan.abramov@gmail.com" + }, + { + "username": "acdlite", + "email": "npm@andrewclark.io" + }, + { + "username": "brianvaughn", + "email": "briandavidvaughn@gmail.com" + }, + { + "username": "fb", + "email": "opensource+npm@fb.com" + }, + { + "username": "trueadm", + "email": "dg@domgan.com" + }, + { + "username": "sophiebits", + "email": "npm@sophiebits.com" + }, + { + "username": "lunaruan", + "email": "lunaris.ruan@gmail.com" + } + ] + }, + "score": { + "final": 0.5866871996642231, + "detail": { + "quality": 0.5243673868446629, + "popularity": 0.8934580484118788, + "maintenance": 0.3333333333333333 } - ], - "total": 159885, - "time": "Sat May 15 2021 07:32:48 GMT+0000 (UTC)" + }, + "searchScore": 100000.65 + }, + { + "package": { + "name": "rxjs", + "scope": "unscoped", + "version": "7.0.1", + "description": "Reactive Extensions for modern JavaScript", + "keywords": ["Rx", "RxJS", "ReactiveX", "ReactiveExtensions", "Streams", "Observables", "Observable", "Stream", "ES6", "ES2015"], + "date": "2021-05-12T02:26:13.432Z", + "links": { + "npm": "https://www.npmjs.com/package/rxjs", + "homepage": "https://rxjs.dev", + "repository": "https://github.com/reactivex/rxjs", + "bugs": "https://github.com/ReactiveX/RxJS/issues" + }, + "author": { + "name": "Ben Lesh", + "email": "ben@benlesh.com", + "username": "blesh" + }, + "publisher": { + "username": "blesh", + "email": "ben@benlesh.com" + }, + "maintainers": [ + { + "username": "blesh", + "email": "ben@benlesh.com" + }, + { + "username": "jeffbcross", + "email": "middlefloor@gmail.com" + } + ] + }, + "score": { + "final": 0.6836223477625805, + "detail": { + "quality": 0.9291959177173365, + "popularity": 0.8234197308020366, + "maintenance": 0.3333333333333333 + } + }, + "searchScore": 0.4475699 + }, + { + "package": { + "name": "react-dom", + "scope": "unscoped", + "version": "17.0.2", + "description": "React package for working with the DOM.", + "keywords": ["react"], + "date": "2021-03-22T21:56:33.089Z", + "links": { + "npm": "https://www.npmjs.com/package/react-dom", + "homepage": "https://reactjs.org/", + "repository": "https://github.com/facebook/react", + "bugs": "https://github.com/facebook/react/issues" + }, + "publisher": { + "username": "gaearon", + "email": "dan.abramov@gmail.com" + }, + "maintainers": [ + { + "username": "sebmarkbage", + "email": "sebastian@calyptus.eu" + }, + { + "username": "gaearon", + "email": "dan.abramov@gmail.com" + }, + { + "username": "zpao", + "email": "paul@oshannessy.com" + }, + { + "username": "acdlite", + "email": "npm@andrewclark.io" + }, + { + "username": "brianvaughn", + "email": "briandavidvaughn@gmail.com" + }, + { + "username": "fb", + "email": "opensource+npm@fb.com" + }, + { + "username": "trueadm", + "email": "dg@domgan.com" + }, + { + "username": "sophiebits", + "email": "npm@sophiebits.com" + }, + { + "username": "lunaruan", + "email": "lunaris.ruan@gmail.com" + } + ] + }, + "score": { + "final": 0.5654772997237696, + "detail": { + "quality": 0.5243673868446629, + "popularity": 0.8328583342962974, + "maintenance": 0.3333333333333333 + } + }, + "searchScore": 0.27131972 + } + ], + "total": 159885, + "time": "Sat May 15 2021 07:32:48 GMT+0000 (UTC)" } diff --git a/test/unit/modules/api/partials/search-v1.json b/test/unit/modules/api/partials/search-v1.json index 276aa1cf9..bd79be05a 100644 --- a/test/unit/modules/api/partials/search-v1.json +++ b/test/unit/modules/api/partials/search-v1.json @@ -1,171 +1,141 @@ { "objects": [ - { - "package": { - "name": "verdaccio", - "scope": "unscoped", - "version": "5.0.4", - "description": "A lightweight private npm proxy registry", - "keywords": [ - "private", - "package", - "repository", - "registry", - "enterprise", - "modules", - "proxy", - "server", - "verdaccio" - ], - "date": "2021-04-28T05:24:23.696Z", - "links": { - "npm": "https://www.npmjs.com/package/verdaccio", - "homepage": "https://verdaccio.org", - "repository": "https://github.com/verdaccio/verdaccio", - "bugs": "https://github.com/verdaccio/verdaccio/issues" - }, - "author": { - "name": "Verdaccio Maintainers", - "email": "verdaccio.npm@gmail.com", - "username": "verdaccio.npm" - }, - "publisher": { - "username": "verdaccio.npm", - "email": "verdaccio.npm@gmail.com" - }, - "maintainers": [ - { - "username": "jotadeveloper", - "email": "juanpicado19@gmail.com" - }, - { - "username": "ayusharma", - "email": "ayush.aceit@gmail.com" - }, - { - "username": "trentearl", - "email": "trent@trentearl.com" - }, - { - "username": "jmwilkinson", - "email": "J.Wilkinson@f5.com" - }, - { - "username": "sergiohgz", - "email": "sergio@sergiohgz.eu" - }, - { - "username": "verdaccio.npm", - "email": "verdaccio.npm@gmail.com" - } - ] + { + "package": { + "name": "verdaccio", + "scope": "unscoped", + "version": "5.0.4", + "description": "A lightweight private npm proxy registry", + "keywords": ["private", "package", "repository", "registry", "enterprise", "modules", "proxy", "server", "verdaccio"], + "date": "2021-04-28T05:24:23.696Z", + "links": { + "npm": "https://www.npmjs.com/package/verdaccio", + "homepage": "https://verdaccio.org", + "repository": "https://github.com/verdaccio/verdaccio", + "bugs": "https://github.com/verdaccio/verdaccio/issues" + }, + "author": { + "name": "Verdaccio Maintainers", + "email": "verdaccio.npm@gmail.com", + "username": "verdaccio.npm" + }, + "publisher": { + "username": "verdaccio.npm", + "email": "verdaccio.npm@gmail.com" + }, + "maintainers": [ + { + "username": "jotadeveloper", + "email": "juanpicado19@gmail.com" }, - "score": { - "final": 0.3753957330043509, - "detail": { - "quality": 0.5818552769606854, - "popularity": 0.24049280928422478, - "maintenance": 0.3333333333333333 - } + { + "username": "ayusharma", + "email": "ayush.aceit@gmail.com" }, - "searchScore": 100000.37 + { + "username": "trentearl", + "email": "trent@trentearl.com" + }, + { + "username": "jmwilkinson", + "email": "J.Wilkinson@f5.com" + }, + { + "username": "sergiohgz", + "email": "sergio@sergiohgz.eu" + }, + { + "username": "verdaccio.npm", + "email": "verdaccio.npm@gmail.com" + } + ] }, - { - "package": { - "name": "verdaccio-bitbucket", - "scope": "unscoped", - "version": "3.0.1", - "description": "Verdaccio module to authenticate users via Bitbucket", - "keywords": [ - "sinopia", - "verdaccio", - "bitbucket", - "atlassian", - "auth", - "node", - "nodejs", - "js", - "javascript" - ], - "date": "2020-11-17T18:31:50.893Z", - "links": { - "npm": "https://www.npmjs.com/package/verdaccio-bitbucket" - }, - "author": { - "name": "Idan Gozlan", - "email": "idangozlan@gmail.com", - "username": "idangozlan" - }, - "publisher": { - "username": "idangozlan", - "email": "idangozlan@gmail.com" - }, - "maintainers": [ - { - "username": "idangozlan", - "email": "idangozlan@gmail.com" - } - ] - }, - "score": { - "final": 0.3976271898729222, - "detail": { - "quality": 0.933162858363102, - "popularity": 0.004198585559205135, - "maintenance": 0.3320252211950568 - } - }, - "searchScore": 0.0006275179 + "score": { + "final": 0.3753957330043509, + "detail": { + "quality": 0.5818552769606854, + "popularity": 0.24049280928422478, + "maintenance": 0.3333333333333333 + } }, - { - "package": { - "name": "verdaccio-auth-bitbucket", - "scope": "unscoped", - "version": "2.0.3", - "description": "Verdaccio module to authenticate users via Bitbucket", - "keywords": [ - "sinopia", - "verdaccio", - "bitbucket", - "atlassian", - "auth", - "node", - "nodejs", - "js", - "javascript" - ], - "date": "2020-11-12T16:44:32.807Z", - "links": { - "npm": "https://www.npmjs.com/package/verdaccio-auth-bitbucket", - "homepage": "https://github.com/tomamatics/verdaccio-bitbucket#readme", - "repository": "https://github.com/tomamatics/verdaccio-bitbucket", - "bugs": "https://github.com/tomamatics/verdaccio-bitbucket/issues" - }, - "author": { - "name": "Tom Pachtner", - "email": "tompachtner@gmail.com" - }, - "publisher": { - "username": "tomamatics", - "email": "tom@pachtner.net" - }, - "maintainers": [ - { - "username": "tomamatics", - "email": "tom@pachtner.net" - } - ] - }, - "score": { - "final": 0.3732625146140655, - "detail": { - "quality": 0.8526588061592506, - "popularity": 0.0026266847120729533, - "maintenance": 0.33298723747732817 - } - }, - "searchScore": 0.00021836061 - } + "searchScore": 100000.37 + }, + { + "package": { + "name": "verdaccio-bitbucket", + "scope": "unscoped", + "version": "3.0.1", + "description": "Verdaccio module to authenticate users via Bitbucket", + "keywords": ["sinopia", "verdaccio", "bitbucket", "atlassian", "auth", "node", "nodejs", "js", "javascript"], + "date": "2020-11-17T18:31:50.893Z", + "links": { + "npm": "https://www.npmjs.com/package/verdaccio-bitbucket" + }, + "author": { + "name": "Idan Gozlan", + "email": "idangozlan@gmail.com", + "username": "idangozlan" + }, + "publisher": { + "username": "idangozlan", + "email": "idangozlan@gmail.com" + }, + "maintainers": [ + { + "username": "idangozlan", + "email": "idangozlan@gmail.com" + } + ] + }, + "score": { + "final": 0.3976271898729222, + "detail": { + "quality": 0.933162858363102, + "popularity": 0.004198585559205135, + "maintenance": 0.3320252211950568 + } + }, + "searchScore": 0.0006275179 + }, + { + "package": { + "name": "verdaccio-auth-bitbucket", + "scope": "unscoped", + "version": "2.0.3", + "description": "Verdaccio module to authenticate users via Bitbucket", + "keywords": ["sinopia", "verdaccio", "bitbucket", "atlassian", "auth", "node", "nodejs", "js", "javascript"], + "date": "2020-11-12T16:44:32.807Z", + "links": { + "npm": "https://www.npmjs.com/package/verdaccio-auth-bitbucket", + "homepage": "https://github.com/tomamatics/verdaccio-bitbucket#readme", + "repository": "https://github.com/tomamatics/verdaccio-bitbucket", + "bugs": "https://github.com/tomamatics/verdaccio-bitbucket/issues" + }, + "author": { + "name": "Tom Pachtner", + "email": "tompachtner@gmail.com" + }, + "publisher": { + "username": "tomamatics", + "email": "tom@pachtner.net" + }, + "maintainers": [ + { + "username": "tomamatics", + "email": "tom@pachtner.net" + } + ] + }, + "score": { + "final": 0.3732625146140655, + "detail": { + "quality": 0.8526588061592506, + "popularity": 0.0026266847120729533, + "maintenance": 0.33298723747732817 + } + }, + "searchScore": 0.00021836061 + } ], "total": 213, "time": "Fri May 14 2021 21:05:27 GMT+0000 (UTC)" diff --git a/test/unit/modules/api/publish.spec.ts b/test/unit/modules/api/publish.spec.ts index 58c1e6236..ff6361092 100644 --- a/test/unit/modules/api/publish.spec.ts +++ b/test/unit/modules/api/publish.spec.ts @@ -1,11 +1,5 @@ -import { - addVersion, - uploadPackageTarball, - removeTarball, - unPublishPackage, - publishPackage -} from '../../../../src/api/endpoint/api/publish'; -import { HTTP_STATUS, API_ERROR } from '../../../../src/lib/constants'; +import { addVersion, publishPackage, removeTarball, unPublishPackage, uploadPackageTarball } from '../../../../src/api/endpoint/api/publish'; +import { API_ERROR, HTTP_STATUS } from '../../../../src/lib/constants'; const REVISION_MOCK = '15-e53a77096b0ee33e'; @@ -21,12 +15,12 @@ describe('Publish endpoints - add a tag', () => { params: { version: '1.0.0', tag: 'tag', - package: 'verdaccio' + package: 'verdaccio', }, - body: '' + body: '', }; res = { - status: jest.fn() + status: jest.fn(), }; next = jest.fn(); @@ -41,7 +35,7 @@ describe('Publish endpoints - add a tag', () => { expect(tag).toEqual(req.params.tag); cb(); done(); - } + }, }; // @ts-ignore @@ -55,11 +49,11 @@ describe('Publish endpoints - add a tag', () => { const storage = { addVersion: (packageName, version, body, tag, cb) => { const error = { - message: 'failure' + message: 'failure', }; cb(error); done(); - } + }, }; // @ts-ignore @@ -81,10 +75,10 @@ describe('Publish endpoints - upload package tarball', () => { req = { params: { filename: 'verdaccio.gzip', - package: 'verdaccio' + package: 'verdaccio', }, pipe: jest.fn(), - on: jest.fn() + on: jest.fn(), }; res = { status: jest.fn(), report_error: jest.fn() }; next = jest.fn(); @@ -94,14 +88,14 @@ describe('Publish endpoints - upload package tarball', () => { const stream = { done: jest.fn(), abort: jest.fn(), - on: jest.fn(() => (status, cb) => cb()) + on: jest.fn(() => (status, cb) => cb()), }; const storage = { addTarball(packageName, filename) { expect(packageName).toEqual(req.params.package); expect(filename).toEqual(req.params.filename); return stream; - } + }, }; // @ts-ignore @@ -124,8 +118,8 @@ describe('Publish endpoints - delete tarball', () => { params: { filename: 'verdaccio.gzip', package: 'verdaccio', - revision: REVISION_MOCK - } + revision: REVISION_MOCK, + }, }; res = { status: jest.fn() }; next = jest.fn(); @@ -139,7 +133,7 @@ describe('Publish endpoints - delete tarball', () => { expect(revision).toEqual(req.params.revision); cb(); done(); - } + }, }; // @ts-ignore @@ -150,13 +144,13 @@ describe('Publish endpoints - delete tarball', () => { test('failed while deleting the tarball', (done) => { const error = { - message: 'deletion failed' + message: 'deletion failed', }; const storage = { removeTarball(packageName, filename, revision, cb) { cb(error); done(); - } + }, }; // @ts-ignore @@ -176,8 +170,8 @@ describe('Publish endpoints - un-publish package', () => { beforeEach(() => { req = { params: { - package: 'verdaccio' - } + package: 'verdaccio', + }, }; res = { status: jest.fn() }; next = jest.fn(); @@ -189,7 +183,7 @@ describe('Publish endpoints - un-publish package', () => { expect(packageName).toEqual(req.params.package); cb(); done(); - } + }, }; // @ts-ignore @@ -200,13 +194,13 @@ describe('Publish endpoints - un-publish package', () => { test('un-publish failed', (done) => { const error = { - message: 'un-publish failed' + message: 'un-publish failed', }; const storage = { removePackage(packageName, cb) { cb(error); done(); - } + }, }; // @ts-ignore @@ -226,11 +220,11 @@ describe('Publish endpoints - publish package', () => { beforeEach(() => { req = { body: { - name: 'verdaccio' + name: 'verdaccio', }, params: { - package: 'verdaccio' - } + package: 'verdaccio', + }, }; res = { status: jest.fn() }; next = jest.fn(); @@ -238,7 +232,7 @@ describe('Publish endpoints - publish package', () => { test('should change the existing package', () => { const storage = { - changePackage: jest.fn() + changePackage: jest.fn(), }; req.params._rev = REVISION_MOCK; @@ -250,7 +244,7 @@ describe('Publish endpoints - publish package', () => { test('should publish a new a new package', () => { const storage = { - addPackage: jest.fn() + addPackage: jest.fn(), }; // @ts-ignore @@ -262,7 +256,7 @@ describe('Publish endpoints - publish package', () => { const storage = { addPackage() { throw new Error(); - } + }, }; // @ts-ignore @@ -276,23 +270,23 @@ describe('Publish endpoints - publish package', () => { changePackage: jest.fn(), getPackage({ callback }) { callback(null, { - users: {} + users: {}, }); - } + }, }; req = { params: { - package: 'verdaccio' + package: 'verdaccio', }, body: { _rev: REVISION_MOCK, users: { - verdaccio: true - } + verdaccio: true, + }, }, remote_user: { - name: 'verdaccio' - } + name: 'verdaccio', + }, }; // @ts-ignore diff --git a/test/unit/modules/api/token.spec.ts b/test/unit/modules/api/token.spec.ts index 75c0b318c..787fb332a 100644 --- a/test/unit/modules/api/token.spec.ts +++ b/test/unit/modules/api/token.spec.ts @@ -1,17 +1,16 @@ -import path from 'path'; - -import configDefault from '../../partials/config'; -import endPointAPI from '../../../../src/api'; - -import { HEADERS, HTTP_STATUS, HEADER_TYPE, TOKEN_BEARER, API_ERROR, SUPPORT_ERRORS } from '../../../../src/lib/constants'; -import { mockServer } from '../../__helper/mock'; -import { DOMAIN_SERVERS } from '../../../functional/config.functional'; -import { getNewToken } from '../../__helper/api'; -import { buildToken } from '../../../../src/lib/utils'; import _ from 'lodash'; +import path from 'path'; import rimraf from 'rimraf'; import request from 'supertest'; +import endPointAPI from '../../../../src/api'; +import { API_ERROR, HEADERS, HEADER_TYPE, HTTP_STATUS, SUPPORT_ERRORS, TOKEN_BEARER } from '../../../../src/lib/constants'; +import { buildToken } from '../../../../src/lib/utils'; +import { DOMAIN_SERVERS } from '../../../functional/config.functional'; +import { getNewToken } from '../../__helper/api'; +import { mockServer } from '../../__helper/mock'; +import configDefault from '../../partials/config'; + require('../../../../src/lib/logger').setup([{ type: 'stdout', format: 'pretty', level: 'trace' }]); const credentials = { name: 'jota_token', password: 'secretPass' }; diff --git a/test/unit/modules/api/validate.api.params.middleware.spec.ts b/test/unit/modules/api/validate.api.params.middleware.spec.ts index e99dbd037..a0392d7b3 100644 --- a/test/unit/modules/api/validate.api.params.middleware.spec.ts +++ b/test/unit/modules/api/validate.api.params.middleware.spec.ts @@ -1,6 +1,6 @@ // ensure that all arguments are validated -import path from 'path'; import fs from 'fs'; +import path from 'path'; /** * Validate. diff --git a/test/unit/modules/auth/auth-utils.spec.ts b/test/unit/modules/auth/auth-utils.spec.ts index 968db6d59..d566cd578 100644 --- a/test/unit/modules/auth/auth-utils.spec.ts +++ b/test/unit/modules/auth/auth-utils.spec.ts @@ -1,24 +1,18 @@ +import _ from 'lodash'; + +import { Config, RemoteUser, Security } from '@verdaccio/types'; + import Auth from '../../../../src/lib/auth'; +import { buildUserBuffer, getApiToken, getAuthenticatedMessage, getMiddlewareCredentials, getSecurity } from '../../../../src/lib/auth-utils'; +import AppConfig from '../../../../src/lib/config'; import { CHARACTER_ENCODING, TOKEN_BEARER } from '../../../../src/lib/constants'; +import { aesDecrypt, verifyPayload } from '../../../../src/lib/crypto-utils'; +import { setup } from '../../../../src/lib/logger'; +import { buildToken, convertPayloadToBase64, parseConfigFile } from '../../../../src/lib/utils'; +import { IAuth } from '../../../../types'; +import { parseConfigurationFile } from '../../__helper'; // $FlowFixMe import configExample from '../../partials/config'; -import AppConfig from '../../../../src/lib/config'; -import { setup } from '../../../../src/lib/logger'; - -import { buildToken, convertPayloadToBase64, parseConfigFile } from '../../../../src/lib/utils'; -import { - buildUserBuffer, - getApiToken, - getAuthenticatedMessage, - getMiddlewareCredentials, - getSecurity -} from '../../../../src/lib/auth-utils'; -import { aesDecrypt, verifyPayload } from '../../../../src/lib/crypto-utils'; -import { parseConfigurationFile } from '../../__helper'; - -import { IAuth } from '../../../../types'; -import { Config, Security, RemoteUser } from '@verdaccio/types'; -import _ from 'lodash'; setup([]); @@ -38,14 +32,7 @@ describe('Auth utilities', () => { return config; } - async function signCredentials( - configFileName: string, - username: string, - password: string, - secret = '12345', - methodToSpy: string, - methodNotBeenCalled: string - ): Promise { + async function signCredentials(configFileName: string, username: string, password: string, secret = '12345', methodToSpy: string, methodNotBeenCalled: string): Promise { const config: Config = getConfig(configFileName, secret); const auth: IAuth = new Auth(config); // @ts-ignore @@ -55,7 +42,7 @@ describe('Auth utilities', () => { const user: RemoteUser = { name: username, real_groups: [], - groups: [] + groups: [], }; const token = await getApiToken(auth, config, user, password); expect(spy).toHaveBeenCalled(); @@ -74,9 +61,7 @@ describe('Auth utilities', () => { }; const verifyAES = (token: string, user: string, password: string, secret: string) => { - const payload = aesDecrypt(convertPayloadToBase64(token), secret).toString( - CHARACTER_ENCODING.UTF8 - ); + const payload = aesDecrypt(convertPayloadToBase64(token), secret).toString(CHARACTER_ENCODING.UTF8); const content = payload.split(':'); expect(content[0]).toBe(user); @@ -85,98 +70,49 @@ describe('Auth utilities', () => { describe('getApiToken test', () => { test('should sign token with aes and security missing', async () => { - const token = await signCredentials( - 'security-missing', - 'test', - 'test', - '1234567', - 'aesEncrypt', - 'jwtEncrypt' - ); + const token = await signCredentials('security-missing', 'test', 'test', '1234567', 'aesEncrypt', 'jwtEncrypt'); verifyAES(token, 'test', 'test', '1234567'); expect(_.isString(token)).toBeTruthy(); }); test('should sign token with aes and security empty', async () => { - const token = await signCredentials( - 'security-empty', - 'test', - 'test', - '123456', - 'aesEncrypt', - 'jwtEncrypt' - ); + const token = await signCredentials('security-empty', 'test', 'test', '123456', 'aesEncrypt', 'jwtEncrypt'); verifyAES(token, 'test', 'test', '123456'); expect(_.isString(token)).toBeTruthy(); }); test('should sign token with aes', async () => { - const token = await signCredentials( - 'security-basic', - 'test', - 'test', - '123456', - 'aesEncrypt', - 'jwtEncrypt' - ); + const token = await signCredentials('security-basic', 'test', 'test', '123456', 'aesEncrypt', 'jwtEncrypt'); verifyAES(token, 'test', 'test', '123456'); expect(_.isString(token)).toBeTruthy(); }); test('should sign token with legacy and jwt disabled', async () => { - const token = await signCredentials( - 'security-no-legacy', - 'test', - 'test', - 'x8T#ZCx=2t', - 'aesEncrypt', - 'jwtEncrypt' - ); + const token = await signCredentials('security-no-legacy', 'test', 'test', 'x8T#ZCx=2t', 'aesEncrypt', 'jwtEncrypt'); expect(_.isString(token)).toBeTruthy(); verifyAES(token, 'test', 'test', 'x8T#ZCx=2t'); }); test('should sign token with legacy enabled and jwt enabled', async () => { - const token = await signCredentials( - 'security-jwt-legacy-enabled', - 'test', - 'test', - 'secret', - 'jwtEncrypt', - 'aesEncrypt' - ); + const token = await signCredentials('security-jwt-legacy-enabled', 'test', 'test', 'secret', 'jwtEncrypt', 'aesEncrypt'); verifyJWT(token, 'test', 'test', 'secret'); expect(_.isString(token)).toBeTruthy(); }); test('should sign token with jwt enabled', async () => { - const token = await signCredentials( - 'security-jwt', - 'test', - 'test', - 'secret', - 'jwtEncrypt', - 'aesEncrypt' - ); + const token = await signCredentials('security-jwt', 'test', 'test', 'secret', 'jwtEncrypt', 'aesEncrypt'); expect(_.isString(token)).toBeTruthy(); verifyJWT(token, 'test', 'test', 'secret'); }); test('should sign with jwt whether legacy is disabled', async () => { - const token = await signCredentials( - 'security-legacy-disabled', - 'test', - 'test', - 'secret', - 'jwtEncrypt', - 'aesEncrypt' - ); + const token = await signCredentials('security-legacy-disabled', 'test', 'test', 'secret', 'jwtEncrypt', 'aesEncrypt'); expect(_.isString(token)).toBeTruthy(); verifyJWT(token, 'test', 'test', 'secret'); @@ -195,14 +131,7 @@ describe('Auth utilities', () => { const secret = 'secret'; const user = 'test'; const pass = 'test'; - const token = await signCredentials( - 'security-legacy', - user, - pass, - secret, - 'aesEncrypt', - 'jwtEncrypt' - ); + const token = await signCredentials('security-legacy', user, pass, secret, 'aesEncrypt', 'jwtEncrypt'); const config: Config = getConfig('security-legacy', secret); const security: Security = getSecurity(config); const credentials = getMiddlewareCredentials(security, secret, `Bearer ${token}`); @@ -230,41 +159,19 @@ describe('Auth utilities', () => { test.concurrent('should return empty credential wrong secret key', async () => { const secret = 'secret'; - const token = await signCredentials( - 'security-legacy', - 'test', - 'test', - secret, - 'aesEncrypt', - 'jwtEncrypt' - ); + const token = await signCredentials('security-legacy', 'test', 'test', secret, 'aesEncrypt', 'jwtEncrypt'); const config: Config = getConfig('security-legacy', secret); const security: Security = getSecurity(config); - const credentials = getMiddlewareCredentials( - security, - 'BAD_SECRET', - buildToken(TOKEN_BEARER, token) - ); + const credentials = getMiddlewareCredentials(security, 'BAD_SECRET', buildToken(TOKEN_BEARER, token)); expect(credentials).not.toBeDefined(); }); test.concurrent('should return empty credential wrong scheme', async () => { const secret = 'secret'; - const token = await signCredentials( - 'security-legacy', - 'test', - 'test', - secret, - 'aesEncrypt', - 'jwtEncrypt' - ); + const token = await signCredentials('security-legacy', 'test', 'test', secret, 'aesEncrypt', 'jwtEncrypt'); const config: Config = getConfig('security-legacy', secret); const security: Security = getSecurity(config); - const credentials = getMiddlewareCredentials( - security, - secret, - buildToken('BAD_SCHEME', token) - ); + const credentials = getMiddlewareCredentials(security, secret, buildToken('BAD_SCHEME', token)); expect(credentials).not.toBeDefined(); }); @@ -274,11 +181,7 @@ describe('Auth utilities', () => { const auth: IAuth = new Auth(config); const token = auth.aesEncrypt(Buffer.from(`corruptedBuffer`)).toString('base64'); const security: Security = getSecurity(config); - const credentials = getMiddlewareCredentials( - security, - secret, - buildToken(TOKEN_BEARER, token) - ); + const credentials = getMiddlewareCredentials(security, secret, buildToken(TOKEN_BEARER, token)); expect(credentials).not.toBeDefined(); }); }); @@ -287,11 +190,7 @@ describe('Auth utilities', () => { test('should return anonymous whether token is corrupted', () => { const config: Config = getConfig('security-jwt', '12345'); const security: Security = getSecurity(config); - const credentials = getMiddlewareCredentials( - security, - '12345', - buildToken(TOKEN_BEARER, 'fakeToken') - ); + const credentials = getMiddlewareCredentials(security, '12345', buildToken(TOKEN_BEARER, 'fakeToken')); expect(credentials).toBeDefined(); // @ts-ignore @@ -305,11 +204,7 @@ describe('Auth utilities', () => { test('should return anonymous whether token and scheme are corrupted', () => { const config: Config = getConfig('security-jwt', '12345'); const security: Security = getSecurity(config); - const credentials = getMiddlewareCredentials( - security, - '12345', - buildToken('FakeScheme', 'fakeToken') - ); + const credentials = getMiddlewareCredentials(security, '12345', buildToken('FakeScheme', 'fakeToken')); expect(credentials).not.toBeDefined(); }); @@ -318,20 +213,9 @@ describe('Auth utilities', () => { const secret = 'secret'; const user = 'test'; const config: Config = getConfig('security-jwt', secret); - const token = await signCredentials( - 'security-jwt', - user, - 'secretTest', - secret, - 'jwtEncrypt', - 'aesEncrypt' - ); + const token = await signCredentials('security-jwt', user, 'secretTest', secret, 'jwtEncrypt', 'aesEncrypt'); const security: Security = getSecurity(config); - const credentials = getMiddlewareCredentials( - security, - secret, - buildToken(TOKEN_BEARER, token) - ); + const credentials = getMiddlewareCredentials(security, secret, buildToken(TOKEN_BEARER, token)); expect(credentials).toBeDefined(); // @ts-ignore expect(credentials.name).toEqual(user); diff --git a/test/unit/modules/auth/jwt.spec.ts b/test/unit/modules/auth/jwt.spec.ts index 6d08c8b05..63729416b 100644 --- a/test/unit/modules/auth/jwt.spec.ts +++ b/test/unit/modules/auth/jwt.spec.ts @@ -1,25 +1,17 @@ import path from 'path'; - -import endPointAPI from '../../../../src/api'; - -import { - HEADERS, - HTTP_STATUS, - HEADER_TYPE, - TOKEN_BEARER, - TOKEN_BASIC, - API_ERROR -} from '../../../../src/lib/constants'; -import { mockServer } from '../../__helper/mock'; -import { DOMAIN_SERVERS } from '../../../functional/config.functional'; -import { buildToken } from '../../../../src/lib/utils'; -import { addUser, getPackage, loginUserToken } from '../../__helper/api'; -import { setup } from '../../../../src/lib/logger'; -import configDefault from '../../partials/config'; -import { buildUserBuffer } from '../../../../src/lib/auth-utils'; import rimraf from 'rimraf'; import request from 'supertest'; +import endPointAPI from '../../../../src/api'; +import { buildUserBuffer } from '../../../../src/lib/auth-utils'; +import { API_ERROR, HEADERS, HEADER_TYPE, HTTP_STATUS, TOKEN_BASIC, TOKEN_BEARER } from '../../../../src/lib/constants'; +import { setup } from '../../../../src/lib/logger'; +import { buildToken } from '../../../../src/lib/utils'; +import { DOMAIN_SERVERS } from '../../../functional/config.functional'; +import { addUser, getPackage, loginUserToken } from '../../__helper/api'; +import { mockServer } from '../../__helper/mock'; +import configDefault from '../../partials/config'; + setup([]); const credentials = { name: 'JotaJWT', password: 'secretPass' }; @@ -40,16 +32,16 @@ describe('endpoint user auth JWT unit test', () => { storage: store, uplinks: { npmjs: { - url: `http://${DOMAIN_SERVERS}:${mockServerPort}` - } + url: `http://${DOMAIN_SERVERS}:${mockServerPort}`, + }, }, self_path: store, auth: { htpasswd: { - file: './test-jwt-storage/.htpasswd_jwt_auth' - } + file: './test-jwt-storage/.htpasswd_jwt_auth', + }, }, - logs: [{ type: 'stdout', format: 'pretty', level: 'warn' }] + logs: [{ type: 'stdout', format: 'pretty', level: 'warn' }], }, 'api-jwt/jwt.yaml' ); @@ -82,12 +74,7 @@ describe('endpoint user auth JWT unit test', () => { expect(resp1.body).toBeDefined(); expect(resp1.body.name).toMatch('vue'); - const [err2, resp2] = await getPackage( - request(app), - FAKE_TOKEN, - 'vue', - HTTP_STATUS.UNAUTHORIZED - ); + const [err2, resp2] = await getPackage(request(app), FAKE_TOKEN, 'vue', HTTP_STATUS.UNAUTHORIZED); expect(err2).toBeNull(); expect(resp2.statusCode).toBe(HTTP_STATUS.UNAUTHORIZED); expect(resp2.body.error).toMatch(FORBIDDEN_VUE); @@ -121,12 +108,7 @@ describe('endpoint user auth JWT unit test', () => { }); test('should fails on try to access with corrupted token', async (done) => { - const [err2, resp2] = await getPackage( - request(app), - FAKE_TOKEN, - 'vue', - HTTP_STATUS.UNAUTHORIZED - ); + const [err2, resp2] = await getPackage(request(app), FAKE_TOKEN, 'vue', HTTP_STATUS.UNAUTHORIZED); expect(err2).toBeNull(); expect(resp2.statusCode).toBe(HTTP_STATUS.UNAUTHORIZED); expect(resp2.body.error).toMatch(FORBIDDEN_VUE); @@ -146,13 +128,7 @@ describe('endpoint user auth JWT unit test', () => { // we login when token is valid const newCredentials = { name: 'newFailsUser', password: 'BAD_PASSWORD' }; - const [err2, resp2] = await loginUserToken( - request(app), - newCredentials.name, - newCredentials, - token, - HTTP_STATUS.UNAUTHORIZED - ); + const [err2, resp2] = await loginUserToken(request(app), newCredentials.name, newCredentials, token, HTTP_STATUS.UNAUTHORIZED); expect(err2).toBeNull(); expect(resp2.statusCode).toBe(HTTP_STATUS.UNAUTHORIZED); expect(resp2.body.error).toMatch(API_ERROR.BAD_USERNAME_PASSWORD); diff --git a/test/unit/modules/auth/profile.spec.ts b/test/unit/modules/auth/profile.spec.ts index eb8788783..734419f92 100644 --- a/test/unit/modules/auth/profile.spec.ts +++ b/test/unit/modules/auth/profile.spec.ts @@ -1,15 +1,15 @@ +import _ from 'lodash'; import path from 'path'; +import rimraf from 'rimraf'; +import request from 'supertest'; import endPointAPI from '../../../../src/api'; -import { mockServer } from '../../__helper/mock'; +import { API_ERROR, HTTP_STATUS, SUPPORT_ERRORS } from '../../../../src/lib/constants'; +import { setup } from '../../../../src/lib/logger'; import { parseConfigFile } from '../../../../src/lib/utils'; import { parseConfigurationFile } from '../../__helper'; import { getNewToken, getProfile, postProfile } from '../../__helper/api'; -import { setup } from '../../../../src/lib/logger'; -import { API_ERROR, HTTP_STATUS, SUPPORT_ERRORS } from '../../../../src/lib/constants'; -import rimraf from 'rimraf'; -import _ from 'lodash'; -import request from 'supertest'; +import { mockServer } from '../../__helper/mock'; setup([]); @@ -31,10 +31,10 @@ describe('endpoint user profile', () => { storage: store, auth: { htpasswd: { - file: './test-profile-storage/.htpasswd-auth-profile' - } + file: './test-profile-storage/.htpasswd-auth-profile', + }, }, - self_path: store + self_path: store, }); app = await endPointAPI(configForTest); mockRegistry = await mockServer(mockServerPort).init(); @@ -63,8 +63,8 @@ describe('endpoint user profile', () => { const body = { password: { new: '12345678', - old: credentials.password - } + old: credentials.password, + }, }; const token = await getNewToken(request(app), credentials); const [err1, res1] = await postProfile(request(app), body, token); @@ -79,8 +79,8 @@ describe('endpoint user profile', () => { const body = { password: { new: 'p1', - old: credentials.password - } + old: credentials.password, + }, }; const token = await getNewToken(request(app), credentials); const [, resp] = await postProfile(request(app), body, token, HTTP_STATUS.UNAUTHORIZED); @@ -96,15 +96,10 @@ describe('endpoint user profile', () => { test('should report TFA is disabled', async (done) => { const credentials = { name: 'userTest2002', password: 'secretPass002' }; const body = { - tfa: {} + tfa: {}, }; const token = await getNewToken(request(app), credentials); - const [, resp] = await postProfile( - request(app), - body, - token, - HTTP_STATUS.SERVICE_UNAVAILABLE - ); + const [, resp] = await postProfile(request(app), body, token, HTTP_STATUS.SERVICE_UNAVAILABLE); expect(resp.error).not.toBeNull(); expect(resp.error.text).toMatch(SUPPORT_ERRORS.TFA_DISABLED); diff --git a/test/unit/modules/basic_system.spec.ts b/test/unit/modules/basic_system.spec.ts index 313508cd8..4bcfd8fc5 100644 --- a/test/unit/modules/basic_system.spec.ts +++ b/test/unit/modules/basic_system.spec.ts @@ -1,11 +1,11 @@ -import { API_ERROR } from '../../../src/lib/constants'; -import endPointAPI from '../../../src/api/index'; -import config from '../partials/config/index'; - -import { setup } from '../../../src/lib/logger'; -import rimraf from 'rimraf'; -import request from 'request'; import express from 'express'; +import request from 'request'; +import rimraf from 'rimraf'; + +import endPointAPI from '../../../src/api/index'; +import { API_ERROR } from '../../../src/lib/constants'; +import { setup } from '../../../src/lib/logger'; +import config from '../partials/config/index'; setup([{ type: 'stdout', format: 'pretty', level: 'trace' }]); diff --git a/test/unit/modules/cli/cli.spec.ts b/test/unit/modules/cli/cli.spec.ts index c62f8a587..e4a444936 100644 --- a/test/unit/modules/cli/cli.spec.ts +++ b/test/unit/modules/cli/cli.spec.ts @@ -1,15 +1,15 @@ -import path from 'path'; -import os from 'os'; import fs from 'fs'; +import _ from 'lodash'; +import os from 'os'; +import path from 'path'; +import selfsigned from 'selfsigned'; import startServer from '../../../../src'; -import config from '../../partials/config'; -import { DEFAULT_DOMAIN, DEFAULT_PORT, DEFAULT_PROTOCOL } from '../../../../src/lib/constants'; import { getListListenAddresses } from '../../../../src/lib/cli/utils'; -import { parseConfigFile } from '../../../../src/lib/utils'; +import { DEFAULT_DOMAIN, DEFAULT_PORT, DEFAULT_PROTOCOL } from '../../../../src/lib/constants'; import { logger } from '../../../../src/lib/logger'; -import selfsigned from 'selfsigned'; -import _ from 'lodash'; +import { parseConfigFile } from '../../../../src/lib/utils'; +import config from '../../partials/config'; jest.mock('../../../../src/lib/logger', () => ({ setup: jest.fn(), diff --git a/test/unit/modules/cli/parseAddress.spec.ts b/test/unit/modules/cli/parseAddress.spec.ts index 30f7e10c8..6420201bb 100644 --- a/test/unit/modules/cli/parseAddress.spec.ts +++ b/test/unit/modules/cli/parseAddress.spec.ts @@ -1,7 +1,8 @@ -import { parseAddress as parse } from '../../../../src/lib/utils'; -import { DEFAULT_DOMAIN, DEFAULT_PORT } from '../../../../src/lib/constants'; import _ from 'lodash'; +import { DEFAULT_DOMAIN, DEFAULT_PORT } from '../../../../src/lib/constants'; +import { parseAddress as parse } from '../../../../src/lib/utils'; + describe('Parse listen address', () => { const useCases: any[] = []; @@ -39,12 +40,12 @@ describe('Parse listen address', () => { expect(parsed).toEqual({ proto, host, - port + port, }); } else { expect(parsed).toEqual({ proto, - path: host + path: host, }); } }); diff --git a/test/unit/modules/config/config.spec.ts b/test/unit/modules/config/config.spec.ts index 2b743755d..f07706d59 100644 --- a/test/unit/modules/config/config.spec.ts +++ b/test/unit/modules/config/config.spec.ts @@ -1,10 +1,10 @@ +import _ from 'lodash'; import path from 'path'; import Config from '../../../../src/lib/config'; -import { parseConfigFile } from '../../../../src/lib/utils'; import { DEFAULT_REGISTRY, DEFAULT_UPLINK, ROLES, WEB_TITLE } from '../../../../src/lib/constants'; import { setup } from '../../../../src/lib/logger'; -import _ from 'lodash'; +import { parseConfigFile } from '../../../../src/lib/utils'; setup([]); diff --git a/test/unit/modules/notifications/notify.spec.ts b/test/unit/modules/notifications/notify.spec.ts index f1df3066e..d31193a68 100644 --- a/test/unit/modules/notifications/notify.spec.ts +++ b/test/unit/modules/notifications/notify.spec.ts @@ -1,27 +1,21 @@ -import { parseConfigurationFile } from '../../__helper'; -import { parseConfigFile } from '../../../../src/lib/utils'; -import { notify } from '../../../../src/lib/notify'; - -import { notifyRequest } from '../../../../src/lib/notify/notify-request'; - import { setup } from '../../../../src/lib/logger'; +import { notify } from '../../../../src/lib/notify'; +import { notifyRequest } from '../../../../src/lib/notify/notify-request'; +import { parseConfigFile } from '../../../../src/lib/utils'; +import { parseConfigurationFile } from '../../__helper'; setup([]); jest.mock('./../../../../src/lib/notify/notify-request', () => ({ - notifyRequest: jest.fn((options, content) => Promise.resolve([options, content])) + notifyRequest: jest.fn((options, content) => Promise.resolve([options, content])), })); const parseConfigurationNotifyFile = (name) => { return parseConfigurationFile(`notify/${name}`); }; const singleNotificationConfig = parseConfigFile(parseConfigurationNotifyFile('single.notify')); -const singleHeaderNotificationConfig = parseConfigFile( - parseConfigurationNotifyFile('single.header.notify') -); -const packagePatternNotificationConfig = parseConfigFile( - parseConfigurationNotifyFile('single.packagePattern.notify') -); +const singleHeaderNotificationConfig = parseConfigFile(parseConfigurationNotifyFile('single.header.notify')); +const packagePatternNotificationConfig = parseConfigFile(parseConfigurationNotifyFile('single.packagePattern.notify')); const multiNotificationConfig = parseConfigFile(parseConfigurationNotifyFile('multiple.notify')); describe('Notifications:: Notify', () => { diff --git a/test/unit/modules/notifications/request.spec.ts b/test/unit/modules/notifications/request.spec.ts index d7f0ff752..3d3c9ed5e 100644 --- a/test/unit/modules/notifications/request.spec.ts +++ b/test/unit/modules/notifications/request.spec.ts @@ -1,4 +1,5 @@ -import { HTTP_STATUS, API_ERROR } from '../../../../src/lib/constants'; +import { API_ERROR, HTTP_STATUS } from '../../../../src/lib/constants'; + /* eslint-disable @typescript-eslint/no-var-requires */ /** @@ -8,8 +9,8 @@ const logger = { logger: { error: jest.fn(), debug: jest.fn(), - info: jest.fn() - } + info: jest.fn(), + }, }; jest.doMock('../../../../src/lib/logger', () => logger); @@ -17,7 +18,7 @@ jest.doMock('../../../../src/lib/logger', () => logger); * Test Data */ const options = { - url: 'http://slack-service' + url: 'http://slack-service', }; const content = 'Verdaccio@x.x.x successfully published'; @@ -29,19 +30,16 @@ describe('Notifications:: notifyRequest', () => { test('when notification service throws error', async () => { jest.doMock('request', () => (options, resolver) => { const response = { - statusCode: HTTP_STATUS.BAD_REQUEST + statusCode: HTTP_STATUS.BAD_REQUEST, }; const error = { - message: API_ERROR.BAD_DATA + message: API_ERROR.BAD_DATA, }; resolver(error, response); }); const notification = require('../../../../src/lib/notify/notify-request'); - const args = [ - { errorMessage: 'bad data' }, - 'notify service has thrown an error: @{errorMessage}' - ]; + const args = [{ errorMessage: 'bad data' }, 'notify service has thrown an error: @{errorMessage}']; await expect(notification.notifyRequest(options, content)).rejects.toEqual(API_ERROR.BAD_DATA); expect(logger.logger.error).toHaveBeenCalledWith(...args); @@ -51,17 +49,14 @@ describe('Notifications:: notifyRequest', () => { jest.doMock('request', () => (options, resolver) => { const response = { statusCode: HTTP_STATUS.BAD_REQUEST, - body: API_ERROR.BAD_DATA + body: API_ERROR.BAD_DATA, }; resolver(null, response); }); const notification = require('../../../../src/lib/notify/notify-request'); - const args = [ - { errorMessage: 'bad data' }, - 'notify service has thrown an error: @{errorMessage}' - ]; + const args = [{ errorMessage: 'bad data' }, 'notify service has thrown an error: @{errorMessage}']; await expect(notification.notifyRequest(options, content)).rejects.toEqual(API_ERROR.BAD_DATA); expect(logger.logger.error).toHaveBeenCalledWith(...args); @@ -71,7 +66,7 @@ describe('Notifications:: notifyRequest', () => { jest.doMock('request', () => (options, resolver) => { const response = { statusCode: HTTP_STATUS.OK, - body: 'Successfully delivered' + body: 'Successfully delivered', }; resolver(null, response, response.body); @@ -81,9 +76,7 @@ describe('Notifications:: notifyRequest', () => { const infoArgs = [{ content }, 'A notification has been shipped: @{content}']; const debugArgs = [{ body: 'Successfully delivered' }, ' body: @{body}']; - await expect(notification.notifyRequest(options, content)).resolves.toEqual( - 'Successfully delivered' - ); + await expect(notification.notifyRequest(options, content)).resolves.toEqual('Successfully delivered'); expect(logger.logger.info).toHaveBeenCalledWith(...infoArgs); expect(logger.logger.debug).toHaveBeenCalledWith(...debugArgs); }); @@ -91,7 +84,7 @@ describe('Notifications:: notifyRequest', () => { test('when notification is successfully delivered but body is undefined/null', async () => { jest.doMock('request', () => (options, resolver) => { const response = { - statusCode: HTTP_STATUS.OK + statusCode: HTTP_STATUS.OK, }; resolver(null, response); diff --git a/test/unit/modules/plugin/auth.spec.ts b/test/unit/modules/plugin/auth.spec.ts index 843d04075..42bbfe281 100644 --- a/test/unit/modules/plugin/auth.spec.ts +++ b/test/unit/modules/plugin/auth.spec.ts @@ -1,13 +1,14 @@ -import Auth from '../../../../src/lib/auth'; -import AppConfig from '../../../../src/lib/config'; -import { setup } from '../../../../src/lib/logger'; +import _ from 'lodash'; -import { IAuth } from '../../../../types'; -import { ROLES } from '../../../../src/lib/constants'; -import { authProfileConf, authPluginFailureConf, authPluginPassThrougConf } from './helper/plugin'; import { getInternalError } from '@verdaccio/commons-api'; import { Config } from '@verdaccio/types'; -import _ from 'lodash'; + +import Auth from '../../../../src/lib/auth'; +import AppConfig from '../../../../src/lib/config'; +import { ROLES } from '../../../../src/lib/constants'; +import { setup } from '../../../../src/lib/logger'; +import { IAuth } from '../../../../types'; +import { authPluginFailureConf, authPluginPassThrougConf, authProfileConf } from './helper/plugin'; setup([]); @@ -34,16 +35,9 @@ describe('AuthTest', () => { expect(callback).toHaveBeenCalledTimes(1); expect(callback).toHaveBeenCalledWith(null, { - groups: [ - 'test', - ROLES.$ALL, - ROLES.$AUTH, - ROLES.DEPRECATED_ALL, - ROLES.DEPRECATED_AUTH, - ROLES.ALL - ], + groups: ['test', ROLES.$ALL, ROLES.$AUTH, ROLES.DEPRECATED_ALL, ROLES.DEPRECATED_AUTH, ROLES.ALL], name: 'foo', - real_groups: groups + real_groups: groups, }); }); diff --git a/test/unit/modules/plugin/helper/plugin.ts b/test/unit/modules/plugin/helper/plugin.ts index d16fb9e06..9a3e8ab0b 100644 --- a/test/unit/modules/plugin/helper/plugin.ts +++ b/test/unit/modules/plugin/helper/plugin.ts @@ -1,20 +1,21 @@ import path from 'path'; + import config from '../../../partials/config'; export const authProfileConf = config({ auth: { - [`${path.join(__dirname, '../../../partials/plugin/authenticate.success')}`]: {} - } + [`${path.join(__dirname, '../../../partials/plugin/authenticate.success')}`]: {}, + }, }); export const authPluginFailureConf = config({ auth: { - [`${path.join(__dirname, '../../../partials/plugin/authenticate.fail')}`]: {} - } + [`${path.join(__dirname, '../../../partials/plugin/authenticate.fail')}`]: {}, + }, }); export const authPluginPassThrougConf = config({ auth: { - [`${path.join(__dirname, '../../../partials/plugin/authenticate.passthroug')}`]: {} - } + [`${path.join(__dirname, '../../../partials/plugin/authenticate.passthroug')}`]: {}, + }, }); diff --git a/test/unit/modules/plugin/partials/test-plugin-storage/invalid-plugin-sanity/index.js b/test/unit/modules/plugin/partials/test-plugin-storage/invalid-plugin-sanity/index.js index bf345d0f2..02aa63e10 100644 --- a/test/unit/modules/plugin/partials/test-plugin-storage/invalid-plugin-sanity/index.js +++ b/test/unit/modules/plugin/partials/test-plugin-storage/invalid-plugin-sanity/index.js @@ -2,8 +2,8 @@ function ValidVerdaccioPlugin() { return { // not valid method // eslint-disable-next-line @typescript-eslint/no-empty-function - authenticate__: function(){} - } + authenticate__: function () {}, + }; } module.exports = ValidVerdaccioPlugin; diff --git a/test/unit/modules/plugin/partials/test-plugin-storage/verdaccio-es6-plugin/dummy.js b/test/unit/modules/plugin/partials/test-plugin-storage/verdaccio-es6-plugin/dummy.js index 14173f478..e65a2399b 100644 --- a/test/unit/modules/plugin/partials/test-plugin-storage/verdaccio-es6-plugin/dummy.js +++ b/test/unit/modules/plugin/partials/test-plugin-storage/verdaccio-es6-plugin/dummy.js @@ -1,17 +1,42 @@ /* eslint-disable max-len */ // this is how a Babel.js transpiled plugin looks like -"use strict"; +'use strict'; -Object.defineProperty(exports, "__esModule", { - value: true +Object.defineProperty(exports, '__esModule', { + value: true, }); -let _createClass = function () { function defineProperties(target, props) { for (let i = 0; i < props.length; i++) { let descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) {descriptor.writable = true;} Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) {defineProperties(Constructor.prototype, protoProps);} if (staticProps) {defineProperties(Constructor, staticProps);} return Constructor; }; }(); +let _createClass = (function () { + function defineProperties(target, props) { + for (let i = 0; i < props.length; i++) { + let descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ('value' in descriptor) { + descriptor.writable = true; + } + Object.defineProperty(target, descriptor.key, descriptor); + } + } + return function (Constructor, protoProps, staticProps) { + if (protoProps) { + defineProperties(Constructor.prototype, protoProps); + } + if (staticProps) { + defineProperties(Constructor, staticProps); + } + return Constructor; + }; +})(); -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError('Cannot call a class as a function'); + } +} -let Dummy = function () { +let Dummy = (function () { function Dummy(config, logger) { _classCallCheck(this, Dummy); @@ -20,12 +45,14 @@ let Dummy = function () { this.data = []; } - _createClass(Dummy, [{ - key: "getPackageStorage", - value: function getPackageStorage() {} - }]); + _createClass(Dummy, [ + { + key: 'getPackageStorage', + value: function getPackageStorage() {}, + }, + ]); return Dummy; -}(); +})(); exports.default = Dummy; diff --git a/test/unit/modules/plugin/partials/test-plugin-storage/verdaccio-es6-plugin/index.js b/test/unit/modules/plugin/partials/test-plugin-storage/verdaccio-es6-plugin/index.js index 34ed1c4a6..ec0693fb4 100644 --- a/test/unit/modules/plugin/partials/test-plugin-storage/verdaccio-es6-plugin/index.js +++ b/test/unit/modules/plugin/partials/test-plugin-storage/verdaccio-es6-plugin/index.js @@ -1,8 +1,8 @@ 'use strict'; /* eslint-disable @typescript-eslint/no-var-requires */ -Object.defineProperty(exports, "__esModule", { - value: true +Object.defineProperty(exports, '__esModule', { + value: true, }); exports.Dummy = undefined; @@ -10,7 +10,9 @@ let _dummy = require('./dummy'); let _dummy2 = _interopRequireDefault(_dummy); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; +} exports.Dummy = _dummy2.default; exports.default = _dummy2.default; diff --git a/test/unit/modules/plugin/partials/test-plugin-storage/verdaccio-plugin/index.js b/test/unit/modules/plugin/partials/test-plugin-storage/verdaccio-plugin/index.js index 7fcfbb17d..c1291e321 100644 --- a/test/unit/modules/plugin/partials/test-plugin-storage/verdaccio-plugin/index.js +++ b/test/unit/modules/plugin/partials/test-plugin-storage/verdaccio-plugin/index.js @@ -1,7 +1,7 @@ function ValidVerdaccioPlugin() { return { - authenticate: function(){} - } + authenticate: function () {}, + }; } module.exports = ValidVerdaccioPlugin; diff --git a/test/unit/modules/plugin/plugin_loader.spec.ts b/test/unit/modules/plugin/plugin_loader.spec.ts index 8a1ec6026..3b189166a 100644 --- a/test/unit/modules/plugin/plugin_loader.spec.ts +++ b/test/unit/modules/plugin/plugin_loader.spec.ts @@ -1,6 +1,7 @@ import path from 'path'; -import loadPlugin from '../../../../src/lib/plugin-loader'; + import { setup } from '../../../../src/lib/logger'; +import loadPlugin from '../../../../src/lib/plugin-loader'; setup([]); @@ -11,8 +12,8 @@ describe('plugin loader', () => { self_path: path.join(__dirname, './'), max_users: 0, auth: { - [`${relativePath}/${name}`]: {} - } + [`${relativePath}/${name}`]: {}, + }, }; }; @@ -45,9 +46,7 @@ describe('plugin loader', () => { return p.authenticate || p.allow_access || p.allow_publish; }); } catch (e) { - expect(e.message).toEqual( - `"${relativePath}/invalid-plugin" plugin does not have the right code structure` - ); + expect(e.message).toEqual(`"${relativePath}/invalid-plugin" plugin does not have the right code structure`); } }); @@ -59,9 +58,7 @@ describe('plugin loader', () => { return plugin.authenticate || plugin.allow_access || plugin.allow_publish; }); } catch (err) { - expect(err.message).toEqual( - `sanity check has failed, "${relativePath}/invalid-plugin-sanity" is not a valid plugin` - ); + expect(err.message).toEqual(`sanity check has failed, "${relativePath}/invalid-plugin-sanity" is not a valid plugin`); } }); diff --git a/test/unit/modules/search/search.spec.ts b/test/unit/modules/search/search.spec.ts index b16fd00d6..b0f85cb12 100644 --- a/test/unit/modules/search/search.spec.ts +++ b/test/unit/modules/search/search.spec.ts @@ -1,8 +1,8 @@ -import Search from '../../../../src/lib/search'; import Config from '../../../../src/lib/config'; +import { setup } from '../../../../src/lib/logger'; +import Search from '../../../../src/lib/search'; import Storage from '../../../../src/lib/storage'; import buildConfig from '../../partials/config'; -import { setup } from '../../../../src/lib/logger'; setup([]); @@ -11,37 +11,37 @@ let packages = [ name: 'test1', description: 'description', _npmUser: { - name: 'test_user' - } + name: 'test_user', + }, }, { name: 'test2', description: 'description', _npmUser: { - name: 'test_user' - } + name: 'test_user', + }, }, { name: 'test3', description: 'description', _npmUser: { - name: 'test_user' - } + name: 'test_user', + }, }, { name: '@verdaccio/scope', description: 'scope', _npmUser: { - name: 'scope_user' - } + name: 'scope_user', + }, }, { name: '@any/scope', description: 'scope', _npmUser: { - name: 'scope_user' - } - } + name: 'scope_user', + }, + }, ]; describe('search', () => { @@ -66,15 +66,15 @@ describe('search', () => { expect(result).toHaveLength(2); result = Search.query('@verdaccio'); expect(result).toHaveLength(1); - }) + }); test('search remove item', () => { let item = { name: 'test6', description: 'description', _npmUser: { - name: 'test_user' - } + name: 'test_user', + }, }; // @ts-ignore Search.add(item); diff --git a/test/unit/modules/storage/local-storage.spec.ts b/test/unit/modules/storage/local-storage.spec.ts index 04696e88a..32ce1df25 100644 --- a/test/unit/modules/storage/local-storage.spec.ts +++ b/test/unit/modules/storage/local-storage.spec.ts @@ -1,23 +1,22 @@ import path from 'path'; import rimRaf from 'rimraf'; -import LocalStorage from '../../../../src/lib/local-storage'; -import AppConfig from '../../../../src/lib/config'; -// @ts-ignore -import configExample from '../../partials/config'; -import { logger, setup } from '../../../../src/lib/logger'; -import { readFile } from '../../../functional/lib/test.utils'; -import { generatePackageTemplate } from '../../../../src/lib/storage-utils'; -import { generateNewVersion } from '../../../lib/utils-test'; - -const readMetadata = (fileName = 'metadata') => - readFile(`../../unit/partials/${fileName}`).toString(); - -import { IStorage } from '../../../../types'; -import { API_ERROR, HTTP_STATUS, DIST_TAGS } from '../../../../src/lib/constants'; import { VerdaccioError } from '@verdaccio/commons-api'; import { Config, MergeTags, Package } from '@verdaccio/types'; +import AppConfig from '../../../../src/lib/config'; +import { API_ERROR, DIST_TAGS, HTTP_STATUS } from '../../../../src/lib/constants'; +import LocalStorage from '../../../../src/lib/local-storage'; +import { logger, setup } from '../../../../src/lib/logger'; +import { generatePackageTemplate } from '../../../../src/lib/storage-utils'; +import { IStorage } from '../../../../types'; +import { readFile } from '../../../functional/lib/test.utils'; +import { generateNewVersion } from '../../../lib/utils-test'; +// @ts-ignore +import configExample from '../../partials/config'; + +const readMetadata = (fileName = 'metadata') => readFile(`../../unit/partials/${fileName}`).toString(); + setup([]); describe('LocalStorage', () => { @@ -30,7 +29,7 @@ describe('LocalStorage', () => { const getStorage = (LocalStorageClass = LocalStorage) => { const config: Config = new AppConfig( configExample({ - self_path: path.join('../partials/store') + self_path: path.join('../partials/store'), }) ); @@ -47,15 +46,9 @@ describe('LocalStorage', () => { const addNewVersion = (pkgName: string, version: string) => { return new Promise((resolve) => { - storage.addVersion( - pkgName, - version, - generateNewVersion(pkgName, version), - '', - (err, data) => { - resolve(data); - } - ); + storage.addVersion(pkgName, version, generateNewVersion(pkgName, version), '', (err, data) => { + resolve(data); + }); }); }; const addTarballToStore = (pkgName: string, tarballName) => { @@ -153,7 +146,7 @@ describe('LocalStorage', () => { await addNewVersion(pkgName, '3.0.0'); const tags: MergeTags = { beta: '3.0.0', - latest: '2.0.0' + latest: '2.0.0', }; storage.mergeTags(pkgName, tags, async (err, data) => { @@ -176,7 +169,7 @@ describe('LocalStorage', () => { await addNewVersion(pkgName, '2.0.0'); await addNewVersion(pkgName, '3.0.0'); const tags: MergeTags = { - beta: '9999.0.0' + beta: '9999.0.0', }; storage.mergeTags(pkgName, tags, async (err) => { @@ -190,7 +183,7 @@ describe('LocalStorage', () => { test('should fails on mergeTags', async (done) => { const tags: MergeTags = { beta: '3.0.0', - latest: '2.0.0' + latest: '2.0.0', }; storage.mergeTags('not-found', tags, async (err) => { @@ -212,17 +205,11 @@ describe('LocalStorage', () => { await addTarballToStore(pkgName, `${pkgName}-9.0.0.tgz`); await addTarballToStore(pkgName, tarballName); - storage.addVersion( - pkgName, - version, - generateNewVersion(pkgName, version), - '', - (err, data) => { - expect(err).toBeNull(); - expect(data).toBeUndefined(); - done(); - } - ); + storage.addVersion(pkgName, version, generateNewVersion(pkgName, version), '', (err, data) => { + expect(err).toBeNull(); + expect(data).toBeUndefined(); + done(); + }); }); test('should fails on add a duplicated version without tag', async (done) => { @@ -246,18 +233,12 @@ describe('LocalStorage', () => { const tarballName = `${pkgName}-${version}.tgz`; await addTarballToStore(pkgName, tarballName); - storage.addVersion( - pkgName, - version, - generateNewVersion(pkgName, version, 'fake'), - '', - (err) => { - expect(err).not.toBeNull(); - expect(err.statusCode).toEqual(HTTP_STATUS.BAD_REQUEST); - expect(err.message).toMatch(/shasum error/); - done(); - } - ); + storage.addVersion(pkgName, version, generateNewVersion(pkgName, version, 'fake'), '', (err) => { + expect(err).not.toBeNull(); + expect(err.statusCode).toEqual(HTTP_STATUS.BAD_REQUEST); + expect(err.message).toMatch(/shasum error/); + done(); + }); }); test('should add new second version without tag', async (done) => { @@ -267,17 +248,11 @@ describe('LocalStorage', () => { await addNewVersion(pkgName, '1.0.1'); await addNewVersion(pkgName, '1.0.3'); - storage.addVersion( - pkgName, - version, - generateNewVersion(pkgName, version), - 'beta', - (err, data) => { - expect(err).toBeNull(); - expect(data).toBeUndefined(); - done(); - } - ); + storage.addVersion(pkgName, version, generateNewVersion(pkgName, version), 'beta', (err, data) => { + expect(err).toBeNull(); + expect(data).toBeUndefined(); + done(); + }); }); }); diff --git a/test/unit/modules/storage/merge.dist.tags.spec.ts b/test/unit/modules/storage/merge.dist.tags.spec.ts index bdcf0e154..c883c7958 100644 --- a/test/unit/modules/storage/merge.dist.tags.spec.ts +++ b/test/unit/modules/storage/merge.dist.tags.spec.ts @@ -1,4 +1,5 @@ import assert from 'assert'; + import { mergeVersions } from '../../../../src/lib/metadata-utils'; let semverSort = require('../../../../src/lib/utils').semverSort; @@ -9,7 +10,7 @@ describe('Storage._merge_versions versions', () => { test('simple', () => { let pkg = { versions: { a: 1, b: 1, c: 1 }, - 'dist-tags': {} + 'dist-tags': {}, }; // @ts-ignore @@ -17,14 +18,14 @@ describe('Storage._merge_versions versions', () => { assert.deepEqual(pkg, { versions: { a: 1, b: 1, c: 1, q: 2 }, - 'dist-tags': {} + 'dist-tags': {}, }); }); test('dist-tags - compat', () => { let pkg = { versions: {}, - 'dist-tags': { q: '1.1.1', w: '2.2.2' } + 'dist-tags': { q: '1.1.1', w: '2.2.2' }, }; // @ts-ignore @@ -32,7 +33,7 @@ describe('Storage._merge_versions versions', () => { assert.deepEqual(pkg, { versions: {}, - 'dist-tags': { q: '2.2.2', w: '3.3.3', t: '4.4.4' } + 'dist-tags': { q: '2.2.2', w: '3.3.3', t: '4.4.4' }, }); }); @@ -41,7 +42,7 @@ describe('Storage._merge_versions versions', () => { versions: {}, // we've been locally publishing 1.1.x in preparation for the next // public release - 'dist-tags': { q: '1.1.10', w: '2.2.2' } + 'dist-tags': { q: '1.1.10', w: '2.2.2' }, }; // 1.1.2 is the latest public release, but we want to continue testing // against our local 1.1.10, which may end up published as 1.1.3 in the @@ -52,16 +53,11 @@ describe('Storage._merge_versions versions', () => { assert.deepEqual(pkg, { versions: {}, - 'dist-tags': { q: '1.1.10', w: '3.3.3', t: '4.4.4' } + 'dist-tags': { q: '1.1.10', w: '3.3.3', t: '4.4.4' }, }); }); test('semverSort', () => { - assert.deepEqual(semverSort(['1.2.3', '1.2', '1.2.3a', '1.2.3c', '1.2.3-b']), [ - '1.2.3a', - '1.2.3-b', - '1.2.3c', - '1.2.3' - ]); + assert.deepEqual(semverSort(['1.2.3', '1.2', '1.2.3a', '1.2.3c', '1.2.3-b']), ['1.2.3a', '1.2.3-b', '1.2.3c', '1.2.3']); }); }); diff --git a/test/unit/modules/storage/storage-utils.spec.ts b/test/unit/modules/storage/storage-utils.spec.ts index 0ecc52159..483263991 100644 --- a/test/unit/modules/storage/storage-utils.spec.ts +++ b/test/unit/modules/storage/storage-utils.spec.ts @@ -1,8 +1,8 @@ -import { normalizePackage, mergeUplinkTimeIntoLocal } from '../../../../src/lib/storage-utils'; -import { STORAGE, DIST_TAGS } from '../../../../src/lib/constants'; -import { readFile } from '../../../functional/lib/test.utils'; import { Package } from '@verdaccio/types'; +import { DIST_TAGS, STORAGE } from '../../../../src/lib/constants'; +import { mergeUplinkTimeIntoLocal, normalizePackage } from '../../../../src/lib/storage-utils'; +import { readFile } from '../../../functional/lib/test.utils'; const readMetadata = (fileName = 'metadata') => readFile(`../../unit/partials/${fileName}`); @@ -16,7 +16,7 @@ describe('Storage Utils', () => { _uplinks: {}, name: '', versions: {}, - [DIST_TAGS]: {} + [DIST_TAGS]: {}, }); expect(pkg).toBeDefined(); expect(pkg.time).toBeInstanceOf(Object); @@ -52,11 +52,11 @@ describe('Storage Utils', () => { const vGroup1 = { '1.0.15': '2018-06-12T23:15:05.864Z', '1.0.16': '2018-06-12T23:17:46.578Z', - '1.0.17': '2018-06-12T23:20:59.106Z' + '1.0.17': '2018-06-12T23:20:59.106Z', }; const vGroup2 = { '1.0.6': '2018-06-07T05:50:21.505Z', - '1.0.7': '2018-06-12T20:35:07.621Z' + '1.0.7': '2018-06-12T20:35:07.621Z', }; test('mergeTime basic', () => { const pkg1: Package = { @@ -67,11 +67,11 @@ describe('Storage Utils', () => { time: { modified: '2018-06-13T06:44:45.747Z', created: '2018-06-07T05:50:21.505Z', - ...vGroup1 + ...vGroup1, }, name: '', versions: {}, - [DIST_TAGS]: {} + [DIST_TAGS]: {}, }; const pkg2: Package = { @@ -83,19 +83,14 @@ describe('Storage Utils', () => { time: { modified: '2019-06-13T06:44:45.747Z', created: '2019-06-07T05:50:21.505Z', - ...vGroup2 + ...vGroup2, }, versions: {}, - [DIST_TAGS]: {} + [DIST_TAGS]: {}, }; const mergedPkg = mergeUplinkTimeIntoLocal(pkg1, pkg2); - expect(Object.keys(mergedPkg)).toEqual([ - 'modified', - 'created', - ...Object.keys(vGroup1), - ...Object.keys(vGroup2) - ]); + expect(Object.keys(mergedPkg)).toEqual(['modified', 'created', ...Object.keys(vGroup1), ...Object.keys(vGroup2)]); }); test('mergeTime remote empty', () => { @@ -108,10 +103,10 @@ describe('Storage Utils', () => { time: { modified: '2018-06-13T06:44:45.747Z', created: '2018-06-07T05:50:21.505Z', - ...vGroup1 + ...vGroup1, }, versions: {}, - [DIST_TAGS]: {} + [DIST_TAGS]: {}, }; const pkg2: Package = { @@ -121,7 +116,7 @@ describe('Storage Utils', () => { _uplinks: {}, name: '', versions: {}, - [DIST_TAGS]: {} + [DIST_TAGS]: {}, }; const mergedPkg = mergeUplinkTimeIntoLocal(pkg1, pkg2); expect(Object.keys(mergedPkg)).toEqual(['modified', 'created', ...Object.keys(vGroup1)]); diff --git a/test/unit/modules/storage/store.spec.ts b/test/unit/modules/storage/store.spec.ts index 81d346cdd..3b7aeca5a 100644 --- a/test/unit/modules/storage/store.spec.ts +++ b/test/unit/modules/storage/store.spec.ts @@ -1,17 +1,18 @@ -import path from 'path'; import fs from 'fs'; -import { Writable } from 'stream'; -import configExample from '../../partials/config'; -import AppConfig from '../../../../src/lib/config'; -import Storage from '../../../../src/lib/storage'; -import { setup } from '../../../../src/lib/logger'; - -import { IStorageHandler } from '../../../../types'; -import { API_ERROR, HTTP_STATUS } from '../../../../src/lib/constants'; -import { mockServer } from '../../__helper/mock'; -import { DOMAIN_SERVERS } from '../../../functional/config.functional'; -import { Config } from '@verdaccio/types'; +import path from 'path'; import rimraf from 'rimraf'; +import { Writable } from 'stream'; + +import { Config } from '@verdaccio/types'; + +import AppConfig from '../../../../src/lib/config'; +import { API_ERROR, HTTP_STATUS } from '../../../../src/lib/constants'; +import { setup } from '../../../../src/lib/logger'; +import Storage from '../../../../src/lib/storage'; +import { IStorageHandler } from '../../../../types'; +import { DOMAIN_SERVERS } from '../../../functional/config.functional'; +import { mockServer } from '../../__helper/mock'; +import configExample from '../../partials/config'; setup([]); diff --git a/test/unit/modules/uplinks/headers.auth.spec.ts b/test/unit/modules/uplinks/headers.auth.spec.ts index 7efd6feaa..94959405d 100644 --- a/test/unit/modules/uplinks/headers.auth.spec.ts +++ b/test/unit/modules/uplinks/headers.auth.spec.ts @@ -1,19 +1,13 @@ -import ProxyStorage from '../../../../src/lib/up-storage'; -import { - ERROR_CODE, - TOKEN_BASIC, - TOKEN_BEARER, - DEFAULT_REGISTRY, - HEADERS -} from '../../../../src/lib/constants'; -import { buildToken } from '../../../../src/lib/utils'; +import { DEFAULT_REGISTRY, ERROR_CODE, HEADERS, TOKEN_BASIC, TOKEN_BEARER } from '../../../../src/lib/constants'; import { setup } from '../../../../src/lib/logger'; +import ProxyStorage from '../../../../src/lib/up-storage'; +import { buildToken } from '../../../../src/lib/utils'; setup([]); function createUplink(config) { const defaultConfig = { - url: DEFAULT_REGISTRY + url: DEFAULT_REGISTRY, }; let mergeConfig = Object.assign({}, defaultConfig, config); // @ts-ignore @@ -24,7 +18,7 @@ function setHeaders(config: unknown = {}, headers: unknown = {}) { const uplink = createUplink(config); // @ts-ignore return uplink._setHeaders({ - headers + headers, }); } @@ -41,7 +35,7 @@ describe('uplink headers auth test', () => { test('if assigns value invalid to attribute auth', () => { const fnError = function () { setHeaders({ - auth: '' + auth: '', }); }; @@ -54,7 +48,7 @@ describe('uplink headers auth test', () => { const headers = setHeaders( {}, { - [HEADERS.AUTHORIZATION]: buildToken(TOKEN_BASIC, 'Zm9vX2Jhcg==') + [HEADERS.AUTHORIZATION]: buildToken(TOKEN_BASIC, 'Zm9vX2Jhcg=='), } ); @@ -67,11 +61,11 @@ describe('uplink headers auth test', () => { { auth: { type: TOKEN_BEARER, - token: 'tokenBearer' - } + token: 'tokenBearer', + }, }, { - [HEADERS.AUTHORIZATION]: buildToken(TOKEN_BASIC, 'tokenBasic') + [HEADERS.AUTHORIZATION]: buildToken(TOKEN_BASIC, 'tokenBasic'), } ); @@ -82,8 +76,8 @@ describe('uplink headers auth test', () => { const headers = setHeaders({ auth: { type: TOKEN_BASIC, - token: 'Zm9vX2Jhcg==' - } + token: 'Zm9vX2Jhcg==', + }, }); expect(Object.keys(headers)).toHaveLength(4); @@ -94,8 +88,8 @@ describe('uplink headers auth test', () => { const headers = setHeaders({ auth: { type: TOKEN_BEARER, - token: 'Zm9vX2Jhcf===' - } + token: 'Zm9vX2Jhcf===', + }, }); expect(Object.keys(headers)).toHaveLength(4); @@ -107,8 +101,8 @@ describe('uplink headers auth test', () => { setHeaders({ auth: { type: 'null', - token: 'Zm9vX2Jhcf===' - } + token: 'Zm9vX2Jhcf===', + }, }); }; @@ -121,8 +115,8 @@ describe('uplink headers auth test', () => { process.env.NPM_TOKEN = 'myToken'; const headers = setHeaders({ auth: { - type: TOKEN_BEARER - } + type: TOKEN_BEARER, + }, }); expect(headers[HEADERS.AUTHORIZATION]).toBe(buildToken(TOKEN_BEARER, 'myToken')); @@ -134,8 +128,8 @@ describe('uplink headers auth test', () => { const headers = setHeaders({ auth: { type: TOKEN_BASIC, - token_env: 'NPM_TOKEN_TEST' - } + token_env: 'NPM_TOKEN_TEST', + }, }); expect(headers[HEADERS.AUTHORIZATION]).toBe(buildToken(TOKEN_BASIC, 'myTokenTest')); @@ -146,8 +140,8 @@ describe('uplink headers auth test', () => { const fnError = function () { setHeaders({ auth: { - type: TOKEN_BASIC - } + type: TOKEN_BASIC, + }, }); }; diff --git a/test/unit/modules/uplinks/up-storage.spec.ts b/test/unit/modules/uplinks/up-storage.spec.ts index e9423ab8f..02b1bf231 100644 --- a/test/unit/modules/uplinks/up-storage.spec.ts +++ b/test/unit/modules/uplinks/up-storage.spec.ts @@ -1,15 +1,16 @@ -import ProxyStorage from '../../../../src/lib/up-storage'; -import AppConfig from '../../../../src/lib/config'; -import configExample from '../../partials/config'; -import { setup } from '../../../../src/lib/logger'; +import _ from 'lodash'; -import { IProxy } from '../../../../types'; -import { API_ERROR, HTTP_STATUS } from '../../../../src/lib/constants'; -import { mockServer } from '../../__helper/mock'; -import { DOMAIN_SERVERS } from '../../../functional/config.functional'; import { VerdaccioError } from '@verdaccio/commons-api'; import { Config, UpLinkConf } from '@verdaccio/types'; -import _ from 'lodash'; + +import AppConfig from '../../../../src/lib/config'; +import { API_ERROR, HTTP_STATUS } from '../../../../src/lib/constants'; +import { setup } from '../../../../src/lib/logger'; +import ProxyStorage from '../../../../src/lib/up-storage'; +import { IProxy } from '../../../../types'; +import { DOMAIN_SERVERS } from '../../../functional/config.functional'; +import { mockServer } from '../../__helper/mock'; +import configExample from '../../partials/config'; setup([]); @@ -17,7 +18,7 @@ describe('UpStorge', () => { const mockServerPort = 55547; let mockRegistry; const uplinkDefault = { - url: `http://localhost:${mockServerPort}` + url: `http://localhost:${mockServerPort}`, }; const generateProxy = (config: UpLinkConf = uplinkDefault) => { const appConfig: Config = new AppConfig(configExample()); diff --git a/test/unit/modules/utils/api.__test.template.ts b/test/unit/modules/utils/api.__test.template.ts index a3fef42e0..dc7736694 100644 --- a/test/unit/modules/utils/api.__test.template.ts +++ b/test/unit/modules/utils/api.__test.template.ts @@ -6,18 +6,18 @@ * If you have any questions, ask at the http://chat.verdaccio.org #questions channel. * */ +import _ from 'lodash'; import path from 'path'; +import rimraf from 'rimraf'; +import request from 'supertest'; import endPointAPI from '../../../../src/api/index'; -import { mockServer } from '../../__helper/mock'; -import { DOMAIN_SERVERS } from '../../../functional/config.functional'; +import { setup } from '../../../../src/lib/logger'; import { parseConfigFile } from '../../../../src/lib/utils'; +import { DOMAIN_SERVERS } from '../../../functional/config.functional'; import { parseConfigurationFile } from '../../__helper'; import { addUser } from '../../__helper/api'; -import { setup } from '../../../../src/lib/logger'; -import rimraf from 'rimraf'; -import _ from 'lodash'; -import request from 'supertest'; +import { mockServer } from '../../__helper/mock'; // we must start logging without output setup([]); @@ -47,17 +47,17 @@ describe('endpoint example unit test', () => { storage: store, uplinks: { npmjs: { - url: `http://${DOMAIN_SERVERS}:${mockServerPort}` - } + url: `http://${DOMAIN_SERVERS}:${mockServerPort}`, + }, }, // 6. The self_path is important be the same as the store self_path: store, // 7. Define the location of the .htpasswd file, this is relative to self_path. auth: { htpasswd: { - file: './test-jwt-storage/.htpasswd' - } - } + file: './test-jwt-storage/.htpasswd', + }, + }, }); // 8. Use the helper `endPointAPI` to mock the API diff --git a/test/unit/modules/utils/config-utils.spec.ts b/test/unit/modules/utils/config-utils.spec.ts index 4875a12c8..217222591 100644 --- a/test/unit/modules/utils/config-utils.spec.ts +++ b/test/unit/modules/utils/config-utils.spec.ts @@ -1,15 +1,10 @@ -import path from 'path'; -import { spliceURL } from '../../../../src/utils/string'; -import { parseConfigFile } from '../../../../src/lib/utils'; -import { - getMatchedPackagesSpec, - hasProxyTo, - normalisePackageAccess, - sanityCheckUplinksProps, - uplinkSanityCheck -} from '../../../../src/lib/config-utils'; -import { PACKAGE_ACCESS, ROLES } from '../../../../src/lib/constants'; import _ from 'lodash'; +import path from 'path'; + +import { getMatchedPackagesSpec, hasProxyTo, normalisePackageAccess, sanityCheckUplinksProps, uplinkSanityCheck } from '../../../../src/lib/config-utils'; +import { PACKAGE_ACCESS, ROLES } from '../../../../src/lib/constants'; +import { parseConfigFile } from '../../../../src/lib/utils'; +import { spliceURL } from '../../../../src/utils/string'; describe('Config Utilities', () => { const parseConfigurationFile = (conf) => { @@ -21,9 +16,7 @@ describe('Config Utilities', () => { describe('uplinkSanityCheck', () => { test('should test basic conversion', () => { - const uplinks = uplinkSanityCheck( - parseConfigFile(parseConfigurationFile('uplink-basic')).uplinks - ); + const uplinks = uplinkSanityCheck(parseConfigFile(parseConfigurationFile('uplink-basic')).uplinks); expect(Object.keys(uplinks)).toContain('server1'); expect(Object.keys(uplinks)).toContain('server2'); }); @@ -208,9 +201,7 @@ describe('Config Utilities', () => { describe('hasProxyTo', () => { test('should test basic config', () => { - const packages = normalisePackageAccess( - parseConfigFile(parseConfigurationFile('pkgs-basic')).packages - ); + const packages = normalisePackageAccess(parseConfigFile(parseConfigurationFile('pkgs-basic')).packages); // react expect(hasProxyTo('react', 'facebook', packages)).toBeFalsy(); expect(hasProxyTo('react', 'google', packages)).toBeFalsy(); @@ -225,9 +216,7 @@ describe('Config Utilities', () => { }); test('should test resolve based on custom package access', () => { - const packages = normalisePackageAccess( - parseConfigFile(parseConfigurationFile('pkgs-custom')).packages - ); + const packages = normalisePackageAccess(parseConfigFile(parseConfigurationFile('pkgs-custom')).packages); // react expect(hasProxyTo('react', 'facebook', packages)).toBeTruthy(); expect(hasProxyTo('react', 'google', packages)).toBeFalsy(); @@ -242,9 +231,7 @@ describe('Config Utilities', () => { }); test('should not resolve any proxy', () => { - const packages = normalisePackageAccess( - parseConfigFile(parseConfigurationFile('pkgs-empty')).packages - ); + const packages = normalisePackageAccess(parseConfigFile(parseConfigurationFile('pkgs-empty')).packages); // react expect(hasProxyTo('react', 'npmjs', packages)).toBeFalsy(); expect(hasProxyTo('react', 'npmjs', packages)).toBeFalsy(); diff --git a/test/unit/modules/utils/parseInterval.spec.ts b/test/unit/modules/utils/parseInterval.spec.ts index ee43de53f..eb40a2d9a 100644 --- a/test/unit/modules/utils/parseInterval.spec.ts +++ b/test/unit/modules/utils/parseInterval.spec.ts @@ -1,4 +1,5 @@ import assert from 'assert'; + import { parseInterval } from '../../../../src/lib/utils'; describe('Parse interval', () => { diff --git a/test/unit/modules/utils/tag.version.spec.ts b/test/unit/modules/utils/tag.version.spec.ts index bc29647c3..19e640c15 100644 --- a/test/unit/modules/utils/tag.version.spec.ts +++ b/test/unit/modules/utils/tag.version.spec.ts @@ -1,7 +1,7 @@ import assert from 'assert'; -import { tagVersion } from '../../../../src/lib/utils'; import { setup } from '../../../../src/lib/logger'; +import { tagVersion } from '../../../../src/lib/utils'; setup([]); @@ -9,42 +9,42 @@ describe('tagVersion', () => { test('add new one', () => { let pkg = { versions: {}, - 'dist-tags': {} + 'dist-tags': {}, }; // @ts-ignore assert(tagVersion(pkg, '1.1.1', 'foo', {})); assert.deepEqual(pkg, { versions: {}, - 'dist-tags': { foo: '1.1.1' } + 'dist-tags': { foo: '1.1.1' }, }); }); test('add (compat)', () => { const x = { versions: {}, - 'dist-tags': { foo: '1.1.0' } + 'dist-tags': { foo: '1.1.0' }, }; // @ts-ignore assert(tagVersion(x, '1.1.1', 'foo')); assert.deepEqual(x, { versions: {}, - 'dist-tags': { foo: '1.1.1' } + 'dist-tags': { foo: '1.1.1' }, }); }); test('add fresh tag', () => { let x = { versions: {}, - 'dist-tags': { foo: '1.1.0' } + 'dist-tags': { foo: '1.1.0' }, }; // @ts-ignore assert(tagVersion(x, '1.1.1', 'foo')); assert.deepEqual(x, { versions: {}, - 'dist-tags': { foo: '1.1.1' } + 'dist-tags': { foo: '1.1.1' }, }); }); }); diff --git a/test/unit/modules/utils/utils.spec.ts b/test/unit/modules/utils/utils.spec.ts index a0e156102..4b335b690 100644 --- a/test/unit/modules/utils/utils.spec.ts +++ b/test/unit/modules/utils/utils.spec.ts @@ -1,28 +1,30 @@ -import { generateGravatarUrl, GENERIC_AVATAR } from '../../../../src/utils/user'; -import { spliceURL } from '../../../../src/utils/string'; -import { - validateName, - convertDistRemoteToLocalTarballUrls, - parseReadme, - addGravatarSupport, - validatePackage, - validateMetadata, - combineBaseUrl, - getVersion, - normalizeDistTags, - getWebProtocol, - getVersionFromTarball, - sortByName, - formatAuthor, - isHTTPProtocol, - getPublicUrl, -} from '../../../../src/lib/utils'; -import { DIST_TAGS, DEFAULT_USER } from '../../../../src/lib/constants'; -import { logger, setup } from '../../../../src/lib/logger'; -import { readFile } from '../../../functional/lib/test.utils'; -import { HEADERS } from '@verdaccio/commons-api'; import * as httpMocks from 'node-mocks-http'; +import { HEADERS } from '@verdaccio/commons-api'; + +import { DEFAULT_USER, DIST_TAGS } from '../../../../src/lib/constants'; +import { logger, setup } from '../../../../src/lib/logger'; +import { + addGravatarSupport, + combineBaseUrl, + convertDistRemoteToLocalTarballUrls, + formatAuthor, + getPublicUrl, + getVersion, + getVersionFromTarball, + getWebProtocol, + isHTTPProtocol, + normalizeDistTags, + parseReadme, + sortByName, + validateMetadata, + validateName, + validatePackage, +} from '../../../../src/lib/utils'; +import { spliceURL } from '../../../../src/utils/string'; +import { GENERIC_AVATAR, generateGravatarUrl } from '../../../../src/utils/user'; +import { readFile } from '../../../functional/lib/test.utils'; + const readmeFile = (fileName = 'markdown.md') => readFile(`../../unit/partials/readme/${fileName}`); setup([]); diff --git a/test/unit/modules/web/api.web.spec.ts b/test/unit/modules/web/api.web.spec.ts index 9dc357a61..d1b9ae9b6 100644 --- a/test/unit/modules/web/api.web.spec.ts +++ b/test/unit/modules/web/api.web.spec.ts @@ -1,17 +1,16 @@ import path from 'path'; - -import configDefault from '../../partials/config'; -import publishMetadata from '../../partials/publish-api'; -import forbiddenPlace from '../../partials/forbidden-place'; -import endPointAPI from '../../../../src/api'; - -import { HEADERS, API_ERROR, HTTP_STATUS, HEADER_TYPE, DIST_TAGS } from '../../../../src/lib/constants'; -import { DOMAIN_SERVERS } from '../../../functional/config.functional'; -import { mockServer } from '../../__helper/mock'; -import { addUser } from '../../__helper/api'; import rimraf from 'rimraf'; import request from 'supertest'; +import endPointAPI from '../../../../src/api'; +import { API_ERROR, DIST_TAGS, HEADERS, HEADER_TYPE, HTTP_STATUS } from '../../../../src/lib/constants'; +import { DOMAIN_SERVERS } from '../../../functional/config.functional'; +import { addUser } from '../../__helper/api'; +import { mockServer } from '../../__helper/mock'; +import configDefault from '../../partials/config'; +import forbiddenPlace from '../../partials/forbidden-place'; +import publishMetadata from '../../partials/publish-api'; + require('../../../../src/lib/logger').setup([]); const credentials = { name: 'user-web', password: 'secretPass' }; diff --git a/tsconfig.json b/tsconfig.json index 704b9ce88..fad0562a1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,15 +9,8 @@ "resolveJsonModule": true, "outDir": "lib", "allowSyntheticDefaultImports": true, - "esModuleInterop": true + "esModuleInterop": true }, - "exclude": [ - "node_modules", - "**/*.spec.ts" - ], - "include": [ - "src/**/*.ts", - "test/**/*.ts", - "types/*.d.ts" - ] + "exclude": ["node_modules", "**/*.spec.ts"], + "include": ["src/**/*.ts", "test/**/*.ts", "types/*.d.ts"] } diff --git a/types/custom.d.ts b/types/custom.d.ts index 35f81819e..32ec6623c 100644 --- a/types/custom.d.ts +++ b/types/custom.d.ts @@ -1,6 +1,5 @@ /// - -import { Logger, RemoteUser } from "@verdaccio/types"; +import { Logger, RemoteUser } from '@verdaccio/types'; declare global { namespace Express { diff --git a/types/index.ts b/types/index.ts index 4af2af9ab..f1c02a3e3 100644 --- a/types/index.ts +++ b/types/index.ts @@ -1,30 +1,31 @@ +import { NextFunction, Request, Response } from 'express'; +import lunrMutable from 'lunr-mutable-indexes'; + import { + AuthPluginPackage, + Author, + Callback, + Config, IBasicAuth, IBasicStorage, - IStorageManager, - UpLinkConf, - Callback, - Versions, - Version, - RemoteUser, - Config, - Logger, - JWTSignOptions, - PackageAccess, IPluginStorage, - StringValue as verdaccio$StringValue, - IReadTarball, - Package, IPluginStorageFilter, - Author, - AuthPluginPackage, - Token, + IReadTarball, + IStorageManager, ITokenActions, - TokenFilter, + JWTSignOptions, + Logger, + Package, + PackageAccess, RateLimit, + RemoteUser, + Token, + TokenFilter, + UpLinkConf, + Version, + Versions, + StringValue as verdaccio$StringValue, } from '@verdaccio/types'; -import lunrMutable from 'lunr-mutable-indexes'; -import { NextFunction, Request, Response } from 'express'; export type StringValue = verdaccio$StringValue; diff --git a/yarn-plugins/plugin-postinstall.js b/yarn-plugins/plugin-postinstall.js index 4c7f071ef..910e82a87 100644 --- a/yarn-plugins/plugin-postinstall.js +++ b/yarn-plugins/plugin-postinstall.js @@ -3,14 +3,14 @@ * Ref https://github.com/verdaccio/verdaccio/pull/2253#discussion_r632052482 */ module.exports = { - name: `plugin-postinstall`, - factory: () => ({ - hooks: { - beforeWorkspacePacking(_workspace, data) { - if ('scripts' in data && 'postinstall' in data.scripts) { - delete data.scripts.postinstall; - } - }, - }, - }), + name: `plugin-postinstall`, + factory: () => ({ + hooks: { + beforeWorkspacePacking(_workspace, data) { + if ('scripts' in data && 'postinstall' in data.scripts) { + delete data.scripts.postinstall; + } + }, + }, + }), }; diff --git a/yarn.lock b/yarn.lock index 480a9322c..d6c0033a9 100644 Binary files a/yarn.lock and b/yarn.lock differ