@abapify/adt-export 0.4.5 → 0.4.6

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-PsRJZmpM.mjs";
1
+ import { a as createFileTree, n as FilteredFileTree, o as findAbapGitRoot, s as resolveFilesRelativeToRoot, t as loadFormatPlugin } from "../format-plugin-BdhDTNMZ.mjs";
2
2
  import { AdkObjectSet, AdkPackage, AdkTransport, createAdk } from "@abapify/adk";
3
3
  import { glob } from "node:fs/promises";
4
4
  //#region src/commands/activate.ts
@@ -1,4 +1,4 @@
1
- import { a as createFileTree, n as FilteredFileTree, o as findAbapGitRoot, s as resolveFilesRelativeToRoot, t as loadFormatPlugin } from "../format-plugin-PsRJZmpM.mjs";
1
+ import { a as createFileTree, n as FilteredFileTree, o as findAbapGitRoot, s as resolveFilesRelativeToRoot, t as loadFormatPlugin } from "../format-plugin-BdhDTNMZ.mjs";
2
2
  import { AdkObjectSet, AdkPackage, tryGetGlobalContext } from "@abapify/adk";
3
3
  import { FileLockStore, createLockService } from "@abapify/adt-locks";
4
4
  //#region src/commands/export.ts
@@ -1,4 +1,4 @@
1
- import { a as createFileTree, n as FilteredFileTree, o as findAbapGitRoot, s as resolveFilesRelativeToRoot, t as loadFormatPlugin } from "../format-plugin-PsRJZmpM.mjs";
1
+ import { a as createFileTree, n as FilteredFileTree, o as findAbapGitRoot, s as resolveFilesRelativeToRoot, t as loadFormatPlugin } from "../format-plugin-BdhDTNMZ.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";
@@ -170,11 +170,11 @@ async function loadFormatPlugin(formatSpec) {
170
170
  return typeof PluginClass === "function" && PluginClass.prototype ? new PluginClass() : PluginClass;
171
171
  } catch (error) {
172
172
  const err = error;
173
- if (err.code === "MODULE_NOT_FOUND" || err.message?.includes(`Cannot find module '${packageName}'`)) throw new Error(`Plugin package '${packageName}' not found. Install it with: bun add ${packageName}`, { cause: error });
173
+ if (err.code === "MODULE_NOT_FOUND" || err.message?.includes(`Cannot find module '${packageName}'`) || err.message?.includes(`Cannot find package '${packageName}'`)) throw new Error(`Plugin package '${packageName}' not found. Install it with: bun add ${packageName}`, { cause: error });
174
174
  throw error;
175
175
  }
176
176
  }
177
177
  //#endregion
178
178
  export { createFileTree as a, MemoryFileTree as i, FilteredFileTree as n, findAbapGitRoot as o, FsFileTree as r, resolveFilesRelativeToRoot as s, loadFormatPlugin as t };
179
179
 
180
- //# sourceMappingURL=format-plugin-PsRJZmpM.mjs.map
180
+ //# sourceMappingURL=format-plugin-BdhDTNMZ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"format-plugin-PsRJZmpM.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 ) {\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,SA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ACpD,IAAI,YAAY,IAChB;CACN,SAAS,OAAgB;EACvB,MAAM,MAAM;EACZ,IACG,IAAY,SAAS,sBACtB,IAAI,SAAS,SAAS,uBAAuB,YAAY,EAAE,GAE3D,MAAM,IAAI,MACR,mBAAmB,YAAY,wCAAwC,eACvE,EAAE,OAAO,MAAM,CACjB;EAEF,MAAM;CACR;AACF"}
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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}
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-PsRJZmpM.mjs";
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";
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.5",
3
+ "version": "0.4.6",
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.5",
33
- "@abapify/adt-locks": "0.4.5",
34
- "@abapify/adt-plugin": "0.4.5",
35
- "@abapify/adt-plugin-abapgit": "0.4.5",
32
+ "@abapify/adk": "0.4.6",
33
+ "@abapify/adt-locks": "0.4.6",
34
+ "@abapify/adt-plugin": "0.4.6",
35
+ "@abapify/adt-plugin-abapgit": "0.4.6",
36
36
  "chalk": "^5.6.2",
37
37
  "diff": "^8.0.3",
38
38
  "fast-xml-parser": "^5.5.5"