代码拉取完成,页面将自动刷新
同步操作将从 刘亚平/简搭云在线可视化表单设计,低码平台 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
// 一键部署 oss
const co = require('co')
const OSS = require('ali-oss')
const path = require('path')
const fs = require('fs')
class Uploader {
constructor(root, ossConfig) {
this.root = path.resolve(root)
this._retries = {}
this.client = new OSS({
region: ossConfig.region,
accessKeyId: ossConfig.accessKeyId,
accessKeySecret: ossConfig.accessKeySecret,
bucket: ossConfig.bucket
})
}
scan(dir) {
const currentDirectory = dir || this.root
fs.readdirSync(currentDirectory)
.forEach(file => {
//去除隐藏文件
// if(file.indexOf('.')===0) return;
const filePath = path.resolve(currentDirectory, file)
const stats = fs.statSync(filePath)
if (stats.isFile(filePath)) {
this.upload(filePath)
.then(() => console.log('uploaded file: ' + filePath))
.catch(e => {
process.exit(1)
})
return
}
if (stats.isDirectory()) {
this.scan(filePath)
}
})
}
upload(file) {
const root = this.root
const _this = this
return co(function *() {
let name = file.replace(root, '').split(path.sep).join('/')
if (name.charAt(0) === '/') {
name = name.substr(1)
}
return yield _this.client.put(process.env.folder+name, file)
}).catch(e => {
const c = this._retries[file] || 1
if (c < 3) { //出错时,再重试2次
this._retries[file] = c + 1
return this.upload(file)
}
return Promise.reject(e)
})
}
}
const { region, accessKeyId, accessKeySecret, bucket } = process.env
const ossConfig = { region, accessKeyId, accessKeySecret, bucket }
const up = new Uploader('./dist', ossConfig)
up.scan()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。