@socketsecurity/lib 1.0.5 → 1.1.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/arrays.d.ts +143 -0
  3. package/dist/arrays.js.map +2 -2
  4. package/dist/effects/text-shimmer.js +2 -1
  5. package/dist/effects/text-shimmer.js.map +2 -2
  6. package/dist/fs.d.ts +595 -23
  7. package/dist/fs.js.map +2 -2
  8. package/dist/git.d.ts +488 -41
  9. package/dist/git.js.map +2 -2
  10. package/dist/github.d.ts +361 -12
  11. package/dist/github.js.map +2 -2
  12. package/dist/http-request.d.ts +463 -4
  13. package/dist/http-request.js.map +2 -2
  14. package/dist/json.d.ts +177 -4
  15. package/dist/json.js.map +2 -2
  16. package/dist/logger.d.ts +822 -67
  17. package/dist/logger.js +653 -46
  18. package/dist/logger.js.map +2 -2
  19. package/dist/objects.d.ts +386 -10
  20. package/dist/objects.js.map +2 -2
  21. package/dist/path.d.ts +270 -6
  22. package/dist/path.js.map +2 -2
  23. package/dist/promises.d.ts +432 -27
  24. package/dist/promises.js.map +2 -2
  25. package/dist/spawn.d.ts +239 -12
  26. package/dist/spawn.js.map +2 -2
  27. package/dist/spinner.d.ts +260 -20
  28. package/dist/spinner.js +201 -63
  29. package/dist/spinner.js.map +2 -2
  30. package/dist/stdio/clear.d.ts +130 -9
  31. package/dist/stdio/clear.js.map +2 -2
  32. package/dist/stdio/divider.d.ts +106 -10
  33. package/dist/stdio/divider.js +10 -0
  34. package/dist/stdio/divider.js.map +2 -2
  35. package/dist/stdio/footer.d.ts +70 -3
  36. package/dist/stdio/footer.js.map +2 -2
  37. package/dist/stdio/header.d.ts +93 -12
  38. package/dist/stdio/header.js.map +2 -2
  39. package/dist/stdio/mask.d.ts +82 -14
  40. package/dist/stdio/mask.js +25 -4
  41. package/dist/stdio/mask.js.map +2 -2
  42. package/dist/stdio/progress.d.ts +112 -15
  43. package/dist/stdio/progress.js +43 -3
  44. package/dist/stdio/progress.js.map +2 -2
  45. package/dist/stdio/prompts.d.ts +95 -5
  46. package/dist/stdio/prompts.js.map +2 -2
  47. package/dist/stdio/stderr.d.ts +114 -11
  48. package/dist/stdio/stderr.js.map +2 -2
  49. package/dist/stdio/stdout.d.ts +107 -11
  50. package/dist/stdio/stdout.js.map +2 -2
  51. package/dist/strings.d.ts +357 -28
  52. package/dist/strings.js.map +2 -2
  53. package/dist/validation/json-parser.d.ts +226 -7
  54. package/dist/validation/json-parser.js.map +2 -2
  55. package/dist/validation/types.d.ts +114 -8
  56. package/dist/validation/types.js.map +1 -1
  57. package/package.json +1 -1
package/dist/git.d.ts CHANGED
@@ -1,93 +1,540 @@
1
1
  /**
2
2
  * Options for git diff operations.
3
+ *
4
+ * Controls how git diff results are processed and returned.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * // Get absolute file paths
9
+ * const files = await getChangedFiles({ absolute: true })
10
+ * // => ['/path/to/repo/src/file.ts']
11
+ *
12
+ * // Get relative paths with caching disabled
13
+ * const files = await getChangedFiles({ cache: false })
14
+ * // => ['src/file.ts']
15
+ *
16
+ * // Get files from specific directory
17
+ * const files = await getChangedFiles({ cwd: '/path/to/repo/src' })
18
+ * ```
3
19
  */
4
20
  export interface GitDiffOptions {
5
- absolute?: boolean;
6
- cache?: boolean;
7
- cwd?: string;
8
- porcelain?: boolean;
9
- asSet?: boolean;
21
+ /**
22
+ * Return absolute file paths instead of relative paths.
23
+ *
24
+ * @default false
25
+ */
26
+ absolute?: boolean | undefined;
27
+ /**
28
+ * Cache git diff results to avoid repeated git subprocess calls.
29
+ *
30
+ * Caching is keyed by the git command and options used, so different
31
+ * option combinations maintain separate cache entries.
32
+ *
33
+ * @default true
34
+ */
35
+ cache?: boolean | undefined;
36
+ /**
37
+ * Working directory for git operations.
38
+ *
39
+ * Git operations will be run from this directory, and returned paths
40
+ * will be relative to the git repository root. Symlinks are resolved
41
+ * using `fs.realpathSync()`.
42
+ *
43
+ * @default process.cwd()
44
+ */
45
+ cwd?: string | undefined;
46
+ /**
47
+ * Parse git porcelain format output (status codes like `M`, `A`, `??`).
48
+ *
49
+ * When `true`, strips the two-character status code and space from the
50
+ * beginning of each line. Automatically enabled for `getChangedFiles()`.
51
+ *
52
+ * @default false
53
+ */
54
+ porcelain?: boolean | undefined;
55
+ /**
56
+ * Return results as a `Set` instead of an array.
57
+ *
58
+ * @default false
59
+ */
60
+ asSet?: boolean | undefined;
61
+ /**
62
+ * Additional options passed to glob matcher.
63
+ *
64
+ * Supports options like `dot`, `ignore`, `nocase` for filtering results.
65
+ */
10
66
  [key: string]: unknown;
11
67
  }
12
68
  /**
13
- * Options for package filtering operations.
69
+ * Options for filtering packages by git changes.
70
+ *
71
+ * Used to determine which packages in a monorepo have changed files.
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * // Filter packages with changes
76
+ * const changed = filterPackagesByChanges(packages)
77
+ *
78
+ * // Force include all packages
79
+ * const all = filterPackagesByChanges(packages, { force: true })
80
+ *
81
+ * // Use custom package key
82
+ * const changed = filterPackagesByChanges(
83
+ * packages,
84
+ * { packageKey: 'directory' }
85
+ * )
86
+ * ```
14
87
  */
15
88
  export interface FilterPackagesByChangesOptions {
16
- force?: boolean;
17
- packageKey?: string;
89
+ /**
90
+ * Force include all packages regardless of changes.
91
+ *
92
+ * @default false
93
+ */
94
+ force?: boolean | undefined;
95
+ /**
96
+ * Key to access package path in package objects.
97
+ *
98
+ * @default 'path'
99
+ */
100
+ packageKey?: string | undefined;
101
+ /**
102
+ * Additional options for filtering.
103
+ */
18
104
  [key: string]: unknown;
19
105
  }
20
106
  /**
21
107
  * Find git repository root by walking up from the given directory.
22
- * Returns the directory itself if it contains .git, or the original path if no .git found.
23
- * Exported for testing.
108
+ *
109
+ * Searches for a `.git` directory or file by traversing parent directories
110
+ * upward until found or filesystem root is reached. Returns the original path
111
+ * if no git repository is found.
112
+ *
113
+ * This function is exported primarily for testing purposes.
114
+ *
115
+ * @param startPath - Directory path to start searching from.
116
+ * @returns Git repository root path, or `startPath` if not found.
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * const root = findGitRoot('/path/to/repo/src/subdir')
121
+ * // => '/path/to/repo'
122
+ *
123
+ * const notFound = findGitRoot('/not/a/repo')
124
+ * // => '/not/a/repo'
125
+ * ```
24
126
  */
25
127
  export declare function findGitRoot(startPath: string): string;
26
128
  /**
27
129
  * Get all changed files including staged, unstaged, and untracked files.
130
+ *
28
131
  * Uses `git status --porcelain` which returns the full working tree status
29
- * with status codes (M=modified, A=added, D=deleted, ??=untracked, etc.).
132
+ * with status codes:
133
+ * - `M` - Modified
134
+ * - `A` - Added
135
+ * - `D` - Deleted
136
+ * - `??` - Untracked
137
+ * - `R` - Renamed
138
+ * - `C` - Copied
139
+ *
30
140
  * This is the most comprehensive check - captures everything that differs
31
- * from the last commit.
141
+ * from the last commit, including:
142
+ * - Files modified and staged with `git add`
143
+ * - Files modified but not staged
144
+ * - New files not yet tracked by git
145
+ *
146
+ * Status codes are automatically stripped from the output.
147
+ *
148
+ * @param options - Options controlling path format and filtering.
149
+ * @returns Promise resolving to array of changed file paths.
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * // Get all changed files as relative paths
154
+ * const files = await getChangedFiles()
155
+ * // => ['src/foo.ts', 'src/bar.ts', 'newfile.ts']
156
+ *
157
+ * // Get absolute paths
158
+ * const files = await getChangedFiles({ absolute: true })
159
+ * // => ['/path/to/repo/src/foo.ts', ...]
160
+ *
161
+ * // Get changed files in specific directory
162
+ * const files = await getChangedFiles({ cwd: '/path/to/repo/src' })
163
+ * // => ['foo.ts', 'bar.ts']
164
+ * ```
32
165
  */
33
- export declare function getChangedFiles(options?: GitDiffOptions): Promise<string[]>;
166
+ export declare function getChangedFiles(options?: GitDiffOptions | undefined): Promise<string[]>;
34
167
  /**
35
168
  * Get all changed files including staged, unstaged, and untracked files.
36
- * Uses `git status --porcelain` which returns the full working tree status
37
- * with status codes (M=modified, A=added, D=deleted, ??=untracked, etc.).
169
+ *
170
+ * Synchronous version of `getChangedFiles()`. Uses `git status --porcelain`
171
+ * which returns the full working tree status with status codes:
172
+ * - `M` - Modified
173
+ * - `A` - Added
174
+ * - `D` - Deleted
175
+ * - `??` - Untracked
176
+ * - `R` - Renamed
177
+ * - `C` - Copied
178
+ *
38
179
  * This is the most comprehensive check - captures everything that differs
39
- * from the last commit.
180
+ * from the last commit, including:
181
+ * - Files modified and staged with `git add`
182
+ * - Files modified but not staged
183
+ * - New files not yet tracked by git
184
+ *
185
+ * Status codes are automatically stripped from the output.
186
+ *
187
+ * @param options - Options controlling path format and filtering.
188
+ * @returns Array of changed file paths.
189
+ *
190
+ * @example
191
+ * ```typescript
192
+ * // Get all changed files as relative paths
193
+ * const files = getChangedFilesSync()
194
+ * // => ['src/foo.ts', 'src/bar.ts', 'newfile.ts']
195
+ *
196
+ * // Get absolute paths
197
+ * const files = getChangedFilesSync({ absolute: true })
198
+ * // => ['/path/to/repo/src/foo.ts', ...]
199
+ *
200
+ * // Get changed files in specific directory
201
+ * const files = getChangedFilesSync({ cwd: '/path/to/repo/src' })
202
+ * // => ['foo.ts', 'bar.ts']
203
+ * ```
40
204
  */
41
- export declare function getChangedFilesSync(options?: GitDiffOptions): string[];
205
+ export declare function getChangedFilesSync(options?: GitDiffOptions | undefined): string[];
42
206
  /**
43
207
  * Get unstaged modified files (changes not yet staged for commit).
208
+ *
44
209
  * Uses `git diff --name-only` which returns only unstaged modifications
45
- * to tracked files. Does not include untracked files or staged changes.
46
- * This is a focused check for uncommitted changes to existing files.
210
+ * to tracked files. Does NOT include:
211
+ * - Untracked files (new files not added to git)
212
+ * - Staged changes (files added with `git add`)
213
+ *
214
+ * This is a focused check for uncommitted changes to existing tracked files.
215
+ * Useful for detecting work-in-progress modifications before staging.
216
+ *
217
+ * @param options - Options controlling path format and filtering.
218
+ * @returns Promise resolving to array of unstaged file paths.
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * // Get unstaged files
223
+ * const files = await getUnstagedFiles()
224
+ * // => ['src/foo.ts', 'src/bar.ts']
225
+ *
226
+ * // After staging some files
227
+ * await spawn('git', ['add', 'src/foo.ts'])
228
+ * const files = await getUnstagedFiles()
229
+ * // => ['src/bar.ts'] (foo.ts no longer included)
230
+ *
231
+ * // Get absolute paths
232
+ * const files = await getUnstagedFiles({ absolute: true })
233
+ * // => ['/path/to/repo/src/bar.ts']
234
+ * ```
47
235
  */
48
- export declare function getUnstagedFiles(options?: GitDiffOptions): Promise<string[]>;
236
+ export declare function getUnstagedFiles(options?: GitDiffOptions | undefined): Promise<string[]>;
49
237
  /**
50
238
  * Get unstaged modified files (changes not yet staged for commit).
51
- * Uses `git diff --name-only` which returns only unstaged modifications
52
- * to tracked files. Does not include untracked files or staged changes.
53
- * This is a focused check for uncommitted changes to existing files.
239
+ *
240
+ * Synchronous version of `getUnstagedFiles()`. Uses `git diff --name-only`
241
+ * which returns only unstaged modifications to tracked files. Does NOT include:
242
+ * - Untracked files (new files not added to git)
243
+ * - Staged changes (files added with `git add`)
244
+ *
245
+ * This is a focused check for uncommitted changes to existing tracked files.
246
+ * Useful for detecting work-in-progress modifications before staging.
247
+ *
248
+ * @param options - Options controlling path format and filtering.
249
+ * @returns Array of unstaged file paths.
250
+ *
251
+ * @example
252
+ * ```typescript
253
+ * // Get unstaged files
254
+ * const files = getUnstagedFilesSync()
255
+ * // => ['src/foo.ts', 'src/bar.ts']
256
+ *
257
+ * // After staging some files
258
+ * spawnSync('git', ['add', 'src/foo.ts'])
259
+ * const files = getUnstagedFilesSync()
260
+ * // => ['src/bar.ts'] (foo.ts no longer included)
261
+ *
262
+ * // Get absolute paths
263
+ * const files = getUnstagedFilesSync({ absolute: true })
264
+ * // => ['/path/to/repo/src/bar.ts']
265
+ * ```
54
266
  */
55
- export declare function getUnstagedFilesSync(options?: GitDiffOptions): string[];
267
+ export declare function getUnstagedFilesSync(options?: GitDiffOptions | undefined): string[];
56
268
  /**
57
269
  * Get staged files ready for commit (changes added with `git add`).
270
+ *
58
271
  * Uses `git diff --cached --name-only` which returns only staged changes.
59
- * Does not include unstaged modifications or untracked files.
272
+ * Does NOT include:
273
+ * - Unstaged modifications (changes not added with `git add`)
274
+ * - Untracked files (new files not added to git)
275
+ *
60
276
  * This is a focused check for what will be included in the next commit.
277
+ * Useful for validating changes before committing or running pre-commit hooks.
278
+ *
279
+ * @param options - Options controlling path format and filtering.
280
+ * @returns Promise resolving to array of staged file paths.
281
+ *
282
+ * @example
283
+ * ```typescript
284
+ * // Get currently staged files
285
+ * const files = await getStagedFiles()
286
+ * // => ['src/foo.ts']
287
+ *
288
+ * // Stage more files
289
+ * await spawn('git', ['add', 'src/bar.ts'])
290
+ * const files = await getStagedFiles()
291
+ * // => ['src/foo.ts', 'src/bar.ts']
292
+ *
293
+ * // Get absolute paths
294
+ * const files = await getStagedFiles({ absolute: true })
295
+ * // => ['/path/to/repo/src/foo.ts', ...]
296
+ * ```
61
297
  */
62
- export declare function getStagedFiles(options?: GitDiffOptions): Promise<string[]>;
298
+ export declare function getStagedFiles(options?: GitDiffOptions | undefined): Promise<string[]>;
63
299
  /**
64
300
  * Get staged files ready for commit (changes added with `git add`).
65
- * Uses `git diff --cached --name-only` which returns only staged changes.
66
- * Does not include unstaged modifications or untracked files.
301
+ *
302
+ * Synchronous version of `getStagedFiles()`. Uses `git diff --cached --name-only`
303
+ * which returns only staged changes. Does NOT include:
304
+ * - Unstaged modifications (changes not added with `git add`)
305
+ * - Untracked files (new files not added to git)
306
+ *
67
307
  * This is a focused check for what will be included in the next commit.
308
+ * Useful for validating changes before committing or running pre-commit hooks.
309
+ *
310
+ * @param options - Options controlling path format and filtering.
311
+ * @returns Array of staged file paths.
312
+ *
313
+ * @example
314
+ * ```typescript
315
+ * // Get currently staged files
316
+ * const files = getStagedFilesSync()
317
+ * // => ['src/foo.ts']
318
+ *
319
+ * // Stage more files
320
+ * spawnSync('git', ['add', 'src/bar.ts'])
321
+ * const files = getStagedFilesSync()
322
+ * // => ['src/foo.ts', 'src/bar.ts']
323
+ *
324
+ * // Get absolute paths
325
+ * const files = getStagedFilesSync({ absolute: true })
326
+ * // => ['/path/to/repo/src/foo.ts', ...]
327
+ * ```
68
328
  */
69
- export declare function getStagedFilesSync(options?: GitDiffOptions): string[];
329
+ export declare function getStagedFilesSync(options?: GitDiffOptions | undefined): string[];
70
330
  /**
71
- * Check if pathname has any changes (staged, unstaged, or untracked).
331
+ * Check if a file or directory has any git changes.
332
+ *
333
+ * Checks if the given pathname has any changes including:
334
+ * - Staged modifications (added with `git add`)
335
+ * - Unstaged modifications (not yet staged)
336
+ * - Untracked status (new file/directory not in git)
337
+ *
338
+ * For directories, returns `true` if ANY file within the directory has changes.
339
+ *
340
+ * Symlinks in the pathname and cwd are automatically resolved using
341
+ * `fs.realpathSync()` before comparison.
342
+ *
343
+ * @param pathname - File or directory path to check.
344
+ * @param options - Options for the git status check.
345
+ * @returns Promise resolving to `true` if path has any changes, `false` otherwise.
346
+ *
347
+ * @example
348
+ * ```typescript
349
+ * // Check if file is changed
350
+ * const changed = await isChanged('src/foo.ts')
351
+ * // => true
352
+ *
353
+ * // Check if directory has any changes
354
+ * const changed = await isChanged('src/')
355
+ * // => true (if any file in src/ is changed)
356
+ *
357
+ * // Check from different cwd
358
+ * const changed = await isChanged(
359
+ * '/path/to/repo/src/foo.ts',
360
+ * { cwd: '/path/to/repo' }
361
+ * )
362
+ * ```
72
363
  */
73
- export declare function isChanged(pathname: string, options?: GitDiffOptions): Promise<boolean>;
364
+ export declare function isChanged(pathname: string, options?: GitDiffOptions | undefined): Promise<boolean>;
74
365
  /**
75
- * Check if pathname has any changes (staged, unstaged, or untracked).
366
+ * Check if a file or directory has any git changes.
367
+ *
368
+ * Synchronous version of `isChanged()`. Checks if the given pathname has
369
+ * any changes including:
370
+ * - Staged modifications (added with `git add`)
371
+ * - Unstaged modifications (not yet staged)
372
+ * - Untracked status (new file/directory not in git)
373
+ *
374
+ * For directories, returns `true` if ANY file within the directory has changes.
375
+ *
376
+ * Symlinks in the pathname and cwd are automatically resolved using
377
+ * `fs.realpathSync()` before comparison.
378
+ *
379
+ * @param pathname - File or directory path to check.
380
+ * @param options - Options for the git status check.
381
+ * @returns `true` if path has any changes, `false` otherwise.
382
+ *
383
+ * @example
384
+ * ```typescript
385
+ * // Check if file is changed
386
+ * const changed = isChangedSync('src/foo.ts')
387
+ * // => true
388
+ *
389
+ * // Check if directory has any changes
390
+ * const changed = isChangedSync('src/')
391
+ * // => true (if any file in src/ is changed)
392
+ *
393
+ * // Check from different cwd
394
+ * const changed = isChangedSync(
395
+ * '/path/to/repo/src/foo.ts',
396
+ * { cwd: '/path/to/repo' }
397
+ * )
398
+ * ```
76
399
  */
77
- export declare function isChangedSync(pathname: string, options?: GitDiffOptions): boolean;
400
+ export declare function isChangedSync(pathname: string, options?: GitDiffOptions | undefined): boolean;
78
401
  /**
79
- * Check if pathname has unstaged changes (modified but not staged).
402
+ * Check if a file or directory has unstaged changes.
403
+ *
404
+ * Checks if the given pathname has modifications that are not yet staged
405
+ * for commit (changes not added with `git add`). Does NOT include:
406
+ * - Staged changes (already added with `git add`)
407
+ * - Untracked files (new files not in git)
408
+ *
409
+ * For directories, returns `true` if ANY file within the directory has
410
+ * unstaged changes.
411
+ *
412
+ * Symlinks in the pathname and cwd are automatically resolved using
413
+ * `fs.realpathSync()` before comparison.
414
+ *
415
+ * @param pathname - File or directory path to check.
416
+ * @param options - Options for the git diff check.
417
+ * @returns Promise resolving to `true` if path has unstaged changes, `false` otherwise.
418
+ *
419
+ * @example
420
+ * ```typescript
421
+ * // Check if file has unstaged changes
422
+ * const unstaged = await isUnstaged('src/foo.ts')
423
+ * // => true
424
+ *
425
+ * // After staging the file
426
+ * await spawn('git', ['add', 'src/foo.ts'])
427
+ * const unstaged = await isUnstaged('src/foo.ts')
428
+ * // => false
429
+ *
430
+ * // Check directory
431
+ * const unstaged = await isUnstaged('src/')
432
+ * // => true (if any file in src/ has unstaged changes)
433
+ * ```
80
434
  */
81
- export declare function isUnstaged(pathname: string, options?: GitDiffOptions): Promise<boolean>;
435
+ export declare function isUnstaged(pathname: string, options?: GitDiffOptions | undefined): Promise<boolean>;
82
436
  /**
83
- * Check if pathname has unstaged changes (modified but not staged).
437
+ * Check if a file or directory has unstaged changes.
438
+ *
439
+ * Synchronous version of `isUnstaged()`. Checks if the given pathname has
440
+ * modifications that are not yet staged for commit (changes not added with
441
+ * `git add`). Does NOT include:
442
+ * - Staged changes (already added with `git add`)
443
+ * - Untracked files (new files not in git)
444
+ *
445
+ * For directories, returns `true` if ANY file within the directory has
446
+ * unstaged changes.
447
+ *
448
+ * Symlinks in the pathname and cwd are automatically resolved using
449
+ * `fs.realpathSync()` before comparison.
450
+ *
451
+ * @param pathname - File or directory path to check.
452
+ * @param options - Options for the git diff check.
453
+ * @returns `true` if path has unstaged changes, `false` otherwise.
454
+ *
455
+ * @example
456
+ * ```typescript
457
+ * // Check if file has unstaged changes
458
+ * const unstaged = isUnstagedSync('src/foo.ts')
459
+ * // => true
460
+ *
461
+ * // After staging the file
462
+ * spawnSync('git', ['add', 'src/foo.ts'])
463
+ * const unstaged = isUnstagedSync('src/foo.ts')
464
+ * // => false
465
+ *
466
+ * // Check directory
467
+ * const unstaged = isUnstagedSync('src/')
468
+ * // => true (if any file in src/ has unstaged changes)
469
+ * ```
84
470
  */
85
- export declare function isUnstagedSync(pathname: string, options?: GitDiffOptions): boolean;
471
+ export declare function isUnstagedSync(pathname: string, options?: GitDiffOptions | undefined): boolean;
86
472
  /**
87
- * Check if pathname is staged for commit.
473
+ * Check if a file or directory is staged for commit.
474
+ *
475
+ * Checks if the given pathname has changes staged with `git add` that will
476
+ * be included in the next commit. Does NOT include:
477
+ * - Unstaged modifications (changes not added with `git add`)
478
+ * - Untracked files (new files not in git)
479
+ *
480
+ * For directories, returns `true` if ANY file within the directory is staged.
481
+ *
482
+ * Symlinks in the pathname and cwd are automatically resolved using
483
+ * `fs.realpathSync()` before comparison.
484
+ *
485
+ * @param pathname - File or directory path to check.
486
+ * @param options - Options for the git diff check.
487
+ * @returns Promise resolving to `true` if path is staged, `false` otherwise.
488
+ *
489
+ * @example
490
+ * ```typescript
491
+ * // Check if file is staged
492
+ * const staged = await isStaged('src/foo.ts')
493
+ * // => false
494
+ *
495
+ * // Stage the file
496
+ * await spawn('git', ['add', 'src/foo.ts'])
497
+ * const staged = await isStaged('src/foo.ts')
498
+ * // => true
499
+ *
500
+ * // Check directory
501
+ * const staged = await isStaged('src/')
502
+ * // => true (if any file in src/ is staged)
503
+ * ```
88
504
  */
89
- export declare function isStaged(pathname: string, options?: GitDiffOptions): Promise<boolean>;
505
+ export declare function isStaged(pathname: string, options?: GitDiffOptions | undefined): Promise<boolean>;
90
506
  /**
91
- * Check if pathname is staged for commit.
507
+ * Check if a file or directory is staged for commit.
508
+ *
509
+ * Synchronous version of `isStaged()`. Checks if the given pathname has
510
+ * changes staged with `git add` that will be included in the next commit.
511
+ * Does NOT include:
512
+ * - Unstaged modifications (changes not added with `git add`)
513
+ * - Untracked files (new files not in git)
514
+ *
515
+ * For directories, returns `true` if ANY file within the directory is staged.
516
+ *
517
+ * Symlinks in the pathname and cwd are automatically resolved using
518
+ * `fs.realpathSync()` before comparison.
519
+ *
520
+ * @param pathname - File or directory path to check.
521
+ * @param options - Options for the git diff check.
522
+ * @returns `true` if path is staged, `false` otherwise.
523
+ *
524
+ * @example
525
+ * ```typescript
526
+ * // Check if file is staged
527
+ * const staged = isStagedSync('src/foo.ts')
528
+ * // => false
529
+ *
530
+ * // Stage the file
531
+ * spawnSync('git', ['add', 'src/foo.ts'])
532
+ * const staged = isStagedSync('src/foo.ts')
533
+ * // => true
534
+ *
535
+ * // Check directory
536
+ * const staged = isStagedSync('src/')
537
+ * // => true (if any file in src/ is staged)
538
+ * ```
92
539
  */
93
- export declare function isStagedSync(pathname: string, options?: GitDiffOptions): boolean;
540
+ export declare function isStagedSync(pathname: string, options?: GitDiffOptions | undefined): boolean;