-import { logger, createCertsIfNotExist, root } from '../helpers'
-
-function installApplication (callback) {
- series([
- function createDatabase (callbackAsync) {
- db.sequelize.sync().asCallback(callbackAsync)
- // db.sequelize.sync({ force: true }).asCallback(callbackAsync)
- },
-
- function createDirectories (callbackAsync) {
- createDirectoriesIfNotExist(callbackAsync)
- },
-
- function createCertificates (callbackAsync) {
- createCertsIfNotExist(callbackAsync)
- },
-
- function createOAuthClient (callbackAsync) {
- createOAuthClientIfNotExist(callbackAsync)
- },
-
- function createOAuthUser (callbackAsync) {
- createOAuthAdminIfNotExist(callbackAsync)
- }
- ], callback)
+import { logger, createCertsIfNotExist, mkdirpPromise, rimrafPromise } from '../helpers'
+
+function installApplication () {
+ return db.sequelize.sync()
+ .then(() => removeCacheDirectories())
+ .then(() => createDirectoriesIfNotExist())
+ .then(() => createCertsIfNotExist())
+ .then(() => createOAuthClientIfNotExist())
+ .then(() => createOAuthAdminIfNotExist())