sf-git-merge-driver 1.7.0 → 1.8.0

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.
Files changed (37) hide show
  1. package/README.md +3 -3
  2. package/bin/merge-driver.cjs +28 -28
  3. package/lib/adapter/TxmlXmlParser.d.ts +13 -0
  4. package/lib/adapter/TxmlXmlParser.js +315 -0
  5. package/lib/adapter/TxmlXmlParser.js.map +1 -0
  6. package/lib/adapter/XmlParser.d.ts +4 -2
  7. package/lib/adapter/XmlSerializer.d.ts +2 -1
  8. package/lib/adapter/writer/XmlStreamWriter.d.ts +9 -0
  9. package/lib/adapter/writer/XmlStreamWriter.js +373 -0
  10. package/lib/adapter/writer/XmlStreamWriter.js.map +1 -0
  11. package/lib/bin/driver.js +3 -0
  12. package/lib/bin/driver.js.map +1 -1
  13. package/lib/constant/parserConstant.d.ts +0 -1
  14. package/lib/constant/parserConstant.js +0 -1
  15. package/lib/constant/parserConstant.js.map +1 -1
  16. package/lib/driver/MergeDriver.js +68 -23
  17. package/lib/driver/MergeDriver.js.map +1 -1
  18. package/lib/merger/XmlMerger.d.ts +4 -4
  19. package/lib/merger/XmlMerger.js +25 -17
  20. package/lib/merger/XmlMerger.js.map +1 -1
  21. package/lib/service/GitAttributesPlanner.d.ts +4 -3
  22. package/lib/utils/gitAttributesFile.d.ts +5 -4
  23. package/lib/utils/peekEol.d.ts +1 -0
  24. package/lib/utils/peekEol.js +32 -0
  25. package/lib/utils/peekEol.js.map +1 -0
  26. package/npm-shrinkwrap.json +838 -1361
  27. package/oclif.manifest.json +1 -1
  28. package/package.json +31 -15
  29. package/lib/adapter/FlxXmlParser.d.ts +0 -5
  30. package/lib/adapter/FlxXmlParser.js +0 -62
  31. package/lib/adapter/FlxXmlParser.js.map +0 -1
  32. package/lib/adapter/FxpXmlSerializer.d.ts +0 -10
  33. package/lib/adapter/FxpXmlSerializer.js +0 -140
  34. package/lib/adapter/FxpXmlSerializer.js.map +0 -1
  35. package/lib/merger/ConflictMarkerFormatter.d.ts +0 -14
  36. package/lib/merger/ConflictMarkerFormatter.js +0 -39
  37. package/lib/merger/ConflictMarkerFormatter.js.map +0 -1
@@ -0,0 +1,315 @@
1
+ // txml has no first-party types — declare a narrow ambient signature
2
+ // here instead of casting the import to `any`. The cast at the call
3
+ // site (line "const top = parsedToTNodes(...)") then narrows from
4
+ // `unknown`, not from `any`, so a future txml release that changes
5
+ // the return shape surfaces as a tsc error rather than silent runtime
6
+ // breakage. The @ts-expect-error covers only the missing-types
7
+ // resolution; the runtime contract is asserted in `parsedToTNodes`.
8
+ // @ts-expect-error: txml ships no .d.ts, declare-module is not picked
9
+ // up across .mjs subpath imports under our nodenext module resolution.
10
+ import { parse as txmlParseUntyped } from 'txml/dist/txml.mjs';
11
+ import { CDATA_PROP_NAME, XML_COMMENT_PROP_NAME, } from '../constant/parserConstant.js';
12
+ const txmlParse = txmlParseUntyped;
13
+ const ATTR_PREFIX = '@_';
14
+ const TEXT_KEY = '#text';
15
+ const XMLNS_RE = /^xmlns(?::.+)?$/;
16
+ // Matches a raw comment string emitted by tXml when keepComments=true.
17
+ // Body (the `[\s\S]*?` capture) is what we store under #xml__comment.
18
+ const COMMENT_RE = /^<!--([\s\S]*?)-->$/;
19
+ // Sentinel tag we substitute for CDATA pre-tXml so the boundary
20
+ // survives. Per the XML 1.0 spec, an element name's NameStartChar
21
+ // disallows ASCII control bytes — so `\x00` cannot appear in a real
22
+ // document's tag and the sentinel is collision-proof against
23
+ // adversarial inputs (a hand-authored profile containing
24
+ // `<__cdata_sentinel__>...` would otherwise have been silently
25
+ // converted into a fabricated CDATA node).
26
+ const CDATA_SENTINEL = '\x00cdata\x00';
27
+ const CDATA_RE = /<!\[CDATA\[([\s\S]*?)\]\]>/g;
28
+ // tXml unconditionally collapses CDATA content into the surrounding
29
+ // children as a plain text string — so by the time we see the parsed
30
+ // tree we can no longer tell `<v><![CDATA[<&>]]></v>` from `<v>&lt;&amp;&gt;</v>`.
31
+ // The writer DOES need to know the difference (it re-emits CDATA verbatim).
32
+ //
33
+ // Workaround: rewrite each CDATA region to a synthetic element BEFORE
34
+ // tXml sees the input. Inside, we entity-escape `<` and `&` so tXml
35
+ // accepts the wrapped content as valid PCDATA. The adapter (below)
36
+ // recognises the sentinel tag, undoes the escape, and emits the
37
+ // original content under the canonical CDATA key.
38
+ //
39
+ // `&` MUST be escaped first — otherwise `<` → `&lt;` would be
40
+ // re-escaped to `&amp;lt;` in a second pass.
41
+ const preprocessCdata = (xml) => xml.replace(CDATA_RE, (_, raw) => {
42
+ const escaped = raw.replace(/&/g, '&amp;').replace(/</g, '&lt;');
43
+ return `<${CDATA_SENTINEL}>${escaped}</${CDATA_SENTINEL}>`;
44
+ });
45
+ // Decode pairs the encode in preprocessCdata. The two patterns
46
+ // (`&lt;` and `&amp;`) are disjoint, so order is not load-bearing
47
+ // for the current set — BUT if a third escape is ever added it MUST
48
+ // be decoded last-encoded-first to avoid double-decoding (e.g. an
49
+ // `>` → `&gt;` extension would have to decode `&gt;` BEFORE `&amp;`).
50
+ const decodeCdataEscape = (s) => s.replace(/&lt;/g, '<').replace(/&amp;/g, '&');
51
+ // Quote-aware scan for the next unescaped `>` that closes a tag
52
+ // starting at `from` (the position of the `<`). Walks past `>` chars
53
+ // that appear inside `"..."` or `'...'` attribute values. Without this
54
+ // guard, `<el attr="a>b">` would be split mid-attribute by a naive
55
+ // `indexOf('>')` and the resulting `tagBody` would falsely trigger
56
+ // the unbalanced-tags check on otherwise valid XML.
57
+ const findTagEnd = (xml, from) => {
58
+ let inQuote = null;
59
+ for (let i = from; i < xml.length; i++) {
60
+ const ch = xml[i];
61
+ if (inQuote !== null) {
62
+ if (ch === inQuote)
63
+ inQuote = null;
64
+ continue;
65
+ }
66
+ if (ch === '"' || ch === "'") {
67
+ inQuote = ch;
68
+ continue;
69
+ }
70
+ if (ch === '>')
71
+ return i;
72
+ }
73
+ return -1;
74
+ };
75
+ // tXml is permissive on malformed input: an unclosed tag like
76
+ // `<Profile><broken>` parses without complaint. The previous parser
77
+ // threw on the same input, and MergeDriver relies on the throw to
78
+ // surface a parse failure as a merge conflict.
79
+ //
80
+ // Restore that behaviour with a minimal well-formedness pass: walk the
81
+ // preprocessed XML once, track open-vs-close tag depth, throw on
82
+ // mismatch. CDATA sections have already been replaced by sentinel
83
+ // elements at this point so we don't need to skip them here.
84
+ const assertBalancedTags = (xml) => {
85
+ let depth = 0;
86
+ let i = 0;
87
+ while (i < xml.length) {
88
+ const next = xml.indexOf('<', i);
89
+ if (next < 0)
90
+ break;
91
+ // <!-- comment -->
92
+ if (xml.startsWith('<!--', next)) {
93
+ const end = xml.indexOf('-->', next + 4);
94
+ if (end < 0)
95
+ throw new Error('XML parse error: unterminated comment');
96
+ i = end + 3;
97
+ continue;
98
+ }
99
+ // <!DOCTYPE …>, <![CDATA[…]]> (already preprocessed away),
100
+ // <!ENTITY …>, etc. None contribute to element nesting; skip the
101
+ // whole declaration. Salesforce metadata never emits these but
102
+ // defensive handling costs two lines and prevents a false
103
+ // unbalanced-tags throw on any document with a DOCTYPE prologue.
104
+ if (xml.startsWith('<!', next)) {
105
+ const end = findTagEnd(xml, next + 2);
106
+ if (end < 0)
107
+ throw new Error('XML parse error: unterminated <! ... >');
108
+ i = end + 1;
109
+ continue;
110
+ }
111
+ // <?xml ... ?> declaration / processing instruction
112
+ if (xml.startsWith('<?', next)) {
113
+ const end = xml.indexOf('?>', next + 2);
114
+ if (end < 0)
115
+ throw new Error('XML parse error: unterminated <? ?>');
116
+ i = end + 2;
117
+ continue;
118
+ }
119
+ const tagEnd = findTagEnd(xml, next + 1);
120
+ if (tagEnd < 0)
121
+ throw new Error('XML parse error: unterminated tag');
122
+ const tagBody = xml.slice(next + 1, tagEnd);
123
+ if (tagBody.startsWith('/')) {
124
+ depth--;
125
+ }
126
+ else if (!tagBody.endsWith('/')) {
127
+ depth++;
128
+ }
129
+ // self-closing `<x/>` does not change depth
130
+ i = tagEnd + 1;
131
+ }
132
+ if (depth !== 0) {
133
+ throw new Error(`XML parse error: tags unbalanced (final depth ${depth.toString()})`);
134
+ }
135
+ };
136
+ // Walk a TNode's children once, separating text (concatenated) from
137
+ // element children (grouped by tagName). CDATA sentinels and comment
138
+ // strings are rewritten into their canonical compact-tree keys here.
139
+ const classifyChildren = (children) => {
140
+ let textBuf = '';
141
+ const grouped = new Map();
142
+ const push = (tag, value) => {
143
+ const existing = grouped.get(tag);
144
+ if (existing) {
145
+ existing.push(value);
146
+ }
147
+ else {
148
+ grouped.set(tag, [value]);
149
+ }
150
+ };
151
+ for (const child of children) {
152
+ if (typeof child === 'string') {
153
+ const commentMatch = child.match(COMMENT_RE);
154
+ if (commentMatch !== null) {
155
+ // commentMatch[1] is the [\s\S]*? capture — always defined here
156
+ // (even an empty `<!---->` matches with body = '').
157
+ push(XML_COMMENT_PROP_NAME, commentMatch[1]);
158
+ continue;
159
+ }
160
+ textBuf += child;
161
+ continue;
162
+ }
163
+ if (child.tagName === CDATA_SENTINEL) {
164
+ push(CDATA_PROP_NAME, decodeCdataEscape(sentinelTextOf(child)));
165
+ continue;
166
+ }
167
+ push(child.tagName, toCompact(child));
168
+ }
169
+ return { textBuf, grouped };
170
+ };
171
+ // Extract the text payload of a CDATA-sentinel TNode. Filtered for
172
+ // `string` so a future txml release that introduces nested TNodes
173
+ // inside the sentinel (e.g. via entity expansion) does not silently
174
+ // stringify `[object Object]` into the CDATA content — the previous
175
+ // `as string[]` cast erased the discriminated-union check.
176
+ //
177
+ // Exported only so the defensive non-string branch can be exercised
178
+ // from a unit test (txml's real output for our preprocessed input
179
+ // always satisfies the all-strings precondition, so the guard is
180
+ // otherwise unreachable through a black-box parseString call).
181
+ export const sentinelTextOf = (node) => {
182
+ let out = '';
183
+ for (const c of node.children) {
184
+ if (typeof c === 'string')
185
+ out += c;
186
+ }
187
+ return out;
188
+ };
189
+ // Single-text-child unbox: <v>1</v> serialises as the scalar "1", not
190
+ // `{ '#text': '1' }`. The previous parser's compact shape preferred
191
+ // the scalar form; the writer relies on it.
192
+ const unboxScalar = (out) => {
193
+ const keys = Object.keys(out);
194
+ if (keys.length === 1 && keys[0] === TEXT_KEY)
195
+ return out[TEXT_KEY];
196
+ return out;
197
+ };
198
+ // Convert a TNode subtree into the compact JsonObject shape.
199
+ //
200
+ // Rules (each one anchored by a specific spike-probed case):
201
+ // - element with no children + no attrs → '' (empty)
202
+ // - element with single text child → unbox to scalar (scalar)
203
+ // - element with attrs + no body → { '@_a': v, '#text': '' }
204
+ // - element with attrs + text → { '@_a': v, '#text': t }
205
+ // - repeated same-name siblings → array under one key
206
+ // - mixed text + elements → text concatenated under '#text'
207
+ // - comments (when keepComments=true) → '#xml__comment'
208
+ // - CDATA (via the synthetic sentinel) → '__cdata' key, multi-segment as array
209
+ // - root-element xmlns attributes → extracted by the caller, NOT here
210
+ const toCompact = (node) => {
211
+ const noChildren = node.children.length === 0;
212
+ const noAttrs = Object.keys(node.attributes).length === 0;
213
+ if (noChildren && noAttrs)
214
+ return '';
215
+ const { textBuf, grouped } = classifyChildren(node.children);
216
+ // Attributes first matches the previous parser's emission order,
217
+ // which the writer relies on for stable byte output.
218
+ const out = {};
219
+ for (const [k, v] of Object.entries(node.attributes)) {
220
+ out[`${ATTR_PREFIX}${k}`] = v;
221
+ }
222
+ for (const [tag, arr] of grouped) {
223
+ out[tag] = arr.length === 1 ? arr[0] : arr;
224
+ }
225
+ // Whitespace-only text between elements is dropped (the previous
226
+ // parser's behaviour); meaningful text is preserved.
227
+ if (textBuf.trim().length > 0)
228
+ out[TEXT_KEY] = textBuf;
229
+ // Attr-only element with empty body — emit explicit empty #text to
230
+ // match the previous parser's shape ({ '@_a': v, '#text': '' }).
231
+ if (noChildren && !noAttrs)
232
+ out[TEXT_KEY] = '';
233
+ return unboxScalar(out);
234
+ };
235
+ // Strip the `<?xml ?>` declaration TNode (if present) and pick the root
236
+ // element. tXml emits at most one `?xml` TNode and exactly one root
237
+ // element for any well-formed document.
238
+ const findRootElement = (topLevel) => {
239
+ for (const n of topLevel) {
240
+ if (typeof n === 'string')
241
+ continue;
242
+ if (n.tagName === '?xml')
243
+ continue;
244
+ return n;
245
+ }
246
+ return undefined;
247
+ };
248
+ // Split root attributes into (xmlns* → namespaces bucket) and (rest →
249
+ // stays on the element). Mirrors the previous parser's namespace
250
+ // extraction.
251
+ const splitRootAttrs = (root) => {
252
+ const rootAttrs = {};
253
+ const namespaces = {};
254
+ for (const [k, v] of Object.entries(root.attributes)) {
255
+ if (XMLNS_RE.test(k)) {
256
+ namespaces[`${ATTR_PREFIX}${k}`] = v;
257
+ }
258
+ else {
259
+ rootAttrs[k] = v;
260
+ }
261
+ }
262
+ return { rootAttrs, namespaces };
263
+ };
264
+ // Narrow txml's `unknown` return into the TNode shape we actually use.
265
+ // A future txml major release that breaks the shape contract surfaces
266
+ // here as a descriptive throw instead of a downstream undefined-access.
267
+ //
268
+ // Exported only so the throw branch can be exercised from a unit test;
269
+ // real txml output is always an array, so the guard is otherwise
270
+ // unreachable through a black-box parseString call.
271
+ export const parsedToTNodes = (raw) => {
272
+ if (!Array.isArray(raw)) {
273
+ throw new Error(`txml.parse: expected an array of nodes, got ${typeof raw}`);
274
+ }
275
+ return raw;
276
+ };
277
+ const adapt = (xml) => {
278
+ const preprocessed = preprocessCdata(xml);
279
+ assertBalancedTags(preprocessed);
280
+ const top = parsedToTNodes(txmlParse(preprocessed, { keepComments: true }));
281
+ const root = findRootElement(top);
282
+ if (root === undefined) {
283
+ return { content: {}, namespaces: {} };
284
+ }
285
+ const { rootAttrs, namespaces } = splitRootAttrs(root);
286
+ const stripped = {
287
+ tagName: root.tagName,
288
+ attributes: rootAttrs,
289
+ children: root.children,
290
+ };
291
+ return {
292
+ content: { [root.tagName]: toCompact(stripped) },
293
+ namespaces,
294
+ };
295
+ };
296
+ // Drain a Readable into a single UTF-8 string. The deliberate
297
+ // full-buffer approach matches the writer's: SF metadata files are
298
+ // KB-MB, and txml's parse API is synchronous, so chunked feeding would
299
+ // add no value while complicating error paths.
300
+ const readStreamAsUtf8 = async (source) => {
301
+ const chunks = [];
302
+ for await (const c of source) {
303
+ chunks.push(typeof c === 'string' ? Buffer.from(c, 'utf8') : c);
304
+ }
305
+ return Buffer.concat(chunks).toString('utf8');
306
+ };
307
+ export class TxmlXmlParser {
308
+ parseString(xml) {
309
+ return adapt(xml);
310
+ }
311
+ async parseStream(source) {
312
+ return adapt(await readStreamAsUtf8(source));
313
+ }
314
+ }
315
+ //# sourceMappingURL=TxmlXmlParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TxmlXmlParser.js","sourceRoot":"","sources":["../../src/adapter/TxmlXmlParser.ts"],"names":[],"mappings":"AACA,qEAAqE;AACrE,oEAAoE;AACpE,kEAAkE;AAClE,mEAAmE;AACnE,sEAAsE;AACtE,+DAA+D;AAC/D,oEAAoE;AACpE,sEAAsE;AACtE,uEAAuE;AACvE,OAAO,EAAE,KAAK,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EACL,eAAe,EACf,qBAAqB,GACtB,MAAM,+BAA+B,CAAA;AAItC,MAAM,SAAS,GAAG,gBAGN,CAAA;AAiBZ,MAAM,WAAW,GAAG,IAAI,CAAA;AACxB,MAAM,QAAQ,GAAG,OAAO,CAAA;AACxB,MAAM,QAAQ,GAAG,iBAAiB,CAAA;AAClC,uEAAuE;AACvE,sEAAsE;AACtE,MAAM,UAAU,GAAG,qBAAqB,CAAA;AACxC,gEAAgE;AAChE,kEAAkE;AAClE,oEAAoE;AACpE,6DAA6D;AAC7D,yDAAyD;AACzD,+DAA+D;AAC/D,2CAA2C;AAC3C,MAAM,cAAc,GAAG,eAAe,CAAA;AACtC,MAAM,QAAQ,GAAG,6BAA6B,CAAA;AAE9C,oEAAoE;AACpE,qEAAqE;AACrE,mFAAmF;AACnF,4EAA4E;AAC5E,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,mEAAmE;AACnE,gEAAgE;AAChE,kDAAkD;AAClD,EAAE;AACF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,OAAO;QACL,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE;QAChD,UAAU;KACX,CAAA;AACH,CAAC,CAAA;AAED,8DAA8D;AAC9D,mEAAmE;AACnE,uEAAuE;AACvE,+CAA+C;AAC/C,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAgB,EAAmB,EAAE;IACnE,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,IAAI,KAAK,EAAE,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAE,CAAY,CAAC,CAAA;IAC7E,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AAC/C,CAAC,CAAA;AAED,MAAM,OAAO,aAAa;IACxB,WAAW,CAAC,GAAW;QACrB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAA;IACnB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,MAAgB;QAChC,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAA;IAC9C,CAAC;CACF"}
@@ -1,8 +1,10 @@
1
+ import type { Readable } from 'node:stream';
1
2
  import type { JsonObject } from '../types/jsonTypes.js';
2
- export interface ParsedXml {
3
+ export interface NormalisedParseResult {
3
4
  readonly content: JsonObject;
4
5
  readonly namespaces: JsonObject;
5
6
  }
6
7
  export interface XmlParser {
7
- parse(xml: string): ParsedXml;
8
+ parseString(xml: string): NormalisedParseResult;
9
+ parseStream(source: Readable): Promise<NormalisedParseResult>;
8
10
  }
@@ -1,4 +1,5 @@
1
+ import type { Writable } from 'node:stream';
1
2
  import type { JsonArray, JsonObject } from '../types/jsonTypes.js';
2
3
  export interface XmlSerializer {
3
- serialize(mergedOutput: JsonArray, namespaces: JsonObject): string;
4
+ writeTo(out: Writable, ordered: JsonArray, namespaces: JsonObject, eol?: '\n' | '\r\n', hasConflict?: boolean): Promise<void>;
4
5
  }
@@ -0,0 +1,9 @@
1
+ import type { Writable } from 'node:stream';
2
+ import type { MergeConfig } from '../../types/conflictTypes.js';
3
+ import type { JsonArray, JsonObject } from '../../types/jsonTypes.js';
4
+ import type { XmlSerializer } from '../XmlSerializer.js';
5
+ export declare class XmlStreamWriter implements XmlSerializer {
6
+ private readonly config;
7
+ constructor(config: MergeConfig);
8
+ writeTo(out: Writable, ordered: JsonArray, namespaces: JsonObject, eol?: '\n' | '\r\n', hasConflict?: boolean): Promise<void>;
9
+ }