@verdaccio/config 6.0.0-6-next.50 → 6.0.0-6-next.52
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 +28 -0
- package/build/agent.js +0 -2
- package/build/agent.js.map +1 -1
- package/build/builder.js +0 -15
- package/build/builder.js.map +1 -1
- package/build/conf/index.js +0 -3
- package/build/conf/index.js.map +1 -1
- package/build/config-path.d.ts +1 -1
- package/build/config-path.js +17 -47
- package/build/config-path.js.map +1 -1
- package/build/config-utils.js +1 -7
- package/build/config-utils.js.map +1 -1
- package/build/config.js +18 -38
- package/build/config.js.map +1 -1
- package/build/index.js +0 -18
- package/build/index.js.map +1 -1
- package/build/package-access.js +8 -18
- package/build/package-access.js.map +1 -1
- package/build/parse.js +1 -18
- package/build/parse.js.map +1 -1
- package/build/security.d.ts +1 -1
- package/build/security.js +5 -4
- package/build/security.js.map +1 -1
- package/build/serverSettings.js.map +1 -1
- package/build/token.js +1 -4
- package/build/token.js.map +1 -1
- package/build/uplinks.js +0 -17
- package/build/uplinks.js.map +1 -1
- package/build/user.js +5 -9
- package/build/user.js.map +1 -1
- package/package.json +3 -3
- package/src/security.ts +3 -2
- package/src/user.ts +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @verdaccio/config
|
|
2
2
|
|
|
3
|
+
## 6.0.0-6-next.52
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @verdaccio/core@6.0.0-6-next.52
|
|
8
|
+
- @verdaccio/utils@6.0.0-6-next.20
|
|
9
|
+
|
|
10
|
+
## 6.0.0-6-next.51
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 4b29d715: chore: move improvements from v5 to v6
|
|
15
|
+
|
|
16
|
+
Migrate improvements form v5 to v6:
|
|
17
|
+
|
|
18
|
+
- https://github.com/verdaccio/verdaccio/pull/3158
|
|
19
|
+
- https://github.com/verdaccio/verdaccio/pull/3151
|
|
20
|
+
- https://github.com/verdaccio/verdaccio/pull/2271
|
|
21
|
+
- https://github.com/verdaccio/verdaccio/pull/2787
|
|
22
|
+
- https://github.com/verdaccio/verdaccio/pull/2791
|
|
23
|
+
- https://github.com/verdaccio/verdaccio/pull/2205
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [4b29d715]
|
|
28
|
+
- @verdaccio/core@6.0.0-6-next.51
|
|
29
|
+
- @verdaccio/utils@6.0.0-6-next.19
|
|
30
|
+
|
|
3
31
|
## 6.0.0-6-next.50
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/build/agent.js
CHANGED
package/build/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","names":["pkgVersion","require","version","getUserAgent"],"sources":["../src/agent.ts"],"sourcesContent":["const pkgVersion = require('../package.json').version;\n\nexport function getUserAgent(): string {\n return `verdaccio/${pkgVersion}`;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent.js","names":["pkgVersion","require","version","getUserAgent"],"sources":["../src/agent.ts"],"sourcesContent":["const pkgVersion = require('../package.json').version;\n\nexport function getUserAgent(): string {\n return `verdaccio/${pkgVersion}`;\n}\n"],"mappings":";;;;;;AAAA,MAAMA,UAAU,GAAGC,OAAO,CAAC,iBAAiB,CAAC,CAACC,OAAO;AAE9C,SAASC,YAAY,GAAW;EACrC,OAAQ,aAAYH,UAAW,EAAC;AAClC"}
|
package/build/builder.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _lodash = require("lodash");
|
|
9
|
-
|
|
10
8
|
var _ = require(".");
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* Helper configuration builder constructor, used to build the configuration for testing or
|
|
14
11
|
* programatically creating a configuration.
|
|
@@ -22,56 +19,44 @@ class ConfigBuilder {
|
|
|
22
19
|
security: {}
|
|
23
20
|
};
|
|
24
21
|
}
|
|
25
|
-
|
|
26
22
|
static build(config) {
|
|
27
23
|
return new ConfigBuilder(config);
|
|
28
24
|
}
|
|
29
|
-
|
|
30
25
|
addPackageAccess(pattern, pkgAccess) {
|
|
31
26
|
// @ts-ignore
|
|
32
27
|
this.config.packages[pattern] = pkgAccess;
|
|
33
28
|
return this;
|
|
34
29
|
}
|
|
35
|
-
|
|
36
30
|
addUplink(id, uplink) {
|
|
37
31
|
this.config.uplinks[id] = uplink;
|
|
38
32
|
return this;
|
|
39
33
|
}
|
|
40
|
-
|
|
41
34
|
addSecurity(security) {
|
|
42
35
|
this.config.security = (0, _lodash.merge)(this.config.security, security);
|
|
43
36
|
return this;
|
|
44
37
|
}
|
|
45
|
-
|
|
46
38
|
addAuth(auth) {
|
|
47
39
|
this.config.auth = (0, _lodash.merge)(this.config.auth, auth);
|
|
48
40
|
return this;
|
|
49
41
|
}
|
|
50
|
-
|
|
51
42
|
addLogger(log) {
|
|
52
43
|
this.config.log = log;
|
|
53
44
|
return this;
|
|
54
45
|
}
|
|
55
|
-
|
|
56
46
|
addStorage(storage) {
|
|
57
47
|
if (typeof storage === 'string') {
|
|
58
48
|
this.config.storage = storage;
|
|
59
49
|
} else {
|
|
60
50
|
this.config.store = storage;
|
|
61
51
|
}
|
|
62
|
-
|
|
63
52
|
return this;
|
|
64
53
|
}
|
|
65
|
-
|
|
66
54
|
getConfig() {
|
|
67
55
|
return this.config;
|
|
68
56
|
}
|
|
69
|
-
|
|
70
57
|
getAsYaml() {
|
|
71
58
|
return (0, _.fromJStoYAML)(this.config);
|
|
72
59
|
}
|
|
73
|
-
|
|
74
60
|
}
|
|
75
|
-
|
|
76
61
|
exports.default = ConfigBuilder;
|
|
77
62
|
//# sourceMappingURL=builder.js.map
|
package/build/builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","names":["ConfigBuilder","constructor","config","uplinks","packages","security","build","addPackageAccess","pattern","pkgAccess","addUplink","id","uplink","addSecurity","merge","addAuth","auth","addLogger","log","addStorage","storage","store","getConfig","getAsYaml","fromJStoYAML"],"sources":["../src/builder.ts"],"sourcesContent":["import { merge } from 'lodash';\n\nimport {\n AuthConf,\n ConfigYaml,\n LoggerConfItem,\n PackageAccessYaml,\n Security,\n UpLinkConf,\n} from '@verdaccio/types';\n\nimport { fromJStoYAML } from '.';\n\n/**\n * Helper configuration builder constructor, used to build the configuration for testing or\n * programatically creating a configuration.\n */\nexport default class ConfigBuilder {\n private config: ConfigYaml;\n\n public constructor(config?: Partial<ConfigYaml>) {\n // @ts-ignore\n this.config = config ?? { uplinks: {}, packages: {}, security: {} };\n }\n\n public static build(config?: Partial<ConfigYaml>): ConfigBuilder {\n return new ConfigBuilder(config);\n }\n\n public addPackageAccess(pattern: string, pkgAccess: PackageAccessYaml) {\n // @ts-ignore\n this.config.packages[pattern] = pkgAccess;\n return this;\n }\n\n public addUplink(id: string, uplink: UpLinkConf) {\n this.config.uplinks[id] = uplink;\n return this;\n }\n\n public addSecurity(security: Partial<Security>) {\n this.config.security = merge(this.config.security, security);\n return this;\n }\n\n public addAuth(auth: Partial<AuthConf>) {\n this.config.auth = merge(this.config.auth, auth);\n return this;\n }\n\n public addLogger(log: LoggerConfItem) {\n this.config.log = log;\n return this;\n }\n\n public addStorage(storage: string | object) {\n if (typeof storage === 'string') {\n this.config.storage = storage;\n } else {\n this.config.store = storage;\n }\n return this;\n }\n\n public getConfig(): ConfigYaml {\n return this.config;\n }\n\n public getAsYaml(): string {\n return fromJStoYAML(this.config) as string;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"builder.js","names":["ConfigBuilder","constructor","config","uplinks","packages","security","build","addPackageAccess","pattern","pkgAccess","addUplink","id","uplink","addSecurity","merge","addAuth","auth","addLogger","log","addStorage","storage","store","getConfig","getAsYaml","fromJStoYAML"],"sources":["../src/builder.ts"],"sourcesContent":["import { merge } from 'lodash';\n\nimport {\n AuthConf,\n ConfigYaml,\n LoggerConfItem,\n PackageAccessYaml,\n Security,\n UpLinkConf,\n} from '@verdaccio/types';\n\nimport { fromJStoYAML } from '.';\n\n/**\n * Helper configuration builder constructor, used to build the configuration for testing or\n * programatically creating a configuration.\n */\nexport default class ConfigBuilder {\n private config: ConfigYaml;\n\n public constructor(config?: Partial<ConfigYaml>) {\n // @ts-ignore\n this.config = config ?? { uplinks: {}, packages: {}, security: {} };\n }\n\n public static build(config?: Partial<ConfigYaml>): ConfigBuilder {\n return new ConfigBuilder(config);\n }\n\n public addPackageAccess(pattern: string, pkgAccess: PackageAccessYaml) {\n // @ts-ignore\n this.config.packages[pattern] = pkgAccess;\n return this;\n }\n\n public addUplink(id: string, uplink: UpLinkConf) {\n this.config.uplinks[id] = uplink;\n return this;\n }\n\n public addSecurity(security: Partial<Security>) {\n this.config.security = merge(this.config.security, security);\n return this;\n }\n\n public addAuth(auth: Partial<AuthConf>) {\n this.config.auth = merge(this.config.auth, auth);\n return this;\n }\n\n public addLogger(log: LoggerConfItem) {\n this.config.log = log;\n return this;\n }\n\n public addStorage(storage: string | object) {\n if (typeof storage === 'string') {\n this.config.storage = storage;\n } else {\n this.config.store = storage;\n }\n return this;\n }\n\n public getConfig(): ConfigYaml {\n return this.config;\n }\n\n public getAsYaml(): string {\n return fromJStoYAML(this.config) as string;\n }\n}\n"],"mappings":";;;;;;AAAA;AAWA;AAEA;AACA;AACA;AACA;AACe,MAAMA,aAAa,CAAC;EAG1BC,WAAW,CAACC,MAA4B,EAAE;IAC/C;IACA,IAAI,CAACA,MAAM,GAAGA,MAAM,IAAI;MAAEC,OAAO,EAAE,CAAC,CAAC;MAAEC,QAAQ,EAAE,CAAC,CAAC;MAAEC,QAAQ,EAAE,CAAC;IAAE,CAAC;EACrE;EAEA,OAAcC,KAAK,CAACJ,MAA4B,EAAiB;IAC/D,O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4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getDefaultConfig = getDefaultConfig;
|
|
7
|
-
|
|
8
7
|
var _path = require("path");
|
|
9
|
-
|
|
10
8
|
var _parse = require("../parse");
|
|
11
|
-
|
|
12
9
|
function getDefaultConfig(fileName = 'default.yaml') {
|
|
13
10
|
const file = (0, _path.join)(__dirname, `./${fileName}`);
|
|
14
11
|
return (0, _parse.parseConfigFile)(file);
|
package/build/conf/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getDefaultConfig","fileName","file","join","__dirname","parseConfigFile"],"sources":["../../src/conf/index.ts"],"sourcesContent":["import { join } from 'path';\n\nimport { parseConfigFile } from '../parse';\n\nexport function getDefaultConfig(fileName = 'default.yaml') {\n const file = join(__dirname, `./${fileName}`);\n return parseConfigFile(file);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["getDefaultConfig","fileName","file","join","__dirname","parseConfigFile"],"sources":["../../src/conf/index.ts"],"sourcesContent":["import { join } from 'path';\n\nimport { parseConfigFile } from '../parse';\n\nexport function getDefaultConfig(fileName = 'default.yaml') {\n const file = join(__dirname, `./${fileName}`);\n return parseConfigFile(file);\n}\n"],"mappings":";;;;;;AAAA;AAEA;AAEO,SAASA,gBAAgB,CAACC,QAAQ,GAAG,cAAc,EAAE;EAC1D,MAAMC,IAAI,GAAG,IAAAC,UAAI,EAACC,SAAS,EAAG,KAAIH,QAAS,EAAC,CAAC;EAC7C,OAAO,IAAAI,sBAAe,EAACH,IAAI,CAAC;AAC9B"}
|
package/build/config-path.d.ts
CHANGED
package/build/config-path.js
CHANGED
|
@@ -5,119 +5,95 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.findConfigFile = findConfigFile;
|
|
7
7
|
exports.readDefaultConfig = readDefaultConfig;
|
|
8
|
-
|
|
9
8
|
var _debug = _interopRequireDefault(require("debug"));
|
|
10
|
-
|
|
11
9
|
var _fs = _interopRequireDefault(require("fs"));
|
|
12
|
-
|
|
13
10
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
14
|
-
|
|
15
11
|
var _path = _interopRequireDefault(require("path"));
|
|
16
|
-
|
|
17
12
|
var _core = require("@verdaccio/core");
|
|
18
|
-
|
|
19
13
|
var _configUtils = require("./config-utils");
|
|
20
|
-
|
|
21
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
|
|
23
15
|
const CONFIG_FILE = 'config.yaml';
|
|
24
16
|
const XDG = 'xdg';
|
|
25
17
|
const WIN = 'win';
|
|
26
|
-
const WIN32 = 'win32';
|
|
27
|
-
|
|
18
|
+
const WIN32 = 'win32';
|
|
19
|
+
// eslint-disable-next-line
|
|
28
20
|
const pkgJSON = {
|
|
29
21
|
name: 'verdaccio'
|
|
30
22
|
};
|
|
31
23
|
const debug = (0, _debug.default)('verdaccio:config');
|
|
24
|
+
|
|
32
25
|
/**
|
|
33
26
|
* Find and get the first config file that match.
|
|
34
27
|
* @return {String} the config file path
|
|
35
28
|
*/
|
|
36
|
-
|
|
37
29
|
function findConfigFile(configPath) {
|
|
38
30
|
// console.log(process.env);
|
|
39
31
|
if (typeof configPath !== 'undefined') {
|
|
40
32
|
return _path.default.resolve(configPath);
|
|
41
33
|
}
|
|
42
|
-
|
|
43
34
|
const configPaths = getConfigPaths();
|
|
44
35
|
debug('%o posible locations found', configPaths.length);
|
|
45
|
-
|
|
46
36
|
if (_lodash.default.isEmpty(configPaths)) {
|
|
47
37
|
// this should never happens
|
|
48
38
|
throw new Error('no configuration files can be processed');
|
|
49
|
-
}
|
|
50
|
-
|
|
39
|
+
}
|
|
51
40
|
|
|
41
|
+
// find the first location that already exist
|
|
52
42
|
const primaryConf = _lodash.default.find(configPaths, configLocation => (0, _configUtils.fileExists)(configLocation.path));
|
|
53
|
-
|
|
54
43
|
if (typeof primaryConf !== 'undefined') {
|
|
55
44
|
debug('previous location exist already %s', primaryConf === null || primaryConf === void 0 ? void 0 : primaryConf.path);
|
|
56
45
|
return primaryConf.path;
|
|
57
|
-
}
|
|
58
|
-
|
|
46
|
+
}
|
|
59
47
|
|
|
48
|
+
// @ts-ignore
|
|
60
49
|
return createConfigFile(_lodash.default.head(configPaths)).path;
|
|
61
50
|
}
|
|
62
|
-
|
|
63
51
|
function createConfigFile(configLocation) {
|
|
64
52
|
createConfigFolder(configLocation);
|
|
65
53
|
const defaultConfig = updateStorageLinks(configLocation, readDefaultConfig());
|
|
66
|
-
|
|
67
54
|
_fs.default.writeFileSync(configLocation.path, defaultConfig);
|
|
68
|
-
|
|
69
55
|
return configLocation;
|
|
70
56
|
}
|
|
71
|
-
|
|
72
57
|
function readDefaultConfig() {
|
|
73
58
|
const pathDefaultConf = _path.default.resolve(__dirname, 'conf/default.yaml');
|
|
74
|
-
|
|
75
59
|
try {
|
|
76
60
|
debug('default configuration file %s', pathDefaultConf);
|
|
77
|
-
|
|
78
61
|
_fs.default.accessSync(pathDefaultConf, _fs.default.constants.R_OK);
|
|
79
62
|
} catch {
|
|
80
63
|
throw new TypeError('configuration file does not have enough permissions for reading');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
64
|
+
}
|
|
65
|
+
// @ts-ignore
|
|
84
66
|
return _fs.default.readFileSync(pathDefaultConf, _core.CHARACTER_ENCODING.UTF8);
|
|
85
67
|
}
|
|
86
|
-
|
|
87
68
|
function createConfigFolder(configLocation) {
|
|
88
69
|
_fs.default.mkdirSync(_path.default.dirname(configLocation.path), {
|
|
89
70
|
recursive: true
|
|
90
71
|
});
|
|
91
|
-
|
|
92
72
|
debug(`Creating default config file in %o`, configLocation === null || configLocation === void 0 ? void 0 : configLocation.path);
|
|
93
73
|
}
|
|
94
|
-
|
|
95
74
|
function updateStorageLinks(configLocation, defaultConfig) {
|
|
96
75
|
if (configLocation.type !== XDG) {
|
|
97
76
|
return defaultConfig;
|
|
98
|
-
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// $XDG_DATA_HOME defines the base directory relative to which user specific data
|
|
99
80
|
// files should be stored, If $XDG_DATA_HOME is either not set or empty, a default
|
|
100
81
|
// equal to $HOME/.local/share should be used.
|
|
101
|
-
|
|
102
|
-
|
|
103
82
|
let dataDir = process.env.XDG_DATA_HOME || _path.default.join(process.env.HOME, '.local', 'share');
|
|
104
|
-
|
|
105
83
|
if ((0, _configUtils.folderExists)(dataDir)) {
|
|
106
84
|
debug(`previous storage located`);
|
|
107
85
|
debug(`update storage links to %s`, dataDir);
|
|
108
86
|
dataDir = _path.default.resolve(_path.default.join(dataDir, pkgJSON.name, 'storage'));
|
|
109
87
|
return defaultConfig.replace(/^storage: .\/storage$/m, `storage: ${dataDir}`);
|
|
110
88
|
}
|
|
111
|
-
|
|
112
89
|
debug(`could not find a previous storage location, skip override`);
|
|
113
90
|
return defaultConfig;
|
|
114
91
|
}
|
|
92
|
+
|
|
115
93
|
/**
|
|
116
94
|
* Return a list of configuration locations by platform.
|
|
117
95
|
* @returns
|
|
118
96
|
*/
|
|
119
|
-
|
|
120
|
-
|
|
121
97
|
function getConfigPaths() {
|
|
122
98
|
const listPaths = [getXDGDirectory(), getWindowsDirectory(), getRelativeDefaultDirectory(), getOldDirectory()];
|
|
123
99
|
return listPaths.reduce(function (acc, currentValue) {
|
|
@@ -125,19 +101,16 @@ function getConfigPaths() {
|
|
|
125
101
|
debug('directory detected path %s for type %s', currentValue === null || currentValue === void 0 ? void 0 : currentValue.path, currentValue.type);
|
|
126
102
|
acc.push(currentValue);
|
|
127
103
|
}
|
|
128
|
-
|
|
129
104
|
return acc;
|
|
130
105
|
}, []);
|
|
131
106
|
}
|
|
107
|
+
|
|
132
108
|
/**
|
|
133
109
|
* Get XDG_CONFIG_HOME or HOME location (usually unix)
|
|
134
110
|
* @returns
|
|
135
111
|
*/
|
|
136
|
-
|
|
137
|
-
|
|
138
112
|
const getXDGDirectory = () => {
|
|
139
113
|
const xDGConfigPath = process.env.XDG_CONFIG_HOME || process.env.HOME && _path.default.join(process.env.HOME, '.config');
|
|
140
|
-
|
|
141
114
|
if (xDGConfigPath && (0, _configUtils.folderExists)(xDGConfigPath)) {
|
|
142
115
|
debug('XDGConfig folder path %s', xDGConfigPath);
|
|
143
116
|
return {
|
|
@@ -146,13 +119,12 @@ const getXDGDirectory = () => {
|
|
|
146
119
|
};
|
|
147
120
|
}
|
|
148
121
|
};
|
|
122
|
+
|
|
149
123
|
/**
|
|
150
124
|
* Detect windows location, APPDATA
|
|
151
125
|
* usually something like C:\User\<Build User>\AppData\Local
|
|
152
126
|
* @returns
|
|
153
127
|
*/
|
|
154
|
-
|
|
155
|
-
|
|
156
128
|
const getWindowsDirectory = () => {
|
|
157
129
|
if (process.platform === WIN32 && process.env.APPDATA && (0, _configUtils.folderExists)(process.env.APPDATA)) {
|
|
158
130
|
debug('is windows appdata: %s', process.env.APPDATA);
|
|
@@ -162,25 +134,23 @@ const getWindowsDirectory = () => {
|
|
|
162
134
|
};
|
|
163
135
|
}
|
|
164
136
|
};
|
|
137
|
+
|
|
165
138
|
/**
|
|
166
139
|
* Return relative directory, this is the default.
|
|
167
140
|
* It will cretate config in your {currentLocation/verdaccio/config.yaml}
|
|
168
141
|
* @returns
|
|
169
142
|
*/
|
|
170
|
-
|
|
171
|
-
|
|
172
143
|
const getRelativeDefaultDirectory = () => {
|
|
173
144
|
return {
|
|
174
145
|
path: _path.default.resolve(_path.default.join('.', pkgJSON.name, CONFIG_FILE)),
|
|
175
146
|
type: 'def'
|
|
176
147
|
};
|
|
177
148
|
};
|
|
149
|
+
|
|
178
150
|
/**
|
|
179
151
|
* This should never happens, consider it DEPRECATED
|
|
180
152
|
* @returns
|
|
181
153
|
*/
|
|
182
|
-
|
|
183
|
-
|
|
184
154
|
const getOldDirectory = () => {
|
|
185
155
|
return {
|
|
186
156
|
path: _path.default.resolve(_path.default.join('.', CONFIG_FILE)),
|
package/build/config-path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-path.js","names":["CONFIG_FILE","XDG","WIN","WIN32","pkgJSON","name","debug","buildDebug","findConfigFile","configPath","path","resolve","configPaths","getConfigPaths","length","_","isEmpty","Error","primaryConf","find","configLocation","fileExists","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","folderExists","replace","listPaths","getXDGDirectory","getWindowsDirectory","getRelativeDefaultDirectory","getOldDirectory","reduce","acc","currentValue","push","xDGConfigPath","XDG_CONFIG_HOME","platform","APPDATA"],"sources":["../src/config-path.ts"],"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"],"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;EACdC,IAAI,EAAE;AADQ,CAAhB;AASA,MAAMC,KAAK,GAAG,IAAAC,cAAA,EAAW,kBAAX,CAAd;AAEA;AACA;AACA;AACA;;AACA,SAASC,cAAT,CAAw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AA1C,IAAqD,IAAAd,yBAAA,EAAaL,OAAO,CAACC,GAAR,CAAYkB,OAAzB,CAAzD,EAA4F;IAC1FzD,KAAK,CAAC,wBAAD,EAA2BsC,OAAO,CAACC,GAAR,CAAYkB,OAAvC,CAAL;IACA,OAAO;MACLrD,IAAI,EAAEA,aAAA,CAAKC,OAAL,CAAaD,aAAA,CAAKqC,IAAL,CAAUH,OAAO,CAACC,GAAR,CAAYkB,OAAtB,EAA+B3D,OAAO,CAACC,IAAvC,EAA6CL,WAA7C,CAAb,CADD;MAEL0C,IAAI,EAAExC;IAFD,CAAP;EAID;AACF,CARD;AAUA;AACA;AACA;AACA;AACA;;;AACA,MAAMoD,2BAA2B,GAAG,MAAsB;EACxD,OAAO;IACL5C,IAAI,EAAEA,aAAA,CAAKC,OAAL,CAAaD,aAAA,CAAKqC,IAAL,CAAU,GAAV,EAAe3C,OAAO,CAACC,IAAvB,EAA6BL,WAA7B,CAAb,CADD;IAEL0C,IAAI,EAAE;EAFD,CAAP;AAID,CALD;AAOA;AACA;AACA;AACA;;;AACA,MAAMa,eAAe,GAAG,MAAsB;EAC5C,OAAO;IACL7C,IAAI,EAAEA,aAAA,CAAKC,OAAL,CAAaD,aAAA,CAAKqC,IAAL,CAAU,GAAV,EAAe/C,WAAf,CAAb,CADD;IAEL0C,IAAI,EAAE;EAFD,CAAP;AAID,CALD"}
|
|
1
|
+
{"version":3,"file":"config-path.js","names":["CONFIG_FILE","XDG","WIN","WIN32","pkgJSON","name","debug","buildDebug","findConfigFile","configPath","path","resolve","configPaths","getConfigPaths","length","_","isEmpty","Error","primaryConf","find","configLocation","fileExists","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","folderExists","replace","listPaths","getXDGDirectory","getWindowsDirectory","getRelativeDefaultDirectory","getOldDirectory","reduce","acc","currentValue","push","xDGConfigPath","XDG_CONFIG_HOME","platform","APPDATA"],"sources":["../src/config-path.ts"],"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"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AAEA;AAEA;AAA0D;AAE1D,MAAMA,WAAW,GAAG,aAAa;AACjC,MAAMC,GAAG,GAAG,KAAK;AACjB,MAAMC,GAAG,GAAG,KAAK;AACjB,MAAMC,KAAK,GAAG,OAAO;AACrB;AACA,MAAMC,OAAO,GAAG;EACdC,IAAI,EAAE;AACR,CAAC;AAOD,MAAMC,KAAK,GAAG,IAAAC,cAAU,EAAC,kBAAkB,CAAC;;AAE5C;AACA;AACA;AACA;AACA,SAASC,cAAc,CAACC,UAAmB,EAAU;EACnD;EACA,IAAI,OAAOA,UAAU,KAAK,WAAW,EAAE;IACrC,OAAOC,aAAI,CAACC,OAAO,CAACF,UAAU,CAAC;EACjC;EAEA,MAAMG,WAA6B,GAAGC,cAAc,EAAE;EACtDP,KAAK,CAAC,4BAA4B,EAAEM,WAAW,CAACE,MAAM,CAAC;EACvD,IAAIC,eAAC,CAACC,OAAO,CAACJ,WAAW,CAAC,EAAE;IAC1B;IACA,MAAM,IAAIK,KAAK,CAAC,yCAAyC,CAAC;EAC5D;;EAEA;EACA,MAAMC,WAAkC,GAAGH,eAAC,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AEL,WAAW,CAAC,CAAC;IAC7D0C,IAAI,EAAE;EACR,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMa,eAAe,GAAG,MAAsB;EAC5C,OAAO;IACL7C,IAAI,EAAEA,aAAI,CAACC,OAAO,CAACD,aAAI,CAACqC,IAAI,CAAC,GAAG,EAAE/C,WAAW,CAAC,CAAC;IAC/C0C,IAAI,EAAE;EACR,CAAC;AACH,CAAC"}
|
package/build/config-utils.js
CHANGED
|
@@ -5,11 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.fileExists = fileExists;
|
|
7
7
|
exports.folderExists = folderExists;
|
|
8
|
-
|
|
9
8
|
var _fs = _interopRequireDefault(require("fs"));
|
|
10
|
-
|
|
11
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
10
|
/**
|
|
14
11
|
* Check whether the path already exist.
|
|
15
12
|
* @param {String} path
|
|
@@ -18,23 +15,20 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
15
|
function folderExists(path) {
|
|
19
16
|
try {
|
|
20
17
|
const stat = _fs.default.statSync(path);
|
|
21
|
-
|
|
22
18
|
return stat.isDirectory();
|
|
23
19
|
} catch (_) {
|
|
24
20
|
return false;
|
|
25
21
|
}
|
|
26
22
|
}
|
|
23
|
+
|
|
27
24
|
/**
|
|
28
25
|
* Check whether the file already exist.
|
|
29
26
|
* @param {String} path
|
|
30
27
|
* @return {Boolean}
|
|
31
28
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
29
|
function fileExists(path) {
|
|
35
30
|
try {
|
|
36
31
|
const stat = _fs.default.statSync(path);
|
|
37
|
-
|
|
38
32
|
return stat.isFile();
|
|
39
33
|
} catch (_) {
|
|
40
34
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-utils.js","names":["folderExists","path","stat","fs","statSync","isDirectory","_","fileExists","isFile"],"sources":["../src/config-utils.ts"],"sourcesContent":["import fs from 'fs';\n\n/**\n * Check whether the path already exist.\n * @param {String} path\n * @return {Boolean}\n */\nexport function folderExists(path: string): boolean {\n try {\n const stat = fs.statSync(path);\n return stat.isDirectory();\n } catch (_: any) {\n return false;\n }\n}\n\n/**\n * Check whether the file already exist.\n * @param {String} path\n * @return {Boolean}\n */\nexport function fileExists(path: string): boolean {\n try {\n const stat = fs.statSync(path);\n return stat.isFile();\n } catch (_: any) {\n return false;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config-utils.js","names":["folderExists","path","stat","fs","statSync","isDirectory","_","fileExists","isFile"],"sources":["../src/config-utils.ts"],"sourcesContent":["import fs from 'fs';\n\n/**\n * Check whether the path already exist.\n * @param {String} path\n * @return {Boolean}\n */\nexport function folderExists(path: string): boolean {\n try {\n const stat = fs.statSync(path);\n return stat.isDirectory();\n } catch (_: any) {\n return false;\n }\n}\n\n/**\n * Check whether the file already exist.\n * @param {String} path\n * @return {Boolean}\n */\nexport function fileExists(path: string): boolean {\n try {\n const stat = fs.statSync(path);\n return stat.isFile();\n } catch (_: any) {\n return false;\n }\n}\n"],"mappings":";;;;;;;AAAA;AAAoB;AAEpB;AACA;AACA;AACA;AACA;AACO,SAASA,YAAY,CAACC,IAAY,EAAW;EAClD,IAAI;IACF,MAAMC,IAAI,GAAGC,WAAE,CAACC,QAAQ,CAACH,IAAI,CAAC;IAC9B,OAAOC,IAAI,CAACG,WAAW,EAAE;EAC3B,CAAC,CAAC,OAAOC,CAAM,EAAE;IACf,OAAO,KAAK;EACd;AACF;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,UAAU,CAACN,IAAY,EAAW;EAChD,IAAI;IACF,MAAMC,IAAI,GAAGC,WAAE,CAACC,QAAQ,CAACH,IAAI,CAAC;IAC9B,OAAOC,IAAI,CAACM,MAAM,EAAE;EACtB,CAAC,CAAC,OAAOF,CAAM,EAAE;IACf,OAAO,KAAK;EACd;AACF"}
|
package/build/config.js
CHANGED
|
@@ -4,54 +4,39 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.WEB_TITLE = exports.Config = void 0;
|
|
7
|
-
|
|
8
7
|
var _assert = _interopRequireDefault(require("assert"));
|
|
9
|
-
|
|
10
8
|
var _debug = _interopRequireDefault(require("debug"));
|
|
11
|
-
|
|
12
9
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
|
-
|
|
14
10
|
var _core = require("@verdaccio/core");
|
|
15
|
-
|
|
16
11
|
var _utils = require("@verdaccio/utils");
|
|
17
|
-
|
|
18
12
|
var _agent = require("./agent");
|
|
19
|
-
|
|
20
13
|
var _packageAccess = require("./package-access");
|
|
21
|
-
|
|
22
14
|
var _security = require("./security");
|
|
23
|
-
|
|
24
15
|
var _serverSettings = _interopRequireDefault(require("./serverSettings"));
|
|
25
|
-
|
|
26
16
|
var _token = require("./token");
|
|
27
|
-
|
|
28
17
|
var _uplinks = require("./uplinks");
|
|
29
|
-
|
|
30
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
19
|
const strategicConfigProps = ['uplinks', 'packages'];
|
|
33
20
|
const allowedEnvConfig = ['http_proxy', 'https_proxy', 'no_proxy'];
|
|
34
21
|
const debug = (0, _debug.default)('verdaccio:config');
|
|
35
22
|
const WEB_TITLE = 'Verdaccio';
|
|
23
|
+
|
|
36
24
|
/**
|
|
37
25
|
* Coordinates the application configuration
|
|
38
26
|
*/
|
|
39
|
-
|
|
40
27
|
exports.WEB_TITLE = WEB_TITLE;
|
|
41
|
-
|
|
42
28
|
class Config {
|
|
43
29
|
// @deprecated use configPath instead
|
|
30
|
+
|
|
44
31
|
// @ts-ignore
|
|
32
|
+
|
|
45
33
|
constructor(config) {
|
|
46
34
|
var _config$flags;
|
|
47
|
-
|
|
48
35
|
const self = this;
|
|
49
36
|
this.storage = process.env.VERDACCIO_STORAGE_PATH || config.storage;
|
|
50
|
-
|
|
51
37
|
if (!config.configPath) {
|
|
52
38
|
throw new Error('config_path is required');
|
|
53
39
|
}
|
|
54
|
-
|
|
55
40
|
this.config_path = config.config_path ?? config.configPath;
|
|
56
41
|
this.configPath = config.configPath;
|
|
57
42
|
debug('config path: %s', this.configPath);
|
|
@@ -61,73 +46,68 @@ class Config {
|
|
|
61
46
|
this.flags = {
|
|
62
47
|
searchRemote: ((_config$flags = config.flags) === null || _config$flags === void 0 ? void 0 : _config$flags.searchRemote) ?? true
|
|
63
48
|
};
|
|
64
|
-
|
|
65
49
|
for (const configProp in config) {
|
|
66
50
|
if (self[configProp] == null) {
|
|
67
51
|
self[configProp] = config[configProp];
|
|
68
52
|
}
|
|
69
|
-
}
|
|
70
|
-
|
|
53
|
+
}
|
|
71
54
|
|
|
55
|
+
// @ts-ignore
|
|
72
56
|
if (_lodash.default.isNil(this.user_agent)) {
|
|
73
57
|
this.user_agent = (0, _agent.getUserAgent)();
|
|
74
|
-
}
|
|
75
|
-
|
|
58
|
+
}
|
|
76
59
|
|
|
77
|
-
|
|
60
|
+
// some weird shell scripts are valid yaml files parsed as string
|
|
61
|
+
(0, _assert.default)(_lodash.default.isObject(config), _core.APP_ERROR.CONFIG_NOT_VALID);
|
|
78
62
|
|
|
63
|
+
// sanity check for strategic config properties
|
|
79
64
|
strategicConfigProps.forEach(function (x) {
|
|
80
65
|
if (self[x] == null) {
|
|
81
66
|
self[x] = {};
|
|
82
67
|
}
|
|
83
|
-
|
|
84
68
|
(0, _assert.default)((0, _utils.isObject)(self[x]), `CONFIG: bad "${x}" value (object expected)`);
|
|
85
69
|
});
|
|
86
70
|
this.uplinks = (0, _uplinks.sanityCheckUplinksProps)((0, _uplinks.uplinkSanityCheck)(this.uplinks));
|
|
87
|
-
this.packages = (0, _packageAccess.normalisePackageAccess)(self.packages);
|
|
71
|
+
this.packages = (0, _packageAccess.normalisePackageAccess)(self.packages);
|
|
88
72
|
|
|
73
|
+
// loading these from ENV if aren't in config
|
|
89
74
|
allowedEnvConfig.forEach(envConf => {
|
|
90
75
|
if (!(envConf in self)) {
|
|
91
76
|
self[envConf] = process.env[envConf] || process.env[envConf.toUpperCase()];
|
|
92
77
|
}
|
|
93
|
-
});
|
|
94
|
-
// @ts-ignore
|
|
78
|
+
});
|
|
95
79
|
|
|
80
|
+
// unique identifier of self server (or a cluster), used to avoid loops
|
|
81
|
+
// @ts-ignore
|
|
96
82
|
if (!this.server_id) {
|
|
97
83
|
this.server_id = (0, _utils.generateRandomHexString)(6);
|
|
98
84
|
}
|
|
99
85
|
}
|
|
86
|
+
|
|
100
87
|
/**
|
|
101
88
|
* Check for package spec
|
|
102
89
|
*/
|
|
103
|
-
|
|
104
|
-
|
|
105
90
|
getMatchedPackagesSpec(pkgName) {
|
|
106
91
|
// TODO: remove this method and replace by library utils
|
|
107
92
|
return (0, _utils.getMatchedPackagesSpec)(pkgName, this.packages);
|
|
108
93
|
}
|
|
94
|
+
|
|
109
95
|
/**
|
|
110
96
|
* Store or create whether receive a secret key
|
|
111
97
|
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
98
|
checkSecretKey(secret) {
|
|
115
99
|
debug('check secret key');
|
|
116
|
-
|
|
117
100
|
if (_lodash.default.isString(secret) && _lodash.default.isEmpty(secret) === false) {
|
|
118
101
|
this.secret = secret;
|
|
119
102
|
debug('reusing previous key');
|
|
120
103
|
return secret;
|
|
121
|
-
}
|
|
104
|
+
}
|
|
105
|
+
// it generates a secret key
|
|
122
106
|
// FUTURE: this might be an external secret key, perhaps within config file?
|
|
123
|
-
|
|
124
|
-
|
|
125
107
|
debug('generate a new key');
|
|
126
108
|
this.secret = (0, _token.generateRandomSecretKey)();
|
|
127
109
|
return this.secret;
|
|
128
110
|
}
|
|
129
|
-
|
|
130
111
|
}
|
|
131
|
-
|
|
132
112
|
exports.Config = Config;
|
|
133
113
|
//# sourceMappingURL=config.js.map
|