Add option: useGitForGitHubPlugins
parent
811dbb23f5
commit
d48c21f608
|
@ -410,6 +410,11 @@ URL to use for attachment and log links. Defaults to `http://IP:PORT`.
|
|||
**Default:** `off`
|
||||
If enabled, mod replies will use their nicknames (on the inbox server) instead of their usernames
|
||||
|
||||
#### useGitForGitHubPlugins
|
||||
**Default:** `off`
|
||||
If enabled, GitHub plugins will be installed with `git` rather than by downloading the archive's tarball.
|
||||
This is useful if you are installing plugins from private repositories that require ssh keys for authentication.
|
||||
|
||||
## Advanced options
|
||||
|
||||
#### extraIntents
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
* @property {*} [logOptions.allowAttachmentUrlFallback=false]
|
||||
* @property {number} [port=8890]
|
||||
* @property {string} [url]
|
||||
* @property {boolean} [useGitForGitHubPlugins=false]
|
||||
* @property {array} [extraIntents=[]]
|
||||
* @property {*} [dbType="sqlite"]
|
||||
* @property {object} [sqliteOptions]
|
||||
|
|
|
@ -409,6 +409,11 @@
|
|||
"type": "string"
|
||||
},
|
||||
|
||||
"useGitForGitHubPlugins": {
|
||||
"$ref": "#/definitions/customBoolean",
|
||||
"default": false
|
||||
},
|
||||
|
||||
"extraIntents": {
|
||||
"$ref": "#/definitions/stringArray",
|
||||
"default": []
|
||||
|
|
|
@ -10,6 +10,7 @@ const path = require("path");
|
|||
const threads = require("./data/threads");
|
||||
const displayRoles = require("./data/displayRoles");
|
||||
const { PluginInstallationError } = require("./PluginInstallationError");
|
||||
const config = require("./cfg");
|
||||
|
||||
const pluginSources = {
|
||||
npm: {
|
||||
|
@ -17,25 +18,28 @@ const pluginSources = {
|
|||
return new Promise((resolve, reject) => {
|
||||
console.log(`Installing ${plugins.length} plugins from NPM...`);
|
||||
|
||||
// Rewrite GitHub npm package names to full GitHub tarball links to avoid
|
||||
// needing to have Git installed to install these plugins.
|
||||
let finalPluginNames = plugins;
|
||||
if (! config.useGitForGitHubPlugins) {
|
||||
// Rewrite GitHub npm package names to full GitHub tarball links to avoid
|
||||
// needing to have Git installed to install these plugins.
|
||||
|
||||
// $1 package author, $2 package name, $3 branch (optional)
|
||||
const npmGitHubPattern = /^([a-z0-9_.-]+)\/([a-z0-9_.-]+)(?:#([a-z0-9_.-]+))?$/i;
|
||||
const rewrittenPluginNames = plugins.map(pluginName => {
|
||||
const gitHubPackageParts = pluginName.match(npmGitHubPattern);
|
||||
if (! gitHubPackageParts) {
|
||||
return pluginName;
|
||||
}
|
||||
// $1 package author, $2 package name, $3 branch (optional)
|
||||
const npmGitHubPattern = /^([a-z0-9_.-]+)\/([a-z0-9_.-]+)(?:#([a-z0-9_.-]+))?$/i;
|
||||
finalPluginNames = plugins.map(pluginName => {
|
||||
const gitHubPackageParts = pluginName.match(npmGitHubPattern);
|
||||
if (! gitHubPackageParts) {
|
||||
return pluginName;
|
||||
}
|
||||
|
||||
return `https://api.github.com/repos/${gitHubPackageParts[1]}/${gitHubPackageParts[2]}/tarball${gitHubPackageParts[3] ? "/" + gitHubPackageParts[3] : ""}`;
|
||||
});
|
||||
return `https://api.github.com/repos/${gitHubPackageParts[1]}/${gitHubPackageParts[2]}/tarball${gitHubPackageParts[3] ? "/" + gitHubPackageParts[3] : ""}`;
|
||||
});
|
||||
}
|
||||
|
||||
let stderr = "";
|
||||
const npmProcessName = /^win/.test(process.platform) ? "npm.cmd" : "npm";
|
||||
const npmProcess = childProcess.spawn(
|
||||
npmProcessName,
|
||||
["install", "--verbose", "--no-save", ...rewrittenPluginNames],
|
||||
["install", "--verbose", "--no-save", ...finalPluginNames],
|
||||
{ cwd: process.cwd() }
|
||||
);
|
||||
npmProcess.stderr.on("data", data => { stderr += String(data) });
|
||||
|
|
Loading…
Reference in New Issue