mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Removed external app support from app service init
no-issue
This commit is contained in:
parent
62f5bdac4c
commit
d63d3f77eb
1 changed files with 9 additions and 66 deletions
|
@ -1,72 +1,16 @@
|
|||
var debug = require('ghost-ignition').debug('services:apps'),
|
||||
_ = require('lodash'),
|
||||
Promise = require('bluebird'),
|
||||
api = require('../../api'),
|
||||
common = require('../../lib/common'),
|
||||
config = require('../../config'),
|
||||
settingsCache = require('../settings/cache'),
|
||||
loader = require('./loader'),
|
||||
// Internal apps are in config
|
||||
internalApps = config.get('apps:internal'),
|
||||
// Holds the available apps
|
||||
availableApps = {};
|
||||
|
||||
function recordLoadedApp(name, loadedApp) {
|
||||
// After loading the app, add it to our hash of loaded apps
|
||||
availableApps[name] = loadedApp;
|
||||
return loadedApp;
|
||||
}
|
||||
|
||||
function saveInstalledApps(installedApps) {
|
||||
debug('saving begin');
|
||||
var currentInstalledApps = settingsCache.get('installed_apps'),
|
||||
// Never save internal apps
|
||||
updatedAppsInstalled = _.difference(_.uniq(installedApps.concat(currentInstalledApps)), internalApps);
|
||||
|
||||
if (_.difference(updatedAppsInstalled, currentInstalledApps).length === 0) {
|
||||
debug('saving unneeded');
|
||||
return new Promise.resolve();
|
||||
}
|
||||
|
||||
debug('saving settings');
|
||||
return api.settings.edit({
|
||||
settings: [{
|
||||
key: 'installed_apps',
|
||||
value: updatedAppsInstalled
|
||||
}]
|
||||
}, {context: {internal: true}});
|
||||
}
|
||||
const debug = require('ghost-ignition').debug('services:apps');
|
||||
const Promise = require('bluebird');
|
||||
const common = require('../../lib/common');
|
||||
const config = require('../../config');
|
||||
const loader = require('./loader');
|
||||
const internalApps = config.get('apps:internal');
|
||||
|
||||
module.exports = {
|
||||
init: function () {
|
||||
debug('init begin');
|
||||
var activeApps = settingsCache.get('active_apps'),
|
||||
installedApps = settingsCache.get('installed_apps'),
|
||||
// Load means either activate, or install and activate
|
||||
// We load all Active Apps, and all Internal Apps
|
||||
appsToLoad = activeApps.concat(internalApps);
|
||||
const appsToLoad = internalApps;
|
||||
|
||||
function loadApp(appName) {
|
||||
// If internal or already installed, the app only needs activating
|
||||
if (_.includes(internalApps, appName) || _.includes(installedApps, appName)) {
|
||||
return loader.activateAppByName(appName).then(function (loadedApp) {
|
||||
return recordLoadedApp(appName, loadedApp);
|
||||
});
|
||||
}
|
||||
|
||||
// Else first install, then activate the app
|
||||
return loader.installAppByName(appName).then(function () {
|
||||
return loader.activateAppByName(appName);
|
||||
}).then(function (loadedApp) {
|
||||
return recordLoadedApp(appName, loadedApp);
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.map(appsToLoad, loadApp)
|
||||
.then(function () {
|
||||
// Save our installed apps to settings
|
||||
return saveInstalledApps(_.keys(availableApps));
|
||||
})
|
||||
return Promise.map(appsToLoad, appName => loader.activateAppByName(appName))
|
||||
.catch(function (err) {
|
||||
common.logging.error(new common.errors.GhostError({
|
||||
err: err,
|
||||
|
@ -74,6 +18,5 @@ module.exports = {
|
|||
help: common.i18n.t('errors.apps.appWillNotBeLoaded.help')
|
||||
}));
|
||||
});
|
||||
},
|
||||
availableApps: availableApps
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue