-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.js
55 lines (45 loc) · 2.02 KB
/
setup.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
console.log("Setting up project...");
const fs = require('fs');
const config = require('./setup.json');
const packageJSON = require('./package.json');
packageJSON.name = config.package.name;
packageJSON.description = config.package.description;
packageJSON.keywords = config.package.keywords;
packageJSON.author = config.package.author;
packageJSON.contributors = config.package.contributors;
packageJSON.license = config.package.license;
packageJSON.repository.url = "git+" + config.package.repositoryURL;
let url = config.package.repositoryURL.replace('.git', '');
packageJSON.bugs.url = url + "/issues";
packageJSON.homepage = url + "#readme";
let tokens = url.split('/');
let organization = tokens[tokens.length - 2];
console.log(organization);
let sonarConfig = "";
sonarConfig += "sonar.projectKey=" + config.sonar.projectKey + "\n";
sonarConfig += "sonar.organization=" + config.sonar.organization + "\n";
sonarConfig += "sonar.javascript.lcov.reportPaths=./coverage/lcov.info" + "\n";
sonarConfig += "sonar.coverage.exclusions=src/tests/**/*,src/ignoreCoverage/**/*,babel.config.js" + "\n";
sonarConfig += "sonar.exclusions=src/tests/**/*,src/ignoreCoverage/**/*,babel.config.js" + "\n";
sonarConfig += "sonar.qualitygate.wait=true" + "\n";
sonarConfig += "sonar.qualitygate.timeout=300" + "\n";
let readme = fs.readFileSync('./README.md', {encoding:'utf8', flag:'r'});
readme = readme.replace(/organization/g, organization);
readme = readme.replace(/sonarProjectKey/g, config.sonar.projectKey);
readme = readme.replace(/packageName/g, config.package.name);
fs.writeFile ("./package.json", JSON.stringify(packageJSON, null, 2), function(err) {
if (err) throw err;
console.log('package.json done...');
}
);
fs.writeFile ("./sonar-project.properties", sonarConfig, function(err) {
if (err) throw err;
console.log('sonar-project.properties done...');
}
);
fs.writeFile ("./README.md", readme, function(err) {
if (err) throw err;
console.log('README.md done...');
}
);
console.log("Setup done.");