This repository was archived by the owner on Dec 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
82 lines (76 loc) · 2.38 KB
/
Copy pathGruntfile.js
File metadata and controls
82 lines (76 loc) · 2.38 KB
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
var DEV_PROPERTIES = '.dev_properties.json';
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
compress: {
main: {
options: {
archive: 'dist/<%= pkg.name %>.zip'
},
expand: true,
cwd: 'src/',
src: ['**/*']
}
},
http_upload: {
upload: {
options: {
url: 'http://<%= username %>:<%= password %>@<%= domain %>/edit-api/1/<%= siteId %>/<%= siteId %>/webappupload',
onComplete: function(data) {
console.log('Response: ' + data);
}
},
src: 'dist/<%= pkg.name %>.zip',
dest: 'fileupload'
}
},
prompt: {
setupdev: {
options: {
questions: [
{
name: 'domain',
type: 'input',
message: 'Website domain(www.example.com)'
},
{
name: 'siteId',
type: 'input',
message: 'SiteId(2.xxxx)'
},
{
name: 'username',
type: 'input',
message: 'Username?'
},
{
name: 'password',
type: 'password',
message: 'Password?'
}
],
then: function(results, done) {
grunt.file.write('.dev_properties.json', JSON.stringify({
domain: results.domain,
siteId: results.siteId,
username: results.username,
password: results.password
}));
}
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-http-upload');
grunt.loadNpmTasks('grunt-prompt');
grunt.registerTask('setup', 'prompt:setupdev');
grunt.registerTask('install', function() {
if (grunt.file.exists(DEV_PROPERTIES)) {
grunt.config.merge(JSON.parse(grunt.file.read(DEV_PROPERTIES)));
grunt.task.run(['compress', 'http_upload:upload']);
} else {
grunt.log.write('Must run setup first');
}
});
};