@abapify/adt-export 0.4.0 → 0.4.1

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.
@@ -0,0 +1,170 @@
1
+ import { access, glob, readFile, readdir } from "node:fs/promises";
2
+ import { dirname, join, relative, resolve } from "node:path";
3
+ import { existsSync } from "node:fs";
4
+ //#region src/utils/filetree.ts
5
+ /**
6
+ * FileTree implementations
7
+ */
8
+ /**
9
+ * File system backed FileTree
10
+ */
11
+ var FsFileTree = class {
12
+ constructor(root) {
13
+ this.root = root;
14
+ }
15
+ async glob(pattern) {
16
+ const results = [];
17
+ for await (const path of glob(pattern, { cwd: this.root })) results.push(path);
18
+ return results;
19
+ }
20
+ async read(path) {
21
+ const content = await readFile(join(this.root, path), "utf-8");
22
+ return content.charCodeAt(0) === 65279 ? content.slice(1) : content;
23
+ }
24
+ async readBuffer(path) {
25
+ return readFile(join(this.root, path));
26
+ }
27
+ async exists(path) {
28
+ const fullPath = join(this.root, path);
29
+ try {
30
+ await access(fullPath);
31
+ return true;
32
+ } catch {
33
+ return false;
34
+ }
35
+ }
36
+ async readdir(path) {
37
+ return readdir(path ? join(this.root, path) : this.root);
38
+ }
39
+ };
40
+ /**
41
+ * In-memory FileTree for testing
42
+ */
43
+ var MemoryFileTree = class {
44
+ constructor(root, files) {
45
+ this.root = root;
46
+ this.files = files;
47
+ }
48
+ async glob(pattern) {
49
+ const body = pattern.replaceAll(/[.+?^${}()|[\]\\/]/g, "\\$&").replaceAll(/\*\*/g, "\0DOUBLESTAR\0").replaceAll(/\*/g, "[^/]*").split("\0DOUBLESTAR\0").join(".*");
50
+ const regex = new RegExp("^" + body + "$");
51
+ return Array.from(this.files.keys()).filter((p) => regex.test(p));
52
+ }
53
+ async read(path) {
54
+ const content = this.files.get(path);
55
+ if (content === void 0) throw new Error(`File not found: ${path}`);
56
+ return typeof content === "string" ? content : content.toString("utf-8");
57
+ }
58
+ async readBuffer(path) {
59
+ const content = this.files.get(path);
60
+ if (content === void 0) throw new Error(`File not found: ${path}`);
61
+ return typeof content === "string" ? Buffer.from(content) : content;
62
+ }
63
+ async exists(path) {
64
+ return this.files.has(path);
65
+ }
66
+ async readdir(path) {
67
+ const prefix = path ? path + "/" : "";
68
+ const entries = /* @__PURE__ */ new Set();
69
+ for (const filePath of this.files.keys()) if (filePath.startsWith(prefix)) {
70
+ const firstPart = filePath.slice(prefix.length).split("/")[0];
71
+ entries.add(firstPart);
72
+ }
73
+ return Array.from(entries);
74
+ }
75
+ };
76
+ /**
77
+ * Create FileTree from path
78
+ */
79
+ function createFileTree(sourcePath) {
80
+ return new FsFileTree(sourcePath);
81
+ }
82
+ /**
83
+ * FileTree wrapper that filters glob results to only include specified files.
84
+ * Metadata files (.abapgit.xml) always pass through.
85
+ */
86
+ var FilteredFileTree = class {
87
+ allowedFiles;
88
+ constructor(inner, files) {
89
+ this.inner = inner;
90
+ this.allowedFiles = new Set(files);
91
+ }
92
+ get root() {
93
+ return this.inner.root;
94
+ }
95
+ async glob(pattern) {
96
+ return (await this.inner.glob(pattern)).filter((f) => this.isAllowed(f));
97
+ }
98
+ read(path) {
99
+ return this.inner.read(path);
100
+ }
101
+ readBuffer(path) {
102
+ return this.inner.readBuffer(path);
103
+ }
104
+ exists(path) {
105
+ return this.inner.exists(path);
106
+ }
107
+ readdir(path) {
108
+ return this.inner.readdir(path);
109
+ }
110
+ isAllowed(filePath) {
111
+ if (filePath.endsWith(".abapgit.xml")) return true;
112
+ const filename = filePath.split("/").pop();
113
+ for (const allowed of this.allowedFiles) {
114
+ if (filePath === allowed || filename === allowed) return true;
115
+ const allowedName = allowed.split("/").pop();
116
+ const allowedBase = allowedName.replace(/\.\w+$/, "");
117
+ if (filename !== allowedName && filename.startsWith(allowedBase + ".")) return true;
118
+ }
119
+ return false;
120
+ }
121
+ };
122
+ /**
123
+ * Walk up from a directory to find the nearest ancestor containing .abapgit.xml.
124
+ * Returns the resolved absolute path to the repo root, or undefined if not found.
125
+ */
126
+ function findAbapGitRoot(startDir) {
127
+ let dir = resolve(startDir);
128
+ const root = resolve("/");
129
+ while (dir !== root) {
130
+ if (existsSync(join(dir, ".abapgit.xml"))) return dir;
131
+ const parent = dirname(dir);
132
+ if (parent === dir) break;
133
+ dir = parent;
134
+ }
135
+ }
136
+ /**
137
+ * Convert absolute file paths to paths relative to the repo root.
138
+ */
139
+ function resolveFilesRelativeToRoot(files, cwd, repoRoot) {
140
+ return files.map((f) => {
141
+ return relative(repoRoot, resolve(cwd, f));
142
+ });
143
+ }
144
+ //#endregion
145
+ //#region src/utils/format-plugin.ts
146
+ /** Map short names to actual package names */
147
+ const FORMAT_SHORTCUTS = {
148
+ abapgit: "@abapify/adt-plugin-abapgit",
149
+ ag: "@abapify/adt-plugin-abapgit"
150
+ };
151
+ /**
152
+ * Load format plugin dynamically by short name or package name.
153
+ */
154
+ async function loadFormatPlugin(formatSpec) {
155
+ const packageName = FORMAT_SHORTCUTS[formatSpec] ?? formatSpec;
156
+ try {
157
+ const pluginModule = await import(packageName);
158
+ const PluginClass = pluginModule.default || pluginModule[Object.keys(pluginModule)[0]];
159
+ if (!PluginClass) throw new Error(`No plugin class found in ${packageName}`);
160
+ return typeof PluginClass === "function" && PluginClass.prototype ? new PluginClass() : PluginClass;
161
+ } catch (error) {
162
+ const err = error;
163
+ 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 });
164
+ throw error;
165
+ }
166
+ }
167
+ //#endregion
168
+ export { createFileTree as a, MemoryFileTree as i, FilteredFileTree as n, findAbapGitRoot as o, FsFileTree as r, resolveFilesRelativeToRoot as s, loadFormatPlugin as t };
169
+
170
+ //# sourceMappingURL=format-plugin-MOM36i3B.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-plugin-MOM36i3B.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};\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;CAC1C,YAAY,MAA8B;AAAd,OAAA,OAAA;;CAE5B,MAAM,KAAK,SAAoC;EAC7C,MAAM,UAAoB,EAAE;AAE5B,aAAW,MAAM,QAAQA,KAAW,SAAS,EAAE,KAAK,KAAK,MAAM,CAAC,CAC9D,SAAQ,KAAK,KAAK;AAEpB,SAAO;;CAGT,MAAM,KAAK,MAA+B;EAExC,MAAM,UAAU,MAAM,SADL,KAAK,KAAK,MAAM,KAAK,EACG,QAAQ;AAEjD,SAAO,QAAQ,WAAW,EAAE,KAAK,QAAS,QAAQ,MAAM,EAAE,GAAG;;CAG/D,MAAM,WAAW,MAA+B;AAE9C,SAAO,SADU,KAAK,KAAK,MAAM,KAAK,CACb;;CAG3B,MAAM,OAAO,MAAgC;EAC3C,MAAM,WAAW,KAAK,KAAK,MAAM,KAAK;AACtC,MAAI;AACF,SAAM,OAAO,SAAS;AACtB,UAAO;UACD;AACN,UAAO;;;CAIX,MAAM,QAAQ,MAAiC;AAE7C,SAAO,QADU,OAAO,KAAK,KAAK,MAAM,KAAK,GAAG,KAAK,KAC7B;;;;;;AAO5B,IAAa,iBAAb,MAAgD;CAC9C,YACE,MACA,OACA;AAFgB,OAAA,OAAA;AACC,OAAA,QAAA;;CAGnB,MAAM,KAAK,SAAoC;EAW7C,MAAM,OADU,QAAQ,WAAW,uBAAuB,OAAO,CA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AM,cACJ,aAAa,WAAW,aAAa,OAAO,KAAK,aAAa,CAAC;AAEjE,MAAI,CAAC,YACH,OAAM,IAAI,MAAM,4BAA4B,cAAc;AAI5D,SAAO,OAAO,gBAAgB,cAAc,YAAY,YACpD,IAAI,aAAa,GACjB;UACG,OAAgB;EACvB,MAAM,MAAM;AACZ,MACG,IAAY,SAAS,sBACtB,IAAI,SAAS,SAAS,uBAAuB,YAAY,GAAG,CAE5D,OAAM,IAAI,MACR,mBAAmB,YAAY,wCAAwC,eACvE,EAAE,OAAO,OAAO,CACjB;AAEH,QAAM"}
@@ -0,0 +1,136 @@
1
+ import exportCommand from "./commands/export.mjs";
2
+ import { FileTree, FileTree as FileTree$1 } from "@abapify/adt-plugin";
3
+
4
+ //#region src/utils/filetree.d.ts
5
+ /**
6
+ * File system backed FileTree
7
+ */
8
+ declare class FsFileTree implements FileTree$1 {
9
+ readonly root: string;
10
+ constructor(root: string);
11
+ glob(pattern: string): Promise<string[]>;
12
+ read(path: string): Promise<string>;
13
+ readBuffer(path: string): Promise<Buffer>;
14
+ exists(path: string): Promise<boolean>;
15
+ readdir(path: string): Promise<string[]>;
16
+ }
17
+ /**
18
+ * In-memory FileTree for testing
19
+ */
20
+ declare class MemoryFileTree implements FileTree$1 {
21
+ readonly root: string;
22
+ private readonly files;
23
+ constructor(root: string, files: Map<string, string | Buffer>);
24
+ glob(pattern: string): Promise<string[]>;
25
+ read(path: string): Promise<string>;
26
+ readBuffer(path: string): Promise<Buffer>;
27
+ exists(path: string): Promise<boolean>;
28
+ readdir(path: string): Promise<string[]>;
29
+ }
30
+ /**
31
+ * Create FileTree from path
32
+ */
33
+ declare function createFileTree(sourcePath: string): FileTree$1;
34
+ /**
35
+ * FileTree wrapper that filters glob results to only include specified files.
36
+ * Metadata files (.abapgit.xml) always pass through.
37
+ */
38
+ declare class FilteredFileTree implements FileTree$1 {
39
+ private readonly inner;
40
+ private readonly allowedFiles;
41
+ constructor(inner: FileTree$1, files: string[]);
42
+ get root(): string;
43
+ glob(pattern: string): Promise<string[]>;
44
+ read(path: string): Promise<string>;
45
+ readBuffer(path: string): Promise<Buffer>;
46
+ exists(path: string): Promise<boolean>;
47
+ readdir(path: string): Promise<string[]>;
48
+ private isAllowed;
49
+ }
50
+ /**
51
+ * Walk up from a directory to find the nearest ancestor containing .abapgit.xml.
52
+ * Returns the resolved absolute path to the repo root, or undefined if not found.
53
+ */
54
+ declare function findAbapGitRoot(startDir: string): string | undefined;
55
+ /**
56
+ * Convert absolute file paths to paths relative to the repo root.
57
+ */
58
+ declare function resolveFilesRelativeToRoot(files: string[], cwd: string, repoRoot: string): string[];
59
+ //#endregion
60
+ //#region src/types.d.ts
61
+ /**
62
+ * Export result statistics
63
+ */
64
+ interface ExportResult {
65
+ /** Number of objects discovered */
66
+ discovered: number;
67
+ /** Number of objects saved */
68
+ saved: number;
69
+ /** Number of objects activated */
70
+ activated: number;
71
+ /** Number of objects skipped */
72
+ skipped: number;
73
+ /** Number of objects failed */
74
+ failed: number;
75
+ /** Detailed object results */
76
+ objects: ExportObjectResult[];
77
+ /** Package verification results (only when --verify is used) */
78
+ verification?: VerificationResult;
79
+ }
80
+ /**
81
+ * Individual object export result
82
+ */
83
+ interface ExportObjectResult {
84
+ type: string;
85
+ name: string;
86
+ status: 'saved' | 'activated' | 'skipped' | 'failed';
87
+ error?: string;
88
+ }
89
+ /**
90
+ * Package verification result
91
+ */
92
+ interface VerificationResult {
93
+ /** Total objects verified */
94
+ total: number;
95
+ /** Objects in the correct package */
96
+ correct: number;
97
+ /** Objects in the wrong package */
98
+ mismatched: number;
99
+ /** Objects that couldn't be verified (e.g., load failed) */
100
+ errors: number;
101
+ /** Detailed per-object results */
102
+ details: VerificationDetail[];
103
+ }
104
+ /**
105
+ * Per-object verification detail
106
+ */
107
+ interface VerificationDetail {
108
+ type: string;
109
+ name: string;
110
+ expectedPackage: string;
111
+ actualPackage?: string;
112
+ status: 'correct' | 'mismatched' | 'error';
113
+ error?: string;
114
+ }
115
+ /**
116
+ * Export options
117
+ */
118
+ interface ExportOptions {
119
+ /** Source directory containing serialized files */
120
+ sourcePath: string;
121
+ /** Format plugin name (e.g., 'abapgit', '@abapify/adt-plugin-abapgit') */
122
+ format: string;
123
+ /** Transport request for changes */
124
+ transportRequest?: string;
125
+ /** Target package (for new objects) */
126
+ targetPackage?: string;
127
+ /** Filter by object types */
128
+ objectTypes?: string[];
129
+ /** Dry run - don't actually save */
130
+ dryRun?: boolean;
131
+ /** Enable debug output */
132
+ debug?: boolean;
133
+ }
134
+ //#endregion
135
+ export { type ExportObjectResult, type ExportOptions, type ExportResult, type FileTree, FilteredFileTree, FsFileTree, MemoryFileTree, createFileTree, exportCommand, findAbapGitRoot, resolveFilesRelativeToRoot };
136
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/utils/filetree.ts","../src/types.ts"],"mappings":";;;;AAiBA;;;AAAA,cAAa,UAAA,YAAsB,UAAA;EAAA,SACL,IAAA;cAAA,IAAA;EAEtB,IAAA,CAAK,OAAA,WAAkB,OAAA;EASvB,IAAA,CAAK,IAAA,WAAe,OAAA;EAOpB,UAAA,CAAW,IAAA,WAAe,OAAA,CAAQ,MAAA;EAKlC,MAAA,CAAO,IAAA,WAAe,OAAA;EAUtB,OAAA,CAAQ,IAAA,WAAe,OAAA;AAAA;;;;cASlB,cAAA,YAA0B,UAAA;EAAA,SAEnB,IAAA;EAAA,iBACC,KAAA;cADD,IAAA,UACC,KAAA,EAAO,GAAA,kBAAqB,MAAA;EAGzC,IAAA,CAAK,OAAA,WAAkB,OAAA;EAoBvB,IAAA,CAAK,IAAA,WAAe,OAAA;EAQpB,UAAA,CAAW,IAAA,WAAe,OAAA,CAAQ,MAAA;EAQlC,MAAA,CAAO,IAAA,WAAe,OAAA;EAItB,OAAA,CAAQ,IAAA,WAAe,OAAA;AAAA;;;;iBAmBf,cAAA,CAAe,UAAA,WAAqB,UAAA;;;;;cAQvC,gBAAA,YAA4B,UAAA;EAAA,iBAIpB,KAAA;EAAA,iBAHF,YAAA;cAGE,KAAA,EAAO,UAAA,EACxB,KAAA;EAAA,IAKE,IAAA,CAAA;EAIE,IAAA,CAAK,OAAA,WAAkB,OAAA;EAK7B,IAAA,CAAK,IAAA,WAAe,OAAA;EAIpB,UAAA,CAAW,IAAA,WAAe,OAAA,CAAQ,MAAA;EAIlC,MAAA,CAAO,IAAA,WAAe,OAAA;EAItB,OAAA,CAAQ,IAAA,WAAe,OAAA;EAAA,QAIf,SAAA;AAAA;;;;;iBA8BM,eAAA,CAAgB,QAAA;;;;iBAkBhB,0BAAA,CACd,KAAA,YACA,GAAA,UACA,QAAA;;;AA1MF;;;AAAA,UCPiB,YAAA;EDmBW;ECjB1B,UAAA;EDwBgC;ECtBhC,KAAA;EDqC6B;ECnC7B,SAAA;EDCyC;ECCzC,OAAA;EDDiC;ECGjC,MAAA;;EAEA,OAAA,EAAS,kBAAA;EDFH;ECIN,YAAA,GAAe,kBAAA;AAAA;;;;UAMA,kBAAA;EACf,IAAA;EACA,IAAA;EACA,MAAA;EACA,KAAA;AAAA;;;;UAMe,kBAAA;EDWqB;ECTpC,KAAA;EDkBW;EChBX,OAAA;;EAEA,UAAA;EDiB0B;ECf1B,MAAA;EDsC0B;ECpC1B,OAAA,EAAS,kBAAA;AAAA;;;;UAMM,kBAAA;EACf,IAAA;EACA,IAAA;EACA,eAAA;EACA,aAAA;EACA,MAAA;EACA,KAAA;AAAA;;;;UAMe,aAAA;EDFc;ECI7B,UAAA;EDgBW;ECdX,MAAA;EDsBM;ECpBN,gBAAA;EDoBgC;EClBhC,aAAA;ED0BM;ECxBN,WAAA;EDwB4B;ECtB5B,MAAA;ED0Bc;ECxBd,KAAA;AAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +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-MOM36i3B.mjs";
2
+ import exportCommand from "./commands/export.mjs";
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.0",
3
+ "version": "0.4.1",
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.0",
33
- "@abapify/adt-locks": "0.4.0",
34
- "@abapify/adt-plugin": "0.4.0",
35
- "@abapify/adt-plugin-abapgit": "0.4.0",
32
+ "@abapify/adk": "0.4.1",
33
+ "@abapify/adt-locks": "0.4.1",
34
+ "@abapify/adt-plugin": "0.4.1",
35
+ "@abapify/adt-plugin-abapgit": "0.4.1",
36
36
  "chalk": "^5.6.2",
37
37
  "diff": "^8.0.3",
38
38
  "fast-xml-parser": "^5.5.5"