-
Notifications
You must be signed in to change notification settings - Fork 2
/
release.js
53 lines (43 loc) · 1.33 KB
/
release.js
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
'use strict';
const childProcess = require('child_process');
const fs = require('fs');
const path = require('path');
const opts = {cwd: __dirname};
const pluginRegExp = /(?<=^VERSION=).*$/m;
const packageRegExp = /(?<=^\s*"version"\s*:\s*").*(?=",$)/m;
const version = process.argv[2];
function replaceInFile(file, regexp, replacement) {
const fullPath = path.join(__dirname, file);
const contents = fs.readFileSync(fullPath, 'utf-8');
fs.writeFileSync(fullPath, contents.replace(regexp, replacement));
}
// Clean al the stuff.
childProcess.spawnSync('git', ['clean', '-xdf'], opts);
// Modify files with the version.
replaceInFile('plugin.cfg', pluginRegExp, version);
replaceInFile('package.json', packageRegExp, version);
replaceInFile('package-lock.json', packageRegExp, version);
replaceInFile('bin/service/package.json', packageRegExp, version);
replaceInFile('bin/service/package-lock.json', packageRegExp, version);
// Commit the modifications.
childProcess.spawnSync('git', ['add', '.'], opts);
childProcess.spawnSync('git', ['commit', '-m', 'Version ' + version], opts);
// Generate the zip.
childProcess.spawnSync(
'zip',
[
'-r',
'-9',
version + '.zip',
'bin',
'config',
'daemon',
'icons',
'uninstall',
'webfrontend',
'plugin.cfg',
'preupgrade.sh',
'postinstall.sh',
],
opts,
);