type-git 0.2.0 → 0.3.0-alpha.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.
- package/README.md +38 -0
- package/dist/adapters/bun/index.cjs +10 -4
- package/dist/adapters/bun/index.cjs.map +1 -1
- package/dist/adapters/bun/index.d.cts +1 -1
- package/dist/adapters/bun/index.d.ts +1 -1
- package/dist/adapters/bun/index.js +10 -4
- package/dist/adapters/bun/index.js.map +1 -1
- package/dist/adapters/deno/index.cjs +10 -4
- package/dist/adapters/deno/index.cjs.map +1 -1
- package/dist/adapters/deno/index.d.cts +1 -1
- package/dist/adapters/deno/index.d.ts +1 -1
- package/dist/adapters/deno/index.js +10 -4
- package/dist/adapters/deno/index.js.map +1 -1
- package/dist/adapters/node/index.cjs +224 -32
- package/dist/adapters/node/index.cjs.map +1 -1
- package/dist/adapters/node/index.d.cts +23 -2
- package/dist/adapters/node/index.d.ts +23 -2
- package/dist/adapters/node/index.js +224 -32
- package/dist/adapters/node/index.js.map +1 -1
- package/dist/{adapters-BFRtEriX.d.cts → adapters-Bpuvmw9y.d.cts} +190 -1
- package/dist/{adapters-BFRtEriX.d.ts → adapters-Bpuvmw9y.d.ts} +190 -1
- package/dist/index.cjs +230 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +227 -33
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment variable inheritance control (environment variable traversal prevention)
|
|
3
|
+
*
|
|
4
|
+
* By default, type-git does NOT pass the entire parent process environment to the
|
|
5
|
+
* spawned Git subprocess. Leaking the full environment into Git (and from there into
|
|
6
|
+
* credential helpers, hooks, and LFS transfer agents) is an environment variable
|
|
7
|
+
* traversal risk: secrets such as cloud credentials or API tokens that live in the
|
|
8
|
+
* parent process can be exfiltrated by untrusted Git configuration or remote-controlled
|
|
9
|
+
* helpers.
|
|
10
|
+
*
|
|
11
|
+
* Instead, only a curated allowlist of variables that Git genuinely needs to operate is
|
|
12
|
+
* inherited. Callers can widen or replace this behavior via the `inheritEnv` option.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Controls how the parent process environment is inherited by spawned Git commands.
|
|
16
|
+
*
|
|
17
|
+
* - `undefined` (default): inherit only {@link DEFAULT_ENV_ALLOWLIST} — the variables
|
|
18
|
+
* Git needs to function. Sensitive variables are not passed through.
|
|
19
|
+
* - `true`: inherit the entire parent environment (legacy behavior, opt-in).
|
|
20
|
+
* - `false`: inherit nothing. The child only receives explicitly provided variables and
|
|
21
|
+
* values computed by the library (e.g. `HOME`, `PATH` prefixes). Note that this may
|
|
22
|
+
* break Git if `PATH` is not otherwise supplied.
|
|
23
|
+
* - `string[]`: inherit {@link DEFAULT_ENV_ALLOWLIST} plus the named variables. Use this
|
|
24
|
+
* to explicitly opt specific variables (e.g. an SSH command or a token) back in.
|
|
25
|
+
*/
|
|
26
|
+
type EnvInheritance = boolean | string[];
|
|
27
|
+
/**
|
|
28
|
+
* Curated allowlist of environment variables inherited by default.
|
|
29
|
+
*
|
|
30
|
+
* These are variables Git (and the tools it shells out to, such as ssh and credential
|
|
31
|
+
* helpers) commonly needs to operate. The list intentionally excludes arbitrary
|
|
32
|
+
* application secrets so they are not silently forwarded to Git subprocesses.
|
|
33
|
+
*
|
|
34
|
+
* Variable names are matched case-insensitively on Windows.
|
|
35
|
+
*/
|
|
36
|
+
declare const DEFAULT_ENV_ALLOWLIST: readonly string[];
|
|
37
|
+
/**
|
|
38
|
+
* Resolve the set of environment variables to inherit from the parent process.
|
|
39
|
+
*
|
|
40
|
+
* @param parentEnv - The parent process environment (e.g. `process.env`).
|
|
41
|
+
* @param inheritEnv - Inheritance policy. See {@link EnvInheritance}.
|
|
42
|
+
* @param platform - The runtime platform (e.g. `process.platform`). When `'win32'`,
|
|
43
|
+
* variable names are matched case-insensitively.
|
|
44
|
+
* @returns A record containing only the inherited variables (undefined values removed).
|
|
45
|
+
*/
|
|
46
|
+
declare function resolveInheritedEnv(parentEnv: Record<string, string | undefined>, inheritEnv?: EnvInheritance, platform?: string): Record<string, string>;
|
|
47
|
+
|
|
1
48
|
/**
|
|
2
49
|
* Core type definitions for the type-safe Git wrapper library
|
|
3
50
|
*
|
|
@@ -9,6 +56,7 @@
|
|
|
9
56
|
* - Output contracts for typed parsing
|
|
10
57
|
* - Branded types for type safety
|
|
11
58
|
*/
|
|
59
|
+
|
|
12
60
|
/**
|
|
13
61
|
* Brand symbol for NonEmptyString
|
|
14
62
|
* @internal
|
|
@@ -331,6 +379,15 @@ type GitOpenOptions = {
|
|
|
331
379
|
credentialHelper?: string;
|
|
332
380
|
/** Additional environment variables */
|
|
333
381
|
env?: Record<string, string>;
|
|
382
|
+
/**
|
|
383
|
+
* Controls how the parent process environment is inherited by spawned Git commands.
|
|
384
|
+
*
|
|
385
|
+
* By default, only a curated allowlist of variables that Git needs to operate is
|
|
386
|
+
* inherited (environment variable traversal prevention). Set to `true` to inherit the
|
|
387
|
+
* full parent environment, or provide an array of variable names to opt additional
|
|
388
|
+
* variables back in.
|
|
389
|
+
*/
|
|
390
|
+
inheritEnv?: EnvInheritance;
|
|
334
391
|
/** Directories to prepend to PATH */
|
|
335
392
|
pathPrefix?: string[];
|
|
336
393
|
/** Credential configuration (§6.4) */
|
|
@@ -378,6 +435,128 @@ type CredentialConfig = {
|
|
|
378
435
|
/** Callback when authentication fails */
|
|
379
436
|
onAuthFailure?: (error: Error, request: CredentialRequest) => void;
|
|
380
437
|
};
|
|
438
|
+
/**
|
|
439
|
+
* Audit event fired when a Git command starts execution
|
|
440
|
+
*/
|
|
441
|
+
type AuditEventStart = {
|
|
442
|
+
/** Event type discriminator */
|
|
443
|
+
type: 'start';
|
|
444
|
+
/** Timestamp in milliseconds since epoch */
|
|
445
|
+
timestamp: number;
|
|
446
|
+
/** Command arguments (e.g., ['git', '-C', '/path', 'status']) */
|
|
447
|
+
argv: string[];
|
|
448
|
+
/** Execution context (global, worktree, or bare) */
|
|
449
|
+
context: ExecutionContext;
|
|
450
|
+
};
|
|
451
|
+
/**
|
|
452
|
+
* Audit event fired when a Git command completes
|
|
453
|
+
*/
|
|
454
|
+
type AuditEventEnd = {
|
|
455
|
+
/** Event type discriminator */
|
|
456
|
+
type: 'end';
|
|
457
|
+
/** Timestamp in milliseconds since epoch */
|
|
458
|
+
timestamp: number;
|
|
459
|
+
/** Command arguments (same as start event) */
|
|
460
|
+
argv: string[];
|
|
461
|
+
/** Execution context (same as start event) */
|
|
462
|
+
context: ExecutionContext;
|
|
463
|
+
/** Standard output from the command */
|
|
464
|
+
stdout: string;
|
|
465
|
+
/** Standard error from the command */
|
|
466
|
+
stderr: string;
|
|
467
|
+
/** Exit code (0 = success) */
|
|
468
|
+
exitCode: number;
|
|
469
|
+
/** Whether command was aborted via AbortSignal */
|
|
470
|
+
aborted: boolean;
|
|
471
|
+
/** Duration in milliseconds */
|
|
472
|
+
duration: number;
|
|
473
|
+
};
|
|
474
|
+
/**
|
|
475
|
+
* Audit event for Git command execution lifecycle
|
|
476
|
+
*
|
|
477
|
+
* Discriminated union based on event type.
|
|
478
|
+
*
|
|
479
|
+
* @example
|
|
480
|
+
* ```typescript
|
|
481
|
+
* const git = await createGit({
|
|
482
|
+
* adapters: createNodeAdapters(),
|
|
483
|
+
* audit: {
|
|
484
|
+
* onAudit: (event) => {
|
|
485
|
+
* if (event.type === 'start') {
|
|
486
|
+
* console.log(`→ ${event.argv.join(' ')}`);
|
|
487
|
+
* } else {
|
|
488
|
+
* console.log(`✓ completed in ${event.duration}ms (exit ${event.exitCode})`);
|
|
489
|
+
* }
|
|
490
|
+
* }
|
|
491
|
+
* }
|
|
492
|
+
* });
|
|
493
|
+
* ```
|
|
494
|
+
*/
|
|
495
|
+
type AuditEvent = AuditEventStart | AuditEventEnd;
|
|
496
|
+
/**
|
|
497
|
+
* Trace output from GIT_TRACE environment variable
|
|
498
|
+
*
|
|
499
|
+
* Captures Git's internal debug output when GIT_TRACE is enabled.
|
|
500
|
+
* Automatically enabled when onTrace callback is provided.
|
|
501
|
+
*
|
|
502
|
+
* @example
|
|
503
|
+
* ```typescript
|
|
504
|
+
* const git = await createGit({
|
|
505
|
+
* adapters: createNodeAdapters(),
|
|
506
|
+
* audit: {
|
|
507
|
+
* onTrace: (trace) => {
|
|
508
|
+
* console.log(`[GIT_TRACE] ${trace.line}`);
|
|
509
|
+
* }
|
|
510
|
+
* }
|
|
511
|
+
* });
|
|
512
|
+
* ```
|
|
513
|
+
*/
|
|
514
|
+
type TraceEvent = {
|
|
515
|
+
/** Timestamp in milliseconds since epoch */
|
|
516
|
+
timestamp: number;
|
|
517
|
+
/** Raw trace output line from git stderr */
|
|
518
|
+
line: string;
|
|
519
|
+
};
|
|
520
|
+
/**
|
|
521
|
+
* Audit configuration for Git instance
|
|
522
|
+
*
|
|
523
|
+
* Provides hooks for observing Git command execution lifecycle
|
|
524
|
+
* and internal Git trace output.
|
|
525
|
+
*
|
|
526
|
+
* @example
|
|
527
|
+
* ```typescript
|
|
528
|
+
* const git = await createGit({
|
|
529
|
+
* adapters: createNodeAdapters(),
|
|
530
|
+
* audit: {
|
|
531
|
+
* onAudit: (event) => {
|
|
532
|
+
* if (event.type === 'start') {
|
|
533
|
+
* console.log(`[AUDIT] Starting: ${event.argv.join(' ')}`);
|
|
534
|
+
* } else {
|
|
535
|
+
* console.log(`[AUDIT] Completed: exit ${event.exitCode}, ${event.duration}ms`);
|
|
536
|
+
* }
|
|
537
|
+
* },
|
|
538
|
+
* onTrace: (trace) => {
|
|
539
|
+
* console.log(`[TRACE] ${trace.line}`);
|
|
540
|
+
* }
|
|
541
|
+
* }
|
|
542
|
+
* });
|
|
543
|
+
* ```
|
|
544
|
+
*/
|
|
545
|
+
type AuditConfig = {
|
|
546
|
+
/**
|
|
547
|
+
* Callback invoked for each Git command lifecycle event
|
|
548
|
+
*
|
|
549
|
+
* Receives 'start' event before command execution and 'end' event after.
|
|
550
|
+
*/
|
|
551
|
+
onAudit?: (event: AuditEvent) => void;
|
|
552
|
+
/**
|
|
553
|
+
* Callback invoked for GIT_TRACE output
|
|
554
|
+
*
|
|
555
|
+
* When provided, GIT_TRACE=1 is automatically set.
|
|
556
|
+
* Trace output is parsed from stderr lines.
|
|
557
|
+
*/
|
|
558
|
+
onTrace?: (trace: TraceEvent) => void;
|
|
559
|
+
};
|
|
381
560
|
|
|
382
561
|
/**
|
|
383
562
|
* Runtime adapter interfaces for cross-platform support (Node/Deno/Bun)
|
|
@@ -396,6 +575,16 @@ type SpawnOptions = {
|
|
|
396
575
|
argv: string[];
|
|
397
576
|
/** Additional environment variables */
|
|
398
577
|
env?: Record<string, string>;
|
|
578
|
+
/**
|
|
579
|
+
* Whether to merge the parent process environment underneath `env`.
|
|
580
|
+
*
|
|
581
|
+
* - `true` (default when omitted): the parent environment is merged underneath `env`,
|
|
582
|
+
* so the child inherits the full parent environment with `env` overrides on top.
|
|
583
|
+
* - `false`: the child receives only the variables in `env` (and nothing from the
|
|
584
|
+
* parent process). This prevents implicit environment variable traversal — used by
|
|
585
|
+
* {@link CliRunner}, which resolves the inherited variables itself.
|
|
586
|
+
*/
|
|
587
|
+
inheritEnv?: boolean;
|
|
399
588
|
/** Working directory */
|
|
400
589
|
cwd?: string;
|
|
401
590
|
/** AbortSignal for cancellation */
|
|
@@ -606,4 +795,4 @@ interface RuntimeAdapters {
|
|
|
606
795
|
*/
|
|
607
796
|
type AdapterFactory = () => RuntimeAdapters;
|
|
608
797
|
|
|
609
|
-
export { type
|
|
798
|
+
export { type AuditConfig as A, type TraceEvent as B, type Capabilities as C, DEFAULT_ENV_ALLOWLIST as D, type ExecAdapter as E, type FsAdapter as F, type GitErrorCategory as G, type LfsMode as L, type NonEmptyString as N, type OutputContract as O, type RuntimeAdapters as R, type SpawnOptions as S, type TailOptions as T, type StreamHandler as a, type SpawnResult as b, type SpawnHandle as c, type TailHandle as d, type ExecOpts as e, type RawResult as f, type GitProgress as g, type GitOpenOptions as h, type EnvInheritance as i, type ExecutionContext as j, GitError as k, type AdapterFactory as l, isNonEmpty as m, nonEmpty as n, type LfsProgress as o, type GitErrorKind as p, GitArgumentError as q, resolveInheritedEnv as r, type Runtime as s, type CommandSpec as t, type CredentialRequest as u, type Credential as v, type CredentialConfig as w, type AuditEventStart as x, type AuditEventEnd as y, type AuditEvent as z };
|
|
@@ -1,3 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment variable inheritance control (environment variable traversal prevention)
|
|
3
|
+
*
|
|
4
|
+
* By default, type-git does NOT pass the entire parent process environment to the
|
|
5
|
+
* spawned Git subprocess. Leaking the full environment into Git (and from there into
|
|
6
|
+
* credential helpers, hooks, and LFS transfer agents) is an environment variable
|
|
7
|
+
* traversal risk: secrets such as cloud credentials or API tokens that live in the
|
|
8
|
+
* parent process can be exfiltrated by untrusted Git configuration or remote-controlled
|
|
9
|
+
* helpers.
|
|
10
|
+
*
|
|
11
|
+
* Instead, only a curated allowlist of variables that Git genuinely needs to operate is
|
|
12
|
+
* inherited. Callers can widen or replace this behavior via the `inheritEnv` option.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Controls how the parent process environment is inherited by spawned Git commands.
|
|
16
|
+
*
|
|
17
|
+
* - `undefined` (default): inherit only {@link DEFAULT_ENV_ALLOWLIST} — the variables
|
|
18
|
+
* Git needs to function. Sensitive variables are not passed through.
|
|
19
|
+
* - `true`: inherit the entire parent environment (legacy behavior, opt-in).
|
|
20
|
+
* - `false`: inherit nothing. The child only receives explicitly provided variables and
|
|
21
|
+
* values computed by the library (e.g. `HOME`, `PATH` prefixes). Note that this may
|
|
22
|
+
* break Git if `PATH` is not otherwise supplied.
|
|
23
|
+
* - `string[]`: inherit {@link DEFAULT_ENV_ALLOWLIST} plus the named variables. Use this
|
|
24
|
+
* to explicitly opt specific variables (e.g. an SSH command or a token) back in.
|
|
25
|
+
*/
|
|
26
|
+
type EnvInheritance = boolean | string[];
|
|
27
|
+
/**
|
|
28
|
+
* Curated allowlist of environment variables inherited by default.
|
|
29
|
+
*
|
|
30
|
+
* These are variables Git (and the tools it shells out to, such as ssh and credential
|
|
31
|
+
* helpers) commonly needs to operate. The list intentionally excludes arbitrary
|
|
32
|
+
* application secrets so they are not silently forwarded to Git subprocesses.
|
|
33
|
+
*
|
|
34
|
+
* Variable names are matched case-insensitively on Windows.
|
|
35
|
+
*/
|
|
36
|
+
declare const DEFAULT_ENV_ALLOWLIST: readonly string[];
|
|
37
|
+
/**
|
|
38
|
+
* Resolve the set of environment variables to inherit from the parent process.
|
|
39
|
+
*
|
|
40
|
+
* @param parentEnv - The parent process environment (e.g. `process.env`).
|
|
41
|
+
* @param inheritEnv - Inheritance policy. See {@link EnvInheritance}.
|
|
42
|
+
* @param platform - The runtime platform (e.g. `process.platform`). When `'win32'`,
|
|
43
|
+
* variable names are matched case-insensitively.
|
|
44
|
+
* @returns A record containing only the inherited variables (undefined values removed).
|
|
45
|
+
*/
|
|
46
|
+
declare function resolveInheritedEnv(parentEnv: Record<string, string | undefined>, inheritEnv?: EnvInheritance, platform?: string): Record<string, string>;
|
|
47
|
+
|
|
1
48
|
/**
|
|
2
49
|
* Core type definitions for the type-safe Git wrapper library
|
|
3
50
|
*
|
|
@@ -9,6 +56,7 @@
|
|
|
9
56
|
* - Output contracts for typed parsing
|
|
10
57
|
* - Branded types for type safety
|
|
11
58
|
*/
|
|
59
|
+
|
|
12
60
|
/**
|
|
13
61
|
* Brand symbol for NonEmptyString
|
|
14
62
|
* @internal
|
|
@@ -331,6 +379,15 @@ type GitOpenOptions = {
|
|
|
331
379
|
credentialHelper?: string;
|
|
332
380
|
/** Additional environment variables */
|
|
333
381
|
env?: Record<string, string>;
|
|
382
|
+
/**
|
|
383
|
+
* Controls how the parent process environment is inherited by spawned Git commands.
|
|
384
|
+
*
|
|
385
|
+
* By default, only a curated allowlist of variables that Git needs to operate is
|
|
386
|
+
* inherited (environment variable traversal prevention). Set to `true` to inherit the
|
|
387
|
+
* full parent environment, or provide an array of variable names to opt additional
|
|
388
|
+
* variables back in.
|
|
389
|
+
*/
|
|
390
|
+
inheritEnv?: EnvInheritance;
|
|
334
391
|
/** Directories to prepend to PATH */
|
|
335
392
|
pathPrefix?: string[];
|
|
336
393
|
/** Credential configuration (§6.4) */
|
|
@@ -378,6 +435,128 @@ type CredentialConfig = {
|
|
|
378
435
|
/** Callback when authentication fails */
|
|
379
436
|
onAuthFailure?: (error: Error, request: CredentialRequest) => void;
|
|
380
437
|
};
|
|
438
|
+
/**
|
|
439
|
+
* Audit event fired when a Git command starts execution
|
|
440
|
+
*/
|
|
441
|
+
type AuditEventStart = {
|
|
442
|
+
/** Event type discriminator */
|
|
443
|
+
type: 'start';
|
|
444
|
+
/** Timestamp in milliseconds since epoch */
|
|
445
|
+
timestamp: number;
|
|
446
|
+
/** Command arguments (e.g., ['git', '-C', '/path', 'status']) */
|
|
447
|
+
argv: string[];
|
|
448
|
+
/** Execution context (global, worktree, or bare) */
|
|
449
|
+
context: ExecutionContext;
|
|
450
|
+
};
|
|
451
|
+
/**
|
|
452
|
+
* Audit event fired when a Git command completes
|
|
453
|
+
*/
|
|
454
|
+
type AuditEventEnd = {
|
|
455
|
+
/** Event type discriminator */
|
|
456
|
+
type: 'end';
|
|
457
|
+
/** Timestamp in milliseconds since epoch */
|
|
458
|
+
timestamp: number;
|
|
459
|
+
/** Command arguments (same as start event) */
|
|
460
|
+
argv: string[];
|
|
461
|
+
/** Execution context (same as start event) */
|
|
462
|
+
context: ExecutionContext;
|
|
463
|
+
/** Standard output from the command */
|
|
464
|
+
stdout: string;
|
|
465
|
+
/** Standard error from the command */
|
|
466
|
+
stderr: string;
|
|
467
|
+
/** Exit code (0 = success) */
|
|
468
|
+
exitCode: number;
|
|
469
|
+
/** Whether command was aborted via AbortSignal */
|
|
470
|
+
aborted: boolean;
|
|
471
|
+
/** Duration in milliseconds */
|
|
472
|
+
duration: number;
|
|
473
|
+
};
|
|
474
|
+
/**
|
|
475
|
+
* Audit event for Git command execution lifecycle
|
|
476
|
+
*
|
|
477
|
+
* Discriminated union based on event type.
|
|
478
|
+
*
|
|
479
|
+
* @example
|
|
480
|
+
* ```typescript
|
|
481
|
+
* const git = await createGit({
|
|
482
|
+
* adapters: createNodeAdapters(),
|
|
483
|
+
* audit: {
|
|
484
|
+
* onAudit: (event) => {
|
|
485
|
+
* if (event.type === 'start') {
|
|
486
|
+
* console.log(`→ ${event.argv.join(' ')}`);
|
|
487
|
+
* } else {
|
|
488
|
+
* console.log(`✓ completed in ${event.duration}ms (exit ${event.exitCode})`);
|
|
489
|
+
* }
|
|
490
|
+
* }
|
|
491
|
+
* }
|
|
492
|
+
* });
|
|
493
|
+
* ```
|
|
494
|
+
*/
|
|
495
|
+
type AuditEvent = AuditEventStart | AuditEventEnd;
|
|
496
|
+
/**
|
|
497
|
+
* Trace output from GIT_TRACE environment variable
|
|
498
|
+
*
|
|
499
|
+
* Captures Git's internal debug output when GIT_TRACE is enabled.
|
|
500
|
+
* Automatically enabled when onTrace callback is provided.
|
|
501
|
+
*
|
|
502
|
+
* @example
|
|
503
|
+
* ```typescript
|
|
504
|
+
* const git = await createGit({
|
|
505
|
+
* adapters: createNodeAdapters(),
|
|
506
|
+
* audit: {
|
|
507
|
+
* onTrace: (trace) => {
|
|
508
|
+
* console.log(`[GIT_TRACE] ${trace.line}`);
|
|
509
|
+
* }
|
|
510
|
+
* }
|
|
511
|
+
* });
|
|
512
|
+
* ```
|
|
513
|
+
*/
|
|
514
|
+
type TraceEvent = {
|
|
515
|
+
/** Timestamp in milliseconds since epoch */
|
|
516
|
+
timestamp: number;
|
|
517
|
+
/** Raw trace output line from git stderr */
|
|
518
|
+
line: string;
|
|
519
|
+
};
|
|
520
|
+
/**
|
|
521
|
+
* Audit configuration for Git instance
|
|
522
|
+
*
|
|
523
|
+
* Provides hooks for observing Git command execution lifecycle
|
|
524
|
+
* and internal Git trace output.
|
|
525
|
+
*
|
|
526
|
+
* @example
|
|
527
|
+
* ```typescript
|
|
528
|
+
* const git = await createGit({
|
|
529
|
+
* adapters: createNodeAdapters(),
|
|
530
|
+
* audit: {
|
|
531
|
+
* onAudit: (event) => {
|
|
532
|
+
* if (event.type === 'start') {
|
|
533
|
+
* console.log(`[AUDIT] Starting: ${event.argv.join(' ')}`);
|
|
534
|
+
* } else {
|
|
535
|
+
* console.log(`[AUDIT] Completed: exit ${event.exitCode}, ${event.duration}ms`);
|
|
536
|
+
* }
|
|
537
|
+
* },
|
|
538
|
+
* onTrace: (trace) => {
|
|
539
|
+
* console.log(`[TRACE] ${trace.line}`);
|
|
540
|
+
* }
|
|
541
|
+
* }
|
|
542
|
+
* });
|
|
543
|
+
* ```
|
|
544
|
+
*/
|
|
545
|
+
type AuditConfig = {
|
|
546
|
+
/**
|
|
547
|
+
* Callback invoked for each Git command lifecycle event
|
|
548
|
+
*
|
|
549
|
+
* Receives 'start' event before command execution and 'end' event after.
|
|
550
|
+
*/
|
|
551
|
+
onAudit?: (event: AuditEvent) => void;
|
|
552
|
+
/**
|
|
553
|
+
* Callback invoked for GIT_TRACE output
|
|
554
|
+
*
|
|
555
|
+
* When provided, GIT_TRACE=1 is automatically set.
|
|
556
|
+
* Trace output is parsed from stderr lines.
|
|
557
|
+
*/
|
|
558
|
+
onTrace?: (trace: TraceEvent) => void;
|
|
559
|
+
};
|
|
381
560
|
|
|
382
561
|
/**
|
|
383
562
|
* Runtime adapter interfaces for cross-platform support (Node/Deno/Bun)
|
|
@@ -396,6 +575,16 @@ type SpawnOptions = {
|
|
|
396
575
|
argv: string[];
|
|
397
576
|
/** Additional environment variables */
|
|
398
577
|
env?: Record<string, string>;
|
|
578
|
+
/**
|
|
579
|
+
* Whether to merge the parent process environment underneath `env`.
|
|
580
|
+
*
|
|
581
|
+
* - `true` (default when omitted): the parent environment is merged underneath `env`,
|
|
582
|
+
* so the child inherits the full parent environment with `env` overrides on top.
|
|
583
|
+
* - `false`: the child receives only the variables in `env` (and nothing from the
|
|
584
|
+
* parent process). This prevents implicit environment variable traversal — used by
|
|
585
|
+
* {@link CliRunner}, which resolves the inherited variables itself.
|
|
586
|
+
*/
|
|
587
|
+
inheritEnv?: boolean;
|
|
399
588
|
/** Working directory */
|
|
400
589
|
cwd?: string;
|
|
401
590
|
/** AbortSignal for cancellation */
|
|
@@ -606,4 +795,4 @@ interface RuntimeAdapters {
|
|
|
606
795
|
*/
|
|
607
796
|
type AdapterFactory = () => RuntimeAdapters;
|
|
608
797
|
|
|
609
|
-
export { type
|
|
798
|
+
export { type AuditConfig as A, type TraceEvent as B, type Capabilities as C, DEFAULT_ENV_ALLOWLIST as D, type ExecAdapter as E, type FsAdapter as F, type GitErrorCategory as G, type LfsMode as L, type NonEmptyString as N, type OutputContract as O, type RuntimeAdapters as R, type SpawnOptions as S, type TailOptions as T, type StreamHandler as a, type SpawnResult as b, type SpawnHandle as c, type TailHandle as d, type ExecOpts as e, type RawResult as f, type GitProgress as g, type GitOpenOptions as h, type EnvInheritance as i, type ExecutionContext as j, GitError as k, type AdapterFactory as l, isNonEmpty as m, nonEmpty as n, type LfsProgress as o, type GitErrorKind as p, GitArgumentError as q, resolveInheritedEnv as r, type Runtime as s, type CommandSpec as t, type CredentialRequest as u, type Credential as v, type CredentialConfig as w, type AuditEventStart as x, type AuditEventEnd as y, type AuditEvent as z };
|