forked from Num142857/alili.tech
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oss.js
71 lines (63 loc) · 1.53 KB
/
oss.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
const publish = require('ali-oss-publish')
publish({
entry: '.', // defaults to '.'
output: '/',
// include: /bin|cli|lib|index\.js$|\.md$/,
exclude: /.DS_Store$|.git/,
mime: (filename) => {
if (/\.md$/.test(filename)) {
return 'text/markdown'
}
return undefined
},
meta: {
ref: Date.now()
},
headers: {
'Cache-Control': 'max-age=30672000'
},
rules: [
{
test: /(index\.html|service-worker\.js)$/,
use: {
headers: {
'Cache-Control': 'no-cache'
}
}
}
],
// config: '/path/to/config/file.js', // defaults to try load config from 'ali-oss-publish.config.js' when config is not set
retry: 1,
concurrency: 4,
force: true
}, (err, stats) => {
if (err) {
console.error('ali-oss-publish encountered a fatal error.')
console.error(err)
process.exit(1)
}
if (stats.hasProgress()) {
const {
type,
index,
current,
total,
message
} = stats
console.log('[%s] [%s/%s] #%s: %s', type, current, total, index, message)
} else {
console.log(stats.message)
}
if (stats.hasWarnings()) {
console.warn('ali-oss-publish encountered some warnings.')
stats.warnings.forEach((x) => {
console.warn(x)
})
}
if (stats.hasErrors()) {
console.error('ali-oss-publish encountered some errors.')
stats.errors.forEach((x) => {
console.error(x)
})
}
})