support registry via config
This commit is contained in:
parent
00efbd04a8
commit
3b3c19ea24
@ -59,7 +59,7 @@ usage: updates [options]
|
||||
|
||||
## Config File
|
||||
|
||||
Put a `updates.config.js` or `updates.config.mjs` in the root of your project, usually besides `package.json` to configure certain options of the module. CLI arguments have precedence over them.
|
||||
Put a `updates.config.js` or `updates.config.mjs` in the root of your project, usually besides `package.json` to configure certain options of the module. CLI arguments have precedence over options in the config file.
|
||||
|
||||
```js
|
||||
export default {
|
||||
@ -71,8 +71,9 @@ export default {
|
||||
|
||||
### Config Options
|
||||
|
||||
- `include` *[]String*: Array of dependencies to include
|
||||
- `exclude` *[]String*: Array of dependencies to exclude
|
||||
- `types` *[]String*: Array of dependency types
|
||||
- `include` *Array<String>*: Array of dependencies to include
|
||||
- `exclude` *Array<String>*: Array of dependencies to exclude
|
||||
- `types` *Array<String>*: Array of dependency types
|
||||
- `registry` *String*: URL to npm registry
|
||||
|
||||
© [silverwind](https://github.com/silverwind), distributed under BSD licence
|
||||
|
29
updates.js
29
updates.js
@ -111,7 +111,6 @@ const allowDowngrade = parseMixedArg(args["allow-downgrade"]);
|
||||
|
||||
const npmrc = rc("npm", {registry: "https://registry.npmjs.org"});
|
||||
const authTokenOpts = {npmrc, recursive: true};
|
||||
const registry = normalizeUrl(args.registry || npmrc.registry);
|
||||
const githubApiUrl = args.githubapi ? normalizeUrl(args.githubapi) : "https://api.github.com";
|
||||
const maxSockets = typeof args.sockets === "number" ? parseInt(args.sockets) : MAX_SOCKETS;
|
||||
const extractCerts = str => Array.from(str.matchAll(/(----BEGIN CERT[^]+?IFICATE----)/g)).map(m => m[0]);
|
||||
@ -591,19 +590,6 @@ async function main() {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
const agentOpts = {};
|
||||
if (npmrc["strict-ssl"] === false) {
|
||||
agentOpts.rejectUnauthorized = false;
|
||||
} else {
|
||||
if ("cafile" in npmrc) {
|
||||
agentOpts.ca = rootCertificates.concat(extractCerts(readFileSync(npmrc.cafile, "utf8")));
|
||||
}
|
||||
if ("ca" in npmrc) {
|
||||
const cas = Array.isArray(npmrc.ca) ? npmrc.ca : [npmrc.ca];
|
||||
agentOpts.ca = rootCertificates.concat(cas.map(ca => extractCerts(ca)));
|
||||
}
|
||||
}
|
||||
|
||||
let packageFile;
|
||||
if (args.file) {
|
||||
let stat;
|
||||
@ -634,6 +620,19 @@ async function main() {
|
||||
} catch {}
|
||||
}
|
||||
|
||||
const agentOpts = {};
|
||||
if (npmrc["strict-ssl"] === false) {
|
||||
agentOpts.rejectUnauthorized = false;
|
||||
} else {
|
||||
if ("cafile" in npmrc) {
|
||||
agentOpts.ca = rootCertificates.concat(extractCerts(readFileSync(npmrc.cafile, "utf8")));
|
||||
}
|
||||
if ("ca" in npmrc) {
|
||||
const cas = Array.isArray(npmrc.ca) ? npmrc.ca : [npmrc.ca];
|
||||
agentOpts.ca = rootCertificates.concat(cas.map(ca => extractCerts(ca)));
|
||||
}
|
||||
}
|
||||
|
||||
let dependencyTypes;
|
||||
if (args.types) {
|
||||
dependencyTypes = Array.isArray(args.types) ? args.types : args.types.split(",");
|
||||
@ -703,6 +702,8 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
const registry = normalizeUrl(args.registry || config.registry || npmrc.registry);
|
||||
|
||||
const entries = await Promise.all(Object.keys(deps).map(key => {
|
||||
const [type, name] = key.split(sep);
|
||||
return fetchInfo(name, type, registry, agentOpts);
|
||||
|
Loading…
Reference in New Issue
Block a user