diff --git a/core/server/services/apps/dependencies.js b/core/server/services/apps/dependencies.js deleted file mode 100644 index 34c8615353..0000000000 --- a/core/server/services/apps/dependencies.js +++ /dev/null @@ -1,51 +0,0 @@ -var _ = require('lodash'), - fs = require('fs-extra'), - path = require('path'), - Promise = require('bluebird'), - spawn = require('child_process').spawn, - win32 = process.platform === 'win32'; - -function AppDependencies(appPath) { - this.appPath = appPath; -} - -AppDependencies.prototype.install = function installAppDependencies() { - var spawnOpts, - self = this; - - return new Promise(function (resolve, reject) { - fs.stat(path.join(self.appPath, 'package.json'), function (err) { - if (err) { - // File doesn't exist - nothing to do, resolve right away? - resolve(); - } else { - // Run npm install in the app directory - spawnOpts = { - cwd: self.appPath - }; - - self.spawnCommand('npm', ['install', '--production'], spawnOpts) - .on('error', reject) - .on('exit', function (err) { - if (err) { - reject(err); - } - - resolve(); - }); - } - }); - }); -}; - -// Normalize a command across OS and spawn it; taken from yeoman/generator -AppDependencies.prototype.spawnCommand = function (command, args, opt) { - var winCommand = win32 ? 'cmd' : command, - winArgs = win32 ? ['/c'].concat(command, args) : args; - - opt = opt || {}; - - return spawn(winCommand, winArgs, _.defaults({stdio: 'inherit'}, opt)); -}; - -module.exports = AppDependencies; diff --git a/core/server/services/apps/loader.js b/core/server/services/apps/loader.js index 40ef014a00..68bb10d540 100644 --- a/core/server/services/apps/loader.js +++ b/core/server/services/apps/loader.js @@ -5,7 +5,6 @@ const config = require('../../config'); const common = require('../../lib/common'); const AppProxy = require('./proxy'); const Sandbox = require('./sandbox'); -const AppDependencies = require('./dependencies'); const AppPermissions = require('./permissions'); // Get the full path to an app by name @@ -49,40 +48,6 @@ function getAppByName(name, permissions) { } module.exports = { - // Load a app and return the instantiated app - installAppByName: function (name) { - // Install the apps dependencies first - const appPath = getAppAbsolutePath(name); - const deps = new AppDependencies(appPath); - - return deps.install() - .then(function () { - // Load app permissions - const perms = new AppPermissions(appPath); - - return perms.read().catch(function (err) { - // Provide a helpful error about which app - return Promise.reject(new Error(common.i18n.t('errors.apps.permissionsErrorLoadingApp.error', { - name: name, - message: err.message - }))); - }); - }) - .then(function (appPerms) { - const {app, proxy} = getAppByName(name, appPerms); - - // Check for an install() method on the app. - if (!_.isFunction(app.install)) { - return Promise.reject(new Error(common.i18n.t('errors.apps.noInstallMethodLoadingApp.error', {name: name}))); - } - - // Run the app.install() method - // Wrapping the install() with a when because it's possible - // to not return a promise from it. - return Promise.resolve(app.install(proxy)).return(app); - }); - }, - // Activate a app and return it activateAppByName: function (name) { const perms = new AppPermissions(getAppAbsolutePath(name));