-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdeploy.js
43 lines (39 loc) · 1.33 KB
/
deploy.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
// TODO: not used now, try to fix the issue that files cannot be found
const { spawnSync } = require('child_process');
// const SALTUIVER = require('saltui/package.json').version;
const BRANCH = new Date().toISOString();
const cmd = (str) => {
console.log(`================${str}==================`);
const strArr = str.split(' ');
console.log(strArr);
spawnSync(strArr[0], strArr.slice(1), { stdio: 'inherit' });
};
const deploy = (theme = 'blue') => {
const lessPath = './site/theme/static';
cmd(`cp -rf ${lessPath}/vars/${theme}.less ${lessPath}/var.less`);
cmd('npm run build');
cmd('ls -al ./build');
console.log('build finished');
setTimeout(() => {
console.log('start deploy');
cmd('git add .');
cmd(`git commit -m v${BRANCH}`);
cmd('git push origin source-blue');
cmd('mkdir ../SALT_UI_BUILD');
cmd('mv ./build/* ../SALT_UI_BUILD/');
cmd('mv ./_site/* ../SALT_UI_BUILD/');
cmd('git checkout master');
cmd('git pull origin master');
cmd('cp -rf ../SALT_UI_BUILD/* .');
cmd(`cp -rf ../SALT_UI_BUILD/index.css ./${theme}.css`);
cmd('rm -rf ../SALT_UI_BUILD');
cmd('git add .');
cmd(`git commit -m v${BRANCH}`);
cmd('git push origin master');
cmd('git checkout source-blue');
}, 5000);
};
const themes = ['blue'];
themes.forEach((theme) => {
deploy(theme);
});