@abapify/adt-export 0.4.34 → 0.4.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { a as createFileTree, n as FilteredFileTree, o as findAbapGitRoot, s as resolveFilesRelativeToRoot, t as loadFormatPlugin } from "../format-plugin-BcmBEYgt.mjs";
1
+ import { a as createFileTree, n as FilteredFileTree, o as findAbapGitRoot, s as resolveFilesRelativeToRoot, t as loadFormatPlugin } from "../format-plugin-DeQBEqwE.mjs";
2
2
  import { AdkObjectSet, AdkPackage, createAdk } from "@abapify/adk";
3
3
  import { glob } from "node:fs/promises";
4
4
  import { join, relative } from "node:path";
@@ -55,7 +55,7 @@ async function normalizeXml(xml) {
55
55
  const { formatXmlAttributes } = await import("@abapify/adt-plugin-abapgit");
56
56
  normalized = formatXmlAttributes(normalized);
57
57
  return normalized;
58
- } catch (_err) {
58
+ } catch {
59
59
  return xml.trim();
60
60
  }
61
61
  }
@@ -83,6 +83,169 @@ async function expandGlobs(patterns, cwd) {
83
83
  else results.push(pattern);
84
84
  return results;
85
85
  }
86
+ /**
87
+ * Resolve the source path: explicit files resolve the abapGit repo root,
88
+ * otherwise the configured `--source` directory is used.
89
+ */
90
+ async function resolveSourcePath(options, ctx) {
91
+ const expandedFiles = options.files && options.files.length > 0 ? await expandGlobs(options.files, ctx.cwd) : void 0;
92
+ const specificFiles = expandedFiles && expandedFiles.length > 0 ? expandedFiles : void 0;
93
+ let sourcePath = options.source;
94
+ if (specificFiles) {
95
+ const repoRoot = findAbapGitRoot(ctx.cwd);
96
+ if (!repoRoot) {
97
+ ctx.logger.error("❌ No .abapgit.xml found in any parent directory.");
98
+ process.exit(1);
99
+ }
100
+ sourcePath = repoRoot;
101
+ }
102
+ return {
103
+ sourcePath,
104
+ specificFiles
105
+ };
106
+ }
107
+ /** Phase 1: deploy the selected objects to SAP. */
108
+ async function deployPhase(fileTree, client, adkContext, options, ctx) {
109
+ ctx.logger.info("\n═══ Phase 1: Deploy to SAP ═══");
110
+ const plugin = await loadFormatPlugin(options.format);
111
+ if (!plugin.format.export) {
112
+ ctx.logger.error(`❌ Plugin '${plugin.name}' does not support export`);
113
+ process.exit(1);
114
+ }
115
+ const exportOptions = {
116
+ rootPackage: options.package,
117
+ abapLanguageVersion: options.abapLanguageVersion
118
+ };
119
+ const objectTypes = options.types ? options.types.split(",").map((t) => t.trim().toUpperCase()) : void 0;
120
+ const deployedObjects = [];
121
+ const deployResult = await (await AdkObjectSet.fromGenerator(plugin.format.export(fileTree, client, exportOptions), adkContext, {
122
+ filter: objectTypes ? (obj) => {
123
+ const objType = obj.type.toUpperCase();
124
+ const objPrefix = objType.split("/")[0];
125
+ return objectTypes.includes(objType) || objectTypes.includes(objPrefix);
126
+ } : void 0,
127
+ onObject: (obj) => {
128
+ ctx.logger.info(` 📄 ${obj.kind} ${obj.name}`);
129
+ }
130
+ })).deploy({
131
+ transport: options.transport,
132
+ activate: options.activate,
133
+ mode: "upsert",
134
+ onProgress: (saved, total, obj) => {
135
+ if (obj._unchanged) ctx.logger.info(` ⏭️ [${saved}/${total}] ${obj.kind} ${obj.name} (unchanged)`);
136
+ else ctx.logger.info(` 💾 [${saved}/${total}] ${obj.kind} ${obj.name}`);
137
+ }
138
+ });
139
+ ctx.logger.info(` ✅ Deployed: ${deployResult.save.success} saved, ${deployResult.save.unchanged} unchanged, ${deployResult.save.failed} failed`);
140
+ if (deployResult.save.failed > 0) ctx.logger.warn(`⚠️ ${deployResult.save.failed} object(s) failed to deploy — continuing roundtrip for ${deployResult.save.success + deployResult.save.unchanged} successful objects`);
141
+ if (deployResult.save.success + deployResult.save.unchanged === 0) {
142
+ ctx.logger.error("❌ No objects deployed successfully — aborting.");
143
+ process.exit(1);
144
+ }
145
+ for (const result of deployResult.save.results) if (result.success) deployedObjects.push(result.object);
146
+ return {
147
+ plugin,
148
+ deployedObjects
149
+ };
150
+ }
151
+ /** Phase 2: load fresh from SAP and re-serialize to `tmpDir`. */
152
+ async function reimportPhase(deployedObjects, plugin, tmpDir, client, ctx) {
153
+ const adk = createAdk(client);
154
+ let reimported = 0;
155
+ let reimportFailed = 0;
156
+ for (const obj of deployedObjects) try {
157
+ const fresh = adk.get(obj.name, obj.type);
158
+ await fresh.load();
159
+ const importContext = { resolvePackagePath };
160
+ const result = await plugin.format.import(fresh, tmpDir, importContext);
161
+ if (result.success) {
162
+ reimported++;
163
+ ctx.logger.info(` ✅ ${obj.kind} ${obj.name}`);
164
+ } else {
165
+ reimportFailed++;
166
+ ctx.logger.error(` ❌ ${obj.kind} ${obj.name}: ${result.errors?.join(", ") || "unknown"}`);
167
+ }
168
+ } catch (err) {
169
+ reimportFailed++;
170
+ ctx.logger.error(` ❌ ${obj.kind} ${obj.name}: ${err instanceof Error ? err.message : String(err)}`);
171
+ }
172
+ if (plugin.hooks?.afterImport) await plugin.hooks.afterImport(tmpDir);
173
+ ctx.logger.info(` 📊 Reimported: ${reimported} success, ${reimportFailed} failed`);
174
+ }
175
+ /** Show diff with colors (skip file headers, keep hunk headers). */
176
+ function printColoredDiff(patch) {
177
+ const diffLines = patch.split("\n");
178
+ let lineCount = 0;
179
+ const maxLines = 50;
180
+ for (const line of diffLines) {
181
+ if (line.startsWith("---") || line.startsWith("+++")) continue;
182
+ if (lineCount >= maxLines) {
183
+ console.log(chalk.yellow(" ... (truncated, use --keep-tmp to inspect full files)"));
184
+ break;
185
+ }
186
+ if (line.startsWith("+")) console.log(chalk.green(` ${line}`));
187
+ else if (line.startsWith("-")) console.log(chalk.red(` ${line}`));
188
+ else if (line.startsWith("@@")) console.log(chalk.cyan(` ${line}`));
189
+ else if (line.trim()) console.log(chalk.gray(` ${line}`));
190
+ lineCount++;
191
+ }
192
+ }
193
+ /** Phase 3: compare original vs re-imported files. */
194
+ async function comparePhase(fileTree, tmpDir, options, ctx) {
195
+ const reimportedFiles = collectFiles(tmpDir).filter((f) => !f.endsWith(".abapgit.xml"));
196
+ let matches = 0;
197
+ let mismatches = 0;
198
+ let onlyOriginal = 0;
199
+ let onlyReimported = 0;
200
+ const reimportedByName = /* @__PURE__ */ new Map();
201
+ for (const f of reimportedFiles) {
202
+ const name = f.split("/").pop();
203
+ reimportedByName.set(name, f);
204
+ }
205
+ const originalXml = await fileTree.glob("**/*.xml");
206
+ const originalAbap = await fileTree.glob("**/*.abap");
207
+ const allOriginal = [...originalXml, ...originalAbap].filter((f) => !f.endsWith(".abapgit.xml") && !f.endsWith("package.devc.xml"));
208
+ for (const origRelPath of allOriginal) {
209
+ const origName = origRelPath.split("/").pop();
210
+ const reimportedRelPath = reimportedByName.get(origName);
211
+ if (!reimportedRelPath) {
212
+ onlyOriginal++;
213
+ ctx.logger.warn(` ⚠️ Only in original: ${origName}`);
214
+ continue;
215
+ }
216
+ reimportedByName.delete(origName);
217
+ let origContent = (await fileTree.read(origRelPath)).trim();
218
+ let reimContent = readFileSync(join(tmpDir, reimportedRelPath), "utf-8").trim();
219
+ origContent = origContent.replaceAll("\r\n", "\n");
220
+ reimContent = reimContent.replaceAll("\r\n", "\n");
221
+ if (origName.endsWith(".xml")) {
222
+ origContent = await normalizeXml(origContent);
223
+ reimContent = await normalizeXml(reimContent);
224
+ if (options.keepTmp) {
225
+ writeFileSync(join(tmpDir, "normalized-original-" + origName), origContent, "utf-8");
226
+ writeFileSync(join(tmpDir, "normalized-reimported-" + origName), reimContent, "utf-8");
227
+ }
228
+ }
229
+ if (origContent === reimContent) {
230
+ matches++;
231
+ ctx.logger.info(` ✅ ${origName}`);
232
+ } else {
233
+ mismatches++;
234
+ ctx.logger.error(` ❌ ${origName} — DIFFERS`);
235
+ printColoredDiff(createTwoFilesPatch(`original/${origName}`, `reimported/${origName}`, origContent, reimContent, "", "", { context: 3 }));
236
+ }
237
+ }
238
+ for (const [name] of reimportedByName) {
239
+ onlyReimported++;
240
+ ctx.logger.warn(` ⚠️ Only in reimported: ${name}`);
241
+ }
242
+ return {
243
+ matches,
244
+ mismatches,
245
+ onlyOriginal,
246
+ onlyReimported
247
+ };
248
+ }
86
249
  const roundtripCommand = {
87
250
  name: "roundtrip",
88
251
  description: "Deploy files to SAP, import back, and compare (roundtrip test)",
@@ -134,17 +297,7 @@ const roundtripCommand = {
134
297
  ctx.logger.error("❌ ADT client not available. Run: adt auth login");
135
298
  process.exit(1);
136
299
  }
137
- const expandedFiles = options.files && options.files.length > 0 ? await expandGlobs(options.files, ctx.cwd) : void 0;
138
- const specificFiles = expandedFiles && expandedFiles.length > 0 ? expandedFiles : void 0;
139
- let sourcePath = options.source;
140
- if (specificFiles) {
141
- const repoRoot = findAbapGitRoot(ctx.cwd);
142
- if (!repoRoot) {
143
- ctx.logger.error("❌ No .abapgit.xml found in any parent directory.");
144
- process.exit(1);
145
- }
146
- sourcePath = repoRoot;
147
- }
300
+ const { sourcePath, specificFiles } = await resolveSourcePath(options, ctx);
148
301
  ctx.logger.info("🔄 Roundtrip test");
149
302
  ctx.logger.info(`📁 Source: ${sourcePath}`);
150
303
  if (specificFiles) ctx.logger.info(`📄 Files: ${specificFiles.join(", ")}`);
@@ -155,44 +308,7 @@ const roundtripCommand = {
155
308
  fileTree = new FilteredFileTree(fileTree, relFiles);
156
309
  }
157
310
  const client = await ctx.getAdtClient();
158
- const adkContext = { client };
159
- ctx.logger.info("\n═══ Phase 1: Deploy to SAP ═══");
160
- const plugin = await loadFormatPlugin(options.format);
161
- if (!plugin.format.export) {
162
- ctx.logger.error(`❌ Plugin '${plugin.name}' does not support export`);
163
- process.exit(1);
164
- }
165
- const exportOptions = {
166
- rootPackage: options.package,
167
- abapLanguageVersion: options.abapLanguageVersion
168
- };
169
- const objectTypes = options.types ? options.types.split(",").map((t) => t.trim().toUpperCase()) : void 0;
170
- const deployedObjects = [];
171
- const deployResult = await (await AdkObjectSet.fromGenerator(plugin.format.export(fileTree, client, exportOptions), adkContext, {
172
- filter: objectTypes ? (obj) => {
173
- const objType = obj.type.toUpperCase();
174
- const objPrefix = objType.split("/")[0];
175
- return objectTypes.includes(objType) || objectTypes.includes(objPrefix);
176
- } : void 0,
177
- onObject: (obj) => {
178
- ctx.logger.info(` 📄 ${obj.kind} ${obj.name}`);
179
- }
180
- })).deploy({
181
- transport: options.transport,
182
- activate: options.activate,
183
- mode: "upsert",
184
- onProgress: (saved, total, obj) => {
185
- if (obj._unchanged) ctx.logger.info(` ⏭️ [${saved}/${total}] ${obj.kind} ${obj.name} (unchanged)`);
186
- else ctx.logger.info(` 💾 [${saved}/${total}] ${obj.kind} ${obj.name}`);
187
- }
188
- });
189
- ctx.logger.info(` ✅ Deployed: ${deployResult.save.success} saved, ${deployResult.save.unchanged} unchanged, ${deployResult.save.failed} failed`);
190
- if (deployResult.save.failed > 0) ctx.logger.warn(`⚠️ ${deployResult.save.failed} object(s) failed to deploy — continuing roundtrip for ${deployResult.save.success + deployResult.save.unchanged} successful objects`);
191
- if (deployResult.save.success + deployResult.save.unchanged === 0) {
192
- ctx.logger.error("❌ No objects deployed successfully — aborting.");
193
- process.exit(1);
194
- }
195
- for (const result of deployResult.save.results) if (result.success) deployedObjects.push(result.object);
311
+ const { plugin, deployedObjects } = await deployPhase(fileTree, client, { client }, options, ctx);
196
312
  ctx.logger.info("\n═══ Phase 2: Import back from SAP ═══");
197
313
  if (!plugin.format.import) {
198
314
  ctx.logger.error(`❌ Plugin '${plugin.name}' does not support import`);
@@ -201,89 +317,9 @@ const roundtripCommand = {
201
317
  const tmpDir = join(tmpdir(), `adt-roundtrip-${Date.now()}`);
202
318
  mkdirSync(tmpDir, { recursive: true });
203
319
  ctx.logger.info(` 📂 Temp dir: ${tmpDir}`);
204
- const adk = createAdk(client);
205
- let reimported = 0;
206
- let reimportFailed = 0;
207
- for (const obj of deployedObjects) try {
208
- const fresh = adk.get(obj.name, obj.type);
209
- await fresh.load();
210
- const importContext = { resolvePackagePath };
211
- const result = await plugin.format.import(fresh, tmpDir, importContext);
212
- if (result.success) {
213
- reimported++;
214
- ctx.logger.info(` ✅ ${obj.kind} ${obj.name}`);
215
- } else {
216
- reimportFailed++;
217
- ctx.logger.error(` ❌ ${obj.kind} ${obj.name}: ${result.errors?.join(", ") || "unknown"}`);
218
- }
219
- } catch (err) {
220
- reimportFailed++;
221
- ctx.logger.error(` ❌ ${obj.kind} ${obj.name}: ${err instanceof Error ? err.message : String(err)}`);
222
- }
223
- if (plugin.hooks?.afterImport) await plugin.hooks.afterImport(tmpDir);
224
- ctx.logger.info(` 📊 Reimported: ${reimported} success, ${reimportFailed} failed`);
320
+ await reimportPhase(deployedObjects, plugin, tmpDir, client, ctx);
225
321
  ctx.logger.info("\n═══ Phase 3: Compare ═══");
226
- const reimportedFiles = collectFiles(tmpDir).filter((f) => !f.endsWith(".abapgit.xml"));
227
- let matches = 0;
228
- let mismatches = 0;
229
- let onlyOriginal = 0;
230
- let onlyReimported = 0;
231
- const reimportedByName = /* @__PURE__ */ new Map();
232
- for (const f of reimportedFiles) {
233
- const name = f.split("/").pop();
234
- reimportedByName.set(name, f);
235
- }
236
- const originalXml = await fileTree.glob("**/*.xml");
237
- const originalAbap = await fileTree.glob("**/*.abap");
238
- const allOriginal = [...originalXml, ...originalAbap].filter((f) => !f.endsWith(".abapgit.xml") && !f.endsWith("package.devc.xml"));
239
- for (const origRelPath of allOriginal) {
240
- const origName = origRelPath.split("/").pop();
241
- const reimportedRelPath = reimportedByName.get(origName);
242
- if (!reimportedRelPath) {
243
- onlyOriginal++;
244
- ctx.logger.warn(` ⚠️ Only in original: ${origName}`);
245
- continue;
246
- }
247
- reimportedByName.delete(origName);
248
- let origContent = (await fileTree.read(origRelPath)).trim();
249
- let reimContent = readFileSync(join(tmpDir, reimportedRelPath), "utf-8").trim();
250
- origContent = origContent.replaceAll(/\r\n/g, "\n");
251
- reimContent = reimContent.replaceAll(/\r\n/g, "\n");
252
- if (origName.endsWith(".xml")) {
253
- origContent = await normalizeXml(origContent);
254
- reimContent = await normalizeXml(reimContent);
255
- if (options.keepTmp) {
256
- writeFileSync(join(tmpDir, "normalized-original-" + origName), origContent, "utf-8");
257
- writeFileSync(join(tmpDir, "normalized-reimported-" + origName), reimContent, "utf-8");
258
- }
259
- }
260
- if (origContent === reimContent) {
261
- matches++;
262
- ctx.logger.info(` ✅ ${origName}`);
263
- } else {
264
- mismatches++;
265
- ctx.logger.error(` ❌ ${origName} — DIFFERS`);
266
- const diffLines = createTwoFilesPatch(`original/${origName}`, `reimported/${origName}`, origContent, reimContent, "", "", { context: 3 }).split("\n");
267
- let lineCount = 0;
268
- const maxLines = 50;
269
- for (const line of diffLines) {
270
- if (line.startsWith("---") || line.startsWith("+++")) continue;
271
- if (lineCount >= maxLines) {
272
- console.log(chalk.yellow(" ... (truncated, use --keep-tmp to inspect full files)"));
273
- break;
274
- }
275
- if (line.startsWith("+")) console.log(chalk.green(` ${line}`));
276
- else if (line.startsWith("-")) console.log(chalk.red(` ${line}`));
277
- else if (line.startsWith("@@")) console.log(chalk.cyan(` ${line}`));
278
- else if (line.trim()) console.log(chalk.gray(` ${line}`));
279
- lineCount++;
280
- }
281
- }
282
- }
283
- for (const [name] of reimportedByName) {
284
- onlyReimported++;
285
- ctx.logger.warn(` ⚠️ Only in reimported: ${name}`);
286
- }
322
+ const { matches, mismatches, onlyOriginal, onlyReimported } = await comparePhase(fileTree, tmpDir, options, ctx);
287
323
  ctx.logger.info("\n═══ Summary ═══");
288
324
  ctx.logger.info(` ✅ Matching: ${matches}`);
289
325
  if (mismatches > 0) ctx.logger.error(` ❌ Mismatches: ${mismatches}`);
@@ -1 +1 @@
1
- {"version":3,"file":"roundtrip.mjs","names":["nativeGlob"],"sources":["../../src/commands/roundtrip.ts"],"sourcesContent":["/**\n * Roundtrip Command Plugin\n *\n * Deploys local files to SAP, imports them back, and compares\n * the original with the re-serialized result.\n *\n * Usage:\n * adt roundtrip zage_fixed_values.doma.xml -p ZABAPGIT_EXAMPLES\n * adt roundtrip *.doma.xml -p ZABAPGIT_EXAMPLES (glob pattern)\n * adt roundtrip -s ./my-repo -p ZPACKAGE (all files)\n */\n\nimport type {\n CliCommandPlugin,\n CliContext,\n ExportOptions,\n ImportContext,\n} from '@abapify/adt-plugin';\nimport {\n AdkObjectSet,\n AdkPackage,\n type AdkContext,\n type AdkObject,\n type AdtClient,\n createAdk,\n} from '@abapify/adk';\nimport {\n createFileTree,\n FilteredFileTree,\n findAbapGitRoot,\n resolveFilesRelativeToRoot,\n} from '../utils/filetree';\nimport { loadFormatPlugin } from '../utils/format-plugin';\nimport {\n mkdirSync,\n rmSync,\n readFileSync,\n writeFileSync,\n readdirSync,\n statSync,\n} from 'node:fs';\nimport { glob as nativeGlob } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { tmpdir } from 'node:os';\nimport { createTwoFilesPatch } from 'diff';\nimport chalk from 'chalk';\nimport { XMLParser, XMLBuilder } from 'fast-xml-parser';\n\n/**\n * Resolve full package path from SAP (walks super packages upward)\n * Uses global ADK context (set when client is initialized)\n */\nasync function resolvePackagePath(packageName: string): Promise<string[]> {\n const path: string[] = [];\n let current = packageName;\n while (current) {\n path.unshift(current);\n try {\n const pkg = await AdkPackage.get(current);\n const superPkg = pkg.superPackage;\n if (superPkg?.name) {\n current = superPkg.name;\n } else {\n break;\n }\n } catch {\n break;\n }\n }\n return path;\n}\n\n/**\n * Normalize XML for comparison\n * - Preserve namespace prefixes and declarations\n * - Normalize whitespace and indentation\n * - Format attributes on separate lines\n */\nasync function normalizeXml(xml: string): Promise<string> {\n try {\n const parser = new XMLParser({\n ignoreAttributes: false,\n attributeNamePrefix: '@_',\n trimValues: true,\n parseTagValue: false,\n parseAttributeValue: false,\n removeNSPrefix: false, // Keep namespace prefixes\n });\n\n const builder = new XMLBuilder({\n ignoreAttributes: false,\n attributeNamePrefix: '@_',\n format: true,\n indentBy: ' ',\n suppressEmptyNode: false,\n });\n\n // Parse → normalize → rebuild\n const obj = parser.parse(xml);\n let normalized = builder.build(obj);\n\n // Format attributes on separate lines for better diff readability\n const { formatXmlAttributes } = await import('@abapify/adt-plugin-abapgit');\n normalized = formatXmlAttributes(normalized);\n\n return normalized;\n } catch (_err) {\n // If parsing fails, return trimmed original\n return xml.trim();\n }\n}\n\n/**\n * Recursively collect all files in a directory (relative paths)\n */\nfunction collectFiles(dir: string, base?: string): string[] {\n const result: string[] = [];\n const baseDir = base ?? dir;\n for (const entry of readdirSync(dir)) {\n const full = join(dir, entry);\n const rel = relative(baseDir, full);\n if (statSync(full).isDirectory()) {\n result.push(...collectFiles(full, baseDir));\n } else {\n result.push(rel);\n }\n }\n return result;\n}\n\n/**\n * Expand glob patterns in a list of file arguments.\n * Literal filenames (no glob characters) pass through unchanged.\n */\nasync function expandGlobs(patterns: string[], cwd: string): Promise<string[]> {\n const results: string[] = [];\n for (const pattern of patterns) {\n if (/[*?[\\]{}]/.test(pattern)) {\n for await (const match of nativeGlob(pattern, { cwd })) {\n results.push(match);\n }\n } else {\n results.push(pattern);\n }\n }\n return results;\n}\n\nexport const roundtripCommand: CliCommandPlugin = {\n name: 'roundtrip',\n description: 'Deploy files to SAP, import back, and compare (roundtrip test)',\n\n arguments: [\n {\n name: '[files...]',\n description:\n 'Specific files or glob patterns to test (e.g., zage_fixed_values.doma.xml, *.doma.xml). Omit to test all.',\n },\n ],\n\n options: [\n {\n flags: '-s, --source <path>',\n description: 'Source directory containing serialized files',\n default: '.',\n },\n {\n flags: '-f, --format <format>',\n description: 'Format plugin: abapgit | @abapify/adt-plugin-abapgit',\n default: 'abapgit',\n },\n {\n flags: '-p, --package <package>',\n description: 'Target package for new objects',\n },\n {\n flags: '-t, --transport <request>',\n description: 'Transport request for changes',\n },\n {\n flags: '--types <types>',\n description: 'Filter by object types (comma-separated)',\n },\n {\n flags: '--activate',\n description: 'Activate objects after deploy (use --no-activate to skip)',\n default: true,\n },\n {\n flags: '--keep-tmp',\n description: 'Keep temporary reimport directory for inspection',\n default: false,\n },\n {\n flags: '--abap-language-version <version>',\n description: 'ABAP language version for new objects (2=keyUser, 5=cloud)',\n },\n ],\n\n async execute(args: Record<string, unknown>, ctx: CliContext) {\n const options = args as {\n files?: string[];\n source: string;\n format: string;\n transport?: string;\n package?: string;\n types?: string;\n activate?: boolean;\n keepTmp?: boolean;\n abapLanguageVersion?: string;\n };\n\n if (!ctx.getAdtClient) {\n ctx.logger.error('❌ ADT client not available. Run: adt auth login');\n process.exit(1);\n }\n\n // ── Resolve source path ──\n const expandedFiles =\n options.files && options.files.length > 0\n ? await expandGlobs(options.files, ctx.cwd)\n : undefined;\n const specificFiles =\n expandedFiles && expandedFiles.length > 0 ? expandedFiles : undefined;\n let sourcePath = options.source;\n\n if (specificFiles) {\n const repoRoot = findAbapGitRoot(ctx.cwd);\n if (!repoRoot) {\n ctx.logger.error('❌ No .abapgit.xml found in any parent directory.');\n process.exit(1);\n }\n sourcePath = repoRoot;\n }\n\n ctx.logger.info('🔄 Roundtrip test');\n ctx.logger.info(`📁 Source: ${sourcePath}`);\n if (specificFiles) ctx.logger.info(`📄 Files: ${specificFiles.join(', ')}`);\n if (options.package) ctx.logger.info(`📦 Package: ${options.package}`);\n\n // ── Build FileTree ──\n let fileTree = createFileTree(sourcePath);\n if (specificFiles) {\n const relFiles = resolveFilesRelativeToRoot(\n specificFiles,\n ctx.cwd,\n sourcePath,\n );\n fileTree = new FilteredFileTree(fileTree, relFiles);\n }\n\n const client = await ctx.getAdtClient!();\n const adkContext: AdkContext = { client: client as any };\n\n // ── Phase 1: Deploy ──\n ctx.logger.info('\\n═══ Phase 1: Deploy to SAP ═══');\n\n const plugin = await loadFormatPlugin(options.format);\n if (!plugin.format.export) {\n ctx.logger.error(`❌ Plugin '${plugin.name}' does not support export`);\n process.exit(1);\n }\n\n const exportOptions: ExportOptions = {\n rootPackage: options.package,\n abapLanguageVersion: options.abapLanguageVersion,\n };\n\n // Parse object types filter\n const objectTypes = options.types\n ? options.types.split(',').map((t: string) => t.trim().toUpperCase())\n : undefined;\n\n const deployedObjects: AdkObject[] = [];\n const objectSet = await AdkObjectSet.fromGenerator(\n plugin.format.export(fileTree, client, exportOptions),\n adkContext,\n {\n filter: objectTypes\n ? (obj) => {\n const objType = obj.type.toUpperCase();\n const objPrefix = objType.split('/')[0];\n return (\n objectTypes.includes(objType) || objectTypes.includes(objPrefix)\n );\n }\n : undefined,\n onObject: (obj) => {\n ctx.logger.info(` 📄 ${obj.kind} ${obj.name}`);\n },\n },\n );\n\n const deployResult = await objectSet.deploy({\n transport: options.transport,\n activate: options.activate,\n mode: 'upsert',\n onProgress: (saved, total, obj) => {\n if (obj._unchanged) {\n ctx.logger.info(\n ` ⏭️ [${saved}/${total}] ${obj.kind} ${obj.name} (unchanged)`,\n );\n } else {\n ctx.logger.info(` 💾 [${saved}/${total}] ${obj.kind} ${obj.name}`);\n }\n },\n });\n\n ctx.logger.info(\n ` ✅ Deployed: ${deployResult.save.success} saved, ${deployResult.save.unchanged} unchanged, ${deployResult.save.failed} failed`,\n );\n\n if (deployResult.save.failed > 0) {\n ctx.logger.warn(\n `⚠️ ${deployResult.save.failed} object(s) failed to deploy — continuing roundtrip for ${deployResult.save.success + deployResult.save.unchanged} successful objects`,\n );\n }\n\n if (deployResult.save.success + deployResult.save.unchanged === 0) {\n ctx.logger.error('❌ No objects deployed successfully — aborting.');\n process.exit(1);\n }\n\n // Collect only successfully deployed objects for reimport\n for (const result of deployResult.save.results) {\n if (result.success) {\n deployedObjects.push(result.object);\n }\n }\n\n // ── Phase 2: Import back from SAP ──\n ctx.logger.info('\\n═══ Phase 2: Import back from SAP ═══');\n\n if (!plugin.format.import) {\n ctx.logger.error(`❌ Plugin '${plugin.name}' does not support import`);\n process.exit(1);\n }\n\n const tmpDir = join(tmpdir(), `adt-roundtrip-${Date.now()}`);\n mkdirSync(tmpDir, { recursive: true });\n ctx.logger.info(` 📂 Temp dir: ${tmpDir}`);\n\n const adk = createAdk(client as AdtClient);\n let reimported = 0;\n let reimportFailed = 0;\n\n for (const obj of deployedObjects) {\n try {\n // Load fresh from SAP\n const fresh = adk.get(obj.name, obj.type);\n await (fresh as any).load();\n\n // Build import context with package path resolver\n const importContext: ImportContext = {\n resolvePackagePath,\n };\n\n // Serialize back to local files using format plugin\n const result = await plugin.format.import(\n fresh as any,\n tmpDir,\n importContext,\n );\n\n if (result.success) {\n reimported++;\n ctx.logger.info(` ✅ ${obj.kind} ${obj.name}`);\n } else {\n reimportFailed++;\n ctx.logger.error(\n ` ❌ ${obj.kind} ${obj.name}: ${result.errors?.join(', ') || 'unknown'}`,\n );\n }\n } catch (err) {\n reimportFailed++;\n ctx.logger.error(\n ` ❌ ${obj.kind} ${obj.name}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n // Call afterImport hook (generates .abapgit.xml etc)\n if (plugin.hooks?.afterImport) {\n await plugin.hooks.afterImport(tmpDir);\n }\n\n ctx.logger.info(\n ` 📊 Reimported: ${reimported} success, ${reimportFailed} failed`,\n );\n\n // ── Phase 3: Compare ──\n ctx.logger.info('\\n═══ Phase 3: Compare ═══');\n\n // Collect re-imported files (skip .abapgit.xml — generated metadata)\n const reimportedFiles = collectFiles(tmpDir).filter(\n (f) => !f.endsWith('.abapgit.xml'),\n );\n\n let matches = 0;\n let mismatches = 0;\n let onlyOriginal = 0;\n let onlyReimported = 0;\n\n // Map reimported files by their filename (last segment) for matching\n const reimportedByName = new Map<string, string>();\n for (const f of reimportedFiles) {\n const name = f.split('/').pop()!;\n reimportedByName.set(name, f);\n }\n\n // Get original files from the FileTree\n const originalXml = await fileTree.glob('**/*.xml');\n const originalAbap = await fileTree.glob('**/*.abap');\n const allOriginal = [...originalXml, ...originalAbap].filter(\n (f) => !f.endsWith('.abapgit.xml') && !f.endsWith('package.devc.xml'),\n );\n\n for (const origRelPath of allOriginal) {\n const origName = origRelPath.split('/').pop()!;\n const reimportedRelPath = reimportedByName.get(origName);\n\n if (!reimportedRelPath) {\n onlyOriginal++;\n ctx.logger.warn(` ⚠️ Only in original: ${origName}`);\n continue;\n }\n\n // Remove from map so we can track reimported-only files\n reimportedByName.delete(origName);\n\n // Read original from FileTree, reimported from disk\n let origContent = (await fileTree.read(origRelPath)).trim();\n let reimContent = readFileSync(\n join(tmpDir, reimportedRelPath),\n 'utf-8',\n ).trim();\n\n // Normalize line endings (SAP returns CRLF, git uses LF)\n origContent = origContent.replaceAll(/\\r\\n/g, '\\n');\n reimContent = reimContent.replaceAll(/\\r\\n/g, '\\n');\n\n // Normalize XML files before comparison\n const isXml = origName.endsWith('.xml');\n if (isXml) {\n origContent = await normalizeXml(origContent);\n reimContent = await normalizeXml(reimContent);\n\n // Save normalized files for inspection\n if (options.keepTmp) {\n writeFileSync(\n join(tmpDir, 'normalized-original-' + origName),\n origContent,\n 'utf-8',\n );\n writeFileSync(\n join(tmpDir, 'normalized-reimported-' + origName),\n reimContent,\n 'utf-8',\n );\n }\n }\n\n // Compare content\n if (origContent === reimContent) {\n matches++;\n ctx.logger.info(` ✅ ${origName}`);\n } else {\n mismatches++;\n ctx.logger.error(` ❌ ${origName} — DIFFERS`);\n\n // Generate unified diff\n const patch = createTwoFilesPatch(\n `original/${origName}`,\n `reimported/${origName}`,\n origContent,\n reimContent,\n '',\n '',\n { context: 3 },\n );\n\n // Show diff with colors (skip file headers, keep hunk headers)\n const diffLines = patch.split('\\n');\n let lineCount = 0;\n const maxLines = 50;\n\n for (const line of diffLines) {\n // Skip file path headers (--- and +++)\n if (line.startsWith('---') || line.startsWith('+++')) {\n continue;\n }\n\n if (lineCount >= maxLines) {\n console.log(\n chalk.yellow(\n ' ... (truncated, use --keep-tmp to inspect full files)',\n ),\n );\n break;\n }\n\n 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 if (line.trim()) {\n console.log(chalk.gray(` ${line}`));\n }\n\n lineCount++;\n }\n }\n }\n\n // Files only in reimported\n for (const [name] of reimportedByName) {\n onlyReimported++;\n ctx.logger.warn(` ⚠️ Only in reimported: ${name}`);\n }\n\n // ── Summary ──\n ctx.logger.info('\\n═══ Summary ═══');\n ctx.logger.info(` ✅ Matching: ${matches}`);\n if (mismatches > 0) ctx.logger.error(` ❌ Mismatches: ${mismatches}`);\n if (onlyOriginal > 0)\n ctx.logger.warn(` ⚠️ Only in original: ${onlyOriginal}`);\n if (onlyReimported > 0)\n ctx.logger.warn(` ⚠️ Only in reimported: ${onlyReimported}`);\n\n if (options.keepTmp) {\n ctx.logger.info(`\\n📂 Temp dir kept: ${tmpDir}`);\n } else {\n rmSync(tmpDir, { recursive: true, force: true });\n }\n\n if (mismatches > 0) {\n ctx.logger.error('\\n❌ Roundtrip test FAILED');\n process.exit(1);\n }\n\n ctx.logger.info('\\n✅ Roundtrip test PASSED');\n },\n};\n\nexport default roundtripCommand;\n"],"mappings":";;;;;;;;;;;;;;AAoDA,eAAe,mBAAmB,aAAwC;CACxE,MAAM,OAAiB,CAAC;CACxB,IAAI,UAAU;CACd,OAAO,SAAS;EACd,KAAK,QAAQ,OAAO;EACpB,IAAI;GAEF,MAAM,YAAW,MADC,WAAW,IAAI,OAAO,EAAA,CACnB;GACrB,IAAI,UAAU,MACZ,UAAU,SAAS;QAEnB;EAEJ,QAAQ;GACN;EACF;CACF;CACA,OAAO;AACT;;;;;;;AAQA,eAAe,aAAa,KAA8B;CACxD,IAAI;EACF,MAAM,SAAS,IAAI,UAAU;GAC3B,kBAAkB;GAClB,qBAAqB;GACrB,YAAY;GACZ,eAAe;GACf,qBAAqB;GACrB,gBAAgB;EAClB,CAAC;EAED,MAAM,UAAU,IAAI,WAAW;GAC7B,kBAAkB;GAClB,qBAAqB;GACrB,QAAQ;GACR,UAAU;GACV,mBAAmB;EACrB,CAAC;EAGD,MAAM,MAAM,OAAO,MAAM,GAAG;EAC5B,IAAI,aAAa,QAAQ,MAAM,GAAG;EAGlC,MAAM,EAAE,wBAAwB,MAAM,OAAO;EAC7C,aAAa,oBAAoB,UAAU;EAE3C,OAAO;CACT,SAAS,MAAM;EAEb,OAAO,IAAI,KAAK;CAClB;AACF;;;;AAKA,SAAS,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OACJ,6DACF,CACF;MACA;KACF;KAEA,IAAI,KAAK,WAAW,GAAG,GACrB,QAAQ,IAAI,MAAM,MAAM,SAAS,MAAM,CAAC;UACnC,IAAI,KAAK,WAAW,GAAG,GAC5B,QAAQ,IAAI,MAAM,IAAI,SAAS,MAAM,CAAC;UACjC,IAAI,KAAK,WAAW,IAAI,GAC7B,QAAQ,IAAI,MAAM,KAAK,SAAS,MAAM,CAAC;UAClC,IAAI,KAAK,KAAK,GACnB,QAAQ,IAAI,MAAM,KAAK,SAAS,MAAM,CAAC;KAGzC;IACF;GACF;EACF;EAGA,KAAK,MAAM,CAAC,SAAS,kBAAkB;GACrC;GACA,IAAI,OAAO,KAAK,6BAA6B,MAAM;EACrD;EAGA,IAAI,OAAO,KAAK,mBAAmB;EACnC,IAAI,OAAO,KAAK,kBAAkB,SAAS;EAC3C,IAAI,aAAa,GAAG,IAAI,OAAO,MAAM,oBAAoB,YAAY;EACrE,IAAI,eAAe,GACjB,IAAI,OAAO,KAAK,2BAA2B,cAAc;EAC3D,IAAI,iBAAiB,GACnB,IAAI,OAAO,KAAK,6BAA6B,gBAAgB;EAE/D,IAAI,QAAQ,SACV,IAAI,OAAO,KAAK,uBAAuB,QAAQ;OAE/C,OAAO,QAAQ;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EAGjD,IAAI,aAAa,GAAG;GAClB,IAAI,OAAO,MAAM,2BAA2B;GAC5C,QAAQ,KAAK,CAAC;EAChB;EAEA,IAAI,OAAO,KAAK,2BAA2B;CAC7C;AACF"}
1
+ {"version":3,"file":"roundtrip.mjs","names":["nativeGlob"],"sources":["../../src/commands/roundtrip.ts"],"sourcesContent":["/**\n * Roundtrip Command Plugin\n *\n * Deploys local files to SAP, imports them back, and compares\n * the original with the re-serialized result.\n *\n * Usage:\n * adt roundtrip zage_fixed_values.doma.xml -p ZABAPGIT_EXAMPLES\n * adt roundtrip *.doma.xml -p ZABAPGIT_EXAMPLES (glob pattern)\n * adt roundtrip -s ./my-repo -p ZPACKAGE (all files)\n */\n\nimport type {\n CliCommandPlugin,\n CliContext,\n ExportOptions,\n FileTree,\n ImportContext,\n} from '@abapify/adt-plugin';\nimport {\n AdkObjectSet,\n AdkPackage,\n type AdkContext,\n type AdkObject,\n type AdtClient,\n createAdk,\n} from '@abapify/adk';\nimport {\n createFileTree,\n FilteredFileTree,\n findAbapGitRoot,\n resolveFilesRelativeToRoot,\n} from '../utils/filetree';\nimport { loadFormatPlugin } from '../utils/format-plugin';\nimport {\n mkdirSync,\n rmSync,\n readFileSync,\n writeFileSync,\n readdirSync,\n statSync,\n} from 'node:fs';\nimport { glob as nativeGlob } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { tmpdir } from 'node:os';\nimport { createTwoFilesPatch } from 'diff';\nimport chalk from 'chalk';\nimport { XMLParser, XMLBuilder } from 'fast-xml-parser';\n\n/**\n * Resolve full package path from SAP (walks super packages upward)\n * Uses global ADK context (set when client is initialized)\n */\nasync function resolvePackagePath(packageName: string): Promise<string[]> {\n const path: string[] = [];\n let current = packageName;\n while (current) {\n path.unshift(current);\n try {\n const pkg = await AdkPackage.get(current);\n const superPkg = pkg.superPackage;\n if (superPkg?.name) {\n current = superPkg.name;\n } else {\n break;\n }\n } catch {\n break;\n }\n }\n return path;\n}\n\n/**\n * Normalize XML for comparison\n * - Preserve namespace prefixes and declarations\n * - Normalize whitespace and indentation\n * - Format attributes on separate lines\n */\nasync function normalizeXml(xml: string): Promise<string> {\n try {\n const parser = new XMLParser({\n ignoreAttributes: false,\n attributeNamePrefix: '@_',\n trimValues: true,\n parseTagValue: false,\n parseAttributeValue: false,\n removeNSPrefix: false, // Keep namespace prefixes\n });\n\n const builder = new XMLBuilder({\n ignoreAttributes: false,\n attributeNamePrefix: '@_',\n format: true,\n indentBy: ' ',\n suppressEmptyNode: false,\n });\n\n // Parse → normalize → rebuild\n const obj = parser.parse(xml);\n let normalized = builder.build(obj);\n\n // Format attributes on separate lines for better diff readability\n const { formatXmlAttributes } = await import('@abapify/adt-plugin-abapgit');\n normalized = formatXmlAttributes(normalized);\n\n return normalized;\n } catch {\n // The exception is ignored on purpose: normalizeXml runs on round-trip\n // input that may legitimately be malformed or non-XML, and falling back\n // to the trimmed original is the desired outcome in that case.\n return xml.trim();\n }\n}\n\n/**\n * Recursively collect all files in a directory (relative paths)\n */\nfunction collectFiles(dir: string, base?: string): string[] {\n const result: string[] = [];\n const baseDir = base ?? dir;\n for (const entry of readdirSync(dir)) {\n const full = join(dir, entry);\n const rel = relative(baseDir, full);\n if (statSync(full).isDirectory()) {\n result.push(...collectFiles(full, baseDir));\n } else {\n result.push(rel);\n }\n }\n return result;\n}\n\n/**\n * Expand glob patterns in a list of file arguments.\n * Literal filenames (no glob characters) pass through unchanged.\n */\nasync function expandGlobs(patterns: string[], cwd: string): Promise<string[]> {\n const results: string[] = [];\n for (const pattern of patterns) {\n if (/[*?[\\]{}]/.test(pattern)) {\n for await (const match of nativeGlob(pattern, { cwd })) {\n results.push(match);\n }\n } else {\n results.push(pattern);\n }\n }\n return results;\n}\n\n/** CLI options parsed for the `roundtrip` command. */\ninterface RoundtripCliOptions {\n files?: string[];\n source: string;\n format: string;\n transport?: string;\n package?: string;\n types?: string;\n activate?: boolean;\n keepTmp?: boolean;\n abapLanguageVersion?: string;\n}\n\n/** The ADT client as handed over by the CLI context. */\ntype ContextClient = Awaited<\n ReturnType<NonNullable<CliContext['getAdtClient']>>\n>;\n\ntype LoadedPlugin = Awaited<ReturnType<typeof loadFormatPlugin>>;\n\n/**\n * Resolve the source path: explicit files resolve the abapGit repo root,\n * otherwise the configured `--source` directory is used.\n */\nasync function resolveSourcePath(\n options: RoundtripCliOptions,\n ctx: CliContext,\n): Promise<{ sourcePath: string; specificFiles: string[] | undefined }> {\n const expandedFiles =\n options.files && options.files.length > 0\n ? await expandGlobs(options.files, ctx.cwd)\n : undefined;\n const specificFiles =\n expandedFiles && expandedFiles.length > 0 ? expandedFiles : undefined;\n let sourcePath = options.source;\n\n if (specificFiles) {\n const repoRoot = findAbapGitRoot(ctx.cwd);\n if (!repoRoot) {\n ctx.logger.error('❌ No .abapgit.xml found in any parent directory.');\n process.exit(1);\n }\n sourcePath = repoRoot;\n }\n\n return { sourcePath, specificFiles };\n}\n\n/** Phase 1: deploy the selected objects to SAP. */\nasync function deployPhase(\n fileTree: FileTree,\n client: ContextClient,\n adkContext: AdkContext,\n options: RoundtripCliOptions,\n ctx: CliContext,\n): Promise<{ plugin: LoadedPlugin; deployedObjects: AdkObject[] }> {\n ctx.logger.info('\\n═══ Phase 1: Deploy to SAP ═══');\n\n const plugin = await loadFormatPlugin(options.format);\n if (!plugin.format.export) {\n ctx.logger.error(`❌ Plugin '${plugin.name}' does not support export`);\n process.exit(1);\n }\n\n const exportOptions: ExportOptions = {\n rootPackage: options.package,\n abapLanguageVersion: options.abapLanguageVersion,\n };\n\n // Parse object types filter\n const objectTypes = options.types\n ? options.types.split(',').map((t: string) => t.trim().toUpperCase())\n : undefined;\n\n const deployedObjects: AdkObject[] = [];\n const objectSet = await AdkObjectSet.fromGenerator(\n plugin.format.export(fileTree, client, exportOptions),\n adkContext,\n {\n filter: objectTypes\n ? (obj) => {\n const objType = obj.type.toUpperCase();\n const objPrefix = objType.split('/')[0];\n return (\n objectTypes.includes(objType) || objectTypes.includes(objPrefix)\n );\n }\n : undefined,\n onObject: (obj) => {\n ctx.logger.info(` 📄 ${obj.kind} ${obj.name}`);\n },\n },\n );\n\n const deployResult = await objectSet.deploy({\n transport: options.transport,\n activate: options.activate,\n mode: 'upsert',\n onProgress: (saved, total, obj) => {\n if (obj._unchanged) {\n ctx.logger.info(\n ` ⏭️ [${saved}/${total}] ${obj.kind} ${obj.name} (unchanged)`,\n );\n } else {\n ctx.logger.info(` 💾 [${saved}/${total}] ${obj.kind} ${obj.name}`);\n }\n },\n });\n\n ctx.logger.info(\n ` ✅ Deployed: ${deployResult.save.success} saved, ${deployResult.save.unchanged} unchanged, ${deployResult.save.failed} failed`,\n );\n\n if (deployResult.save.failed > 0) {\n ctx.logger.warn(\n `⚠️ ${deployResult.save.failed} object(s) failed to deploy — continuing roundtrip for ${deployResult.save.success + deployResult.save.unchanged} successful objects`,\n );\n }\n\n if (deployResult.save.success + deployResult.save.unchanged === 0) {\n ctx.logger.error('❌ No objects deployed successfully — aborting.');\n process.exit(1);\n }\n\n // Collect only successfully deployed objects for reimport\n for (const result of deployResult.save.results) {\n if (result.success) {\n deployedObjects.push(result.object);\n }\n }\n\n return { plugin, deployedObjects };\n}\n\n/** Phase 2: load fresh from SAP and re-serialize to `tmpDir`. */\nasync function reimportPhase(\n deployedObjects: AdkObject[],\n plugin: LoadedPlugin,\n tmpDir: string,\n client: ContextClient,\n ctx: CliContext,\n): Promise<void> {\n const adk = createAdk(client as AdtClient);\n let reimported = 0;\n let reimportFailed = 0;\n\n for (const obj of deployedObjects) {\n try {\n // Load fresh from SAP\n const fresh = adk.get(obj.name, obj.type);\n await (fresh as any).load();\n\n // Build import context with package path resolver\n const importContext: ImportContext = {\n resolvePackagePath,\n };\n\n // Serialize back to local files using format plugin\n const result = await plugin.format.import(\n fresh as any,\n tmpDir,\n importContext,\n );\n\n if (result.success) {\n reimported++;\n ctx.logger.info(` ✅ ${obj.kind} ${obj.name}`);\n } else {\n reimportFailed++;\n ctx.logger.error(\n ` ❌ ${obj.kind} ${obj.name}: ${result.errors?.join(', ') || 'unknown'}`,\n );\n }\n } catch (err) {\n reimportFailed++;\n ctx.logger.error(\n ` ❌ ${obj.kind} ${obj.name}: ${err instanceof Error ? err.message : String(err)}`,\n );\n }\n }\n\n // Call afterImport hook (generates .abapgit.xml etc)\n if (plugin.hooks?.afterImport) {\n await plugin.hooks.afterImport(tmpDir);\n }\n\n ctx.logger.info(\n ` 📊 Reimported: ${reimported} success, ${reimportFailed} failed`,\n );\n}\n\n/** Show diff with colors (skip file headers, keep hunk headers). */\nfunction printColoredDiff(patch: string): void {\n const diffLines = patch.split('\\n');\n let lineCount = 0;\n const maxLines = 50;\n\n for (const line of diffLines) {\n // Skip file path headers (--- and +++)\n if (line.startsWith('---') || line.startsWith('+++')) {\n continue;\n }\n\n if (lineCount >= maxLines) {\n console.log(\n chalk.yellow(\n ' ... (truncated, use --keep-tmp to inspect full files)',\n ),\n );\n break;\n }\n\n 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 if (line.trim()) {\n console.log(chalk.gray(` ${line}`));\n }\n\n lineCount++;\n }\n}\n\n/** Phase 3: compare original vs re-imported files. */\nasync function comparePhase(\n fileTree: FileTree,\n tmpDir: string,\n options: RoundtripCliOptions,\n ctx: CliContext,\n): Promise<{\n matches: number;\n mismatches: number;\n onlyOriginal: number;\n onlyReimported: number;\n}> {\n // Collect re-imported files (skip .abapgit.xml — generated metadata)\n const reimportedFiles = collectFiles(tmpDir).filter(\n (f) => !f.endsWith('.abapgit.xml'),\n );\n\n let matches = 0;\n let mismatches = 0;\n let onlyOriginal = 0;\n let onlyReimported = 0;\n\n // Map reimported files by their filename (last segment) for matching\n const reimportedByName = new Map<string, string>();\n for (const f of reimportedFiles) {\n const name = f.split('/').pop()!;\n reimportedByName.set(name, f);\n }\n\n // Get original files from the FileTree\n const originalXml = await fileTree.glob('**/*.xml');\n const originalAbap = await fileTree.glob('**/*.abap');\n const allOriginal = [...originalXml, ...originalAbap].filter(\n (f) => !f.endsWith('.abapgit.xml') && !f.endsWith('package.devc.xml'),\n );\n\n for (const origRelPath of allOriginal) {\n const origName = origRelPath.split('/').pop()!;\n const reimportedRelPath = reimportedByName.get(origName);\n\n if (!reimportedRelPath) {\n onlyOriginal++;\n ctx.logger.warn(` ⚠️ Only in original: ${origName}`);\n continue;\n }\n\n // Remove from map so we can track reimported-only files\n reimportedByName.delete(origName);\n\n // Read original from FileTree, reimported from disk\n let origContent = (await fileTree.read(origRelPath)).trim();\n let reimContent = readFileSync(\n join(tmpDir, reimportedRelPath),\n 'utf-8',\n ).trim();\n\n // Normalize line endings (SAP returns CRLF, git uses LF)\n origContent = origContent.replaceAll('\\r\\n', '\\n');\n reimContent = reimContent.replaceAll('\\r\\n', '\\n');\n\n // Normalize XML files before comparison\n const isXml = origName.endsWith('.xml');\n if (isXml) {\n origContent = await normalizeXml(origContent);\n reimContent = await normalizeXml(reimContent);\n\n // Save normalized files for inspection\n if (options.keepTmp) {\n writeFileSync(\n join(tmpDir, 'normalized-original-' + origName),\n origContent,\n 'utf-8',\n );\n writeFileSync(\n join(tmpDir, 'normalized-reimported-' + origName),\n reimContent,\n 'utf-8',\n );\n }\n }\n\n // Compare content\n if (origContent === reimContent) {\n matches++;\n ctx.logger.info(` ✅ ${origName}`);\n } else {\n mismatches++;\n ctx.logger.error(` ❌ ${origName} — DIFFERS`);\n\n // Generate unified diff\n const patch = createTwoFilesPatch(\n `original/${origName}`,\n `reimported/${origName}`,\n origContent,\n reimContent,\n '',\n '',\n { context: 3 },\n );\n\n printColoredDiff(patch);\n }\n }\n\n // Files only in reimported\n for (const [name] of reimportedByName) {\n onlyReimported++;\n ctx.logger.warn(` ⚠️ Only in reimported: ${name}`);\n }\n\n return { matches, mismatches, onlyOriginal, onlyReimported };\n}\n\nexport const roundtripCommand: CliCommandPlugin = {\n name: 'roundtrip',\n description: 'Deploy files to SAP, import back, and compare (roundtrip test)',\n\n arguments: [\n {\n name: '[files...]',\n description:\n 'Specific files or glob patterns to test (e.g., zage_fixed_values.doma.xml, *.doma.xml). Omit to test all.',\n },\n ],\n\n options: [\n {\n flags: '-s, --source <path>',\n description: 'Source directory containing serialized files',\n default: '.',\n },\n {\n flags: '-f, --format <format>',\n description: 'Format plugin: abapgit | @abapify/adt-plugin-abapgit',\n default: 'abapgit',\n },\n {\n flags: '-p, --package <package>',\n description: 'Target package for new objects',\n },\n {\n flags: '-t, --transport <request>',\n description: 'Transport request for changes',\n },\n {\n flags: '--types <types>',\n description: 'Filter by object types (comma-separated)',\n },\n {\n flags: '--activate',\n description: 'Activate objects after deploy (use --no-activate to skip)',\n default: true,\n },\n {\n flags: '--keep-tmp',\n description: 'Keep temporary reimport directory for inspection',\n default: false,\n },\n {\n flags: '--abap-language-version <version>',\n description: 'ABAP language version for new objects (2=keyUser, 5=cloud)',\n },\n ],\n\n async execute(args: Record<string, unknown>, ctx: CliContext) {\n const options = args as unknown as RoundtripCliOptions;\n\n if (!ctx.getAdtClient) {\n ctx.logger.error('❌ ADT client not available. Run: adt auth login');\n process.exit(1);\n }\n\n // ── Resolve source path ──\n const { sourcePath, specificFiles } = await resolveSourcePath(options, ctx);\n\n ctx.logger.info('🔄 Roundtrip test');\n ctx.logger.info(`📁 Source: ${sourcePath}`);\n if (specificFiles) ctx.logger.info(`📄 Files: ${specificFiles.join(', ')}`);\n if (options.package) ctx.logger.info(`📦 Package: ${options.package}`);\n\n // ── Build FileTree ──\n let fileTree = createFileTree(sourcePath);\n if (specificFiles) {\n const relFiles = resolveFilesRelativeToRoot(\n specificFiles,\n ctx.cwd,\n sourcePath,\n );\n fileTree = new FilteredFileTree(fileTree, relFiles);\n }\n\n const client = await ctx.getAdtClient!();\n const adkContext: AdkContext = { client: client as any };\n\n // ── Phase 1: Deploy ──\n const { plugin, deployedObjects } = await deployPhase(\n fileTree,\n client,\n adkContext,\n options,\n ctx,\n );\n\n // ── Phase 2: Import back from SAP ──\n ctx.logger.info('\\n═══ Phase 2: Import back from SAP ═══');\n\n if (!plugin.format.import) {\n ctx.logger.error(`❌ Plugin '${plugin.name}' does not support import`);\n process.exit(1);\n }\n\n const tmpDir = join(tmpdir(), `adt-roundtrip-${Date.now()}`);\n mkdirSync(tmpDir, { recursive: true });\n ctx.logger.info(` 📂 Temp dir: ${tmpDir}`);\n\n await reimportPhase(deployedObjects, plugin, tmpDir, client, ctx);\n\n // ── Phase 3: Compare ──\n ctx.logger.info('\\n═══ Phase 3: Compare ═══');\n\n const { matches, mismatches, onlyOriginal, onlyReimported } =\n await comparePhase(fileTree, tmpDir, options, ctx);\n\n // ── Summary ──\n ctx.logger.info('\\n═══ Summary ═══');\n ctx.logger.info(` ✅ Matching: ${matches}`);\n if (mismatches > 0) ctx.logger.error(` ❌ Mismatches: ${mismatches}`);\n if (onlyOriginal > 0)\n ctx.logger.warn(` ⚠️ Only in original: ${onlyOriginal}`);\n if (onlyReimported > 0)\n ctx.logger.warn(` ⚠️ Only in reimported: ${onlyReimported}`);\n\n if (options.keepTmp) {\n ctx.logger.info(`\\n📂 Temp dir kept: ${tmpDir}`);\n } else {\n rmSync(tmpDir, { recursive: true, force: true });\n }\n\n if (mismatches > 0) {\n ctx.logger.error('\\n❌ Roundtrip test FAILED');\n process.exit(1);\n }\n\n ctx.logger.info('\\n✅ Roundtrip test PASSED');\n },\n};\n\nexport default roundtripCommand;\n"],"mappings":";;;;;;;;;;;;;;AAqDA,eAAe,mBAAmB,aAAwC;CACxE,MAAM,OAAiB,CAAC;CACxB,IAAI,UAAU;CACd,OAAO,SAAS;EACd,KAAK,QAAQ,OAAO;EACpB,IAAI;GAEF,MAAM,YAAW,MADC,WAAW,IAAI,OAAO,EAAA,CACnB;GACrB,IAAI,UAAU,MACZ,UAAU,SAAS;QAEnB;EAEJ,QAAQ;GACN;EACF;CACF;CACA,OAAO;AACT;;;;;;;AAQA,eAAe,aAAa,KAA8B;CACxD,IAAI;EACF,MAAM,SAAS,IAAI,UAAU;GAC3B,kBAAkB;GAClB,qBAAqB;GACrB,YAAY;GACZ,eAAe;GACf,qBAAqB;GACrB,gBAAgB;EAClB,CAAC;EAED,MAAM,UAAU,IAAI,WAAW;GAC7B,kBAAkB;GAClB,qBAAqB;GACrB,QAAQ;GACR,UAAU;GACV,mBAAmB;EACrB,CAAC;EAGD,MAAM,MAAM,OAAO,MAAM,GAAG;EAC5B,IAAI,aAAa,QAAQ,MAAM,GAAG;EAGlC,MAAM,EAAE,wBAAwB,MAAM,OAAO;EAC7C,aAAa,oBAAoB,UAAU;EAE3C,OAAO;CACT,QAAQ;EAIN,OAAO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