@abapify/adt-export 0.4.15 → 0.4.18

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,6 +1,4 @@
1
1
  import { CliCommandPlugin } from "@abapify/adt-plugin";
2
- //#region src/commands/activate.d.ts
3
2
  declare const activateCommand: CliCommandPlugin;
4
- //#endregion
5
3
  export { activateCommand, activateCommand as default };
6
4
  //# sourceMappingURL=activate.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"activate.d.mts","names":[],"sources":["../../src/commands/activate.ts"],"mappings":";;cAsDa,iBAAiB"}
1
+ {"version":3,"file":"activate.d.mts","names":[],"sources":["../../src/commands/activate.ts"],"mappings":";cAsDa,iBAAiB"}
@@ -1,7 +1,7 @@
1
- import { a as createFileTree, n as FilteredFileTree, o as findAbapGitRoot, s as resolveFilesRelativeToRoot, t as loadFormatPlugin } from "../format-plugin-BdhDTNMZ.mjs";
1
+ import { a as createFileTree, n as FilteredFileTree, o as findAbapGitRoot, s as resolveFilesRelativeToRoot, t as loadFormatPlugin } from "../format-plugin-BcmBEYgt.mjs";
2
2
  import { AdkObjectSet, AdkPackage, AdkTransport, createAdk } from "@abapify/adk";
3
3
  import { glob } from "node:fs/promises";
4
- //#region src/commands/activate.ts
4
+ // src/commands/activate.ts
5
5
  /**
6
6
  * Expand glob patterns in a list of file arguments.
7
7
  * Literal filenames (no glob characters) pass through unchanged.
@@ -136,7 +136,6 @@ const activateCommand = {
136
136
  }
137
137
  }
138
138
  };
139
- //#endregion
140
139
  export { activateCommand, activateCommand as default };
141
140
 
142
141
  //# sourceMappingURL=activate.mjs.map
@@ -1,5 +1,4 @@
1
1
  import { CliCommandPlugin } from "@abapify/adt-plugin";
2
- //#region src/commands/export.d.ts
3
2
  /**
4
3
  * Export Command Plugin
5
4
  *
@@ -15,6 +14,5 @@ import { CliCommandPlugin } from "@abapify/adt-plugin";
15
14
  * ```
16
15
  */
17
16
  declare const exportCommand: CliCommandPlugin;
18
- //#endregion
19
17
  export { exportCommand as default, exportCommand };
20
18
  //# sourceMappingURL=export.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"export.d.mts","names":[],"sources":["../../src/commands/export.ts"],"mappings":";;;;;;;;;;;;;;;;cA4Ka,eAAe"}
1
+ {"version":3,"file":"export.d.mts","names":[],"sources":["../../src/commands/export.ts"],"mappings":";;;;;;;;;;;;;;;cA4Ka,eAAe"}
@@ -1,7 +1,7 @@
1
- import { a as createFileTree, n as FilteredFileTree, o as findAbapGitRoot, s as resolveFilesRelativeToRoot, t as loadFormatPlugin } from "../format-plugin-BdhDTNMZ.mjs";
1
+ import { a as createFileTree, n as FilteredFileTree, o as findAbapGitRoot, s as resolveFilesRelativeToRoot, t as loadFormatPlugin } from "../format-plugin-BcmBEYgt.mjs";
2
2
  import { AdkObjectSet, AdkPackage, tryGetGlobalContext } from "@abapify/adk";
3
3
  import { FileLockStore, createLockService } from "@abapify/adt-locks";
4
- //#region src/commands/export.ts
4
+ // src/commands/export.ts
5
5
  /**
6
6
  * Display export results in console
7
7
  */
@@ -570,7 +570,6 @@ const exportCommand = {
570
570
  if (result.failed > 0 || (result.verification?.mismatched ?? 0) > 0) process.exit(1);
571
571
  }
572
572
  };
573
- //#endregion
574
573
  export { exportCommand as default, exportCommand };
575
574
 
576
575
  //# sourceMappingURL=export.mjs.map
@@ -1,6 +1,4 @@
1
1
  import { CliCommandPlugin } from "@abapify/adt-plugin";
2
- //#region src/commands/roundtrip.d.ts
3
2
  declare const roundtripCommand: CliCommandPlugin;
4
- //#endregion
5
3
  export { roundtripCommand as default, roundtripCommand };
6
4
  //# sourceMappingURL=roundtrip.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"roundtrip.d.mts","names":[],"sources":["../../src/commands/roundtrip.ts"],"mappings":";;cAoJa,kBAAkB"}
1
+ {"version":3,"file":"roundtrip.d.mts","names":[],"sources":["../../src/commands/roundtrip.ts"],"mappings":";cAoJa,kBAAkB"}
@@ -1,4 +1,4 @@
1
- import { a as createFileTree, n as FilteredFileTree, o as findAbapGitRoot, s as resolveFilesRelativeToRoot, t as loadFormatPlugin } from "../format-plugin-BdhDTNMZ.mjs";
1
+ import { a as createFileTree, n as FilteredFileTree, o as findAbapGitRoot, s as resolveFilesRelativeToRoot, t as loadFormatPlugin } from "../format-plugin-BcmBEYgt.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";
@@ -7,7 +7,7 @@ import { tmpdir } from "node:os";
7
7
  import { createTwoFilesPatch } from "diff";
8
8
  import chalk from "chalk";
9
9
  import { XMLBuilder, XMLParser } from "fast-xml-parser";
10
- //#region src/commands/roundtrip.ts
10
+ // src/commands/roundtrip.ts
11
11
  /**
12
12
  * Resolve full package path from SAP (walks super packages upward)
13
13
  * Uses global ADK context (set when client is initialized)
@@ -301,7 +301,6 @@ const roundtripCommand = {
301
301
  ctx.logger.info("\n✅ Roundtrip test PASSED");
302
302
  }
303
303
  };
304
- //#endregion
305
304
  export { roundtripCommand as default, roundtripCommand };
306
305
 
307
306
  //# sourceMappingURL=roundtrip.mjs.map
@@ -1,7 +1,7 @@
1
1
  import { access, glob, readFile, readdir } from "node:fs/promises";
2
2
  import { dirname, join, relative, resolve } from "node:path";
3
3
  import { existsSync } from "node:fs";
4
- //#region src/utils/filetree.ts
4
+ // src/utils/filetree.ts
5
5
  /**
6
6
  * FileTree implementations
7
7
  */
@@ -149,8 +149,7 @@ function resolveFilesRelativeToRoot(files, cwd, repoRoot) {
149
149
  return relative(repoRoot, abs);
150
150
  });
151
151
  }
152
- //#endregion
153
- //#region src/utils/format-plugin.ts
152
+ // src/utils/format-plugin.ts
154
153
  /** Map short names to actual package names */
155
154
  const FORMAT_SHORTCUTS = {
156
155
  abapgit: "@abapify/adt-plugin-abapgit",
@@ -174,7 +173,6 @@ async function loadFormatPlugin(formatSpec) {
174
173
  throw error;
175
174
  }
176
175
  }
177
- //#endregion
178
176
  export { createFileTree as a, MemoryFileTree as i, FilteredFileTree as n, findAbapGitRoot as o, FsFileTree as r, resolveFilesRelativeToRoot as s, loadFormatPlugin as t };
179
177
 
180
- //# sourceMappingURL=format-plugin-BdhDTNMZ.mjs.map
178
+ //# sourceMappingURL=format-plugin-BcmBEYgt.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"format-plugin-BdhDTNMZ.mjs","names":["nativeGlob"],"sources":["../src/utils/filetree.ts","../src/utils/format-plugin.ts"],"sourcesContent":["/**\n * FileTree implementations\n */\n\nimport {\n readFile,\n readdir,\n access,\n glob as nativeGlob,\n} from 'node:fs/promises';\nimport { join, relative, resolve, dirname } from 'node:path';\nimport { existsSync } from 'node:fs';\nimport type { FileTree } from '@abapify/adt-plugin';\n\n/**\n * File system backed FileTree\n */\nexport class FsFileTree implements FileTree {\n constructor(public readonly root: string) {}\n\n async glob(pattern: string): Promise<string[]> {\n const results: string[] = [];\n // Node.js native glob returns AsyncIterator of strings\n for await (const path of nativeGlob(pattern, { cwd: this.root })) {\n results.push(path);\n }\n return results;\n }\n\n async read(path: string): Promise<string> {\n const fullPath = join(this.root, path);\n const content = await readFile(fullPath, 'utf-8');\n // Strip UTF-8 BOM if present\n return content.charCodeAt(0) === 0xfeff ? content.slice(1) : content;\n }\n\n async readBuffer(path: string): Promise<Buffer> {\n const fullPath = join(this.root, path);\n return readFile(fullPath);\n }\n\n async exists(path: string): Promise<boolean> {\n const fullPath = join(this.root, path);\n try {\n await access(fullPath);\n return true;\n } catch {\n return false;\n }\n }\n\n async readdir(path: string): Promise<string[]> {\n const fullPath = path ? join(this.root, path) : this.root;\n return readdir(fullPath);\n }\n}\n\n/**\n * In-memory FileTree for testing\n */\nexport class MemoryFileTree implements FileTree {\n constructor(\n public readonly root: string,\n private readonly files: Map<string, string | Buffer>,\n ) {}\n\n async glob(pattern: string): Promise<string[]> {\n // Simple glob matching for testing.\n // Step 1: escape ALL regex metacharacters except '*' (our glob syntax).\n // This prevents metachars like '+', '(' in the pattern from\n // being interpreted as regex. Also avoids the\n // incomplete-sanitization pitfall where a later unconditional\n // escape of '.' re-mangled characters produced by earlier\n // wildcard expansions (e.g. '**' -> '.*' -> '\\\\.\\\\*').\n // Step 2: expand '**' then '*' using a placeholder that contains no\n // regex metacharacters, so later passes leave it alone.\n const escaped = pattern.replaceAll(/[.+?^${}()|[\\]\\\\/]/g, '\\\\$&');\n const body = escaped\n .replaceAll(/\\*\\*/g, '\\x00DOUBLESTAR\\x00')\n .replaceAll(/\\*/g, '[^/]*')\n .split('\\x00DOUBLESTAR\\x00')\n .join('.*');\n const regex = new RegExp('^' + body + '$');\n return Array.from(this.files.keys()).filter((p) => regex.test(p));\n }\n\n async read(path: string): Promise<string> {\n const content = this.files.get(path);\n if (content === undefined) {\n throw new Error(`File not found: ${path}`);\n }\n return typeof content === 'string' ? content : content.toString('utf-8');\n }\n\n async readBuffer(path: string): Promise<Buffer> {\n const content = this.files.get(path);\n if (content === undefined) {\n throw new Error(`File not found: ${path}`);\n }\n return typeof content === 'string' ? Buffer.from(content) : content;\n }\n\n async exists(path: string): Promise<boolean> {\n return this.files.has(path);\n }\n\n async readdir(path: string): Promise<string[]> {\n const prefix = path ? path + '/' : '';\n const entries = new Set<string>();\n\n for (const filePath of this.files.keys()) {\n if (filePath.startsWith(prefix)) {\n const rest = filePath.slice(prefix.length);\n const firstPart = rest.split('/')[0];\n entries.add(firstPart);\n }\n }\n\n return Array.from(entries);\n }\n}\n\n/**\n * Create FileTree from path\n */\nexport function createFileTree(sourcePath: string): FileTree {\n return new FsFileTree(sourcePath);\n}\n\n/**\n * FileTree wrapper that filters glob results to only include specified files.\n * Metadata files (.abapgit.xml) always pass through.\n */\nexport class FilteredFileTree implements FileTree {\n private readonly allowedFiles: Set<string>;\n\n constructor(\n private readonly inner: FileTree,\n files: string[],\n ) {\n this.allowedFiles = new Set(files);\n }\n\n get root(): string {\n return this.inner.root;\n }\n\n async glob(pattern: string): Promise<string[]> {\n const all = await this.inner.glob(pattern);\n return all.filter((f) => this.isAllowed(f));\n }\n\n read(path: string): Promise<string> {\n return this.inner.read(path);\n }\n\n readBuffer(path: string): Promise<Buffer> {\n return this.inner.readBuffer(path);\n }\n\n exists(path: string): Promise<boolean> {\n return this.inner.exists(path);\n }\n\n readdir(path: string): Promise<string[]> {\n return this.inner.readdir(path);\n }\n\n private isAllowed(filePath: string): boolean {\n // Always allow metadata files\n if (filePath.endsWith('.abapgit.xml')) return true;\n\n // Check if any allowed file pattern matches\n const filename = filePath.split('/').pop()!;\n for (const allowed of this.allowedFiles) {\n // Exact path or filename match\n if (filePath === allowed || filename === allowed) return true;\n\n // Match companion files by {name}.{type} prefix\n // e.g., myobj.clas.xml → base \"myobj.clas\"\n // matches myobj.clas.abap, myobj.clas.testclasses.abap,\n // myobj.clas.locals_def.abap, etc.\n const allowedName = allowed.split('/').pop()!;\n const allowedBase = allowedName.replace(/\\.\\w+$/, ''); // strip last extension\n // startsWith covers both simple companions (myobj.clas.abap)\n // and multi-extension companions (myobj.clas.testclasses.abap)\n if (filename !== allowedName && filename.startsWith(allowedBase + '.')) {\n return true;\n }\n }\n return false;\n }\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 */\nexport function 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 * Convert absolute file paths to paths relative to the repo root.\n */\nexport function resolveFilesRelativeToRoot(\n files: string[],\n cwd: string,\n repoRoot: string,\n): string[] {\n return files.map((f) => {\n const abs = resolve(cwd, f);\n return relative(repoRoot, abs);\n });\n}\n","/**\n * Shared format plugin loader for export commands.\n *\n * Extracted from export.ts / activate.ts / roundtrip.ts to avoid\n * cross-file duplication (SonarQube CPD).\n */\n\nimport type { AdtPlugin } from '@abapify/adt-plugin';\n\n/** Map short names to actual package names */\nconst FORMAT_SHORTCUTS: Record<string, string> = {\n abapgit: '@abapify/adt-plugin-abapgit',\n ag: '@abapify/adt-plugin-abapgit', // alias\n // gCTS / AFF format plugin. `aff` is the primary id; `gcts` is an alias —\n // both share the same on-disk layout (SAP/abap-file-formats).\n aff: '@abapify/adt-plugin-gcts',\n gcts: '@abapify/adt-plugin-gcts',\n};\n\n/**\n * Load format plugin dynamically by short name or package name.\n */\nexport async function loadFormatPlugin(formatSpec: string): Promise<AdtPlugin> {\n const packageName = FORMAT_SHORTCUTS[formatSpec] ?? formatSpec;\n\n try {\n const pluginModule = await import(packageName);\n const PluginClass =\n pluginModule.default || pluginModule[Object.keys(pluginModule)[0]];\n\n if (!PluginClass) {\n throw new Error(`No plugin class found in ${packageName}`);\n }\n\n // Check if it's already an instance or needs instantiation\n return typeof PluginClass === 'function' && PluginClass.prototype\n ? new PluginClass()\n : PluginClass;\n } catch (error: unknown) {\n const err = error as Error;\n if (\n (err as any).code === 'MODULE_NOT_FOUND' ||\n err.message?.includes(`Cannot find module '${packageName}'`) ||\n err.message?.includes(`Cannot find package '${packageName}'`)\n ) {\n throw new Error(\n `Plugin package '${packageName}' not found. Install it with: bun add ${packageName}`,\n { cause: error },\n );\n }\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;AAiBA,IAAa,aAAb,MAA4C;CACd;CAA5B,YAAY,MAA8B;EAAd,KAAA,OAAA;CAAe;CAE3C,MAAM,KAAK,SAAoC;EAC7C,MAAM,UAAoB,CAAC;EAE3B,WAAW,MAAM,QAAQA,KAAW,SAAS,EAAE,KAAK,KAAK,KAAK,CAAC,GAC7D,QAAQ,KAAK,IAAI;EAEnB,OAAO;CACT;CAEA,MAAM,KAAK,MAA+B;EACxC,MAAM,WAAW,KAAK,KAAK,MAAM,IAAI;EACrC,MAAM,UAAU,MAAM,SAAS,UAAU,OAAO;EAEhD,OAAO,QAAQ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
1
+ {"version":3,"file":"format-plugin-BcmBEYgt.mjs","names":["nativeGlob"],"sources":["../src/utils/filetree.ts","../src/utils/format-plugin.ts"],"sourcesContent":["/**\n * FileTree implementations\n */\n\nimport {\n readFile,\n readdir,\n access,\n glob as nativeGlob,\n} from 'node:fs/promises';\nimport { join, relative, resolve, dirname } from 'node:path';\nimport { existsSync } from 'node:fs';\nimport type { FileTree } from '@abapify/adt-plugin';\n\n/**\n * File system backed FileTree\n */\nexport class FsFileTree implements FileTree {\n constructor(public readonly root: string) {}\n\n async glob(pattern: string): Promise<string[]> {\n const results: string[] = [];\n // Node.js native glob returns AsyncIterator of strings\n for await (const path of nativeGlob(pattern, { cwd: this.root })) {\n results.push(path);\n }\n return results;\n }\n\n async read(path: string): Promise<string> {\n const fullPath = join(this.root, path);\n const content = await readFile(fullPath, 'utf-8');\n // Strip UTF-8 BOM if present\n return content.charCodeAt(0) === 0xfeff ? content.slice(1) : content;\n }\n\n async readBuffer(path: string): Promise<Buffer> {\n const fullPath = join(this.root, path);\n return readFile(fullPath);\n }\n\n async exists(path: string): Promise<boolean> {\n const fullPath = join(this.root, path);\n try {\n await access(fullPath);\n return true;\n } catch {\n return false;\n }\n }\n\n async readdir(path: string): Promise<string[]> {\n const fullPath = path ? join(this.root, path) : this.root;\n return readdir(fullPath);\n }\n}\n\n/**\n * In-memory FileTree for testing\n */\nexport class MemoryFileTree implements FileTree {\n constructor(\n public readonly root: string,\n private readonly files: Map<string, string | Buffer>,\n ) {}\n\n async glob(pattern: string): Promise<string[]> {\n // Simple glob matching for testing.\n // Step 1: escape ALL regex metacharacters except '*' (our glob syntax).\n // This prevents metachars like '+', '(' in the pattern from\n // being interpreted as regex. Also avoids the\n // incomplete-sanitization pitfall where a later unconditional\n // escape of '.' re-mangled characters produced by earlier\n // wildcard expansions (e.g. '**' -> '.*' -> '\\\\.\\\\*').\n // Step 2: expand '**' then '*' using a placeholder that contains no\n // regex metacharacters, so later passes leave it alone.\n const escaped = pattern.replaceAll(/[.+?^${}()|[\\]\\\\/]/g, '\\\\$&');\n const body = escaped\n .replaceAll(/\\*\\*/g, '\\x00DOUBLESTAR\\x00')\n .replaceAll(/\\*/g, '[^/]*')\n .split('\\x00DOUBLESTAR\\x00')\n .join('.*');\n const regex = new RegExp('^' + body + '$');\n return Array.from(this.files.keys()).filter((p) => regex.test(p));\n }\n\n async read(path: string): Promise<string> {\n const content = this.files.get(path);\n if (content === undefined) {\n throw new Error(`File not found: ${path}`);\n }\n return typeof content === 'string' ? content : content.toString('utf-8');\n }\n\n async readBuffer(path: string): Promise<Buffer> {\n const content = this.files.get(path);\n if (content === undefined) {\n throw new Error(`File not found: ${path}`);\n }\n return typeof content === 'string' ? Buffer.from(content) : content;\n }\n\n async exists(path: string): Promise<boolean> {\n return this.files.has(path);\n }\n\n async readdir(path: string): Promise<string[]> {\n const prefix = path ? path + '/' : '';\n const entries = new Set<string>();\n\n for (const filePath of this.files.keys()) {\n if (filePath.startsWith(prefix)) {\n const rest = filePath.slice(prefix.length);\n const firstPart = rest.split('/')[0];\n entries.add(firstPart);\n }\n }\n\n return Array.from(entries);\n }\n}\n\n/**\n * Create FileTree from path\n */\nexport function createFileTree(sourcePath: string): FileTree {\n return new FsFileTree(sourcePath);\n}\n\n/**\n * FileTree wrapper that filters glob results to only include specified files.\n * Metadata files (.abapgit.xml) always pass through.\n */\nexport class FilteredFileTree implements FileTree {\n private readonly allowedFiles: Set<string>;\n\n constructor(\n private readonly inner: FileTree,\n files: string[],\n ) {\n this.allowedFiles = new Set(files);\n }\n\n get root(): string {\n return this.inner.root;\n }\n\n async glob(pattern: string): Promise<string[]> {\n const all = await this.inner.glob(pattern);\n return all.filter((f) => this.isAllowed(f));\n }\n\n read(path: string): Promise<string> {\n return this.inner.read(path);\n }\n\n readBuffer(path: string): Promise<Buffer> {\n return this.inner.readBuffer(path);\n }\n\n exists(path: string): Promise<boolean> {\n return this.inner.exists(path);\n }\n\n readdir(path: string): Promise<string[]> {\n return this.inner.readdir(path);\n }\n\n private isAllowed(filePath: string): boolean {\n // Always allow metadata files\n if (filePath.endsWith('.abapgit.xml')) return true;\n\n // Check if any allowed file pattern matches\n const filename = filePath.split('/').pop()!;\n for (const allowed of this.allowedFiles) {\n // Exact path or filename match\n if (filePath === allowed || filename === allowed) return true;\n\n // Match companion files by {name}.{type} prefix\n // e.g., myobj.clas.xml → base \"myobj.clas\"\n // matches myobj.clas.abap, myobj.clas.testclasses.abap,\n // myobj.clas.locals_def.abap, etc.\n const allowedName = allowed.split('/').pop()!;\n const allowedBase = allowedName.replace(/\\.\\w+$/, ''); // strip last extension\n // startsWith covers both simple companions (myobj.clas.abap)\n // and multi-extension companions (myobj.clas.testclasses.abap)\n if (filename !== allowedName && filename.startsWith(allowedBase + '.')) {\n return true;\n }\n }\n return false;\n }\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 */\nexport function 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 * Convert absolute file paths to paths relative to the repo root.\n */\nexport function resolveFilesRelativeToRoot(\n files: string[],\n cwd: string,\n repoRoot: string,\n): string[] {\n return files.map((f) => {\n const abs = resolve(cwd, f);\n return relative(repoRoot, abs);\n });\n}\n","/**\n * Shared format plugin loader for export commands.\n *\n * Extracted from export.ts / activate.ts / roundtrip.ts to avoid\n * cross-file duplication (SonarQube CPD).\n */\n\nimport type { AdtPlugin } from '@abapify/adt-plugin';\n\n/** Map short names to actual package names */\nconst FORMAT_SHORTCUTS: Record<string, string> = {\n abapgit: '@abapify/adt-plugin-abapgit',\n ag: '@abapify/adt-plugin-abapgit', // alias\n // gCTS / AFF format plugin. `aff` is the primary id; `gcts` is an alias —\n // both share the same on-disk layout (SAP/abap-file-formats).\n aff: '@abapify/adt-plugin-gcts',\n gcts: '@abapify/adt-plugin-gcts',\n};\n\n/**\n * Load format plugin dynamically by short name or package name.\n */\nexport async function loadFormatPlugin(formatSpec: string): Promise<AdtPlugin> {\n const packageName = FORMAT_SHORTCUTS[formatSpec] ?? formatSpec;\n\n try {\n const pluginModule = await import(packageName);\n const PluginClass =\n pluginModule.default || pluginModule[Object.keys(pluginModule)[0]];\n\n if (!PluginClass) {\n throw new Error(`No plugin class found in ${packageName}`);\n }\n\n // Check if it's already an instance or needs instantiation\n return typeof PluginClass === 'function' && PluginClass.prototype\n ? new PluginClass()\n : PluginClass;\n } catch (error: unknown) {\n const err = error as Error;\n if (\n (err as any).code === 'MODULE_NOT_FOUND' ||\n err.message?.includes(`Cannot find module '${packageName}'`) ||\n err.message?.includes(`Cannot find package '${packageName}'`)\n ) {\n throw new Error(\n `Plugin package '${packageName}' not found. Install it with: bun add ${packageName}`,\n { cause: error },\n );\n }\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;AAiBA,IAAa,aAAb,MAA4C;CACd;CAA5B,YAAY,MAA8B;EAAd,KAAA,OAAA;CAAe;CAE3C,MAAM,KAAK,SAAoC;EAC7C,MAAM,UAAoB,CAAC;EAE3B,WAAW,MAAM,QAAQA,KAAW,SAAS,EAAE,KAAK,KAAK,KAAK,CAAC,GAC7D,QAAQ,KAAK,IAAI;EAEnB,OAAO;CACT;CAEA,MAAM,KAAK,MAA+B;EACxC,MAAM,WAAW,KAAK,KAAK,MAAM,IAAI;EACrC,MAAM,UAAU,MAAM,SAAS,UAAU,OAAO;EAEhD,OAAO,QAAQ,WAAW,CAAC,MAAM,QAAS,QAAQ,MAAM,CAAC,IAAI;CAC/D;CAEA,MAAM,WAAW,MAA+B;EAC9C,MAAM,WAAW,KAAK,KAAK,MAAM,IAAI;EACrC,OAAO,SAAS,QAAQ;CAC1B;CAEA,MAAM,OAAO,MAAgC;EAC3C,MAAM,WAAW,KAAK,KAAK,MAAM,IAAI;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AAsC;CACpE,IAAI,MAAM,QAAQ,QAAQ;CAC1B,MAAM,OAAO,QAAQ,GAAG;CAExB,OAAO,QAAQ,MAAM;EACnB,IAAI,WAAW,KAAK,KAAK,cAAc,CAAC,GACtC,OAAO;EAET,MAAM,SAAS,QAAQ,GAAG;EAC1B,IAAI,WAAW,KAAK;EACpB,MAAM;CACR;AAEF;;;;AAKA,SAAgB,2BACd,OACA,KACA,UACU;CACV,OAAO,MAAM,KAAK,MAAM;EACtB,MAAM,MAAM,QAAQ,KAAK,CAAC;EAC1B,OAAO,SAAS,UAAU,GAAG;CAC/B,CAAC;AACH;;;ACvNA,MAAM,mBAA2C;CAC/C,SAAS;CACT,IAAI;CAGJ,KAAK;CACL,MAAM;AACR;;;;AAKA,eAAsB,iBAAiB,YAAwC;CAC7E,MAAM,cAAc,iBAAiB,eAAe;CAEpD,IAAI;EACF,MAAM,eAAe,MAAM,OAAO;EAClC,MAAM,cACJ,aAAa,WAAW,aAAa,OAAO,KAAK,YAAY,CAAC,CAAC;EAEjE,IAAI,CAAC,aACH,MAAM,IAAI,MAAM,4BAA4B,aAAa;EAI3D,OAAO,OAAO,gBAAgB,cAAc,YAAY,YACpD,IAAI,YAAY,IAChB;CACN,SAAS,OAAgB;EACvB,MAAM,MAAM;EACZ,IACG,IAAY,SAAS,sBACtB,IAAI,SAAS,SAAS,uBAAuB,YAAY,EAAE,KAC3D,IAAI,SAAS,SAAS,wBAAwB,YAAY,EAAE,GAE5D,MAAM,IAAI,MACR,mBAAmB,YAAY,wCAAwC,eACvE,EAAE,OAAO,MAAM,CACjB;EAEF,MAAM;CACR;AACF"}
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import exportCommand from "./commands/export.mjs";
2
2
  import { FileTree, FileTree as FileTree$1 } from "@abapify/adt-plugin";
3
- //#region src/utils/filetree.d.ts
4
3
  /**
5
4
  * File system backed FileTree
6
5
  */
@@ -55,8 +54,6 @@ declare function findAbapGitRoot(startDir: string): string | undefined;
55
54
  * Convert absolute file paths to paths relative to the repo root.
56
55
  */
57
56
  declare function resolveFilesRelativeToRoot(files: string[], cwd: string, repoRoot: string): string[];
58
- //#endregion
59
- //#region src/types.d.ts
60
57
  /**
61
58
  * Export result statistics
62
59
  */
@@ -130,6 +127,5 @@ interface ExportOptions {
130
127
  /** Enable debug output */
131
128
  debug?: boolean;
132
129
  }
133
- //#endregion
134
130
  export { type ExportObjectResult, type ExportOptions, type ExportResult, type FileTree, FilteredFileTree, FsFileTree, MemoryFileTree, createFileTree, exportCommand, findAbapGitRoot, resolveFilesRelativeToRoot };
135
131
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/utils/filetree.ts","../src/types.ts"],"mappings":";;;;;;cAiBa,sBAAsB;WACL;EAAA,YAAA;EAEtB,KAAK,kBAAkB;EASvB,KAAK,eAAe;EAOpB,WAAW,eAAe,QAAQ;EAKlC,OAAO,eAAe;EAUtB,QAAQ,eAAe;;;;;cASlB,0BAA0B;WAEnB;mBACC;EADD,YAAA,cACC,OAAO,qBAAqB;EAGzC,KAAK,kBAAkB;EAoBvB,KAAK,eAAe;EAQpB,WAAW,eAAe,QAAQ;EAQlC,OAAO,eAAe;EAItB,QAAQ,eAAe;;;;;iBAmBf,eAAe,qBAAqB;;;;;cAQvC,4BAA4B;mBAIpB;mBAHF;EAGE,YAAA,OAAO,YACxB;MAKE;EAIE,KAAK,kBAAkB;EAK7B,KAAK,eAAe;EAIpB,WAAW,eAAe,QAAQ;EAIlC,OAAO,eAAe;EAItB,QAAQ,eAAe;UAIf;;;;;;iBA8BM,gBAAgB;;;;iBAkBhB,2BACd,iBACA,aACA;;;;;;UCjNe;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,SAAS;;EAET,eAAe;;;;;UAMA;EACf;EACA;EACA;EACA;;;;;UAMe;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA,SAAS;;;;;UAMM;EACf;EACA;EACA;EACA;EACA;EACA;;;;;UAMe;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA"}
1
+ {"version":3,"file":"index.d.mts","names":["FileTree"],"sources":["../src/utils/filetree.ts","../src/types.ts"],"mappings":";;;;;cAiBa,sBAAsBA;WACL;EAAA,YAAA;EAEtB,KAAK,kBAAkB;EASvB,KAAK,eAAe;EAOpB,WAAW,eAAe,QAAQ;EAKlC,OAAO,eAAe;EAUtB,QAAQ,eAAe;;;;;cASlB,0BAA0BA;WAEnB;mBACC;EADD,YAAA,cACC,OAAO,qBAAqB;EAGzC,KAAK,kBAAkB;EAoBvB,KAAK,eAAe;EAQpB,WAAW,eAAe,QAAQ;EAQlC,OAAO,eAAe;EAItB,QAAQ,eAAe;;;;;iBAmBf,eAAe,qBAAqBA;;;;;cAQvC,4BAA4BA;mBAIpB;mBAHF;EAGE,YAAA,OAAOA,YACxB;MAKE;EAIE,KAAK,kBAAkB;EAK7B,KAAK,eAAe;EAIpB,WAAW,eAAe,QAAQ;EAIlC,OAAO,eAAe;EAItB,QAAQ,eAAe;UAIf;;;;;;iBA8BM,gBAAgB;;;;iBAkBhB,2BACd,iBACA,aACA;;;;UCjNe;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,SAAS;;EAET,eAAe;;;;;UAMA;EACf;EACA;EACA;EACA;;;;;UAMe;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA,SAAS;;;;;UAMM;EACf;EACA;EACA;EACA;EACA;EACA;;;;;UAMe;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA"}
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { a as createFileTree, i as MemoryFileTree, n as FilteredFileTree, o as findAbapGitRoot, r as FsFileTree, s as resolveFilesRelativeToRoot } from "./format-plugin-BdhDTNMZ.mjs";
1
+ import { a as createFileTree, i as MemoryFileTree, n as FilteredFileTree, o as findAbapGitRoot, r as FsFileTree, s as resolveFilesRelativeToRoot } from "./format-plugin-BcmBEYgt.mjs";
2
2
  import exportCommand from "./commands/export.mjs";
3
3
  export { FilteredFileTree, FsFileTree, MemoryFileTree, createFileTree, exportCommand, findAbapGitRoot, resolveFilesRelativeToRoot };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abapify/adt-export",
3
- "version": "0.4.15",
3
+ "version": "0.4.18",
4
4
  "description": "Export CLI plugin for adt-cli - deploy local files to SAP",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -29,10 +29,10 @@
29
29
  "abapgit"
30
30
  ],
31
31
  "dependencies": {
32
- "@abapify/adk": "0.4.15",
33
- "@abapify/adt-locks": "0.4.15",
34
- "@abapify/adt-plugin": "0.4.15",
35
- "@abapify/adt-plugin-abapgit": "0.4.15",
32
+ "@abapify/adk": "0.4.18",
33
+ "@abapify/adt-locks": "0.4.18",
34
+ "@abapify/adt-plugin": "0.4.18",
35
+ "@abapify/adt-plugin-abapgit": "0.4.18",
36
36
  "chalk": "^5.6.2",
37
37
  "diff": "^8.0.3",
38
38
  "fast-xml-parser": "^5.5.5"