-
Notifications
You must be signed in to change notification settings - Fork 209
/
Copy pathbuild-preview.js
62 lines (53 loc) · 1.61 KB
/
build-preview.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
54
55
56
57
58
59
60
61
62
const { execSync } = require('child_process');
const path = require('path');
const NodeGit = require('nodegit');
const fs = require('fs-extra');
if (!process.env.GITHUB_TOKEN) {
console.error('GITHUB_TOKEN not provided as an environment property');
return 1;
}
const url = 'https://github.com/vaadin/docs-app.git';
const localPath = path.join(__dirname, 'docs-app');
const opts = {
checkoutBranch: 'master',
fetchOpts: {
callbacks: {
certificateCheck: function () {
return 0;
},
credentials: function (args) {
return NodeGit.Cred.userpassPlaintextNew(process.env.GITHUB_TOKEN, 'x-oauth-basic');
},
},
},
};
// Cleanup
fs.rmdirSync(localPath, { recursive: true });
console.info('Cloning docs-app...');
const clonePromise = new Promise((resolve, reject) => {
const clone = NodeGit.Clone(url, localPath, opts);
clone
.catch((e) => {
reject(e);
})
.then(() => {
resolve();
});
});
clonePromise
.then(() => {
console.log('Installing docs-app dependencies...');
execSync('npm ci --only=production', { cwd: './docs-app', stdio: 'inherit' });
console.log('Prepare content...');
execSync(
'./scripts/mvnw -B --no-transfer-progress compile vaadin:prepare-frontend vaadin:build-frontend',
{ cwd: '../', stdio: 'inherit' }
);
// console.log('Run lint...');
// execSync('npm run lint', { cwd: '../', stdio: 'inherit' });
console.log('Building documentation site...');
execSync('DOCS_CONTENT_ROOT=../../ npm run build', { cwd: './docs-app', stdio: 'inherit' });
})
.catch(() => {
process.exit(1);
});