mirror of
https://github.com/s4u/maven-settings-action.git
synced 2026-02-12 00:05:49 +08:00
Merge remote-tracking branch 'origin/master' into releases/v1
This commit is contained in:
10
README.md
10
README.md
@ -4,6 +4,7 @@
|
||||
This action setup maven environment for use in action by:
|
||||
- create maven settings.xml
|
||||
- set ```interactiveMode``` to false - useful in CI system
|
||||
- after job finish generated settings.xml will be removed to prevent cache or left sensitive data on build system
|
||||
|
||||
# Usage
|
||||
See [action.yml](action.yml)
|
||||
@ -38,6 +39,15 @@ steps:
|
||||
sonatypeSnapshots: true
|
||||
```
|
||||
|
||||
Override existing existing ```settings.xml```:
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v1
|
||||
with:
|
||||
override: true
|
||||
```
|
||||
|
||||
|
||||
# License
|
||||
|
||||
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
||||
|
||||
@ -16,8 +16,13 @@ inputs:
|
||||
description: 'add https://oss.sonatype.org/content/repositories/snapshots to repository list - true or false'
|
||||
default: "false"
|
||||
required: false
|
||||
override:
|
||||
description: 'override existing settings.xml file'
|
||||
default: "false"
|
||||
required: false
|
||||
|
||||
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'index.js'
|
||||
post: 'cleanup.js'
|
||||
|
||||
36
cleanup.js
Normal file
36
cleanup.js
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2020 Slawomir Jaranowski and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
const core = require('@actions/core');
|
||||
const settings = require('./settings');
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
settings.cleanup();
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
60
cleanup.test.js
Normal file
60
cleanup.test.js
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2020 Slawomir Jaranowski and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
const cp = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const process = require('process');
|
||||
|
||||
const cleanupPath = path.join(__dirname, 'cleanup.js');
|
||||
|
||||
const testHomePath = fs.mkdtempSync(".m2");
|
||||
const settingsPath = path.join(testHomePath, '.m2', 'settings.xml');
|
||||
|
||||
beforeAll(() => {
|
||||
if (!fs.existsSync(testHomePath)) {
|
||||
fs.mkdirSync(testHomePath);
|
||||
}
|
||||
|
||||
process.env['HOME'] = testHomePath;
|
||||
process.env['USERPROFILE'] = testHomePath;
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
||||
try {
|
||||
fs.rmdirSync(path.dirname(settingsPath));
|
||||
} catch (error) {
|
||||
}
|
||||
|
||||
try {
|
||||
fs.rmdirSync(testHomePath);
|
||||
} catch (error) {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
test('run with default values', () => {
|
||||
cp.execSync(`node ${cleanupPath}`, { env: process.env }).toString();
|
||||
})
|
||||
48
index.js
48
index.js
@ -1,35 +1,37 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2020 Slawomir Jaranowski and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
const core = require('@actions/core');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const settings = require('./settings');
|
||||
|
||||
|
||||
// most @actions toolkit packages have async methods
|
||||
async function run() {
|
||||
|
||||
try {
|
||||
const settingsPath = path.join(os.homedir(), '.m2', 'settings.xml');
|
||||
|
||||
core.info('Prepare maven setings: ' + settingsPath);
|
||||
|
||||
if (fs.existsSync(settingsPath)) {
|
||||
core.warning('maven settings.xml already exists - skip');
|
||||
return;
|
||||
}
|
||||
|
||||
const templateXml = settings.getSettingsTemplate();
|
||||
settings.fillServers(templateXml);
|
||||
settings.fillProperties(templateXml);
|
||||
settings.addSonatypeSnapshots(templateXml);
|
||||
settings.writeSettings(settingsPath, templateXml);
|
||||
|
||||
settings.generate();
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
|
||||
module.exports = { run };
|
||||
|
||||
@ -1,3 +1,27 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2020 Slawomir Jaranowski and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
const process = require('process');
|
||||
const cp = require('child_process');
|
||||
const path = require('path');
|
||||
@ -24,30 +48,33 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
||||
try {
|
||||
fs.rmdirSync(path.dirname(settingsPath));
|
||||
} catch (error) {
|
||||
}
|
||||
|
||||
try {
|
||||
fs.rmdirSync(testHomePath);
|
||||
} catch (error) {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
test('run with default values', () => {
|
||||
|
||||
console.log(cp.execSync(`node ${indexPath}`, { env: process.env }).toString());
|
||||
const settingsStatus = fs.lstatSync(settingsPath);
|
||||
expect(settingsStatus.isFile()).toBeTruthy();
|
||||
expect(settingsStatus.size).toBeGreaterThan(0);
|
||||
})
|
||||
|
||||
test('run with all feature', () => {
|
||||
|
||||
process.env['INPUT_SERVERES'] = '[{"id": "serverId", "username": "username", "password": "password"}]';
|
||||
process.env['INPUT_SERVERS'] = '[{"id": "serverId", "username": "username", "password": "password"}]';
|
||||
process.env['INPUT_PROPERTIES'] = '[{"prop1": "value1"}, {"prop2": "value2"}]'
|
||||
process.env['INPUT_SONATYPESNAPSHOT'] = true;
|
||||
|
||||
console.log(cp.execSync(`node ${indexPath}`, { env: process.env }).toString());
|
||||
cp.execSync(`node ${indexPath}`, { env: process.env }).toString();
|
||||
|
||||
const settingsStatus = fs.lstatSync(settingsPath);
|
||||
expect(settingsStatus.isFile()).toBeTruthy();
|
||||
expect(settingsStatus.size).toBeGreaterThan(0);
|
||||
|
||||
const settingsBody = fs.readFileSync(settingsPath).toString();
|
||||
expect(settingsBody).toMatch('<settings>');
|
||||
expect(settingsBody).toMatch('<servers><server><id>serverId</id><username>username</username><password>password</password></server></servers>');
|
||||
expect(settingsBody).toMatch('prop1');
|
||||
})
|
||||
|
||||
4469
package-lock.json
generated
4469
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -24,12 +24,12 @@
|
||||
},
|
||||
"homepage": "https://github.com/s4u/maven-settings-action#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.0",
|
||||
"xmldom": "^0.1.27",
|
||||
"@actions/core": "^1.2.2",
|
||||
"xmldom": "^0.2.1",
|
||||
"xpath": "0.0.27"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^6.7.1",
|
||||
"jest": "^24.9.0"
|
||||
"eslint": "^6.8.0",
|
||||
"jest": "^25.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
74
settings.js
74
settings.js
@ -1,10 +1,40 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2020 Slawomir Jaranowski and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
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');
|
||||
|
||||
|
||||
function getSettingsPath() {
|
||||
return 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 +112,52 @@ function addSonatypeSnapshots(template) {
|
||||
}
|
||||
}
|
||||
|
||||
function generate() {
|
||||
|
||||
const settingsPath = getSettingsPath();
|
||||
|
||||
core.info('Prepare maven setings: ' + settingsPath);
|
||||
|
||||
if (fs.existsSync(settingsPath)) {
|
||||
const val = core.getInput("override");
|
||||
if (val && val.toLocaleLowerCase() == 'true') {
|
||||
core.info('maven settings.xml already exists - override');
|
||||
} else {
|
||||
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');
|
||||
const settingsPath = getSettingsPath();
|
||||
if (mavenSettingsState == 'ok') {
|
||||
if (fs.existsSync(settingsPath)) {
|
||||
fs.unlinkSync(settingsPath);
|
||||
core.info('Cleanup maven setings: ' + settingsPath + ' - file was removed');
|
||||
} else {
|
||||
core.warning('Cleanup maven setings: ' + settingsPath + ' - file not exist');
|
||||
}
|
||||
} else {
|
||||
core.info('Cleanup maven setings: ' + settingsPath + ' - file wasn\'t generated by action');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getSettingsTemplate,
|
||||
writeSettings,
|
||||
fillServers,
|
||||
fillProperties,
|
||||
addSonatypeSnapshots
|
||||
addSonatypeSnapshots,
|
||||
generate,
|
||||
cleanup
|
||||
}
|
||||
|
||||
145
settings.test.js
145
settings.test.js
@ -1,4 +1,29 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2020 Slawomir Jaranowski and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
const os = require('os');
|
||||
const process = require('process');
|
||||
const DOMParser = require('xmldom').DOMParser;
|
||||
const XMLSerializer = require('xmldom').XMLSerializer;
|
||||
const fs = require('fs');
|
||||
@ -11,6 +36,20 @@ var xmlTestProfile = undefined;
|
||||
const testHomePath = fs.mkdtempSync(".m2");
|
||||
const settingsPath = path.join(testHomePath, '.m2', 'settings.xml');
|
||||
|
||||
var consoleOutput = [];
|
||||
|
||||
beforeAll(() => {
|
||||
if (!fs.existsSync(testHomePath)) {
|
||||
fs.mkdirSync(testHomePath);
|
||||
}
|
||||
|
||||
process.env['HOME'] = testHomePath;
|
||||
process.env['USERPROFILE'] = testHomePath;
|
||||
os.homedir = () => testHomePath;
|
||||
|
||||
process.stdout.write = output => consoleOutput.push(output);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
xmlTestProfile = new DOMParser().parseFromString(`<settings>
|
||||
<profiles>
|
||||
@ -30,6 +69,19 @@ beforeEach(() => {
|
||||
</profiles>
|
||||
</settings>`);
|
||||
|
||||
consoleOutput = [];
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
try {
|
||||
fs.rmdirSync(path.dirname(settingsPath));
|
||||
} catch (error) {
|
||||
}
|
||||
|
||||
try {
|
||||
fs.rmdirSync(testHomePath);
|
||||
} catch (error) {
|
||||
}
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@ -46,14 +98,6 @@ afterEach(() => {
|
||||
}
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
try {
|
||||
fs.rmdirSync(path.dirname(settingsPath));
|
||||
fs.rmdirSync(testHomePath);
|
||||
} catch (error) {
|
||||
}
|
||||
});
|
||||
|
||||
test('template should be read', () => {
|
||||
|
||||
const template = settings.getSettingsTemplate();
|
||||
@ -193,3 +237,88 @@ test('fillProperties do nothing if no params', () => {
|
||||
</profiles>
|
||||
</settings>`);
|
||||
})
|
||||
|
||||
test('cleanup - not generated', () => {
|
||||
|
||||
settings.cleanup();
|
||||
|
||||
expect(consoleOutput).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.stringMatching(/Cleanup maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml - file wasn\'t generated by action/)
|
||||
])
|
||||
);
|
||||
})
|
||||
|
||||
test('cleanup - not exist', () => {
|
||||
|
||||
process.env['STATE_maven-settings'] = 'ok';
|
||||
|
||||
settings.cleanup();
|
||||
|
||||
expect(consoleOutput).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.stringMatching(/::warning::Cleanup maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml - file not exist/)
|
||||
])
|
||||
);
|
||||
})
|
||||
|
||||
test('cleanup - ok', () => {
|
||||
|
||||
process.env['STATE_maven-settings'] = 'ok';
|
||||
fs.closeSync(fs.openSync(settingsPath, 'w'));
|
||||
|
||||
settings.cleanup();
|
||||
|
||||
expect(consoleOutput).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.stringMatching(/Cleanup maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml - file was removed/)
|
||||
])
|
||||
);
|
||||
expect(fs.existsSync(settingsPath)).not.toBeTruthy();
|
||||
})
|
||||
|
||||
test('genereate', () => {
|
||||
|
||||
process.env['INPUT_SERVERS'] = '[{"id": "serverId", "username": "username", "password": "password"}]';
|
||||
process.env['INPUT_PROPERTIES'] = '[{"prop1": "value1"}, {"prop2": "value2"}]'
|
||||
process.env['INPUT_SONATYPESNAPSHOT'] = true;
|
||||
|
||||
settings.generate();
|
||||
|
||||
expect(consoleOutput).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.stringMatching(/Prepare maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml/),
|
||||
expect.stringMatching(/:save-state name=maven-settings::ok/)
|
||||
])
|
||||
);
|
||||
})
|
||||
|
||||
test('genereate - skip', () => {
|
||||
|
||||
fs.closeSync(fs.openSync(settingsPath, 'w'));
|
||||
|
||||
settings.generate();
|
||||
|
||||
expect(consoleOutput).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.stringMatching(/Prepare maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml/),
|
||||
expect.stringMatching(/::warning::maven settings.xml already exists - skip/)
|
||||
])
|
||||
);
|
||||
})
|
||||
|
||||
test('genereate - override', () => {
|
||||
|
||||
fs.closeSync(fs.openSync(settingsPath, 'w'));
|
||||
process.env['INPUT_OVERRIDE'] = 'true';
|
||||
|
||||
settings.generate();
|
||||
|
||||
expect(consoleOutput).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.stringMatching(/Prepare maven setings: \..+[\/\\]{1,2}\.m2[\/\\]{1,2}settings.xml/),
|
||||
expect.stringMatching(/maven settings.xml already exists - override/),
|
||||
expect.stringMatching(/:save-state name=maven-settings::ok/)
|
||||
])
|
||||
);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user