diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cce2467e..dcf38551 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,6 +14,6 @@ jobs: with: servers: '[{"id": "serverId", "username": "username", "password": "password"}]' properties: '[{"prop1": "value1"}, {"prop2": "value2"}]' - sonatype-snapshots: true + sonatypeSnapshots: true - run: cat ~/.m2/settings.xml diff --git a/README.md b/README.md index 2bbf02d0..f2727d1e 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Create ```settings.xml``` with https://oss.sonatype.org/content/repositories/sna steps: - uses: s4u/maven-settings-action@v1 with: - sonatype-snapshots: true + sonatypeSnapshots: true ``` # License diff --git a/action.yml b/action.yml index 8787f0b3..05f31a78 100644 --- a/action.yml +++ b/action.yml @@ -8,7 +8,7 @@ inputs: properties: description: 'json array with properties, eg [{"propertyName1": "propertyValue1"}, {"propertyName2": "propertyValue2"}]' required: false - sonatype-snapshots: + sonatypeSnapshots: description: 'add https://oss.sonatype.org/content/repositories/snapshots to repository list - true or false' default: "false" required: false diff --git a/index.test.js b/index.test.js index 280a506e..e6076432 100644 --- a/index.test.js +++ b/index.test.js @@ -40,3 +40,15 @@ test('run with default values', () => { 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_PROPERTIES'] = '[{"prop1": "value1"}, {"prop2": "value2"}]' + process.env['INPUT_SONATYPESNAPSHOT'] = true; + + console.log(cp.execSync(`node ${indexPath}`, { env: process.env }).toString()); + const settingsStatus = fs.lstatSync(settingsPath); + expect(settingsStatus.isFile()).toBeTruthy(); + expect(settingsStatus.size).toBeGreaterThan(0); +}) diff --git a/settings.js b/settings.js index fb3b683b..0c3f3d45 100644 --- a/settings.js +++ b/settings.js @@ -66,6 +66,7 @@ function fillProperties(template) { .select(`/settings/profiles/profile[id[contains(text(),"_properties_")]]/properties`, template)[0]; JSON.parse(properties).forEach((property) => { + for (const key in property) { const keyXml = template.createElement(key); keyXml.textContent = property[key]; @@ -75,7 +76,7 @@ function fillProperties(template) { } function addSonatypeSnapshots(template) { - const val = core.getInput('sonatype-snapshots'); + const val = core.getInput('sonatypeSnapshots'); if (val && val.toLocaleLowerCase() == 'true') { activateProfile(template, '_sonatype-snapshots_') } diff --git a/settings.test.js b/settings.test.js index 6f4d57ec..6dde1b5d 100644 --- a/settings.test.js +++ b/settings.test.js @@ -82,7 +82,7 @@ test('fillServers two servers', () => { test('addSonatypeSnapshots activate', () => { - process.env['INPUT_SONATYPE-SNAPSHOTS'] = "true"; + process.env['INPUT_SONATYPESNAPSHOTS'] = "true"; settings.addSonatypeSnapshots(xmlTestProfile); diff --git a/templates/settings.xml b/templates/settings.xml index dab5a9f8..0ac93007 100644 --- a/templates/settings.xml +++ b/templates/settings.xml @@ -1,4 +1,4 @@ - + false