forked from verdaccio/verdaccio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuplink-util.js
39 lines (32 loc) · 1.02 KB
/
uplink-util.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* @prettier
* @flow
*/
import ProxyStorage from './up-storage';
import type { Versions, Config } from '@verdaccio/types';
import type { IProxy, ProxyList } from '../../types';
/**
* Set up the Up Storage for each link.
*/
export function setupUpLinks(config: Config): ProxyList {
const uplinks: ProxyList = {};
for (const uplinkName in config.uplinks) {
if (Object.prototype.hasOwnProperty.call(config.uplinks, uplinkName)) {
// instance for each up-link definition
const proxy: IProxy = new ProxyStorage(config.uplinks[uplinkName], config);
proxy.upname = uplinkName;
uplinks[uplinkName] = proxy;
}
}
return uplinks;
}
export function updateVersionsHiddenUpLink(versions: Versions, upLink: IProxy) {
for (const i in versions) {
if (Object.prototype.hasOwnProperty.call(versions, i)) {
const version = versions[i];
// holds a "hidden" value to be used by the package storage.
// $FlowFixMe
version[Symbol.for('__verdaccio_uplink')] = upLink.upname;
}
}
}