@eldrforge/git-tools 0.1.7 → 0.1.9

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.
package/dist/index.d.ts CHANGED
@@ -1,254 +1,2 @@
1
- import { default as default_2 } from 'child_process';
2
-
3
- /**
4
- * Default console-based logger implementation
5
- */
6
- export declare class ConsoleLogger implements Logger {
7
- private level;
8
- constructor(level?: string);
9
- private shouldLog;
10
- error(message: string, ...meta: any[]): void;
11
- warn(message: string, ...meta: any[]): void;
12
- info(message: string, ...meta: any[]): void;
13
- verbose(message: string, ...meta: any[]): void;
14
- debug(message: string, ...meta: any[]): void;
15
- }
16
-
17
- /**
18
- * Escapes shell arguments to prevent command injection
19
- */
20
- export declare function escapeShellArg(arg: string): string;
21
-
22
- /**
23
- * Finds the previous release tag based on the current version using semantic versioning.
24
- * Returns the highest version tag that is less than the current version.
25
- *
26
- * @param currentVersion The current version (e.g., "1.2.3", "2.0.0")
27
- * @param tagPattern The pattern to match tags (e.g., "v*", "working/v*")
28
- * @returns The previous release tag or null if none found
29
- */
30
- export declare const findPreviousReleaseTag: (currentVersion: string, tagPattern?: string) => Promise<string | null>;
31
-
32
- /**
33
- * Gets the commit SHA for a given branch (local or remote)
34
- */
35
- export declare const getBranchCommitSha: (branchRef: string) => Promise<string>;
36
-
37
- /**
38
- * Gets the current branch name
39
- */
40
- export declare const getCurrentBranch: () => Promise<string>;
41
-
42
- /**
43
- * Gets the current version from package.json
44
- *
45
- * @returns The current version string or null if not found
46
- */
47
- export declare const getCurrentVersion: () => Promise<string | null>;
48
-
49
- /**
50
- * Gets a reliable default for the --from parameter by trying multiple fallbacks
51
- *
52
- * Tries in order:
53
- * 1. Previous working branch tag (if on working branch)
54
- * 2. Previous release tag (if current version can be determined)
55
- * 3. main (local main branch - typical release comparison base)
56
- * 4. master (local master branch - legacy default)
57
- * 5. origin/main (remote main branch fallback)
58
- * 6. origin/master (remote master branch fallback)
59
- *
60
- * @param forceMainBranch If true, skip tag detection and use main branch
61
- * @param currentBranch Current branch name for branch-aware tag detection
62
- * @returns A valid git reference to use as the default from parameter
63
- * @throws Error if no valid reference can be found
64
- */
65
- export declare const getDefaultFromRef: (forceMainBranch?: boolean, currentBranch?: string) => Promise<string>;
66
-
67
- /**
68
- * Gets git status summary including unstaged files, uncommitted changes, and unpushed commits
69
- */
70
- export declare const getGitStatusSummary: (workingDir?: string) => Promise<{
71
- branch: string;
72
- hasUnstagedFiles: boolean;
73
- hasUncommittedChanges: boolean;
74
- hasUnpushedCommits: boolean;
75
- unstagedCount: number;
76
- uncommittedCount: number;
77
- unpushedCount: number;
78
- status: string;
79
- }>;
80
-
81
- /**
82
- * Gets the list of globally linked packages (packages available to be linked to)
83
- */
84
- export declare const getGloballyLinkedPackages: () => Promise<Set<string>>;
85
-
86
- /**
87
- * Checks for actual semantic version compatibility issues between linked packages and their consumers
88
- * Returns a set of dependency names that have real compatibility problems
89
- *
90
- * This function ignores npm's strict prerelease handling and focuses on actual compatibility:
91
- * - "^4.4" is compatible with "4.4.53-dev.0" (prerelease of compatible minor version)
92
- * - "^4.4" is incompatible with "4.5.3" (different minor version)
93
- */
94
- export declare const getLinkCompatibilityProblems: (packageDir: string, allPackagesInfo?: Map<string, {
95
- name: string;
96
- version: string;
97
- path: string;
98
- }>) => Promise<Set<string>>;
99
-
100
- /**
101
- * Gets the list of packages that this package is actively linking to (consuming linked packages)
102
- */
103
- export declare const getLinkedDependencies: (packageDir: string) => Promise<Set<string>>;
104
-
105
- /**
106
- * Checks for npm link problems (version mismatches) in a package directory
107
- * Returns a set of dependency names that have link problems
108
- *
109
- * @deprecated Use getLinkCompatibilityProblems instead for better prerelease version handling
110
- */
111
- export declare const getLinkProblems: (packageDir: string) => Promise<Set<string>>;
112
-
113
- /**
114
- * Get the global logger instance
115
- */
116
- export declare function getLogger(): Logger;
117
-
118
- /**
119
- * Gets the default branch name from the remote repository
120
- */
121
- export declare const getRemoteDefaultBranch: () => Promise<string | null>;
122
-
123
- /**
124
- * Checks if a local branch is in sync with its remote counterpart
125
- */
126
- export declare const isBranchInSyncWithRemote: (branchName: string, remote?: string) => Promise<{
127
- inSync: boolean;
128
- localSha?: string;
129
- remoteSha?: string;
130
- localExists: boolean;
131
- remoteExists: boolean;
132
- error?: string;
133
- }>;
134
-
135
- /**
136
- * Checks if a package directory is npm linked (has a global symlink)
137
- */
138
- export declare const isNpmLinked: (packageDir: string) => Promise<boolean>;
139
-
140
- /**
141
- * Tests if a git reference exists and is valid
142
- */
143
- export declare const isValidGitRef: (ref: string) => Promise<boolean>;
144
-
145
- /**
146
- * Checks if a local branch exists
147
- */
148
- export declare const localBranchExists: (branchName: string) => Promise<boolean>;
149
-
150
- /**
151
- * Minimal logging interface that git-tools requires.
152
- * Allows consumers to provide their own logger implementation (e.g., Winston, console, etc.)
153
- */
154
- export declare interface Logger {
155
- error(message: string, ...meta: any[]): void;
156
- warn(message: string, ...meta: any[]): void;
157
- info(message: string, ...meta: any[]): void;
158
- verbose(message: string, ...meta: any[]): void;
159
- debug(message: string, ...meta: any[]): void;
160
- }
161
-
162
- /**
163
- * Checks if a remote branch exists
164
- */
165
- export declare const remoteBranchExists: (branchName: string, remote?: string) => Promise<boolean>;
166
-
167
- export declare function run(command: string, options?: RunOptions): Promise<{
168
- stdout: string;
169
- stderr: string;
170
- }>;
171
-
172
- export declare interface RunOptions extends default_2.ExecOptions {
173
- /** If true, suppresses error logging for non-zero exits (useful when non-zero exit is expected behavior) */
174
- suppressErrorLogging?: boolean;
175
- }
176
-
177
- /**
178
- * Securely executes a command with arguments array (no shell injection risk)
179
- */
180
- export declare function runSecure(command: string, args?: string[], options?: default_2.SpawnOptions): Promise<{
181
- stdout: string;
182
- stderr: string;
183
- }>;
184
-
185
- /**
186
- * Secure version of runWithDryRunSupport using argument arrays
187
- */
188
- export declare function runSecureWithDryRunSupport(command: string, args: string[] | undefined, isDryRun: boolean, options?: default_2.SpawnOptions, useInheritedStdio?: boolean): Promise<{
189
- stdout: string;
190
- stderr: string;
191
- }>;
192
-
193
- /**
194
- * Securely executes a command with inherited stdio (no shell injection risk)
195
- */
196
- export declare function runSecureWithInheritedStdio(command: string, args?: string[], options?: default_2.SpawnOptions): Promise<void>;
197
-
198
- export declare function runWithDryRunSupport(command: string, isDryRun: boolean, options?: default_2.ExecOptions, useInheritedStdio?: boolean): Promise<{
199
- stdout: string;
200
- stderr: string;
201
- }>;
202
-
203
- /**
204
- * @deprecated Use runSecureWithInheritedStdio instead for better security
205
- * Legacy function for backward compatibility - parses shell command string
206
- */
207
- export declare function runWithInheritedStdio(command: string, options?: default_2.ExecOptions): Promise<void>;
208
-
209
- /**
210
- * Safely parses JSON with error handling
211
- */
212
- export declare const safeJsonParse: <T = any>(jsonString: string, context?: string) => T;
213
-
214
- /**
215
- * Attempts to safely sync a local branch with its remote counterpart
216
- * Returns true if successful, false if conflicts exist that require manual resolution
217
- */
218
- export declare const safeSyncBranchWithRemote: (branchName: string, remote?: string) => Promise<{
219
- success: boolean;
220
- error?: string;
221
- conflictResolutionRequired?: boolean;
222
- }>;
223
-
224
- /**
225
- * Set the global logger instance
226
- */
227
- export declare function setLogger(logger: Logger): void;
228
-
229
- /**
230
- * Validates file paths to prevent injection
231
- */
232
- export declare function validateFilePath(filePath: string): boolean;
233
-
234
- /**
235
- * Validates git references to prevent injection
236
- */
237
- export declare function validateGitRef(ref: string): boolean;
238
-
239
- /**
240
- * Validates that a value exists and has a specific property
241
- */
242
- export declare const validateHasProperty: (obj: any, property: string, context?: string) => void;
243
-
244
- /**
245
- * Validates package.json structure has basic required fields
246
- */
247
- export declare const validatePackageJson: (data: any, context?: string, requireName?: boolean) => any;
248
-
249
- /**
250
- * Validates that a value is a non-empty string
251
- */
252
- export declare const validateString: (value: any, fieldName: string) => string;
253
-
254
- export { }
1
+ export * from './src/index'
2
+ export {}