@abapify/adt-diff 0.4.34 → 0.4.38
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/README.md +14 -43
- package/dist/commands/diff.d.mts.map +1 -1
- package/dist/commands/diff.mjs +1 -1
- package/dist/{diff-C9jJwHCe.mjs → diff-BNaZOwe9.mjs} +328 -356
- package/dist/diff-BNaZOwe9.mjs.map +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +6 -6
- package/dist/diff-C9jJwHCe.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
# @abapify/adt-diff
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
current source in a connected SAP system and prints a coloured unified diff.
|
|
6
|
-
Any object type supported by `@abapify/adt-plugin-abapgit` can be compared.
|
|
3
|
+
[](https://www.npmjs.com/package/@abapify/adt-diff)
|
|
4
|
+
[](https://github.com/abapify/adt-cli/blob/main/LICENSE)
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
Diff CLI plugin for adt-cli - compare local serialized files against SAP remote source.
|
|
9
7
|
|
|
10
8
|
## Install
|
|
11
9
|
|
|
12
10
|
```bash
|
|
13
|
-
npm
|
|
14
|
-
# or
|
|
15
|
-
bun add @abapify/adt-diff
|
|
11
|
+
npm install @abapify/adt-diff @abapify/adt-cli
|
|
16
12
|
```
|
|
17
13
|
|
|
18
14
|
## Usage
|
|
19
15
|
|
|
20
|
-
Register the command in
|
|
16
|
+
Register the command plugin in your project config:
|
|
21
17
|
|
|
22
18
|
```ts
|
|
23
19
|
// adt.config.ts
|
|
@@ -26,46 +22,21 @@ export default {
|
|
|
26
22
|
};
|
|
27
23
|
```
|
|
28
24
|
|
|
29
|
-
Then
|
|
30
|
-
directory:
|
|
25
|
+
Then:
|
|
31
26
|
|
|
32
27
|
```bash
|
|
33
|
-
|
|
34
|
-
adt diff zcl_myclass.clas.xml ztab.tabl.xml
|
|
35
|
-
|
|
36
|
-
# Glob patterns
|
|
37
|
-
adt diff "*.tabl.xml" --context 5
|
|
38
|
-
|
|
39
|
-
# Scan the whole repo, ignoring unchanged objects
|
|
40
|
-
adt diff --package ZMY_PACKAGE
|
|
41
|
-
|
|
42
|
-
# Compare ADK-rendered source instead of raw XML (TABL only)
|
|
43
|
-
adt diff zmy_table.tabl.xml --source
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
The package also exposes a small TABL-to-CDS DDL utility that is independent
|
|
47
|
-
of the diff command:
|
|
48
|
-
|
|
49
|
-
```ts
|
|
50
|
-
import { tablXmlToCdsDdl, buildCdsDdl } from '@abapify/adt-diff';
|
|
51
|
-
|
|
52
|
-
const ddl = tablXmlToCdsDdl(xmlString);
|
|
28
|
+
adt diff zcl_my_class.clas.xml
|
|
53
29
|
```
|
|
54
30
|
|
|
55
|
-
##
|
|
31
|
+
## Features
|
|
56
32
|
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
`@abapify/adt-plugin-abapgit` to resolve filenames to ADT object URIs.
|
|
60
|
-
- Read-only: it never locks, writes, or imports objects. For round-tripping
|
|
61
|
-
objects into and out of the system, see `@abapify/adt-export` and the
|
|
62
|
-
relevant ADK save flow.
|
|
33
|
+
- Compare local abapGit / gCTS files with SAP
|
|
34
|
+
- Unified diff output for review and CI
|
|
63
35
|
|
|
64
|
-
##
|
|
36
|
+
## Documentation
|
|
65
37
|
|
|
66
|
-
-
|
|
67
|
-
- [Full docs](https://adt-cli.netlify.app)
|
|
38
|
+
**[adt-cli.netlify.app/sdk/packages/adt-diff](https://adt-cli.netlify.app/sdk/packages/adt-diff)**
|
|
68
39
|
|
|
69
|
-
|
|
40
|
+
---
|
|
70
41
|
|
|
71
|
-
|
|
42
|
+
Part of [**abapify**](https://github.com/abapify/adt-cli) — open, typed tooling for SAP ABAP Development Tools (ADT): CLI, MCP server, and SDK.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.mts","names":[],"sources":["../../src/commands/diff.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"diff.d.mts","names":[],"sources":["../../src/commands/diff.ts"],"mappings":";cAq/Ba,aAAa"}
|
package/dist/commands/diff.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default, t as diffCommand } from "../diff-
|
|
1
|
+
export { t as default, t as diffCommand } from "../diff-BNaZOwe9.mjs";
|
|
@@ -109,6 +109,35 @@ const DATA_MAINTENANCE_REVERSE = {
|
|
|
109
109
|
"": "#ALLOWED"
|
|
110
110
|
};
|
|
111
111
|
/**
|
|
112
|
+
* Push a reverse-mapped header annotation when the DDIC code has a CDS
|
|
113
|
+
* meaning. `code` is the raw DDIC value (`''` is meaningful for some flags).
|
|
114
|
+
*/
|
|
115
|
+
function pushMappedAnnotation(lines, label, code, mapping) {
|
|
116
|
+
const value = mapping[code ?? ""];
|
|
117
|
+
if (value) lines.push(`@${label} : ${value}`);
|
|
118
|
+
}
|
|
119
|
+
/** Push the DD02V-derived header annotations. */
|
|
120
|
+
function pushHeaderAnnotations(lines, dd02v, isStructure) {
|
|
121
|
+
if (dd02v.DDTEXT) lines.push(`@EndUserText.label : '${escapeAnnotationString(dd02v.DDTEXT)}'`);
|
|
122
|
+
pushMappedAnnotation(lines, "AbapCatalog.enhancement.category", dd02v.EXCLASS, ENHANCEMENT_CATEGORY_REVERSE);
|
|
123
|
+
if (!isStructure) {
|
|
124
|
+
pushMappedAnnotation(lines, "AbapCatalog.tableCategory", dd02v.TABCLASS, TABLE_CATEGORY_REVERSE);
|
|
125
|
+
pushMappedAnnotation(lines, "AbapCatalog.deliveryClass", dd02v.CONTFLAG, DELIVERY_CLASS_REVERSE);
|
|
126
|
+
if (dd02v.MATEFLAG !== void 0) pushMappedAnnotation(lines, "AbapCatalog.dataMaintenance", dd02v.MATEFLAG, DATA_MAINTENANCE_REVERSE);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/** Emit include/field lines, field names aligned to `maxNameWidth`. */
|
|
130
|
+
function pushMemberLines(lines, fieldInfos, maxNameWidth) {
|
|
131
|
+
for (const info of fieldInfos) if (info.kind === "include") {
|
|
132
|
+
if (info.suffix) lines.push(` include ${info.name} with suffix ${info.suffix};`);
|
|
133
|
+
else lines.push(` include ${info.name};`);
|
|
134
|
+
} else {
|
|
135
|
+
for (const ann of info.annotations) lines.push(` ${ann}`);
|
|
136
|
+
const paddedPrefix = info.prefix.padEnd(maxNameWidth);
|
|
137
|
+
lines.push(` ${paddedPrefix} : ${info.typeStr};`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
112
141
|
* Build CDS DDL source from DD02V header and DD03P field entries.
|
|
113
142
|
*
|
|
114
143
|
* @param dd02v - Table/structure header data
|
|
@@ -119,117 +148,77 @@ function buildCdsDdl(dd02v, dd03pEntries) {
|
|
|
119
148
|
const lines = [];
|
|
120
149
|
const tableName = dd02v.TABNAME ?? "";
|
|
121
150
|
const isStructure = dd02v.TABCLASS === "INTTAB";
|
|
122
|
-
|
|
123
|
-
if (dd02v.EXCLASS) {
|
|
124
|
-
const cat = ENHANCEMENT_CATEGORY_REVERSE[dd02v.EXCLASS];
|
|
125
|
-
if (cat) lines.push(`@AbapCatalog.enhancement.category : ${cat}`);
|
|
126
|
-
}
|
|
127
|
-
if (!isStructure) {
|
|
128
|
-
if (dd02v.TABCLASS) {
|
|
129
|
-
const cat = TABLE_CATEGORY_REVERSE[dd02v.TABCLASS];
|
|
130
|
-
if (cat) lines.push(`@AbapCatalog.tableCategory : ${cat}`);
|
|
131
|
-
}
|
|
132
|
-
if (dd02v.CONTFLAG) {
|
|
133
|
-
const dc = DELIVERY_CLASS_REVERSE[dd02v.CONTFLAG];
|
|
134
|
-
if (dc) lines.push(`@AbapCatalog.deliveryClass : ${dc}`);
|
|
135
|
-
}
|
|
136
|
-
if (dd02v.MATEFLAG !== void 0) {
|
|
137
|
-
const dm = DATA_MAINTENANCE_REVERSE[dd02v.MATEFLAG ?? ""];
|
|
138
|
-
if (dm) lines.push(`@AbapCatalog.dataMaintenance : ${dm}`);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
151
|
+
pushHeaderAnnotations(lines, dd02v, isStructure);
|
|
141
152
|
const keyword = isStructure ? "define structure" : "define table";
|
|
142
153
|
lines.push(`${keyword} ${tableName.toLowerCase()} {`, "");
|
|
143
154
|
const fieldInfos = buildFieldInfos([...dd03pEntries].sort((a, b) => {
|
|
144
155
|
return Number.parseInt(a.POSITION ?? "0", 10) - Number.parseInt(b.POSITION ?? "0", 10);
|
|
145
156
|
}), tableName);
|
|
146
|
-
|
|
147
|
-
for (const info of fieldInfos) if (info.kind === "include") {
|
|
148
|
-
if (info.suffix) lines.push(` include ${info.name} with suffix ${info.suffix};`);
|
|
149
|
-
else lines.push(` include ${info.name};`);
|
|
150
|
-
} else {
|
|
151
|
-
for (const ann of info.annotations) lines.push(` ${ann}`);
|
|
152
|
-
const paddedPrefix = info.prefix.padEnd(maxNameWidth);
|
|
153
|
-
lines.push(` ${paddedPrefix} : ${info.typeStr};`);
|
|
154
|
-
}
|
|
157
|
+
pushMemberLines(lines, fieldInfos, Math.max(...fieldInfos.filter((f) => f.kind === "field").map((f) => f.prefix.length), 0));
|
|
155
158
|
lines.push("", "}");
|
|
156
159
|
return lines.join("\n") + "\n";
|
|
157
160
|
}
|
|
158
161
|
/**
|
|
162
|
+
* Assemble a field info from an already-rendered base type string, adding
|
|
163
|
+
* the `key` prefix and `not null` suffix.
|
|
164
|
+
*/
|
|
165
|
+
function buildTypedFieldInfo(fieldName, typeBase, entry, annotations = []) {
|
|
166
|
+
const isKey = entry.KEYFLAG === "X";
|
|
167
|
+
const notNull = entry.NOTNULL === "X" || isKey;
|
|
168
|
+
return {
|
|
169
|
+
kind: "field",
|
|
170
|
+
prefix: isKey ? `key ${fieldName.toLowerCase()}` : fieldName.toLowerCase(),
|
|
171
|
+
typeStr: notNull ? `${typeBase} not null` : typeBase,
|
|
172
|
+
annotations
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/** `@Semantics` annotations for CURR/QUAN fields with a reference table. */
|
|
176
|
+
function semanticsAnnotations(entry, tableName) {
|
|
177
|
+
const annotations = [];
|
|
178
|
+
if (entry.DATATYPE === "CURR" && entry.REFTABLE && entry.REFFIELD) {
|
|
179
|
+
const refTable = entry.REFTABLE.toUpperCase() === tableName.toUpperCase() ? tableName.toLowerCase() : entry.REFTABLE.toLowerCase();
|
|
180
|
+
annotations.push(`@Semantics.amount.currencyCode : '${refTable}.${entry.REFFIELD.toLowerCase()}'`);
|
|
181
|
+
} else if (entry.DATATYPE === "QUAN" && entry.REFTABLE && entry.REFFIELD) {
|
|
182
|
+
const refTable = entry.REFTABLE.toUpperCase() === tableName.toUpperCase() ? tableName.toLowerCase() : entry.REFTABLE.toLowerCase();
|
|
183
|
+
annotations.push(`@Semantics.quantity.unitOfMeasure : '${refTable}.${entry.REFFIELD.toLowerCase()}'`);
|
|
184
|
+
}
|
|
185
|
+
return annotations;
|
|
186
|
+
}
|
|
187
|
+
/** Classify one DD03P entry into a field/include info (or nothing). */
|
|
188
|
+
function buildMemberInfo(entry, tableName) {
|
|
189
|
+
const fieldName = entry.FIELDNAME ?? "";
|
|
190
|
+
if (fieldName.startsWith(".INCLU-")) {
|
|
191
|
+
const includeName = entry.PRECFIELD ?? "";
|
|
192
|
+
if (!includeName) return null;
|
|
193
|
+
const suffix = fieldName.slice(7).toLowerCase();
|
|
194
|
+
return {
|
|
195
|
+
kind: "include",
|
|
196
|
+
name: includeName.toLowerCase(),
|
|
197
|
+
suffix
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
if (fieldName === ".INCLUDE") {
|
|
201
|
+
const includeName = entry.PRECFIELD ?? "";
|
|
202
|
+
if (!includeName) return null;
|
|
203
|
+
return {
|
|
204
|
+
kind: "include",
|
|
205
|
+
name: includeName.toLowerCase()
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
if (entry.COMPTYPE === "S" && entry.DATATYPE === "STRU") return buildTypedFieldInfo(fieldName, (entry.ROLLNAME ?? fieldName).toLowerCase(), entry);
|
|
209
|
+
if (entry.COMPTYPE === "E" && entry.ROLLNAME) return buildTypedFieldInfo(fieldName, entry.ROLLNAME.toLowerCase(), entry);
|
|
210
|
+
const cdsType = buildCdsTypeString(entry);
|
|
211
|
+
if (!cdsType) return null;
|
|
212
|
+
return buildTypedFieldInfo(fieldName, cdsType, entry, semanticsAnnotations(entry, tableName));
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
159
215
|
* Pre-process DD03P entries into structured field info for emission.
|
|
160
216
|
*/
|
|
161
217
|
function buildFieldInfos(entries, tableName) {
|
|
162
218
|
const result = [];
|
|
163
|
-
for (
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
if (fieldName.startsWith(".INCLU-")) {
|
|
167
|
-
const includeName = entry.PRECFIELD ?? "";
|
|
168
|
-
if (includeName) {
|
|
169
|
-
const suffix = fieldName.slice(7).toLowerCase();
|
|
170
|
-
result.push({
|
|
171
|
-
kind: "include",
|
|
172
|
-
name: includeName.toLowerCase(),
|
|
173
|
-
suffix
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
if (fieldName === ".INCLUDE") {
|
|
179
|
-
const includeName = entry.PRECFIELD ?? "";
|
|
180
|
-
if (includeName) result.push({
|
|
181
|
-
kind: "include",
|
|
182
|
-
name: includeName.toLowerCase()
|
|
183
|
-
});
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
if (entry.COMPTYPE === "S" && entry.DATATYPE === "STRU") {
|
|
187
|
-
const isKey = entry.KEYFLAG === "X";
|
|
188
|
-
const notNull = entry.NOTNULL === "X" || isKey;
|
|
189
|
-
const rollname = entry.ROLLNAME ?? fieldName;
|
|
190
|
-
const prefix = isKey ? `key ${fieldName.toLowerCase()}` : fieldName.toLowerCase();
|
|
191
|
-
const typeStr = notNull ? `${rollname.toLowerCase()} not null` : rollname.toLowerCase();
|
|
192
|
-
result.push({
|
|
193
|
-
kind: "field",
|
|
194
|
-
prefix,
|
|
195
|
-
typeStr,
|
|
196
|
-
annotations: []
|
|
197
|
-
});
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
if (entry.COMPTYPE === "E" && entry.ROLLNAME) {
|
|
201
|
-
const isKey = entry.KEYFLAG === "X";
|
|
202
|
-
const notNull = entry.NOTNULL === "X" || isKey;
|
|
203
|
-
const prefix = isKey ? `key ${fieldName.toLowerCase()}` : fieldName.toLowerCase();
|
|
204
|
-
const typeStr = notNull ? `${entry.ROLLNAME.toLowerCase()} not null` : entry.ROLLNAME.toLowerCase();
|
|
205
|
-
result.push({
|
|
206
|
-
kind: "field",
|
|
207
|
-
prefix,
|
|
208
|
-
typeStr,
|
|
209
|
-
annotations: []
|
|
210
|
-
});
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
const cdsType = buildCdsTypeString(entry);
|
|
214
|
-
if (!cdsType) continue;
|
|
215
|
-
const isKey = entry.KEYFLAG === "X";
|
|
216
|
-
const notNull = entry.NOTNULL === "X" || isKey;
|
|
217
|
-
const annotations = [];
|
|
218
|
-
if (entry.DATATYPE === "CURR" && entry.REFTABLE && entry.REFFIELD) {
|
|
219
|
-
const refTable = entry.REFTABLE.toUpperCase() === tableName.toUpperCase() ? tableName.toLowerCase() : entry.REFTABLE.toLowerCase();
|
|
220
|
-
annotations.push(`@Semantics.amount.currencyCode : '${refTable}.${entry.REFFIELD.toLowerCase()}'`);
|
|
221
|
-
} else if (entry.DATATYPE === "QUAN" && entry.REFTABLE && entry.REFFIELD) {
|
|
222
|
-
const refTable = entry.REFTABLE.toUpperCase() === tableName.toUpperCase() ? tableName.toLowerCase() : entry.REFTABLE.toLowerCase();
|
|
223
|
-
annotations.push(`@Semantics.quantity.unitOfMeasure : '${refTable}.${entry.REFFIELD.toLowerCase()}'`);
|
|
224
|
-
}
|
|
225
|
-
const prefix = isKey ? `key ${fieldName.toLowerCase()}` : fieldName.toLowerCase();
|
|
226
|
-
const typeStr = notNull ? `${cdsType} not null` : cdsType;
|
|
227
|
-
result.push({
|
|
228
|
-
kind: "field",
|
|
229
|
-
prefix,
|
|
230
|
-
typeStr,
|
|
231
|
-
annotations
|
|
232
|
-
});
|
|
219
|
+
for (const entry of entries) {
|
|
220
|
+
const info = buildMemberInfo(entry, tableName);
|
|
221
|
+
if (info) result.push(info);
|
|
233
222
|
}
|
|
234
223
|
return result;
|
|
235
224
|
}
|
|
@@ -365,10 +354,12 @@ const adtSchemaMap = {
|
|
|
365
354
|
* Passes through literal filenames unchanged.
|
|
366
355
|
*/
|
|
367
356
|
async function expandGlobs(patterns, cwd) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
357
|
+
return (await Promise.all(patterns.map(async (pattern) => {
|
|
358
|
+
const matches = [];
|
|
359
|
+
if (/[*?[\]{}]/.test(pattern)) for await (const match of glob(pattern, { cwd })) matches.push(match);
|
|
360
|
+
else matches.push(pattern);
|
|
361
|
+
return matches;
|
|
362
|
+
}))).flat();
|
|
372
363
|
}
|
|
373
364
|
/**
|
|
374
365
|
* Walk up from a directory to find the nearest ancestor containing .abapgit.xml.
|
|
@@ -505,202 +496,120 @@ function printDiff(localLabel, remoteLabel, localContent, remoteContent, context
|
|
|
505
496
|
}
|
|
506
497
|
return true;
|
|
507
498
|
}
|
|
508
|
-
/**
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
*/
|
|
512
|
-
async function diffSingleFile(filePath, ctx, adk, options) {
|
|
513
|
-
const { contextLines, useColor, source, raw, summary } = options;
|
|
514
|
-
const fullPath = resolve(ctx.cwd, filePath);
|
|
515
|
-
if (!existsSync(fullPath)) return {
|
|
516
|
-
objectName: filePath,
|
|
517
|
-
objectType: "?",
|
|
518
|
-
hasDifferences: false,
|
|
519
|
-
fileCount: 0,
|
|
520
|
-
identicalCount: 0,
|
|
521
|
-
error: `File not found: ${fullPath}`
|
|
522
|
-
};
|
|
523
|
-
const filename = basename(fullPath);
|
|
524
|
-
const parsed = parseAbapGitFilename(filename);
|
|
525
|
-
if (!parsed) return {
|
|
526
|
-
objectName: filename,
|
|
527
|
-
objectType: "?",
|
|
528
|
-
hasDifferences: false,
|
|
529
|
-
fileCount: 0,
|
|
530
|
-
identicalCount: 0,
|
|
531
|
-
error: `Cannot parse filename: ${filename}. Expected abapGit format: name.type.xml`
|
|
532
|
-
};
|
|
533
|
-
if (parsed.extension !== "xml") return {
|
|
534
|
-
objectName: parsed.name,
|
|
535
|
-
objectType: parsed.type,
|
|
536
|
-
hasDifferences: false,
|
|
537
|
-
fileCount: 0,
|
|
538
|
-
identicalCount: 0,
|
|
539
|
-
error: `Expected .xml metadata file, got .${parsed.extension}. Pass the .xml file, not .abap.`
|
|
540
|
-
};
|
|
541
|
-
if (source && parsed.type !== "TABL") return {
|
|
542
|
-
objectName: parsed.name,
|
|
543
|
-
objectType: parsed.type,
|
|
544
|
-
hasDifferences: false,
|
|
545
|
-
fileCount: 0,
|
|
546
|
-
identicalCount: 0,
|
|
547
|
-
error: `Source format is only supported for TABL objects. Got: ${parsed.type}`
|
|
548
|
-
};
|
|
549
|
-
if (source && raw) return {
|
|
499
|
+
/** Build an error DiffResult. */
|
|
500
|
+
function errorResult(parsed, error, fileCount = 0) {
|
|
501
|
+
return {
|
|
550
502
|
objectName: parsed.name,
|
|
551
503
|
objectType: parsed.type,
|
|
552
504
|
hasDifferences: false,
|
|
553
|
-
fileCount
|
|
505
|
+
fileCount,
|
|
554
506
|
identicalCount: 0,
|
|
555
|
-
error
|
|
507
|
+
error
|
|
556
508
|
};
|
|
557
|
-
|
|
558
|
-
|
|
509
|
+
}
|
|
510
|
+
/** Result for a single compared file in source/raw mode. */
|
|
511
|
+
function modeResult(parsed, diffFound) {
|
|
512
|
+
return {
|
|
559
513
|
objectName: parsed.name,
|
|
560
514
|
objectType: parsed.type,
|
|
561
|
-
hasDifferences:
|
|
562
|
-
fileCount:
|
|
563
|
-
identicalCount: 0
|
|
564
|
-
error: `Unsupported object type: ${parsed.type}. Supported: ${getSupportedTypes().join(", ")}`
|
|
515
|
+
hasDifferences: diffFound,
|
|
516
|
+
fileCount: 1,
|
|
517
|
+
identicalCount: diffFound ? 0 : 1
|
|
565
518
|
};
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
519
|
+
}
|
|
520
|
+
/** Error message when the --source/--raw mode options are invalid. */
|
|
521
|
+
function modeOptionsError(parsed, source, raw) {
|
|
522
|
+
if (source && parsed.type !== "TABL") return `Source format is only supported for TABL objects. Got: ${parsed.type}`;
|
|
523
|
+
if (source && raw) return "--source and --raw are mutually exclusive";
|
|
524
|
+
}
|
|
525
|
+
/** Derive the ADK type from the local XML via fromAbapGit (fallback: filename). */
|
|
526
|
+
function resolveAdkType(handler, localXml, fallback) {
|
|
527
|
+
if (!handler.fromAbapGit) return fallback;
|
|
528
|
+
try {
|
|
572
529
|
const values = handler.schema.parse(localXml)?.abapGit?.abap?.values ?? {};
|
|
573
530
|
const payload = handler.fromAbapGit(values);
|
|
574
|
-
if (typeof payload.type === "string")
|
|
531
|
+
if (typeof payload.type === "string") return payload.type;
|
|
575
532
|
} catch {}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
533
|
+
return fallback;
|
|
534
|
+
}
|
|
535
|
+
/** Announce the object being diffed. */
|
|
536
|
+
function printDiffBanner(parsed, fileCount, useColor) {
|
|
537
|
+
console.log(`\n${useColor ? chalk.bold("Diff:") : "Diff:"} ${parsed.name} (${parsed.type}) — ${fileCount} file(s)`);
|
|
538
|
+
}
|
|
539
|
+
/** Announce the remote fetch. */
|
|
540
|
+
function printFetchBanner(parsed, adkType, useColor) {
|
|
541
|
+
console.log(`${useColor ? chalk.dim("Fetching") : "Fetching"} ${parsed.name} (${adkType}) from SAP...`);
|
|
542
|
+
}
|
|
543
|
+
/** Announce a path that exists on only one side. */
|
|
544
|
+
function printOnlyIn(side, path, useColor, summary) {
|
|
545
|
+
if (summary) return;
|
|
546
|
+
const line = `\n ${side === "local" ? "+" : "-"} Only in ${side}: ${path}`;
|
|
547
|
+
console.log(useColor ? chalk.yellow(line) : line);
|
|
548
|
+
}
|
|
549
|
+
/** Compare one local/remote content pair (XML pairs are normalized first). */
|
|
550
|
+
function diffOnePair(localPath, localContent, remoteContent, handler, options) {
|
|
551
|
+
const isXml = localPath.endsWith(".xml");
|
|
552
|
+
let diffLocal = localContent;
|
|
553
|
+
let diffRemote = remoteContent;
|
|
554
|
+
if (isXml) [diffLocal, diffRemote] = normalizeXmlPair(localContent, remoteContent, handler);
|
|
555
|
+
return printDiff(localPath, localPath, diffLocal, diffRemote, options.contextLines, options.useColor, options.summary);
|
|
556
|
+
}
|
|
557
|
+
/** Source format: compare ADK source (e.g. CDS DDL). */
|
|
558
|
+
async function diffSourceMode(parsed, localXml, objectName, remoteObj, options) {
|
|
559
|
+
const { contextLines, useColor, summary } = options;
|
|
560
|
+
const localSource = tablXmlToCdsDdl(localXml);
|
|
561
|
+
let remoteSource;
|
|
587
562
|
try {
|
|
588
|
-
await remoteObj.
|
|
563
|
+
remoteSource = await remoteObj.getSource();
|
|
589
564
|
} catch (error) {
|
|
590
|
-
return {
|
|
591
|
-
objectName: parsed.name,
|
|
592
|
-
objectType: parsed.type,
|
|
593
|
-
hasDifferences: false,
|
|
594
|
-
fileCount: localFiles.size,
|
|
595
|
-
identicalCount: 0,
|
|
596
|
-
error: `Failed to load remote object: ${error instanceof Error ? error.message : String(error)}`
|
|
597
|
-
};
|
|
565
|
+
return errorResult(parsed, `Failed to fetch remote source: ${error instanceof Error ? error.message : String(error)}`, 1);
|
|
598
566
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
const sourceFile = `${objectName}.tabl.acds`;
|
|
621
|
-
const diffFound = printDiff(sourceFile, sourceFile, localSource, remoteSource, contextLines, useColor, summary);
|
|
622
|
-
return {
|
|
623
|
-
objectName: parsed.name,
|
|
624
|
-
objectType: parsed.type,
|
|
625
|
-
hasDifferences: diffFound,
|
|
626
|
-
fileCount: 1,
|
|
627
|
-
identicalCount: diffFound ? 0 : 1
|
|
628
|
-
};
|
|
567
|
+
const localAnnotations = new Set(localSource.split("\n").filter((l) => l.startsWith("@")).map((l) => l.split(":")[0].trim()));
|
|
568
|
+
remoteSource = remoteSource.split("\n").filter((l) => {
|
|
569
|
+
if (!l.startsWith("@")) return true;
|
|
570
|
+
const name = l.split(":")[0].trim();
|
|
571
|
+
return localAnnotations.has(name);
|
|
572
|
+
}).join("\n");
|
|
573
|
+
const sourceFile = `${objectName}.tabl.acds`;
|
|
574
|
+
return modeResult(parsed, printDiff(sourceFile, sourceFile, localSource, remoteSource, contextLines, useColor, summary));
|
|
575
|
+
}
|
|
576
|
+
/** Raw mode: compare ADT-level XML payloads. */
|
|
577
|
+
async function diffRawMode(parsed, localXml, objectName, handler, remoteObj, options) {
|
|
578
|
+
const { contextLines, useColor, summary } = options;
|
|
579
|
+
const adtSchema = adtSchemaMap[parsed.type];
|
|
580
|
+
if (!adtSchema) return errorResult(parsed, `Raw mode not supported for ${parsed.type}: no ADT schema mapping. Supported: ${Object.keys(adtSchemaMap).join(", ")}`, 1);
|
|
581
|
+
const { schema: rawSchema, wrapperKey } = adtSchema;
|
|
582
|
+
let remoteAdtXml;
|
|
583
|
+
try {
|
|
584
|
+
const remoteData = await remoteObj.data();
|
|
585
|
+
remoteAdtXml = rawSchema.build({ [wrapperKey]: remoteData }, { pretty: true });
|
|
586
|
+
} catch (e) {
|
|
587
|
+
return errorResult(parsed, `Failed to build remote ADT XML: ${e instanceof Error ? e.message : String(e)}`, 1);
|
|
629
588
|
}
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
identicalCount: 0,
|
|
638
|
-
error: `Raw mode not supported for ${parsed.type}: no ADT schema mapping. Supported: ${Object.keys(adtSchemaMap).join(", ")}`
|
|
639
|
-
};
|
|
640
|
-
const { schema: rawSchema, wrapperKey } = adtSchema;
|
|
641
|
-
let remoteAdtXml;
|
|
642
|
-
try {
|
|
643
|
-
const remoteData = await remoteObj.data();
|
|
644
|
-
remoteAdtXml = rawSchema.build({ [wrapperKey]: remoteData }, { pretty: true });
|
|
645
|
-
} catch (e) {
|
|
646
|
-
return {
|
|
647
|
-
objectName: parsed.name,
|
|
648
|
-
objectType: parsed.type,
|
|
649
|
-
hasDifferences: false,
|
|
650
|
-
fileCount: 1,
|
|
651
|
-
identicalCount: 0,
|
|
652
|
-
error: `Failed to build remote ADT XML: ${e instanceof Error ? e.message : String(e)}`
|
|
653
|
-
};
|
|
654
|
-
}
|
|
655
|
-
let localAdtXml;
|
|
656
|
-
if (handler.fromAbapGit) try {
|
|
657
|
-
const values = handler.schema.parse(localXml)?.abapGit?.abap?.values ?? {};
|
|
658
|
-
const localPayload = handler.fromAbapGit(values);
|
|
659
|
-
const merged = {
|
|
660
|
-
...await remoteObj.data(),
|
|
661
|
-
...localPayload
|
|
662
|
-
};
|
|
663
|
-
localAdtXml = rawSchema.build({ [wrapperKey]: merged }, { pretty: true });
|
|
664
|
-
} catch (e) {
|
|
665
|
-
return {
|
|
666
|
-
objectName: parsed.name,
|
|
667
|
-
objectType: parsed.type,
|
|
668
|
-
hasDifferences: false,
|
|
669
|
-
fileCount: 1,
|
|
670
|
-
identicalCount: 0,
|
|
671
|
-
error: `Failed to build local ADT XML: ${e instanceof Error ? e.message : String(e)}`
|
|
672
|
-
};
|
|
673
|
-
}
|
|
674
|
-
if (!localAdtXml) return {
|
|
675
|
-
objectName: parsed.name,
|
|
676
|
-
objectType: parsed.type,
|
|
677
|
-
hasDifferences: false,
|
|
678
|
-
fileCount: 1,
|
|
679
|
-
identicalCount: 0,
|
|
680
|
-
error: `Raw mode not supported for ${parsed.type}: no fromAbapGit() mapping`
|
|
681
|
-
};
|
|
682
|
-
const xmlFile = `${objectName}.${parsed.type.toLowerCase()}.adt.xml`;
|
|
683
|
-
const diffFound = printDiff(xmlFile, xmlFile, localAdtXml, remoteAdtXml, contextLines, useColor, summary);
|
|
684
|
-
return {
|
|
685
|
-
objectName: parsed.name,
|
|
686
|
-
objectType: parsed.type,
|
|
687
|
-
hasDifferences: diffFound,
|
|
688
|
-
fileCount: 1,
|
|
689
|
-
identicalCount: diffFound ? 0 : 1
|
|
589
|
+
let localAdtXml;
|
|
590
|
+
if (handler.fromAbapGit) try {
|
|
591
|
+
const values = handler.schema.parse(localXml)?.abapGit?.abap?.values ?? {};
|
|
592
|
+
const localPayload = handler.fromAbapGit(values);
|
|
593
|
+
const merged = {
|
|
594
|
+
...await remoteObj.data(),
|
|
595
|
+
...localPayload
|
|
690
596
|
};
|
|
597
|
+
localAdtXml = rawSchema.build({ [wrapperKey]: merged }, { pretty: true });
|
|
598
|
+
} catch (e) {
|
|
599
|
+
return errorResult(parsed, `Failed to build local ADT XML: ${e instanceof Error ? e.message : String(e)}`, 1);
|
|
691
600
|
}
|
|
601
|
+
if (!localAdtXml) return errorResult(parsed, `Raw mode not supported for ${parsed.type}: no fromAbapGit() mapping`, 1);
|
|
602
|
+
const xmlFile = `${objectName}.${parsed.type.toLowerCase()}.adt.xml`;
|
|
603
|
+
return modeResult(parsed, printDiff(xmlFile, xmlFile, localAdtXml, remoteAdtXml, contextLines, useColor, summary));
|
|
604
|
+
}
|
|
605
|
+
/** Serialize remote with the handler and diff it file-by-file. */
|
|
606
|
+
async function diffFilesMode(parsed, localFiles, handler, remoteObj, options) {
|
|
607
|
+
const { contextLines, useColor, summary } = options;
|
|
692
608
|
let remoteFiles;
|
|
693
609
|
try {
|
|
694
610
|
remoteFiles = await handler.serialize(remoteObj);
|
|
695
611
|
} catch (error) {
|
|
696
|
-
return {
|
|
697
|
-
objectName: parsed.name,
|
|
698
|
-
objectType: parsed.type,
|
|
699
|
-
hasDifferences: false,
|
|
700
|
-
fileCount: localFiles.size,
|
|
701
|
-
identicalCount: 0,
|
|
702
|
-
error: `Failed to serialize remote object: ${error instanceof Error ? error.message : String(error)}`
|
|
703
|
-
};
|
|
612
|
+
return errorResult(parsed, `Failed to serialize remote object: ${error instanceof Error ? error.message : String(error)}`, localFiles.size);
|
|
704
613
|
}
|
|
705
614
|
const remoteMap = /* @__PURE__ */ new Map();
|
|
706
615
|
for (const f of remoteFiles) remoteMap.set(f.path.toLowerCase(), f.content);
|
|
@@ -709,19 +618,19 @@ async function diffSingleFile(filePath, ctx, adk, options) {
|
|
|
709
618
|
for (const [localPath, localContent] of localFiles) {
|
|
710
619
|
const remoteContent = remoteMap.get(localPath);
|
|
711
620
|
if (remoteContent === void 0) {
|
|
712
|
-
|
|
621
|
+
printOnlyIn("local", localPath, useColor, summary);
|
|
713
622
|
hasDifferences = true;
|
|
714
623
|
continue;
|
|
715
624
|
}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
625
|
+
if (diffOnePair(localPath, localContent, remoteContent, handler, {
|
|
626
|
+
contextLines,
|
|
627
|
+
useColor,
|
|
628
|
+
summary
|
|
629
|
+
})) hasDifferences = true;
|
|
721
630
|
else identicalCount++;
|
|
722
631
|
}
|
|
723
632
|
for (const [remotePath] of remoteMap) if (!localFiles.has(remotePath)) {
|
|
724
|
-
|
|
633
|
+
printOnlyIn("remote", remotePath, useColor, summary);
|
|
725
634
|
hasDifferences = true;
|
|
726
635
|
}
|
|
727
636
|
return {
|
|
@@ -732,6 +641,135 @@ async function diffSingleFile(filePath, ctx, adk, options) {
|
|
|
732
641
|
identicalCount
|
|
733
642
|
};
|
|
734
643
|
}
|
|
644
|
+
/**
|
|
645
|
+
* Diff a single abapGit XML file against SAP remote.
|
|
646
|
+
* Returns a result object indicating whether differences were found.
|
|
647
|
+
*/
|
|
648
|
+
async function diffSingleFile(filePath, ctx, adk, options) {
|
|
649
|
+
const { source, raw, summary, useColor } = options;
|
|
650
|
+
const fullPath = resolve(ctx.cwd, filePath);
|
|
651
|
+
if (!existsSync(fullPath)) return errorResult({
|
|
652
|
+
name: filePath,
|
|
653
|
+
type: "?"
|
|
654
|
+
}, `File not found: ${fullPath}`);
|
|
655
|
+
const filename = basename(fullPath);
|
|
656
|
+
const parsed = parseAbapGitFilename(filename);
|
|
657
|
+
if (!parsed) return errorResult({
|
|
658
|
+
name: filename,
|
|
659
|
+
type: "?"
|
|
660
|
+
}, `Cannot parse filename: ${filename}. Expected abapGit format: name.type.xml`);
|
|
661
|
+
if (parsed.extension !== "xml") return errorResult(parsed, `Expected .xml metadata file, got .${parsed.extension}. Pass the .xml file, not .abap.`);
|
|
662
|
+
const modeError = modeOptionsError(parsed, source, raw);
|
|
663
|
+
if (modeError) return errorResult(parsed, modeError);
|
|
664
|
+
const handler = getHandler(parsed.type);
|
|
665
|
+
if (!handler) return errorResult(parsed, `Unsupported object type: ${parsed.type}. Supported: ${getSupportedTypes().join(", ")}`);
|
|
666
|
+
const objectName = parsed.name.toLowerCase();
|
|
667
|
+
const localFiles = collectLocalFiles(fullPath, objectName, handler.fileExtension);
|
|
668
|
+
if (!summary) printDiffBanner(parsed, localFiles.size, useColor);
|
|
669
|
+
const localXml = readFileSync(fullPath, "utf-8");
|
|
670
|
+
const adkType = resolveAdkType(handler, localXml, parsed.type);
|
|
671
|
+
if (!summary) printFetchBanner(parsed, adkType, useColor);
|
|
672
|
+
const remoteObjRaw = adk.get(parsed.name, adkType);
|
|
673
|
+
if (!(remoteObjRaw instanceof AdkObject)) return errorResult(parsed, `Unsupported ADK type: ${adkType} (no registered handler)`, localFiles.size);
|
|
674
|
+
const remoteObj = remoteObjRaw;
|
|
675
|
+
try {
|
|
676
|
+
await remoteObj.load();
|
|
677
|
+
} catch (error) {
|
|
678
|
+
return errorResult(parsed, `Failed to load remote object: ${error instanceof Error ? error.message : String(error)}`, localFiles.size);
|
|
679
|
+
}
|
|
680
|
+
if (source) return diffSourceMode(parsed, localXml, objectName, remoteObj, options);
|
|
681
|
+
if (raw) return diffRawMode(parsed, localXml, objectName, handler, remoteObj, options);
|
|
682
|
+
return diffFilesMode(parsed, localFiles, handler, remoteObj, options);
|
|
683
|
+
}
|
|
684
|
+
/** Expand explicit globs, or scan the abapGit repo when no files are given. */
|
|
685
|
+
async function resolveDiffFiles(filePatterns, ctx, packageName) {
|
|
686
|
+
if (filePatterns.length > 0) {
|
|
687
|
+
const files = await expandGlobs(filePatterns, ctx.cwd);
|
|
688
|
+
if (files.length === 0) {
|
|
689
|
+
ctx.logger.error("No files matched the given pattern(s).");
|
|
690
|
+
process.exit(1);
|
|
691
|
+
}
|
|
692
|
+
return {
|
|
693
|
+
files,
|
|
694
|
+
scanMode: false
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
const repoRoot = findAbapGitRoot(ctx.cwd);
|
|
698
|
+
if (!repoRoot) {
|
|
699
|
+
ctx.logger.error(packageName ? "No .abapgit.xml found in current directory or parents." : "No files specified and no .abapgit.xml found. Usage: adt diff <file...> or run from an abapGit repo directory.");
|
|
700
|
+
process.exit(1);
|
|
701
|
+
}
|
|
702
|
+
const scannedFiles = await scanAbapGitFiles(repoRoot);
|
|
703
|
+
if (scannedFiles.length === 0) {
|
|
704
|
+
ctx.logger.error("No supported abapGit objects found in repository.");
|
|
705
|
+
process.exit(1);
|
|
706
|
+
}
|
|
707
|
+
const files = scannedFiles.map((f) => relative(ctx.cwd, join(repoRoot, f)));
|
|
708
|
+
const pkgSuffix = packageName ? ` (package: ${packageName})` : "";
|
|
709
|
+
ctx.logger.info(`📦 Scanning ${scannedFiles.length} object(s) in ${repoRoot}${pkgSuffix}...`);
|
|
710
|
+
return {
|
|
711
|
+
files,
|
|
712
|
+
scanMode: true
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
/** Per-object status table for scan mode. */
|
|
716
|
+
function printScanTable(results, useColor) {
|
|
717
|
+
for (const r of results) {
|
|
718
|
+
let icon;
|
|
719
|
+
let line;
|
|
720
|
+
if (r.error) {
|
|
721
|
+
icon = "⚠️";
|
|
722
|
+
line = `${r.objectType} ${r.objectName}: ${r.error}`;
|
|
723
|
+
} else if (r.hasDifferences) {
|
|
724
|
+
icon = "❌";
|
|
725
|
+
line = `${r.objectType} ${r.objectName}`;
|
|
726
|
+
} else {
|
|
727
|
+
icon = "✅";
|
|
728
|
+
line = `${r.objectType} ${r.objectName}`;
|
|
729
|
+
}
|
|
730
|
+
if (useColor) {
|
|
731
|
+
if (r.error) console.log(chalk.yellow(` ${icon} ${line}`));
|
|
732
|
+
else if (r.hasDifferences) console.log(chalk.red(` ${icon} ${line}`));
|
|
733
|
+
else console.log(chalk.green(` ${icon} ${line}`));
|
|
734
|
+
} else console.log(` ${icon} ${line}`);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
/** Scan-mode summary line; exits 1 when anything changed or failed. */
|
|
738
|
+
function printScanSummary(totalFiles, identical, withDiffs, withErrors, useColor) {
|
|
739
|
+
console.log("");
|
|
740
|
+
const summaryParts = [`${totalFiles} object(s)`, `${identical} identical`];
|
|
741
|
+
if (withDiffs > 0) summaryParts.push(`${withDiffs} changed`);
|
|
742
|
+
if (withErrors > 0) summaryParts.push(`${withErrors} errors`);
|
|
743
|
+
const summaryLine = summaryParts.join(", ");
|
|
744
|
+
if (withDiffs > 0 || withErrors > 0) {
|
|
745
|
+
console.log(useColor ? chalk.red(`📋 ${summaryLine}`) : `📋 ${summaryLine}`);
|
|
746
|
+
process.exit(1);
|
|
747
|
+
}
|
|
748
|
+
console.log(useColor ? chalk.green(`📋 ${summaryLine}`) : `📋 ${summaryLine}`);
|
|
749
|
+
}
|
|
750
|
+
/** Single-file mode: keep original concise output. Exits 1 on diff/error. */
|
|
751
|
+
function printSingleFileOutcome(r, useColor) {
|
|
752
|
+
if (r.error) process.exit(1);
|
|
753
|
+
if (r.hasDifferences) {
|
|
754
|
+
const identicalSuffix = r.identicalCount > 0 ? ` (${r.identicalCount} file(s) identical)` : "";
|
|
755
|
+
const coloredSuffix = r.identicalCount > 0 ? chalk.dim(identicalSuffix) : "";
|
|
756
|
+
console.log(useColor ? chalk.red("Differences found.") + coloredSuffix : `Differences found.${identicalSuffix}`);
|
|
757
|
+
process.exit(1);
|
|
758
|
+
}
|
|
759
|
+
console.log(useColor ? chalk.green(`No differences found. (${r.identicalCount} file(s) identical)`) : `No differences found. (${r.identicalCount} file(s) identical)`);
|
|
760
|
+
}
|
|
761
|
+
/** Multi-file summary (explicit glob, not scan mode). Exits 1 on diff/error. */
|
|
762
|
+
function printMultiFileOutcome(totalFiles, identical, withDiffs, withErrors, useColor) {
|
|
763
|
+
const parts = [`${totalFiles} object(s) checked`, `${identical} identical`];
|
|
764
|
+
if (withDiffs > 0) parts.push(`${withDiffs} with differences`);
|
|
765
|
+
if (withErrors > 0) parts.push(`${withErrors} with errors`);
|
|
766
|
+
const summaryText = parts.join(", ");
|
|
767
|
+
if (withDiffs > 0 || withErrors > 0) {
|
|
768
|
+
console.log(useColor ? chalk.red(`Diff summary: ${summaryText}`) : `Diff summary: ${summaryText}`);
|
|
769
|
+
process.exit(1);
|
|
770
|
+
}
|
|
771
|
+
console.log(useColor ? chalk.green(`Diff summary: ${summaryText}`) : `Diff summary: ${summaryText}`);
|
|
772
|
+
}
|
|
735
773
|
const diffCommand = {
|
|
736
774
|
name: "diff",
|
|
737
775
|
description: "Compare local abapGit files against SAP remote (any supported object type)",
|
|
@@ -774,31 +812,7 @@ const diffCommand = {
|
|
|
774
812
|
const raw = args.raw === true;
|
|
775
813
|
const packageName = args.package;
|
|
776
814
|
const fullDiffs = args.full === true;
|
|
777
|
-
|
|
778
|
-
let scanMode = false;
|
|
779
|
-
let repoRoot;
|
|
780
|
-
if (filePatterns.length > 0) {
|
|
781
|
-
files = await expandGlobs(filePatterns, ctx.cwd);
|
|
782
|
-
if (files.length === 0) {
|
|
783
|
-
ctx.logger.error("No files matched the given pattern(s).");
|
|
784
|
-
process.exit(1);
|
|
785
|
-
}
|
|
786
|
-
} else {
|
|
787
|
-
repoRoot = findAbapGitRoot(ctx.cwd);
|
|
788
|
-
if (!repoRoot) {
|
|
789
|
-
ctx.logger.error(packageName ? "No .abapgit.xml found in current directory or parents." : "No files specified and no .abapgit.xml found. Usage: adt diff <file...> or run from an abapGit repo directory.");
|
|
790
|
-
process.exit(1);
|
|
791
|
-
}
|
|
792
|
-
scanMode = true;
|
|
793
|
-
const scannedFiles = await scanAbapGitFiles(repoRoot);
|
|
794
|
-
if (scannedFiles.length === 0) {
|
|
795
|
-
ctx.logger.error("No supported abapGit objects found in repository.");
|
|
796
|
-
process.exit(1);
|
|
797
|
-
}
|
|
798
|
-
files = scannedFiles.map((f) => relative(ctx.cwd, join(repoRoot, f)));
|
|
799
|
-
const pkgSuffix = packageName ? ` (package: ${packageName})` : "";
|
|
800
|
-
ctx.logger.info(`📦 Scanning ${scannedFiles.length} object(s) in ${repoRoot}${pkgSuffix}...`);
|
|
801
|
-
}
|
|
815
|
+
const { files, scanMode } = await resolveDiffFiles(filePatterns, ctx, packageName);
|
|
802
816
|
const summaryMode = scanMode && !fullDiffs;
|
|
803
817
|
if (!ctx.getAdtClient) {
|
|
804
818
|
ctx.logger.error("ADT client not available. Run: adt auth login");
|
|
@@ -824,59 +838,17 @@ const diffCommand = {
|
|
|
824
838
|
const identical = totalFiles - withDiffs - withErrors;
|
|
825
839
|
console.log("");
|
|
826
840
|
if (scanMode) {
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
let line;
|
|
830
|
-
if (r.error) {
|
|
831
|
-
icon = "⚠️";
|
|
832
|
-
line = `${r.objectType} ${r.objectName}: ${r.error}`;
|
|
833
|
-
} else if (r.hasDifferences) {
|
|
834
|
-
icon = "❌";
|
|
835
|
-
line = `${r.objectType} ${r.objectName}`;
|
|
836
|
-
} else {
|
|
837
|
-
icon = "✅";
|
|
838
|
-
line = `${r.objectType} ${r.objectName}`;
|
|
839
|
-
}
|
|
840
|
-
if (useColor) {
|
|
841
|
-
if (r.error) console.log(chalk.yellow(` ${icon} ${line}`));
|
|
842
|
-
else if (r.hasDifferences) console.log(chalk.red(` ${icon} ${line}`));
|
|
843
|
-
else console.log(chalk.green(` ${icon} ${line}`));
|
|
844
|
-
} else console.log(` ${icon} ${line}`);
|
|
845
|
-
}
|
|
846
|
-
console.log("");
|
|
847
|
-
const summaryParts = [`${totalFiles} object(s)`, `${identical} identical`];
|
|
848
|
-
if (withDiffs > 0) summaryParts.push(`${withDiffs} changed`);
|
|
849
|
-
if (withErrors > 0) summaryParts.push(`${withErrors} errors`);
|
|
850
|
-
const summaryLine = summaryParts.join(", ");
|
|
851
|
-
if (withDiffs > 0 || withErrors > 0) {
|
|
852
|
-
console.log(useColor ? chalk.red(`📋 ${summaryLine}`) : `📋 ${summaryLine}`);
|
|
853
|
-
process.exit(1);
|
|
854
|
-
}
|
|
855
|
-
console.log(useColor ? chalk.green(`📋 ${summaryLine}`) : `📋 ${summaryLine}`);
|
|
841
|
+
printScanTable(results, useColor);
|
|
842
|
+
printScanSummary(totalFiles, identical, withDiffs, withErrors, useColor);
|
|
856
843
|
return;
|
|
857
844
|
}
|
|
858
845
|
if (totalFiles === 1) {
|
|
859
|
-
|
|
860
|
-
if (r.error) process.exit(1);
|
|
861
|
-
if (r.hasDifferences) {
|
|
862
|
-
const identicalSuffix = r.identicalCount > 0 ? ` (${r.identicalCount} file(s) identical)` : "";
|
|
863
|
-
console.log(useColor ? chalk.red("Differences found.") + (r.identicalCount > 0 ? chalk.dim(identicalSuffix) : "") : `Differences found.${identicalSuffix}`);
|
|
864
|
-
process.exit(1);
|
|
865
|
-
}
|
|
866
|
-
console.log(useColor ? chalk.green(`No differences found. (${r.identicalCount} file(s) identical)`) : `No differences found. (${r.identicalCount} file(s) identical)`);
|
|
846
|
+
printSingleFileOutcome(results[0], useColor);
|
|
867
847
|
return;
|
|
868
848
|
}
|
|
869
|
-
|
|
870
|
-
if (withDiffs > 0) parts.push(`${withDiffs} with differences`);
|
|
871
|
-
if (withErrors > 0) parts.push(`${withErrors} with errors`);
|
|
872
|
-
const summaryText = parts.join(", ");
|
|
873
|
-
if (withDiffs > 0 || withErrors > 0) {
|
|
874
|
-
console.log(useColor ? chalk.red(`Diff summary: ${summaryText}`) : `Diff summary: ${summaryText}`);
|
|
875
|
-
process.exit(1);
|
|
876
|
-
}
|
|
877
|
-
console.log(useColor ? chalk.green(`Diff summary: ${summaryText}`) : `Diff summary: ${summaryText}`);
|
|
849
|
+
printMultiFileOutcome(totalFiles, identical, withDiffs, withErrors, useColor);
|
|
878
850
|
}
|
|
879
851
|
};
|
|
880
852
|
export { tablXmlToCdsDdl as i, buildCdsDdl as n, parseTablXml as r, diffCommand as t };
|
|
881
853
|
|
|
882
|
-
//# sourceMappingURL=diff-
|
|
854
|
+
//# sourceMappingURL=diff-BNaZOwe9.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-BNaZOwe9.mjs","names":["nativeGlob"],"sources":["../src/lib/abapgit-to-cds.ts","../src/commands/diff.ts"],"sourcesContent":["/**\n * abapGit DD02V/DD03P → CDS DDL Source Builder\n *\n * Reverse mapping of cds-to-abapgit.ts — reconstructs CDS DDL source code\n * from parsed abapGit XML data (DD02V header + DD03P field entries).\n *\n * Used by `adt diff` to compare local abapGit serialized files against\n * SAP remote CDS source fetched via ADT /source/main endpoint.\n */\n\n// ============================================\n// DD02V / DD03P input types\n// (mirror of cds-to-abapgit.ts output types)\n// ============================================\n\nexport interface DD02VData {\n TABNAME?: string;\n DDLANGUAGE?: string;\n TABCLASS?: string;\n LANGDEP?: string;\n DDTEXT?: string;\n MASTERLANG?: string;\n CONTFLAG?: string;\n EXCLASS?: string;\n AUTHCLASS?: string;\n CLIDEP?: string;\n BUFFERED?: string;\n MATEFLAG?: string;\n SHLPEXI?: string;\n}\n\nexport interface DD03PData {\n FIELDNAME?: string;\n POSITION?: string;\n KEYFLAG?: string;\n ROLLNAME?: string;\n ADMINFIELD?: string;\n INTTYPE?: string;\n INTLEN?: string;\n NOTNULL?: string;\n DATATYPE?: string;\n LENG?: string;\n DECIMALS?: string;\n SHLPORIGIN?: string;\n MASK?: string;\n COMPTYPE?: string;\n REFTABLE?: string;\n REFFIELD?: string;\n PRECFIELD?: string;\n DDTEXT?: string;\n DOMNAME?: string;\n}\n\n// ============================================\n// Reverse mapping tables\n// ============================================\n\n/** DDIC DATATYPE → CDS abap.<type> name */\nconst DATATYPE_TO_CDS: Record<string, string> = {\n CHAR: 'char',\n CLNT: 'clnt',\n NUMC: 'numc',\n DATS: 'dats',\n DATN: 'datn',\n TIMS: 'tims',\n TIMN: 'timn',\n DEC: 'dec',\n CURR: 'curr',\n QUAN: 'quan',\n RAW: 'raw',\n INT1: 'int1',\n INT2: 'int2',\n INT4: 'int4',\n INT8: 'int8',\n FLTP: 'fltp',\n STRG: 'string',\n RSTR: 'rawstring',\n CUKY: 'cuky',\n UNIT: 'unit',\n LANG: 'lang',\n ACCP: 'accp',\n PREC: 'prec',\n D16N: 'd16n',\n D34N: 'd34n',\n D16R: 'd16r',\n D34R: 'd34r',\n D16D: 'd16d',\n D34D: 'd34d',\n UTCL: 'utclong',\n SSTR: 'sstring',\n LCHR: 'lchr',\n LRAW: 'lraw',\n};\n\n/** Types that never take a length parameter in CDS */\nconst NO_LENGTH_TYPES = new Set([\n 'clnt',\n 'cuky',\n 'dats',\n 'datn',\n 'tims',\n 'timn',\n 'int1',\n 'int2',\n 'int4',\n 'int8',\n 'fltp',\n 'lang',\n 'accp',\n 'prec',\n 'd16n',\n 'd34n',\n 'd16r',\n 'd34r',\n 'utclong',\n]);\n\n/** Types that take decimals in CDS: abap.dec(len,dec) */\nconst DECIMAL_TYPES = new Set(['dec', 'curr', 'quan', 'fltp', 'd16d', 'd34d']);\n\n/** Types that are variable-length (string, rawstring) — length 0 is omitted */\nconst VARIABLE_LENGTH_TYPES = new Set(['string', 'rawstring']);\n\n/** DD02V EXCLASS → CDS @AbapCatalog.enhancement.category */\nconst ENHANCEMENT_CATEGORY_REVERSE: Record<string, string> = {\n '0': '#NOT_CLASSIFIED',\n '1': '#NOT_EXTENSIBLE',\n '2': '#EXTENSIBLE_CHARACTER_NUMERIC',\n '3': '#EXTENSIBLE_CHARACTER',\n '4': '#EXTENSIBLE_ANY',\n};\n\n/** DD02V CONTFLAG → CDS @AbapCatalog.deliveryClass */\nconst DELIVERY_CLASS_REVERSE: Record<string, string> = {\n A: '#A',\n C: '#C',\n L: '#L',\n G: '#G',\n E: '#E',\n S: '#S',\n W: '#W',\n};\n\n/** DD02V TABCLASS → CDS @AbapCatalog.tableCategory */\nconst TABLE_CATEGORY_REVERSE: Record<string, string> = {\n TRANSP: '#TRANSPARENT',\n CLUSTER: '#CLUSTER',\n POOL: '#POOL',\n APPEND: '#APPEND',\n};\n\n/** DD02V MATEFLAG → CDS @AbapCatalog.dataMaintenance */\nconst DATA_MAINTENANCE_REVERSE: Record<string, string> = {\n X: '#RESTRICTED',\n N: '#NOT_ALLOWED',\n '': '#ALLOWED',\n};\n\n// ============================================\n// Builder\n// ============================================\n\n/**\n * Push a reverse-mapped header annotation when the DDIC code has a CDS\n * meaning. `code` is the raw DDIC value (`''` is meaningful for some flags).\n */\nfunction pushMappedAnnotation(\n lines: string[],\n label: string,\n code: string | undefined,\n mapping: Record<string, string>,\n): void {\n const value = mapping[code ?? ''];\n if (value) {\n lines.push(`@${label} : ${value}`);\n }\n}\n\n/** Push the DD02V-derived header annotations. */\nfunction pushHeaderAnnotations(\n lines: string[],\n dd02v: DD02VData,\n isStructure: boolean,\n): void {\n if (dd02v.DDTEXT) {\n lines.push(\n `@EndUserText.label : '${escapeAnnotationString(dd02v.DDTEXT)}'`,\n );\n }\n\n pushMappedAnnotation(\n lines,\n 'AbapCatalog.enhancement.category',\n dd02v.EXCLASS,\n ENHANCEMENT_CATEGORY_REVERSE,\n );\n\n if (!isStructure) {\n // Table-specific annotations\n pushMappedAnnotation(\n lines,\n 'AbapCatalog.tableCategory',\n dd02v.TABCLASS,\n TABLE_CATEGORY_REVERSE,\n );\n pushMappedAnnotation(\n lines,\n 'AbapCatalog.deliveryClass',\n dd02v.CONTFLAG,\n DELIVERY_CLASS_REVERSE,\n );\n if (dd02v.MATEFLAG !== undefined) {\n pushMappedAnnotation(\n lines,\n 'AbapCatalog.dataMaintenance',\n dd02v.MATEFLAG,\n DATA_MAINTENANCE_REVERSE,\n );\n }\n }\n}\n\n/** Emit include/field lines, field names aligned to `maxNameWidth`. */\nfunction pushMemberLines(\n lines: string[],\n fieldInfos: MemberInfo[],\n maxNameWidth: number,\n): void {\n for (const info of fieldInfos) {\n if (info.kind === 'include') {\n if (info.suffix) {\n lines.push(` include ${info.name} with suffix ${info.suffix};`);\n } else {\n lines.push(` include ${info.name};`);\n }\n } else {\n // Field annotations (e.g., @Semantics.amount.currencyCode)\n for (const ann of info.annotations) {\n lines.push(` ${ann}`);\n }\n\n const paddedPrefix = info.prefix.padEnd(maxNameWidth);\n lines.push(` ${paddedPrefix} : ${info.typeStr};`);\n }\n }\n}\n\n/**\n * Build CDS DDL source from DD02V header and DD03P field entries.\n *\n * @param dd02v - Table/structure header data\n * @param dd03pEntries - Field entries (sorted by POSITION if present)\n * @returns CDS DDL source string\n */\nexport function buildCdsDdl(\n dd02v: DD02VData,\n dd03pEntries: DD03PData[],\n): string {\n const lines: string[] = [];\n const tableName = dd02v.TABNAME ?? '';\n const isStructure = dd02v.TABCLASS === 'INTTAB';\n\n // --- Annotations ---\n pushHeaderAnnotations(lines, dd02v, isStructure);\n\n // --- Definition header ---\n const keyword = isStructure ? 'define structure' : 'define table';\n lines.push(`${keyword} ${tableName.toLowerCase()} {`, ''); // Blank line after opening brace (SAP format)\n\n // --- Sort fields by POSITION ---\n const sorted = [...dd03pEntries].sort((a, b) => {\n const posA = Number.parseInt(a.POSITION ?? '0', 10);\n const posB = Number.parseInt(b.POSITION ?? '0', 10);\n return posA - posB;\n });\n\n // --- Compute alignment ---\n // Find max field name width for alignment (only field entries, not includes)\n const fieldInfos = buildFieldInfos(sorted, tableName);\n const maxNameWidth = Math.max(\n ...fieldInfos\n .filter((f): f is FieldInfo => f.kind === 'field')\n .map((f) => f.prefix.length),\n 0,\n );\n\n // --- Emit fields ---\n pushMemberLines(lines, fieldInfos, maxNameWidth);\n\n lines.push('', '}'); // Blank line before closing brace (SAP format)\n\n return lines.join('\\n') + '\\n'; // Trailing newline (SAP format)\n}\n\n// ============================================\n// Internal helpers\n// ============================================\n\ninterface FieldInfo {\n kind: 'field';\n /** \"key fieldname\" or \"fieldname\" — used for alignment */\n prefix: string;\n /** CDS type string (e.g., \"abap.char(10) not null\") */\n typeStr: string;\n /** Field-level annotations */\n annotations: string[];\n}\n\ninterface IncludeInfo {\n kind: 'include';\n name: string;\n /** Optional suffix for `include ... with suffix <suffix>` */\n suffix?: string;\n}\n\ntype MemberInfo = FieldInfo | IncludeInfo;\n\n/**\n * Assemble a field info from an already-rendered base type string, adding\n * the `key` prefix and `not null` suffix.\n */\nfunction buildTypedFieldInfo(\n fieldName: string,\n typeBase: string,\n entry: DD03PData,\n annotations: string[] = [],\n): FieldInfo {\n const isKey = entry.KEYFLAG === 'X';\n const notNull = entry.NOTNULL === 'X' || isKey;\n return {\n kind: 'field',\n prefix: isKey ? `key ${fieldName.toLowerCase()}` : fieldName.toLowerCase(),\n typeStr: notNull ? `${typeBase} not null` : typeBase,\n annotations,\n };\n}\n\n/** `@Semantics` annotations for CURR/QUAN fields with a reference table. */\nfunction semanticsAnnotations(entry: DD03PData, tableName: string): string[] {\n const annotations: string[] = [];\n\n // @Semantics annotations for CURR/QUAN fields\n if (entry.DATATYPE === 'CURR' && entry.REFTABLE && entry.REFFIELD) {\n const refTable =\n entry.REFTABLE.toUpperCase() === tableName.toUpperCase()\n ? tableName.toLowerCase()\n : entry.REFTABLE.toLowerCase();\n annotations.push(\n `@Semantics.amount.currencyCode : '${refTable}.${entry.REFFIELD.toLowerCase()}'`,\n );\n } else if (entry.DATATYPE === 'QUAN' && entry.REFTABLE && entry.REFFIELD) {\n const refTable =\n entry.REFTABLE.toUpperCase() === tableName.toUpperCase()\n ? tableName.toLowerCase()\n : entry.REFTABLE.toLowerCase();\n annotations.push(\n `@Semantics.quantity.unitOfMeasure : '${refTable}.${entry.REFFIELD.toLowerCase()}'`,\n );\n }\n\n return annotations;\n}\n\n/** Classify one DD03P entry into a field/include info (or nothing). */\nfunction buildMemberInfo(\n entry: DD03PData,\n tableName: string,\n): MemberInfo | null {\n const fieldName = entry.FIELDNAME ?? '';\n\n // .INCLU-<SUFFIX> entries → include with suffix\n if (fieldName.startsWith('.INCLU-')) {\n const includeName = entry.PRECFIELD ?? '';\n if (!includeName) return null;\n // Extract suffix from .INCLU-<SUFFIX> (e.g., \".INCLU-_XX\" → \"_xx\")\n const suffix = fieldName.slice('.INCLU-'.length).toLowerCase();\n return {\n kind: 'include',\n name: includeName.toLowerCase(),\n suffix,\n };\n }\n\n // Include directive → plain include\n if (fieldName === '.INCLUDE') {\n const includeName = entry.PRECFIELD ?? '';\n if (!includeName) return null;\n return {\n kind: 'include',\n name: includeName.toLowerCase(),\n };\n }\n\n // Structure-typed field (COMPTYPE = 'S', not an include)\n if (entry.COMPTYPE === 'S' && entry.DATATYPE === 'STRU') {\n const rollname = entry.ROLLNAME ?? fieldName;\n return buildTypedFieldInfo(fieldName, rollname.toLowerCase(), entry);\n }\n\n // Data element reference (COMPTYPE = 'E')\n if (entry.COMPTYPE === 'E' && entry.ROLLNAME) {\n return buildTypedFieldInfo(fieldName, entry.ROLLNAME.toLowerCase(), entry);\n }\n\n // Built-in type field\n const cdsType = buildCdsTypeString(entry);\n if (!cdsType) return null;\n\n return buildTypedFieldInfo(\n fieldName,\n cdsType,\n entry,\n semanticsAnnotations(entry, tableName),\n );\n}\n\n/**\n * Pre-process DD03P entries into structured field info for emission.\n */\nfunction buildFieldInfos(\n entries: DD03PData[],\n tableName: string,\n): MemberInfo[] {\n const result: MemberInfo[] = [];\n\n for (const entry of entries) {\n const info = buildMemberInfo(entry, tableName);\n if (info) result.push(info);\n }\n\n return result;\n}\n\n/**\n * Build the CDS type string from a DD03P entry.\n * E.g., \"abap.char(10)\", \"abap.dec(15,2)\", \"abap.int4\"\n */\nfunction buildCdsTypeString(entry: DD03PData): string | null {\n const datatype = entry.DATATYPE;\n if (!datatype) return null;\n\n const cdsName = DATATYPE_TO_CDS[datatype];\n if (!cdsName) return null;\n\n // Fixed-length types without parameters\n if (NO_LENGTH_TYPES.has(cdsName)) {\n return `abap.${cdsName}`;\n }\n\n // Parse LENG and DECIMALS (strip leading zeros)\n const leng = entry.LENG ? Number.parseInt(entry.LENG, 10) : undefined;\n const decimals = entry.DECIMALS\n ? Number.parseInt(entry.DECIMALS, 10)\n : undefined;\n\n // Variable-length types (string, rawstring)\n if (VARIABLE_LENGTH_TYPES.has(cdsName)) {\n if (leng && leng > 0) {\n return `abap.${cdsName}(${leng})`;\n }\n return `abap.${cdsName}(0)`;\n }\n\n // Types with decimals\n if (DECIMAL_TYPES.has(cdsName) && leng !== undefined) {\n const dec = decimals ?? 0;\n return `abap.${cdsName}(${leng},${dec})`;\n }\n\n // Types with length only\n if (leng !== undefined) {\n return `abap.${cdsName}(${leng})`;\n }\n\n // Fallback: no parameters\n return `abap.${cdsName}`;\n}\n\n/**\n * Escape single quotes in annotation string values\n */\nfunction escapeAnnotationString(value: string): string {\n return value.replaceAll(\"'\", \"''\");\n}\n\n// ============================================\n// XML parsing\n// ============================================\n\nimport { XMLParser } from 'fast-xml-parser';\n\nconst xmlParser = new XMLParser({\n ignoreAttributes: false,\n attributeNamePrefix: '@_',\n trimValues: true,\n parseTagValue: false,\n parseAttributeValue: false,\n removeNSPrefix: true,\n isArray: (name) => name === 'DD03P',\n});\n\n/**\n * Parse abapGit TABL XML content and extract DD02V/DD03P data.\n */\nexport function parseTablXml(xmlContent: string): {\n dd02v: DD02VData;\n dd03p: DD03PData[];\n} {\n const parsed = xmlParser.parse(xmlContent);\n const values = parsed?.abapGit?.abap?.values ?? {};\n\n const dd02v: DD02VData = values.DD02V ?? {};\n\n // DD03P can be inside DD03P_TABLE or directly as array\n let dd03pRaw = values.DD03P_TABLE?.DD03P ?? [];\n if (!Array.isArray(dd03pRaw)) {\n dd03pRaw = [dd03pRaw];\n }\n\n return { dd02v, dd03p: dd03pRaw };\n}\n\n// ============================================\n// Convenience: parse XML and build DDL\n// ============================================\n\n/**\n * Parse abapGit TABL XML and build CDS DDL source.\n *\n * @param xmlContent - Raw XML content of a .tabl.xml file\n * @returns CDS DDL source string\n */\nexport function tablXmlToCdsDdl(xmlContent: string): string {\n const { dd02v, dd03p } = parseTablXml(xmlContent);\n return buildCdsDdl(dd02v, dd03p);\n}\n","/**\n * Diff Command Plugin — Type-Agnostic\n *\n * Compares local abapGit files against what SAP has.\n *\n * The local file (from abapGit) is the source of truth — it defines which\n * fields matter. The remote side is fetched from SAP via ADT, serialized\n * through the same handler, then **projected** onto the local's field set.\n * Any extra fields the serializer adds (LANGDEP, POSITION, etc.) are\n * stripped so the diff only shows real value changes.\n *\n * For XML metadata: parse both → project remote onto local's keys → rebuild\n * For .abap source: compare text directly\n *\n * Works for ALL object types supported by adt-plugin-abapgit:\n * CLAS, INTF, PROG, FUGR, TABL, DOMA, DTEL, TTYP, DEVC\n *\n * Usage:\n * adt diff zage_structure.tabl.xml\n * adt diff *.tabl.xml\n * adt diff zcl_myclass.clas.xml --no-color\n */\n\nimport {\n requireFormatPlugin,\n getFormatPlugin,\n type CliCommandPlugin,\n type CliContext,\n type FormatHandler,\n type ParsedFormatFilename,\n} from '@abapify/adt-plugin';\nimport {\n createAdk,\n AdkObject,\n type AdtClient,\n type AdkFactory,\n} from '@abapify/adk';\nimport { readFileSync, existsSync, readdirSync } from 'node:fs';\nimport { glob as nativeGlob } from 'node:fs/promises';\nimport { resolve, basename, dirname, join, relative } from 'node:path';\nimport { createTwoFilesPatch } from 'diff';\nimport chalk from 'chalk';\n\n// abapGit is the only diff format today. The plugin registers itself on\n// import (see adt-cli/src/lib/cli.ts bootstrap).\nconst abapgit = () => requireFormatPlugin('abapgit');\nconst getHandler = (type: string): FormatHandler | undefined =>\n abapgit().getHandler(type);\n// Used in command `description` at module-load time — must be safe to call\n// before the bootstrap has registered the plugin (returns `[]` in that case;\n// the actual `execute` body always runs post-bootstrap).\nconst getSupportedTypes = (): string[] => [\n ...(getFormatPlugin('abapgit')?.supportedTypes ?? []),\n];\nconst parseAbapGitFilename = (filename: string): ParsedFormatFilename | null =>\n abapgit().parseFilename?.(filename) ?? null;\ntype ObjectHandler = FormatHandler;\nimport { tablXmlToCdsDdl } from '../lib/abapgit-to-cds';\nimport { adtContract } from '@abapify/adt-contracts';\n\n/**\n * ADT schema lookup for --raw mode.\n *\n * Maps abapGit type codes to raw CRUD contract schemas (NOT speci-proxied).\n * Each entry has:\n * - schema: the TypedSchema with .build() for XML serialization\n * - wrapperKey: the root element key expected by build()\n */\nconst adtSchemaMap: Record<\n string,\n {\n // The actual schemas are TypedSchema<T> from adt-schemas. Each has a\n // narrowly-typed build(data: T, ...) that is contravariantly incompatible\n // with a unified (data: unknown, ...) signature. We widen to `any` here\n // so the callers in this file (which know the wrapperKey) can pass the\n // correct shape. See FormatHandler<T, TSchema> in adt-plugin for the\n // same pattern.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: { build: (data: any, options?: { pretty?: boolean }) => string };\n wrapperKey: string;\n }\n> = {\n TTYP: {\n schema: adtContract.ddic.tabletypes.bodySchema,\n wrapperKey: 'tableType',\n },\n DOMA: { schema: adtContract.ddic.domains.bodySchema, wrapperKey: 'domain' },\n DTEL: {\n schema: adtContract.ddic.dataelements.bodySchema,\n wrapperKey: 'wbobj',\n },\n CLAS: { schema: adtContract.oo.classes.bodySchema, wrapperKey: 'abapClass' },\n INTF: {\n schema: adtContract.oo.interfaces.bodySchema,\n wrapperKey: 'abapInterface',\n },\n PROG: {\n schema: adtContract.programs.programs.bodySchema,\n wrapperKey: 'abapProgram',\n },\n FUGR: {\n schema: adtContract.functions.groups.bodySchema,\n wrapperKey: 'abapFunctionGroup',\n },\n DEVC: {\n schema: adtContract.packages.bodySchema,\n wrapperKey: 'package',\n },\n};\n\n/**\n * Expand glob patterns to matching file paths.\n * Passes through literal filenames unchanged.\n */\nasync function expandGlobs(patterns: string[], cwd: string): Promise<string[]> {\n const perPattern = await Promise.all(\n patterns.map(async (pattern) => {\n const matches: string[] = [];\n if (/[*?[\\]{}]/.test(pattern)) {\n for await (const match of nativeGlob(pattern, { cwd })) {\n matches.push(match);\n }\n } else {\n matches.push(pattern);\n }\n return matches;\n }),\n );\n return perPattern.flat();\n}\n\n/**\n * Walk up from a directory to find the nearest ancestor containing .abapgit.xml.\n * Returns the resolved absolute path to the repo root, or undefined if not found.\n */\nfunction findAbapGitRoot(startDir: string): string | undefined {\n let dir = resolve(startDir);\n const root = resolve('/');\n\n while (dir !== root) {\n if (existsSync(join(dir, '.abapgit.xml'))) {\n return dir;\n }\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return undefined;\n}\n\n/**\n * Scan an abapGit repository directory for all supported XML metadata files.\n * Returns relative paths to each .xml file (excluding .abapgit.xml and package.devc.xml).\n */\nasync function scanAbapGitFiles(repoRoot: string): Promise<string[]> {\n const supportedTypes = new Set(\n getSupportedTypes().map((t) => t.toLowerCase()),\n );\n const files: string[] = [];\n\n for await (const match of nativeGlob('**/*.xml', { cwd: repoRoot })) {\n if (match.endsWith('.abapgit.xml')) continue;\n if (match.endsWith('package.devc.xml')) continue;\n\n const filename = basename(match);\n const parsed = parseAbapGitFilename(filename);\n if (!parsed) continue;\n if (parsed.extension !== 'xml') continue;\n if (!supportedTypes.has(parsed.type.toLowerCase())) continue;\n\n files.push(match);\n }\n\n return [...files].sort((a: string, b: string) => a.localeCompare(b));\n}\n\n/**\n * Collect all local files belonging to one abapGit object.\n *\n * Given the XML metadata file, scans the same directory for companion\n * .abap files that share the same name.type prefix.\n *\n * @returns Map of relative filename → content\n */\nfunction collectLocalFiles(\n xmlPath: string,\n objectName: string,\n fileExtension: string,\n): Map<string, string> {\n const dir = dirname(xmlPath);\n const prefix = `${objectName}.${fileExtension}`;\n const files = new Map<string, string>();\n\n for (const entry of readdirSync(dir)) {\n if (entry.toLowerCase().startsWith(prefix)) {\n const fullPath = join(dir, entry);\n files.set(entry.toLowerCase(), readFileSync(fullPath, 'utf-8'));\n }\n }\n\n return files;\n}\n\n/**\n * Project `source` onto `reference`'s key structure.\n *\n * Recursively keeps only the keys from `source` that also exist in\n * `reference`. For arrays, builds a **union** of all keys across all\n * reference elements as the template — because different elements may\n * have different optional fields (e.g. DD03P entries where some have\n * DECIMALS and others don't).\n *\n * This ensures the remote object only contains fields the local cares\n * about, so serializer-added extras (LANGDEP, POSITION, etc.) vanish.\n */\nfunction projectOnto(source: unknown, reference: unknown): unknown {\n if (reference === null || reference === undefined) return source;\n if (source === null || source === undefined) return source;\n\n // Both arrays — build union template from ALL reference elements\n if (Array.isArray(reference) && Array.isArray(source)) {\n if (reference.length === 0) return source;\n\n // Merge all reference elements into a union shape\n const unionShape = mergeObjectKeys(reference);\n if (unionShape === undefined) return source;\n\n return source.map((item) => projectOnto(item, unionShape));\n }\n\n // Both objects — keep only keys present in reference\n if (\n typeof reference === 'object' &&\n typeof source === 'object' &&\n !Array.isArray(reference) &&\n !Array.isArray(source)\n ) {\n const ref = reference as Record<string, unknown>;\n const src = source as Record<string, unknown>;\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(ref)) {\n if (key in src) {\n result[key] = projectOnto(src[key], ref[key]);\n }\n }\n return result;\n }\n\n // Primitives — return source as-is\n return source;\n}\n\n/**\n * Merge all keys from an array of objects into a single union object.\n * Each key gets the first non-undefined value found across elements.\n * Used to build the \"widest\" template for array element projection.\n */\nfunction mergeObjectKeys(\n items: unknown[],\n): Record<string, unknown> | undefined {\n const objects = items.filter(\n (item): item is Record<string, unknown> =>\n item !== null && typeof item === 'object' && !Array.isArray(item),\n );\n if (objects.length === 0) return undefined;\n\n const union: Record<string, unknown> = {};\n for (const obj of objects) {\n for (const [key, value] of Object.entries(obj)) {\n if (!(key in union) || union[key] === undefined) {\n union[key] = value;\n }\n }\n }\n return union;\n}\n\n/**\n * Normalize an XML pair for comparison.\n *\n * 1. Parse both local and remote through the schema (strips formatting)\n * 2. Project remote values onto local's field structure (strips extras)\n * 3. Rebuild both through the same builder (identical formatting)\n *\n * Returns [normalizedLocal, normalizedRemote].\n */\nfunction normalizeXmlPair(\n localXml: string,\n remoteXml: string,\n handler: ObjectHandler,\n): [string, string] {\n try {\n const localParsed = handler.schema.parse(localXml);\n const remoteParsed = handler.schema.parse(remoteXml);\n\n // Project remote onto local's shape — drop fields local doesn't have\n const remoteProjected = projectOnto(remoteParsed, localParsed);\n\n const normalizedLocal = handler.schema.build(localParsed, { pretty: true });\n const normalizedRemote = handler.schema.build(\n remoteProjected as typeof localParsed,\n { pretty: true },\n );\n\n return [normalizedLocal, normalizedRemote];\n } catch {\n // If parsing fails, return as-is\n return [localXml, remoteXml];\n }\n}\n\n/**\n * Print a unified diff with optional color.\n * Returns true if differences were found.\n * When silent=true, skips printing but still detects differences.\n */\nfunction printDiff(\n localLabel: string,\n remoteLabel: string,\n localContent: string,\n remoteContent: string,\n contextLines: number,\n useColor: boolean,\n silent = false,\n): boolean {\n const local = localContent.endsWith('\\n')\n ? localContent\n : localContent + '\\n';\n const remote = remoteContent.endsWith('\\n')\n ? remoteContent\n : remoteContent + '\\n';\n\n if (local === remote) return false;\n\n if (silent) return true;\n\n const patch = createTwoFilesPatch(\n `a/${localLabel}`,\n `b/${remoteLabel}`,\n local,\n remote,\n 'local',\n 'remote (SAP)',\n { context: contextLines },\n );\n\n for (const line of patch.split('\\n')) {\n if (!useColor) {\n console.log(line);\n continue;\n }\n if (line.startsWith('+++') || line.startsWith('---')) {\n console.log(chalk.bold(line));\n } else if (line.startsWith('+')) {\n console.log(chalk.green(line));\n } else if (line.startsWith('-')) {\n console.log(chalk.red(line));\n } else if (line.startsWith('@@')) {\n console.log(chalk.cyan(line));\n } else {\n console.log(line);\n }\n }\n\n return true;\n}\n\n/** Result of diffing a single file */\ninterface DiffResult {\n objectName: string;\n objectType: string;\n hasDifferences: boolean;\n fileCount: number;\n identicalCount: number;\n error?: string;\n}\n\n/** Options driving one single-file diff. */\ninterface DiffModeOptions {\n contextLines: number;\n useColor: boolean;\n source: boolean;\n raw: boolean;\n summary?: boolean;\n}\n\n/** Build an error DiffResult. */\nfunction errorResult(\n parsed: { name: string; type: string },\n error: string,\n fileCount = 0,\n): DiffResult {\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences: false,\n fileCount,\n identicalCount: 0,\n error,\n };\n}\n\n/** Result for a single compared file in source/raw mode. */\nfunction modeResult(\n parsed: { name: string; type: string },\n diffFound: boolean,\n): DiffResult {\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences: diffFound,\n fileCount: 1,\n identicalCount: diffFound ? 0 : 1,\n };\n}\n\n/** Error message when the --source/--raw mode options are invalid. */\nfunction modeOptionsError(\n parsed: { name: string; type: string },\n source: boolean,\n raw: boolean,\n): string | undefined {\n // Validate --source option\n if (source && parsed.type !== 'TABL') {\n return `Source format is only supported for TABL objects. Got: ${parsed.type}`;\n }\n\n // Validate mutual exclusion of --source and --raw\n if (source && raw) {\n return '--source and --raw are mutually exclusive';\n }\n\n return undefined;\n}\n\n/** Derive the ADK type from the local XML via fromAbapGit (fallback: filename). */\nfunction resolveAdkType(\n handler: ReturnType<typeof getHandler>,\n localXml: string,\n fallback: string,\n): string {\n if (!handler.fromAbapGit) return fallback;\n try {\n const parsedXml = handler.schema.parse(localXml);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const values = (parsedXml as any)?.abapGit?.abap?.values ?? {};\n const payload = handler.fromAbapGit(values);\n if (typeof payload.type === 'string') {\n return payload.type;\n }\n } catch {\n // Fall through — use filename-derived type\n }\n return fallback;\n}\n\n/** Announce the object being diffed. */\nfunction printDiffBanner(\n parsed: { name: string; type: string },\n fileCount: number,\n useColor: boolean,\n): void {\n console.log(\n `\\n${useColor ? chalk.bold('Diff:') : 'Diff:'} ${parsed.name} (${parsed.type}) — ${fileCount} file(s)`,\n );\n}\n\n/** Announce the remote fetch. */\nfunction printFetchBanner(\n parsed: { name: string; type: string },\n adkType: string,\n useColor: boolean,\n): void {\n console.log(\n `${useColor ? chalk.dim('Fetching') : 'Fetching'} ${parsed.name} (${adkType}) from SAP...`,\n );\n}\n\n/** Announce a path that exists on only one side. */\nfunction printOnlyIn(\n side: 'local' | 'remote',\n path: string,\n useColor: boolean,\n summary?: boolean,\n): void {\n if (summary) return;\n const line = `\\n ${side === 'local' ? '+' : '-'} Only in ${side}: ${path}`;\n console.log(useColor ? chalk.yellow(line) : line);\n}\n\n/** Compare one local/remote content pair (XML pairs are normalized first). */\nfunction diffOnePair(\n localPath: string,\n localContent: string,\n remoteContent: string,\n handler: ReturnType<typeof getHandler>,\n options: DiffModeOptions,\n): boolean {\n // For XML files: normalize both through schema, projecting remote\n // onto local's field set to strip serializer-added extras\n const isXml = localPath.endsWith('.xml');\n let diffLocal = localContent;\n let diffRemote = remoteContent;\n if (isXml) {\n [diffLocal, diffRemote] = normalizeXmlPair(\n localContent,\n remoteContent,\n handler,\n );\n }\n\n return printDiff(\n localPath,\n localPath,\n diffLocal,\n diffRemote,\n options.contextLines,\n options.useColor,\n options.summary,\n );\n}\n\n/** Source format: compare ADK source (e.g. CDS DDL). */\nasync function diffSourceMode(\n parsed: { name: string; type: string },\n localXml: string,\n objectName: string,\n remoteObj: AdkObject,\n options: DiffModeOptions,\n): Promise<DiffResult> {\n const { contextLines, useColor, summary } = options;\n const localSource = tablXmlToCdsDdl(localXml);\n\n let remoteSource: string;\n try {\n remoteSource = await (\n remoteObj as unknown as { getSource(): Promise<string> }\n ).getSource();\n } catch (error) {\n return errorResult(\n parsed,\n `Failed to fetch remote source: ${error instanceof Error ? error.message : String(error)}`,\n 1,\n );\n }\n\n // Project remote onto local's annotation set — same principle as XML path.\n // If local XML doesn't have a field (e.g. MATEFLAG), strip the\n // corresponding annotation from remote so it doesn't appear as a diff.\n const localAnnotations = new Set(\n localSource\n .split('\\n')\n .filter((l) => l.startsWith('@'))\n .map((l) => l.split(':')[0].trim()),\n );\n remoteSource = remoteSource\n .split('\\n')\n .filter((l) => {\n if (!l.startsWith('@')) return true;\n const name = l.split(':')[0].trim();\n return localAnnotations.has(name);\n })\n .join('\\n');\n\n const sourceFile = `${objectName}.tabl.acds`;\n const diffFound = printDiff(\n sourceFile,\n sourceFile,\n localSource,\n remoteSource,\n contextLines,\n useColor,\n summary,\n );\n\n return modeResult(parsed, diffFound);\n}\n\n/** Raw mode: compare ADT-level XML payloads. */\nasync function diffRawMode(\n parsed: { name: string; type: string },\n localXml: string,\n objectName: string,\n handler: ReturnType<typeof getHandler>,\n remoteObj: AdkObject,\n options: DiffModeOptions,\n): Promise<DiffResult> {\n const { contextLines, useColor, summary } = options;\n const adtSchema = adtSchemaMap[parsed.type];\n if (!adtSchema) {\n return errorResult(\n parsed,\n `Raw mode not supported for ${parsed.type}: no ADT schema mapping. Supported: ${Object.keys(adtSchemaMap).join(', ')}`,\n 1,\n );\n }\n\n const { schema: rawSchema, wrapperKey } = adtSchema;\n\n // Build remote ADT XML from loaded data\n let remoteAdtXml: string;\n try {\n const remoteData = await remoteObj.data();\n remoteAdtXml = rawSchema.build(\n { [wrapperKey]: remoteData },\n { pretty: true },\n );\n } catch (e) {\n return errorResult(\n parsed,\n `Failed to build remote ADT XML: ${e instanceof Error ? e.message : String(e)}`,\n 1,\n );\n }\n\n // Parse local abapGit XML → fromAbapGit() → local ADK data\n let localAdtXml: string | undefined;\n if (handler.fromAbapGit) {\n try {\n const parsedXml = handler.schema.parse(localXml);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const values = (parsedXml as any)?.abapGit?.abap?.values ?? {};\n const localPayload = handler.fromAbapGit(values);\n\n // Merge local overrides onto remote's full data (remote is template)\n const remoteData = await remoteObj.data();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const merged = { ...(remoteData as any), ...localPayload };\n localAdtXml = rawSchema.build({ [wrapperKey]: merged }, { pretty: true });\n } catch (e) {\n return errorResult(\n parsed,\n `Failed to build local ADT XML: ${e instanceof Error ? e.message : String(e)}`,\n 1,\n );\n }\n }\n\n if (!localAdtXml) {\n return errorResult(\n parsed,\n `Raw mode not supported for ${parsed.type}: no fromAbapGit() mapping`,\n 1,\n );\n }\n\n const xmlFile = `${objectName}.${parsed.type.toLowerCase()}.adt.xml`;\n const diffFound = printDiff(\n xmlFile,\n xmlFile,\n localAdtXml,\n remoteAdtXml,\n contextLines,\n useColor,\n summary,\n );\n\n return modeResult(parsed, diffFound);\n}\n\n/** Serialize remote with the handler and diff it file-by-file. */\nasync function diffFilesMode(\n parsed: { name: string; type: string },\n localFiles: Map<string, string>,\n handler: ReturnType<typeof getHandler>,\n remoteObj: AdkObject,\n options: DiffModeOptions,\n): Promise<DiffResult> {\n const { contextLines, useColor, summary } = options;\n\n // Serialize remote using the same handler → produces SerializedFile[]\n let remoteFiles;\n try {\n remoteFiles = await handler.serialize(remoteObj);\n } catch (error) {\n return errorResult(\n parsed,\n `Failed to serialize remote object: ${error instanceof Error ? error.message : String(error)}`,\n localFiles.size,\n );\n }\n\n // Build remote file map (lowercase path → content)\n const remoteMap = new Map<string, string>();\n for (const f of remoteFiles) {\n remoteMap.set(f.path.toLowerCase(), f.content);\n }\n\n // Diff each file\n let hasDifferences = false;\n let identicalCount = 0;\n\n for (const [localPath, localContent] of localFiles) {\n const remoteContent = remoteMap.get(localPath);\n if (remoteContent === undefined) {\n printOnlyIn('local', localPath, useColor, summary);\n hasDifferences = true;\n continue;\n }\n\n const diffFound = diffOnePair(\n localPath,\n localContent,\n remoteContent,\n handler,\n {\n contextLines,\n useColor,\n summary,\n },\n );\n if (diffFound) {\n hasDifferences = true;\n } else {\n identicalCount++;\n }\n }\n\n // Files present in remote but not locally\n for (const [remotePath] of remoteMap) {\n if (!localFiles.has(remotePath)) {\n printOnlyIn('remote', remotePath, useColor, summary);\n hasDifferences = true;\n }\n }\n\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences,\n fileCount: localFiles.size,\n identicalCount,\n };\n}\n\n/**\n * Diff a single abapGit XML file against SAP remote.\n * Returns a result object indicating whether differences were found.\n */\nasync function diffSingleFile(\n filePath: string,\n ctx: CliContext,\n adk: AdkFactory,\n options: DiffModeOptions,\n): Promise<DiffResult> {\n const { source, raw, summary, useColor } = options;\n const fullPath = resolve(ctx.cwd, filePath);\n\n if (!existsSync(fullPath)) {\n return errorResult(\n { name: filePath, type: '?' },\n `File not found: ${fullPath}`,\n );\n }\n\n // Parse filename to detect type\n const filename = basename(fullPath);\n const parsed = parseAbapGitFilename(filename);\n if (!parsed) {\n return errorResult(\n { name: filename, type: '?' },\n `Cannot parse filename: ${filename}. Expected abapGit format: name.type.xml`,\n );\n }\n\n if (parsed.extension !== 'xml') {\n return errorResult(\n parsed,\n `Expected .xml metadata file, got .${parsed.extension}. Pass the .xml file, not .abap.`,\n );\n }\n\n const modeError = modeOptionsError(parsed, source, raw);\n if (modeError) {\n return errorResult(parsed, modeError);\n }\n\n // Look up handler from abapGit registry\n const handler = getHandler(parsed.type);\n if (!handler) {\n return errorResult(\n parsed,\n `Unsupported object type: ${parsed.type}. Supported: ${getSupportedTypes().join(', ')}`,\n );\n }\n\n // Collect local files for this object\n const objectName = parsed.name.toLowerCase();\n const localFiles = collectLocalFiles(\n fullPath,\n objectName,\n handler.fileExtension,\n );\n\n if (!summary) {\n printDiffBanner(parsed, localFiles.size, useColor);\n }\n\n // Parse local XML to extract ADK type info via fromAbapGit\n const localXml = readFileSync(fullPath, 'utf-8');\n const adkType = resolveAdkType(handler, localXml, parsed.type);\n\n // Fetch remote ADK object\n if (!summary) {\n printFetchBanner(parsed, adkType, useColor);\n }\n\n const remoteObjRaw = adk.get(parsed.name, adkType);\n\n // Narrow to AdkObject (excludes AdkGenericObject for unregistered types)\n if (!(remoteObjRaw instanceof AdkObject)) {\n return errorResult(\n parsed,\n `Unsupported ADK type: ${adkType} (no registered handler)`,\n localFiles.size,\n );\n }\n const remoteObj = remoteObjRaw;\n\n try {\n await remoteObj.load();\n } catch (error) {\n return errorResult(\n parsed,\n `Failed to load remote object: ${error instanceof Error ? error.message : String(error)}`,\n localFiles.size,\n );\n }\n\n // ========================================\n // Source format: compare ADK source (e.g. CDS DDL)\n // ========================================\n if (source) {\n return diffSourceMode(parsed, localXml, objectName, remoteObj, options);\n }\n\n // ========================================\n // Raw mode: compare ADT-level XML payloads\n // ========================================\n if (raw) {\n return diffRawMode(\n parsed,\n localXml,\n objectName,\n handler,\n remoteObj,\n options,\n );\n }\n\n return diffFilesMode(parsed, localFiles, handler, remoteObj, options);\n}\n\n/** Expand explicit globs, or scan the abapGit repo when no files are given. */\nasync function resolveDiffFiles(\n filePatterns: string[],\n ctx: CliContext,\n packageName: string | undefined,\n): Promise<{ files: string[]; scanMode: boolean }> {\n if (filePatterns.length > 0) {\n // Explicit files/globs — expand as before\n const files = await expandGlobs(filePatterns, ctx.cwd);\n if (files.length === 0) {\n ctx.logger.error('No files matched the given pattern(s).');\n process.exit(1);\n }\n return { files, scanMode: false };\n }\n\n // No files given — scan mode.\n // If --package given, or auto-detect abapGit repo root from cwd.\n const repoRoot = findAbapGitRoot(ctx.cwd);\n if (!repoRoot) {\n ctx.logger.error(\n packageName\n ? 'No .abapgit.xml found in current directory or parents.'\n : 'No files specified and no .abapgit.xml found. Usage: adt diff <file...> or run from an abapGit repo directory.',\n );\n process.exit(1);\n }\n\n const scannedFiles = await scanAbapGitFiles(repoRoot);\n if (scannedFiles.length === 0) {\n ctx.logger.error('No supported abapGit objects found in repository.');\n process.exit(1);\n }\n\n // Convert to paths relative to cwd\n const files = scannedFiles.map((f) => relative(ctx.cwd, join(repoRoot, f)));\n\n const pkgSuffix = packageName ? ` (package: ${packageName})` : '';\n ctx.logger.info(\n `📦 Scanning ${scannedFiles.length} object(s) in ${repoRoot}${pkgSuffix}...`,\n );\n return { files, scanMode: true };\n}\n\n/** Per-object status table for scan mode. */\nfunction printScanTable(results: DiffResult[], useColor: boolean): void {\n for (const r of results) {\n let icon: string;\n let line: string;\n if (r.error) {\n icon = '⚠️';\n line = `${r.objectType} ${r.objectName}: ${r.error}`;\n } else if (r.hasDifferences) {\n icon = '❌';\n line = `${r.objectType} ${r.objectName}`;\n } else {\n icon = '✅';\n line = `${r.objectType} ${r.objectName}`;\n }\n\n if (useColor) {\n if (r.error) {\n console.log(chalk.yellow(` ${icon} ${line}`));\n } else if (r.hasDifferences) {\n console.log(chalk.red(` ${icon} ${line}`));\n } else {\n console.log(chalk.green(` ${icon} ${line}`));\n }\n } else {\n console.log(` ${icon} ${line}`);\n }\n }\n}\n\n/** Scan-mode summary line; exits 1 when anything changed or failed. */\nfunction printScanSummary(\n totalFiles: number,\n identical: number,\n withDiffs: number,\n withErrors: number,\n useColor: boolean,\n): void {\n console.log('');\n const summaryParts: string[] = [\n `${totalFiles} object(s)`,\n `${identical} identical`,\n ];\n if (withDiffs > 0) summaryParts.push(`${withDiffs} changed`);\n if (withErrors > 0) summaryParts.push(`${withErrors} errors`);\n const summaryLine = summaryParts.join(', ');\n\n if (withDiffs > 0 || withErrors > 0) {\n console.log(\n useColor ? chalk.red(`📋 ${summaryLine}`) : `📋 ${summaryLine}`,\n );\n process.exit(1);\n }\n console.log(\n useColor ? chalk.green(`📋 ${summaryLine}`) : `📋 ${summaryLine}`,\n );\n}\n\n/** Single-file mode: keep original concise output. Exits 1 on diff/error. */\nfunction printSingleFileOutcome(r: DiffResult, useColor: boolean): void {\n if (r.error) {\n // Error already printed above\n process.exit(1);\n }\n if (r.hasDifferences) {\n const identicalSuffix =\n r.identicalCount > 0 ? ` (${r.identicalCount} file(s) identical)` : '';\n const coloredSuffix =\n r.identicalCount > 0 ? chalk.dim(identicalSuffix) : '';\n console.log(\n useColor\n ? chalk.red('Differences found.') + coloredSuffix\n : `Differences found.${identicalSuffix}`,\n );\n process.exit(1);\n }\n console.log(\n useColor\n ? chalk.green(\n `No differences found. (${r.identicalCount} file(s) identical)`,\n )\n : `No differences found. (${r.identicalCount} file(s) identical)`,\n );\n}\n\n/** Multi-file summary (explicit glob, not scan mode). Exits 1 on diff/error. */\nfunction printMultiFileOutcome(\n totalFiles: number,\n identical: number,\n withDiffs: number,\n withErrors: number,\n useColor: boolean,\n): void {\n const parts: string[] = [\n `${totalFiles} object(s) checked`,\n `${identical} identical`,\n ];\n if (withDiffs > 0) parts.push(`${withDiffs} with differences`);\n if (withErrors > 0) parts.push(`${withErrors} with errors`);\n const summaryText = parts.join(', ');\n\n if (withDiffs > 0 || withErrors > 0) {\n console.log(\n useColor\n ? chalk.red(`Diff summary: ${summaryText}`)\n : `Diff summary: ${summaryText}`,\n );\n process.exit(1);\n }\n console.log(\n useColor\n ? chalk.green(`Diff summary: ${summaryText}`)\n : `Diff summary: ${summaryText}`,\n );\n}\n\nexport const diffCommand: CliCommandPlugin = {\n name: 'diff',\n description:\n 'Compare local abapGit files against SAP remote (any supported object type)',\n\n arguments: [\n {\n name: '[files...]',\n description: `Local .xml files or glob patterns to compare (e.g., zcl_myclass.clas.xml, *.tabl.xml). When omitted, scans the abapGit repo in the current directory. Supported types: ${getSupportedTypes().join(', ')}`,\n },\n ],\n\n options: [\n {\n flags: '--no-color',\n description: 'Disable colored output',\n },\n {\n flags: '-c, --context <lines>',\n description: 'Number of context lines in diff',\n default: '3',\n },\n {\n flags: '-s, --source',\n description: 'Compare ADK source instead of XML (TABL only)',\n },\n {\n flags: '-r, --raw',\n description:\n 'Compare ADT-level XML payloads (what GET returns vs what PUT would send)',\n },\n {\n flags: '-p, --package <name>',\n description:\n 'Scan all abapGit files in the current directory (package name is informational)',\n },\n {\n flags: '-f, --full',\n description:\n 'Show full unified diffs (default in single-file mode; in package/multi-file mode only summary is shown unless --full is given)',\n },\n ],\n\n async execute(args: Record<string, unknown>, ctx: CliContext) {\n const filePatterns = (args.files as string[]) ?? [];\n const contextLines = Number.parseInt(\n String((args.context as string | number | undefined) ?? '3'),\n 10,\n );\n const useColor = args.color !== false;\n const source = args.source === true;\n const raw = args.raw === true;\n const packageName = args.package as string | undefined;\n const fullDiffs = args.full === true;\n\n const { files, scanMode } = await resolveDiffFiles(\n filePatterns,\n ctx,\n packageName,\n );\n\n // In scan mode default to summary (suppress diffs), unless --full\n const summaryMode = scanMode && !fullDiffs;\n\n // Need ADT client for remote comparison\n if (!ctx.getAdtClient) {\n ctx.logger.error('ADT client not available. Run: adt auth login');\n process.exit(1);\n }\n\n // Create ADT client and ADK once, shared across all files\n const client = await ctx.getAdtClient!();\n const adk = createAdk(client as AdtClient);\n\n // Diff each file\n const results: DiffResult[] = [];\n for (const file of files) {\n const result = await diffSingleFile(file, ctx, adk, {\n contextLines,\n useColor,\n source,\n raw,\n summary: summaryMode,\n });\n\n if (result.error && !summaryMode) {\n ctx.logger.error(result.error);\n }\n\n results.push(result);\n }\n\n // Summary\n const totalFiles = results.length;\n const withDiffs = results.filter((r) => r.hasDifferences).length;\n const withErrors = results.filter((r) => r.error).length;\n const identical = totalFiles - withDiffs - withErrors;\n\n console.log('');\n\n if (scanMode) {\n // Package/scan mode: always show per-object status table\n printScanTable(results, useColor);\n printScanSummary(totalFiles, identical, withDiffs, withErrors, useColor);\n return;\n }\n\n if (totalFiles === 1) {\n // Single-file mode: keep original concise output\n printSingleFileOutcome(results[0], useColor);\n return;\n }\n\n // Multi-file summary (explicit glob, not scan mode)\n printMultiFileOutcome(\n totalFiles,\n identical,\n withDiffs,\n withErrors,\n useColor,\n );\n },\n};\n\nexport default diffCommand;\n"],"mappings":";;;;;;;;;;;AA0DA,MAAM,kBAA0C;CAC9C,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,KAAK;CACL,MAAM;CACN,MAAM;CACN,KAAK;CACL,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;AACR;;AAGA,MAAM,kCAAkB,IAAI,IAAI;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAM,gCAAgB,IAAI,IAAI;CAAC;CAAO;CAAQ;CAAQ;CAAQ;CAAQ;AAAM,CAAC;;AAG7E,MAAM,wCAAwB,IAAI,IAAI,CAAC,UAAU,WAAW,CAAC;;AAG7D,MAAM,+BAAuD;CAC3D,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;AACP;;AAGA,MAAM,yBAAiD;CACrD,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;AACL;;AAGA,MAAM,yBAAiD;CACrD,QAAQ;CACR,SAAS;CACT,MAAM;CACN,QAAQ;AACV;;AAGA,MAAM,2BAAmD;CACvD,GAAG;CACH,GAAG;CACH,IAAI;AACN;;;;;AAUA,SAAS,qBACP,OACA,OACA,MACA,SACM;CACN,MAAM,QAAQ,QAAQ,QAAQ;CAC9B,IAAI,OACF,MAAM,KAAK,IAAI,MAAM,KAAK,OAAO;AAErC;;AAGA,SAAS,sBACP,OACA,OACA,aACM;CACN,IAAI,MAAM,QACR,MAAM,KACJ,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,MAAM,EAAE,cAAc,CAAC,CAAC;EAC1D,MAAM,aAAa,QAAQ,QAAQ,MAAM,EAAE,KAAK,CAAC,CAAC;EAClD,MAAM,YAAY,aAAa,YAAY;EAE3C,QAAQ,IAAI,EAAE;EAEd,IAAI,UAAU;GAEZ,eAAe,SAAS,QAAQ;GAChC,iBAAiB,YAAY,WAAW,WAAW,YAAY,QAAQ;GACvE;EACF;EAEA,IAAI,eAAe,GAAG;GAEpB,uBAAuB,QAAQ,IAAI,QAAQ;GAC3C;EACF;EAGA,sBACE,YACA,WACA,WACA,YACA,QACF;CACF;AACF"}
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/lib/abapgit-to-cds.ts"],"mappings":";;;;;;;;;;UAeiB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/lib/abapgit-to-cds.ts"],"mappings":";;;;;;;;;;UAeiB;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;;iBA4Mc,YACd,OAAO,WACP,cAAc;;;;iBAwPA,aAAa;EAC3B,OAAO;EACP,OAAO;;;;;;;;iBA0BO,gBAAgB"}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { n as buildCdsDdl, t as diffCommand, r as parseTablXml, i as tablXmlToCdsDdl } from "./diff-
|
|
1
|
+
export { n as buildCdsDdl, t as diffCommand, r as parseTablXml, i as tablXmlToCdsDdl } from "./diff-BNaZOwe9.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abapify/adt-diff",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.38",
|
|
4
4
|
"description": "Diff CLI plugin for adt-cli - compare local serialized files against SAP remote source",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -27,17 +27,17 @@
|
|
|
27
27
|
"abapgit"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@abapify/adk": "0.4.
|
|
31
|
-
"@abapify/adt-contracts": "0.4.
|
|
32
|
-
"@abapify/adt-plugin": "0.4.
|
|
33
|
-
"@abapify/adt-plugin-abapgit": "0.4.
|
|
30
|
+
"@abapify/adk": "0.4.38",
|
|
31
|
+
"@abapify/adt-contracts": "0.4.38",
|
|
32
|
+
"@abapify/adt-plugin": "0.4.38",
|
|
33
|
+
"@abapify/adt-plugin-abapgit": "0.4.38",
|
|
34
34
|
"chalk": "^5.6.2",
|
|
35
35
|
"diff": "^8.0.3",
|
|
36
36
|
"fast-xml-parser": "^5.5.5"
|
|
37
37
|
},
|
|
38
38
|
"module": "./dist/index.mjs",
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@abapify/adt-fixtures": "0.4.
|
|
40
|
+
"@abapify/adt-fixtures": "0.4.38"
|
|
41
41
|
},
|
|
42
42
|
"repository": {
|
|
43
43
|
"type": "git",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diff-C9jJwHCe.mjs","names":["nativeGlob"],"sources":["../src/lib/abapgit-to-cds.ts","../src/commands/diff.ts"],"sourcesContent":["/**\n * abapGit DD02V/DD03P → CDS DDL Source Builder\n *\n * Reverse mapping of cds-to-abapgit.ts — reconstructs CDS DDL source code\n * from parsed abapGit XML data (DD02V header + DD03P field entries).\n *\n * Used by `adt diff` to compare local abapGit serialized files against\n * SAP remote CDS source fetched via ADT /source/main endpoint.\n */\n\n// ============================================\n// DD02V / DD03P input types\n// (mirror of cds-to-abapgit.ts output types)\n// ============================================\n\nexport interface DD02VData {\n TABNAME?: string;\n DDLANGUAGE?: string;\n TABCLASS?: string;\n LANGDEP?: string;\n DDTEXT?: string;\n MASTERLANG?: string;\n CONTFLAG?: string;\n EXCLASS?: string;\n AUTHCLASS?: string;\n CLIDEP?: string;\n BUFFERED?: string;\n MATEFLAG?: string;\n SHLPEXI?: string;\n}\n\nexport interface DD03PData {\n FIELDNAME?: string;\n POSITION?: string;\n KEYFLAG?: string;\n ROLLNAME?: string;\n ADMINFIELD?: string;\n INTTYPE?: string;\n INTLEN?: string;\n NOTNULL?: string;\n DATATYPE?: string;\n LENG?: string;\n DECIMALS?: string;\n SHLPORIGIN?: string;\n MASK?: string;\n COMPTYPE?: string;\n REFTABLE?: string;\n REFFIELD?: string;\n PRECFIELD?: string;\n DDTEXT?: string;\n DOMNAME?: string;\n}\n\n// ============================================\n// Reverse mapping tables\n// ============================================\n\n/** DDIC DATATYPE → CDS abap.<type> name */\nconst DATATYPE_TO_CDS: Record<string, string> = {\n CHAR: 'char',\n CLNT: 'clnt',\n NUMC: 'numc',\n DATS: 'dats',\n DATN: 'datn',\n TIMS: 'tims',\n TIMN: 'timn',\n DEC: 'dec',\n CURR: 'curr',\n QUAN: 'quan',\n RAW: 'raw',\n INT1: 'int1',\n INT2: 'int2',\n INT4: 'int4',\n INT8: 'int8',\n FLTP: 'fltp',\n STRG: 'string',\n RSTR: 'rawstring',\n CUKY: 'cuky',\n UNIT: 'unit',\n LANG: 'lang',\n ACCP: 'accp',\n PREC: 'prec',\n D16N: 'd16n',\n D34N: 'd34n',\n D16R: 'd16r',\n D34R: 'd34r',\n D16D: 'd16d',\n D34D: 'd34d',\n UTCL: 'utclong',\n SSTR: 'sstring',\n LCHR: 'lchr',\n LRAW: 'lraw',\n};\n\n/** Types that never take a length parameter in CDS */\nconst NO_LENGTH_TYPES = new Set([\n 'clnt',\n 'cuky',\n 'dats',\n 'datn',\n 'tims',\n 'timn',\n 'int1',\n 'int2',\n 'int4',\n 'int8',\n 'fltp',\n 'lang',\n 'accp',\n 'prec',\n 'd16n',\n 'd34n',\n 'd16r',\n 'd34r',\n 'utclong',\n]);\n\n/** Types that take decimals in CDS: abap.dec(len,dec) */\nconst DECIMAL_TYPES = new Set(['dec', 'curr', 'quan', 'fltp', 'd16d', 'd34d']);\n\n/** Types that are variable-length (string, rawstring) — length 0 is omitted */\nconst VARIABLE_LENGTH_TYPES = new Set(['string', 'rawstring']);\n\n/** DD02V EXCLASS → CDS @AbapCatalog.enhancement.category */\nconst ENHANCEMENT_CATEGORY_REVERSE: Record<string, string> = {\n '0': '#NOT_CLASSIFIED',\n '1': '#NOT_EXTENSIBLE',\n '2': '#EXTENSIBLE_CHARACTER_NUMERIC',\n '3': '#EXTENSIBLE_CHARACTER',\n '4': '#EXTENSIBLE_ANY',\n};\n\n/** DD02V CONTFLAG → CDS @AbapCatalog.deliveryClass */\nconst DELIVERY_CLASS_REVERSE: Record<string, string> = {\n A: '#A',\n C: '#C',\n L: '#L',\n G: '#G',\n E: '#E',\n S: '#S',\n W: '#W',\n};\n\n/** DD02V TABCLASS → CDS @AbapCatalog.tableCategory */\nconst TABLE_CATEGORY_REVERSE: Record<string, string> = {\n TRANSP: '#TRANSPARENT',\n CLUSTER: '#CLUSTER',\n POOL: '#POOL',\n APPEND: '#APPEND',\n};\n\n/** DD02V MATEFLAG → CDS @AbapCatalog.dataMaintenance */\nconst DATA_MAINTENANCE_REVERSE: Record<string, string> = {\n X: '#RESTRICTED',\n N: '#NOT_ALLOWED',\n '': '#ALLOWED',\n};\n\n// ============================================\n// Builder\n// ============================================\n\n/**\n * Build CDS DDL source from DD02V header and DD03P field entries.\n *\n * @param dd02v - Table/structure header data\n * @param dd03pEntries - Field entries (sorted by POSITION if present)\n * @returns CDS DDL source string\n */\nexport function buildCdsDdl(\n dd02v: DD02VData,\n dd03pEntries: DD03PData[],\n): string {\n const lines: string[] = [];\n const tableName = dd02v.TABNAME ?? '';\n const isStructure = dd02v.TABCLASS === 'INTTAB';\n\n // --- Annotations ---\n if (dd02v.DDTEXT) {\n lines.push(\n `@EndUserText.label : '${escapeAnnotationString(dd02v.DDTEXT)}'`,\n );\n }\n\n if (dd02v.EXCLASS) {\n const cat = ENHANCEMENT_CATEGORY_REVERSE[dd02v.EXCLASS];\n if (cat) {\n lines.push(`@AbapCatalog.enhancement.category : ${cat}`);\n }\n }\n\n if (!isStructure) {\n // Table-specific annotations\n if (dd02v.TABCLASS) {\n const cat = TABLE_CATEGORY_REVERSE[dd02v.TABCLASS];\n if (cat) {\n lines.push(`@AbapCatalog.tableCategory : ${cat}`);\n }\n }\n\n if (dd02v.CONTFLAG) {\n const dc = DELIVERY_CLASS_REVERSE[dd02v.CONTFLAG];\n if (dc) {\n lines.push(`@AbapCatalog.deliveryClass : ${dc}`);\n }\n }\n\n if (dd02v.MATEFLAG !== undefined) {\n const dm = DATA_MAINTENANCE_REVERSE[dd02v.MATEFLAG ?? ''];\n if (dm) {\n lines.push(`@AbapCatalog.dataMaintenance : ${dm}`);\n }\n }\n }\n\n // --- Definition header ---\n const keyword = isStructure ? 'define structure' : 'define table';\n lines.push(`${keyword} ${tableName.toLowerCase()} {`, ''); // Blank line after opening brace (SAP format)\n\n // --- Sort fields by POSITION ---\n const sorted = [...dd03pEntries].sort((a, b) => {\n const posA = Number.parseInt(a.POSITION ?? '0', 10);\n const posB = Number.parseInt(b.POSITION ?? '0', 10);\n return posA - posB;\n });\n\n // --- Compute alignment ---\n // Find max field name width for alignment (only field entries, not includes)\n const fieldInfos = buildFieldInfos(sorted, tableName);\n const maxNameWidth = Math.max(\n ...fieldInfos\n .filter((f): f is FieldInfo => f.kind === 'field')\n .map((f) => f.prefix.length),\n 0,\n );\n\n // --- Emit fields ---\n for (const info of fieldInfos) {\n if (info.kind === 'include') {\n if (info.suffix) {\n lines.push(` include ${info.name} with suffix ${info.suffix};`);\n } else {\n lines.push(` include ${info.name};`);\n }\n } else {\n // Field annotations (e.g., @Semantics.amount.currencyCode)\n for (const ann of info.annotations) {\n lines.push(` ${ann}`);\n }\n\n const paddedPrefix = info.prefix.padEnd(maxNameWidth);\n lines.push(` ${paddedPrefix} : ${info.typeStr};`);\n }\n }\n\n lines.push('', '}'); // Blank line before closing brace (SAP format)\n\n return lines.join('\\n') + '\\n'; // Trailing newline (SAP format)\n}\n\n// ============================================\n// Internal helpers\n// ============================================\n\ninterface FieldInfo {\n kind: 'field';\n /** \"key fieldname\" or \"fieldname\" — used for alignment */\n prefix: string;\n /** CDS type string (e.g., \"abap.char(10) not null\") */\n typeStr: string;\n /** Field-level annotations */\n annotations: string[];\n}\n\ninterface IncludeInfo {\n kind: 'include';\n name: string;\n /** Optional suffix for `include ... with suffix <suffix>` */\n suffix?: string;\n}\n\ntype MemberInfo = FieldInfo | IncludeInfo;\n\n/**\n * Pre-process DD03P entries into structured field info for emission.\n */\nfunction buildFieldInfos(\n entries: DD03PData[],\n tableName: string,\n): MemberInfo[] {\n const result: MemberInfo[] = [];\n\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n const fieldName = entry.FIELDNAME ?? '';\n\n // .INCLU-<SUFFIX> entries → include with suffix\n if (fieldName.startsWith('.INCLU-')) {\n const includeName = entry.PRECFIELD ?? '';\n if (includeName) {\n // Extract suffix from .INCLU-<SUFFIX> (e.g., \".INCLU-_XX\" → \"_xx\")\n const suffix = fieldName.slice('.INCLU-'.length).toLowerCase();\n result.push({\n kind: 'include',\n name: includeName.toLowerCase(),\n suffix,\n });\n }\n continue;\n }\n\n // Include directive → plain include\n if (fieldName === '.INCLUDE') {\n const includeName = entry.PRECFIELD ?? '';\n if (includeName) {\n result.push({\n kind: 'include',\n name: includeName.toLowerCase(),\n });\n }\n continue;\n }\n\n // Structure-typed field (COMPTYPE = 'S', not an include)\n if (entry.COMPTYPE === 'S' && entry.DATATYPE === 'STRU') {\n const isKey = entry.KEYFLAG === 'X';\n const notNull = entry.NOTNULL === 'X' || isKey;\n const rollname = entry.ROLLNAME ?? fieldName;\n\n const prefix = isKey\n ? `key ${fieldName.toLowerCase()}`\n : fieldName.toLowerCase();\n\n const typeStr = notNull\n ? `${rollname.toLowerCase()} not null`\n : rollname.toLowerCase();\n\n result.push({\n kind: 'field',\n prefix,\n typeStr,\n annotations: [],\n });\n continue;\n }\n\n // Data element reference (COMPTYPE = 'E')\n if (entry.COMPTYPE === 'E' && entry.ROLLNAME) {\n const isKey = entry.KEYFLAG === 'X';\n const notNull = entry.NOTNULL === 'X' || isKey;\n\n const prefix = isKey\n ? `key ${fieldName.toLowerCase()}`\n : fieldName.toLowerCase();\n\n const typeStr = notNull\n ? `${entry.ROLLNAME.toLowerCase()} not null`\n : entry.ROLLNAME.toLowerCase();\n\n result.push({\n kind: 'field',\n prefix,\n typeStr,\n annotations: [],\n });\n continue;\n }\n\n // Built-in type field\n const cdsType = buildCdsTypeString(entry);\n if (!cdsType) continue;\n\n const isKey = entry.KEYFLAG === 'X';\n const notNull = entry.NOTNULL === 'X' || isKey;\n const annotations: string[] = [];\n\n // @Semantics annotations for CURR/QUAN fields\n if (entry.DATATYPE === 'CURR' && entry.REFTABLE && entry.REFFIELD) {\n const refTable =\n entry.REFTABLE.toUpperCase() === tableName.toUpperCase()\n ? tableName.toLowerCase()\n : entry.REFTABLE.toLowerCase();\n annotations.push(\n `@Semantics.amount.currencyCode : '${refTable}.${entry.REFFIELD.toLowerCase()}'`,\n );\n } else if (entry.DATATYPE === 'QUAN' && entry.REFTABLE && entry.REFFIELD) {\n const refTable =\n entry.REFTABLE.toUpperCase() === tableName.toUpperCase()\n ? tableName.toLowerCase()\n : entry.REFTABLE.toLowerCase();\n annotations.push(\n `@Semantics.quantity.unitOfMeasure : '${refTable}.${entry.REFFIELD.toLowerCase()}'`,\n );\n }\n\n const prefix = isKey\n ? `key ${fieldName.toLowerCase()}`\n : fieldName.toLowerCase();\n\n const typeStr = notNull ? `${cdsType} not null` : cdsType;\n\n result.push({\n kind: 'field',\n prefix,\n typeStr,\n annotations,\n });\n }\n\n return result;\n}\n\n/**\n * Build the CDS type string from a DD03P entry.\n * E.g., \"abap.char(10)\", \"abap.dec(15,2)\", \"abap.int4\"\n */\nfunction buildCdsTypeString(entry: DD03PData): string | null {\n const datatype = entry.DATATYPE;\n if (!datatype) return null;\n\n const cdsName = DATATYPE_TO_CDS[datatype];\n if (!cdsName) return null;\n\n // Fixed-length types without parameters\n if (NO_LENGTH_TYPES.has(cdsName)) {\n return `abap.${cdsName}`;\n }\n\n // Parse LENG and DECIMALS (strip leading zeros)\n const leng = entry.LENG ? Number.parseInt(entry.LENG, 10) : undefined;\n const decimals = entry.DECIMALS\n ? Number.parseInt(entry.DECIMALS, 10)\n : undefined;\n\n // Variable-length types (string, rawstring)\n if (VARIABLE_LENGTH_TYPES.has(cdsName)) {\n if (leng && leng > 0) {\n return `abap.${cdsName}(${leng})`;\n }\n return `abap.${cdsName}(0)`;\n }\n\n // Types with decimals\n if (DECIMAL_TYPES.has(cdsName) && leng !== undefined) {\n const dec = decimals ?? 0;\n return `abap.${cdsName}(${leng},${dec})`;\n }\n\n // Types with length only\n if (leng !== undefined) {\n return `abap.${cdsName}(${leng})`;\n }\n\n // Fallback: no parameters\n return `abap.${cdsName}`;\n}\n\n/**\n * Escape single quotes in annotation string values\n */\nfunction escapeAnnotationString(value: string): string {\n return value.replaceAll(\"'\", \"''\");\n}\n\n// ============================================\n// XML parsing\n// ============================================\n\nimport { XMLParser } from 'fast-xml-parser';\n\nconst xmlParser = new XMLParser({\n ignoreAttributes: false,\n attributeNamePrefix: '@_',\n trimValues: true,\n parseTagValue: false,\n parseAttributeValue: false,\n removeNSPrefix: true,\n isArray: (name) => name === 'DD03P',\n});\n\n/**\n * Parse abapGit TABL XML content and extract DD02V/DD03P data.\n */\nexport function parseTablXml(xmlContent: string): {\n dd02v: DD02VData;\n dd03p: DD03PData[];\n} {\n const parsed = xmlParser.parse(xmlContent);\n const values = parsed?.abapGit?.abap?.values ?? {};\n\n const dd02v: DD02VData = values.DD02V ?? {};\n\n // DD03P can be inside DD03P_TABLE or directly as array\n let dd03pRaw = values.DD03P_TABLE?.DD03P ?? [];\n if (!Array.isArray(dd03pRaw)) {\n dd03pRaw = [dd03pRaw];\n }\n\n return { dd02v, dd03p: dd03pRaw };\n}\n\n// ============================================\n// Convenience: parse XML and build DDL\n// ============================================\n\n/**\n * Parse abapGit TABL XML and build CDS DDL source.\n *\n * @param xmlContent - Raw XML content of a .tabl.xml file\n * @returns CDS DDL source string\n */\nexport function tablXmlToCdsDdl(xmlContent: string): string {\n const { dd02v, dd03p } = parseTablXml(xmlContent);\n return buildCdsDdl(dd02v, dd03p);\n}\n","/**\n * Diff Command Plugin — Type-Agnostic\n *\n * Compares local abapGit files against what SAP has.\n *\n * The local file (from abapGit) is the source of truth — it defines which\n * fields matter. The remote side is fetched from SAP via ADT, serialized\n * through the same handler, then **projected** onto the local's field set.\n * Any extra fields the serializer adds (LANGDEP, POSITION, etc.) are\n * stripped so the diff only shows real value changes.\n *\n * For XML metadata: parse both → project remote onto local's keys → rebuild\n * For .abap source: compare text directly\n *\n * Works for ALL object types supported by adt-plugin-abapgit:\n * CLAS, INTF, PROG, FUGR, TABL, DOMA, DTEL, TTYP, DEVC\n *\n * Usage:\n * adt diff zage_structure.tabl.xml\n * adt diff *.tabl.xml\n * adt diff zcl_myclass.clas.xml --no-color\n */\n\nimport {\n requireFormatPlugin,\n getFormatPlugin,\n type CliCommandPlugin,\n type CliContext,\n type FormatHandler,\n type ParsedFormatFilename,\n} from '@abapify/adt-plugin';\nimport {\n createAdk,\n AdkObject,\n type AdtClient,\n type AdkFactory,\n} from '@abapify/adk';\nimport { readFileSync, existsSync, readdirSync } from 'node:fs';\nimport { glob as nativeGlob } from 'node:fs/promises';\nimport { resolve, basename, dirname, join, relative } from 'node:path';\nimport { createTwoFilesPatch } from 'diff';\nimport chalk from 'chalk';\n\n// abapGit is the only diff format today. The plugin registers itself on\n// import (see adt-cli/src/lib/cli.ts bootstrap).\nconst abapgit = () => requireFormatPlugin('abapgit');\nconst getHandler = (type: string): FormatHandler | undefined =>\n abapgit().getHandler(type);\n// Used in command `description` at module-load time — must be safe to call\n// before the bootstrap has registered the plugin (returns `[]` in that case;\n// the actual `execute` body always runs post-bootstrap).\nconst getSupportedTypes = (): string[] => [\n ...(getFormatPlugin('abapgit')?.supportedTypes ?? []),\n];\nconst parseAbapGitFilename = (filename: string): ParsedFormatFilename | null =>\n abapgit().parseFilename?.(filename) ?? null;\ntype ObjectHandler = FormatHandler;\nimport { tablXmlToCdsDdl } from '../lib/abapgit-to-cds';\nimport { adtContract } from '@abapify/adt-contracts';\n\n/**\n * ADT schema lookup for --raw mode.\n *\n * Maps abapGit type codes to raw CRUD contract schemas (NOT speci-proxied).\n * Each entry has:\n * - schema: the TypedSchema with .build() for XML serialization\n * - wrapperKey: the root element key expected by build()\n */\nconst adtSchemaMap: Record<\n string,\n {\n // The actual schemas are TypedSchema<T> from adt-schemas. Each has a\n // narrowly-typed build(data: T, ...) that is contravariantly incompatible\n // with a unified (data: unknown, ...) signature. We widen to `any` here\n // so the callers in this file (which know the wrapperKey) can pass the\n // correct shape. See FormatHandler<T, TSchema> in adt-plugin for the\n // same pattern.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: { build: (data: any, options?: { pretty?: boolean }) => string };\n wrapperKey: string;\n }\n> = {\n TTYP: {\n schema: adtContract.ddic.tabletypes.bodySchema,\n wrapperKey: 'tableType',\n },\n DOMA: { schema: adtContract.ddic.domains.bodySchema, wrapperKey: 'domain' },\n DTEL: {\n schema: adtContract.ddic.dataelements.bodySchema,\n wrapperKey: 'wbobj',\n },\n CLAS: { schema: adtContract.oo.classes.bodySchema, wrapperKey: 'abapClass' },\n INTF: {\n schema: adtContract.oo.interfaces.bodySchema,\n wrapperKey: 'abapInterface',\n },\n PROG: {\n schema: adtContract.programs.programs.bodySchema,\n wrapperKey: 'abapProgram',\n },\n FUGR: {\n schema: adtContract.functions.groups.bodySchema,\n wrapperKey: 'abapFunctionGroup',\n },\n DEVC: {\n schema: adtContract.packages.bodySchema,\n wrapperKey: 'package',\n },\n};\n\n/**\n * Expand glob patterns to matching file paths.\n * Passes through literal filenames unchanged.\n */\nasync function expandGlobs(patterns: string[], cwd: string): Promise<string[]> {\n const results: string[] = [];\n for (const pattern of patterns) {\n if (/[*?[\\]{}]/.test(pattern)) {\n for await (const match of nativeGlob(pattern, { cwd })) {\n results.push(match);\n }\n } else {\n results.push(pattern);\n }\n }\n return results;\n}\n\n/**\n * Walk up from a directory to find the nearest ancestor containing .abapgit.xml.\n * Returns the resolved absolute path to the repo root, or undefined if not found.\n */\nfunction findAbapGitRoot(startDir: string): string | undefined {\n let dir = resolve(startDir);\n const root = resolve('/');\n\n while (dir !== root) {\n if (existsSync(join(dir, '.abapgit.xml'))) {\n return dir;\n }\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return undefined;\n}\n\n/**\n * Scan an abapGit repository directory for all supported XML metadata files.\n * Returns relative paths to each .xml file (excluding .abapgit.xml and package.devc.xml).\n */\nasync function scanAbapGitFiles(repoRoot: string): Promise<string[]> {\n const supportedTypes = new Set(\n getSupportedTypes().map((t) => t.toLowerCase()),\n );\n const files: string[] = [];\n\n for await (const match of nativeGlob('**/*.xml', { cwd: repoRoot })) {\n if (match.endsWith('.abapgit.xml')) continue;\n if (match.endsWith('package.devc.xml')) continue;\n\n const filename = basename(match);\n const parsed = parseAbapGitFilename(filename);\n if (!parsed) continue;\n if (parsed.extension !== 'xml') continue;\n if (!supportedTypes.has(parsed.type.toLowerCase())) continue;\n\n files.push(match);\n }\n\n return [...files].sort((a: string, b: string) => a.localeCompare(b));\n}\n\n/**\n * Collect all local files belonging to one abapGit object.\n *\n * Given the XML metadata file, scans the same directory for companion\n * .abap files that share the same name.type prefix.\n *\n * @returns Map of relative filename → content\n */\nfunction collectLocalFiles(\n xmlPath: string,\n objectName: string,\n fileExtension: string,\n): Map<string, string> {\n const dir = dirname(xmlPath);\n const prefix = `${objectName}.${fileExtension}`;\n const files = new Map<string, string>();\n\n for (const entry of readdirSync(dir)) {\n if (entry.toLowerCase().startsWith(prefix)) {\n const fullPath = join(dir, entry);\n files.set(entry.toLowerCase(), readFileSync(fullPath, 'utf-8'));\n }\n }\n\n return files;\n}\n\n/**\n * Project `source` onto `reference`'s key structure.\n *\n * Recursively keeps only the keys from `source` that also exist in\n * `reference`. For arrays, builds a **union** of all keys across all\n * reference elements as the template — because different elements may\n * have different optional fields (e.g. DD03P entries where some have\n * DECIMALS and others don't).\n *\n * This ensures the remote object only contains fields the local cares\n * about, so serializer-added extras (LANGDEP, POSITION, etc.) vanish.\n */\nfunction projectOnto(source: unknown, reference: unknown): unknown {\n if (reference === null || reference === undefined) return source;\n if (source === null || source === undefined) return source;\n\n // Both arrays — build union template from ALL reference elements\n if (Array.isArray(reference) && Array.isArray(source)) {\n if (reference.length === 0) return source;\n\n // Merge all reference elements into a union shape\n const unionShape = mergeObjectKeys(reference);\n if (unionShape === undefined) return source;\n\n return source.map((item) => projectOnto(item, unionShape));\n }\n\n // Both objects — keep only keys present in reference\n if (\n typeof reference === 'object' &&\n typeof source === 'object' &&\n !Array.isArray(reference) &&\n !Array.isArray(source)\n ) {\n const ref = reference as Record<string, unknown>;\n const src = source as Record<string, unknown>;\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(ref)) {\n if (key in src) {\n result[key] = projectOnto(src[key], ref[key]);\n }\n }\n return result;\n }\n\n // Primitives — return source as-is\n return source;\n}\n\n/**\n * Merge all keys from an array of objects into a single union object.\n * Each key gets the first non-undefined value found across elements.\n * Used to build the \"widest\" template for array element projection.\n */\nfunction mergeObjectKeys(\n items: unknown[],\n): Record<string, unknown> | undefined {\n const objects = items.filter(\n (item): item is Record<string, unknown> =>\n item !== null && typeof item === 'object' && !Array.isArray(item),\n );\n if (objects.length === 0) return undefined;\n\n const union: Record<string, unknown> = {};\n for (const obj of objects) {\n for (const [key, value] of Object.entries(obj)) {\n if (!(key in union) || union[key] === undefined) {\n union[key] = value;\n }\n }\n }\n return union;\n}\n\n/**\n * Normalize an XML pair for comparison.\n *\n * 1. Parse both local and remote through the schema (strips formatting)\n * 2. Project remote values onto local's field structure (strips extras)\n * 3. Rebuild both through the same builder (identical formatting)\n *\n * Returns [normalizedLocal, normalizedRemote].\n */\nfunction normalizeXmlPair(\n localXml: string,\n remoteXml: string,\n handler: ObjectHandler,\n): [string, string] {\n try {\n const localParsed = handler.schema.parse(localXml);\n const remoteParsed = handler.schema.parse(remoteXml);\n\n // Project remote onto local's shape — drop fields local doesn't have\n const remoteProjected = projectOnto(remoteParsed, localParsed);\n\n const normalizedLocal = handler.schema.build(localParsed, { pretty: true });\n const normalizedRemote = handler.schema.build(\n remoteProjected as typeof localParsed,\n { pretty: true },\n );\n\n return [normalizedLocal, normalizedRemote];\n } catch {\n // If parsing fails, return as-is\n return [localXml, remoteXml];\n }\n}\n\n/**\n * Print a unified diff with optional color.\n * Returns true if differences were found.\n * When silent=true, skips printing but still detects differences.\n */\nfunction printDiff(\n localLabel: string,\n remoteLabel: string,\n localContent: string,\n remoteContent: string,\n contextLines: number,\n useColor: boolean,\n silent = false,\n): boolean {\n const local = localContent.endsWith('\\n')\n ? localContent\n : localContent + '\\n';\n const remote = remoteContent.endsWith('\\n')\n ? remoteContent\n : remoteContent + '\\n';\n\n if (local === remote) return false;\n\n if (silent) return true;\n\n const patch = createTwoFilesPatch(\n `a/${localLabel}`,\n `b/${remoteLabel}`,\n local,\n remote,\n 'local',\n 'remote (SAP)',\n { context: contextLines },\n );\n\n for (const line of patch.split('\\n')) {\n if (!useColor) {\n console.log(line);\n continue;\n }\n if (line.startsWith('+++') || line.startsWith('---')) {\n console.log(chalk.bold(line));\n } else if (line.startsWith('+')) {\n console.log(chalk.green(line));\n } else if (line.startsWith('-')) {\n console.log(chalk.red(line));\n } else if (line.startsWith('@@')) {\n console.log(chalk.cyan(line));\n } else {\n console.log(line);\n }\n }\n\n return true;\n}\n\n/** Result of diffing a single file */\ninterface DiffResult {\n objectName: string;\n objectType: string;\n hasDifferences: boolean;\n fileCount: number;\n identicalCount: number;\n error?: string;\n}\n\n/**\n * Diff a single abapGit XML file against SAP remote.\n * Returns a result object indicating whether differences were found.\n */\nasync function diffSingleFile(\n filePath: string,\n ctx: CliContext,\n adk: AdkFactory,\n options: {\n contextLines: number;\n useColor: boolean;\n source: boolean;\n raw: boolean;\n summary?: boolean;\n },\n): Promise<DiffResult> {\n const { contextLines, useColor, source, raw, summary } = options;\n const fullPath = resolve(ctx.cwd, filePath);\n\n if (!existsSync(fullPath)) {\n return {\n objectName: filePath,\n objectType: '?',\n hasDifferences: false,\n fileCount: 0,\n identicalCount: 0,\n error: `File not found: ${fullPath}`,\n };\n }\n\n // Parse filename to detect type\n const filename = basename(fullPath);\n const parsed = parseAbapGitFilename(filename);\n if (!parsed) {\n return {\n objectName: filename,\n objectType: '?',\n hasDifferences: false,\n fileCount: 0,\n identicalCount: 0,\n error: `Cannot parse filename: ${filename}. Expected abapGit format: name.type.xml`,\n };\n }\n\n if (parsed.extension !== 'xml') {\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences: false,\n fileCount: 0,\n identicalCount: 0,\n error: `Expected .xml metadata file, got .${parsed.extension}. Pass the .xml file, not .abap.`,\n };\n }\n\n // Validate --source option\n if (source && parsed.type !== 'TABL') {\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences: false,\n fileCount: 0,\n identicalCount: 0,\n error: `Source format is only supported for TABL objects. Got: ${parsed.type}`,\n };\n }\n\n // Validate mutual exclusion of --source and --raw\n if (source && raw) {\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences: false,\n fileCount: 0,\n identicalCount: 0,\n error: '--source and --raw are mutually exclusive',\n };\n }\n\n // Look up handler from abapGit registry\n const handler = getHandler(parsed.type);\n if (!handler) {\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences: false,\n fileCount: 0,\n identicalCount: 0,\n error: `Unsupported object type: ${parsed.type}. Supported: ${getSupportedTypes().join(', ')}`,\n };\n }\n\n // Collect local files for this object\n const objectName = parsed.name.toLowerCase();\n const localFiles = collectLocalFiles(\n fullPath,\n objectName,\n handler.fileExtension,\n );\n\n if (!summary) {\n console.log(\n `\\n${useColor ? chalk.bold('Diff:') : 'Diff:'} ${parsed.name} (${parsed.type}) — ${localFiles.size} file(s)`,\n );\n }\n\n // Parse local XML to extract ADK type info via fromAbapGit\n const localXml = readFileSync(fullPath, 'utf-8');\n let adkType = parsed.type;\n\n if (handler.fromAbapGit) {\n try {\n const parsedXml = handler.schema.parse(localXml);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const values = (parsedXml as any)?.abapGit?.abap?.values ?? {};\n const payload = handler.fromAbapGit(values);\n if (typeof payload.type === 'string') {\n adkType = payload.type;\n }\n } catch {\n // Fall through — use filename-derived type\n }\n }\n\n // Fetch remote ADK object\n if (!summary) {\n console.log(\n `${useColor ? chalk.dim('Fetching') : 'Fetching'} ${parsed.name} (${adkType}) from SAP...`,\n );\n }\n\n const remoteObjRaw = adk.get(parsed.name, adkType);\n\n // Narrow to AdkObject (excludes AdkGenericObject for unregistered types)\n if (!(remoteObjRaw instanceof AdkObject)) {\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences: false,\n fileCount: localFiles.size,\n identicalCount: 0,\n error: `Unsupported ADK type: ${adkType} (no registered handler)`,\n };\n }\n const remoteObj = remoteObjRaw;\n\n try {\n await remoteObj.load();\n } catch (error) {\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences: false,\n fileCount: localFiles.size,\n identicalCount: 0,\n error: `Failed to load remote object: ${error instanceof Error ? error.message : String(error)}`,\n };\n }\n\n // ========================================\n // Source format: compare ADK source (e.g. CDS DDL)\n // ========================================\n if (source) {\n const localSource = tablXmlToCdsDdl(localXml);\n\n let remoteSource: string;\n try {\n remoteSource = await (\n remoteObj as unknown as { getSource(): Promise<string> }\n ).getSource();\n } catch (error) {\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences: false,\n fileCount: 1,\n identicalCount: 0,\n error: `Failed to fetch remote source: ${error instanceof Error ? error.message : String(error)}`,\n };\n }\n\n // Project remote onto local's annotation set — same principle as XML path.\n // If local XML doesn't have a field (e.g. MATEFLAG), strip the\n // corresponding annotation from remote so it doesn't appear as a diff.\n const localAnnotations = new Set(\n localSource\n .split('\\n')\n .filter((l) => l.startsWith('@'))\n .map((l) => l.split(':')[0].trim()),\n );\n remoteSource = remoteSource\n .split('\\n')\n .filter((l) => {\n if (!l.startsWith('@')) return true;\n const name = l.split(':')[0].trim();\n return localAnnotations.has(name);\n })\n .join('\\n');\n\n const sourceFile = `${objectName}.tabl.acds`;\n const diffFound = printDiff(\n sourceFile,\n sourceFile,\n localSource,\n remoteSource,\n contextLines,\n useColor,\n summary,\n );\n\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences: diffFound,\n fileCount: 1,\n identicalCount: diffFound ? 0 : 1,\n };\n }\n\n // ========================================\n // Raw mode: compare ADT-level XML payloads\n // ========================================\n if (raw) {\n const adtSchema = adtSchemaMap[parsed.type];\n if (!adtSchema) {\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences: false,\n fileCount: 1,\n identicalCount: 0,\n error: `Raw mode not supported for ${parsed.type}: no ADT schema mapping. Supported: ${Object.keys(adtSchemaMap).join(', ')}`,\n };\n }\n\n const { schema: rawSchema, wrapperKey } = adtSchema;\n\n // Build remote ADT XML from loaded data\n let remoteAdtXml: string;\n try {\n const remoteData = await remoteObj.data();\n remoteAdtXml = rawSchema.build(\n { [wrapperKey]: remoteData },\n { pretty: true },\n );\n } catch (e) {\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences: false,\n fileCount: 1,\n identicalCount: 0,\n error: `Failed to build remote ADT XML: ${e instanceof Error ? e.message : String(e)}`,\n };\n }\n\n // Parse local abapGit XML → fromAbapGit() → local ADK data\n let localAdtXml: string | undefined;\n if (handler.fromAbapGit) {\n try {\n const parsedXml = handler.schema.parse(localXml);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const values = (parsedXml as any)?.abapGit?.abap?.values ?? {};\n const localPayload = handler.fromAbapGit(values);\n\n // Merge local overrides onto remote's full data (remote is template)\n const remoteData = await remoteObj.data();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const merged = { ...(remoteData as any), ...localPayload };\n localAdtXml = rawSchema.build(\n { [wrapperKey]: merged },\n { pretty: true },\n );\n } catch (e) {\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences: false,\n fileCount: 1,\n identicalCount: 0,\n error: `Failed to build local ADT XML: ${e instanceof Error ? e.message : String(e)}`,\n };\n }\n }\n\n if (!localAdtXml) {\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences: false,\n fileCount: 1,\n identicalCount: 0,\n error: `Raw mode not supported for ${parsed.type}: no fromAbapGit() mapping`,\n };\n }\n\n const xmlFile = `${objectName}.${parsed.type.toLowerCase()}.adt.xml`;\n const diffFound = printDiff(\n xmlFile,\n xmlFile,\n localAdtXml,\n remoteAdtXml,\n contextLines,\n useColor,\n summary,\n );\n\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences: diffFound,\n fileCount: 1,\n identicalCount: diffFound ? 0 : 1,\n };\n }\n\n // Serialize remote using the same handler → produces SerializedFile[]\n let remoteFiles;\n try {\n remoteFiles = await handler.serialize(remoteObj);\n } catch (error) {\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences: false,\n fileCount: localFiles.size,\n identicalCount: 0,\n error: `Failed to serialize remote object: ${error instanceof Error ? error.message : String(error)}`,\n };\n }\n\n // Build remote file map (lowercase path → content)\n const remoteMap = new Map<string, string>();\n for (const f of remoteFiles) {\n remoteMap.set(f.path.toLowerCase(), f.content);\n }\n\n // Diff each file\n let hasDifferences = false;\n let identicalCount = 0;\n\n for (const [localPath, localContent] of localFiles) {\n const remoteContent = remoteMap.get(localPath);\n if (remoteContent === undefined) {\n if (!summary) {\n console.log(\n useColor\n ? chalk.yellow(`\\n + Only in local: ${localPath}`)\n : `\\n + Only in local: ${localPath}`,\n );\n }\n hasDifferences = true;\n continue;\n }\n\n // For XML files: normalize both through schema, projecting remote\n // onto local's field set to strip serializer-added extras\n const isXml = localPath.endsWith('.xml');\n let diffLocal = localContent;\n let diffRemote = remoteContent;\n if (isXml) {\n [diffLocal, diffRemote] = normalizeXmlPair(\n localContent,\n remoteContent,\n handler,\n );\n }\n\n const diffFound = printDiff(\n localPath,\n localPath,\n diffLocal,\n diffRemote,\n contextLines,\n useColor,\n summary,\n );\n if (diffFound) {\n hasDifferences = true;\n } else {\n identicalCount++;\n }\n }\n\n // Files present in remote but not locally\n for (const [remotePath] of remoteMap) {\n if (!localFiles.has(remotePath)) {\n if (!summary) {\n console.log(\n useColor\n ? chalk.yellow(`\\n - Only in remote: ${remotePath}`)\n : `\\n - Only in remote: ${remotePath}`,\n );\n }\n hasDifferences = true;\n }\n }\n\n return {\n objectName: parsed.name,\n objectType: parsed.type,\n hasDifferences,\n fileCount: localFiles.size,\n identicalCount,\n };\n}\n\nexport const diffCommand: CliCommandPlugin = {\n name: 'diff',\n description:\n 'Compare local abapGit files against SAP remote (any supported object type)',\n\n arguments: [\n {\n name: '[files...]',\n description: `Local .xml files or glob patterns to compare (e.g., zcl_myclass.clas.xml, *.tabl.xml). When omitted, scans the abapGit repo in the current directory. Supported types: ${getSupportedTypes().join(', ')}`,\n },\n ],\n\n options: [\n {\n flags: '--no-color',\n description: 'Disable colored output',\n },\n {\n flags: '-c, --context <lines>',\n description: 'Number of context lines in diff',\n default: '3',\n },\n {\n flags: '-s, --source',\n description: 'Compare ADK source instead of XML (TABL only)',\n },\n {\n flags: '-r, --raw',\n description:\n 'Compare ADT-level XML payloads (what GET returns vs what PUT would send)',\n },\n {\n flags: '-p, --package <name>',\n description:\n 'Scan all abapGit files in the current directory (package name is informational)',\n },\n {\n flags: '-f, --full',\n description:\n 'Show full unified diffs (default in single-file mode; in package/multi-file mode only summary is shown unless --full is given)',\n },\n ],\n\n async execute(args: Record<string, unknown>, ctx: CliContext) {\n const filePatterns = (args.files as string[]) ?? [];\n const contextLines = Number.parseInt(\n String((args.context as string | number | undefined) ?? '3'),\n 10,\n );\n const useColor = args.color !== false;\n const source = args.source === true;\n const raw = args.raw === true;\n const packageName = args.package as string | undefined;\n const fullDiffs = args.full === true;\n\n let files: string[];\n let scanMode = false;\n let repoRoot: string | undefined;\n\n if (filePatterns.length > 0) {\n // Explicit files/globs — expand as before\n files = await expandGlobs(filePatterns, ctx.cwd);\n if (files.length === 0) {\n ctx.logger.error('No files matched the given pattern(s).');\n process.exit(1);\n }\n } else {\n // No files given — scan mode.\n // If --package given, or auto-detect abapGit repo root from cwd.\n repoRoot = findAbapGitRoot(ctx.cwd);\n if (!repoRoot) {\n ctx.logger.error(\n packageName\n ? 'No .abapgit.xml found in current directory or parents.'\n : 'No files specified and no .abapgit.xml found. Usage: adt diff <file...> or run from an abapGit repo directory.',\n );\n process.exit(1);\n }\n\n scanMode = true;\n const scannedFiles = await scanAbapGitFiles(repoRoot);\n if (scannedFiles.length === 0) {\n ctx.logger.error('No supported abapGit objects found in repository.');\n process.exit(1);\n }\n\n // Convert to paths relative to cwd\n files = scannedFiles.map((f) => relative(ctx.cwd, join(repoRoot!, f)));\n\n const pkgSuffix = packageName ? ` (package: ${packageName})` : '';\n ctx.logger.info(\n `📦 Scanning ${scannedFiles.length} object(s) in ${repoRoot}${pkgSuffix}...`,\n );\n }\n\n // In scan mode default to summary (suppress diffs), unless --full\n const summaryMode = scanMode && !fullDiffs;\n\n // Need ADT client for remote comparison\n if (!ctx.getAdtClient) {\n ctx.logger.error('ADT client not available. Run: adt auth login');\n process.exit(1);\n }\n\n // Create ADT client and ADK once, shared across all files\n const client = await ctx.getAdtClient!();\n const adk = createAdk(client as AdtClient);\n\n // Diff each file\n const results: DiffResult[] = [];\n for (const file of files) {\n const result = await diffSingleFile(file, ctx, adk, {\n contextLines,\n useColor,\n source,\n raw,\n summary: summaryMode,\n });\n\n if (result.error && !summaryMode) {\n ctx.logger.error(result.error);\n }\n\n results.push(result);\n }\n\n // Summary\n const totalFiles = results.length;\n const withDiffs = results.filter((r) => r.hasDifferences).length;\n const withErrors = results.filter((r) => r.error).length;\n const identical = totalFiles - withDiffs - withErrors;\n\n console.log('');\n\n if (scanMode) {\n // Package/scan mode: always show per-object status table\n for (const r of results) {\n let icon: string;\n let line: string;\n if (r.error) {\n icon = '⚠️';\n line = `${r.objectType} ${r.objectName}: ${r.error}`;\n } else if (r.hasDifferences) {\n icon = '❌';\n line = `${r.objectType} ${r.objectName}`;\n } else {\n icon = '✅';\n line = `${r.objectType} ${r.objectName}`;\n }\n\n if (useColor) {\n if (r.error) {\n console.log(chalk.yellow(` ${icon} ${line}`));\n } else if (r.hasDifferences) {\n console.log(chalk.red(` ${icon} ${line}`));\n } else {\n console.log(chalk.green(` ${icon} ${line}`));\n }\n } else {\n console.log(` ${icon} ${line}`);\n }\n }\n\n console.log('');\n const summaryParts: string[] = [\n `${totalFiles} object(s)`,\n `${identical} identical`,\n ];\n if (withDiffs > 0) summaryParts.push(`${withDiffs} changed`);\n if (withErrors > 0) summaryParts.push(`${withErrors} errors`);\n const summaryLine = summaryParts.join(', ');\n\n if (withDiffs > 0 || withErrors > 0) {\n console.log(\n useColor ? chalk.red(`📋 ${summaryLine}`) : `📋 ${summaryLine}`,\n );\n process.exit(1);\n }\n console.log(\n useColor ? chalk.green(`📋 ${summaryLine}`) : `📋 ${summaryLine}`,\n );\n return;\n }\n\n if (totalFiles === 1) {\n // Single-file mode: keep original concise output\n const r = results[0];\n if (r.error) {\n // Error already printed above\n process.exit(1);\n }\n if (r.hasDifferences) {\n const identicalSuffix =\n r.identicalCount > 0\n ? ` (${r.identicalCount} file(s) identical)`\n : '';\n console.log(\n useColor\n ? chalk.red('Differences found.') +\n (r.identicalCount > 0 ? chalk.dim(identicalSuffix) : '')\n : `Differences found.${identicalSuffix}`,\n );\n process.exit(1);\n }\n console.log(\n useColor\n ? chalk.green(\n `No differences found. (${r.identicalCount} file(s) identical)`,\n )\n : `No differences found. (${r.identicalCount} file(s) identical)`,\n );\n return;\n }\n\n // Multi-file summary (explicit glob, not scan mode)\n const parts: string[] = [\n `${totalFiles} object(s) checked`,\n `${identical} identical`,\n ];\n if (withDiffs > 0) parts.push(`${withDiffs} with differences`);\n if (withErrors > 0) parts.push(`${withErrors} with errors`);\n const summaryText = parts.join(', ');\n\n if (withDiffs > 0 || withErrors > 0) {\n console.log(\n useColor\n ? chalk.red(`Diff summary: ${summaryText}`)\n : `Diff summary: ${summaryText}`,\n );\n process.exit(1);\n }\n console.log(\n useColor\n ? chalk.green(`Diff summary: ${summaryText}`)\n : `Diff summary: ${summaryText}`,\n );\n },\n};\n\nexport default diffCommand;\n"],"mappings":";;;;;;;;;;;AA0DA,MAAM,kBAA0C;CAC9C,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,KAAK;CACL,MAAM;CACN,MAAM;CACN,KAAK;CACL,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;AACR;;AAGA,MAAM,kCAAkB,IAAI,IAAI;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAM,gCAAgB,IAAI,IAAI;CAAC;CAAO;CAAQ;CAAQ;CAAQ;CAAQ;AAAM,CAAC;;AAG7E,MAAM,wCAAwB,IAAI,IAAI,CAAC,U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