@optique/git 0.9.0-dev.215 → 0.9.0-dev.217

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -4,52 +4,12 @@ import { expandOid, listBranches, listRemotes, listTags, readObject, resolveRef
4
4
 
5
5
  //#region src/index.d.ts
6
6
 
7
- /**
8
- * Interface for FileSystem operations required by git parsers.
9
- * This allows custom filesystem implementations for different environments.
10
- *
11
- * @since 0.9.0
12
- */
13
- interface FileSystem {
14
- readFile(path: string): Promise<Uint8Array | string>;
15
- writeFile(path: string, data: Uint8Array | string): Promise<void>;
16
- mkdir(path: string, options?: {
17
- recursive?: boolean;
18
- }): Promise<void>;
19
- rmdir(path: string, options?: {
20
- recursive?: boolean;
21
- }): Promise<void>;
22
- unlink(path: string): Promise<void>;
23
- readdir(path: string): Promise<string[]>;
24
- lstat(path: string): Promise<{
25
- isSymbolicLink(): boolean;
26
- isDirectory(): boolean;
27
- isFile(): boolean;
28
- }>;
29
- stat(path: string): Promise<{
30
- isSymbolicLink(): boolean;
31
- isDirectory(): boolean;
32
- isFile(): boolean;
33
- }>;
34
- readlink(path: string): Promise<string>;
35
- symlink(target: string, path: string): Promise<void>;
36
- chmod(path: string, mode: number): Promise<void>;
37
- chown(path: string, uid: number, gid: number): Promise<void>;
38
- rename(oldPath: string, newPath: string): Promise<void>;
39
- copyFile(srcPath: string, destPath: string): Promise<void>;
40
- exists(path: string): Promise<boolean>;
41
- }
42
7
  /**
43
8
  * Options for creating git value parsers.
44
9
  *
45
10
  * @since 0.9.0
46
11
  */
47
12
  interface GitParserOptions {
48
- /**
49
- * The filesystem implementation to use.
50
- * Defaults to node:fs/promises (works in Deno and Node.js).
51
- */
52
- fs?: FileSystem;
53
13
  /**
54
14
  * The directory of the git repository.
55
15
  * Defaults to the current working directory.
@@ -67,11 +27,43 @@ interface GitParserOptions {
67
27
  * @since 0.9.0
68
28
  */
69
29
  interface GitParsers {
30
+ /**
31
+ * Creates a value parser that validates local branch names.
32
+ * @param options Configuration options for the parser.
33
+ * @returns A value parser that accepts existing branch names.
34
+ */
70
35
  branch(options?: GitParserOptions): ValueParser<"async", string>;
36
+ /**
37
+ * Creates a value parser that validates remote branch names.
38
+ * @param remote The remote name to validate against.
39
+ * @param options Configuration options for the parser.
40
+ * @returns A value parser that accepts existing remote branch names.
41
+ */
71
42
  remoteBranch(remote: string, options?: GitParserOptions): ValueParser<"async", string>;
43
+ /**
44
+ * Creates a value parser that validates tag names.
45
+ * @param options Configuration options for the parser.
46
+ * @returns A value parser that accepts existing tag names.
47
+ */
72
48
  tag(options?: GitParserOptions): ValueParser<"async", string>;
49
+ /**
50
+ * Creates a value parser that validates remote names.
51
+ * @param options Configuration options for the parser.
52
+ * @returns A value parser that accepts existing remote names.
53
+ */
73
54
  remote(options?: GitParserOptions): ValueParser<"async", string>;
55
+ /**
56
+ * Creates a value parser that validates commit SHAs.
57
+ * @param options Configuration options for the parser.
58
+ * @returns A value parser that accepts existing commit SHAs.
59
+ */
74
60
  commit(options?: GitParserOptions): ValueParser<"async", string>;
61
+ /**
62
+ * Creates a value parser that validates any git reference.
63
+ * Accepts branch names, tag names, or commit SHAs.
64
+ * @param options Configuration options for the parser.
65
+ * @returns A value parser that accepts any git reference.
66
+ */
75
67
  ref(options?: GitParserOptions): ValueParser<"async", string>;
76
68
  }
77
69
  /**
@@ -116,100 +108,48 @@ declare function gitRemoteBranch(remote: string, options?: GitParserOptions): Va
116
108
  /**
117
109
  * Creates a value parser that validates tag names.
118
110
  *
119
- * This parser uses isomorphic-git to verify that the provided input
120
- * matches an existing tag in the repository.
121
- *
122
111
  * @param options Configuration options for the parser.
123
112
  * @returns A value parser that accepts existing tag names.
124
113
  * @since 0.9.0
125
- *
126
- * @example
127
- * ~~~~ typescript
128
- * import { gitTag } from "@optique/git";
129
- * import { option } from "@optique/core/primitives";
130
- *
131
- * const parser = option("-t", "--tag", gitTag());
132
- * ~~~~
133
114
  */
134
115
  declare function gitTag(options?: GitParserOptions): ValueParser<"async", string>;
135
116
  /**
136
117
  * Creates a value parser that validates remote names.
137
118
  *
138
- * This parser uses isomorphic-git to verify that the provided input
139
- * matches an existing remote in the repository.
140
- *
141
119
  * @param options Configuration options for the parser.
142
120
  * @returns A value parser that accepts existing remote names.
143
121
  * @since 0.9.0
144
- *
145
- * @example
146
- * ~~~~ typescript
147
- * import { gitRemote } from "@optique/git";
148
- * import { option } from "@optique/core/primitives";
149
- *
150
- * const parser = option("-r", "--remote", gitRemote());
151
- * ~~~~
152
122
  */
153
123
  declare function gitRemote(options?: GitParserOptions): ValueParser<"async", string>;
154
124
  /**
155
125
  * Creates a value parser that validates commit SHAs.
156
126
  *
157
- * This parser uses isomorphic-git to verify that the provided input
158
- * is a valid commit SHA (full or shortened) that exists in the repository.
127
+ * This parser resolves the provided commit reference to its full 40-character
128
+ * OID.
159
129
  *
160
130
  * @param options Configuration options for the parser.
161
- * @returns A value parser that accepts valid commit SHAs.
131
+ * @returns A value parser that accepts existing commit SHAs.
162
132
  * @since 0.9.0
163
- *
164
- * @example
165
- * ~~~~ typescript
166
- * import { gitCommit } from "@optique/git";
167
- * import { option } from "@optique/core/primitives";
168
- *
169
- * const parser = option("-c", "--commit", gitCommit());
170
- * ~~~~
171
133
  */
172
134
  declare function gitCommit(options?: GitParserOptions): ValueParser<"async", string>;
173
135
  /**
174
- * Creates a value parser that validates any git reference
175
- * (branches, tags, or commits).
136
+ * Creates a value parser that validates any git reference.
176
137
  *
177
- * This parser uses isomorphic-git to verify that the provided input
178
- * resolves to a valid git reference (branch, tag, or commit SHA).
138
+ * Accepts branch names, tag names, or commit SHAs and resolves them to the
139
+ * corresponding commit OID.
179
140
  *
180
141
  * @param options Configuration options for the parser.
181
- * @returns A value parser that accepts branches, tags, or commit SHAs.
142
+ * @returns A value parser that accepts any git reference.
182
143
  * @since 0.9.0
183
- *
184
- * @example
185
- * ~~~~ typescript
186
- * import { gitRef } from "@optique/git";
187
- * import { option } from "@optique/core/primitives";
188
- *
189
- * const parser = option("--ref", gitRef());
190
- * ~~~~
191
144
  */
192
145
  declare function gitRef(options?: GitParserOptions): ValueParser<"async", string>;
193
146
  /**
194
- * Creates a factory for git parsers with shared configuration.
147
+ * Creates a set of git parsers with shared configuration.
195
148
  *
196
- * This function returns an object with methods for creating individual git
197
- * parsers that share the same configuration (filesystem and directory).
198
- *
199
- * @param options Shared configuration options for all parsers.
200
- * @returns An object with methods for creating individual git parsers.
149
+ * @param options Shared configuration for the parsers.
150
+ * @returns An object containing git parsers.
201
151
  * @since 0.9.0
202
- *
203
- * @example
204
- * ~~~~ typescript
205
- * import { createGitParsers } from "@optique/git";
206
- *
207
- * const git = createGitParsers({ dir: "/path/to/repo" });
208
- *
209
- * const branchParser = git.branch();
210
- * const tagParser = git.tag();
211
- * ~~~~
212
152
  */
213
153
  declare function createGitParsers(options?: GitParserOptions): GitParsers;
214
154
  //#endregion
215
- export { FileSystem, GitParserOptions, GitParsers, createGitParsers, expandOid, gitBranch, gitCommit, gitRef, gitRemote, gitRemoteBranch, gitTag, listBranches, listRemotes, listTags, readObject, resolveRef };
155
+ export { GitParserOptions, GitParsers, createGitParsers, expandOid, gitBranch, gitCommit, gitRef, gitRemote, gitRemoteBranch, gitTag, listBranches, listRemotes, listTags, readObject, resolveRef };
package/dist/index.d.ts CHANGED
@@ -4,52 +4,12 @@ import { ValueParser } from "@optique/core/valueparser";
4
4
 
5
5
  //#region src/index.d.ts
6
6
 
7
- /**
8
- * Interface for FileSystem operations required by git parsers.
9
- * This allows custom filesystem implementations for different environments.
10
- *
11
- * @since 0.9.0
12
- */
13
- interface FileSystem {
14
- readFile(path: string): Promise<Uint8Array | string>;
15
- writeFile(path: string, data: Uint8Array | string): Promise<void>;
16
- mkdir(path: string, options?: {
17
- recursive?: boolean;
18
- }): Promise<void>;
19
- rmdir(path: string, options?: {
20
- recursive?: boolean;
21
- }): Promise<void>;
22
- unlink(path: string): Promise<void>;
23
- readdir(path: string): Promise<string[]>;
24
- lstat(path: string): Promise<{
25
- isSymbolicLink(): boolean;
26
- isDirectory(): boolean;
27
- isFile(): boolean;
28
- }>;
29
- stat(path: string): Promise<{
30
- isSymbolicLink(): boolean;
31
- isDirectory(): boolean;
32
- isFile(): boolean;
33
- }>;
34
- readlink(path: string): Promise<string>;
35
- symlink(target: string, path: string): Promise<void>;
36
- chmod(path: string, mode: number): Promise<void>;
37
- chown(path: string, uid: number, gid: number): Promise<void>;
38
- rename(oldPath: string, newPath: string): Promise<void>;
39
- copyFile(srcPath: string, destPath: string): Promise<void>;
40
- exists(path: string): Promise<boolean>;
41
- }
42
7
  /**
43
8
  * Options for creating git value parsers.
44
9
  *
45
10
  * @since 0.9.0
46
11
  */
47
12
  interface GitParserOptions {
48
- /**
49
- * The filesystem implementation to use.
50
- * Defaults to node:fs/promises (works in Deno and Node.js).
51
- */
52
- fs?: FileSystem;
53
13
  /**
54
14
  * The directory of the git repository.
55
15
  * Defaults to the current working directory.
@@ -67,11 +27,43 @@ interface GitParserOptions {
67
27
  * @since 0.9.0
68
28
  */
69
29
  interface GitParsers {
30
+ /**
31
+ * Creates a value parser that validates local branch names.
32
+ * @param options Configuration options for the parser.
33
+ * @returns A value parser that accepts existing branch names.
34
+ */
70
35
  branch(options?: GitParserOptions): ValueParser<"async", string>;
36
+ /**
37
+ * Creates a value parser that validates remote branch names.
38
+ * @param remote The remote name to validate against.
39
+ * @param options Configuration options for the parser.
40
+ * @returns A value parser that accepts existing remote branch names.
41
+ */
71
42
  remoteBranch(remote: string, options?: GitParserOptions): ValueParser<"async", string>;
43
+ /**
44
+ * Creates a value parser that validates tag names.
45
+ * @param options Configuration options for the parser.
46
+ * @returns A value parser that accepts existing tag names.
47
+ */
72
48
  tag(options?: GitParserOptions): ValueParser<"async", string>;
49
+ /**
50
+ * Creates a value parser that validates remote names.
51
+ * @param options Configuration options for the parser.
52
+ * @returns A value parser that accepts existing remote names.
53
+ */
73
54
  remote(options?: GitParserOptions): ValueParser<"async", string>;
55
+ /**
56
+ * Creates a value parser that validates commit SHAs.
57
+ * @param options Configuration options for the parser.
58
+ * @returns A value parser that accepts existing commit SHAs.
59
+ */
74
60
  commit(options?: GitParserOptions): ValueParser<"async", string>;
61
+ /**
62
+ * Creates a value parser that validates any git reference.
63
+ * Accepts branch names, tag names, or commit SHAs.
64
+ * @param options Configuration options for the parser.
65
+ * @returns A value parser that accepts any git reference.
66
+ */
75
67
  ref(options?: GitParserOptions): ValueParser<"async", string>;
76
68
  }
77
69
  /**
@@ -116,100 +108,48 @@ declare function gitRemoteBranch(remote: string, options?: GitParserOptions): Va
116
108
  /**
117
109
  * Creates a value parser that validates tag names.
118
110
  *
119
- * This parser uses isomorphic-git to verify that the provided input
120
- * matches an existing tag in the repository.
121
- *
122
111
  * @param options Configuration options for the parser.
123
112
  * @returns A value parser that accepts existing tag names.
124
113
  * @since 0.9.0
125
- *
126
- * @example
127
- * ~~~~ typescript
128
- * import { gitTag } from "@optique/git";
129
- * import { option } from "@optique/core/primitives";
130
- *
131
- * const parser = option("-t", "--tag", gitTag());
132
- * ~~~~
133
114
  */
134
115
  declare function gitTag(options?: GitParserOptions): ValueParser<"async", string>;
135
116
  /**
136
117
  * Creates a value parser that validates remote names.
137
118
  *
138
- * This parser uses isomorphic-git to verify that the provided input
139
- * matches an existing remote in the repository.
140
- *
141
119
  * @param options Configuration options for the parser.
142
120
  * @returns A value parser that accepts existing remote names.
143
121
  * @since 0.9.0
144
- *
145
- * @example
146
- * ~~~~ typescript
147
- * import { gitRemote } from "@optique/git";
148
- * import { option } from "@optique/core/primitives";
149
- *
150
- * const parser = option("-r", "--remote", gitRemote());
151
- * ~~~~
152
122
  */
153
123
  declare function gitRemote(options?: GitParserOptions): ValueParser<"async", string>;
154
124
  /**
155
125
  * Creates a value parser that validates commit SHAs.
156
126
  *
157
- * This parser uses isomorphic-git to verify that the provided input
158
- * is a valid commit SHA (full or shortened) that exists in the repository.
127
+ * This parser resolves the provided commit reference to its full 40-character
128
+ * OID.
159
129
  *
160
130
  * @param options Configuration options for the parser.
161
- * @returns A value parser that accepts valid commit SHAs.
131
+ * @returns A value parser that accepts existing commit SHAs.
162
132
  * @since 0.9.0
163
- *
164
- * @example
165
- * ~~~~ typescript
166
- * import { gitCommit } from "@optique/git";
167
- * import { option } from "@optique/core/primitives";
168
- *
169
- * const parser = option("-c", "--commit", gitCommit());
170
- * ~~~~
171
133
  */
172
134
  declare function gitCommit(options?: GitParserOptions): ValueParser<"async", string>;
173
135
  /**
174
- * Creates a value parser that validates any git reference
175
- * (branches, tags, or commits).
136
+ * Creates a value parser that validates any git reference.
176
137
  *
177
- * This parser uses isomorphic-git to verify that the provided input
178
- * resolves to a valid git reference (branch, tag, or commit SHA).
138
+ * Accepts branch names, tag names, or commit SHAs and resolves them to the
139
+ * corresponding commit OID.
179
140
  *
180
141
  * @param options Configuration options for the parser.
181
- * @returns A value parser that accepts branches, tags, or commit SHAs.
142
+ * @returns A value parser that accepts any git reference.
182
143
  * @since 0.9.0
183
- *
184
- * @example
185
- * ~~~~ typescript
186
- * import { gitRef } from "@optique/git";
187
- * import { option } from "@optique/core/primitives";
188
- *
189
- * const parser = option("--ref", gitRef());
190
- * ~~~~
191
144
  */
192
145
  declare function gitRef(options?: GitParserOptions): ValueParser<"async", string>;
193
146
  /**
194
- * Creates a factory for git parsers with shared configuration.
147
+ * Creates a set of git parsers with shared configuration.
195
148
  *
196
- * This function returns an object with methods for creating individual git
197
- * parsers that share the same configuration (filesystem and directory).
198
- *
199
- * @param options Shared configuration options for all parsers.
200
- * @returns An object with methods for creating individual git parsers.
149
+ * @param options Shared configuration for the parsers.
150
+ * @returns An object containing git parsers.
201
151
  * @since 0.9.0
202
- *
203
- * @example
204
- * ~~~~ typescript
205
- * import { createGitParsers } from "@optique/git";
206
- *
207
- * const git = createGitParsers({ dir: "/path/to/repo" });
208
- *
209
- * const branchParser = git.branch();
210
- * const tagParser = git.tag();
211
- * ~~~~
212
152
  */
213
153
  declare function createGitParsers(options?: GitParserOptions): GitParsers;
214
154
  //#endregion
215
- export { FileSystem, GitParserOptions, GitParsers, createGitParsers, expandOid, gitBranch, gitCommit, gitRef, gitRemote, gitRemoteBranch, gitTag, listBranches, listRemotes, listTags, readObject, resolveRef };
155
+ export { GitParserOptions, GitParsers, createGitParsers, expandOid, gitBranch, gitCommit, gitRef, gitRemote, gitRemoteBranch, gitTag, listBranches, listRemotes, listTags, readObject, resolveRef };