@jjrawlins/cdk-diff-pr-github-action 1.9.7 → 1.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +3 -3
- package/cdkdiffprgithubaction/go.mod +1 -1
- package/cdkdiffprgithubaction/jsii/jsii.go +2 -2
- package/cdkdiffprgithubaction/version +1 -1
- package/lib/CdkDiffIamTemplate.js +2 -2
- package/lib/CdkDiffIamTemplateStackSet.js +2 -2
- package/lib/CdkDiffStackWorkflow.js +1 -1
- package/lib/CdkDriftDetectionWorkflow.js +1 -1
- package/lib/CdkDriftIamTemplate.js +2 -2
- package/node_modules/@aws-sdk/client-cloudformation/package.json +2 -2
- package/node_modules/@smithy/util-waiter/dist-cjs/index.js +1 -1
- package/node_modules/@smithy/util-waiter/dist-es/poller.js +1 -1
- package/node_modules/@smithy/util-waiter/package.json +1 -1
- package/node_modules/fast-xml-builder/README.md +1 -1
- package/node_modules/fast-xml-builder/lib/fxb.cjs +1 -0
- package/node_modules/fast-xml-builder/lib/fxb.d.cts +6 -1
- package/node_modules/fast-xml-builder/lib/fxb.min.js +2 -0
- package/node_modules/fast-xml-builder/lib/fxb.min.js.map +1 -0
- package/node_modules/fast-xml-builder/package.json +7 -5
- package/node_modules/fast-xml-builder/src/fxb.d.ts +8 -2
- package/node_modules/fast-xml-builder/src/fxb.js +262 -21
- package/node_modules/fast-xml-builder/src/orderedJs2Xml.js +161 -18
- package/node_modules/path-expression-matcher/LICENSE +21 -0
- package/node_modules/path-expression-matcher/README.md +635 -0
- package/node_modules/path-expression-matcher/package.json +52 -0
- package/node_modules/path-expression-matcher/src/Expression.js +232 -0
- package/node_modules/path-expression-matcher/src/Matcher.js +414 -0
- package/node_modules/path-expression-matcher/src/index.js +28 -0
- package/package.json +3 -3
- package/node_modules/fast-xml-builder/lib/builder.cjs +0 -1
- package/node_modules/fast-xml-builder/lib/builder.min.js +0 -2
- package/node_modules/fast-xml-builder/lib/builder.min.js.map +0 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Expression, Matcher } from 'path-expression-matcher';
|
|
2
|
+
|
|
1
3
|
const EOL = "\n";
|
|
2
4
|
|
|
3
5
|
/**
|
|
@@ -11,10 +13,27 @@ export default function toXml(jArray, options) {
|
|
|
11
13
|
if (options.format && options.indentBy.length > 0) {
|
|
12
14
|
indentation = EOL;
|
|
13
15
|
}
|
|
14
|
-
|
|
16
|
+
|
|
17
|
+
// Pre-compile stopNode expressions for pattern matching
|
|
18
|
+
const stopNodeExpressions = [];
|
|
19
|
+
if (options.stopNodes && Array.isArray(options.stopNodes)) {
|
|
20
|
+
for (let i = 0; i < options.stopNodes.length; i++) {
|
|
21
|
+
const node = options.stopNodes[i];
|
|
22
|
+
if (typeof node === 'string') {
|
|
23
|
+
stopNodeExpressions.push(new Expression(node));
|
|
24
|
+
} else if (node instanceof Expression) {
|
|
25
|
+
stopNodeExpressions.push(node);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Initialize matcher for path tracking
|
|
31
|
+
const matcher = new Matcher();
|
|
32
|
+
|
|
33
|
+
return arrToStr(jArray, options, indentation, matcher, stopNodeExpressions);
|
|
15
34
|
}
|
|
16
35
|
|
|
17
|
-
function arrToStr(arr, options,
|
|
36
|
+
function arrToStr(arr, options, indentation, matcher, stopNodeExpressions) {
|
|
18
37
|
let xmlStr = "";
|
|
19
38
|
let isPreviousElementTag = false;
|
|
20
39
|
|
|
@@ -34,13 +53,18 @@ function arrToStr(arr, options, jPath, indentation) {
|
|
|
34
53
|
const tagName = propName(tagObj);
|
|
35
54
|
if (tagName === undefined) continue;
|
|
36
55
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
56
|
+
// Extract attributes from ":@" property
|
|
57
|
+
const attrValues = extractAttributeValues(tagObj[":@"], options);
|
|
58
|
+
|
|
59
|
+
// Push tag to matcher WITH attributes
|
|
60
|
+
matcher.push(tagName, attrValues);
|
|
61
|
+
|
|
62
|
+
// Check if this is a stop node using Expression matching
|
|
63
|
+
const isStopNode = checkStopNode(matcher, stopNodeExpressions);
|
|
40
64
|
|
|
41
65
|
if (tagName === options.textNodeName) {
|
|
42
66
|
let tagText = tagObj[tagName];
|
|
43
|
-
if (!isStopNode
|
|
67
|
+
if (!isStopNode) {
|
|
44
68
|
tagText = options.tagValueProcessor(tagName, tagText);
|
|
45
69
|
tagText = replaceEntitiesValue(tagText, options);
|
|
46
70
|
}
|
|
@@ -49,6 +73,7 @@ function arrToStr(arr, options, jPath, indentation) {
|
|
|
49
73
|
}
|
|
50
74
|
xmlStr += tagText;
|
|
51
75
|
isPreviousElementTag = false;
|
|
76
|
+
matcher.pop();
|
|
52
77
|
continue;
|
|
53
78
|
} else if (tagName === options.cdataPropName) {
|
|
54
79
|
if (isPreviousElementTag) {
|
|
@@ -56,27 +81,41 @@ function arrToStr(arr, options, jPath, indentation) {
|
|
|
56
81
|
}
|
|
57
82
|
xmlStr += `<![CDATA[${tagObj[tagName][0][options.textNodeName]}]]>`;
|
|
58
83
|
isPreviousElementTag = false;
|
|
84
|
+
matcher.pop();
|
|
59
85
|
continue;
|
|
60
86
|
} else if (tagName === options.commentPropName) {
|
|
61
87
|
xmlStr += indentation + `<!--${tagObj[tagName][0][options.textNodeName]}-->`;
|
|
62
88
|
isPreviousElementTag = true;
|
|
89
|
+
matcher.pop();
|
|
63
90
|
continue;
|
|
64
91
|
} else if (tagName[0] === "?") {
|
|
65
|
-
const attStr = attr_to_str(tagObj[":@"], options);
|
|
92
|
+
const attStr = attr_to_str(tagObj[":@"], options, isStopNode);
|
|
66
93
|
const tempInd = tagName === "?xml" ? "" : indentation;
|
|
67
94
|
let piTextNodeName = tagObj[tagName][0][options.textNodeName];
|
|
68
95
|
piTextNodeName = piTextNodeName.length !== 0 ? " " + piTextNodeName : ""; //remove extra spacing
|
|
69
96
|
xmlStr += tempInd + `<${tagName}${piTextNodeName}${attStr}?>`;
|
|
70
97
|
isPreviousElementTag = true;
|
|
98
|
+
matcher.pop();
|
|
71
99
|
continue;
|
|
72
100
|
}
|
|
101
|
+
|
|
73
102
|
let newIdentation = indentation;
|
|
74
103
|
if (newIdentation !== "") {
|
|
75
104
|
newIdentation += options.indentBy;
|
|
76
105
|
}
|
|
77
|
-
|
|
106
|
+
|
|
107
|
+
// Pass isStopNode to attr_to_str so attributes are also not processed for stopNodes
|
|
108
|
+
const attStr = attr_to_str(tagObj[":@"], options, isStopNode);
|
|
78
109
|
const tagStart = indentation + `<${tagName}${attStr}`;
|
|
79
|
-
|
|
110
|
+
|
|
111
|
+
// If this is a stopNode, get raw content without processing
|
|
112
|
+
let tagValue;
|
|
113
|
+
if (isStopNode) {
|
|
114
|
+
tagValue = getRawContent(tagObj[tagName], options);
|
|
115
|
+
} else {
|
|
116
|
+
tagValue = arrToStr(tagObj[tagName], options, newIdentation, matcher, stopNodeExpressions);
|
|
117
|
+
}
|
|
118
|
+
|
|
80
119
|
if (options.unpairedTags.indexOf(tagName) !== -1) {
|
|
81
120
|
if (options.suppressUnpairedNode) xmlStr += tagStart + ">";
|
|
82
121
|
else xmlStr += tagStart + "/>";
|
|
@@ -94,11 +133,104 @@ function arrToStr(arr, options, jPath, indentation) {
|
|
|
94
133
|
xmlStr += `</${tagName}>`;
|
|
95
134
|
}
|
|
96
135
|
isPreviousElementTag = true;
|
|
136
|
+
|
|
137
|
+
// Pop tag from matcher
|
|
138
|
+
matcher.pop();
|
|
97
139
|
}
|
|
98
140
|
|
|
99
141
|
return xmlStr;
|
|
100
142
|
}
|
|
101
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Extract attribute values from the ":@" object and return as plain object
|
|
146
|
+
* for passing to matcher.push()
|
|
147
|
+
*/
|
|
148
|
+
function extractAttributeValues(attrMap, options) {
|
|
149
|
+
if (!attrMap || options.ignoreAttributes) return null;
|
|
150
|
+
|
|
151
|
+
const attrValues = {};
|
|
152
|
+
let hasAttrs = false;
|
|
153
|
+
|
|
154
|
+
for (let attr in attrMap) {
|
|
155
|
+
if (!Object.prototype.hasOwnProperty.call(attrMap, attr)) continue;
|
|
156
|
+
// Remove the attribute prefix to get clean attribute name
|
|
157
|
+
const cleanAttrName = attr.startsWith(options.attributeNamePrefix)
|
|
158
|
+
? attr.substr(options.attributeNamePrefix.length)
|
|
159
|
+
: attr;
|
|
160
|
+
attrValues[cleanAttrName] = attrMap[attr];
|
|
161
|
+
hasAttrs = true;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return hasAttrs ? attrValues : null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Extract raw content from a stopNode without any processing
|
|
169
|
+
* This preserves the content exactly as-is, including special characters
|
|
170
|
+
*/
|
|
171
|
+
function getRawContent(arr, options) {
|
|
172
|
+
if (!Array.isArray(arr)) {
|
|
173
|
+
// Non-array values return as-is
|
|
174
|
+
if (arr !== undefined && arr !== null) {
|
|
175
|
+
return arr.toString();
|
|
176
|
+
}
|
|
177
|
+
return "";
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
let content = "";
|
|
181
|
+
for (let i = 0; i < arr.length; i++) {
|
|
182
|
+
const item = arr[i];
|
|
183
|
+
const tagName = propName(item);
|
|
184
|
+
|
|
185
|
+
if (tagName === options.textNodeName) {
|
|
186
|
+
// Raw text content - NO processing, NO entity replacement
|
|
187
|
+
content += item[tagName];
|
|
188
|
+
} else if (tagName === options.cdataPropName) {
|
|
189
|
+
// CDATA content
|
|
190
|
+
content += item[tagName][0][options.textNodeName];
|
|
191
|
+
} else if (tagName === options.commentPropName) {
|
|
192
|
+
// Comment content
|
|
193
|
+
content += item[tagName][0][options.textNodeName];
|
|
194
|
+
} else if (tagName && tagName[0] === "?") {
|
|
195
|
+
// Processing instruction - skip for stopNodes
|
|
196
|
+
continue;
|
|
197
|
+
} else if (tagName) {
|
|
198
|
+
// Nested tags within stopNode
|
|
199
|
+
// Recursively get raw content and reconstruct the tag
|
|
200
|
+
// For stopNodes, we don't process attributes either
|
|
201
|
+
const attStr = attr_to_str_raw(item[":@"], options);
|
|
202
|
+
const nestedContent = getRawContent(item[tagName], options);
|
|
203
|
+
|
|
204
|
+
if (!nestedContent || nestedContent.length === 0) {
|
|
205
|
+
content += `<${tagName}${attStr}/>`;
|
|
206
|
+
} else {
|
|
207
|
+
content += `<${tagName}${attStr}>${nestedContent}</${tagName}>`;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return content;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Build attribute string for stopNodes - NO entity replacement
|
|
216
|
+
*/
|
|
217
|
+
function attr_to_str_raw(attrMap, options) {
|
|
218
|
+
let attrStr = "";
|
|
219
|
+
if (attrMap && !options.ignoreAttributes) {
|
|
220
|
+
for (let attr in attrMap) {
|
|
221
|
+
if (!Object.prototype.hasOwnProperty.call(attrMap, attr)) continue;
|
|
222
|
+
// For stopNodes, use raw value without processing
|
|
223
|
+
let attrVal = attrMap[attr];
|
|
224
|
+
if (attrVal === true && options.suppressBooleanAttributes) {
|
|
225
|
+
attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}`;
|
|
226
|
+
} else {
|
|
227
|
+
attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}="${attrVal}"`;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return attrStr;
|
|
232
|
+
}
|
|
233
|
+
|
|
102
234
|
function propName(obj) {
|
|
103
235
|
const keys = Object.keys(obj);
|
|
104
236
|
for (let i = 0; i < keys.length; i++) {
|
|
@@ -108,13 +240,22 @@ function propName(obj) {
|
|
|
108
240
|
}
|
|
109
241
|
}
|
|
110
242
|
|
|
111
|
-
function attr_to_str(attrMap, options) {
|
|
243
|
+
function attr_to_str(attrMap, options, isStopNode) {
|
|
112
244
|
let attrStr = "";
|
|
113
245
|
if (attrMap && !options.ignoreAttributes) {
|
|
114
246
|
for (let attr in attrMap) {
|
|
115
247
|
if (!Object.prototype.hasOwnProperty.call(attrMap, attr)) continue;
|
|
116
|
-
let attrVal
|
|
117
|
-
|
|
248
|
+
let attrVal;
|
|
249
|
+
|
|
250
|
+
if (isStopNode) {
|
|
251
|
+
// For stopNodes, use raw value without any processing
|
|
252
|
+
attrVal = attrMap[attr];
|
|
253
|
+
} else {
|
|
254
|
+
// Normal processing: apply attributeValueProcessor and entity replacement
|
|
255
|
+
attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
|
|
256
|
+
attrVal = replaceEntitiesValue(attrVal, options);
|
|
257
|
+
}
|
|
258
|
+
|
|
118
259
|
if (attrVal === true && options.suppressBooleanAttributes) {
|
|
119
260
|
attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}`;
|
|
120
261
|
} else {
|
|
@@ -125,11 +266,13 @@ function attr_to_str(attrMap, options) {
|
|
|
125
266
|
return attrStr;
|
|
126
267
|
}
|
|
127
268
|
|
|
128
|
-
function
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
for (let
|
|
132
|
-
if (
|
|
269
|
+
function checkStopNode(matcher, stopNodeExpressions) {
|
|
270
|
+
if (!stopNodeExpressions || stopNodeExpressions.length === 0) return false;
|
|
271
|
+
|
|
272
|
+
for (let i = 0; i < stopNodeExpressions.length; i++) {
|
|
273
|
+
if (matcher.matches(stopNodeExpressions[i])) {
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
133
276
|
}
|
|
134
277
|
return false;
|
|
135
278
|
}
|
|
@@ -142,4 +285,4 @@ function replaceEntitiesValue(textValue, options) {
|
|
|
142
285
|
}
|
|
143
286
|
}
|
|
144
287
|
return textValue;
|
|
145
|
-
}
|
|
288
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|