-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGruntfile.js
150 lines (145 loc) · 4.12 KB
/
Gruntfile.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
pluginDir: 'wordpress/wp-content/plugins',
themeDir: 'wordpress/wp-content/themes',
wordpressConfig : {
db_name : "wordpress",
db_usr : "root",
db_pwd : "root"
},
copy: {
core: {
files: [
{
expand: true,
cwd: 'bower_components/wordpress/',
src: ['**/*'],
dest: 'wordpress/',
flatten: false
}
]
},
plugins:{
files: [
{
expand: true,
cwd: 'bower_components/woocommerce/',
src: ['**/*'],
dest: '<%=pluginDir%>/woocommerce/',
flatten: false
}
]
},
themes:{
files: [
{
expand: true,
cwd: 'bower_components/sparcui/',
src: ['**/*'],
dest: '<%=themeDir%>/sparcui/',
flatten: false
}
]
}
},
replace: {
example: {
src: ['wordpress/wp-config-sample.php'], // source files array (supports minimatch)
dest: 'wordpress/wp-config.php', // destination directory or file
replacements: [
{
from: 'database_name_here', // string replacement
to: '<%=wordpressConfig.db_name%>'
},
{
from: 'username_here', // string replacement
to: '<%=wordpressConfig.db_usr%>'
},
{
from: 'password_here', // string replacement
to: '<%=wordpressConfig.db_pwd%>'
}
]
}
},
shell: {
wpsql: {
command: 'mysql --user="<%=wordpressConfig.db_usr%>" --password="<%=wordpressConfig.db_pwd%>" --execute="CREATE DATABASE IF NOT EXISTS <%=wordpressConfig.db_name%>;"'
}
},
//Deployment over SFTP
'sftp-deploy': {
build: {
auth: {
host: '50.116.17.29', //server.com the name or the IP address of the server we are deploying to
port: 22, // the port that the sftp service is running on
authKey: 'key1' // a key for looking up the saved credentials
},
cache: 'sftpCache.json',
src: 'wordpress', // the source location, the local folder that we are transferring to the server
dest: '/', // the destination location, the folder on the server we are deploying to
exclusions: [
'wordpress/**/.DS_Store',
'wordpress/**/Thumbs.db',
'wordpress/wp-config.php',
'wordpress/.htaccess',
'wordpress/wp-admin/*',
'wordpress/index.php',
'wordpress/license.txt',
'wordpress/readme.html',
'wordpress/wc-logs/*',
'wordpress/wp-activate.php',
'wordpress/wp-blog-header.php',
'wordpress/wp-comments-post.php',
'wordpress/wp-config-sample.php',
'wordpress/wp-config.php',
'wordpress/wp-cron.php',
'wordpress/wp-includes/*',
'wordpress/wp-links-opml.php',
'wordpress/wp-load.php',
'wordpress/wp-login.php',
'wordpress/wp-mail.php',
'wordpress/wp-settings.php',
'wordpress/wp-signup.php',
'wordpress/wp-trackback.php',
'wordpress/xmlrpc.php',
'wordpress/wp-content/index.php',
'wordpress/wp-content/uploads/',
'wordpress/wp-content/blogs.dir/',
'wordpress/wp-content/upgrade/*',
'wordpress/wp-content/backup-db/*',
'wordpress/wp-content/advanced-cache.php',
'wordpress/wp-content/wp-cache-config.php',
'wordpress/wp-content/cache/*',
'wordpress/wp-content/cache/supercache/*',
'wordpress/wp-content/themes/index.php',
'wordpress/wp-content/themes/twentyfourteen/*',
'wordpress/wp-content/themes/twentythirteen/*',
'wordpress/wp-content/themes/twentytwelve/*',
'wordpress/wp-content/themes/twentyeleven/*',
'wordpress/wp-content/themes/twentyten/*'
],
concurrency: 4,
progress: true
}
}
});
// Load the Grunt plugins.
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-text-replace')
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-sftp-deploy');
// Default task(s).
grunt.registerTask('default', [
// default actions go here
'copy',
'replace',
'shell'
]);
// Deploy task(s).
grunt.registerTask('deploy-sftp', [
// default actions go here
'sftp-deploy'
]);
};