@verdaccio/config 6.0.0-6-next.10 → 6.0.0-6-next.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/build/conf/default.yaml +3 -5
- package/build/conf/docker.yaml +3 -3
- package/build/config-path.js +3 -3
- package/build/config-path.js.map +1 -1
- package/build/config.d.ts +2 -1
- package/build/config.js +12 -33
- package/build/config.js.map +1 -1
- package/build/package-access.js +2 -7
- package/build/package-access.js.map +1 -1
- package/build/parse.js.map +1 -1
- package/build/uplinks.js +2 -2
- package/build/uplinks.js.map +1 -1
- package/package.json +4 -4
- package/src/conf/default.yaml +3 -5
- package/src/conf/docker.yaml +3 -3
- package/src/config-path.ts +4 -3
- package/src/config.ts +13 -8
- package/src/package-access.ts +3 -1
- package/src/parse.ts +1 -0
- package/src/uplinks.ts +3 -2
- package/test/config.path.spec.ts +1 -0
- package/test/config.spec.ts +8 -8
- package/test/package-access.spec.ts +1 -1
- package/test/partials/config/js/default.js +1 -1
- package/test/partials/config/yaml/storage.yaml +1 -4
- package/test/token.spec.ts +1 -1
- package/test/uplinks.spec.ts +1 -1
- package/test/utils.spec.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,65 @@
|
|
|
1
1
|
# @verdaccio/config
|
|
2
2
|
|
|
3
|
+
## 6.0.0-6-next.13
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 82cb0f2b: feat!: config.logs throw an error, logging config not longer accept array or logs property
|
|
8
|
+
|
|
9
|
+
### 💥 Breaking change
|
|
10
|
+
|
|
11
|
+
This is valid
|
|
12
|
+
|
|
13
|
+
```yaml
|
|
14
|
+
log: { type: stdout, format: pretty, level: http }
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This is invalid
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
logs: { type: stdout, format: pretty, level: http }
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
or
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
logs:
|
|
27
|
+
- [{ type: stdout, format: pretty, level: http }]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Minor Changes
|
|
31
|
+
|
|
32
|
+
- 5167bb52: feat: ui search support for remote, local and private packages
|
|
33
|
+
|
|
34
|
+
The command `npm search` search globally and return all matches, with this improvement the user interface
|
|
35
|
+
is powered with the same capabilities.
|
|
36
|
+
|
|
37
|
+
The UI also tag where is the origin the package with a tag, also provide the latest version and description of the package.
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Updated dependencies [82cb0f2b]
|
|
42
|
+
- Updated dependencies [5167bb52]
|
|
43
|
+
- @verdaccio/core@6.0.0-6-next.5
|
|
44
|
+
- @verdaccio/utils@6.0.0-6-next.11
|
|
45
|
+
|
|
46
|
+
## 6.0.0-6-next.12
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- Updated dependencies [a828271d]
|
|
51
|
+
- Updated dependencies [24b9be02]
|
|
52
|
+
- Updated dependencies [b13a3fef]
|
|
53
|
+
- @verdaccio/utils@6.0.0-6-next.10
|
|
54
|
+
- @verdaccio/core@6.0.0-6-next.4
|
|
55
|
+
|
|
56
|
+
## 6.0.0-6-next.11
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- Updated dependencies [f86c31ed]
|
|
61
|
+
- @verdaccio/utils@6.0.0-6-next.9
|
|
62
|
+
|
|
3
63
|
## 6.0.0-6-next.10
|
|
4
64
|
|
|
5
65
|
### Patch Changes
|
package/build/conf/default.yaml
CHANGED
|
@@ -3,15 +3,13 @@
|
|
|
3
3
|
# so don't use it on production systems.
|
|
4
4
|
#
|
|
5
5
|
# Look here for more config file examples:
|
|
6
|
-
# https://github.com/verdaccio/verdaccio/tree/master/conf
|
|
6
|
+
# https://github.com/verdaccio/verdaccio/tree/master/packages/config/src/conf
|
|
7
7
|
#
|
|
8
8
|
|
|
9
9
|
# path to a directory with all packages
|
|
10
10
|
storage: ./storage
|
|
11
11
|
# path to a directory with plugins to include
|
|
12
12
|
plugins: ./plugins
|
|
13
|
-
# print logs
|
|
14
|
-
# logs: ./logs
|
|
15
13
|
|
|
16
14
|
web:
|
|
17
15
|
title: Verdaccio
|
|
@@ -67,7 +65,7 @@ packages:
|
|
|
67
65
|
# and three keywords: "$all", "$anonymous", "$authenticated"
|
|
68
66
|
access: $all
|
|
69
67
|
|
|
70
|
-
# allow all known users to publish/
|
|
68
|
+
# allow all known users to publish/unpublish packages
|
|
71
69
|
# (anyone can register by default, remember?)
|
|
72
70
|
publish: $authenticated
|
|
73
71
|
unpublish: $authenticated
|
|
@@ -87,7 +85,7 @@ middlewares:
|
|
|
87
85
|
enabled: true
|
|
88
86
|
|
|
89
87
|
# log settings
|
|
90
|
-
|
|
88
|
+
log:
|
|
91
89
|
# Logger as STDOUT
|
|
92
90
|
{ type: stdout, format: pretty, level: http }
|
|
93
91
|
# Logger as STDOUT as JSON
|
package/build/conf/docker.yaml
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
# see https://verdaccio.org/docs/en/docker#docker-and-custom-port-configuration
|
|
8
8
|
#
|
|
9
9
|
# Look here for more config file examples:
|
|
10
|
-
# https://github.com/verdaccio/verdaccio/tree/master/conf
|
|
10
|
+
# https://github.com/verdaccio/verdaccio/tree/master/packages/config/src/conf
|
|
11
11
|
#
|
|
12
12
|
|
|
13
13
|
# path to a directory with all packages
|
|
@@ -58,7 +58,7 @@ packages:
|
|
|
58
58
|
# and three keywords: "$all", "$anonymous", "$authenticated"
|
|
59
59
|
access: $all
|
|
60
60
|
|
|
61
|
-
# allow all known users to publish/
|
|
61
|
+
# allow all known users to publish/unpublish packages
|
|
62
62
|
# (anyone can register by default, remember?)
|
|
63
63
|
publish: $authenticated
|
|
64
64
|
unpublish: $authenticated
|
|
@@ -72,7 +72,7 @@ middlewares:
|
|
|
72
72
|
|
|
73
73
|
# log settings
|
|
74
74
|
# log settings
|
|
75
|
-
|
|
75
|
+
log:
|
|
76
76
|
# Logger as STDOUT
|
|
77
77
|
{ type: stdout, format: pretty, level: http }
|
|
78
78
|
# Logger as STDOUT as JSON
|
package/build/config-path.js
CHANGED
|
@@ -6,13 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.findConfigFile = findConfigFile;
|
|
7
7
|
exports.readDefaultConfig = readDefaultConfig;
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
12
12
|
|
|
13
13
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _path = _interopRequireDefault(require("path"));
|
|
16
16
|
|
|
17
17
|
var _core = require("@verdaccio/core");
|
|
18
18
|
|
package/build/config-path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/config-path.ts"],"names":["CONFIG_FILE","XDG","WIN","WIN32","pkgJSON","name","debug","findConfigFile","configPath","path","resolve","configPaths","getConfigPaths","length","_","isEmpty","Error","primaryConf","find","configLocation","createConfigFile","head","createConfigFolder","defaultConfig","updateStorageLinks","readDefaultConfig","fs","writeFileSync","pathDefaultConf","__dirname","accessSync","constants","R_OK","TypeError","readFileSync","CHARACTER_ENCODING","UTF8","mkdirSync","dirname","recursive","type","dataDir","process","env","XDG_DATA_HOME","join","HOME","replace","listPaths","getXDGDirectory","getWindowsDirectory","getRelativeDefaultDirectory","getOldDirectory","reduce","acc","currentValue","push","xDGConfigPath","XDG_CONFIG_HOME","platform","APPDATA"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;AAEA,MAAMA,WAAW,GAAG,aAApB;AACA,MAAMC,GAAG,GAAG,KAAZ;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C;AAFD,KAAP;AAID;AACF,CAVD;AAYA;AACA;AACA;AACA;AACA;;;AACA,MAAMiD,mBAAmB,GAAG,MAA6B;AACvD,MAAIR,OAAO,CAACiB,QAAR,KAAqBxD,KAArB,IAA8BuC,OAAO,CAACC,GAAR,CAAYiB,OAA1C,IAAqD,+BAAalB,OAAO,CAACC,GAAR,CAAYiB,OAAzB,CAAzD,EAA4F;AAC1FtD,IAAAA,KAAK,CAAC,wBAAD,EAA2BoC,OAAO,CAACC,GAAR,CAAYiB,OAAvC,CAAL;AACA,WAAO;AACLnD,MAAAA,IAAI,EAAEA,cAAKC,OAAL,CAAaD,cAAKoC,IAAL,CAAUH,OAAO,CAACC,GAAR,CAAYiB,OAAtB,EAA+BxD,OAAO,CAACC,IAAvC,EAA6CL,WAA7C,CAAb,CADD;AAELwC,MAAAA,IAAI,EAAEtC;AAFD,KAAP;AAID;AACF,CARD;AAUA;AACA;AACA;AACA;AACA;;;AACA,MAAMiD,2BAA2B,GAAG,MAAsB;AACxD,SAAO;AACL1C,IAAAA,IAAI,EAAEA,cAAKC,OAAL,CAAaD,cAAKoC,IAAL,CAAU,GAAV,EAAezC,OAAO,CAACC,IAAvB,EAA6BL,WAA7B,CAAb,CADD;AAELwC,IAAAA,IAAI,EAAE;AAFD,GAAP;AAID,CALD;AAOA;AACA;AACA;AACA;;;AACA,MAAMY,eAAe,GAAG,MAAsB;AAC5C,SAAO;AACL3C,IAAAA,IAAI,EAAEA,cAAKC,OAAL,CAAaD,cAAKoC,IAAL,CAAU,GAAV,EAAe7C,WAAf,CAAb,CADD;AAELwC,IAAAA,IAAI,EAAE;AAFD,GAAP;AAID,CALD","sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport _ from 'lodash';\nimport buildDebug from 'debug';\n\nimport { CHARACTER_ENCODING } from '@verdaccio/core';\nimport { folderExists, fileExists } from './config-utils';\n\nconst CONFIG_FILE = 'config.yaml';\nconst XDG = 'xdg';\nconst WIN = 'win';\nconst WIN32 = 'win32';\n// eslint-disable-next-line\nconst pkgJSON = {\n name: 'verdaccio',\n};\n\nexport type SetupDirectory = {\n path: string;\n type: string;\n};\n\nconst debug = buildDebug('verdaccio:config');\n\n/**\n * Find and get the first config file that match.\n * @return {String} the config file path\n */\nfunction findConfigFile(configPath?: string): string {\n // console.log(process.env);\n if (typeof configPath !== 'undefined') {\n return path.resolve(configPath);\n }\n\n const configPaths: SetupDirectory[] = getConfigPaths();\n debug('%o posible locations found', configPaths.length);\n if (_.isEmpty(configPaths)) {\n // this should never happens\n throw new Error('no configuration files can be processed');\n }\n\n // find the first location that already exist\n const primaryConf: SetupDirectory | void = _.find(configPaths, (configLocation: SetupDirectory) =>\n fileExists(configLocation.path)\n );\n\n if (typeof primaryConf !== 'undefined') {\n debug('previous location exist already %s', primaryConf?.path);\n return primaryConf.path;\n }\n\n // @ts-ignore\n return createConfigFile(_.head(configPaths)).path;\n}\n\nfunction createConfigFile(configLocation: SetupDirectory): SetupDirectory {\n createConfigFolder(configLocation);\n\n const defaultConfig = updateStorageLinks(configLocation, readDefaultConfig());\n\n fs.writeFileSync(configLocation.path, defaultConfig);\n\n return configLocation;\n}\n\nexport function readDefaultConfig(): Buffer {\n const pathDefaultConf: string = path.resolve(__dirname, 'conf/default.yaml');\n try {\n debug('default configuration file %s', pathDefaultConf);\n fs.accessSync(pathDefaultConf, fs.constants.R_OK);\n } catch {\n throw new TypeError('configuration file does not have enough permissions for reading');\n }\n // @ts-ignore\n return fs.readFileSync(pathDefaultConf, CHARACTER_ENCODING.UTF8);\n}\n\nfunction createConfigFolder(configLocation): void {\n fs.mkdirSync(path.dirname(configLocation.path), { recursive: true });\n debug(`Creating default config file in %o`, configLocation?.path);\n}\n\nfunction updateStorageLinks(configLocation, defaultConfig): string {\n if (configLocation.type !== XDG) {\n return defaultConfig;\n }\n\n // $XDG_DATA_HOME defines the base directory relative to which user specific data\n // files should be stored, If $XDG_DATA_HOME is either not set or empty, a default\n // equal to $HOME/.local/share should be used.\n let dataDir =\n process.env.XDG_DATA_HOME || path.join(process.env.HOME as string, '.local', 'share');\n if (folderExists(dataDir)) {\n debug(`previous storage located`);\n debug(`update storage links to %s`, dataDir);\n dataDir = path.resolve(path.join(dataDir, pkgJSON.name, 'storage'));\n return defaultConfig.replace(/^storage: .\\/storage$/m, `storage: ${dataDir}`);\n }\n debug(`could not find a previous storage location, skip override`);\n return defaultConfig;\n}\n\n/**\n * Return a list of configuration locations by platform.\n * @returns\n */\nfunction getConfigPaths(): SetupDirectory[] {\n const listPaths: (SetupDirectory | void)[] = [\n getXDGDirectory(),\n getWindowsDirectory(),\n getRelativeDefaultDirectory(),\n getOldDirectory(),\n ];\n\n return listPaths.reduce(function (acc, currentValue: SetupDirectory | void): SetupDirectory[] {\n if (typeof currentValue !== 'undefined') {\n debug('directory detected path %s for type %s', currentValue?.path, currentValue.type);\n acc.push(currentValue);\n }\n return acc;\n }, [] as SetupDirectory[]);\n}\n\n/**\n * Get XDG_CONFIG_HOME or HOME location (usually unix)\n * @returns\n */\nconst getXDGDirectory = (): SetupDirectory | void => {\n const xDGConfigPath =\n process.env.XDG_CONFIG_HOME || (process.env.HOME && path.join(process.env.HOME, '.config'));\n if (xDGConfigPath && folderExists(xDGConfigPath)) {\n debug('XDGConfig folder path %s', xDGConfigPath);\n return {\n path: path.join(xDGConfigPath, pkgJSON.name, CONFIG_FILE),\n type: XDG,\n };\n }\n};\n\n/**\n * Detect windows location, APPDATA\n * usually something like C:\\User\\<Build User>\\AppData\\Local\n * @returns\n */\nconst getWindowsDirectory = (): SetupDirectory | void => {\n if (process.platform === WIN32 && process.env.APPDATA && folderExists(process.env.APPDATA)) {\n debug('is windows appdata: %s', process.env.APPDATA);\n return {\n path: path.resolve(path.join(process.env.APPDATA, pkgJSON.name, CONFIG_FILE)),\n type: WIN,\n };\n }\n};\n\n/**\n * Return relative directory, this is the default.\n * It will cretate config in your {currentLocation/verdaccio/config.yaml}\n * @returns\n */\nconst getRelativeDefaultDirectory = (): SetupDirectory => {\n return {\n path: path.resolve(path.join('.', pkgJSON.name, CONFIG_FILE)),\n type: 'def',\n };\n};\n\n/**\n * This should never happens, consider it DEPRECATED\n * @returns\n */\nconst getOldDirectory = (): SetupDirectory => {\n return {\n path: path.resolve(path.join('.', CONFIG_FILE)),\n type: 'old',\n };\n};\n\nexport { findConfigFile };\n"],"file":"config-path.js"}
|
|
1
|
+
{"version":3,"sources":["../src/config-path.ts"],"names":["CONFIG_FILE","XDG","WIN","WIN32","pkgJSON","name","debug","findConfigFile","configPath","path","resolve","configPaths","getConfigPaths","length","_","isEmpty","Error","primaryConf","find","configLocation","createConfigFile","head","createConfigFolder","defaultConfig","updateStorageLinks","readDefaultConfig","fs","writeFileSync","pathDefaultConf","__dirname","accessSync","constants","R_OK","TypeError","readFileSync","CHARACTER_ENCODING","UTF8","mkdirSync","dirname","recursive","type","dataDir","process","env","XDG_DATA_HOME","join","HOME","replace","listPaths","getXDGDirectory","getWindowsDirectory","getRelativeDefaultDirectory","getOldDirectory","reduce","acc","currentValue","push","xDGConfigPath","XDG_CONFIG_HOME","platform","APPDATA"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;;;AAEA,MAAMA,WAAW,GAAG,aAApB;AACA,MAAMC,GAAG,GAAG,KAAZ;AACA,MAAMC,GAAG,GAAG,KAAZ;AACA,MAAMC,KAAK,GAAG,OAAd,C,CACA;;AACA,MAAMC,OAAO,GAAG;AACdC,EAAAA,IAAI,EAAE;AADQ,CAAhB;AASA,MAAMC,KAAK,GAAG,oBAAW,kBAAX,CAAd;AAEA;AACA;AACA;AACA;;AACA,SAASC,cAAT,CAAwBC,UAAxB,EAAqD;AACnD;AACA,MAAI,OAAOA,UAAP,KAAsB,WAA1B,EAAuC;AACrC,WAAOC,cAAKC,OAAL,CAAaF,UAAb,CAAP;AACD;;AAED,QAAMG,WAA6B,GAAGC,cAAc,EAApD;AACAN,EAAAA,KAAK,CAAC,4BAAD,EAA+BK,WAAW,CAACE,MAA3C,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OAAtB,EAA+BxD,OAAO,CAACC,IAAvC,EAA6CL,WAA7C,CAAb,CADD;AAELwC,MAAAA,IAAI,EAAEtC;AAFD,KAAP;AAID;AACF,CARD;AAUA;AACA;AACA;AACA;AACA;;;AACA,MAAMiD,2BAA2B,GAAG,MAAsB;AACxD,SAAO;AACL1C,IAAAA,IAAI,EAAEA,cAAKC,OAAL,CAAaD,cAAKoC,IAAL,CAAU,GAAV,EAAezC,OAAO,CAACC,IAAvB,EAA6BL,WAA7B,CAAb,CADD;AAELwC,IAAAA,IAAI,EAAE;AAFD,GAAP;AAID,CALD;AAOA;AACA;AACA;AACA;;;AACA,MAAMY,eAAe,GAAG,MAAsB;AAC5C,SAAO;AACL3C,IAAAA,IAAI,EAAEA,cAAKC,OAAL,CAAaD,cAAKoC,IAAL,CAAU,GAAV,EAAe7C,WAAf,CAAb,CADD;AAELwC,IAAAA,IAAI,EAAE;AAFD,GAAP;AAID,CALD","sourcesContent":["import buildDebug from 'debug';\nimport fs from 'fs';\nimport _ from 'lodash';\nimport path from 'path';\n\nimport { CHARACTER_ENCODING } from '@verdaccio/core';\n\nimport { fileExists, folderExists } from './config-utils';\n\nconst CONFIG_FILE = 'config.yaml';\nconst XDG = 'xdg';\nconst WIN = 'win';\nconst WIN32 = 'win32';\n// eslint-disable-next-line\nconst pkgJSON = {\n name: 'verdaccio',\n};\n\nexport type SetupDirectory = {\n path: string;\n type: string;\n};\n\nconst debug = buildDebug('verdaccio:config');\n\n/**\n * Find and get the first config file that match.\n * @return {String} the config file path\n */\nfunction findConfigFile(configPath?: string): string {\n // console.log(process.env);\n if (typeof configPath !== 'undefined') {\n return path.resolve(configPath);\n }\n\n const configPaths: SetupDirectory[] = getConfigPaths();\n debug('%o posible locations found', configPaths.length);\n if (_.isEmpty(configPaths)) {\n // this should never happens\n throw new Error('no configuration files can be processed');\n }\n\n // find the first location that already exist\n const primaryConf: SetupDirectory | void = _.find(configPaths, (configLocation: SetupDirectory) =>\n fileExists(configLocation.path)\n );\n\n if (typeof primaryConf !== 'undefined') {\n debug('previous location exist already %s', primaryConf?.path);\n return primaryConf.path;\n }\n\n // @ts-ignore\n return createConfigFile(_.head(configPaths)).path;\n}\n\nfunction createConfigFile(configLocation: SetupDirectory): SetupDirectory {\n createConfigFolder(configLocation);\n\n const defaultConfig = updateStorageLinks(configLocation, readDefaultConfig());\n\n fs.writeFileSync(configLocation.path, defaultConfig);\n\n return configLocation;\n}\n\nexport function readDefaultConfig(): Buffer {\n const pathDefaultConf: string = path.resolve(__dirname, 'conf/default.yaml');\n try {\n debug('default configuration file %s', pathDefaultConf);\n fs.accessSync(pathDefaultConf, fs.constants.R_OK);\n } catch {\n throw new TypeError('configuration file does not have enough permissions for reading');\n }\n // @ts-ignore\n return fs.readFileSync(pathDefaultConf, CHARACTER_ENCODING.UTF8);\n}\n\nfunction createConfigFolder(configLocation): void {\n fs.mkdirSync(path.dirname(configLocation.path), { recursive: true });\n debug(`Creating default config file in %o`, configLocation?.path);\n}\n\nfunction updateStorageLinks(configLocation, defaultConfig): string {\n if (configLocation.type !== XDG) {\n return defaultConfig;\n }\n\n // $XDG_DATA_HOME defines the base directory relative to which user specific data\n // files should be stored, If $XDG_DATA_HOME is either not set or empty, a default\n // equal to $HOME/.local/share should be used.\n let dataDir =\n process.env.XDG_DATA_HOME || path.join(process.env.HOME as string, '.local', 'share');\n if (folderExists(dataDir)) {\n debug(`previous storage located`);\n debug(`update storage links to %s`, dataDir);\n dataDir = path.resolve(path.join(dataDir, pkgJSON.name, 'storage'));\n return defaultConfig.replace(/^storage: .\\/storage$/m, `storage: ${dataDir}`);\n }\n debug(`could not find a previous storage location, skip override`);\n return defaultConfig;\n}\n\n/**\n * Return a list of configuration locations by platform.\n * @returns\n */\nfunction getConfigPaths(): SetupDirectory[] {\n const listPaths: (SetupDirectory | void)[] = [\n getXDGDirectory(),\n getWindowsDirectory(),\n getRelativeDefaultDirectory(),\n getOldDirectory(),\n ];\n\n return listPaths.reduce(function (acc, currentValue: SetupDirectory | void): SetupDirectory[] {\n if (typeof currentValue !== 'undefined') {\n debug('directory detected path %s for type %s', currentValue?.path, currentValue.type);\n acc.push(currentValue);\n }\n return acc;\n }, [] as SetupDirectory[]);\n}\n\n/**\n * Get XDG_CONFIG_HOME or HOME location (usually unix)\n * @returns\n */\nconst getXDGDirectory = (): SetupDirectory | void => {\n const xDGConfigPath =\n process.env.XDG_CONFIG_HOME || (process.env.HOME && path.join(process.env.HOME, '.config'));\n if (xDGConfigPath && folderExists(xDGConfigPath)) {\n debug('XDGConfig folder path %s', xDGConfigPath);\n return {\n path: path.join(xDGConfigPath, pkgJSON.name, CONFIG_FILE),\n type: XDG,\n };\n }\n};\n\n/**\n * Detect windows location, APPDATA\n * usually something like C:\\User\\<Build User>\\AppData\\Local\n * @returns\n */\nconst getWindowsDirectory = (): SetupDirectory | void => {\n if (process.platform === WIN32 && process.env.APPDATA && folderExists(process.env.APPDATA)) {\n debug('is windows appdata: %s', process.env.APPDATA);\n return {\n path: path.resolve(path.join(process.env.APPDATA, pkgJSON.name, CONFIG_FILE)),\n type: WIN,\n };\n }\n};\n\n/**\n * Return relative directory, this is the default.\n * It will cretate config in your {currentLocation/verdaccio/config.yaml}\n * @returns\n */\nconst getRelativeDefaultDirectory = (): SetupDirectory => {\n return {\n path: path.resolve(path.join('.', pkgJSON.name, CONFIG_FILE)),\n type: 'def',\n };\n};\n\n/**\n * This should never happens, consider it DEPRECATED\n * @returns\n */\nconst getOldDirectory = (): SetupDirectory => {\n return {\n path: path.resolve(path.join('.', CONFIG_FILE)),\n type: 'old',\n };\n};\n\nexport { findConfigFile };\n"],"file":"config-path.js"}
|
package/build/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Config as AppConfig, AuthConf, ConfigRuntime, FlagsConfig, PackageAccess, PackageList, Security, ServerSettingsConf } from '@verdaccio/types';
|
|
2
2
|
export declare const WEB_TITLE = "Verdaccio";
|
|
3
3
|
/**
|
|
4
4
|
* Coordinates the application configuration
|
|
@@ -16,6 +16,7 @@ declare class Config implements AppConfig {
|
|
|
16
16
|
security: Security;
|
|
17
17
|
serverSettings: ServerSettingsConf;
|
|
18
18
|
secret: string;
|
|
19
|
+
flags: FlagsConfig;
|
|
19
20
|
constructor(config: ConfigRuntime);
|
|
20
21
|
/**
|
|
21
22
|
* Check for package spec
|
package/build/config.js
CHANGED
|
@@ -7,29 +7,27 @@ exports.WEB_TITLE = exports.Config = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _assert = _interopRequireDefault(require("assert"));
|
|
9
9
|
|
|
10
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
11
|
-
|
|
12
10
|
var _debug = _interopRequireDefault(require("debug"));
|
|
13
11
|
|
|
14
|
-
var
|
|
12
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
15
13
|
|
|
16
14
|
var _core = require("@verdaccio/core");
|
|
17
15
|
|
|
18
|
-
var
|
|
16
|
+
var _utils = require("@verdaccio/utils");
|
|
19
17
|
|
|
20
|
-
var
|
|
18
|
+
var _agent = require("./agent");
|
|
21
19
|
|
|
22
|
-
var
|
|
20
|
+
var _packageAccess = require("./package-access");
|
|
23
21
|
|
|
24
22
|
var _security = require("./security");
|
|
25
23
|
|
|
26
|
-
var _agent = require("./agent");
|
|
27
|
-
|
|
28
24
|
var _serverSettings = _interopRequireDefault(require("./serverSettings"));
|
|
29
25
|
|
|
30
|
-
|
|
26
|
+
var _token = require("./token");
|
|
31
27
|
|
|
32
|
-
|
|
28
|
+
var _uplinks = require("./uplinks");
|
|
29
|
+
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
31
|
|
|
34
32
|
const strategicConfigProps = ['uplinks', 'packages'];
|
|
35
33
|
const allowedEnvConfig = ['http_proxy', 'https_proxy', 'no_proxy'];
|
|
@@ -44,29 +42,7 @@ exports.WEB_TITLE = WEB_TITLE;
|
|
|
44
42
|
class Config {
|
|
45
43
|
// @ts-ignore
|
|
46
44
|
constructor(config) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
_defineProperty(this, "uplinks", void 0);
|
|
50
|
-
|
|
51
|
-
_defineProperty(this, "packages", void 0);
|
|
52
|
-
|
|
53
|
-
_defineProperty(this, "users", void 0);
|
|
54
|
-
|
|
55
|
-
_defineProperty(this, "auth", void 0);
|
|
56
|
-
|
|
57
|
-
_defineProperty(this, "server_id", void 0);
|
|
58
|
-
|
|
59
|
-
_defineProperty(this, "config_path", void 0);
|
|
60
|
-
|
|
61
|
-
_defineProperty(this, "storage", void 0);
|
|
62
|
-
|
|
63
|
-
_defineProperty(this, "plugins", void 0);
|
|
64
|
-
|
|
65
|
-
_defineProperty(this, "security", void 0);
|
|
66
|
-
|
|
67
|
-
_defineProperty(this, "serverSettings", void 0);
|
|
68
|
-
|
|
69
|
-
_defineProperty(this, "secret", void 0);
|
|
45
|
+
var _config$flags;
|
|
70
46
|
|
|
71
47
|
const self = this;
|
|
72
48
|
this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;
|
|
@@ -74,6 +50,9 @@ class Config {
|
|
|
74
50
|
this.plugins = config.plugins;
|
|
75
51
|
this.security = _lodash.default.merge(_security.defaultSecurity, config.security);
|
|
76
52
|
this.serverSettings = _serverSettings.default;
|
|
53
|
+
this.flags = {
|
|
54
|
+
searchRemote: ((_config$flags = config.flags) === null || _config$flags === void 0 ? void 0 : _config$flags.searchRemote) ?? true
|
|
55
|
+
};
|
|
77
56
|
|
|
78
57
|
for (const configProp in config) {
|
|
79
58
|
if (self[configProp] == null) {
|
package/build/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/config.ts"],"names":["strategicConfigProps","allowedEnvConfig","debug","WEB_TITLE","Config","constructor","config","self","storage","process","env","VERDACCIO_STORAGE_PATH","config_path","plugins","security","_","merge","defaultSecurity","serverSettings","configProp","isNil","user_agent","isObject","APP_ERROR","CONFIG_NOT_VALID","forEach","x","uplinks","packages","envConf","toUpperCase","server_id","getMatchedPackagesSpec","pkgName","checkSecretKey","secret","isString","isEmpty"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;
|
|
1
|
+
{"version":3,"sources":["../src/config.ts"],"names":["strategicConfigProps","allowedEnvConfig","debug","WEB_TITLE","Config","constructor","config","self","storage","process","env","VERDACCIO_STORAGE_PATH","config_path","plugins","security","_","merge","defaultSecurity","serverSettings","flags","searchRemote","configProp","isNil","user_agent","isObject","APP_ERROR","CONFIG_NOT_VALID","forEach","x","uplinks","packages","envConf","toUpperCase","server_id","getMatchedPackagesSpec","pkgName","checkSecretKey","secret","isString","isEmpty"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAWA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,oBAAoB,GAAG,CAAC,SAAD,EAAY,UAAZ,CAA7B;AACA,MAAMC,gBAAgB,GAAG,CAAC,YAAD,EAAe,aAAf,EAA8B,UAA9B,CAAzB;AACA,MAAMC,KAAK,GAAG,oBAAW,kBAAX,CAAd;AAEO,MAAMC,SAAS,GAAG,WAAlB;AAEP;AACA;AACA;;;;AACA,MAAMC,MAAN,CAAkC;AAYhC;AAIOC,EAAAA,WAAW,CAACC,MAAD,EAAwB;AAAA;;AACxC,UAAMC,IAAI,GAAG,IAAb;AACA,SAAKC,OAAL,GAAeC,OAAO,CAACC,GAAR,CAAYC,sBAAZ,IAAsCL,MAAM,CAACE,OAA5D;AACA,SAAKI,WAAL,GAAmBN,MAAM,CAACM,WAA1B;AACA,SAAKC,OAAL,GAAeP,MAAM,CAACO,OAAtB;AACA,SAAKC,QAAL,GAAgBC,gBAAEC,KAAF,CAAQC,yBAAR,EAAyBX,MAAM,CAACQ,QAAhC,CAAhB;AACA,SAAKI,cAAL,GAAsBA,uBAAtB;AACA,SAAKC,KAAL,GAAa;AACXC,MAAAA,YAAY,EAAE,kBAAAd,MAAM,CAACa,KAAP,gEAA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,WAAKA,SAAL,GAAiB,oCAAwB,CAAxB,CAAjB;AACD;AACF;AAED;AACF;AACA;;;AACSC,EAAAA,sBAAsB,CAACC,OAAD,EAAwC;AACnE;AACA,WAAO,mCAAuBA,OAAvB,EAAgC,KAAKL,QAArC,CAAP;AACD;AAED;AACF;AACA;;;AACSM,EAAAA,cAAc,CAACC,MAAD,EAA0B;AAC7CnC,IAAAA,KAAK,CAAC,kBAAD,CAAL;;AACA,QAAIa,gBAAEuB,QAAF,CAAWD,MAAX,KAAsBtB,gBAAEwB,OAAF,CAAUF,MAAV,MAAsB,KAAhD,EAAuD;AACrD,WAAKA,MAAL,GAAcA,MAAd;AACAnC,MAAAA,KAAK,CAAC,sBAAD,CAAL;AACA,aAAOmC,MAAP;AACD,KAN4C,CAO7C;AACA;;;AACAnC,IAAAA,KAAK,CAAC,oBAAD,CAAL;AACA,SAAKmC,MAAL,GAAc,qCAAd;AACA,WAAO,KAAKA,MAAZ;AACD;;AA1F+B","sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { APP_ERROR } from '@verdaccio/core';\nimport {\n Config as AppConfig,\n AuthConf,\n ConfigRuntime,\n FlagsConfig,\n PackageAccess,\n PackageList,\n Security,\n ServerSettingsConf,\n} from '@verdaccio/types';\nimport { generateRandomHexString, getMatchedPackagesSpec, isObject } from '@verdaccio/utils';\n\nimport { getUserAgent } from './agent';\nimport { normalisePackageAccess } from './package-access';\nimport { defaultSecurity } from './security';\nimport serverSettings from './serverSettings';\nimport { generateRandomSecretKey } from './token';\nimport { sanityCheckUplinksProps, uplinkSanityCheck } from './uplinks';\n\nconst strategicConfigProps = ['uplinks', 'packages'];\nconst allowedEnvConfig = ['http_proxy', 'https_proxy', 'no_proxy'];\nconst debug = buildDebug('verdaccio:config');\n\nexport const WEB_TITLE = 'Verdaccio';\n\n/**\n * Coordinates the application configuration\n */\nclass Config implements AppConfig {\n public user_agent: string;\n public uplinks: any;\n public packages: PackageList;\n public users: any;\n public auth: AuthConf;\n public server_id: string;\n public config_path: string;\n public storage: string | void;\n public plugins: string | void;\n public security: Security;\n public serverSettings: ServerSettingsConf;\n // @ts-ignore\n public secret: string;\n public flags: FlagsConfig;\n\n public constructor(config: ConfigRuntime) {\n const self = this;\n this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;\n this.config_path = config.config_path;\n this.plugins = config.plugins;\n this.security = _.merge(defaultSecurity, config.security);\n this.serverSettings = serverSettings;\n this.flags = {\n searchRemote: config.flags?.searchRemote ?? true,\n };\n\n for (const configProp in config) {\n if (self[configProp] == null) {\n self[configProp] = config[configProp];\n }\n }\n\n // @ts-ignore\n if (_.isNil(this.user_agent)) {\n this.user_agent = getUserAgent();\n }\n\n // some weird shell scripts are valid yaml files parsed as string\n assert(_.isObject(config), APP_ERROR.CONFIG_NOT_VALID);\n\n // sanity check for strategic config properties\n strategicConfigProps.forEach(function (x): void {\n if (self[x] == null) {\n self[x] = {};\n }\n\n assert(isObject(self[x]), `CONFIG: bad \"${x}\" value (object expected)`);\n });\n\n this.uplinks = sanityCheckUplinksProps(uplinkSanityCheck(this.uplinks));\n this.packages = normalisePackageAccess(self.packages);\n\n // loading these from ENV if aren't in config\n allowedEnvConfig.forEach((envConf): void => {\n if (!(envConf in self)) {\n self[envConf] = process.env[envConf] || process.env[envConf.toUpperCase()];\n }\n });\n\n // unique identifier of self server (or a cluster), used to avoid loops\n // @ts-ignore\n if (!this.server_id) {\n this.server_id = generateRandomHexString(6);\n }\n }\n\n /**\n * Check for package spec\n */\n public getMatchedPackagesSpec(pkgName: string): PackageAccess | void {\n // TODO: remove this method and replace by library utils\n return getMatchedPackagesSpec(pkgName, this.packages);\n }\n\n /**\n * Store or create whether receive a secret key\n */\n public checkSecretKey(secret?: string): string {\n debug('check secret key');\n if (_.isString(secret) && _.isEmpty(secret) === false) {\n this.secret = secret;\n debug('reusing previous key');\n return secret;\n }\n // it generates a secret key\n // FUTURE: this might be an external secret key, perhaps within config file?\n debug('generate a new key');\n this.secret = generateRandomSecretKey();\n return this.secret;\n }\n}\n\nexport { Config };\n"],"file":"config.js"}
|
package/build/package-access.js
CHANGED
|
@@ -15,12 +15,6 @@ var _core = require("@verdaccio/core");
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
21
|
-
|
|
22
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
|
-
|
|
24
18
|
const ROLES = {
|
|
25
19
|
$ALL: '$all',
|
|
26
20
|
ALL: 'all',
|
|
@@ -58,7 +52,8 @@ function normalizeUserList(groupsList) {
|
|
|
58
52
|
}
|
|
59
53
|
|
|
60
54
|
function normalisePackageAccess(packages) {
|
|
61
|
-
const normalizedPkgs =
|
|
55
|
+
const normalizedPkgs = { ...packages
|
|
56
|
+
};
|
|
62
57
|
|
|
63
58
|
if (_lodash.default.isNil(normalizedPkgs['**'])) {
|
|
64
59
|
normalizedPkgs['**'] = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/package-access.ts"],"names":["ROLES","$ALL","ALL","$AUTH","$ANONYMOUS","DEPRECATED_ALL","DEPRECATED_AUTH","DEPRECATED_ANONYMOUS","PACKAGE_ACCESS","SCOPE","normalizeUserList","groupsList","result","_","isNil","isString","groupsArray","split","push","Array","isArray","errorUtils","getInternalError","JSON","stringify","flatten","normalisePackageAccess","packages","normalizedPkgs","access","publish","unpublish","proxy","pkg","Object","prototype","hasOwnProperty","call","packageAccess","isInvalid","isObject","isUndefined"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA
|
|
1
|
+
{"version":3,"sources":["../src/package-access.ts"],"names":["ROLES","$ALL","ALL","$AUTH","$ANONYMOUS","DEPRECATED_ALL","DEPRECATED_AUTH","DEPRECATED_ANONYMOUS","PACKAGE_ACCESS","SCOPE","normalizeUserList","groupsList","result","_","isNil","isString","groupsArray","split","push","Array","isArray","errorUtils","getInternalError","JSON","stringify","flatten","normalisePackageAccess","packages","normalizedPkgs","access","publish","unpublish","proxy","pkg","Object","prototype","hasOwnProperty","call","packageAccess","isInvalid","isObject","isUndefined"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA;;;;AAOO,MAAMA,KAAK,GAAG;AACnBC,EAAAA,IAAI,EAAE,MADa;AAEnBC,EAAAA,GAAG,EAAE,KAFc;AAGnBC,EAAAA,KAAK,EAAE,gBAHY;AAInBC,EAAAA,UAAU,EAAE,YAJO;AAKnBC,EAAAA,cAAc,EAAE,MALG;AAMnBC,EAAAA,eAAe,EAAE,gBANE;AAOnBC,EAAAA,oBAAoB,EAAE;AAPH,CAAd;;AAUA,MAAMC,cAAc,GAAG;AAC5BC,EAAAA,KAAK,EAAE,MADqB;AAE5BP,EAAAA,GAAG,EAAE;AAFuB,CAAvB;;;AAKA,SAASQ,iBAAT,CAA2BC,UAA3B,EAAiD;AACtD,QAAMC,MAAa,GAAG,EAAtB;;AACA,MAAIC,gBAAEC,KAAF,CAAQH,UAAR,CAAJ,EAAyB;AACvB,WAAOC,MAAP;AACD,GAJqD,CAMt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,GAA6BnB,iBAAiB,CAAC4B,aAAa,CAACT,MAAf,CAA9C;AACAD,MAAAA,cAAc,CAACK,GAAD,CAAd,CAAoBH,OAApB,GAA8BpB,iBAAiB,CAAC4B,aAAa,CAACR,OAAf,CAA/C;AACAF,MAAAA,cAAc,CAACK,GAAD,CAAd,CAAoBD,KAApB,GAA4BtB,iBAAiB,CAAC4B,aAAa,CAACN,KAAf,CAA7C,CAPuD,CAQvD;;AACAJ,MAAAA,cAAc,CAACK,GAAD,CAAd,CAAoBF,SAApB,GAAgClB,gBAAE4B,WAAF,CAAcH,aAAa,CAACP,SAA5B,IAC5B,KAD4B,GAE5BrB,iBAAiB,CAAC4B,aAAa,CAACP,SAAf,CAFrB;AAGD;AACF;;AAED,SAAOH,cAAP;AACD","sourcesContent":["import assert from 'assert';\nimport _ from 'lodash';\n\nimport { errorUtils } from '@verdaccio/core';\nimport { PackageAccess } from '@verdaccio/types';\n\nexport interface LegacyPackageList {\n [key: string]: PackageAccess;\n}\n\nexport const ROLES = {\n $ALL: '$all',\n ALL: 'all',\n $AUTH: '$authenticated',\n $ANONYMOUS: '$anonymous',\n DEPRECATED_ALL: '@all',\n DEPRECATED_AUTH: '@authenticated',\n DEPRECATED_ANONYMOUS: '@anonymous',\n};\n\nexport const PACKAGE_ACCESS = {\n SCOPE: '@*/*',\n ALL: '**',\n};\n\nexport function normalizeUserList(groupsList: any): any {\n const result: any[] = [];\n if (_.isNil(groupsList)) {\n return result;\n }\n\n // if it's a string, split it to array\n if (_.isString(groupsList)) {\n const groupsArray = groupsList.split(/\\s+/);\n\n result.push(groupsArray);\n } else if (Array.isArray(groupsList)) {\n result.push(groupsList);\n } else {\n throw errorUtils.getInternalError(\n 'CONFIG: bad package acl (array or string expected): ' + JSON.stringify(groupsList)\n );\n }\n\n return _.flatten(result);\n}\n\nexport function normalisePackageAccess(packages: LegacyPackageList): LegacyPackageList {\n const normalizedPkgs: LegacyPackageList = { ...packages };\n if (_.isNil(normalizedPkgs['**'])) {\n normalizedPkgs['**'] = {\n access: [],\n publish: [],\n unpublish: [],\n proxy: [],\n };\n }\n\n for (const pkg in packages) {\n if (Object.prototype.hasOwnProperty.call(packages, pkg)) {\n const packageAccess = packages[pkg];\n const isInvalid = _.isObject(packageAccess) && _.isArray(packageAccess) === false;\n assert(isInvalid, `CONFIG: bad \"'${pkg}'\" package description (object expected)`);\n\n normalizedPkgs[pkg].access = normalizeUserList(packageAccess.access);\n normalizedPkgs[pkg].publish = normalizeUserList(packageAccess.publish);\n normalizedPkgs[pkg].proxy = normalizeUserList(packageAccess.proxy);\n // if unpublish is not defined, we set to false to fallback in publish access\n normalizedPkgs[pkg].unpublish = _.isUndefined(packageAccess.unpublish)\n ? false\n : normalizeUserList(packageAccess.unpublish);\n }\n }\n\n return normalizedPkgs;\n}\n"],"file":"package-access.js"}
|
package/build/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/parse.ts"],"names":["parseConfigFile","configPath","test","yamlConfig","YAML","safeLoad","fs","readFileSync","Object","assign","config_path","jsonConfig","require","e","code","message","APP_ERROR","CONFIG_NOT_VALID"],"mappings":";;;;;;;AAAA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["../src/parse.ts"],"names":["parseConfigFile","configPath","test","yamlConfig","YAML","safeLoad","fs","readFileSync","Object","assign","config_path","jsonConfig","require","e","code","message","APP_ERROR","CONFIG_NOT_VALID"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;AAGA;AACA;AACA;AACA;AACO,SAASA,eAAT,CAAyBC,UAAzB,EAA4D;AACjE,MAAI;AACF,QAAI,YAAYC,IAAZ,CAAiBD,UAAjB,CAAJ,EAAkC;AAChC,YAAME,UAAU,GAAGC,gBAAKC,QAAL,CAAcC,YAAGC,YAAH,CAAgBN,UAAhB,EAA4B,MAA5B,CAAd,CAAnB;;AACA,aAAOO,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBN,UAAlB,EAA8B;AACnCF,QAAAA,UADmC;AAEnC;AACAS,QAAAA,WAAW,EAAET;AAHsB,OAA9B,CAAP;AAKD;;AAED,UAAMU,UAAU,GAAGC,OAAO,CAACX,UAAD,CAA1B;;AACA,WAAOO,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBE,UAAlB,EAA8B;AACnCV,MAAAA,UADmC;AAEnC;AACAS,MAAAA,WAAW,EAAET;AAHsB,KAA9B,CAAP;AAKD,GAhBD,CAgBE,OAAOY,CAAP,EAAe;AACf,QAAIA,CAAC,CAACC,IAAF,KAAW,kBAAf,EAAmC;AACjCD,MAAAA,CAAC,CAACE,OAAF,GAAYC,gBAAUC,gBAAtB;AACD;;AAED,UAAMJ,CAAN;AACD;AACF","sourcesContent":["import fs from 'fs';\nimport YAML from 'js-yaml';\n\nimport { APP_ERROR } from '@verdaccio/core';\nimport { ConfigRuntime, ConfigYaml } from '@verdaccio/types';\n\n/**\n * Parse a config file from yaml to JSON.\n * @param configPath the absolute path of the configuration file\n */\nexport function parseConfigFile(configPath: string): ConfigRuntime {\n try {\n if (/\\.ya?ml$/i.test(configPath)) {\n const yamlConfig = YAML.safeLoad(fs.readFileSync(configPath, 'utf8')) as ConfigYaml;\n return Object.assign({}, yamlConfig, {\n configPath,\n // @deprecated use configPath instead\n config_path: configPath,\n });\n }\n\n const jsonConfig = require(configPath) as ConfigYaml;\n return Object.assign({}, jsonConfig, {\n configPath,\n // @deprecated use configPath instead\n config_path: configPath,\n });\n } catch (e: any) {\n if (e.code !== 'MODULE_NOT_FOUND') {\n e.message = APP_ERROR.CONFIG_NOT_VALID;\n }\n\n throw e;\n }\n}\n"],"file":"parse.js"}
|
package/build/uplinks.js
CHANGED
|
@@ -11,10 +11,10 @@ exports.uplinkSanityCheck = uplinkSanityCheck;
|
|
|
11
11
|
|
|
12
12
|
var _assert = _interopRequireDefault(require("assert"));
|
|
13
13
|
|
|
14
|
-
var _utils = require("@verdaccio/utils");
|
|
15
|
-
|
|
16
14
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
17
15
|
|
|
16
|
+
var _utils = require("@verdaccio/utils");
|
|
17
|
+
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
20
20
|
const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
|
package/build/uplinks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/uplinks.ts"],"names":["DEFAULT_REGISTRY","DEFAULT_UPLINK","BLACKLIST","all","anonymous","undefined","owner","none","uplinkSanityCheck","uplinks","users","newUplinks","_","clone","newUsers","uplink","Object","prototype","hasOwnProperty","call","isNil","cache","sanityCheckNames","sanityCheckUplinksProps","configUpLinks","url","isString","replace","hasProxyTo","pkg","upLink","packages","matchedPkg","proxyList","proxy","some","curr","item","match"],"mappings":";;;;;;;;;;;AAAA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["../src/uplinks.ts"],"names":["DEFAULT_REGISTRY","DEFAULT_UPLINK","BLACKLIST","all","anonymous","undefined","owner","none","uplinkSanityCheck","uplinks","users","newUplinks","_","clone","newUsers","uplink","Object","prototype","hasOwnProperty","call","isNil","cache","sanityCheckNames","sanityCheckUplinksProps","configUpLinks","url","isString","replace","hasProxyTo","pkg","upLink","packages","matchedPkg","proxyList","proxy","some","curr","item","match"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAGA;;;;AAEO,MAAMA,gBAAgB,GAAG,4BAAzB;;AACA,MAAMC,cAAc,GAAG,OAAvB;;AAEP,MAAMC,SAAS,GAAG;AAChBC,EAAAA,GAAG,EAAE,IADW;AAEhBC,EAAAA,SAAS,EAAE,IAFK;AAGhBC,EAAAA,SAAS,EAAE,IAHK;AAIhBC,EAAAA,KAAK,EAAE,IAJS;AAKhBC,EAAAA,IAAI,EAAE;AALU,CAAlB;;AAQO,SAASC,iBAAT,CACLC,OADK,EAELC,KAAU,GAAGR,SAFR,EAGY;AACjB,QAAMS,UAAU,GAAGC,gBAAEC,KAAF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U,GAAG,mCAAuBH,GAAvB,EAA4BE,QAA5B,CAAnB;AACA,QAAME,SAAS,GAAG,OAAOD,UAAP,KAAsB,WAAtB,GAAoCA,UAAU,CAACE,KAA/C,GAAuD,EAAzE;;AACA,MAAID,SAAJ,EAAe;AACb,WAAOA,SAAS,CAACE,IAAV,CAAgBC,IAAD,IAAUN,MAAM,KAAKM,IAApC,CAAP;AACD;;AAED,SAAO,KAAP;AACD;;AAEM,SAASd,gBAAT,CAA0Be,IAA1B,EAAwC3B,KAAxC,EAAyD;AAC9D,uBACE2B,IAAI,KAAK,KAAT,IACEA,IAAI,KAAK,OADX,IAEEA,IAAI,KAAK,WAFX,IAGEA,IAAI,KAAK,WAHX,IAIEA,IAAI,KAAK,MALb,EAME,mCAAmCA,IANrC;AAQA,uBAAO,CAACA,IAAI,CAACC,KAAL,CAAW,IAAX,CAAR,EAA0B,kCAAkCD,IAA5D;AACA,uBAAOzB,gBAAEQ,KAAF,CAAQV,KAAK,CAAC2B,IAAD,CAAb,CAAP,EAA6B,oCAAoCA,IAAjE;AACA3B,EAAAA,KAAK,CAAC2B,IAAD,CAAL,GAAc,IAAd;AAEA,SAAO3B,KAAP;AACD","sourcesContent":["import assert from 'assert';\nimport _ from 'lodash';\n\nimport { PackageList, UpLinksConfList } from '@verdaccio/types';\nimport { getMatchedPackagesSpec } from '@verdaccio/utils';\n\nexport const DEFAULT_REGISTRY = 'https://registry.npmjs.org';\nexport const DEFAULT_UPLINK = 'npmjs';\n\nconst BLACKLIST = {\n all: true,\n anonymous: true,\n undefined: true,\n owner: true,\n none: true,\n};\n\nexport function uplinkSanityCheck(\n uplinks: UpLinksConfList,\n users: any = BLACKLIST\n): UpLinksConfList {\n const newUplinks = _.clone(uplinks);\n let newUsers = _.clone(users);\n\n for (const uplink in newUplinks) {\n if (Object.prototype.hasOwnProperty.call(newUplinks, uplink)) {\n if (_.isNil(newUplinks[uplink].cache)) {\n newUplinks[uplink].cache = true;\n }\n newUsers = sanityCheckNames(uplink, newUsers);\n }\n }\n\n return newUplinks;\n}\n\nexport function sanityCheckUplinksProps(configUpLinks: UpLinksConfList): UpLinksConfList {\n const uplinks = _.clone(configUpLinks);\n\n for (const uplink in uplinks) {\n if (Object.prototype.hasOwnProperty.call(uplinks, uplink)) {\n assert(uplinks[uplink].url, 'CONFIG: no url for uplink: ' + uplink);\n assert(_.isString(uplinks[uplink].url), 'CONFIG: wrong url format for uplink: ' + uplink);\n uplinks[uplink].url = uplinks[uplink].url.replace(/\\/$/, '');\n }\n }\n\n return uplinks;\n}\n\nexport function hasProxyTo(pkg: string, upLink: string, packages: PackageList): boolean {\n const matchedPkg = getMatchedPackagesSpec(pkg, packages);\n const proxyList = typeof matchedPkg !== 'undefined' ? matchedPkg.proxy : [];\n if (proxyList) {\n return proxyList.some((curr) => upLink === curr);\n }\n\n return false;\n}\n\nexport function sanityCheckNames(item: string, users: any): any {\n assert(\n item !== 'all' &&\n item !== 'owner' &&\n item !== 'anonymous' &&\n item !== 'undefined' &&\n item !== 'none',\n 'CONFIG: reserved uplink name: ' + item\n );\n assert(!item.match(/\\s/), 'CONFIG: invalid uplink name: ' + item);\n assert(_.isNil(users[item]), 'CONFIG: duplicate uplink name: ' + item);\n users[item] = true;\n\n return users;\n}\n"],"file":"uplinks.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/config",
|
|
3
|
-
"version": "6.0.0-6-next.
|
|
3
|
+
"version": "6.0.0-6-next.13",
|
|
4
4
|
"description": "logger",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"npm": ">=6"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@verdaccio/core": "6.0.0-6-next.
|
|
34
|
-
"@verdaccio/utils": "6.0.0-6-next.
|
|
35
|
-
"debug": "4.3.
|
|
33
|
+
"@verdaccio/core": "6.0.0-6-next.5",
|
|
34
|
+
"@verdaccio/utils": "6.0.0-6-next.11",
|
|
35
|
+
"debug": "4.3.3",
|
|
36
36
|
"js-yaml": "3.14.1",
|
|
37
37
|
"lodash": "4.17.21",
|
|
38
38
|
"minimatch": "3.0.4",
|
package/src/conf/default.yaml
CHANGED
|
@@ -3,15 +3,13 @@
|
|
|
3
3
|
# so don't use it on production systems.
|
|
4
4
|
#
|
|
5
5
|
# Look here for more config file examples:
|
|
6
|
-
# https://github.com/verdaccio/verdaccio/tree/master/conf
|
|
6
|
+
# https://github.com/verdaccio/verdaccio/tree/master/packages/config/src/conf
|
|
7
7
|
#
|
|
8
8
|
|
|
9
9
|
# path to a directory with all packages
|
|
10
10
|
storage: ./storage
|
|
11
11
|
# path to a directory with plugins to include
|
|
12
12
|
plugins: ./plugins
|
|
13
|
-
# print logs
|
|
14
|
-
# logs: ./logs
|
|
15
13
|
|
|
16
14
|
web:
|
|
17
15
|
title: Verdaccio
|
|
@@ -67,7 +65,7 @@ packages:
|
|
|
67
65
|
# and three keywords: "$all", "$anonymous", "$authenticated"
|
|
68
66
|
access: $all
|
|
69
67
|
|
|
70
|
-
# allow all known users to publish/
|
|
68
|
+
# allow all known users to publish/unpublish packages
|
|
71
69
|
# (anyone can register by default, remember?)
|
|
72
70
|
publish: $authenticated
|
|
73
71
|
unpublish: $authenticated
|
|
@@ -87,7 +85,7 @@ middlewares:
|
|
|
87
85
|
enabled: true
|
|
88
86
|
|
|
89
87
|
# log settings
|
|
90
|
-
|
|
88
|
+
log:
|
|
91
89
|
# Logger as STDOUT
|
|
92
90
|
{ type: stdout, format: pretty, level: http }
|
|
93
91
|
# Logger as STDOUT as JSON
|
package/src/conf/docker.yaml
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
# see https://verdaccio.org/docs/en/docker#docker-and-custom-port-configuration
|
|
8
8
|
#
|
|
9
9
|
# Look here for more config file examples:
|
|
10
|
-
# https://github.com/verdaccio/verdaccio/tree/master/conf
|
|
10
|
+
# https://github.com/verdaccio/verdaccio/tree/master/packages/config/src/conf
|
|
11
11
|
#
|
|
12
12
|
|
|
13
13
|
# path to a directory with all packages
|
|
@@ -58,7 +58,7 @@ packages:
|
|
|
58
58
|
# and three keywords: "$all", "$anonymous", "$authenticated"
|
|
59
59
|
access: $all
|
|
60
60
|
|
|
61
|
-
# allow all known users to publish/
|
|
61
|
+
# allow all known users to publish/unpublish packages
|
|
62
62
|
# (anyone can register by default, remember?)
|
|
63
63
|
publish: $authenticated
|
|
64
64
|
unpublish: $authenticated
|
|
@@ -72,7 +72,7 @@ middlewares:
|
|
|
72
72
|
|
|
73
73
|
# log settings
|
|
74
74
|
# log settings
|
|
75
|
-
|
|
75
|
+
log:
|
|
76
76
|
# Logger as STDOUT
|
|
77
77
|
{ type: stdout, format: pretty, level: http }
|
|
78
78
|
# Logger as STDOUT as JSON
|
package/src/config-path.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import buildDebug from 'debug';
|
|
1
2
|
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
3
|
import _ from 'lodash';
|
|
4
|
-
import
|
|
4
|
+
import path from 'path';
|
|
5
5
|
|
|
6
6
|
import { CHARACTER_ENCODING } from '@verdaccio/core';
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
import { fileExists, folderExists } from './config-utils';
|
|
8
9
|
|
|
9
10
|
const CONFIG_FILE = 'config.yaml';
|
|
10
11
|
const XDG = 'xdg';
|
package/src/config.ts
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import assert from 'assert';
|
|
2
|
-
import _ from 'lodash';
|
|
3
2
|
import buildDebug from 'debug';
|
|
3
|
+
import _ from 'lodash';
|
|
4
4
|
|
|
5
|
-
import { getMatchedPackagesSpec, generateRandomHexString, isObject } from '@verdaccio/utils';
|
|
6
5
|
import { APP_ERROR } from '@verdaccio/core';
|
|
7
6
|
import {
|
|
8
|
-
PackageList,
|
|
9
7
|
Config as AppConfig,
|
|
8
|
+
AuthConf,
|
|
10
9
|
ConfigRuntime,
|
|
11
|
-
|
|
10
|
+
FlagsConfig,
|
|
12
11
|
PackageAccess,
|
|
12
|
+
PackageList,
|
|
13
|
+
Security,
|
|
13
14
|
ServerSettingsConf,
|
|
14
|
-
AuthConf,
|
|
15
15
|
} from '@verdaccio/types';
|
|
16
|
+
import { generateRandomHexString, getMatchedPackagesSpec, isObject } from '@verdaccio/utils';
|
|
16
17
|
|
|
17
|
-
import {
|
|
18
|
+
import { getUserAgent } from './agent';
|
|
18
19
|
import { normalisePackageAccess } from './package-access';
|
|
19
|
-
import { sanityCheckUplinksProps, uplinkSanityCheck } from './uplinks';
|
|
20
20
|
import { defaultSecurity } from './security';
|
|
21
|
-
import { getUserAgent } from './agent';
|
|
22
21
|
import serverSettings from './serverSettings';
|
|
22
|
+
import { generateRandomSecretKey } from './token';
|
|
23
|
+
import { sanityCheckUplinksProps, uplinkSanityCheck } from './uplinks';
|
|
23
24
|
|
|
24
25
|
const strategicConfigProps = ['uplinks', 'packages'];
|
|
25
26
|
const allowedEnvConfig = ['http_proxy', 'https_proxy', 'no_proxy'];
|
|
@@ -44,6 +45,7 @@ class Config implements AppConfig {
|
|
|
44
45
|
public serverSettings: ServerSettingsConf;
|
|
45
46
|
// @ts-ignore
|
|
46
47
|
public secret: string;
|
|
48
|
+
public flags: FlagsConfig;
|
|
47
49
|
|
|
48
50
|
public constructor(config: ConfigRuntime) {
|
|
49
51
|
const self = this;
|
|
@@ -52,6 +54,9 @@ class Config implements AppConfig {
|
|
|
52
54
|
this.plugins = config.plugins;
|
|
53
55
|
this.security = _.merge(defaultSecurity, config.security);
|
|
54
56
|
this.serverSettings = serverSettings;
|
|
57
|
+
this.flags = {
|
|
58
|
+
searchRemote: config.flags?.searchRemote ?? true,
|
|
59
|
+
};
|
|
55
60
|
|
|
56
61
|
for (const configProp in config) {
|
|
57
62
|
if (self[configProp] == null) {
|
package/src/package-access.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import assert from 'assert';
|
|
2
2
|
import _ from 'lodash';
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import { errorUtils } from '@verdaccio/core';
|
|
5
|
+
import { PackageAccess } from '@verdaccio/types';
|
|
6
|
+
|
|
5
7
|
export interface LegacyPackageList {
|
|
6
8
|
[key: string]: PackageAccess;
|
|
7
9
|
}
|
package/src/parse.ts
CHANGED
package/src/uplinks.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import assert from 'assert';
|
|
2
|
-
import { getMatchedPackagesSpec } from '@verdaccio/utils';
|
|
3
|
-
import { PackageList, UpLinksConfList } from '@verdaccio/types';
|
|
4
2
|
import _ from 'lodash';
|
|
5
3
|
|
|
4
|
+
import { PackageList, UpLinksConfList } from '@verdaccio/types';
|
|
5
|
+
import { getMatchedPackagesSpec } from '@verdaccio/utils';
|
|
6
|
+
|
|
6
7
|
export const DEFAULT_REGISTRY = 'https://registry.npmjs.org';
|
|
7
8
|
export const DEFAULT_UPLINK = 'npmjs';
|
|
8
9
|
|
package/test/config.path.spec.ts
CHANGED
package/test/config.spec.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
1
|
import _ from 'lodash';
|
|
2
|
+
import path from 'path';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
Config,
|
|
6
6
|
DEFAULT_REGISTRY,
|
|
7
7
|
DEFAULT_UPLINK,
|
|
8
|
-
defaultSecurity,
|
|
9
|
-
parseConfigFile,
|
|
10
8
|
ROLES,
|
|
11
9
|
WEB_TITLE,
|
|
10
|
+
defaultSecurity,
|
|
11
|
+
parseConfigFile,
|
|
12
12
|
} from '../src';
|
|
13
13
|
import { parseConfigurationFile } from './utils';
|
|
14
14
|
|
|
@@ -57,11 +57,11 @@ describe('check basic content parsed file', () => {
|
|
|
57
57
|
expect(config.middlewares).toBeDefined();
|
|
58
58
|
expect(config.middlewares.audit).toBeDefined();
|
|
59
59
|
expect(config.middlewares.audit.enabled).toBeTruthy();
|
|
60
|
-
//
|
|
61
|
-
expect(config.
|
|
62
|
-
expect(config.
|
|
63
|
-
expect(config.
|
|
64
|
-
expect(config.
|
|
60
|
+
// log
|
|
61
|
+
expect(config.log).toBeDefined();
|
|
62
|
+
expect(config.log.type).toEqual('stdout');
|
|
63
|
+
expect(config.log.format).toEqual('pretty');
|
|
64
|
+
expect(config.log.level).toEqual('http');
|
|
65
65
|
// must not be enabled by default
|
|
66
66
|
expect(config.notify).toBeUndefined();
|
|
67
67
|
expect(config.store).toBeUndefined();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
|
|
3
|
-
import { normalisePackageAccess, PACKAGE_ACCESS } from '../src/package-access';
|
|
4
3
|
import { parseConfigFile } from '../src';
|
|
4
|
+
import { PACKAGE_ACCESS, normalisePackageAccess } from '../src/package-access';
|
|
5
5
|
import { parseConfigurationFile } from './utils';
|
|
6
6
|
|
|
7
7
|
describe('Package access utilities', () => {
|
|
@@ -11,5 +11,5 @@ module.exports = {
|
|
|
11
11
|
vue: { access: '$authenticated', publish: '$authenticated', proxy: 'npmjs' },
|
|
12
12
|
'*': { access: '$all', publish: '$all', proxy: 'npmjs' },
|
|
13
13
|
},
|
|
14
|
-
|
|
14
|
+
log: { type: 'stdout', format: 'pretty', level: 'warn' },
|
|
15
15
|
};
|
package/test/token.spec.ts
CHANGED
package/test/uplinks.spec.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { hasProxyTo, sanityCheckUplinksProps, uplinkSanityCheck } from '../src/uplinks';
|
|
2
1
|
import { normalisePackageAccess, parseConfigFile } from '../src';
|
|
2
|
+
import { hasProxyTo, sanityCheckUplinksProps, uplinkSanityCheck } from '../src/uplinks';
|
|
3
3
|
import { parseConfigurationFile } from './utils';
|
|
4
4
|
|
|
5
5
|
describe('Uplinks Utilities', () => {
|
package/test/utils.spec.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { ROLES, createAnonymousRemoteUser, createRemoteUser } from '../src';
|
|
1
2
|
import { spliceURL } from '../src/string';
|
|
2
|
-
import { createAnonymousRemoteUser, createRemoteUser, ROLES } from '../src';
|
|
3
3
|
|
|
4
4
|
describe('spliceURL', () => {
|
|
5
5
|
test('should splice two strings and generate a url', () => {
|