-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.js
76 lines (73 loc) · 2.29 KB
/
install.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
module.exports = {
/**
* Install function run in we.js site install.
*
* @param {Object} we we.js object
* @param {Function} done callback
*/
install: function install(we, done) {
we.log.info('Starting project install...');
we.utils.async.series([
function registerUser1(done) {
var user1 = {
username: 'administrator',
biography: 'The administrator user account!',
email: '[email protected]',
password: '123', // change after install
displayName: 'Administrator',
language: 'en-us',
active: true,
roles: ['administrator']
};
we.log.info('I will create the user: ', user1);
we.db.models.user.create(user1)
.then(function (user) {
we.log.info('New User with id: ', user.id);
// set the password
user.updatePassword(user1.password , function(error) {
if (error) return done(error);
done();
});
});
},
function createDefaultMenus(done) {
we.utils.async.series([
function createMainMenu(done) {
we.db.models.menu.create({
name: 'main',
class: 'nav navbar-nav collapse navbar-collapse '
}).then(function (r){
we.log.info('New menu with name: '+r.name+' and id: '+r.id);
// then create menu links
we.db.models.link.bulkCreate([
{
href: '/post',
text: 'POsts',
title: 'Posts page',
menuId: r.id
},
{
href: '/group',
text: 'Groups',
title: 'Groups page',
menuId: r.id
}
]).then(function(){
done();
}).catch(done);
}).catch(done);
},
function createSocialMenu(done) {
we.db.models.menu.create({
name: 'social',
class: 'list-inline text-center'
}).then(function (r) {
we.log.info('New menu with name: '+r.name+' and id: '+r.id);
done();
}).catch(done);
}
], done);
}
], done);
}
};