1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-08 23:25:51 +01:00

fix: #3666 experiments config fail on startup (#3668)

* fix: #3666 experiments config fail on startup

* Update experiments.yaml

* Update init.ts

* add tests

* Update bootstrap.ts

* update deps

* update deps
This commit is contained in:
Juan Picado 2023-03-07 22:50:16 +01:00 committed by GitHub
parent 335704ba2a
commit f6c22d3ea8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 212 additions and 103 deletions

134
.pnp.cjs generated

@ -68,18 +68,18 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["@typescript-eslint/eslint-plugin", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:5.49.0"],\
["@typescript-eslint/parser", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:5.49.0"],\
["@verdaccio-scope/verdaccio-auth-foo", "npm:0.0.2"],\
["@verdaccio/config", "npm:6.0.0-6-next.63"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["@verdaccio/config", "npm:6.0.0-6-next.65"],\
["@verdaccio/core", "npm:6.0.0-6-next.65"],\
["@verdaccio/local-storage", "npm:10.3.1"],\
["@verdaccio/logger-7", "npm:6.0.0-6-next.8"],\
["@verdaccio/middleware", "npm:6.0.0-6-next.42"],\
["@verdaccio/logger-7", "npm:6.0.0-6-next.10"],\
["@verdaccio/middleware", "npm:6.0.0-6-next.44"],\
["@verdaccio/signature", "npm:6.0.0-6-next.2"],\
["@verdaccio/streams", "npm:10.2.0"],\
["@verdaccio/tarball", "npm:11.0.0-6-next.32"],\
["@verdaccio/tarball", "npm:11.0.0-6-next.34"],\
["@verdaccio/types", "npm:10.7.1"],\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.63"],\
["@verdaccio/url", "npm:11.0.0-6-next.29"],\
["@verdaccio/utils", "npm:6.0.0-6-next.31"],\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.65"],\
["@verdaccio/url", "npm:11.0.0-6-next.31"],\
["@verdaccio/utils", "npm:6.0.0-6-next.33"],\
["JSONStream", "npm:1.3.5"],\
["async", "npm:3.2.4"],\
["babel-eslint", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.1.0"],\
@ -139,7 +139,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["ts-node", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.9.1"],\
["typescript", "patch:typescript@npm%3A4.1.3#~builtin<compat/typescript>::version=4.1.3&hash=4a8eb8"],\
["validator", "npm:13.9.0"],\
["verdaccio-audit", "npm:11.0.0-6-next.26"],\
["verdaccio-audit", "npm:11.0.0-6-next.28"],\
["verdaccio-auth-memory", "npm:10.2.0"],\
["verdaccio-htpasswd", "npm:10.5.2"],\
["verdaccio-memory", "npm:10.3.0"]\
@ -5022,12 +5022,12 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/config", [\
["npm:6.0.0-6-next.63", {\
"packageLocation": "./.yarn/cache/@verdaccio-config-npm-6.0.0-6-next.63-d9081a2c96-e570992530.zip/node_modules/@verdaccio/config/",\
["npm:6.0.0-6-next.65", {\
"packageLocation": "./.yarn/cache/@verdaccio-config-npm-6.0.0-6-next.65-ec8dc725a5-bd0362c497.zip/node_modules/@verdaccio/config/",\
"packageDependencies": [\
["@verdaccio/config", "npm:6.0.0-6-next.63"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["@verdaccio/utils", "npm:6.0.0-6-next.31"],\
["@verdaccio/config", "npm:6.0.0-6-next.65"],\
["@verdaccio/core", "npm:6.0.0-6-next.65"],\
["@verdaccio/utils", "npm:6.0.0-6-next.33"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["js-yaml", "npm:4.1.0"],\
["lodash", "npm:4.17.21"],\
@ -5038,10 +5038,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/core", [\
["npm:6.0.0-6-next.63", {\
"packageLocation": "./.yarn/cache/@verdaccio-core-npm-6.0.0-6-next.63-2e4bd5002d-5482de0363.zip/node_modules/@verdaccio/core/",\
["npm:6.0.0-6-next.65", {\
"packageLocation": "./.yarn/cache/@verdaccio-core-npm-6.0.0-6-next.65-1f44570534-f235d6f826.zip/node_modules/@verdaccio/core/",\
"packageDependencies": [\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["@verdaccio/core", "npm:6.0.0-6-next.65"],\
["ajv", "npm:8.11.2"],\
["core-js", "npm:3.28.0"],\
["http-errors", "npm:1.8.1"],\
@ -5080,22 +5080,22 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/logger-7", [\
["npm:6.0.0-6-next.8", {\
"packageLocation": "./.yarn/cache/@verdaccio-logger-7-npm-6.0.0-6-next.8-e3eb29a637-dad4916287.zip/node_modules/@verdaccio/logger-7/",\
["npm:6.0.0-6-next.10", {\
"packageLocation": "./.yarn/cache/@verdaccio-logger-7-npm-6.0.0-6-next.10-a9267d8eae-49d6f1102e.zip/node_modules/@verdaccio/logger-7/",\
"packageDependencies": [\
["@verdaccio/logger-7", "npm:6.0.0-6-next.8"],\
["@verdaccio/logger-commons", "npm:6.0.0-6-next.31"],\
["@verdaccio/logger-7", "npm:6.0.0-6-next.10"],\
["@verdaccio/logger-commons", "npm:6.0.0-6-next.33"],\
["pino", "npm:7.11.0"]\
],\
"linkType": "HARD"\
}]\
]],\
["@verdaccio/logger-commons", [\
["npm:6.0.0-6-next.31", {\
"packageLocation": "./.yarn/cache/@verdaccio-logger-commons-npm-6.0.0-6-next.31-d40fe77eab-e2a9276d7f.zip/node_modules/@verdaccio/logger-commons/",\
["npm:6.0.0-6-next.33", {\
"packageLocation": "./.yarn/cache/@verdaccio-logger-commons-npm-6.0.0-6-next.33-c128af2265-d8a77df746.zip/node_modules/@verdaccio/logger-commons/",\
"packageDependencies": [\
["@verdaccio/logger-commons", "npm:6.0.0-6-next.31"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["@verdaccio/logger-commons", "npm:6.0.0-6-next.33"],\
["@verdaccio/core", "npm:6.0.0-6-next.65"],\
["@verdaccio/logger-prettify", "npm:6.0.0-6-next.9"],\
["colorette", "npm:2.0.19"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"]\
@ -5118,14 +5118,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/middleware", [\
["npm:6.0.0-6-next.42", {\
"packageLocation": "./.yarn/cache/@verdaccio-middleware-npm-6.0.0-6-next.42-b919b3b771-6ee70fa2bb.zip/node_modules/@verdaccio/middleware/",\
["npm:6.0.0-6-next.44", {\
"packageLocation": "./.yarn/cache/@verdaccio-middleware-npm-6.0.0-6-next.44-fe2d3ca885-c6c5ac1011.zip/node_modules/@verdaccio/middleware/",\
"packageDependencies": [\
["@verdaccio/middleware", "npm:6.0.0-6-next.42"],\
["@verdaccio/config", "npm:6.0.0-6-next.63"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["@verdaccio/url", "npm:11.0.0-6-next.29"],\
["@verdaccio/utils", "npm:6.0.0-6-next.31"],\
["@verdaccio/middleware", "npm:6.0.0-6-next.44"],\
["@verdaccio/config", "npm:6.0.0-6-next.65"],\
["@verdaccio/core", "npm:6.0.0-6-next.65"],\
["@verdaccio/url", "npm:11.0.0-6-next.31"],\
["@verdaccio/utils", "npm:6.0.0-6-next.33"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["express", "npm:4.18.2"],\
["express-rate-limit", "npm:5.5.1"],\
@ -5158,13 +5158,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/tarball", [\
["npm:11.0.0-6-next.32", {\
"packageLocation": "./.yarn/cache/@verdaccio-tarball-npm-11.0.0-6-next.32-0e4e9c55a3-6d99a03e8e.zip/node_modules/@verdaccio/tarball/",\
["npm:11.0.0-6-next.34", {\
"packageLocation": "./.yarn/cache/@verdaccio-tarball-npm-11.0.0-6-next.34-1f9fd3401e-aea6817f54.zip/node_modules/@verdaccio/tarball/",\
"packageDependencies": [\
["@verdaccio/tarball", "npm:11.0.0-6-next.32"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["@verdaccio/url", "npm:11.0.0-6-next.29"],\
["@verdaccio/utils", "npm:6.0.0-6-next.31"],\
["@verdaccio/tarball", "npm:11.0.0-6-next.34"],\
["@verdaccio/core", "npm:6.0.0-6-next.65"],\
["@verdaccio/url", "npm:11.0.0-6-next.31"],\
["@verdaccio/utils", "npm:6.0.0-6-next.33"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["lodash", "npm:4.17.21"]\
],\
@ -5181,20 +5181,20 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/ui-theme", [\
["npm:6.0.0-6-next.63", {\
"packageLocation": "./.yarn/cache/@verdaccio-ui-theme-npm-6.0.0-6-next.63-0be4db2b6b-f22d063917.zip/node_modules/@verdaccio/ui-theme/",\
["npm:6.0.0-6-next.65", {\
"packageLocation": "./.yarn/cache/@verdaccio-ui-theme-npm-6.0.0-6-next.65-6e789e15ea-60c56e22b1.zip/node_modules/@verdaccio/ui-theme/",\
"packageDependencies": [\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.63"]\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.65"]\
],\
"linkType": "HARD"\
}]\
]],\
["@verdaccio/url", [\
["npm:11.0.0-6-next.29", {\
"packageLocation": "./.yarn/cache/@verdaccio-url-npm-11.0.0-6-next.29-aec2138405-9a8e33a242.zip/node_modules/@verdaccio/url/",\
["npm:11.0.0-6-next.31", {\
"packageLocation": "./.yarn/cache/@verdaccio-url-npm-11.0.0-6-next.31-58ffaa952e-bde97904c2.zip/node_modules/@verdaccio/url/",\
"packageDependencies": [\
["@verdaccio/url", "npm:11.0.0-6-next.29"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["@verdaccio/url", "npm:11.0.0-6-next.31"],\
["@verdaccio/core", "npm:6.0.0-6-next.65"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["lodash", "npm:4.17.21"],\
["validator", "npm:13.9.0"]\
@ -5203,11 +5203,11 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["@verdaccio/utils", [\
["npm:6.0.0-6-next.31", {\
"packageLocation": "./.yarn/cache/@verdaccio-utils-npm-6.0.0-6-next.31-999a173ba7-d6c849c845.zip/node_modules/@verdaccio/utils/",\
["npm:6.0.0-6-next.33", {\
"packageLocation": "./.yarn/cache/@verdaccio-utils-npm-6.0.0-6-next.33-4613ccc841-2957435210.zip/node_modules/@verdaccio/utils/",\
"packageDependencies": [\
["@verdaccio/utils", "npm:6.0.0-6-next.31"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["@verdaccio/utils", "npm:6.0.0-6-next.33"],\
["@verdaccio/core", "npm:6.0.0-6-next.65"],\
["lodash", "npm:4.17.21"],\
["minimatch", "npm:3.1.2"],\
["semver", "npm:7.3.8"]\
@ -11467,10 +11467,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
],\
"linkType": "HARD"\
}],\
["virtual:ba5481a20e14b5defa2f3db22489403a4de9f5b4645871e0be81fb7e8290e7bf5d80c3d6f6435f950cd1eeae681924df27f429454447130d590f84ee64a21788#npm:2.6.7", {\
"packageLocation": "./.yarn/__virtual__/node-fetch-virtual-53e851eaf1/0/cache/node-fetch-npm-2.6.7-777aa2a6df-8d816ffd1e.zip/node_modules/node-fetch/",\
["virtual:9afe74ba930b955a1743d5d1fa543240cc314de8bf1fa58bbf063d17d78a9f5f6d771784605774e10562f3877ee4eb910580dcb9146d4f0fa1ee6d9a015ef75b#npm:2.6.7", {\
"packageLocation": "./.yarn/__virtual__/node-fetch-virtual-dbc96021ed/0/cache/node-fetch-npm-2.6.7-777aa2a6df-8d816ffd1e.zip/node_modules/node-fetch/",\
"packageDependencies": [\
["node-fetch", "virtual:ba5481a20e14b5defa2f3db22489403a4de9f5b4645871e0be81fb7e8290e7bf5d80c3d6f6435f950cd1eeae681924df27f429454447130d590f84ee64a21788#npm:2.6.7"],\
["node-fetch", "virtual:9afe74ba930b955a1743d5d1fa543240cc314de8bf1fa58bbf063d17d78a9f5f6d771784605774e10562f3877ee4eb910580dcb9146d4f0fa1ee6d9a015ef75b#npm:2.6.7"],\
["@types/encoding", null],\
["encoding", null],\
["whatwg-url", "npm:5.0.0"]\
@ -14230,18 +14230,18 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["@typescript-eslint/eslint-plugin", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:5.49.0"],\
["@typescript-eslint/parser", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:5.49.0"],\
["@verdaccio-scope/verdaccio-auth-foo", "npm:0.0.2"],\
["@verdaccio/config", "npm:6.0.0-6-next.63"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["@verdaccio/config", "npm:6.0.0-6-next.65"],\
["@verdaccio/core", "npm:6.0.0-6-next.65"],\
["@verdaccio/local-storage", "npm:10.3.1"],\
["@verdaccio/logger-7", "npm:6.0.0-6-next.8"],\
["@verdaccio/middleware", "npm:6.0.0-6-next.42"],\
["@verdaccio/logger-7", "npm:6.0.0-6-next.10"],\
["@verdaccio/middleware", "npm:6.0.0-6-next.44"],\
["@verdaccio/signature", "npm:6.0.0-6-next.2"],\
["@verdaccio/streams", "npm:10.2.0"],\
["@verdaccio/tarball", "npm:11.0.0-6-next.32"],\
["@verdaccio/tarball", "npm:11.0.0-6-next.34"],\
["@verdaccio/types", "npm:10.7.1"],\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.63"],\
["@verdaccio/url", "npm:11.0.0-6-next.29"],\
["@verdaccio/utils", "npm:6.0.0-6-next.31"],\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.65"],\
["@verdaccio/url", "npm:11.0.0-6-next.31"],\
["@verdaccio/utils", "npm:6.0.0-6-next.33"],\
["JSONStream", "npm:1.3.5"],\
["async", "npm:3.2.4"],\
["babel-eslint", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.1.0"],\
@ -14301,7 +14301,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["ts-node", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.9.1"],\
["typescript", "patch:typescript@npm%3A4.1.3#~builtin<compat/typescript>::version=4.1.3&hash=4a8eb8"],\
["validator", "npm:13.9.0"],\
["verdaccio-audit", "npm:11.0.0-6-next.26"],\
["verdaccio-audit", "npm:11.0.0-6-next.28"],\
["verdaccio-auth-memory", "npm:10.2.0"],\
["verdaccio-htpasswd", "npm:10.5.2"],\
["verdaccio-memory", "npm:10.3.0"]\
@ -14310,15 +14310,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["verdaccio-audit", [\
["npm:11.0.0-6-next.26", {\
"packageLocation": "./.yarn/cache/verdaccio-audit-npm-11.0.0-6-next.26-ba5481a20e-426067a7a7.zip/node_modules/verdaccio-audit/",\
["npm:11.0.0-6-next.28", {\
"packageLocation": "./.yarn/cache/verdaccio-audit-npm-11.0.0-6-next.28-9afe74ba93-5b2d431546.zip/node_modules/verdaccio-audit/",\
"packageDependencies": [\
["verdaccio-audit", "npm:11.0.0-6-next.26"],\
["@verdaccio/config", "npm:6.0.0-6-next.63"],\
["@verdaccio/core", "npm:6.0.0-6-next.63"],\
["verdaccio-audit", "npm:11.0.0-6-next.28"],\
["@verdaccio/config", "npm:6.0.0-6-next.65"],\
["@verdaccio/core", "npm:6.0.0-6-next.65"],\
["express", "npm:4.18.2"],\
["https-proxy-agent", "npm:5.0.1"],\
["node-fetch", "virtual:ba5481a20e14b5defa2f3db22489403a4de9f5b4645871e0be81fb7e8290e7bf5d80c3d6f6435f950cd1eeae681924df27f429454447130d590f84ee64a21788#npm:2.6.7"]\
["node-fetch", "virtual:9afe74ba930b955a1743d5d1fa543240cc314de8bf1fa58bbf063d17d78a9f5f6d771784605774e10562f3877ee4eb910580dcb9146d4f0fa1ee6d9a015ef75b#npm:2.6.7"]\
],\
"linkType": "HARD"\
}]\

@ -179,7 +179,7 @@ middlewares:
# https://verdaccio.org/docs/logger
# log settings
logs: { type: stdout, format: pretty, level: http }
log: { type: stdout, format: pretty, level: http }
#experiments:
# # support for npm token command
# token: false

@ -183,7 +183,7 @@ middlewares:
# https://verdaccio.org/docs/logger
# log settings
logs: { type: stdout, format: pretty, level: http }
log: { type: stdout, format: pretty, level: http }
#experiments:
# # support for npm token command
# token: false

@ -19,17 +19,17 @@
"url": "https://opencollective.com/verdaccio"
},
"dependencies": {
"@verdaccio/config": "6.0.0-6-next.63",
"@verdaccio/core": "6.0.0-6-next.63",
"@verdaccio/config": "6.0.0-6-next.65",
"@verdaccio/core": "6.0.0-6-next.65",
"@verdaccio/local-storage": "10.3.1",
"@verdaccio/logger-7": "6.0.0-6-next.8",
"@verdaccio/middleware": "6.0.0-6-next.42",
"@verdaccio/logger-7": "6.0.0-6-next.10",
"@verdaccio/middleware": "6.0.0-6-next.44",
"@verdaccio/signature": "6.0.0-6-next.2",
"@verdaccio/streams": "10.2.0",
"@verdaccio/tarball": "11.0.0-6-next.32",
"@verdaccio/ui-theme": "6.0.0-6-next.63",
"@verdaccio/url": "11.0.0-6-next.29",
"@verdaccio/utils": "6.0.0-6-next.31",
"@verdaccio/tarball": "11.0.0-6-next.34",
"@verdaccio/ui-theme": "6.0.0-6-next.65",
"@verdaccio/url": "11.0.0-6-next.31",
"@verdaccio/utils": "6.0.0-6-next.33",
"JSONStream": "1.3.5",
"async": "3.2.4",
"body-parser": "1.20.2",
@ -56,7 +56,7 @@
"request": "2.88.2",
"semver": "7.3.8",
"validator": "13.9.0",
"verdaccio-audit": "11.0.0-6-next.26",
"verdaccio-audit": "11.0.0-6-next.28",
"verdaccio-htpasswd": "10.5.2"
},
"devDependencies": {

@ -19,7 +19,7 @@ function displayExperimentsInfoBox(experiments) {
const experimentList = Object.keys(experiments);
if (experimentList.length >= 1) {
logger.logger.warn(
'⚠️ experiments are enabled, we recommend do not use experiments in production, comment out this section to disable it'
'⚠️ experiments are enabled, it is recommended do not use experiments in production, comment out the experiments section to disable this warning'
);
experimentList.forEach((experiment) => {
logger.logger.warn(

@ -1,6 +1,9 @@
import { Command, Option } from 'clipanion';
import path from 'path';
import { warningUtils } from '@verdaccio/core';
import { ConfigYaml } from '@verdaccio/types';
import { listenDefaultCallback, startVerdaccio } from '../../bootstrap';
import findConfigFile from '../../config-path';
import { parseConfigFile } from '../../utils';
@ -49,23 +52,35 @@ export class InitCommand extends Command {
description: 'use this configuration file (default: ./config.yaml)',
});
private initLogger(logConfig: ConfigYaml) {
if (logConfig.logs) {
// @ts-expect-error
logConfig.log = logConfig.logs;
warningUtils.emit(warningUtils.Codes.VERWAR002);
}
// @ts-expect-error
logger.setup(logConfig.log);
}
async execute() {
let configPathLocation;
try {
configPathLocation = findConfigFile(this.config as string);
const verdaccioConfiguration: ReturnType<any> = parseConfigFile(configPathLocation);
if (!verdaccioConfiguration.self_path) {
verdaccioConfiguration.self_path = path.resolve(configPathLocation);
const configParsed: ReturnType<any> = parseConfigFile(configPathLocation);
if (!configParsed.self_path) {
configParsed.self_path = path.resolve(configPathLocation);
this.initLogger(configParsed);
// compatibility with 6.x plugins
configParsed.configPath = configParsed.self_path;
}
if (!verdaccioConfiguration.https) {
verdaccioConfiguration.https = { enable: false };
if (!configParsed.https) {
configParsed.https = { enable: false };
}
process.title =
(verdaccioConfiguration.web && verdaccioConfiguration.web.title) || 'verdaccio';
process.title = (configParsed.web && configParsed.web.title) || 'verdaccio';
startVerdaccio(
verdaccioConfiguration,
configParsed,
this.listen as string,
configPathLocation,
pkgVersion,
@ -74,8 +89,15 @@ export class InitCommand extends Command {
);
logger.logger.info({ file: configPathLocation }, 'config file - @{file}');
} catch (err) {
// eslint-disable-next-line no-console
console.error(`cannot open config file ${configPathLocation}: ${!err.message}`);
if (typeof logger?.logger?.fatal === 'function') {
logger.logger.fatal(
{ file: configPathLocation, err: err },
'cannot open config file @{file}: @{!err.message}'
);
} else {
// eslint-disable-next-line no-console
console.error(`cannot open config file ${configPathLocation}: ${!err.message}`);
}
process.exit(1);
}
}

@ -1,7 +1,4 @@
import assert from 'assert';
import buildDebug from 'debug';
import fs from 'fs';
import YAML from 'js-yaml';
import _ from 'lodash';
import semver from 'semver';
import { URL } from 'url';

@ -8,11 +8,10 @@ import { parseConfigFile } from '../../../../src/lib/utils';
setup([]);
const resolveConf = (conf) => {
const { name, ext } = path.parse(conf);
return path.join(__dirname, `../../../../conf/${name}${ext.startsWith('.') ? ext : '.yaml'}`);
const resolveConf = (conf, location = `../../../../conf/${conf}.yaml`) => {
return path.join(__dirname, location);
};
const checkDefaultUplink = (config) => {
expect(_.isObject(config.uplinks[DEFAULT_UPLINK])).toBeTruthy();
expect(config.uplinks[DEFAULT_UPLINK].url).toMatch(DEFAULT_REGISTRY);
@ -51,18 +50,16 @@ const checkDefaultConfPackages = (config) => {
expect(config.middlewares).toBeDefined();
expect(config.middlewares.audit).toBeDefined();
expect(config.middlewares.audit.enabled).toBeTruthy();
// logs
expect(config.logs.type).toEqual('stdout');
expect(config.logs.format).toEqual('pretty');
expect(config.logs.level).toEqual('http');
// log
expect(config.log.type).toEqual('stdout');
expect(config.log.format).toEqual('pretty');
expect(config.log.level).toEqual('http');
// must not be enabled by default
expect(config.notify).toBeUndefined();
expect(config.store).toBeUndefined();
expect(config.publish).toBeUndefined();
expect(config.url_prefix).toBeUndefined();
expect(config.url_prefix).toBeUndefined();
expect(config.experiments).toBeUndefined();
expect(config.security).toEqual({
api: { legacy: true },
web: { sign: { expiresIn: '1h' }, verify: {} },
@ -76,7 +73,7 @@ describe('Config file', () => {
this.config = new Config(parseConfigFile(resolveConf('default')));
});
describe('Config file', () => {
describe('default configurations', () => {
test('parse docker.yaml', () => {
const config = new Config(parseConfigFile(resolveConf('docker')));
checkDefaultUplink(config);
@ -84,6 +81,8 @@ describe('Config file', () => {
// @ts-ignore
expect(config.auth.htpasswd.file).toBe('/verdaccio/storage/htpasswd');
checkDefaultConfPackages(config);
// @ts-expect-error
expect(config.experiments).toBeUndefined();
});
test('parse default.yaml', () => {
@ -93,8 +92,12 @@ describe('Config file', () => {
// @ts-ignore
expect(config.auth.htpasswd.file).toBe('./htpasswd');
checkDefaultConfPackages(config);
// @ts-expect-error
expect(config.experiments).toBeUndefined();
});
});
describe('env variables', () => {
test('with process.env.VERDACCIO_STORAGE_PATH', () => {
const testPath = '/builds/project/foo/bar/baz';
// @ts-ignore
@ -108,4 +111,25 @@ describe('Config file', () => {
}
});
});
describe('with additional configurations', () => {
test('parse experiments.yaml', () => {
const config = new Config(
parseConfigFile(path.join(__dirname, './partials/experiments.yaml'))
);
checkDefaultUplink(config);
checkDefaultConfPackages(config);
// @ts-expect-error
expect(config.experiments).toEqual({
bytesin_off: false,
tarball_url_redirect: 'https://mycdn.com/verdaccio/${packageName}/${filename}',
token: false,
});
});
test('backward compability with logs', () => {
const config = new Config(parseConfigFile(path.join(__dirname, './partials/logs.yaml')));
// @ts-expect-error
expect(config.logs).toEqual({ format: 'pretty', level: 'http', type: 'stdout' });
});
});
});

@ -0,0 +1,33 @@
storage: ./storage
plugins: ./plugins
web:
title: Verdaccio
auth:
htpasswd:
file: ./htpasswd
uplinks:
npmjs:
url: https://registry.npmjs.org/
packages:
'@*/*':
access: $all
publish: $authenticated
unpublish: $authenticated
proxy: npmjs
'**':
access: $all
publish: $authenticated
unpublish: $authenticated
proxy: npmjs
server:
keepAliveTimeout: 60
middlewares:
audit:
enabled: true
log: { type: stdout, format: pretty, level: http }
experiments:
token: false
bytesin_off: false
tarball_url_redirect: 'https://mycdn.com/verdaccio/${packageName}/${filename}'

@ -0,0 +1,33 @@
storage: ./storage
plugins: ./plugins
web:
title: Verdaccio
auth:
htpasswd:
file: ./htpasswd
uplinks:
npmjs:
url: https://registry.npmjs.org/
packages:
'@*/*':
access: $all
publish: $authenticated
unpublish: $authenticated
proxy: npmjs
'**':
access: $all
publish: $authenticated
unpublish: $authenticated
proxy: npmjs
server:
keepAliveTimeout: 60
middlewares:
audit:
enabled: true
logs: { type: stdout, format: pretty, level: http }
experiments:
token: false
bytesin_off: false
tarball_url_redirect: 'https://mycdn.com/verdaccio/${packageName}/${filename}'

BIN
yarn.lock

Binary file not shown.