-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare.js
79 lines (71 loc) · 2.11 KB
/
prepare.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
'use strict';
const fs = require('fs');
const defaultConfig = {
currentRepositoryURL: 'https://github.com/sengac/gitfeatures-spec.git',
localRepositories: {},
isCommitPushChecked: false,
gitProfiles: {
Default: {
'profile-name': 'Default',
'cors-proxy-address': 'https://cors.gitfeatures.com',
'author-name': 'Sir Testsalot',
'author-email': '[email protected]',
'default-branch': 'master',
'remote-name': 'origin',
'pgp-private-key': '',
'username': 'sirtestsalot',
'password': ''
}
}
};
function getProxies() {
return 'localhost:25921 cors.gitfeatures.com';
}
function getContentSecurityPolicy(proxies) {
if (process.env.NODE_ENV === 'production') {
return `default-src 'self' ${proxies}; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' data: blob: 'unsafe-eval';`;
} else {
return `default-src 'self' 'unsafe-inline' ${proxies}; style-src 'self' 'unsafe-inline'; font-src 'self'; img-src 'self' data: blob: 'unsafe-eval';`;
}
}
function getConfig() {
return encodeURIComponent(JSON.stringify(defaultConfig));
}
function getTitle() {
return 'GitFeatures';
}
function getDescription() {
return 'GitFeatures: BDD specification writing tool';
}
const html = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Security-Policy" content="${getContentSecurityPolicy(getProxies())}">
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="${getDescription()}" />
<meta name="gf:config" content="${getConfig()}" />
<title>${getTitle()}</title>
<style type="text/css">
html, body {
overscroll-behavior: contain;
overscroll-behavior-y: contain;
height: 100%;
margin: 0;
}
</style>
</head>
<body>
<div id="root"></div>
<script>
window.global = window
</script>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
`;
fs.writeFile('public/index.html', html.trim(), function (err) {
if (err) return console.log(err);
});