repo-do 1.2.0 → 1.2.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 +356 -333
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/add.d.ts +1 -0
- package/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +18 -2
- package/dist/commands/add.js.map +1 -1
- package/dist/core/repository-manager.d.ts +3 -1
- package/dist/core/repository-manager.d.ts.map +1 -1
- package/dist/core/repository-manager.js +2 -2
- package/dist/core/repository-manager.js.map +1 -1
- package/dist/utils/git-executor.d.ts +4 -2
- package/dist/utils/git-executor.d.ts.map +1 -1
- package/dist/utils/git-executor.js +10 -8
- package/dist/utils/git-executor.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,333 +1,356 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
# repo-do
|
|
4
|
-
|
|
5
|
-
A unified CLI tool for managing git repositories with a structured directory layout.
|
|
6
|
-
Organize all your repositories in a consistent domain-based structure.
|
|
7
|
-
Fast search, clipboard integration, and cross-platform support.
|
|
8
|
-
|
|
9
|
-
English · [简体中文](./docs/README.zh-CN.md)
|
|
10
|
-
|
|
11
|
-
[](https://www.npmjs.com/package/repo-do)
|
|
12
|
-
[](https://github.com/STDSuperman/repo-do/blob/master/LICENSE)
|
|
13
|
-
[](https://nodejs.org)
|
|
14
|
-
[](https://www.npmjs.com/package/repo-do)
|
|
15
|
-
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
## Overview
|
|
19
|
-
|
|
20
|
-
`repo-do` helps you organize all your git repositories in a consistent, domain-based directory structure. It automatically clones repositories to organized paths and provides fast search capabilities to find and navigate to your projects.
|
|
21
|
-
|
|
22
|
-
## Features
|
|
23
|
-
|
|
24
|
-
- **Structured Organization**: Clone repositories to `{baseDir}/{domain}/{group}/{repo}` structure
|
|
25
|
-
- **Fast Repository Search**: Quickly find repositories by name or path fragments
|
|
26
|
-
- **Clipboard Integration**: Automatically copy `cd` commands to clipboard
|
|
27
|
-
- **Cache-Based Performance**: Fast repository listing without repeated directory scans
|
|
28
|
-
- **Cross-Platform**: Works on Windows, macOS, and Linux
|
|
29
|
-
- **Git Clone Pass-through**: Support all git clone arguments (--depth, --branch, etc.)
|
|
30
|
-
|
|
31
|
-
## Installation
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
npm install -g repo-do
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
> **Tip**: After installation, you can use the shorter command `rpd` instead of `repo-do` for faster typing!
|
|
38
|
-
|
|
39
|
-
## Quick Start
|
|
40
|
-
|
|
41
|
-
### 1. Initialize Configuration
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
repo-do init
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
This prompts you to set a base directory for storing repositories (default: `~/.repo-do/repo`).
|
|
48
|
-
|
|
49
|
-
### 2. Clone a Repository
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
repo-do add git@github.com:STDSuperman/super-image-cropper.git
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
The repository will be cloned to:
|
|
56
|
-
```
|
|
57
|
-
{baseDir}/github.com/STDSuperman/super-image-cropper
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
The `cd` command is automatically copied to your clipboard!
|
|
61
|
-
|
|
62
|
-
### 3. Find a Repository
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
repo-do find super-image
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
Output:
|
|
69
|
-
```
|
|
70
|
-
Found 1 repository:
|
|
71
|
-
1. D:\Code\github.com\STDSuperman\super-image-cropper
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### 4. List All Repositories
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
repo-do list
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Output:
|
|
81
|
-
```
|
|
82
|
-
github.com/STDSuperman/super-image-cropper
|
|
83
|
-
github.com/STDSuperman/NanoBanana-PPT-Skills
|
|
84
|
-
gitlab.com/myorg/internal-tool
|
|
85
|
-
|
|
86
|
-
Total: 3 repositories
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
## Commands
|
|
90
|
-
|
|
91
|
-
### `repo-do init`
|
|
92
|
-
|
|
93
|
-
Initialize configuration and set the base directory for repositories.
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
repo-do init
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### `repo-do add <repo_url> [git-clone-args...]`
|
|
100
|
-
|
|
101
|
-
Clone a repository to the structured directory.
|
|
102
|
-
|
|
103
|
-
**Supported URL formats:**
|
|
104
|
-
- HTTPS: `https://github.com/user/repo.git` or `https://github.com/user/repo`
|
|
105
|
-
- SSH: `git@github.com:user/repo.git` or `ssh://git@github.com/user/repo.git`
|
|
106
|
-
|
|
107
|
-
**Examples:**
|
|
108
|
-
|
|
109
|
-
```bash
|
|
110
|
-
# Basic clone
|
|
111
|
-
repo-do add git@github.com:STDSuperman/super-image-cropper.git
|
|
112
|
-
|
|
113
|
-
# Shallow clone
|
|
114
|
-
repo-do add https://github.com/STDSuperman/super-image-cropper.git --depth 1
|
|
115
|
-
|
|
116
|
-
# Clone specific branch
|
|
117
|
-
repo-do add https://github.com/STDSuperman/super-image-cropper.git --branch develop
|
|
118
|
-
|
|
119
|
-
# SSH clone
|
|
120
|
-
repo-do add git@github.com:STDSuperman/NanoBanana-PPT-Skills.git
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
repo-do
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
**
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
- **
|
|
272
|
-
- **
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# repo-do
|
|
4
|
+
|
|
5
|
+
A unified CLI tool for managing git repositories with a structured directory layout.
|
|
6
|
+
Organize all your repositories in a consistent domain-based structure.
|
|
7
|
+
Fast search, clipboard integration, and cross-platform support.
|
|
8
|
+
|
|
9
|
+
English · [简体中文](./docs/README.zh-CN.md)
|
|
10
|
+
|
|
11
|
+
[](https://www.npmjs.com/package/repo-do)
|
|
12
|
+
[](https://github.com/STDSuperman/repo-do/blob/master/LICENSE)
|
|
13
|
+
[](https://nodejs.org)
|
|
14
|
+
[](https://www.npmjs.com/package/repo-do)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
## Overview
|
|
19
|
+
|
|
20
|
+
`repo-do` helps you organize all your git repositories in a consistent, domain-based directory structure. It automatically clones repositories to organized paths and provides fast search capabilities to find and navigate to your projects.
|
|
21
|
+
|
|
22
|
+
## Features
|
|
23
|
+
|
|
24
|
+
- **Structured Organization**: Clone repositories to `{baseDir}/{domain}/{group}/{repo}` structure
|
|
25
|
+
- **Fast Repository Search**: Quickly find repositories by name or path fragments
|
|
26
|
+
- **Clipboard Integration**: Automatically copy `cd` commands to clipboard
|
|
27
|
+
- **Cache-Based Performance**: Fast repository listing without repeated directory scans
|
|
28
|
+
- **Cross-Platform**: Works on Windows, macOS, and Linux
|
|
29
|
+
- **Git Clone Pass-through**: Support all git clone arguments (--depth, --branch, etc.)
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install -g repo-do
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
> **Tip**: After installation, you can use the shorter command `rpd` instead of `repo-do` for faster typing!
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
### 1. Initialize Configuration
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
repo-do init
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
This prompts you to set a base directory for storing repositories (default: `~/.repo-do/repo`).
|
|
48
|
+
|
|
49
|
+
### 2. Clone a Repository
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
repo-do add git@github.com:STDSuperman/super-image-cropper.git
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The repository will be cloned to:
|
|
56
|
+
```
|
|
57
|
+
{baseDir}/github.com/STDSuperman/super-image-cropper
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The `cd` command is automatically copied to your clipboard!
|
|
61
|
+
|
|
62
|
+
### 3. Find a Repository
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
repo-do find super-image
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Output:
|
|
69
|
+
```
|
|
70
|
+
Found 1 repository:
|
|
71
|
+
1. D:\Code\github.com\STDSuperman\super-image-cropper
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 4. List All Repositories
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
repo-do list
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Output:
|
|
81
|
+
```
|
|
82
|
+
github.com/STDSuperman/super-image-cropper
|
|
83
|
+
github.com/STDSuperman/NanoBanana-PPT-Skills
|
|
84
|
+
gitlab.com/myorg/internal-tool
|
|
85
|
+
|
|
86
|
+
Total: 3 repositories
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Commands
|
|
90
|
+
|
|
91
|
+
### `repo-do init`
|
|
92
|
+
|
|
93
|
+
Initialize configuration and set the base directory for repositories.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
repo-do init
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### `repo-do add <repo_url> [git-clone-args...]`
|
|
100
|
+
|
|
101
|
+
Clone a repository to the structured directory.
|
|
102
|
+
|
|
103
|
+
**Supported URL formats:**
|
|
104
|
+
- HTTPS: `https://github.com/user/repo.git` or `https://github.com/user/repo`
|
|
105
|
+
- SSH: `git@github.com:user/repo.git` or `ssh://git@github.com/user/repo.git`
|
|
106
|
+
|
|
107
|
+
**Examples:**
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# Basic clone
|
|
111
|
+
repo-do add git@github.com:STDSuperman/super-image-cropper.git
|
|
112
|
+
|
|
113
|
+
# Shallow clone
|
|
114
|
+
repo-do add https://github.com/STDSuperman/super-image-cropper.git --depth 1
|
|
115
|
+
|
|
116
|
+
# Clone specific branch
|
|
117
|
+
repo-do add https://github.com/STDSuperman/super-image-cropper.git --branch develop
|
|
118
|
+
|
|
119
|
+
# SSH clone
|
|
120
|
+
repo-do add git@github.com:STDSuperman/NanoBanana-PPT-Skills.git
|
|
121
|
+
|
|
122
|
+
# JSON output (for scripts and AI models)
|
|
123
|
+
repo-do add https://github.com/user/repo.git --json
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**`--json` output:**
|
|
127
|
+
|
|
128
|
+
When using `--json`, the command outputs a single line of JSON to stdout with no spinner, color, or clipboard side effects:
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{"success":true,"path":"/path/to/repo","alreadyExists":false,"message":""}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
| Field | Type | Description |
|
|
135
|
+
|-------|------|-------------|
|
|
136
|
+
| `success` | boolean | `true` if the repo path is available (cloned or already exists) |
|
|
137
|
+
| `path` | string | Absolute path to the local repository |
|
|
138
|
+
| `alreadyExists` | boolean | `true` if the repository was already cloned |
|
|
139
|
+
| `message` | string | Error or status message |
|
|
140
|
+
|
|
141
|
+
On failure, the process exits with code 1 and outputs:
|
|
142
|
+
```json
|
|
143
|
+
{"success":false,"path":"","alreadyExists":false,"message":"error details"}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Directory structure:**
|
|
147
|
+
```
|
|
148
|
+
{baseDir}/
|
|
149
|
+
├── github.com/
|
|
150
|
+
│ └── STDSuperman/
|
|
151
|
+
│ ├── super-image-cropper/
|
|
152
|
+
│ └── NanoBanana-PPT-Skills/
|
|
153
|
+
└── gitlab.com/
|
|
154
|
+
└── myorg/
|
|
155
|
+
└── internal-tool/
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### `repo-do find <query>`
|
|
159
|
+
|
|
160
|
+
Search for repositories by name, group, or path fragment (case-insensitive).
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
repo-do find super-image
|
|
164
|
+
repo-do find STDSuperman
|
|
165
|
+
repo-do find github.com
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Output format:**
|
|
169
|
+
```
|
|
170
|
+
Found 2 repositories:
|
|
171
|
+
1. D:\Code\github.com\STDSuperman\super-image-cropper
|
|
172
|
+
2. D:\Code\github.com\STDSuperman\NanoBanana-PPT-Skills
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Each result is prefixed with a number, followed by the absolute path.
|
|
176
|
+
|
|
177
|
+
### `repo-do list [--refresh]`
|
|
178
|
+
|
|
179
|
+
List all managed repositories.
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# List from cache (fast)
|
|
183
|
+
repo-do list
|
|
184
|
+
|
|
185
|
+
# Force rebuild cache
|
|
186
|
+
repo-do list --refresh
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### `repo-do remove <repo>`
|
|
190
|
+
|
|
191
|
+
Remove a repository from tracking (does not delete files).
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
repo-do remove super-image
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
If multiple matches are found, you'll be prompted to select which one to remove.
|
|
198
|
+
|
|
199
|
+
### `repo-do config [options]`
|
|
200
|
+
|
|
201
|
+
View or modify configuration.
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
# Show current config
|
|
205
|
+
repo-do config
|
|
206
|
+
|
|
207
|
+
# Get base directory
|
|
208
|
+
repo-do config --get baseDirectory
|
|
209
|
+
|
|
210
|
+
# Set base directory
|
|
211
|
+
repo-do config --set baseDirectory /path/to/repos
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Directory Structure
|
|
215
|
+
|
|
216
|
+
All repositories are organized in a consistent structure:
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
{baseDirectory}/{domain}/{group}/{repository}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**Examples:**
|
|
223
|
+
|
|
224
|
+
| Git URL | Cloned Path |
|
|
225
|
+
|---------|-------------|
|
|
226
|
+
| `git@github.com:STDSuperman/super-image-cropper.git` | `{baseDir}/github.com/STDSuperman/super-image-cropper` |
|
|
227
|
+
| `git@gitlab.com:myorg/myrepo.git` | `{baseDir}/gitlab.com/myorg/myrepo` |
|
|
228
|
+
| `https://github.com/STDSuperman/NanoBanana-PPT-Skills.git` | `{baseDir}/github.com/STDSuperman/NanoBanana-PPT-Skills` |
|
|
229
|
+
|
|
230
|
+
## Configuration
|
|
231
|
+
|
|
232
|
+
Configuration is stored in `~/.repo-do/config.json`:
|
|
233
|
+
|
|
234
|
+
```json
|
|
235
|
+
{
|
|
236
|
+
"baseDirectory": "D:\\Code",
|
|
237
|
+
"version": "1.0.0"
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Cache System
|
|
242
|
+
|
|
243
|
+
To improve performance, `repo-do` maintains a repository cache at `~/.repo-do/repo_cache.json`.
|
|
244
|
+
|
|
245
|
+
**Cache is automatically updated when:**
|
|
246
|
+
- Adding a new repository (`repo-do add`)
|
|
247
|
+
- Removing a repository (`repo-do remove`)
|
|
248
|
+
- Forcing refresh (`repo-do list --refresh`)
|
|
249
|
+
|
|
250
|
+
**Cache format:**
|
|
251
|
+
```json
|
|
252
|
+
{
|
|
253
|
+
"repositories": [
|
|
254
|
+
{
|
|
255
|
+
"name": "super-image-cropper",
|
|
256
|
+
"fullPath": "D:\\Code\\github.com\\STDSuperman\\super-image-cropper",
|
|
257
|
+
"gitUrl": "git@github.com:STDSuperman/super-image-cropper.git",
|
|
258
|
+
"domain": "github.com",
|
|
259
|
+
"group": "STDSuperman",
|
|
260
|
+
"lastUpdated": "2026-01-11T12:00:00.000Z"
|
|
261
|
+
}
|
|
262
|
+
],
|
|
263
|
+
"lastUpdated": "2026-01-11T12:00:00.000Z"
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Cross-Platform Support
|
|
268
|
+
|
|
269
|
+
### Clipboard Support
|
|
270
|
+
|
|
271
|
+
- **macOS**: Uses `pbcopy`
|
|
272
|
+
- **Linux**: Uses `xclip` or `xsel` (may require installation)
|
|
273
|
+
- **Windows**: Uses `clip` command
|
|
274
|
+
|
|
275
|
+
If clipboard fails, the path is still displayed in the terminal.
|
|
276
|
+
|
|
277
|
+
### Path Handling
|
|
278
|
+
|
|
279
|
+
All paths are handled using Node.js `path` module for cross-platform compatibility.
|
|
280
|
+
|
|
281
|
+
## Requirements
|
|
282
|
+
|
|
283
|
+
- Node.js >= 18.0.0
|
|
284
|
+
- Git installed and available in PATH
|
|
285
|
+
|
|
286
|
+
## Error Handling
|
|
287
|
+
|
|
288
|
+
`repo-do` provides clear error messages for common issues:
|
|
289
|
+
|
|
290
|
+
- **INVALID_URL**: Git URL format not recognized
|
|
291
|
+
- **CLONE_FAILED**: Git clone operation failed
|
|
292
|
+
- **CONFIG_ERROR**: Configuration file read/write error
|
|
293
|
+
- **NOT_FOUND**: Repository not found in cache
|
|
294
|
+
- **PERMISSION_DENIED**: File system permission error
|
|
295
|
+
- **GIT_NOT_INSTALLED**: Git is not installed
|
|
296
|
+
|
|
297
|
+
## Development
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# Clone the repository
|
|
301
|
+
git clone https://github.com/your-username/repo-do.git
|
|
302
|
+
cd repo-do
|
|
303
|
+
|
|
304
|
+
# Install dependencies
|
|
305
|
+
npm install
|
|
306
|
+
|
|
307
|
+
# Run in development mode
|
|
308
|
+
npm run dev
|
|
309
|
+
|
|
310
|
+
# Build
|
|
311
|
+
npm run build
|
|
312
|
+
|
|
313
|
+
# Run tests
|
|
314
|
+
npm test
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
## Project Structure
|
|
318
|
+
|
|
319
|
+
```
|
|
320
|
+
repo-do/
|
|
321
|
+
├── src/
|
|
322
|
+
│ ├── commands/ # CLI command implementations
|
|
323
|
+
│ ├── core/ # Core business logic
|
|
324
|
+
│ ├── utils/ # Utility functions
|
|
325
|
+
│ ├── types/ # TypeScript type definitions
|
|
326
|
+
│ ├── constants/ # Constants
|
|
327
|
+
│ └── index.ts # CLI entry point
|
|
328
|
+
├── bin/
|
|
329
|
+
│ └── repo-do.js # Executable entry
|
|
330
|
+
├── dist/ # Compiled output
|
|
331
|
+
└── tests/ # Test files
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
## Dependencies
|
|
335
|
+
|
|
336
|
+
- **chalk**: Terminal text styling
|
|
337
|
+
- **clipboardy**: Cross-platform clipboard operations
|
|
338
|
+
- **commander**: CLI framework
|
|
339
|
+
- **inquirer**: Interactive command line prompts
|
|
340
|
+
- **ora**: Elegant terminal spinner
|
|
341
|
+
|
|
342
|
+
## License
|
|
343
|
+
|
|
344
|
+
MIT
|
|
345
|
+
|
|
346
|
+
## Contributing
|
|
347
|
+
|
|
348
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
349
|
+
|
|
350
|
+
## Changelog
|
|
351
|
+
|
|
352
|
+
### 1.0.0
|
|
353
|
+
- Initial release
|
|
354
|
+
- Core functionality: init, add, list, find, remove, config
|
|
355
|
+
- Cross-platform support
|
|
356
|
+
- Cache system for fast repository listing
|
package/dist/cli.js
CHANGED
|
@@ -19,10 +19,11 @@ program
|
|
|
19
19
|
program
|
|
20
20
|
.command('add <url>')
|
|
21
21
|
.description('Clone a git repository')
|
|
22
|
+
.option('--json', 'Output result as JSON')
|
|
22
23
|
.allowUnknownOption()
|
|
23
24
|
.action((url, options, command) => {
|
|
24
25
|
const args = command.args.slice(1);
|
|
25
|
-
addCommand(url, { args });
|
|
26
|
+
addCommand(url, { args, json: options.json });
|
|
26
27
|
});
|
|
27
28
|
program
|
|
28
29
|
.command('list')
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAUA,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE;AAE7B;KACG,IAAI,CAAC,SAAS;KACd,WAAW,CAAC,wCAAwC;KACpD,OAAO,CAAC,OAAO,CAAC;AAEnB;KACG,OAAO,CAAC,MAAM;KACd,WAAW,CAAC,0BAA0B;KACtC,MAAM,CAAC,WAAW,CAAC;AAEtB;KACG,OAAO,CAAC,WAAW;KACnB,WAAW,CAAC,wBAAwB;AACpC,KAAA,kBAAkB;KAClB,MAAM,CAAC,CAAC,GAAW,EAAE,OAAY,EAAE,OAAgB,KAAI;IACtD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAClC,IAAA,UAAU,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAUA,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE;AAE7B;KACG,IAAI,CAAC,SAAS;KACd,WAAW,CAAC,wCAAwC;KACpD,OAAO,CAAC,OAAO,CAAC;AAEnB;KACG,OAAO,CAAC,MAAM;KACd,WAAW,CAAC,0BAA0B;KACtC,MAAM,CAAC,WAAW,CAAC;AAEtB;KACG,OAAO,CAAC,WAAW;KACnB,WAAW,CAAC,wBAAwB;AACpC,KAAA,MAAM,CAAC,QAAQ,EAAE,uBAAuB;AACxC,KAAA,kBAAkB;KAClB,MAAM,CAAC,CAAC,GAAW,EAAE,OAAY,EAAE,OAAgB,KAAI;IACtD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAClC,IAAA,UAAU,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;AAC/C,CAAC,CAAC;AAEJ;KACG,OAAO,CAAC,MAAM;KACd,WAAW,CAAC,+BAA+B;AAC3C,KAAA,MAAM,CAAC,WAAW,EAAE,0BAA0B;AAC9C,KAAA,MAAM,CAAC,CAAC,OAAO,KAAI;IAClB,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;AAC3C,CAAC,CAAC;AAEJ;KACG,OAAO,CAAC,eAAe;KACvB,WAAW,CAAC,kCAAkC;KAC9C,MAAM,CAAC,WAAW,CAAC;AAEtB;KACG,OAAO,CAAC,qBAAqB;KAC7B,WAAW,CAAC,uDAAuD;KACnE,MAAM,CAAC,aAAa,CAAC;AAExB;KACG,OAAO,CAAC,QAAQ;KAChB,WAAW,CAAC,8BAA8B;AAC1C,KAAA,MAAM,CAAC,aAAa,EAAE,yBAAyB;AAC/C,KAAA,MAAM,CAAC,aAAa,EAAE,uBAAuB;AAC7C,KAAA,MAAM,CAAC,iBAAiB,EAAE,4BAA4B;AACtD,KAAA,MAAM,CAAC,CAAC,OAAO,KAAI;AAClB,IAAA,aAAa,CAAC;QACZ,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,KAAK,EAAE,OAAO,CAAC,KAAK;AACrB,KAAA,CAAC;AACJ,CAAC,CAAC;AAEJ,OAAO,CAAC,KAAK,EAAE"}
|
package/dist/commands/add.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AASA,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA0CzG"}
|
package/dist/commands/add.js
CHANGED
|
@@ -3,15 +3,27 @@ import { clipboardUtil } from '../utils/clipboard.js';
|
|
|
3
3
|
import { logger } from '../utils/logger.js';
|
|
4
4
|
import ora from 'ora';
|
|
5
5
|
|
|
6
|
+
function outputJson(data) {
|
|
7
|
+
console.log(JSON.stringify(data));
|
|
8
|
+
}
|
|
6
9
|
async function addCommand(url, options) {
|
|
7
|
-
const
|
|
10
|
+
const jsonMode = options.json ?? false;
|
|
11
|
+
const spinner = jsonMode ? null : ora('Cloning repository...').start();
|
|
8
12
|
try {
|
|
9
13
|
const cloneArgs = options.args || [];
|
|
10
|
-
const result = await repositoryManager.cloneRepository(url, cloneArgs);
|
|
14
|
+
const result = await repositoryManager.cloneRepository(url, cloneArgs, { silent: jsonMode });
|
|
11
15
|
if (result.alreadyExists) {
|
|
16
|
+
if (jsonMode) {
|
|
17
|
+
outputJson({ success: true, path: result.path, alreadyExists: true, message: result.message });
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
12
20
|
spinner.warn(result.message);
|
|
13
21
|
return;
|
|
14
22
|
}
|
|
23
|
+
if (jsonMode) {
|
|
24
|
+
outputJson({ success: true, path: result.path, alreadyExists: false, message: '' });
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
15
27
|
spinner.succeed('Repository cloned successfully!');
|
|
16
28
|
logger.success(result.path);
|
|
17
29
|
const cdCommand = `cd ${result.path}`;
|
|
@@ -22,6 +34,10 @@ async function addCommand(url, options) {
|
|
|
22
34
|
console.log(`\n${cdCommand}`);
|
|
23
35
|
}
|
|
24
36
|
catch (error) {
|
|
37
|
+
if (jsonMode) {
|
|
38
|
+
outputJson({ success: false, path: '', alreadyExists: false, message: error.message });
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
25
41
|
spinner.fail('Failed to clone repository');
|
|
26
42
|
logger.error(error.message);
|
|
27
43
|
process.exit(1);
|
package/dist/commands/add.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.js","sources":["../../src/commands/add.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"add.js","sources":["../../src/commands/add.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAKA,SAAS,UAAU,CAAC,IAAiF,EAAA;IACnG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AACnC;AAEO,eAAe,UAAU,CAAC,GAAW,EAAE,OAA4C,EAAA;AACxF,IAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,IAAI,KAAK;AACtC,IAAA,MAAM,OAAO,GAAG,QAAQ,GAAG,IAAI,GAAG,GAAG,CAAC,uBAAuB,CAAC,CAAC,KAAK,EAAE;AAEtE,IAAA,IAAI;AACF,QAAA,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,IAAI,EAAE;AACpC,QAAA,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,eAAe,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAE5F,QAAA,IAAI,MAAM,CAAC,aAAa,EAAE;YACxB,IAAI,QAAQ,EAAE;gBACZ,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;gBAC9F;YACF;AACA,YAAA,OAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;YAC7B;QACF;QAEA,IAAI,QAAQ,EAAE;YACZ,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;YACnF;QACF;AAEA,QAAA,OAAQ,CAAC,OAAO,CAAC,iCAAiC,CAAC;AACnD,QAAA,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;AAE3B,QAAA,MAAM,SAAS,GAAG,CAAA,GAAA,EAAM,MAAM,CAAC,IAAI,EAAE;QACrC,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC;QAElD,IAAI,MAAM,EAAE;AACV,YAAA,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC;QAC1C;AAEA,QAAA,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS,CAAA,CAAE,CAAC;IAC/B;IAAE,OAAO,KAAK,EAAE;QACd,IAAI,QAAQ,EAAE;YACZ,UAAU,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,EAAG,KAAe,CAAC,OAAO,EAAE,CAAC;AACjG,YAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACjB;AACA,QAAA,OAAQ,CAAC,IAAI,CAAC,4BAA4B,CAAC;AAC3C,QAAA,MAAM,CAAC,KAAK,CAAE,KAAe,CAAC,OAAO,CAAC;AACtC,QAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACjB;AACF;;;;"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { IRepositoryInfo, ICloneResult } from '../types';
|
|
2
2
|
export declare class RepositoryManager {
|
|
3
|
-
cloneRepository(url: string, cloneArgs?: string[]
|
|
3
|
+
cloneRepository(url: string, cloneArgs?: string[], options?: {
|
|
4
|
+
silent?: boolean;
|
|
5
|
+
}): Promise<ICloneResult>;
|
|
4
6
|
listRepositories(refresh?: boolean): Promise<IRepositoryInfo[]>;
|
|
5
7
|
findRepositories(query: string): Promise<IRepositoryInfo[]>;
|
|
6
8
|
removeRepository(identifier: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository-manager.d.ts","sourceRoot":"","sources":["../../src/core/repository-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAa,MAAM,UAAU,CAAC;AAQpE,qBAAa,iBAAiB;IACtB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"repository-manager.d.ts","sourceRoot":"","sources":["../../src/core/repository-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAa,MAAM,UAAU,CAAC;AAQpE,qBAAa,iBAAiB;IACtB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,GAAE,MAAM,EAAO,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,CAAC;IA0C7G,gBAAgB,CAAC,OAAO,GAAE,OAAe,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAStE,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAI3D,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBnD,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAQvD;AAED,eAAO,MAAM,iBAAiB,mBAA0B,CAAC"}
|
|
@@ -8,7 +8,7 @@ import { pathGenerator } from './path-generator.js';
|
|
|
8
8
|
import { ERROR_CODES } from '../constants/index.js';
|
|
9
9
|
|
|
10
10
|
class RepositoryManager {
|
|
11
|
-
async cloneRepository(url, cloneArgs = []) {
|
|
11
|
+
async cloneRepository(url, cloneArgs = [], options) {
|
|
12
12
|
const parsed = parseGitUrl(url);
|
|
13
13
|
const baseDir = await configManager.getBaseDirectory();
|
|
14
14
|
const targetPath = pathGenerator.generateRepoPath(baseDir, parsed);
|
|
@@ -21,7 +21,7 @@ class RepositoryManager {
|
|
|
21
21
|
alreadyExists: true,
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
const result = await gitExecutor.clone(url, targetPath, cloneArgs);
|
|
24
|
+
const result = await gitExecutor.clone(url, targetPath, cloneArgs, { silent: options?.silent });
|
|
25
25
|
if (result.success) {
|
|
26
26
|
const repoInfo = {
|
|
27
27
|
name: parsed.repoName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository-manager.js","sources":["../../src/core/repository-manager.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;MASa,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"repository-manager.js","sources":["../../src/core/repository-manager.ts"],"sourcesContent":[null],"names":[],"mappings":"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"}
|
|
@@ -4,8 +4,10 @@ export interface IExecuteResult {
|
|
|
4
4
|
stderr: string;
|
|
5
5
|
}
|
|
6
6
|
export declare class GitExecutor {
|
|
7
|
-
checkGitInstalled(): Promise<boolean>;
|
|
8
|
-
clone(url: string, targetPath: string, args?: string[]
|
|
7
|
+
checkGitInstalled(silent?: boolean): Promise<boolean>;
|
|
8
|
+
clone(url: string, targetPath: string, args?: string[], options?: {
|
|
9
|
+
silent?: boolean;
|
|
10
|
+
}): Promise<IExecuteResult>;
|
|
9
11
|
private execute;
|
|
10
12
|
}
|
|
11
13
|
export declare const gitExecutor: GitExecutor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-executor.d.ts","sourceRoot":"","sources":["../../src/utils/git-executor.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,WAAW;IAChB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"git-executor.d.ts","sourceRoot":"","sources":["../../src/utils/git-executor.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,WAAW;IAChB,iBAAiB,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IASrD,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAO,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;YAa5G,OAAO;CAsCtB;AAED,eAAO,MAAM,WAAW,aAAoB,CAAC"}
|
|
@@ -3,24 +3,24 @@ import { GitMError } from '../types/index.js';
|
|
|
3
3
|
import { ERROR_CODES } from '../constants/index.js';
|
|
4
4
|
|
|
5
5
|
class GitExecutor {
|
|
6
|
-
async checkGitInstalled() {
|
|
6
|
+
async checkGitInstalled(silent) {
|
|
7
7
|
try {
|
|
8
|
-
const result = await this.execute('git', ['--version']);
|
|
8
|
+
const result = await this.execute('git', ['--version'], silent);
|
|
9
9
|
return result.success;
|
|
10
10
|
}
|
|
11
11
|
catch {
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
async clone(url, targetPath, args = []) {
|
|
16
|
-
const gitInstalled = await this.checkGitInstalled();
|
|
15
|
+
async clone(url, targetPath, args = [], options) {
|
|
16
|
+
const gitInstalled = await this.checkGitInstalled(options?.silent);
|
|
17
17
|
if (!gitInstalled) {
|
|
18
18
|
throw new GitMError('Git is not installed. Please install git first.', ERROR_CODES.GIT_NOT_INSTALLED);
|
|
19
19
|
}
|
|
20
20
|
const cloneArgs = ['clone', ...args, url, targetPath];
|
|
21
|
-
return this.execute('git', cloneArgs);
|
|
21
|
+
return this.execute('git', cloneArgs, options?.silent);
|
|
22
22
|
}
|
|
23
|
-
async execute(command, args) {
|
|
23
|
+
async execute(command, args, silent) {
|
|
24
24
|
return new Promise((resolve, reject) => {
|
|
25
25
|
const child = spawn(command, args, {
|
|
26
26
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
@@ -31,12 +31,14 @@ class GitExecutor {
|
|
|
31
31
|
child.stdout?.on('data', (data) => {
|
|
32
32
|
const text = data.toString();
|
|
33
33
|
stdout += text;
|
|
34
|
-
|
|
34
|
+
if (!silent)
|
|
35
|
+
process.stdout.write(text);
|
|
35
36
|
});
|
|
36
37
|
child.stderr?.on('data', (data) => {
|
|
37
38
|
const text = data.toString();
|
|
38
39
|
stderr += text;
|
|
39
|
-
|
|
40
|
+
if (!silent)
|
|
41
|
+
process.stderr.write(text);
|
|
40
42
|
});
|
|
41
43
|
child.on('error', (error) => {
|
|
42
44
|
reject(new GitMError(`Failed to execute git command: ${error.message}`, ERROR_CODES.CLONE_FAILED));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-executor.js","sources":["../../src/utils/git-executor.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;MAUa,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"git-executor.js","sources":["../../src/utils/git-executor.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;MAUa,WAAW,CAAA;IACtB,MAAM,iBAAiB,CAAC,MAAgB,EAAA;AACtC,QAAA,IAAI;AACF,YAAA,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;YAC/D,OAAO,MAAM,CAAC,OAAO;QACvB;AAAE,QAAA,MAAM;AACN,YAAA,OAAO,KAAK;QACd;IACF;IAEA,MAAM,KAAK,CAAC,GAAW,EAAE,UAAkB,EAAE,IAAA,GAAiB,EAAE,EAAE,OAA8B,EAAA;QAC9F,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC;QAClE,IAAI,CAAC,YAAY,EAAE;YACjB,MAAM,IAAI,SAAS,CACjB,iDAAiD,EACjD,WAAW,CAAC,iBAAiB,CAC9B;QACH;AAEA,QAAA,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,UAAU,CAAC;AACrD,QAAA,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC;IACxD;AAEQ,IAAA,MAAM,OAAO,CAAC,OAAe,EAAE,IAAc,EAAE,MAAgB,EAAA;QACrE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAI;AACrC,YAAA,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE;AACjC,gBAAA,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC;AACjC,gBAAA,KAAK,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO;AACpC,aAAA,CAAC;YAEF,IAAI,MAAM,GAAG,EAAE;YACf,IAAI,MAAM,GAAG,EAAE;YAEf,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,KAAI;AAChC,gBAAA,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE;gBAC5B,MAAM,IAAI,IAAI;AACd,gBAAA,IAAI,CAAC,MAAM;AAAE,oBAAA,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;AACzC,YAAA,CAAC,CAAC;YAEF,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,KAAI;AAChC,gBAAA,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE;gBAC5B,MAAM,IAAI,IAAI;AACd,gBAAA,IAAI,CAAC,MAAM;AAAE,oBAAA,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;AACzC,YAAA,CAAC,CAAC;YAEF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,KAAI;AAC1B,gBAAA,MAAM,CAAC,IAAI,SAAS,CAClB,kCAAkC,KAAK,CAAC,OAAO,CAAA,CAAE,EACjD,WAAW,CAAC,YAAY,CACzB,CAAC;AACJ,YAAA,CAAC,CAAC;YAEF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,KAAI;AACzB,gBAAA,IAAI,IAAI,KAAK,CAAC,EAAE;oBACd,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;gBAC5C;qBAAO;oBACL,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;gBAC7C;AACF,YAAA,CAAC,CAAC;AACJ,QAAA,CAAC,CAAC;IACJ;AACD;AAEM,MAAM,WAAW,GAAG,IAAI,WAAW;;;;"}
|