Website Structure

This commit is contained in:
supalerk-ar66 2026-01-13 10:46:40 +07:00
parent 62812f2090
commit 71f0676a62
22365 changed files with 4265753 additions and 791 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,3 @@
{
"type": "module"
}

View file

@ -0,0 +1,13 @@
import { pathspec } from './args/pathspec';
import { GitConstructError } from './errors/git-construct-error';
import { GitError } from './errors/git-error';
import { GitPluginError } from './errors/git-plugin-error';
import { GitResponseError } from './errors/git-response-error';
import { TaskConfigurationError } from './errors/task-configuration-error';
import { CheckRepoActions } from './tasks/check-is-repo';
import { CleanOptions } from './tasks/clean';
import { GitConfigScope } from './tasks/config';
import { DiffNameStatus } from './tasks/diff-name-status';
import { grepQueryBuilder } from './tasks/grep';
import { ResetMode } from './tasks/reset';
export { CheckRepoActions, CleanOptions, DiffNameStatus, GitConfigScope, GitConstructError, GitError, GitPluginError, GitResponseError, ResetMode, TaskConfigurationError, grepQueryBuilder, pathspec, };

View file

@ -0,0 +1,9 @@
export declare enum LogFormat {
NONE = "",
STAT = "--stat",
NUM_STAT = "--numstat",
NAME_ONLY = "--name-only",
NAME_STATUS = "--name-status"
}
export declare function logFormatFromCommand(customArgs: string[]): LogFormat;
export declare function isLogFormat(customArg: string | unknown): boolean;

View file

@ -0,0 +1,3 @@
export declare function pathspec(...paths: string[]): string;
export declare function isPathSpec(path: string | unknown): path is string;
export declare function toPaths(pathSpec: string): string[];

View file

@ -0,0 +1,15 @@
import { GitError } from './git-error';
import { SimpleGitOptions } from '../types';
/**
* The `GitConstructError` is thrown when an error occurs in the constructor
* of the `simple-git` instance itself. Most commonly as a result of using
* a `baseDir` option that points to a folder that either does not exist,
* or cannot be read by the user the node script is running as.
*
* Check the `.message` property for more detail including the properties
* passed to the constructor.
*/
export declare class GitConstructError extends GitError {
readonly config: SimpleGitOptions;
constructor(config: SimpleGitOptions, message: string);
}

View file

@ -0,0 +1,30 @@
import type { SimpleGitTask } from '../types';
/**
* The `GitError` is thrown when the underlying `git` process throws a
* fatal exception (eg an `ENOENT` exception when attempting to use a
* non-writable directory as the root for your repo), and acts as the
* base class for more specific errors thrown by the parsing of the
* git response or errors in the configuration of the task about to
* be run.
*
* When an exception is thrown, pending tasks in the same instance will
* not be executed. The recommended way to run a series of tasks that
* can independently fail without needing to prevent future tasks from
* running is to catch them individually:
*
* ```typescript
import { gitP, SimpleGit, GitError, PullResult } from 'simple-git';
function catchTask (e: GitError) {
return e.
}
const git = gitP(repoWorkingDir);
const pulled: PullResult | GitError = await git.pull().catch(catchTask);
const pushed: string | GitError = await git.pushTags().catch(catchTask);
```
*/
export declare class GitError extends Error {
task?: SimpleGitTask<any> | undefined;
constructor(task?: SimpleGitTask<any> | undefined, message?: string);
}

View file

@ -0,0 +1,7 @@
import { SimpleGitOptions, SimpleGitTask } from '../types';
import { GitError } from './git-error';
export declare class GitPluginError extends GitError {
task?: SimpleGitTask<any> | undefined;
readonly plugin?: keyof SimpleGitOptions | undefined;
constructor(task?: SimpleGitTask<any> | undefined, plugin?: keyof SimpleGitOptions | undefined, message?: string);
}

View file

@ -0,0 +1,32 @@
import { GitError } from './git-error';
/**
* The `GitResponseError` is the wrapper for a parsed response that is treated as
* a fatal error, for example attempting a `merge` can leave the repo in a corrupted
* state when there are conflicts so the task will reject rather than resolve.
*
* For example, catching the merge conflict exception:
*
* ```typescript
import { gitP, SimpleGit, GitResponseError, MergeSummary } from 'simple-git';
const git = gitP(repoRoot);
const mergeOptions: string[] = ['--no-ff', 'other-branch'];
const mergeSummary: MergeSummary = await git.merge(mergeOptions)
.catch((e: GitResponseError<MergeSummary>) => e.git);
if (mergeSummary.failed) {
// deal with the error
}
```
*/
export declare class GitResponseError<T = any> extends GitError {
/**
* `.git` access the parsed response that is treated as being an error
*/
readonly git: T;
constructor(
/**
* `.git` access the parsed response that is treated as being an error
*/
git: T, message?: string);
}

View file

@ -0,0 +1,12 @@
import { GitError } from './git-error';
/**
* The `TaskConfigurationError` is thrown when a command was incorrectly
* configured. An error of this kind means that no attempt was made to
* run your command through the underlying `git` binary.
*
* Check the `.message` property for more detail on why your configuration
* resulted in an error.
*/
export declare class TaskConfigurationError extends GitError {
constructor(message?: string);
}

View file

@ -0,0 +1,15 @@
import { SimpleGitFactory } from '../../typings';
import * as api from './api';
import { SimpleGitOptions } from './types';
/**
* Adds the necessary properties to the supplied object to enable it for use as
* the default export of a module.
*
* Eg: `module.exports = esModuleFactory({ something () {} })`
*/
export declare function esModuleFactory<T>(defaultExport: T): T & {
__esModule: true;
default: T;
};
export declare function gitExportFactory(factory: SimpleGitFactory): SimpleGitFactory & typeof api;
export declare function gitInstanceFactory(baseDir?: string | Partial<SimpleGitOptions>, options?: Partial<SimpleGitOptions>): any;

View file

@ -0,0 +1,21 @@
import { Debugger } from 'debug';
type OutputLoggingHandler = (message: string, ...args: any[]) => void;
export interface OutputLogger extends OutputLoggingHandler {
readonly label: string;
info: OutputLoggingHandler;
step(nextStep?: string): OutputLogger;
sibling(name: string): OutputLogger;
}
export declare function createLogger(label: string, verbose?: string | Debugger, initialStep?: string, infoDebugger?: Debugger): OutputLogger;
/**
* The `GitLogger` is used by the main `SimpleGit` runner to handle logging
* any warnings or errors.
*/
export declare class GitLogger {
private _out;
error: OutputLoggingHandler;
warn: OutputLoggingHandler;
constructor(_out?: Debugger);
silent(silence?: boolean): void;
}
export {};

View file

@ -0,0 +1,5 @@
import { BranchMultiDeleteResult } from '../../../typings';
import { TaskParser } from '../types';
import { ExitCodes } from '../utils';
export declare const parseBranchDeletions: TaskParser<string, BranchMultiDeleteResult>;
export declare function hasBranchDeletionError(data: string, processExitCode: ExitCodes): boolean;

View file

@ -0,0 +1,2 @@
import type { BranchSummary } from '../../../typings';
export declare function parseBranchSummary(stdOut: string, currentOnly?: boolean): BranchSummary;

View file

@ -0,0 +1,2 @@
import { CommitResult } from '../../../typings';
export declare function parseCommitResult(stdOut: string): CommitResult;

View file

@ -0,0 +1,3 @@
import { LogFormat } from '../args/log-format';
import { DiffSummary } from '../responses/DiffSummary';
export declare function getDiffParser(format?: LogFormat): (stdOut: string) => DiffSummary;

View file

@ -0,0 +1,2 @@
import { FetchResult } from '../../../typings';
export declare function parseFetchResult(stdOut: string, stdErr: string): FetchResult;

View file

@ -0,0 +1,6 @@
import { LogResult } from '../../../typings';
import { LogFormat } from '../args/log-format';
export declare const START_BOUNDARY = "\u00F2\u00F2\u00F2\u00F2\u00F2\u00F2 ";
export declare const COMMIT_BOUNDARY = " \u00F2\u00F2";
export declare const SPLITTER = " \u00F2 ";
export declare function createListLogSummaryParser<T = any>(splitter?: string, fields?: string[], logFormat?: LogFormat): (stdOut: string) => LogResult<T>;

View file

@ -0,0 +1,11 @@
import { MergeDetail, MergeResult } from '../../../typings';
import { TaskParser } from '../types';
/**
* Parse the complete response from `git.merge`
*/
export declare const parseMergeResult: TaskParser<string, MergeResult>;
/**
* Parse the merge specific detail (ie: not the content also available in the pull detail) from `git.mnerge`
* @param stdOut
*/
export declare const parseMergeDetail: TaskParser<string, MergeDetail>;

View file

@ -0,0 +1,2 @@
import { MoveResult } from '../../../typings';
export declare function parseMoveResult(stdOut: string): MoveResult;

View file

@ -0,0 +1,6 @@
import { PullDetail, PullResult } from '../../../typings';
import { PullFailedSummary } from '../responses/PullSummary';
import { TaskParser } from '../types';
export declare const parsePullDetail: TaskParser<string, PullDetail>;
export declare const parsePullResult: TaskParser<string, PullResult>;
export declare function parsePullErrorResult(stdOut: string, stdErr: string): "" | PullFailedSummary;

View file

@ -0,0 +1,4 @@
import { PushDetail, PushResult } from '../../../typings';
import { TaskParser } from '../types';
export declare const parsePushResult: TaskParser<string, PushResult>;
export declare const parsePushDetail: TaskParser<string, PushDetail>;

View file

@ -0,0 +1,5 @@
import { RemoteMessageResult, RemoteMessages } from '../../../typings';
export declare function parseRemoteMessages<T extends RemoteMessages = RemoteMessages>(_stdOut: string, stdErr: string): RemoteMessageResult;
export declare class RemoteMessageSummary implements RemoteMessages {
readonly all: string[];
}

View file

@ -0,0 +1,3 @@
import { RemoteMessageResult, RemoteMessages } from '../../../typings';
import { RemoteLineParser } from '../utils';
export declare const remoteMessagesObjectParsers: RemoteLineParser<RemoteMessageResult<RemoteMessages>>[];

View file

@ -0,0 +1,3 @@
import { SimpleGitOptions } from '../types';
import { SimpleGitPlugin } from './simple-git-plugin';
export declare function abortPlugin(signal: SimpleGitOptions['abort']): (SimpleGitPlugin<"spawn.before"> | SimpleGitPlugin<"spawn.after">)[] | undefined;

View file

@ -0,0 +1,3 @@
import type { SimpleGitPlugin } from './simple-git-plugin';
import type { SimpleGitPluginConfig } from '../types';
export declare function blockUnsafeOperationsPlugin({ allowUnsafeProtocolOverride, allowUnsafePack, }?: SimpleGitPluginConfig['unsafe']): SimpleGitPlugin<'spawn.args'>;

View file

@ -0,0 +1,2 @@
import { SimpleGitPlugin } from './simple-git-plugin';
export declare function commandConfigPrefixingPlugin(configuration: string[]): SimpleGitPlugin<'spawn.args'>;

View file

@ -0,0 +1,3 @@
import { SimpleGitPluginConfig } from '../types';
import { SimpleGitPlugin } from './simple-git-plugin';
export declare function completionDetectionPlugin({ onClose, onExit, }?: SimpleGitPluginConfig['completion']): SimpleGitPlugin<'spawn.after'>;

View file

@ -0,0 +1,3 @@
import type { SimpleGitOptions } from '../types';
import { PluginStore } from './plugin-store';
export declare function customBinaryPlugin(plugins: PluginStore, input?: SimpleGitOptions['binary'], allowUnsafe?: boolean): void;

View file

@ -0,0 +1,7 @@
import { GitExecutorResult, SimpleGitPluginConfig } from '../types';
import { SimpleGitPlugin } from './simple-git-plugin';
type TaskResult = Omit<GitExecutorResult, 'rejection'>;
declare function isTaskError(result: TaskResult): boolean;
export declare function errorDetectionHandler(overwrite?: boolean, isError?: typeof isTaskError, errorMessage?: (result: TaskResult) => Buffer | Error): (error: Buffer | Error | undefined, result: TaskResult) => Error | Buffer<ArrayBufferLike> | undefined;
export declare function errorDetectionPlugin(config: SimpleGitPluginConfig['errors']): SimpleGitPlugin<'task.error'>;
export {};

View file

@ -0,0 +1,11 @@
export * from './abort-plugin';
export * from './block-unsafe-operations-plugin';
export * from './command-config-prefixing-plugin';
export * from './completion-detection.plugin';
export * from './custom-binary.plugin';
export * from './error-detection.plugin';
export * from './plugin-store';
export * from './progress-monitor-plugin';
export * from './simple-git-plugin';
export * from './spawn-options-plugin';
export * from './timout-plugin';

View file

@ -0,0 +1,11 @@
import type { SimpleGitPlugin, SimpleGitPluginType, SimpleGitPluginTypes } from './simple-git-plugin';
import type { SimpleGitPluginConfig } from '../types';
export declare class PluginStore {
private plugins;
private events;
on<K extends keyof SimpleGitPluginConfig>(type: K, listener: (data: SimpleGitPluginConfig[K]) => void): void;
reconfigure<K extends keyof SimpleGitPluginConfig>(type: K, data: SimpleGitPluginConfig[K]): void;
append<T extends SimpleGitPluginType>(type: T, action: SimpleGitPlugin<T>['action']): () => boolean;
add<T extends SimpleGitPluginType>(plugin: void | SimpleGitPlugin<T> | SimpleGitPlugin<T>[]): () => void;
exec<T extends SimpleGitPluginType>(type: T, data: SimpleGitPluginTypes[T]['data'], context: SimpleGitPluginTypes[T]['context']): typeof data;
}

View file

@ -0,0 +1,3 @@
import { SimpleGitOptions } from '../types';
import { SimpleGitPlugin } from './simple-git-plugin';
export declare function progressMonitorPlugin(progress: Exclude<SimpleGitOptions['progress'], void>): (SimpleGitPlugin<"spawn.after"> | SimpleGitPlugin<"spawn.args">)[];

View file

@ -0,0 +1,46 @@
import { ChildProcess, SpawnOptions } from 'child_process';
import { GitExecutorResult } from '../types';
type SimpleGitTaskPluginContext = {
readonly method: string;
readonly commands: string[];
};
export interface SimpleGitPluginTypes {
'spawn.args': {
data: string[];
context: SimpleGitTaskPluginContext & {};
};
'spawn.binary': {
data: string;
context: SimpleGitTaskPluginContext & {};
};
'spawn.options': {
data: Partial<SpawnOptions>;
context: SimpleGitTaskPluginContext & {};
};
'spawn.before': {
data: void;
context: SimpleGitTaskPluginContext & {
kill(reason: Error): void;
};
};
'spawn.after': {
data: void;
context: SimpleGitTaskPluginContext & {
spawned: ChildProcess;
close(exitCode: number, reason?: Error): void;
kill(reason: Error): void;
};
};
'task.error': {
data: {
error?: Error;
};
context: SimpleGitTaskPluginContext & GitExecutorResult;
};
}
export type SimpleGitPluginType = keyof SimpleGitPluginTypes;
export interface SimpleGitPlugin<T extends SimpleGitPluginType> {
action(data: SimpleGitPluginTypes[T]['data'], context: SimpleGitPluginTypes[T]['context']): typeof data;
type: T;
}
export {};

View file

@ -0,0 +1,3 @@
import { SpawnOptions } from 'child_process';
import { SimpleGitPlugin } from './simple-git-plugin';
export declare function spawnOptionsPlugin(spawnOptions: Partial<SpawnOptions>): SimpleGitPlugin<'spawn.options'>;

View file

@ -0,0 +1,2 @@
import { SimpleGitPlugin } from './simple-git-plugin';
export declare function suffixPathsPlugin(): SimpleGitPlugin<'spawn.args'>;

View file

@ -0,0 +1,3 @@
import type { SimpleGitPlugin } from './simple-git-plugin';
import type { SimpleGitOptions } from '../types';
export declare function timeoutPlugin({ block, stdErr, stdOut, }: Exclude<SimpleGitOptions['timeout'], undefined>): SimpleGitPlugin<'spawn.after'> | void;

View file

@ -0,0 +1,12 @@
import { BranchMultiDeleteResult, BranchSingleDeleteFailure, BranchSingleDeleteResult, BranchSingleDeleteSuccess } from '../../../typings';
export declare class BranchDeletionBatch implements BranchMultiDeleteResult {
all: BranchSingleDeleteResult[];
branches: {
[branchName: string]: BranchSingleDeleteResult;
};
errors: BranchSingleDeleteResult[];
get success(): boolean;
}
export declare function branchDeletionSuccess(branch: string, hash: string): BranchSingleDeleteSuccess;
export declare function branchDeletionFailure(branch: string): BranchSingleDeleteFailure;
export declare function isSingleBranchDeleteFailure(test: BranchSingleDeleteResult): test is BranchSingleDeleteSuccess;

View file

@ -0,0 +1,14 @@
import type { BranchSummary, BranchSummaryBranch } from '../../../typings';
export declare enum BranchStatusIdentifier {
CURRENT = "*",
LINKED = "+"
}
export declare class BranchSummaryResult implements BranchSummary {
all: string[];
branches: {
[p: string]: BranchSummaryBranch;
};
current: string;
detached: boolean;
push(status: BranchStatusIdentifier | unknown, detached: boolean, name: string, commit: string, label: string): void;
}

View file

@ -0,0 +1,4 @@
/**
* Parser for the `check-ignore` command - returns each file as a string array
*/
export declare const parseCheckIgnore: (text: string) => string[];

View file

@ -0,0 +1,9 @@
import { CleanSummary } from '../../../typings';
export declare class CleanResponse implements CleanSummary {
readonly dryRun: boolean;
paths: string[];
files: string[];
folders: string[];
constructor(dryRun: boolean);
}
export declare function cleanSummaryParser(dryRun: boolean, text: string): CleanSummary;

View file

@ -0,0 +1,13 @@
import { ConfigGetResult, ConfigListSummary, ConfigValues } from '../../../typings';
export declare class ConfigList implements ConfigListSummary {
files: string[];
values: {
[fileName: string]: ConfigValues;
};
private _all;
get all(): ConfigValues;
addFile(file: string): ConfigValues;
addValue(file: string, key: string, value: string): void;
}
export declare function configListParser(text: string): ConfigList;
export declare function configGetParser(text: string, key: string): ConfigGetResult;

View file

@ -0,0 +1,10 @@
import { DiffResult, DiffResultBinaryFile, DiffResultTextFile } from '../../../typings';
/***
* The DiffSummary is returned as a response to getting `git().status()`
*/
export declare class DiffSummary implements DiffResult {
changed: number;
deletions: number;
insertions: number;
files: Array<DiffResultTextFile | DiffResultBinaryFile>;
}

View file

@ -0,0 +1,9 @@
import { FileStatusResult } from '../../../typings';
export declare const fromPathRegex: RegExp;
export declare class FileStatusSummary implements FileStatusResult {
path: string;
index: string;
working_dir: string;
readonly from: string | undefined;
constructor(path: string, index: string, working_dir: string);
}

View file

@ -0,0 +1,11 @@
export interface RemoteWithoutRefs {
name: string;
}
export interface RemoteWithRefs extends RemoteWithoutRefs {
refs: {
fetch: string;
push: string;
};
}
export declare function parseGetRemotes(text: string): RemoteWithoutRefs[];
export declare function parseGetRemotesVerbose(text: string): RemoteWithRefs[];

View file

@ -0,0 +1,9 @@
import { InitResult } from '../../../typings';
export declare class InitSummary implements InitResult {
readonly bare: boolean;
readonly path: string;
readonly existing: boolean;
readonly gitDir: string;
constructor(bare: boolean, path: string, existing: boolean, gitDir: string);
}
export declare function parseInit(bare: boolean, path: string, text: string): InitSummary;

View file

@ -0,0 +1,16 @@
import { MergeConflict, MergeConflictDeletion, MergeDetail, MergeResultStatus } from '../../../typings';
export declare class MergeSummaryConflict implements MergeConflict {
readonly reason: string;
readonly file: string | null;
readonly meta?: MergeConflictDeletion | undefined;
constructor(reason: string, file?: string | null, meta?: MergeConflictDeletion | undefined);
toString(): string;
}
export declare class MergeSummaryDetail implements MergeDetail {
conflicts: MergeConflict[];
merges: string[];
result: MergeResultStatus;
get failed(): boolean;
get reason(): string;
toString(): string;
}

View file

@ -0,0 +1,25 @@
import { PullDetailFileChanges, PullDetailSummary, PullFailedResult, PullResult } from '../../../typings';
export declare class PullSummary implements PullResult {
remoteMessages: {
all: never[];
};
created: never[];
deleted: string[];
files: string[];
deletions: PullDetailFileChanges;
insertions: PullDetailFileChanges;
summary: PullDetailSummary;
}
export declare class PullFailedSummary implements PullFailedResult {
remote: string;
hash: {
local: string;
remote: string;
};
branch: {
local: string;
remote: string;
};
message: string;
toString(): string;
}

View file

@ -0,0 +1,19 @@
import { StatusResult } from '../../../typings';
export declare class StatusSummary implements StatusResult {
not_added: never[];
conflicted: never[];
created: never[];
deleted: never[];
ignored: undefined;
modified: never[];
renamed: never[];
files: never[];
staged: never[];
ahead: number;
behind: number;
current: null;
tracking: null;
detached: boolean;
isClean: () => boolean;
}
export declare const parseStatusSummary: (text: string) => StatusResult;

View file

@ -0,0 +1,7 @@
import { TagResult } from '../../../typings';
export declare class TagList implements TagResult {
readonly all: string[];
readonly latest: string | undefined;
constructor(all: string[], latest: string | undefined);
}
export declare const parseTagList: (data: string, customSort?: boolean) => TagList;

View file

@ -0,0 +1,25 @@
import { PluginStore } from '../plugins';
import { outputHandler, SimpleGitExecutor, SimpleGitTask } from '../types';
import { Scheduler } from './scheduler';
export declare class GitExecutorChain implements SimpleGitExecutor {
private _executor;
private _scheduler;
private _plugins;
private _chain;
private _queue;
private _cwd;
get cwd(): string;
set cwd(cwd: string);
get env(): import("../types").GitExecutorEnv;
get outputHandler(): outputHandler | undefined;
constructor(_executor: SimpleGitExecutor, _scheduler: Scheduler, _plugins: PluginStore);
chain(): this;
push<R>(task: SimpleGitTask<R>): Promise<R>;
private attemptTask;
private onFatalException;
private attemptRemoteTask;
private attemptEmptyTask;
private handleTaskData;
private gitResponse;
private _beforeSpawn;
}

View file

@ -0,0 +1,14 @@
import type { PluginStore } from '../plugins';
import type { GitExecutorEnv, outputHandler, SimpleGitExecutor, SimpleGitTask } from '../types';
import { Scheduler } from './scheduler';
export declare class GitExecutor implements SimpleGitExecutor {
cwd: string;
private _scheduler;
private _plugins;
private _chain;
env: GitExecutorEnv;
outputHandler?: outputHandler;
constructor(cwd: string, _scheduler: Scheduler, _plugins: PluginStore);
chain(): SimpleGitExecutor;
push<R>(task: SimpleGitTask<R>): Promise<R>;
}

View file

@ -0,0 +1,2 @@
import { SimpleGit, SimpleGitOptions } from '../../../typings';
export declare function gitP(...args: [] | [string] | [Partial<SimpleGitOptions>] | [string, Partial<SimpleGitOptions>]): SimpleGit;

View file

@ -0,0 +1,11 @@
type ScheduleCompleteCallback = () => void;
export declare class Scheduler {
private concurrency;
private logger;
private pending;
private running;
constructor(concurrency?: number);
private schedule;
next(): Promise<ScheduleCompleteCallback>;
}
export {};

View file

@ -0,0 +1,23 @@
import { SimpleGitTask } from '../types';
import { GitError } from '../errors/git-error';
import { OutputLogger } from '../git-logger';
type AnySimpleGitTask = SimpleGitTask<any>;
type TaskInProgress = {
name: string;
logger: OutputLogger;
task: AnySimpleGitTask;
};
export declare class TasksPendingQueue {
private logLabel;
private _queue;
constructor(logLabel?: string);
private withProgress;
private createProgress;
push(task: AnySimpleGitTask): TaskInProgress;
fatal(err: GitError): void;
complete(task: AnySimpleGitTask): void;
attempt(task: AnySimpleGitTask): TaskInProgress;
static getName(name?: string): string;
private static counter;
}
export {};

View file

@ -0,0 +1,20 @@
import { SimpleGitBase } from '../../typings';
import { outputHandler, SimpleGitExecutor, SimpleGitTask, SimpleGitTaskCallback } from './types';
export declare class SimpleGitApi implements SimpleGitBase {
private _executor;
constructor(_executor: SimpleGitExecutor);
protected _runTask<T>(task: SimpleGitTask<T>, then?: SimpleGitTaskCallback<T>): any;
add(files: string | string[]): any;
cwd(directory: string | {
path: string;
root?: boolean;
}): any;
hashObject(path: string, write: boolean | unknown): any;
init(bare?: boolean | unknown): any;
merge(): any;
mergeFromTo(remote: string, branch: string): any;
outputHandler(handler: outputHandler): this;
push(): any;
stash(): any;
status(): any;
}

View file

@ -0,0 +1,2 @@
import { SimpleGitTask, SimpleGitTaskCallback } from './types';
export declare function taskCallback<R>(task: SimpleGitTask<R>, response: Promise<R>, callback?: SimpleGitTaskCallback<R>): void;

View file

@ -0,0 +1,3 @@
import { OptionFlags, Options, StringTask } from '../types';
export type ApplyOptions = Options & OptionFlags<'--stat' | '--numstat' | '--summary' | '--check' | '--index' | '--intent-to-add' | '--3way' | '--apply' | '--no-add' | '-R' | '--reverse' | '--allow-binary-replacement' | '--binary' | '--reject' | '-z' | '--inaccurate-eof' | '--recount' | '--cached' | '--ignore-space-change' | '--ignore-whitespace' | '--verbose' | '--unsafe-paths'> & OptionFlags<'--whitespace', 'nowarn' | 'warn' | 'fix' | 'error' | 'error-all'> & OptionFlags<'--build-fake-ancestor' | '--exclude' | '--include' | '--directory', string> & OptionFlags<'-p' | '-C', number>;
export declare function applyPatchTask(patches: string[], customArgs: string[]): StringTask<string>;

View file

@ -0,0 +1,7 @@
import { BranchMultiDeleteResult, BranchSingleDeleteResult, BranchSummary } from '../../../typings';
import { StringTask } from '../types';
export declare function containsDeleteBranchCommand(commands: string[]): boolean;
export declare function branchTask(customArgs: string[]): StringTask<BranchSummary | BranchSingleDeleteResult>;
export declare function branchLocalTask(): StringTask<BranchSummary>;
export declare function deleteBranchesTask(branches: string[], forceDelete?: boolean): StringTask<BranchMultiDeleteResult>;
export declare function deleteBranchTask(branch: string, forceDelete?: boolean): StringTask<BranchSingleDeleteResult>;

View file

@ -0,0 +1,2 @@
import { SimpleGitExecutor } from '../types';
export declare function changeWorkingDirectoryTask(directory: string, root?: SimpleGitExecutor): import("./task").EmptyTask;

View file

@ -0,0 +1,2 @@
import { StringTask } from '../types';
export declare function checkIgnoreTask(paths: string[]): StringTask<string[]>;

View file

@ -0,0 +1,9 @@
import { Maybe, StringTask } from '../types';
export declare enum CheckRepoActions {
BARE = "bare",
IN_TREE = "tree",
IS_REPO_ROOT = "root"
}
export declare function checkIsRepoTask(action: Maybe<CheckRepoActions>): StringTask<boolean>;
export declare function checkIsRepoRootTask(): StringTask<boolean>;
export declare function checkIsBareRepoTask(): StringTask<boolean>;

View file

@ -0,0 +1,2 @@
import type { SimpleGit } from '../../../typings';
export default function (): Pick<SimpleGit, 'checkout' | 'checkoutBranch' | 'checkoutLocalBranch'>;

View file

@ -0,0 +1,25 @@
import { CleanSummary } from '../../../typings';
import { StringTask } from '../types';
export declare const CONFIG_ERROR_INTERACTIVE_MODE = "Git clean interactive mode is not supported";
export declare const CONFIG_ERROR_MODE_REQUIRED = "Git clean mode parameter (\"n\" or \"f\") is required";
export declare const CONFIG_ERROR_UNKNOWN_OPTION = "Git clean unknown option found in: ";
/**
* All supported option switches available for use in a `git.clean` operation
*/
export declare enum CleanOptions {
DRY_RUN = "n",
FORCE = "f",
IGNORED_INCLUDED = "x",
IGNORED_ONLY = "X",
EXCLUDING = "e",
QUIET = "q",
RECURSIVE = "d"
}
/**
* The two modes `git.clean` can run in - one of these must be supplied in order
* for the command to not throw a `TaskConfigurationError`
*/
export type CleanMode = CleanOptions.FORCE | CleanOptions.DRY_RUN;
export declare function cleanWithOptionsTask(mode: CleanMode | string, customArgs: string[]): import("./task").EmptyTask | StringTask<CleanSummary>;
export declare function cleanTask(mode: CleanMode, customArgs: string[]): StringTask<CleanSummary>;
export declare function isCleanOptionsArray(input: string[]): input is CleanOptions[];

View file

@ -0,0 +1,5 @@
import { EmptyTask } from './task';
import { OptionFlags, Options, StringTask } from '../types';
export type CloneOptions = Options & OptionFlags<'--bare' | '--dissociate' | '--mirror' | '--no-checkout' | '--no-remote-submodules' | '--no-shallow-submodules' | '--no-single-branch' | '--no-tags' | '--remote-submodules' | '--single-branch' | '--shallow-submodules' | '--verbose'> & OptionFlags<'--depth' | '-j' | '--jobs', number> & OptionFlags<'--branch' | '--origin' | '--recurse-submodules' | '--separate-git-dir' | '--shallow-exclude' | '--shallow-since' | '--template', string>;
export declare function cloneTask(repo: string | undefined, directory: string | undefined, customArgs: string[]): StringTask<string> | EmptyTask;
export declare function cloneMirrorTask(repo: string | undefined, directory: string | undefined, customArgs: string[]): EmptyTask | StringTask<string>;

View file

@ -0,0 +1,4 @@
import type { CommitResult, SimpleGit } from '../../../typings';
import type { StringTask } from '../types';
export declare function commitTask(message: string[], files: string[], customArgs: string[]): StringTask<CommitResult>;
export default function (): Pick<SimpleGit, 'commit'>;

View file

@ -0,0 +1,8 @@
import type { SimpleGit } from '../../../typings';
export declare enum GitConfigScope {
system = "system",
global = "global",
local = "local",
worktree = "worktree"
}
export default function (): Pick<SimpleGit, 'addConfig' | 'getConfig' | 'listConfig'>;

View file

@ -0,0 +1,12 @@
import type { SimpleGit } from '../../../typings';
export interface CountObjectsResult {
count: number;
size: number;
inPack: number;
packs: number;
sizePack: number;
prunePackable: number;
garbage: number;
sizeGarbage: number;
}
export default function (): Pick<SimpleGit, 'countObjects'>;

View file

@ -0,0 +1,12 @@
export declare enum DiffNameStatus {
ADDED = "A",
COPIED = "C",
DELETED = "D",
MODIFIED = "M",
RENAMED = "R",
CHANGED = "T",
UNMERGED = "U",
UNKNOWN = "X",
BROKEN = "B"
}
export declare function isDiffNameStatus(input: string): input is DiffNameStatus;

View file

@ -0,0 +1,5 @@
import { StringTask } from '../types';
import { DiffResult } from '../../../typings';
import { EmptyTask } from './task';
export declare function diffSummaryTask(customArgs: string[]): StringTask<DiffResult> | EmptyTask;
export declare function validateLogFormatConfig(customArgs: unknown[]): EmptyTask | void;

View file

@ -0,0 +1,4 @@
import { FetchResult } from '../../../typings';
import { StringTask } from '../types';
import { EmptyTask } from './task';
export declare function fetchTask(remote: string, branch: string, customArgs: string[]): StringTask<FetchResult> | EmptyTask;

View file

@ -0,0 +1,2 @@
import { SimpleGit } from '../../../typings';
export default function (): Pick<SimpleGit, 'firstCommit'>;

View file

@ -0,0 +1,12 @@
import { SimpleGit } from '../../../typings';
export interface GitGrepQuery extends Iterable<string> {
/** Adds one or more terms to be grouped as an "and" to any other terms */
and(...and: string[]): this;
/** Adds one or more search terms - git.grep will "or" this to other terms */
param(...param: string[]): this;
}
/**
* Creates a new builder for a `git.grep` query with optional params
*/
export declare function grepQueryBuilder(...params: string[]): GitGrepQuery;
export default function (): Pick<SimpleGit, 'grep'>;

View file

@ -0,0 +1,5 @@
import { StringTask } from '../types';
/**
* Task used by `git.hashObject`
*/
export declare function hashObjectTask(filePath: string, write: boolean): StringTask<string>;

View file

@ -0,0 +1,3 @@
import { InitResult } from '../../../typings';
import { StringTask } from '../types';
export declare function initTask(bare: boolean | undefined, path: string, customArgs: string[]): StringTask<InitResult>;

View file

@ -0,0 +1,32 @@
import type { LogResult, Options, SimpleGit } from '../../../typings';
import { StringTask } from '../types';
export interface DefaultLogFields {
hash: string;
date: string;
message: string;
refs: string;
body: string;
author_name: string;
author_email: string;
}
export type LogOptions<T = DefaultLogFields> = {
file?: string;
format?: T;
from?: string;
mailMap?: boolean;
maxCount?: number;
multiLine?: boolean;
splitter?: string;
strictDate?: boolean;
symmetric?: boolean;
to?: string;
};
interface ParsedLogOptions {
fields: string[];
splitter: string;
commands: string[];
}
export declare function parseLogOptions<T extends Options>(opt?: Options | LogOptions<T>, customArgs?: string[]): ParsedLogOptions;
export declare function logTask<T>(splitter: string, fields: string[], customArgs: string[]): StringTask<LogResult<T>>;
export default function (): Pick<SimpleGit, 'log'>;
export {};

View file

@ -0,0 +1,4 @@
import { MergeResult } from '../../../typings';
import { StringTask } from '../types';
import { EmptyTask } from './task';
export declare function mergeTask(customArgs: string[]): EmptyTask | StringTask<MergeResult>;

View file

@ -0,0 +1,3 @@
import { MoveResult } from '../../../typings';
import { StringTask } from '../types';
export declare function moveTask(from: string | string[], to: string): StringTask<MoveResult>;

View file

@ -0,0 +1,3 @@
import { PullResult } from '../../../typings';
import { Maybe, StringTask } from '../types';
export declare function pullTask(remote: Maybe<string>, branch: Maybe<string>, customArgs: string[]): StringTask<PullResult>;

View file

@ -0,0 +1,9 @@
import { PushResult } from '../../../typings';
import { StringTask } from '../types';
type PushRef = {
remote?: string;
branch?: string;
};
export declare function pushTagsTask(ref: PushRef | undefined, customArgs: string[]): StringTask<PushResult>;
export declare function pushTask(ref: PushRef | undefined, customArgs: string[]): StringTask<PushResult>;
export {};

View file

@ -0,0 +1,8 @@
import { type RemoteWithoutRefs, type RemoteWithRefs } from '../responses/GetRemoteSummary';
import type { StringTask } from '../types';
export declare function addRemoteTask(remoteName: string, remoteRepo: string, customArgs: string[]): StringTask<string>;
export declare function getRemotesTask(verbose: true): StringTask<RemoteWithRefs[]>;
export declare function getRemotesTask(verbose: false): StringTask<RemoteWithoutRefs[]>;
export declare function listRemotesTask(customArgs: string[]): StringTask<string>;
export declare function remoteTask(customArgs: string[]): StringTask<string>;
export declare function removeRemoteTask(remoteName: string): StringTask<string>;

View file

@ -0,0 +1,11 @@
import type { Maybe, OptionFlags, Options } from '../types';
export declare enum ResetMode {
MIXED = "mixed",
SOFT = "soft",
HARD = "hard",
MERGE = "merge",
KEEP = "keep"
}
export type ResetOptions = Options & OptionFlags<'-q' | '--quiet' | '--no-quiet' | '--pathspec-from-nul'> & OptionFlags<'--pathspec-from-file', string>;
export declare function resetTask(mode: Maybe<ResetMode>, customArgs: string[]): import("../types").StringTask<string>;
export declare function getResetMode(mode: ResetMode | unknown): Maybe<ResetMode>;

View file

@ -0,0 +1,2 @@
import { SimpleGit } from '../../../typings';
export default function (): Pick<SimpleGit, 'showBuffer' | 'show'>;

View file

@ -0,0 +1,4 @@
import { LogOptions, LogResult } from '../../../typings';
import type { StringTask } from '../types';
import type { EmptyTask } from './task';
export declare function stashListTask(opt: LogOptions | undefined, customArgs: string[]): EmptyTask | StringTask<LogResult>;

View file

@ -0,0 +1,3 @@
import { StatusResult } from '../../../typings';
import { StringTask } from '../types';
export declare function statusTask(customArgs: string[]): StringTask<StatusResult>;

View file

@ -0,0 +1,5 @@
import { StringTask } from '../types';
export declare function addSubModuleTask(repo: string, path: string): StringTask<string>;
export declare function initSubModuleTask(customArgs: string[]): StringTask<string>;
export declare function subModuleTask(customArgs: string[]): StringTask<string>;
export declare function updateSubModuleTask(customArgs: string[]): StringTask<string>;

View file

@ -0,0 +1,18 @@
import { TagResult } from '../../../typings';
import { StringTask } from '../types';
/**
* Task used by `git.tags`
*/
export declare function tagListTask(customArgs?: string[]): StringTask<TagResult>;
/**
* Task used by `git.addTag`
*/
export declare function addTagTask(name: string): StringTask<{
name: string;
}>;
/**
* Task used by `git.addTag`
*/
export declare function addAnnotatedTagTask(name: string, tagMessage: string): StringTask<{
name: string;
}>;

View file

@ -0,0 +1,14 @@
import type { BufferTask, EmptyTaskParser, SimpleGitTask, StringTask } from '../types';
export declare const EMPTY_COMMANDS: [];
export type EmptyTask = {
commands: typeof EMPTY_COMMANDS;
format: 'empty';
parser: EmptyTaskParser;
onError?: undefined;
};
export declare function adhocExecTask(parser: EmptyTaskParser): EmptyTask;
export declare function configurationErrorTask(error: Error | string): EmptyTask;
export declare function straightThroughStringTask(commands: string[], trimmed?: boolean): StringTask<string>;
export declare function straightThroughBufferTask(commands: string[]): BufferTask<Buffer>;
export declare function isBufferTask<R>(task: SimpleGitTask<R>): task is BufferTask<R>;
export declare function isEmptyTask<R>(task: SimpleGitTask<R>): task is EmptyTask;

View file

@ -0,0 +1,9 @@
import type { SimpleGit } from '../../../typings';
export interface VersionResult {
major: number;
minor: number;
patch: number | string;
agent: string;
installed: boolean;
}
export default function (): Pick<SimpleGit, 'version'>;

View file

@ -0,0 +1,21 @@
import { GitError } from '../errors/git-error';
/**
* The node-style callback to a task accepts either two arguments with the first as a null
* and the second as the data, or just one argument which is an error.
*/
export type SimpleGitTaskCallback<T = string, E extends GitError = GitError> = (err: E | null, data: T) => void;
/**
* The event data emitted to the progress handler whenever progress detail is received.
*/
export interface SimpleGitProgressEvent {
/** The underlying method called - push, pull etc */
method: string;
/** The type of progress being reported, note that any one task may emit many stages - for example `git clone` emits both `receiving` and `resolving` */
stage: 'compressing' | 'counting' | 'receiving' | 'resolving' | 'unknown' | 'writing' | string;
/** The percent progressed as a number 0 - 100 */
progress: number;
/** The number of items processed so far */
processed: number;
/** The total number of items to be processed */
total: number;
}

View file

@ -0,0 +1,154 @@
import type { SpawnOptions } from 'child_process';
import type { SimpleGitTask } from './tasks';
import type { SimpleGitProgressEvent } from './handlers';
export * from './handlers';
export * from './tasks';
/**
* Most tasks accept custom options as an array of strings as well as the
* options object. Unless the task is explicitly documented as such, the
* tasks will not accept both formats at the same time, preferring whichever
* appears last in the arguments.
*/
export type TaskOptions<O extends Options = Options> = string[] | O;
/**
* Options supplied in most tasks as an optional trailing object
*/
export type OptionsValues = null | string | number | (string | number)[];
export type Options = Record<string, OptionsValues>;
export type OptionFlags<FLAGS extends string, VALUE = null> = Partial<Record<FLAGS, VALUE>>;
/**
* A function called by the executor immediately after creating a child
* process. Allows the calling application to implement custom handling of
* the incoming stream of data from the `git`.
*/
export type outputHandler = (command: string, stdout: NodeJS.ReadableStream, stderr: NodeJS.ReadableStream, args: string[]) => void;
/**
* Environment variables to be passed into the child process.
*/
export type GitExecutorEnv = NodeJS.ProcessEnv | undefined;
/**
* Public interface of the Executor
*/
export interface SimpleGitExecutor {
env: GitExecutorEnv;
outputHandler?: outputHandler;
cwd: string;
chain(): SimpleGitExecutor;
push<R>(task: SimpleGitTask<R>): Promise<R>;
}
/**
* The resulting output from running the git child process
*/
export interface GitExecutorResult {
stdOut: Buffer[];
stdErr: Buffer[];
exitCode: number;
rejection: Maybe<Error>;
}
export interface SimpleGitPluginConfig {
abort: AbortSignal;
/**
* Name of the binary the child processes will spawn - defaults to `git`,
* supply as a tuple to enable the use of platforms that require `git` to be
* called through an alternative binary (eg: `wsl git ...`).
* Note: commands supplied in this way support a restricted set of characters
* and should not be used as a way to supply arbitrary config arguments etc.
*/
binary: string | [string] | [string, string];
/**
* Configures the events that should be used to determine when the unederlying child process has
* been terminated.
*
* Version 2 will default to use `onClose=true, onExit=50` to mean the `close` event will be
* used to immediately treat the child process as closed and start using the data from `stdOut`
* / `stdErr`, whereas the `exit` event will wait `50ms` before treating the child process
* as closed.
*
* This will be changed in version 3 to use `onClose=true, onExit=false` so that only the
* close event is used to determine the termination of the process.
*/
completion: {
onClose?: boolean | number;
onExit?: boolean | number;
};
/**
* Configures the content of errors thrown by the `simple-git` instance for each task
*/
errors(error: Buffer | Error | undefined, result: Omit<GitExecutorResult, 'rejection'>): Buffer | Error | undefined;
/**
* Handler to be called with progress events emitted through the progress plugin
*/
progress(data: SimpleGitProgressEvent): void;
/**
* Configuration for the `timeoutPlugin`
*/
timeout: {
/**
* The number of milliseconds to wait after spawning the process / receiving
* content on the stdOut/stdErr streams before forcibly closing the git process.
*/
block: number;
/**
* Reset timeout plugin after receiving data on `stdErr` - set to `false` to ignore
* `stdErr` content when determining whether to kill the process (defaults to `true`).
*/
stdErr?: boolean;
/**
* Reset timeout plugin after receiving data on `stdOut` - set to `false` to ignore
* `stdOut` content when determining whether to kill the process (defaults to `true`).
*/
stdOut?: boolean;
};
spawnOptions: Pick<SpawnOptions, 'uid' | 'gid'>;
unsafe: {
/**
* Allows potentially unsafe values to be supplied in the `binary` configuration option and
* `git.customBinary()` method call.
*/
allowUnsafeCustomBinary?: boolean;
/**
* By default `simple-git` prevents the use of inline configuration
* options to override the protocols available for the `git` child
* process to prevent accidental security vulnerabilities when
* unsanitised user data is passed directly into operations such as
* `git.addRemote`, `git.clone` or `git.raw`.
*
* Enable this override to use the `ext::` protocol (see examples on
* [git-scm.com](https://git-scm.com/docs/git-remote-ext#_examples)).
*/
allowUnsafeProtocolOverride?: boolean;
/**
* Given the possibility of using `--upload-pack` and `--receive-pack` as
* attack vectors, the use of these in any command (or the shorthand
* `-u` option in a `clone` operation) are blocked by default.
*
* Enable this override to permit the use of these arguments.
*/
allowUnsafePack?: boolean;
};
}
/**
* Optional configuration settings to be passed to the `simpleGit`
* builder.
*/
export interface SimpleGitOptions extends Partial<SimpleGitPluginConfig> {
/**
* Base directory for all tasks run through this `simple-git` instance
*/
baseDir: string;
/**
* Limit for the number of child processes that will be spawned concurrently from a `simple-git` instance
*/
maxConcurrentProcesses: number;
/**
* Per-command configuration parameters to be passed with the `-c` switch to `git`
*/
config: string[];
/**
* Enable trimming of trailing white-space in `git.raw`
*/
trimmed: boolean;
}
export type Maybe<T> = T | undefined;
export type MaybeArray<T> = T | T[];
export type Primitives = string | number | boolean;

View file

@ -0,0 +1,19 @@
import { GitExecutorResult, SimpleGitExecutor } from './index';
import { EmptyTask } from '../tasks/task';
export type TaskResponseFormat = Buffer | string;
export interface TaskParser<INPUT extends TaskResponseFormat, RESPONSE> {
(stdOut: INPUT, stdErr: INPUT): RESPONSE;
}
export interface EmptyTaskParser {
(executor: SimpleGitExecutor): void;
}
export interface SimpleGitTaskConfiguration<RESPONSE, FORMAT, INPUT extends TaskResponseFormat> {
commands: string[];
format: FORMAT;
parser: TaskParser<INPUT, RESPONSE>;
onError?: (result: GitExecutorResult, error: Error, done: (result: Buffer | Buffer[]) => void, fail: (error: string | Error) => void) => void;
}
export type StringTask<R> = SimpleGitTaskConfiguration<R, 'utf-8', string>;
export type BufferTask<R> = SimpleGitTaskConfiguration<R, 'buffer', Buffer>;
export type RunnableTask<R> = StringTask<R> | BufferTask<R>;
export type SimpleGitTask<R> = RunnableTask<R> | EmptyTask;

View file

@ -0,0 +1,14 @@
import type { Options, Primitives } from '../types';
export type ArgumentFilterPredicate<T> = (input: T | unknown) => input is T;
export declare function filterType<T, K>(input: K, filter: ArgumentFilterPredicate<T>): K extends T ? T : undefined;
export declare function filterType<T, K>(input: K, filter: ArgumentFilterPredicate<T>, def: T): T;
export declare const filterArray: ArgumentFilterPredicate<Array<unknown>>;
export declare function filterPrimitives(input: unknown, omit?: Array<'boolean' | 'string' | 'number'>): input is Primitives;
export declare const filterNumber: ArgumentFilterPredicate<number>;
export declare const filterString: ArgumentFilterPredicate<string>;
export declare const filterStringOrStringArray: ArgumentFilterPredicate<string | string[]>;
export declare function filterPlainObject<T extends Options>(input: T | unknown): input is T;
export declare function filterFunction(input: unknown): input is (...args: unknown[]) => unknown;
export declare const filterHasLength: ArgumentFilterPredicate<{
length: number;
}>;

View file

@ -0,0 +1,10 @@
/**
* Known process exit codes used by the task parsers to determine whether an error
* was one they can automatically handle
*/
export declare enum ExitCodes {
SUCCESS = 0,
ERROR = 1,
NOT_FOUND = -2,
UNCLEAN = 128
}

View file

@ -0,0 +1,7 @@
import { TaskResponseFormat } from '../types';
export declare class GitOutputStreams<T extends TaskResponseFormat = Buffer> {
readonly stdOut: T;
readonly stdErr: T;
constructor(stdOut: T, stdErr: T);
asStrings(): GitOutputStreams<string>;
}

View file

@ -0,0 +1,8 @@
export * from './argument-filters';
export * from './exit-codes';
export * from './git-output-streams';
export * from './line-parser';
export * from './simple-git-options';
export * from './task-options';
export * from './task-parser';
export * from './util';

View file

@ -0,0 +1,15 @@
export declare class LineParser<T> {
protected matches: string[];
protected useMatches: (target: T, match: string[]) => boolean | void;
private _regExp;
constructor(regExp: RegExp | RegExp[], useMatches?: (target: T, match: string[]) => boolean | void);
parse: (line: (offset: number) => string | undefined, target: T) => boolean;
protected resetMatches(): void;
protected prepareMatches(): string[];
protected addMatch(reg: RegExp, index: number, line?: string): boolean;
protected pushMatch(_index: number, matched: string[]): void;
}
export declare class RemoteLineParser<T> extends LineParser<T> {
protected addMatch(reg: RegExp, index: number, line?: string): boolean;
protected pushMatch(index: number, matched: string[]): void;
}

Some files were not shown because too many files have changed in this diff Show more