1 Star 0 Fork 1

向阳花-语/amis-admin

forked from ssltest/amis-admin 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
upload2cdn.js 1.61 KB
一键复制 编辑 原始数据 按行查看 历史
liaoxuezhi 提交于 2019-06-05 11:15 +08:00 . 更新 gh-pages
const bosSDK = require('bce-sdk-js');
const fs = require('fs');
const walk = require('fs-walk');
const path = require('path');
const tokenFile = process.argv[2] || '~/bos.credentials';
if (!fs.existsSync(tokenFile)) {
console.error(tokenFile + ' does not exists!');
process.exit(1);
}
const config = JSON.parse(fs.readFileSync(tokenFile, 'utf-8'));
const client = new bosSDK.BosClient(config);
const bucketName = config.bucket || 'bce-cdn';
const prefix = 'fex/';
async function main() {
const folder = 'gh-pages';
const productName = 'amis-admin-gh-pages';
if (!fs.existsSync(folder)) {
throw new Error('文件夹不存在');
}
if (!productName) {
throw new Error('请指定产品名称');
}
const promises = [];
walk.walkSync(folder, (basedir, filename, stat) => {
if (stat.isDirectory() || /\.html$/.test(filename)) {
return;
}
const relativePath = path.relative(folder, basedir);
const objectName = path.join(prefix, productName, relativePath, filename);
promises.push(() => client
.putObjectFromFile(bucketName, objectName, path.join(basedir, filename))
.then(
() => console.log(` ==> ${objectName}`),
res => console.error(res)
)
);
});
if (!promises.length) {
console.log('Nothing need to upload');
}
return promises
.reduce((preview, current) => {
return preview.then(current);
}, Promise.resolve());
}
main().then(() => console.log('Done!')).catch(e => console.error(e.message, e.stack));
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mozhengrong/amis-admin.git
git@gitee.com:mozhengrong/amis-admin.git
mozhengrong
amis-admin
amis-admin
master

搜索帮助