Skip to content

Commit c0d1704

Browse files
committed
zip release source
1 parent 9863420 commit c0d1704

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ node_modules/
77
dist/
88

99
package-lock.json
10-
.env.development
10+
.env.development
11+
wedatasphere-scriptis-*.zip

Diff for: package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"name": "scriptis",
3-
"version": "0.1.0",
3+
"version": "0.5.1",
44
"private": true,
55
"scripts": {
66
"serve": "vue-cli-service serve",
77
"build": "vue-cli-service build",
8+
"release": "node release.js",
89
"lint": "vue-cli-service lint",
910
"fix": "eslint --ext .js,.vue src --fix"
1011
},
@@ -32,6 +33,7 @@
3233
"@vue/cli-plugin-eslint": "^3.8.0",
3334
"@vue/cli-service": "^3.8.0",
3435
"@vue/eslint-config-standard": "^4.0.0",
36+
"archiver": "^3.0.3",
3537
"babel-eslint": "^10.0.1",
3638
"copy-webpack-plugin": "^4.5.2",
3739
"eslint": "^5.16.0",

Diff for: release.js

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
var fs = require('fs');
3+
var path = require('path');
4+
var archiver = require('archiver');
5+
6+
var pkg = require('./package.json');
7+
var outputFileName = `wedatasphere-scriptis-${pkg.version}-dist.zip`;
8+
9+
var outputFilePath = path.join(__dirname, outputFileName);
10+
11+
// create a file to stream archive data to.
12+
var output = fs.createWriteStream(outputFilePath);
13+
var archive = archiver('zip', {
14+
zlib: { level: 9 } // Sets the compression level.
15+
});
16+
17+
// listen for all archive data to be written
18+
// 'close' event is fired only when a file descriptor is involved
19+
output.on('close', function() {
20+
console.log(`${outputFileName}: ${archive.pointer()} total bytes`);
21+
console.log('archiver has been finalized and the output file descriptor has closed.');
22+
});
23+
24+
output.on('end', function() {
25+
console.log('Data has been drained');
26+
});
27+
28+
// good practice to catch warnings (ie stat failures and other non-blocking errors)
29+
archive.on('warning', function(err) {
30+
if (err.code === 'ENOENT') {
31+
// log warning
32+
} else {
33+
// throw error
34+
throw err;
35+
}
36+
});
37+
38+
// good practice to catch this error explicitly
39+
archive.on('error', function(err) {
40+
throw err;
41+
});
42+
43+
// pipe archive data to the file
44+
archive.pipe(output);
45+
46+
archive.directory('dist/');
47+
48+
var configSH = path.join(__dirname, 'config.sh');
49+
archive.append(fs.createReadStream(configSH), { name: 'config.sh' });
50+
var installSH = path.join(__dirname, 'install.sh');
51+
archive.append(fs.createReadStream(installSH), { name: 'install.sh' });
52+
53+
// finalize the archive (ie we are done appending files but streams have to finish yet)
54+
// 'close', 'end' or 'finish' may be fired right after calling this method so register to them beforehand
55+
archive.finalize();

0 commit comments

Comments
 (0)