20fec74c73
closes #5492 - remove core/server/require-tree.js and split it into modules - add read-directory module to recursively read directories - add validate-themes module to scan themes and return errors/warnings - add parse-package-json module to parse json and validate requirements - rewrite core/server/models/index.js to manually require models
70 lines
1.3 KiB
JavaScript
70 lines
1.3 KiB
JavaScript
/**
|
|
* Dependencies
|
|
*/
|
|
|
|
var Promise = require('bluebird'),
|
|
_ = require('lodash'),
|
|
|
|
exports,
|
|
models;
|
|
|
|
/**
|
|
* Expose all models
|
|
*/
|
|
|
|
exports = module.exports;
|
|
|
|
models = [
|
|
'accesstoken',
|
|
'app-field',
|
|
'app-setting',
|
|
'app',
|
|
'client-trusted-domain',
|
|
'client',
|
|
'permission',
|
|
'post',
|
|
'refreshtoken',
|
|
'role',
|
|
'settings',
|
|
'tag',
|
|
'user'
|
|
];
|
|
|
|
function init() {
|
|
exports.Base = require('./base');
|
|
|
|
models.forEach(function (name) {
|
|
_.extend(exports, require('./' + name));
|
|
});
|
|
|
|
return Promise.resolve();
|
|
}
|
|
|
|
/**
|
|
* TODO: move to some other place
|
|
*/
|
|
|
|
// ### deleteAllContent
|
|
// Delete all content from the database (posts, tags, tags_posts)
|
|
exports.deleteAllContent = function deleteAllContent() {
|
|
var self = this;
|
|
|
|
return self.Post.findAll().then(function then(posts) {
|
|
return Promise.all(_.map(posts.toJSON(), function mapper(post) {
|
|
return self.Post.destroy({id: post.id});
|
|
}));
|
|
}).then(function () {
|
|
return self.Tag.findAll().then(function then(tags) {
|
|
return Promise.all(_.map(tags.toJSON(), function mapper(tag) {
|
|
return self.Tag.destroy({id: tag.id});
|
|
}));
|
|
});
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Expose `init`
|
|
*/
|
|
|
|
exports.init = init;
|