@abapify/adt-diff 0.4.38 → 0.4.39
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.
|
@@ -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":";cAw/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-CSCLev1E.mjs";
|
|
@@ -524,7 +524,7 @@ function modeOptionsError(parsed, source, raw) {
|
|
|
524
524
|
}
|
|
525
525
|
/** Derive the ADK type from the local XML via fromAbapGit (fallback: filename). */
|
|
526
526
|
function resolveAdkType(handler, localXml, fallback) {
|
|
527
|
-
if (!handler
|
|
527
|
+
if (!handler?.fromAbapGit) return fallback;
|
|
528
528
|
try {
|
|
529
529
|
const values = handler.schema.parse(localXml)?.abapGit?.abap?.values ?? {};
|
|
530
530
|
const payload = handler.fromAbapGit(values);
|
|
@@ -551,7 +551,7 @@ function diffOnePair(localPath, localContent, remoteContent, handler, options) {
|
|
|
551
551
|
const isXml = localPath.endsWith(".xml");
|
|
552
552
|
let diffLocal = localContent;
|
|
553
553
|
let diffRemote = remoteContent;
|
|
554
|
-
if (isXml) [diffLocal, diffRemote] = normalizeXmlPair(localContent, remoteContent, handler);
|
|
554
|
+
if (isXml && handler) [diffLocal, diffRemote] = normalizeXmlPair(localContent, remoteContent, handler);
|
|
555
555
|
return printDiff(localPath, localPath, diffLocal, diffRemote, options.contextLines, options.useColor, options.summary);
|
|
556
556
|
}
|
|
557
557
|
/** Source format: compare ADK source (e.g. CDS DDL). */
|
|
@@ -587,7 +587,7 @@ async function diffRawMode(parsed, localXml, objectName, handler, remoteObj, opt
|
|
|
587
587
|
return errorResult(parsed, `Failed to build remote ADT XML: ${e instanceof Error ? e.message : String(e)}`, 1);
|
|
588
588
|
}
|
|
589
589
|
let localAdtXml;
|
|
590
|
-
if (handler
|
|
590
|
+
if (handler?.fromAbapGit) try {
|
|
591
591
|
const values = handler.schema.parse(localXml)?.abapGit?.abap?.values ?? {};
|
|
592
592
|
const localPayload = handler.fromAbapGit(values);
|
|
593
593
|
const merged = {
|
|
@@ -604,7 +604,8 @@ async function diffRawMode(parsed, localXml, objectName, handler, remoteObj, opt
|
|
|
604
604
|
}
|
|
605
605
|
/** Serialize remote with the handler and diff it file-by-file. */
|
|
606
606
|
async function diffFilesMode(parsed, localFiles, handler, remoteObj, options) {
|
|
607
|
-
const {
|
|
607
|
+
const { useColor, summary } = options;
|
|
608
|
+
if (!handler) return errorResult(parsed, `No format handler for ${parsed.type}`, localFiles.size);
|
|
608
609
|
let remoteFiles;
|
|
609
610
|
try {
|
|
610
611
|
remoteFiles = await handler.serialize(remoteObj);
|
|
@@ -622,11 +623,7 @@ async function diffFilesMode(parsed, localFiles, handler, remoteObj, options) {
|
|
|
622
623
|
hasDifferences = true;
|
|
623
624
|
continue;
|
|
624
625
|
}
|
|
625
|
-
if (diffOnePair(localPath, localContent, remoteContent, handler,
|
|
626
|
-
contextLines,
|
|
627
|
-
useColor,
|
|
628
|
-
summary
|
|
629
|
-
})) hasDifferences = true;
|
|
626
|
+
if (diffOnePair(localPath, localContent, remoteContent, handler, options)) hasDifferences = true;
|
|
630
627
|
else identicalCount++;
|
|
631
628
|
}
|
|
632
629
|
for (const [remotePath] of remoteMap) if (!localFiles.has(remotePath)) {
|
|
@@ -851,4 +848,4 @@ const diffCommand = {
|
|
|
851
848
|
};
|
|
852
849
|
export { tablXmlToCdsDdl as i, buildCdsDdl as n, parseTablXml as r, diffCommand as t };
|
|
853
850
|
|
|
854
|
-
//# sourceMappingURL=diff-
|
|
851
|
+
//# sourceMappingURL=diff-CSCLev1E.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-CSCLev1E.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 && handler) {\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 { useColor, summary } = options;\n\n // Serialize remote using the same handler → produces SerializedFile[]\n if (!handler) {\n return errorResult(\n parsed,\n `No format handler for ${parsed.type}`,\n localFiles.size,\n );\n }\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 options,\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;CAC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ACF;EAGA,MAAM,cAAc,YAAY,CAAC;EAGjC,IAAI,CAAC,IAAI,cAAc;GACrB,IAAI,OAAO,MAAM,+CAA+C;GAChE,QAAQ,KAAK,CAAC;EAChB;EAGA,MAAM,SAAS,MAAM,IAAI,aAAc;EACvC,MAAM,MAAM,UAAU,MAAmB;EAGzC,MAAM,UAAwB,CAAC;EAC/B,KAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,SAAS,MAAM,eAAe,MAAM,KAAK,KAAK;IAClD;IACA;IACA;IACA;IACA,SAAS;GACX,CAAC;GAED,IAAI,OAAO,SAAS,CAAC,aACnB,IAAI,OAAO,MAAM,OAAO,KAAK;GAG/B,QAAQ,KAAK,MAAM;EACrB;EAGA,MAAM,aAAa,QAAQ;EAC3B,MAAM,YAAY,QAAQ,QAAQ,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.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-CSCLev1E.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.39",
|
|
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.39",
|
|
31
|
+
"@abapify/adt-contracts": "0.4.39",
|
|
32
|
+
"@abapify/adt-plugin": "0.4.39",
|
|
33
|
+
"@abapify/adt-plugin-abapgit": "0.4.39",
|
|
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.39"
|
|
41
41
|
},
|
|
42
42
|
"repository": {
|
|
43
43
|
"type": "git",
|
|
@@ -1 +0,0 @@
|
|
|
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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