mirror of
https://github.com/s4u/maven-settings-action.git
synced 2026-02-13 00:05:25 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6091258250 | |||
| 2bd0acf716 | |||
| e204770e52 | |||
| e4252b9282 | |||
| d80c14480e | |||
| a4fae4024d | |||
| 52fa27d07a | |||
| 4a3e3d7344 | |||
| 268ea183e3 | |||
| c29ea0c1c0 |
2
.github/workflows/release-drafter.yml
vendored
2
.github/workflows/release-drafter.yml
vendored
@ -17,6 +17,6 @@ jobs:
|
||||
&& !startsWith(github.event.head_commit.message , '[maven-release-plugin]')
|
||||
|
||||
steps:
|
||||
- uses: release-drafter/release-drafter@v5.21.0
|
||||
- uses: release-drafter/release-drafter@v5.21.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
34
README.md
34
README.md
@ -31,14 +31,14 @@ See [action.yml](action.yml)
|
||||
## default ```settings.xml```
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.7.0
|
||||
- uses: s4u/maven-settings-action@v2.8.0
|
||||
```
|
||||
|
||||
## ```settings.xml``` with servers section
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.7.0
|
||||
- uses: s4u/maven-settings-action@v2.8.0
|
||||
with:
|
||||
servers: '[{"id": "serverId", "username": "username", "password": "password"}]'
|
||||
```
|
||||
@ -62,7 +62,7 @@ Please refer to the [servers](http://maven.apache.org/settings.html#Servers) doc
|
||||
|
||||
``` yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.7.0
|
||||
- uses: s4u/maven-settings-action@v2.8.0
|
||||
with:
|
||||
servers: |
|
||||
[{
|
||||
@ -96,15 +96,23 @@ result will be:
|
||||
## ```settings.xml``` with mirrors section
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.7.0
|
||||
- uses: s4u/maven-settings-action@v2.8.0
|
||||
with:
|
||||
mirrors: '[{"id": "mirrorId", "name": "mirrorName", "mirrorOf": "mirrorOf", "url": "mirrorUrl"}]'
|
||||
```
|
||||
|
||||
## ```settings.xml``` with proxies section
|
||||
```yml
|
||||
step:
|
||||
- uses: s4u/maven-settings-action@v2.8.0
|
||||
with:
|
||||
proxies: '[{"id": "proxyId", "active": "isActive", "protocol": "proxyProtocol", "host": "proxyHost", "port": "proxyPort", "nonProxyHosts": "nonProxyHost"}]'
|
||||
```
|
||||
|
||||
## ```settings.xml``` with properties
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.7.0
|
||||
- uses: s4u/maven-settings-action@v2.8.0
|
||||
with:
|
||||
properties: '[{"propertyName1": "propertyValue1"}, {"propertyName2": "propertyValue2"}]'
|
||||
```
|
||||
@ -113,7 +121,7 @@ steps:
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.7.0
|
||||
- uses: s4u/maven-settings-action@v2.8.0
|
||||
with:
|
||||
sonatypeSnapshots: true
|
||||
```
|
||||
@ -122,7 +130,7 @@ steps:
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.7.0
|
||||
- uses: s4u/maven-settings-action@v2.8.0
|
||||
with:
|
||||
apacheSnapshots: true
|
||||
```
|
||||
@ -130,7 +138,7 @@ steps:
|
||||
## Do not override existing ```settings.xml```, from version **2.0** file is override by default :
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.7.0
|
||||
- uses: s4u/maven-settings-action@v2.8.0
|
||||
with:
|
||||
override: false
|
||||
```
|
||||
@ -138,7 +146,7 @@ steps:
|
||||
## Do not add github to server in ```settings.xml```, by default is added:
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.7.0
|
||||
- uses: s4u/maven-settings-action@v2.8.0
|
||||
with:
|
||||
githubServer: false
|
||||
```
|
||||
@ -147,7 +155,7 @@ steps:
|
||||
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.7.0
|
||||
- uses: s4u/maven-settings-action@v2.8.0
|
||||
with:
|
||||
oracleServers: '[{"id": "serverId", "username": "username", "password": "password"}]'
|
||||
```
|
||||
@ -155,7 +163,7 @@ steps:
|
||||
## ```settings.xml``` with [Oracle Maven Repository](https://docs.oracle.com/middleware/1213/core/MAVEN/config_maven_repo.htm#MAVEN9017)
|
||||
```yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.7.0
|
||||
- uses: s4u/maven-settings-action@v2.8.0
|
||||
with:
|
||||
oracleRepo: true
|
||||
```
|
||||
@ -166,7 +174,7 @@ It is also possible pass in Github Secrets e.g.
|
||||
|
||||
``` yml
|
||||
steps:
|
||||
- uses: s4u/maven-settings-action@v2.7.0
|
||||
- uses: s4u/maven-settings-action@v2.8.0
|
||||
with:
|
||||
servers: |
|
||||
[{
|
||||
@ -196,7 +204,7 @@ steps:
|
||||
with:
|
||||
java-version: 8
|
||||
|
||||
- uses: s4u/maven-settings-action@v2.7.0
|
||||
- uses: s4u/maven-settings-action@v2.8.0
|
||||
|
||||
- run: mvn verify
|
||||
```
|
||||
|
||||
@ -15,6 +15,8 @@ inputs:
|
||||
mirrors:
|
||||
description: 'mirrors definition in json array, eg: [{"id": "id", "name": "name", "mirrorOf": "mirrorOf", "url": "url"}]'
|
||||
required: false
|
||||
proxies:
|
||||
description: 'proxies definition in json array, eg: [{"id": "id", "active": "active", "protocol": "protocol", "host": "hostl", "port": "port", "nonProxyHosts", "nonProxyHosts"}]'
|
||||
properties:
|
||||
description: 'json array with properties, eg [{"propertyName1": "propertyValue1"}, {"propertyName2": "propertyValue2"}]'
|
||||
required: false
|
||||
|
||||
@ -68,6 +68,7 @@ test('run with all feature', () => {
|
||||
process.env['INPUT_GITHUBSERVER'] = true;
|
||||
|
||||
process.env['INPUT_MIRRORS'] = '[{"id": "mirrorId", "name": "mirror Name", "mirrorOf": "mirror Off *", "url": "mirror url"}]';
|
||||
process.env['INPUT_PROXIES'] = '[{"id": "proxyId", "active": "isActive", "protocol": "proxyProtocol", "host": "proxyHost", "port": "proxyPort", "nonProxyHosts": "nonProxyHost"}]';
|
||||
process.env['INPUT_PROPERTIES'] = '[{"prop1": "value1"}, {"prop2": "value2"}]'
|
||||
|
||||
process.env['INPUT_APACHESNAPSHOTS'] = true;
|
||||
@ -75,7 +76,6 @@ test('run with all feature', () => {
|
||||
process.env['INPUT_ORACLEREPO'] = true;
|
||||
|
||||
cp.spawnSync('node', [ `${indexPath}` ], { env: process.env, stdio: 'inherit' });
|
||||
|
||||
const settingsStatus = fs.lstatSync(settingsPath);
|
||||
expect(settingsStatus.isFile()).toBeTruthy();
|
||||
expect(settingsStatus.size).toBeGreaterThan(0);
|
||||
@ -242,5 +242,13 @@ test('run with all feature', () => {
|
||||
<mirrorOf>mirror Off *</mirrorOf>
|
||||
<url>mirror url</url>
|
||||
</mirror></mirrors>
|
||||
<proxies><proxy>
|
||||
<id>proxyId</id>
|
||||
<active>isActive</active>
|
||||
<protocol>proxyProtocol</protocol>
|
||||
<host>proxyHost</host>
|
||||
<port>proxyPort</port>
|
||||
<nonProxyHosts>nonProxyHost</nonProxyHosts>
|
||||
</proxy></proxies>
|
||||
</settings>`);
|
||||
})
|
||||
|
||||
8
node_modules/.package-lock.json
generated
vendored
8
node_modules/.package-lock.json
generated
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "maven-settings-action",
|
||||
"version": "2.7.0",
|
||||
"version": "2.8.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
@ -22,9 +22,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@xmldom/xmldom": {
|
||||
"version": "0.8.3",
|
||||
"resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.3.tgz",
|
||||
"integrity": "sha512-Lv2vySXypg4nfa51LY1nU8yDAGo/5YwF+EY/rUZgIbfvwVARcd67ttCM8SMsTeJy51YhHYavEq+FS6R0hW9PFQ==",
|
||||
"version": "0.8.6",
|
||||
"resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.6.tgz",
|
||||
"integrity": "sha512-uRjjusqpoqfmRkTaNuLJ2VohVr67Q5YwDATW3VU7PfzTj6IRaihGrYI7zckGZjxQPBIp63nfvJbM+Yu5ICh0Bg==",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
|
||||
31
node_modules/@xmldom/xmldom/CHANGELOG.md
generated
vendored
31
node_modules/@xmldom/xmldom/CHANGELOG.md
generated
vendored
@ -4,6 +4,37 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.8.6](https://github.com/xmldom/xmldom/compare/0.8.5...0.8.6)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Properly check nodes before replacement [`#457`](https://github.com/xmldom/xmldom/pull/457) / [`#455`](https://github.com/xmldom/xmldom/issues/455) / [`#456`](https://github.com/xmldom/xmldom/issues/456)
|
||||
|
||||
Thank you, [@edemaine](https://github.com/edemaine), [@pedro-l9](https://github.com/pedro-l9), for your contributions
|
||||
|
||||
|
||||
## [0.8.5](https://github.com/xmldom/xmldom/compare/0.8.4...0.8.5)
|
||||
|
||||
### Fixed
|
||||
|
||||
- fix: Restore ES5 compatibility [`#452`](https://github.com/xmldom/xmldom/pull/452) / [`#453`](https://github.com/xmldom/xmldom/issues/453)
|
||||
|
||||
Thank you, [@fengxinming](https://github.com/fengxinming), for your contributions
|
||||
|
||||
|
||||
## [0.8.4](https://github.com/xmldom/xmldom/compare/0.8.3...0.8.4)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Security: Prevent inserting DOM nodes when they are not well-formed [`CVE-2022-39353`](https://github.com/xmldom/xmldom/security/advisories/GHSA-crh6-fp67-6883)
|
||||
In case such a DOM would be created, the part that is not well-formed will be transformed into text nodes, in which xml specific characters like `<` and `>` are encoded accordingly.
|
||||
In the upcoming version 0.9.0 those text nodes will no longer be added and an error will be thrown instead.
|
||||
This change can break your code, if you relied on this behavior, e.g. multiple root elements in the past. We consider it more important to align with the specs that we want to be aligned with, considering the potential security issues that might derive from people not being aware of the difference in behavior.
|
||||
Related Spec: <https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity>
|
||||
|
||||
Thank you, [@frumioj](https://github.com/frumioj), [@cjbarth](https://github.com/cjbarth), [@markgollnick](https://github.com/markgollnick) for your contributions
|
||||
|
||||
|
||||
## [0.8.3](https://github.com/xmldom/xmldom/compare/0.8.3...0.8.2)
|
||||
|
||||
### Fixed
|
||||
|
||||
33
node_modules/@xmldom/xmldom/lib/conventions.js
generated
vendored
33
node_modules/@xmldom/xmldom/lib/conventions.js
generated
vendored
@ -1,5 +1,37 @@
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Ponyfill for `Array.prototype.find` which is only available in ES6 runtimes.
|
||||
*
|
||||
* Works with anything that has a `length` property and index access properties, including NodeList.
|
||||
*
|
||||
* @template {unknown} T
|
||||
* @param {Array<T> | ({length:number, [number]: T})} list
|
||||
* @param {function (item: T, index: number, list:Array<T> | ({length:number, [number]: T})):boolean} predicate
|
||||
* @param {Partial<Pick<ArrayConstructor['prototype'], 'find'>>?} ac `Array.prototype` by default,
|
||||
* allows injecting a custom implementation in tests
|
||||
* @returns {T | undefined}
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
|
||||
* @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.find
|
||||
*/
|
||||
function find(list, predicate, ac) {
|
||||
if (ac === undefined) {
|
||||
ac = Array.prototype;
|
||||
}
|
||||
if (list && typeof ac.find === 'function') {
|
||||
return ac.find.call(list, predicate);
|
||||
}
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (Object.prototype.hasOwnProperty.call(list, i)) {
|
||||
var item = list[i];
|
||||
if (predicate.call(undefined, item, i, list)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* "Shallow freezes" an object to render it immutable.
|
||||
* Uses `Object.freeze` if available,
|
||||
@ -165,6 +197,7 @@ var NAMESPACE = freeze({
|
||||
})
|
||||
|
||||
exports.assign = assign;
|
||||
exports.find = find;
|
||||
exports.freeze = freeze;
|
||||
exports.MIME_TYPE = MIME_TYPE;
|
||||
exports.NAMESPACE = NAMESPACE;
|
||||
|
||||
400
node_modules/@xmldom/xmldom/lib/dom.js
generated
vendored
400
node_modules/@xmldom/xmldom/lib/dom.js
generated
vendored
@ -1,5 +1,6 @@
|
||||
var conventions = require("./conventions");
|
||||
|
||||
var find = conventions.find;
|
||||
var NAMESPACE = conventions.NAMESPACE;
|
||||
|
||||
/**
|
||||
@ -158,14 +159,14 @@ NodeList.prototype = {
|
||||
* The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
|
||||
* @standard level1
|
||||
*/
|
||||
length:0,
|
||||
length:0,
|
||||
/**
|
||||
* Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
|
||||
* @standard level1
|
||||
* @param index unsigned long
|
||||
* @param index unsigned long
|
||||
* Index into the collection.
|
||||
* @return Node
|
||||
* The node at the indexth position in the NodeList, or null if that is not a valid index.
|
||||
* The node at the indexth position in the NodeList, or null if that is not a valid index.
|
||||
*/
|
||||
item: function(index) {
|
||||
return this[index] || null;
|
||||
@ -175,7 +176,23 @@ NodeList.prototype = {
|
||||
serializeToString(this[i],buf,isHTML,nodeFilter);
|
||||
}
|
||||
return buf.join('');
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @param {function (Node):boolean} predicate
|
||||
* @returns {Node[]}
|
||||
*/
|
||||
filter: function (predicate) {
|
||||
return Array.prototype.filter.call(this, predicate);
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} item
|
||||
* @returns {number}
|
||||
*/
|
||||
indexOf: function (item) {
|
||||
return Array.prototype.indexOf.call(this, item);
|
||||
},
|
||||
};
|
||||
|
||||
function LiveNodeList(node,refresh){
|
||||
@ -209,7 +226,7 @@ _extends(LiveNodeList,NodeList);
|
||||
* but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,
|
||||
* and does not imply that the DOM specifies an order to these Nodes.
|
||||
* NamedNodeMap objects in the DOM are live.
|
||||
* used for attributes or DocumentType entities
|
||||
* used for attributes or DocumentType entities
|
||||
*/
|
||||
function NamedNodeMap() {
|
||||
};
|
||||
@ -253,7 +270,7 @@ function _removeNamedNode(el,list,attr){
|
||||
}
|
||||
}
|
||||
}else{
|
||||
throw DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr))
|
||||
throw new DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr))
|
||||
}
|
||||
}
|
||||
NamedNodeMap.prototype = {
|
||||
@ -298,10 +315,10 @@ NamedNodeMap.prototype = {
|
||||
var attr = this.getNamedItem(key);
|
||||
_removeNamedNode(this._ownerElement,this,attr);
|
||||
return attr;
|
||||
|
||||
|
||||
|
||||
|
||||
},// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
|
||||
|
||||
|
||||
//for level2
|
||||
removeNamedItemNS:function(namespaceURI,localName){
|
||||
var attr = this.getNamedItemNS(namespaceURI,localName);
|
||||
@ -447,11 +464,11 @@ Node.prototype = {
|
||||
prefix : null,
|
||||
localName : null,
|
||||
// Modified in DOM Level 2:
|
||||
insertBefore:function(newChild, refChild){//raises
|
||||
insertBefore:function(newChild, refChild){//raises
|
||||
return _insertBefore(this,newChild,refChild);
|
||||
},
|
||||
replaceChild:function(newChild, oldChild){//raises
|
||||
this.insertBefore(newChild,oldChild);
|
||||
replaceChild:function(newChild, oldChild){//raises
|
||||
_insertBefore(this, newChild,oldChild, assertPreReplacementValidityInDocument);
|
||||
if(oldChild){
|
||||
this.removeChild(oldChild);
|
||||
}
|
||||
@ -573,6 +590,7 @@ function _visitNode(node,callback){
|
||||
|
||||
|
||||
function Document(){
|
||||
this.ownerDocument = this;
|
||||
}
|
||||
|
||||
function _onAddAttribute(doc,el,newAttr){
|
||||
@ -656,48 +674,313 @@ function _removeChild (parentNode, child) {
|
||||
_onUpdateChild(parentNode.ownerDocument, parentNode);
|
||||
return child;
|
||||
}
|
||||
|
||||
/**
|
||||
* preformance key(refChild == null)
|
||||
* Returns `true` if `node` can be a parent for insertion.
|
||||
* @param {Node} node
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function _insertBefore(parentNode,newChild,nextChild){
|
||||
var cp = newChild.parentNode;
|
||||
if(cp){
|
||||
cp.removeChild(newChild);//remove and update
|
||||
function hasValidParentNodeType(node) {
|
||||
return (
|
||||
node &&
|
||||
(node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.ELEMENT_NODE)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if `node` can be inserted according to it's `nodeType`.
|
||||
* @param {Node} node
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function hasInsertableNodeType(node) {
|
||||
return (
|
||||
node &&
|
||||
(isElementNode(node) ||
|
||||
isTextNode(node) ||
|
||||
isDocTypeNode(node) ||
|
||||
node.nodeType === Node.DOCUMENT_FRAGMENT_NODE ||
|
||||
node.nodeType === Node.COMMENT_NODE ||
|
||||
node.nodeType === Node.PROCESSING_INSTRUCTION_NODE)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if `node` is a DOCTYPE node
|
||||
* @param {Node} node
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isDocTypeNode(node) {
|
||||
return node && node.nodeType === Node.DOCUMENT_TYPE_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the node is an element
|
||||
* @param {Node} node
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isElementNode(node) {
|
||||
return node && node.nodeType === Node.ELEMENT_NODE;
|
||||
}
|
||||
/**
|
||||
* Returns true if `node` is a text node
|
||||
* @param {Node} node
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isTextNode(node) {
|
||||
return node && node.nodeType === Node.TEXT_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if en element node can be inserted before `child`, or at the end if child is falsy,
|
||||
* according to the presence and position of a doctype node on the same level.
|
||||
*
|
||||
* @param {Document} doc The document node
|
||||
* @param {Node} child the node that would become the nextSibling if the element would be inserted
|
||||
* @returns {boolean} `true` if an element can be inserted before child
|
||||
* @private
|
||||
* https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
|
||||
*/
|
||||
function isElementInsertionPossible(doc, child) {
|
||||
var parentChildNodes = doc.childNodes || [];
|
||||
if (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {
|
||||
return false;
|
||||
}
|
||||
if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
|
||||
var newFirst = newChild.firstChild;
|
||||
if (newFirst == null) {
|
||||
return newChild;
|
||||
var docTypeNode = find(parentChildNodes, isDocTypeNode);
|
||||
return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if en element node can be inserted before `child`, or at the end if child is falsy,
|
||||
* according to the presence and position of a doctype node on the same level.
|
||||
*
|
||||
* @param {Node} doc The document node
|
||||
* @param {Node} child the node that would become the nextSibling if the element would be inserted
|
||||
* @returns {boolean} `true` if an element can be inserted before child
|
||||
* @private
|
||||
* https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
|
||||
*/
|
||||
function isElementReplacementPossible(doc, child) {
|
||||
var parentChildNodes = doc.childNodes || [];
|
||||
|
||||
function hasElementChildThatIsNotChild(node) {
|
||||
return isElementNode(node) && node !== child;
|
||||
}
|
||||
|
||||
if (find(parentChildNodes, hasElementChildThatIsNotChild)) {
|
||||
return false;
|
||||
}
|
||||
var docTypeNode = find(parentChildNodes, isDocTypeNode);
|
||||
return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child));
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Steps 1-5 of the checks before inserting and before replacing a child are the same.
|
||||
*
|
||||
* @param {Node} parent the parent node to insert `node` into
|
||||
* @param {Node} node the node to insert
|
||||
* @param {Node=} child the node that should become the `nextSibling` of `node`
|
||||
* @returns {Node}
|
||||
* @throws DOMException for several node combinations that would create a DOM that is not well-formed.
|
||||
* @throws DOMException if `child` is provided but is not a child of `parent`.
|
||||
* @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
|
||||
* @see https://dom.spec.whatwg.org/#concept-node-replace
|
||||
*/
|
||||
function assertPreInsertionValidity1to5(parent, node, child) {
|
||||
// 1. If `parent` is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException.
|
||||
if (!hasValidParentNodeType(parent)) {
|
||||
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Unexpected parent node type ' + parent.nodeType);
|
||||
}
|
||||
// 2. If `node` is a host-including inclusive ancestor of `parent`, then throw a "HierarchyRequestError" DOMException.
|
||||
// not implemented!
|
||||
// 3. If `child` is non-null and its parent is not `parent`, then throw a "NotFoundError" DOMException.
|
||||
if (child && child.parentNode !== parent) {
|
||||
throw new DOMException(NOT_FOUND_ERR, 'child not in parent');
|
||||
}
|
||||
if (
|
||||
// 4. If `node` is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a "HierarchyRequestError" DOMException.
|
||||
!hasInsertableNodeType(node) ||
|
||||
// 5. If either `node` is a Text node and `parent` is a document,
|
||||
// the sax parser currently adds top level text nodes, this will be fixed in 0.9.0
|
||||
// || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE)
|
||||
// or `node` is a doctype and `parent` is not a document, then throw a "HierarchyRequestError" DOMException.
|
||||
(isDocTypeNode(node) && parent.nodeType !== Node.DOCUMENT_NODE)
|
||||
) {
|
||||
throw new DOMException(
|
||||
HIERARCHY_REQUEST_ERR,
|
||||
'Unexpected node type ' + node.nodeType + ' for parent node type ' + parent.nodeType
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Step 6 of the checks before inserting and before replacing a child are different.
|
||||
*
|
||||
* @param {Document} parent the parent node to insert `node` into
|
||||
* @param {Node} node the node to insert
|
||||
* @param {Node | undefined} child the node that should become the `nextSibling` of `node`
|
||||
* @returns {Node}
|
||||
* @throws DOMException for several node combinations that would create a DOM that is not well-formed.
|
||||
* @throws DOMException if `child` is provided but is not a child of `parent`.
|
||||
* @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
|
||||
* @see https://dom.spec.whatwg.org/#concept-node-replace
|
||||
*/
|
||||
function assertPreInsertionValidityInDocument(parent, node, child) {
|
||||
var parentChildNodes = parent.childNodes || [];
|
||||
var nodeChildNodes = node.childNodes || [];
|
||||
|
||||
// DocumentFragment
|
||||
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
||||
var nodeChildElements = nodeChildNodes.filter(isElementNode);
|
||||
// If node has more than one element child or has a Text node child.
|
||||
if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
|
||||
throw new DOMException(HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');
|
||||
}
|
||||
// Otherwise, if `node` has one element child and either `parent` has an element child,
|
||||
// `child` is a doctype, or `child` is non-null and a doctype is following `child`.
|
||||
if (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {
|
||||
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');
|
||||
}
|
||||
var newLast = newChild.lastChild;
|
||||
}else{
|
||||
newFirst = newLast = newChild;
|
||||
}
|
||||
var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild;
|
||||
// Element
|
||||
if (isElementNode(node)) {
|
||||
// `parent` has an element child, `child` is a doctype,
|
||||
// or `child` is non-null and a doctype is following `child`.
|
||||
if (!isElementInsertionPossible(parent, child)) {
|
||||
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');
|
||||
}
|
||||
}
|
||||
// DocumentType
|
||||
if (isDocTypeNode(node)) {
|
||||
// `parent` has a doctype child,
|
||||
if (find(parentChildNodes, isDocTypeNode)) {
|
||||
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');
|
||||
}
|
||||
var parentElementChild = find(parentChildNodes, isElementNode);
|
||||
// `child` is non-null and an element is preceding `child`,
|
||||
if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
|
||||
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');
|
||||
}
|
||||
// or `child` is null and `parent` has an element child.
|
||||
if (!child && parentElementChild) {
|
||||
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can not be appended since element is present');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Step 6 of the checks before inserting and before replacing a child are different.
|
||||
*
|
||||
* @param {Document} parent the parent node to insert `node` into
|
||||
* @param {Node} node the node to insert
|
||||
* @param {Node | undefined} child the node that should become the `nextSibling` of `node`
|
||||
* @returns {Node}
|
||||
* @throws DOMException for several node combinations that would create a DOM that is not well-formed.
|
||||
* @throws DOMException if `child` is provided but is not a child of `parent`.
|
||||
* @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
|
||||
* @see https://dom.spec.whatwg.org/#concept-node-replace
|
||||
*/
|
||||
function assertPreReplacementValidityInDocument(parent, node, child) {
|
||||
var parentChildNodes = parent.childNodes || [];
|
||||
var nodeChildNodes = node.childNodes || [];
|
||||
|
||||
// DocumentFragment
|
||||
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
||||
var nodeChildElements = nodeChildNodes.filter(isElementNode);
|
||||
// If `node` has more than one element child or has a Text node child.
|
||||
if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
|
||||
throw new DOMException(HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment');
|
||||
}
|
||||
// Otherwise, if `node` has one element child and either `parent` has an element child that is not `child` or a doctype is following `child`.
|
||||
if (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) {
|
||||
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype');
|
||||
}
|
||||
}
|
||||
// Element
|
||||
if (isElementNode(node)) {
|
||||
// `parent` has an element child that is not `child` or a doctype is following `child`.
|
||||
if (!isElementReplacementPossible(parent, child)) {
|
||||
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype');
|
||||
}
|
||||
}
|
||||
// DocumentType
|
||||
if (isDocTypeNode(node)) {
|
||||
function hasDoctypeChildThatIsNotChild(node) {
|
||||
return isDocTypeNode(node) && node !== child;
|
||||
}
|
||||
|
||||
// `parent` has a doctype child that is not `child`,
|
||||
if (find(parentChildNodes, hasDoctypeChildThatIsNotChild)) {
|
||||
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed');
|
||||
}
|
||||
var parentElementChild = find(parentChildNodes, isElementNode);
|
||||
// or an element is preceding `child`.
|
||||
if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
|
||||
throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {Node} parent the parent node to insert `node` into
|
||||
* @param {Node} node the node to insert
|
||||
* @param {Node=} child the node that should become the `nextSibling` of `node`
|
||||
* @returns {Node}
|
||||
* @throws DOMException for several node combinations that would create a DOM that is not well-formed.
|
||||
* @throws DOMException if `child` is provided but is not a child of `parent`.
|
||||
* @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
|
||||
*/
|
||||
function _insertBefore(parent, node, child, _inDocumentAssertion) {
|
||||
// To ensure pre-insertion validity of a node into a parent before a child, run these steps:
|
||||
assertPreInsertionValidity1to5(parent, node, child);
|
||||
|
||||
// If parent is a document, and any of the statements below, switched on the interface node implements,
|
||||
// are true, then throw a "HierarchyRequestError" DOMException.
|
||||
if (parent.nodeType === Node.DOCUMENT_NODE) {
|
||||
(_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child);
|
||||
}
|
||||
|
||||
var cp = node.parentNode;
|
||||
if(cp){
|
||||
cp.removeChild(node);//remove and update
|
||||
}
|
||||
if(node.nodeType === DOCUMENT_FRAGMENT_NODE){
|
||||
var newFirst = node.firstChild;
|
||||
if (newFirst == null) {
|
||||
return node;
|
||||
}
|
||||
var newLast = node.lastChild;
|
||||
}else{
|
||||
newFirst = newLast = node;
|
||||
}
|
||||
var pre = child ? child.previousSibling : parent.lastChild;
|
||||
|
||||
newFirst.previousSibling = pre;
|
||||
newLast.nextSibling = nextChild;
|
||||
|
||||
|
||||
newLast.nextSibling = child;
|
||||
|
||||
|
||||
if(pre){
|
||||
pre.nextSibling = newFirst;
|
||||
}else{
|
||||
parentNode.firstChild = newFirst;
|
||||
parent.firstChild = newFirst;
|
||||
}
|
||||
if(nextChild == null){
|
||||
parentNode.lastChild = newLast;
|
||||
if(child == null){
|
||||
parent.lastChild = newLast;
|
||||
}else{
|
||||
nextChild.previousSibling = newLast;
|
||||
child.previousSibling = newLast;
|
||||
}
|
||||
do{
|
||||
newFirst.parentNode = parentNode;
|
||||
newFirst.parentNode = parent;
|
||||
}while(newFirst !== newLast && (newFirst= newFirst.nextSibling))
|
||||
_onUpdateChild(parentNode.ownerDocument||parentNode,parentNode);
|
||||
//console.log(parentNode.lastChild.nextSibling == null)
|
||||
if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
|
||||
newChild.firstChild = newChild.lastChild = null;
|
||||
_onUpdateChild(parent.ownerDocument||parent, parent);
|
||||
//console.log(parent.lastChild.nextSibling == null)
|
||||
if (node.nodeType == DOCUMENT_FRAGMENT_NODE) {
|
||||
node.firstChild = node.lastChild = null;
|
||||
}
|
||||
return newChild;
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -752,11 +1035,13 @@ Document.prototype = {
|
||||
}
|
||||
return newChild;
|
||||
}
|
||||
if(this.documentElement == null && newChild.nodeType == ELEMENT_NODE){
|
||||
_insertBefore(this, newChild, refChild);
|
||||
newChild.ownerDocument = this;
|
||||
if (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {
|
||||
this.documentElement = newChild;
|
||||
}
|
||||
|
||||
return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild;
|
||||
return newChild;
|
||||
},
|
||||
removeChild : function(oldChild){
|
||||
if(this.documentElement == oldChild){
|
||||
@ -764,6 +1049,17 @@ Document.prototype = {
|
||||
}
|
||||
return _removeChild(this,oldChild);
|
||||
},
|
||||
replaceChild: function (newChild, oldChild) {
|
||||
//raises
|
||||
_insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument);
|
||||
newChild.ownerDocument = this;
|
||||
if (oldChild) {
|
||||
this.removeChild(oldChild);
|
||||
}
|
||||
if (isElementNode(newChild)) {
|
||||
this.documentElement = newChild;
|
||||
}
|
||||
},
|
||||
// Introduced in DOM Level 2:
|
||||
importNode : function(importedNode,deep){
|
||||
return importNode(this,importedNode,deep);
|
||||
@ -950,7 +1246,7 @@ Element.prototype = {
|
||||
var attr = this.getAttributeNode(name)
|
||||
attr && this.removeAttributeNode(attr);
|
||||
},
|
||||
|
||||
|
||||
//four real opeartion method
|
||||
appendChild:function(newChild){
|
||||
if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
|
||||
@ -974,7 +1270,7 @@ Element.prototype = {
|
||||
var old = this.getAttributeNodeNS(namespaceURI, localName);
|
||||
old && this.removeAttributeNode(old);
|
||||
},
|
||||
|
||||
|
||||
hasAttributeNS : function(namespaceURI, localName){
|
||||
return this.getAttributeNodeNS(namespaceURI, localName)!=null;
|
||||
},
|
||||
@ -990,7 +1286,7 @@ Element.prototype = {
|
||||
getAttributeNodeNS : function(namespaceURI, localName){
|
||||
return this.attributes.getNamedItemNS(namespaceURI, localName);
|
||||
},
|
||||
|
||||
|
||||
getElementsByTagName : function(tagName){
|
||||
return new LiveNodeList(this,function(base){
|
||||
var ls = [];
|
||||
@ -1011,7 +1307,7 @@ Element.prototype = {
|
||||
}
|
||||
});
|
||||
return ls;
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -1040,7 +1336,7 @@ CharacterData.prototype = {
|
||||
},
|
||||
insertData: function(offset,text) {
|
||||
this.replaceData(offset,0,text);
|
||||
|
||||
|
||||
},
|
||||
appendChild:function(newChild){
|
||||
throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])
|
||||
@ -1134,7 +1430,7 @@ function nodeSerializeToString(isHtml,nodeFilter){
|
||||
var refNode = this.nodeType == 9 && this.documentElement || this;
|
||||
var prefix = refNode.prefix;
|
||||
var uri = refNode.namespaceURI;
|
||||
|
||||
|
||||
if(uri && prefix == null){
|
||||
//console.log(prefix)
|
||||
var prefix = refNode.lookupPrefix(uri);
|
||||
@ -1167,8 +1463,8 @@ function needNamespaceDefine(node, isHTML, visibleNamespaces) {
|
||||
if (prefix === "xml" && uri === NAMESPACE.XML || uri === NAMESPACE.XMLNS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var i = visibleNamespaces.length
|
||||
|
||||
var i = visibleNamespaces.length
|
||||
while (i--) {
|
||||
var ns = visibleNamespaces[i];
|
||||
// get namespace prefix
|
||||
@ -1219,7 +1515,7 @@ function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
|
||||
var len = attrs.length;
|
||||
var child = node.firstChild;
|
||||
var nodeName = node.tagName;
|
||||
|
||||
|
||||
isHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML
|
||||
|
||||
var prefixedNodeName = nodeName
|
||||
@ -1278,14 +1574,14 @@ function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
|
||||
serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
|
||||
}
|
||||
|
||||
// add namespace for current node
|
||||
// add namespace for current node
|
||||
if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
|
||||
var prefix = node.prefix||'';
|
||||
var uri = node.namespaceURI;
|
||||
addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri);
|
||||
visibleNamespaces.push({ prefix: prefix, namespace:uri });
|
||||
}
|
||||
|
||||
|
||||
if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
|
||||
buf.push('>');
|
||||
//if is cdata child node
|
||||
@ -1500,7 +1796,7 @@ try{
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
function getTextContent(node){
|
||||
switch(node.nodeType){
|
||||
case ELEMENT_NODE:
|
||||
|
||||
6
node_modules/@xmldom/xmldom/package.json
generated
vendored
6
node_modules/@xmldom/xmldom/package.json
generated
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@xmldom/xmldom",
|
||||
"version": "0.8.3",
|
||||
"version": "0.8.6",
|
||||
"description": "A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.",
|
||||
"keywords": [
|
||||
"w3c",
|
||||
@ -29,13 +29,15 @@
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint lib test",
|
||||
"format": "prettier --write test",
|
||||
"changelog": "auto-changelog --unreleased-only",
|
||||
"start": "nodemon --watch package.json --watch lib --watch test --exec 'npm --silent run test && npm --silent run lint'",
|
||||
"stryker": "stryker run",
|
||||
"stryker:dry-run": "stryker run -m '' --reporters progress",
|
||||
"test": "jest",
|
||||
"testrelease": "npm test && eslint lib",
|
||||
"version": "./changelog-has-version.sh",
|
||||
"release": "np --no-yarn"
|
||||
"release": "np --no-yarn --test-script testrelease --branch release-0.8.x patch"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
|
||||
589
package-lock.json
generated
589
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "maven-settings-action",
|
||||
"version": "2.7.0",
|
||||
"version": "2.8.0",
|
||||
"description": "Prepare maven settings",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@ -27,10 +27,10 @@
|
||||
"homepage": "https://github.com/s4u/maven-settings-action#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"@xmldom/xmldom": "^0.8.3"
|
||||
"@xmldom/xmldom": "^0.8.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^8.25.0",
|
||||
"eslint": "^8.27.0",
|
||||
"jest": "^28.1.3"
|
||||
}
|
||||
}
|
||||
|
||||
31
settings.js
31
settings.js
@ -152,6 +152,35 @@ function fillMirrors(template) {
|
||||
JSON.parse(mirrors).forEach((mirror) => fillMirror(template, mirror.id, mirror.name, mirror.mirrorOf, mirror.url));
|
||||
}
|
||||
|
||||
function fillProxies(template) {
|
||||
|
||||
const proxies = core.getInput('proxies');
|
||||
|
||||
if (!proxies) {
|
||||
return;
|
||||
}
|
||||
|
||||
JSON.parse(proxies).forEach((proxy) => fillProxy(template, proxy.id, proxy.active, proxy.protocol, proxy.host, proxy.port, proxy.nonProxyHosts));
|
||||
}
|
||||
|
||||
function fillProxy(template, id, active, protocol, host, port, nonProxyHosts) {
|
||||
if(!id || !active || !protocol || !host || !port || !nonProxyHosts) {
|
||||
core.setFailed('proxies must contain id, active, protocol, host, port and nonProxyHosts');
|
||||
return;
|
||||
}
|
||||
|
||||
const proxyXml = getTemplate('proxy.xml');
|
||||
proxyXml.getElementsByTagName("id")[0].textContent = id;
|
||||
proxyXml.getElementsByTagName("active")[0].textContent = active;
|
||||
proxyXml.getElementsByTagName("protocol")[0].textContent = protocol;
|
||||
proxyXml.getElementsByTagName("host")[0].textContent = host;
|
||||
proxyXml.getElementsByTagName("port")[0].textContent = port;
|
||||
proxyXml.getElementsByTagName("nonProxyHosts")[0].textContent = nonProxyHosts;
|
||||
|
||||
const proxiesXml = template.getElementsByTagName('proxies')[0];
|
||||
proxiesXml.appendChild(proxyXml);
|
||||
}
|
||||
|
||||
function isInputTrue(inputName) {
|
||||
const val = core.getInput(inputName);
|
||||
return val && val.toLocaleLowerCase() == 'true';
|
||||
@ -230,6 +259,7 @@ function generate() {
|
||||
}
|
||||
|
||||
const settingsXml = getTemplate('settings.xml');
|
||||
fillProxies(settingsXml);
|
||||
fillMirrors(settingsXml);
|
||||
fillServers(settingsXml, 'servers');
|
||||
fillServers(settingsXml, 'oracleServers');
|
||||
@ -263,6 +293,7 @@ module.exports = {
|
||||
writeSettings,
|
||||
fillMirrors,
|
||||
fillServers,
|
||||
fillProxies,
|
||||
fillServerForGithub,
|
||||
fillProperties,
|
||||
addApacheSnapshots,
|
||||
|
||||
@ -436,6 +436,83 @@ test('fillMirrors incorrect fields', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("fillProxies do noting if no params", () => {
|
||||
const xml = stringAsXml("<proxies/>");
|
||||
|
||||
settings.fillProxies(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
expect(xmlStr).toBe("<proxies/>");
|
||||
expect(consoleOutput).toEqual([]);
|
||||
})
|
||||
|
||||
test("fillProxies one proxy", () => {
|
||||
const xml = stringAsXml("<proxies/>");
|
||||
|
||||
process.env['INPUT_PROXIES'] = `[{"id": "proxyId", "active": "isActive", "protocol": "proxyProtocol",
|
||||
"host": "proxyHost", "port": "proxyPort", "nonProxyHosts": "nonProxyHost"}]`;
|
||||
|
||||
settings.fillProxies(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
expect(xmlStr).toBe(`<proxies><proxy>
|
||||
<id>proxyId</id>
|
||||
<active>isActive</active>
|
||||
<protocol>proxyProtocol</protocol>
|
||||
<host>proxyHost</host>
|
||||
<port>proxyPort</port>
|
||||
<nonProxyHosts>nonProxyHost</nonProxyHosts>
|
||||
</proxy></proxies>`)
|
||||
|
||||
})
|
||||
|
||||
test("fillProxies two proxies", () => {
|
||||
const xml = stringAsXml("<proxies/>");
|
||||
|
||||
process.env['INPUT_PROXIES'] = `[{"id": "proxyId1", "active": "isActive1", "protocol": "proxyProtocol1",
|
||||
"host": "proxyHost1", "port": "proxyPort1", "nonProxyHosts": "nonProxyHost1"},
|
||||
{"id": "proxyId2", "active": "isActive2", "protocol": "proxyProtocol2",
|
||||
"host": "proxyHost2", "port": "proxyPort2", "nonProxyHosts": "nonProxyHost2"}]`;
|
||||
|
||||
settings.fillProxies(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
expect(xmlStr).toBe(`<proxies><proxy>
|
||||
<id>proxyId1</id>
|
||||
<active>isActive1</active>
|
||||
<protocol>proxyProtocol1</protocol>
|
||||
<host>proxyHost1</host>
|
||||
<port>proxyPort1</port>
|
||||
<nonProxyHosts>nonProxyHost1</nonProxyHosts>
|
||||
</proxy><proxy>
|
||||
<id>proxyId2</id>
|
||||
<active>isActive2</active>
|
||||
<protocol>proxyProtocol2</protocol>
|
||||
<host>proxyHost2</host>
|
||||
<port>proxyPort2</port>
|
||||
<nonProxyHosts>nonProxyHost2</nonProxyHosts>
|
||||
</proxy></proxies>`)
|
||||
|
||||
})
|
||||
|
||||
test('fillProxies incorrect fields', () => {
|
||||
|
||||
const xml = stringAsXml("<proxies/>");
|
||||
|
||||
process.env['INPUT_PROXIES'] = '[{"idx": "id1"}]';
|
||||
|
||||
settings.fillProxies(xml);
|
||||
|
||||
const xmlStr = new XMLSerializer().serializeToString(xml);
|
||||
|
||||
expect(xmlStr).toBe('<proxies/>');
|
||||
expect(consoleOutput).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.stringMatching(/::error::proxies must contain id, active, protocol, host, port and nonProxyHosts/)
|
||||
])
|
||||
);
|
||||
})
|
||||
|
||||
test('addApacheSnapshots', () => {
|
||||
|
||||
process.env['INPUT_APACHESNAPSHOTS'] = "true";
|
||||
|
||||
8
templates/proxy.xml
Normal file
8
templates/proxy.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<proxy>
|
||||
<id />
|
||||
<active />
|
||||
<protocol />
|
||||
<host />
|
||||
<port />
|
||||
<nonProxyHosts />
|
||||
</proxy>
|
||||
@ -3,4 +3,5 @@
|
||||
<profiles/>
|
||||
<servers />
|
||||
<mirrors />
|
||||
<proxies />
|
||||
</settings>
|
||||
|
||||
Reference in New Issue
Block a user