forked from ali-sdk/ali-oss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.js
32 lines (28 loc) · 881 Bytes
/
publish.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
const { env } = process;
const oss = require('.');
const pkg = require('./package.json');
const check = require('./publish-check');
const store = oss({
accessKeyId: env.ALI_SDK_OSS_CDN_ID,
accessKeySecret: env.ALI_SDK_OSS_CDN_SECRET,
endpoint: env.ALI_SDK_OSS_CDN_ENDPOINT,
bucket: env.ALI_SDK_OSS_CDN_BUCKET
});
const current = `aliyun-oss-sdk-${pkg.version}.min.js`;
const dist = './dist/aliyun-oss-sdk.min.js';
async function checkFile() {
try {
check.checkDist(dist); // check file exist
const contentMd5 = await check.caculateFileMd5(dist); // check md5 to server
await store.put(current, dist, {
headers: {
'Content-Md5': contentMd5
}
});
await check.checkCDNFile(current, store); // check cdn file
console.log(`publish CDN success, version is ${pkg.version}`);
} catch (e) {
console.log(e);
}
}
checkFile();