-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathuToolsUpload.js
More file actions
56 lines (49 loc) · 1.51 KB
/
uToolsUpload.js
File metadata and controls
56 lines (49 loc) · 1.51 KB
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
const path = require('path');
const OSS = require('ali-oss');
const tar = require('tar');
const fs = require('fs-extra');
const tempPath = path.join(__dirname, '.lowcode', 'dist');
const file = path.join(__dirname, '.lowcode', 'download.tar.gz');
fs.copySync(
path.join(__dirname, 'dist', 'uTools'),
path.join(tempPath, 'uTools'),
);
fs.copySync(
path.join(__dirname, 'dist', 'share/uTools/webviewBaseControllerBundle.js'),
path.join(tempPath, 'share/uTools/webviewBaseControllerBundle.js'),
);
const dirNameArray = fs.readdirSync(path.join(tempPath, 'uTools'));
// eslint-disable-next-line no-restricted-syntax
for (const dirName of dirNameArray) {
const scriptPath = path.join(tempPath, 'uTools', dirName, 'script');
fs.removeSync(path.join(scriptPath, 'index.js'));
const files = fs.readdirSync(path.join(scriptPath, 'src'));
files.forEach((f) => {
if (f !== 'mainBundle.js') {
fs.removeSync(path.join(path.join(scriptPath, 'src'), f));
}
});
}
const upload = async () => {
await tar.create(
{
gzip: true,
file,
cwd: path.join(__dirname, '.lowcode'),
},
['dist'],
);
if (process.env.bucket) {
const store = new OSS({
region: 'oss-cn-beijing',
accessKeyId: process.env.accessKeyId,
accessKeySecret: process.env.accessKeySecret,
bucket: process.env.bucket,
});
store.put('download-free.tar.gz', file).then((result) => {
fs.removeSync(path.join(__dirname, '.lowcode'));
console.log(result.url);
});
}
};
upload();