forked from luiscrjunior/sei-trello
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
executable file
·49 lines (42 loc) · 1.28 KB
/
build.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
#!/usr/bin/env node
const path = require('path');
const { execSync } = require('child_process');
const appPath = path.resolve(__dirname, 'dist/expanded');
const outputPath = path.resolve(__dirname, 'dist/bundled');
const appManifest = require(path.resolve(__dirname, 'src/manifest.json'));
const runCommands = (commands) => {
for (let i = 0; i < commands.length; i++) {
const command = commands[i];
const step = (i + 1);
try {
console.log(`\x1b[33m[${step}]\x1b[0m '${command.descr}'...`);
const output = execSync(command.cmd, { stdio: 'ignore' });
} catch (e) {
console.log(`\x1b[31m[ERRO]\x1b[0m Erro ao executar '${command.cmd}'...`);
break;
}
}
};
const commands = [
{
descr: 'Mudando para a branch master',
cmd: 'git checkout master',
},
{
descr: `Fazendo build da versão atual: ${appManifest.version}`,
cmd: 'npm run webpack:prod',
},
{
descr: 'Compactando o path',
cmd: `cd ${appPath} && mkdir -p ${outputPath} && zip -r "${outputPath}/sei-trello_v${appManifest.version}.zip" ./`,
},
{
descr: 'Setando tag desta versão',
cmd: `git tag ${appManifest.version}`,
},
{
descr: 'Sincronizando git local com remote...',
cmd: 'git push --tags origin master dev',
},
];
runCommands(commands);