update dependency, code cleanup

This commit is contained in:
Slawomir Jaranowski
2020-01-23 00:08:24 +01:00
parent f9c596d8b3
commit cfeadc6038
8 changed files with 2863 additions and 1819 deletions

View File

@ -1,10 +1,14 @@
const core = require('@actions/core');
const os = require('os');
const path = require('path');
const fs = require('fs');
const DOMParser = require('xmldom').DOMParser;
const XMLSerializer = require('xmldom').XMLSerializer;
const xpath = require('xpath');
const settingsPath = path.join(os.homedir(), '.m2', 'settings.xml');
function getSettingsTemplate() {
const templatePath = path.join(__dirname, 'templates', 'settings.xml');
const templateStr = fs.readFileSync(templatePath).toString();
@ -82,10 +86,33 @@ function addSonatypeSnapshots(template) {
}
}
function generate() {
core.info('Prepare maven setings: ' + settingsPath);
if (fs.existsSync(settingsPath)) {
core.warning('maven settings.xml already exists - skip');
return;
}
const templateXml = getSettingsTemplate();
fillServers(templateXml);
fillProperties(templateXml);
addSonatypeSnapshots(templateXml);
writeSettings(settingsPath, templateXml);
core.saveState('maven-settings', 'ok');
}
function cleanup() {
const mavenSettingsState = core.getState('maven-settings');
core.info('Cleanup maven setings: ' + settingsPath + " state: " + mavenSettingsState);
}
module.exports = {
getSettingsTemplate,
writeSettings,
fillServers,
fillProperties,
addSonatypeSnapshots
addSonatypeSnapshots,
generate,
cleanup
}