-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from EllenFawkes/npm
Npm dependencies for plugins
- Loading branch information
Showing
15 changed files
with
168 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
node_modules | ||
**/node_modules | ||
npm-debug.log | ||
.git | ||
.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
var fs = require('fs'), | ||
path = require('path'); | ||
function getDirectories(srcpath) { | ||
return fs.readdirSync(srcpath).filter(function(file) { | ||
return fs.statSync(path.join(srcpath, file)).isDirectory(); | ||
}); | ||
} | ||
|
||
console.log("***********"); | ||
|
||
var plugin_folders; | ||
var plugin_directory; | ||
var exec_dir; | ||
try { //try loading plugins from a non standalone install first | ||
plugin_directory = "./plugins/"; | ||
plugin_folders = getDirectories(plugin_directory); | ||
} catch(e){//load paths for an Electrify install | ||
exec_dir = path.dirname(process.execPath) + "/resources/default_app/"; //need this to change node prefix for npm installs | ||
plugin_directory = path.dirname(process.execPath) + "/resources/default_app/plugins/"; | ||
plugin_folders = getDirectories(plugin_directory); | ||
} | ||
|
||
function createNpmDependenciesArray (packageFilePath) { | ||
var p = require(packageFilePath); | ||
if (!p.dependencies) return []; | ||
var deps = []; | ||
for (var mod in p.dependencies) { | ||
deps.push(mod + "@" + p.dependencies[mod]); | ||
} | ||
|
||
return deps; | ||
} | ||
|
||
function npm_install(){ | ||
var deps = []; | ||
var npm = require("npm"); | ||
for (var i = 0; i < plugin_folders.length; i++) { | ||
try{ | ||
require(plugin_directory + plugin_folders[i]); | ||
} catch(e) { | ||
deps = deps.concat(createNpmDependenciesArray(plugin_directory + plugin_folders[i] + "/package.json")); | ||
} | ||
} | ||
if(deps.length > 0) { | ||
npm.load({ | ||
loaded: false | ||
}, function (err) { | ||
// catch errors | ||
if (plugin_directory != "./plugins/"){ //install plugin modules for Electrify builds | ||
npm.prefix = exec_dir; | ||
console.log(npm.prefix); | ||
} | ||
npm.commands.install(deps, function (er, data) { | ||
if(er){ | ||
console.log(er); | ||
} | ||
console.log("Plugin NPM install complete!"); | ||
}); | ||
|
||
if (err) { | ||
console.log("preload_plugins: " + err); | ||
} | ||
}); | ||
} else { | ||
console.log("No dependencies to install"); | ||
} | ||
} | ||
|
||
npm_install(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
|
||
projectDir=$(pwd) | ||
pluginDirs=$(find plugins -maxdepth 2 -name package.json | sed "s/package.json//") | ||
|
||
echo "Found plugin dirs: $pluginDirs" | ||
|
||
for pluginDir in $pluginDirs; do | ||
cd $pluginDir | ||
echo "Installing NPM dependencies for: $pluginDir" | ||
npm install | ||
#mv -f node_modules/* $projectDir/node_modules | ||
done | ||
|
||
echo "OK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"pluginName": "Announcer", | ||
"description": "Announce callouts to your Discord text channels", | ||
"type": "plugin", | ||
"main": "announcer.js", | ||
"dependencies": { | ||
"duration-parser": "^1.0.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"pluginName": "ChanInfo", | ||
"description": "Get a Discord channel informations", | ||
"type": "plugin", | ||
"main": "chaninfo.js", | ||
"dependencies": { | ||
"moment": "^2.18.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"pluginName": "Giphy", | ||
"description": "Find a gif and send it to a discord channel", | ||
"type": "plugin", | ||
"main": "giphy.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"pluginName": "Meowii", | ||
"description": "Cat and Fox funny gifs", | ||
"type": "plugin", | ||
"main": "meowi.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"pluginName": "Misc", | ||
"description": "Core expansion plugin", | ||
"type": "plugin", | ||
"main": "misc.js", | ||
"dependencies": { | ||
"moment": "^2.18.1", | ||
"twix": "^1.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"pluginName": "MumbleBox", | ||
"description": "Mumbles and reactions to text messages on Discord channels", | ||
"type": "plugin", | ||
"main": "urbandictionary.js", | ||
"dependencies": { | ||
"url-regex": "^4.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"pluginName": "Nextstream", | ||
"description": "Is your stream live now? When is planned next stream?", | ||
"type": "plugin", | ||
"main": "nextstream.js", | ||
"dependencies": { | ||
"moment": "^2.18.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"pluginName": "Twitchcord", | ||
"description": "Chat messages bridge betwen Discord and Twitch worlds", | ||
"type": "plugin", | ||
"main": "twitchcord.js", | ||
"dependencies": { | ||
"tmi.js": "^1.2.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"pluginName": "UrbanDictionary", | ||
"description": "Be smarter with Urbandictionary quotes!", | ||
"type": "plugin", | ||
"main": "urbandictionary.js" | ||
} |