forked from skanaar/nomnoml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.js
50 lines (43 loc) · 1.13 KB
/
deploy.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
var AWS = require('aws-sdk')
var fs = require('fs')
AWS.config.update({
accessKeyId: process.env.AWS_KEY,
secretAccessKey: process.env.AWS_SECRET
})
var files = [
'index.html',
'nomnoml.css',
'dist/nomnoml.web.js',
'dist/webapp.js',
'lib/dagre.min.js',
'lib/filesaver.min.js',
'lib/underscore.min.js',
'lib/vue.min.js',
'codemirror/codemirror-compressed.js',
'codemirror/codemirror.css',
'codemirror/nomnoml.codemirror-mode.js',
'codemirror/solarized.nomnoml.css',
'img/interaction-tutorial.svg',
]
var contentTypes = {
js: 'application/javascript',
css: 'text/css',
html: 'text/html',
svg: 'image/svg+xml',
}
var subfolder = process.argv[2]
subfolder = subfolder ? (subfolder + '/') : ''
function contentType(file){ return contentTypes[file.split('.').slice(-1)[0]] }
files.forEach(function (file){
var base64data = Buffer.from(fs.readFileSync(file), 'binary')
var s3 = new AWS.S3()
s3.putObject({
Bucket: 'www.nomnoml.com',
Key: subfolder + file,
Body: base64data,
ContentType: contentType(file),
ACL: 'public-read'
}, function (resp) {
console.log(' uploaded ' + file)
})
})