This repository has been archived by the owner on May 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
158 lines (153 loc) · 4.24 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
151
152
153
154
155
156
157
158
module.exports = function(grunt) {
var SECRET_FILE = "config/secret.json";
var fs = require("fs");
var secret;
var targetEnv = grunt.option('env') || 'dev';
var extend = require("extend");
if (fs.existsSync(SECRET_FILE)) {
secret = grunt.file.readJSON(SECRET_FILE);
}
// Project configuration.
grunt.initConfig(extend({
pkg: grunt.file.readJSON('package.json'),
jshint: {
files: [
"app/**/*.js",
"lib/**/*.js",
"!**/vendor/**/*.js"
],
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
node: true,
esnext: true,
globals: {
exports: true,
module: false,
window: true,
app: true,
jQuery: true,
FB: true,
twttr: true,
ppar: true
}
}
},
clean: {
folder: "dist",
folderTwo: ["build"]
},
copy: {
main: {
files: [{
expand: true,
src: ["app/**", "lib/**", "index.js", "package.json", "!**/data/**",
"!**/vendor/lib/**", "sql/db-setup.sql", "sql/db-setup.d/*.sql",
"sql/db-setup.d/*.json", "Deployment.md", "Gruntfile.js", "jobs.js",
"sql/datasets/*.json", "Gruntfile.client.json", "sql/upgrade.sql"],
dest: "build/yolosparo"
}, {
expand: false,
src: ["bin/remote_deploy.sh"],
dest: "dist/remote_deploy.sh"
}]
}
},
compress: {
main: {
options: {
archive: "dist/yolosparo-<%= pkg.version %>.tgz",
mode: "tgz"
},
files: [{
expand: true,
src: ["**"], // What should be included in the zip
dest: ".",
cwd: "build"
}]
}
},
release: {
options: {
push: false,
npm: false,
folder: "build",
beforeBump: ["jshint"],
beforeRelease: ["clean", "copy", "compress"],
github: {
repo: "piratas-ar/yolosparo",
usernameVar: "GITHUB_USERNAME",
passwordVar: "GITHUB_PASSWORD"
}
}
},
secret: secret,
"sftp": {
deploy: {
files: {
"./": ["dist/*"]
},
options: {
host: "<%= secret.host %>",
path: "<%= secret.remotePath %>",
port: "<%= secret.port %>",
username: "<%= secret.username %>",
privateKey: secret && grunt.file.read(secret.privateKey),
passphrase: "<%= secret.passphrase %>",
srcBasePath: "dist/",
showProgress: true
}
}
},
"sshexec": {
dev: {
command: "<%= secret.remotePath %>/remote_deploy.sh " +
"<%= pkg.version %> dev",
options: {
host: "<%= secret.host %>",
username: "<%= secret.username %>",
port: "<%= secret.port %>",
privateKey: secret && grunt.file.read(secret.privateKey),
passphrase: "<%= secret.passphrase %>"
}
},
prod: {
command: "<%= secret.remotePath %>/remote_deploy.sh " +
"<%= pkg.version %> prod",
options: {
host: "<%= secret.host %>",
username: "<%= secret.username %>",
port: "<%= secret.port %>",
privateKey: secret && grunt.file.read(secret.privateKey),
passphrase: "<%= secret.passphrase %>"
}
}
},
githooks: {
all: {
// Will run the jshint and test:unit tasks at every commit
'pre-commit': 'jshint',
}
}
}, grunt.file.readJSON("Gruntfile.client.json")));
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks("grunt-release");
grunt.loadNpmTasks('grunt-ssh');
grunt.loadNpmTasks('grunt-npmcopy');
grunt.loadNpmTasks("grunt-githooks");
// Default task.
grunt.registerTask("default", ["jshint", "clean", "copy", "compress"]);
grunt.registerTask("deploy", ["jshint", "clean", "copy", "compress",
"sftp", "sshexec:" + targetEnv]);
};