/* eslint-disable */ var aliOss = require('ali-oss'); var fs = require('fs'); var path = require('path'); const adseedOssManager = new aliOss({ region: 'oss-cn-beijing', accessKeyId: 'LTAI5tEday8PJNaMTz5mp8g4', accessKeySecret: 'ck84eTxx4aSTjornlYrCy8RkurCHfc', bucket: 'banban-new-admin-web2', }); const distDir = path.resolve(__dirname, '../dist'); const distFiles = traverseFiles(distDir, []); console.log('start deploying'); Promise.all(distFiles.map((fileName) => adseedOssManager.put(fileName.slice(distDir.length), fileName))) .then(() => console.log('deployment succeed')) .catch((e) => console.log('deployment failed:', e)); function traverseFiles(dir, distFiles) { const dirents = fs.readdirSync(dir, { withFileTypes: true }); for (const dirent of dirents) { const res = `${dir}/${dirent.name}`; const file = fs.statSync(res); if (file.isDirectory()) { traverseFiles(res, distFiles); } else { distFiles.push(res); } } return distFiles; }