grf-cli 1.0.0
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/LICENSE +21 -0
- package/README.md +503 -0
- package/README.zh-CN.md +503 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +74 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/add.d.ts +7 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +92 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/clean.d.ts +7 -0
- package/dist/commands/clean.d.ts.map +1 -0
- package/dist/commands/clean.js +171 -0
- package/dist/commands/clean.js.map +1 -0
- package/dist/commands/config.d.ts +7 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +170 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/list.d.ts +7 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +149 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/load.d.ts +8 -0
- package/dist/commands/load.d.ts.map +1 -0
- package/dist/commands/load.js +239 -0
- package/dist/commands/load.js.map +1 -0
- package/dist/commands/unload.d.ts +7 -0
- package/dist/commands/unload.d.ts.map +1 -0
- package/dist/commands/unload.js +738 -0
- package/dist/commands/unload.js.map +1 -0
- package/dist/commands/update.d.ts +7 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +471 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/use.d.ts +8 -0
- package/dist/commands/use.d.ts.map +1 -0
- package/dist/commands/use.js +224 -0
- package/dist/commands/use.js.map +1 -0
- package/dist/core/config.d.ts +55 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +179 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/filesystem.d.ts +74 -0
- package/dist/core/filesystem.d.ts.map +1 -0
- package/dist/core/filesystem.js +300 -0
- package/dist/core/filesystem.js.map +1 -0
- package/dist/core/git.d.ts +75 -0
- package/dist/core/git.d.ts.map +1 -0
- package/dist/core/git.js +169 -0
- package/dist/core/git.js.map +1 -0
- package/dist/core/loading.d.ts +85 -0
- package/dist/core/loading.d.ts.map +1 -0
- package/dist/core/loading.js +224 -0
- package/dist/core/loading.js.map +1 -0
- package/dist/core/repository.d.ts +120 -0
- package/dist/core/repository.d.ts.map +1 -0
- package/dist/core/repository.js +374 -0
- package/dist/core/repository.js.map +1 -0
- package/dist/core/sync.d.ts +72 -0
- package/dist/core/sync.d.ts.map +1 -0
- package/dist/core/sync.js +226 -0
- package/dist/core/sync.js.map +1 -0
- package/dist/types/index.d.ts +135 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +63 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 haiyewei
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
# Git Reference (grf)
|
|
2
|
+
|
|
3
|
+
English | [简体中文](https://github.com/haiyewei/gitreference/blob/main/README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
A lightweight CLI tool for managing reference code from Git repositories. Easily add, load, and sync reference code into your projects without cluttering your main codebase.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Add and manage Git reference repositories** - Track multiple reference repositories with custom aliases
|
|
10
|
+
- **Load reference code into your working directory** - Selectively load files and directories from references
|
|
11
|
+
- **Shallow clone support** - Save disk space with shallow clones by default
|
|
12
|
+
- **Automatic .gitignore management** - Automatically adds loaded references to .gitignore
|
|
13
|
+
- **Repository update and sync** - Keep your reference code up-to-date with simple commands
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
### Prerequisites
|
|
18
|
+
|
|
19
|
+
- **Node.js** >= 18.0.0
|
|
20
|
+
- **Git** >= 2.0.0
|
|
21
|
+
|
|
22
|
+
### Install via npm
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Global installation (recommended)
|
|
26
|
+
npm install -g gitreference
|
|
27
|
+
|
|
28
|
+
# Or use npx without installation
|
|
29
|
+
npx gitreference <command>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Initialize grf in your project
|
|
36
|
+
grf config init
|
|
37
|
+
|
|
38
|
+
# Add a reference repository
|
|
39
|
+
grf add https://github.com/example/awesome-utils.git --alias utils
|
|
40
|
+
|
|
41
|
+
# List all reference repositories
|
|
42
|
+
grf list
|
|
43
|
+
|
|
44
|
+
# Load reference code into your project
|
|
45
|
+
grf load utils --path src/helpers
|
|
46
|
+
|
|
47
|
+
# Update all references to latest
|
|
48
|
+
grf update
|
|
49
|
+
|
|
50
|
+
# Unload reference code when no longer needed
|
|
51
|
+
grf unload utils
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Commands
|
|
55
|
+
|
|
56
|
+
### add
|
|
57
|
+
|
|
58
|
+
Add a reference repository.
|
|
59
|
+
|
|
60
|
+
**Syntax:**
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
grf add <url> [options]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Arguments:**
|
|
67
|
+
|
|
68
|
+
| Argument | Type | Required | Default | Description |
|
|
69
|
+
| -------- | ------ | -------- | ------- | ------------------ |
|
|
70
|
+
| url | string | ✅ Yes | - | Git repository URL |
|
|
71
|
+
|
|
72
|
+
**Options:**
|
|
73
|
+
|
|
74
|
+
| Option | Short | Type | Default | Description |
|
|
75
|
+
| ------------ | ----- | ------- | ------- | -------------------------------- |
|
|
76
|
+
| --name | -n | string | - | Custom repository name |
|
|
77
|
+
| --branch | -b | string | - | Specify branch |
|
|
78
|
+
| --shallow | - | boolean | true | Shallow clone (default: enabled) |
|
|
79
|
+
| --no-shallow | - | boolean | - | Full clone |
|
|
80
|
+
| --depth | - | string | "1" | Shallow clone depth |
|
|
81
|
+
|
|
82
|
+
**Examples:**
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Add a repository with default settings
|
|
86
|
+
grf add https://github.com/example/repo.git
|
|
87
|
+
|
|
88
|
+
# Add with a custom name
|
|
89
|
+
grf add https://github.com/example/repo.git --name my-ref
|
|
90
|
+
|
|
91
|
+
# Add a specific branch
|
|
92
|
+
grf add https://github.com/example/repo.git --branch develop
|
|
93
|
+
|
|
94
|
+
# Add with full clone (no shallow)
|
|
95
|
+
grf add https://github.com/example/repo.git --no-shallow
|
|
96
|
+
|
|
97
|
+
# Add with custom shallow depth
|
|
98
|
+
grf add https://github.com/example/repo.git --depth 10
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### clean
|
|
104
|
+
|
|
105
|
+
Clean cached repositories.
|
|
106
|
+
|
|
107
|
+
**Syntax:**
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
grf clean [name] [options]
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Arguments:**
|
|
114
|
+
|
|
115
|
+
| Argument | Type | Required | Default | Description |
|
|
116
|
+
| -------- | ------ | -------- | ------- | ------------------------- |
|
|
117
|
+
| name | string | ❌ No | - | Repository name to remove |
|
|
118
|
+
|
|
119
|
+
**Options:**
|
|
120
|
+
|
|
121
|
+
| Option | Short | Type | Default | Description |
|
|
122
|
+
| ------- | ----- | ------- | ------- | ------------------------------ |
|
|
123
|
+
| --all | - | boolean | false | Remove all cached repositories |
|
|
124
|
+
| --force | -f | boolean | false | Skip confirmation |
|
|
125
|
+
|
|
126
|
+
**Examples:**
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Remove a specific cached repository
|
|
130
|
+
grf clean my-ref
|
|
131
|
+
|
|
132
|
+
# Remove all cached repositories (with confirmation)
|
|
133
|
+
grf clean --all
|
|
134
|
+
|
|
135
|
+
# Remove all cached repositories without confirmation
|
|
136
|
+
grf clean --all --force
|
|
137
|
+
|
|
138
|
+
# Remove a specific repository without confirmation
|
|
139
|
+
grf clean my-ref -f
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
### config
|
|
145
|
+
|
|
146
|
+
Manage global configuration.
|
|
147
|
+
|
|
148
|
+
**Syntax:**
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
grf config [key] [value] [options]
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Arguments:**
|
|
155
|
+
|
|
156
|
+
| Argument | Type | Required | Default | Description |
|
|
157
|
+
| -------- | ------ | -------- | ------- | ------------------- |
|
|
158
|
+
| key | string | ❌ No | - | Configuration key |
|
|
159
|
+
| value | string | ❌ No | - | Configuration value |
|
|
160
|
+
|
|
161
|
+
**Options:**
|
|
162
|
+
|
|
163
|
+
| Option | Short | Type | Default | Description |
|
|
164
|
+
| ------ | ----- | ------- | ------- | ---------------------------- |
|
|
165
|
+
| --list | - | boolean | false | Show all configuration |
|
|
166
|
+
| --path | - | boolean | false | Show configuration file path |
|
|
167
|
+
|
|
168
|
+
**Valid Configuration Keys:**
|
|
169
|
+
|
|
170
|
+
| Key | Type | Description |
|
|
171
|
+
| ------------- | ------- | -------------------------------------- |
|
|
172
|
+
| defaultBranch | string | Default branch name |
|
|
173
|
+
| shallowClone | boolean | Enable shallow clone (true/false) |
|
|
174
|
+
| shallowDepth | number | Shallow clone depth (positive integer) |
|
|
175
|
+
|
|
176
|
+
**Examples:**
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Show all configuration
|
|
180
|
+
grf config --list
|
|
181
|
+
|
|
182
|
+
# Show configuration file path
|
|
183
|
+
grf config --path
|
|
184
|
+
|
|
185
|
+
# Get a configuration value
|
|
186
|
+
grf config defaultBranch
|
|
187
|
+
|
|
188
|
+
# Set a configuration value
|
|
189
|
+
grf config defaultBranch main
|
|
190
|
+
|
|
191
|
+
# Enable shallow clone
|
|
192
|
+
grf config shallowClone true
|
|
193
|
+
|
|
194
|
+
# Set shallow clone depth
|
|
195
|
+
grf config shallowDepth 5
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
### list
|
|
201
|
+
|
|
202
|
+
List all cached repositories.
|
|
203
|
+
|
|
204
|
+
**Syntax:**
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
grf list [options]
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Options:**
|
|
211
|
+
|
|
212
|
+
| Option | Short | Type | Default | Description |
|
|
213
|
+
| ------ | ----- | ------- | ------- | --------------------- |
|
|
214
|
+
| --json | - | boolean | false | Output in JSON format |
|
|
215
|
+
|
|
216
|
+
**Examples:**
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
# List all cached repositories
|
|
220
|
+
grf list
|
|
221
|
+
|
|
222
|
+
# List in JSON format
|
|
223
|
+
grf list --json
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
### load
|
|
229
|
+
|
|
230
|
+
Copy reference repository to current directory (supports Git URL).
|
|
231
|
+
|
|
232
|
+
**Syntax:**
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
grf load <name> [path] [options]
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Arguments:**
|
|
239
|
+
|
|
240
|
+
| Argument | Type | Required | Default | Description |
|
|
241
|
+
| -------- | ------ | -------- | --------------------------- | --------------------------------------- |
|
|
242
|
+
| name | string | ✅ Yes | - | Repository name, short name, or Git URL |
|
|
243
|
+
| path | string | ❌ No | .gitreference/\<repo-path\> | Target path |
|
|
244
|
+
|
|
245
|
+
**Options:**
|
|
246
|
+
|
|
247
|
+
| Option | Short | Type | Default | Description |
|
|
248
|
+
| ----------- | ----- | ------- | ------- | --------------------------------- |
|
|
249
|
+
| --subdir | -s | string | - | Copy only a specific subdirectory |
|
|
250
|
+
| --no-ignore | - | boolean | - | Do not update .gitignore |
|
|
251
|
+
| --branch | -b | string | - | Specify branch (only for Git URL) |
|
|
252
|
+
|
|
253
|
+
**Examples:**
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
# Load a repository by name
|
|
257
|
+
grf load my-ref
|
|
258
|
+
|
|
259
|
+
# Load to a specific path
|
|
260
|
+
grf load my-ref src/helpers
|
|
261
|
+
|
|
262
|
+
# Load only a specific subdirectory
|
|
263
|
+
grf load my-ref --subdir src/utils
|
|
264
|
+
|
|
265
|
+
# Load without updating .gitignore
|
|
266
|
+
grf load my-ref --no-ignore
|
|
267
|
+
|
|
268
|
+
# Load directly from a Git URL
|
|
269
|
+
grf load https://github.com/example/repo.git
|
|
270
|
+
|
|
271
|
+
# Load from a Git URL with specific branch
|
|
272
|
+
grf load https://github.com/example/repo.git --branch develop
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
### unload
|
|
278
|
+
|
|
279
|
+
Remove reference code from current project.
|
|
280
|
+
|
|
281
|
+
**Syntax:**
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
grf unload [name] [options]
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
**Arguments:**
|
|
288
|
+
|
|
289
|
+
| Argument | Type | Required | Default | Description |
|
|
290
|
+
| -------- | ------ | -------- | ------- | ------------------------- |
|
|
291
|
+
| name | string | ❌ No | - | Repository name to remove |
|
|
292
|
+
|
|
293
|
+
**Options:**
|
|
294
|
+
|
|
295
|
+
| Option | Short | Type | Default | Description |
|
|
296
|
+
| ------------- | ----- | ------- | ------- | ---------------------------------------------------- |
|
|
297
|
+
| --all | -a | boolean | false | Remove all reference code |
|
|
298
|
+
| --force | -f | boolean | false | Skip confirmation prompt |
|
|
299
|
+
| --dry-run | - | boolean | false | Show what would be deleted without actually deleting |
|
|
300
|
+
| --list | -l | boolean | false | List all loaded reference code |
|
|
301
|
+
| --keep-empty | - | boolean | false | Keep empty .gitreference/ directory after removal |
|
|
302
|
+
| --clean-empty | - | boolean | false | Clean empty directory structures in .gitreference/ |
|
|
303
|
+
| --verbose | -v | boolean | false | Show detailed deletion progress |
|
|
304
|
+
|
|
305
|
+
**Examples:**
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
# Remove a specific reference
|
|
309
|
+
grf unload my-ref
|
|
310
|
+
|
|
311
|
+
# Remove all reference code
|
|
312
|
+
grf unload --all
|
|
313
|
+
|
|
314
|
+
# Remove without confirmation
|
|
315
|
+
grf unload my-ref --force
|
|
316
|
+
|
|
317
|
+
# Preview what would be deleted
|
|
318
|
+
grf unload my-ref --dry-run
|
|
319
|
+
|
|
320
|
+
# List all loaded references
|
|
321
|
+
grf unload --list
|
|
322
|
+
|
|
323
|
+
# Remove but keep empty .gitreference/ directory
|
|
324
|
+
grf unload my-ref --keep-empty
|
|
325
|
+
|
|
326
|
+
# Clean empty directories after removal
|
|
327
|
+
grf unload my-ref --clean-empty
|
|
328
|
+
|
|
329
|
+
# Show detailed progress
|
|
330
|
+
grf unload my-ref --verbose
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
### update
|
|
336
|
+
|
|
337
|
+
Update cached repositories and optionally sync to workspace.
|
|
338
|
+
|
|
339
|
+
**Syntax:**
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
grf update [name] [options]
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
**Arguments:**
|
|
346
|
+
|
|
347
|
+
| Argument | Type | Required | Default | Description |
|
|
348
|
+
| -------- | ------ | -------- | ------- | --------------------------------------------- |
|
|
349
|
+
| name | string | ❌ No | - | Repository name (update all if not specified) |
|
|
350
|
+
|
|
351
|
+
**Options:**
|
|
352
|
+
|
|
353
|
+
| Option | Short | Type | Default | Description |
|
|
354
|
+
| ----------- | ----- | ------- | ------- | ------------------------------------------------- |
|
|
355
|
+
| --check | - | boolean | false | Only check for updates, do not pull |
|
|
356
|
+
| --status | - | boolean | false | Show sync status between workspace and cache |
|
|
357
|
+
| --sync | -s | boolean | false | Sync to workspace after updating cache |
|
|
358
|
+
| --sync-only | - | boolean | false | Only sync to workspace (skip cache update) |
|
|
359
|
+
| --force | -f | boolean | false | Force sync even if versions match |
|
|
360
|
+
| --dry-run | - | boolean | false | Show what would be done without actually doing it |
|
|
361
|
+
|
|
362
|
+
**Examples:**
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
# Update all cached repositories
|
|
366
|
+
grf update
|
|
367
|
+
|
|
368
|
+
# Update a specific repository
|
|
369
|
+
grf update my-ref
|
|
370
|
+
|
|
371
|
+
# Check for updates without pulling
|
|
372
|
+
grf update --check
|
|
373
|
+
|
|
374
|
+
# Show sync status
|
|
375
|
+
grf update --status
|
|
376
|
+
|
|
377
|
+
# Update and sync to workspace
|
|
378
|
+
grf update --sync
|
|
379
|
+
|
|
380
|
+
# Only sync to workspace (skip cache update)
|
|
381
|
+
grf update --sync-only
|
|
382
|
+
|
|
383
|
+
# Force sync even if versions match
|
|
384
|
+
grf update --sync --force
|
|
385
|
+
|
|
386
|
+
# Preview what would be done
|
|
387
|
+
grf update --dry-run
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## Configuration
|
|
393
|
+
|
|
394
|
+
### Configuration Files
|
|
395
|
+
|
|
396
|
+
grf uses a global configuration directory to store settings and cached repositories:
|
|
397
|
+
|
|
398
|
+
| Location | Description |
|
|
399
|
+
| ----------------------------- | ----------------------------------- |
|
|
400
|
+
| `~/.gitreference/config.json` | Global configuration file |
|
|
401
|
+
| `~/.gitreference/repos/` | Cached repository storage |
|
|
402
|
+
| `.gitreference/` | Working directory (in project root) |
|
|
403
|
+
|
|
404
|
+
### Configuration File Structure
|
|
405
|
+
|
|
406
|
+
The global configuration file (`~/.gitreference/config.json`) contains:
|
|
407
|
+
|
|
408
|
+
```json
|
|
409
|
+
{
|
|
410
|
+
"defaultBranch": "main",
|
|
411
|
+
"shallowClone": true,
|
|
412
|
+
"shallowDepth": 1,
|
|
413
|
+
"repositories": [
|
|
414
|
+
{
|
|
415
|
+
"name": "example-repo",
|
|
416
|
+
"url": "https://github.com/example/repo.git",
|
|
417
|
+
"branch": "main",
|
|
418
|
+
"shallow": true,
|
|
419
|
+
"depth": 1
|
|
420
|
+
}
|
|
421
|
+
]
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## How It Works
|
|
428
|
+
|
|
429
|
+
grf follows a two-stage workflow to manage reference code:
|
|
430
|
+
|
|
431
|
+
```
|
|
432
|
+
┌─────────────────┐ ┌─────────────────────────┐ ┌─────────────────┐
|
|
433
|
+
│ Remote Repo │────▶│ Global Cache │────▶│ Project Work │
|
|
434
|
+
│ (GitHub etc) │ │ (~/.gitreference/repos) │ │ (.gitreference) │
|
|
435
|
+
└─────────────────┘ └─────────────────────────┘ └─────────────────┘
|
|
436
|
+
│ │ │
|
|
437
|
+
│ grf add │ grf load │
|
|
438
|
+
│ grf update │ grf update --sync│
|
|
439
|
+
└───────────────────────┴───────────────────────┘
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
### Workflow Steps
|
|
443
|
+
|
|
444
|
+
1. **`grf add`** - Clones the repository to the global cache directory (`~/.gitreference/repos/`)
|
|
445
|
+
2. **`grf load`** - Copies the cached repository to the current project's `.gitreference/` directory
|
|
446
|
+
3. **Automatic .gitignore** - The `.gitreference/` directory is automatically added to `.gitignore`
|
|
447
|
+
4. **`grf update`** - Updates the cache from remote and optionally syncs to the working directory
|
|
448
|
+
5. **`grf unload`** - Removes loaded reference code from the project
|
|
449
|
+
|
|
450
|
+
### Benefits
|
|
451
|
+
|
|
452
|
+
- **Centralized caching** - Repositories are cloned once and shared across projects
|
|
453
|
+
- **Clean project history** - Reference code is excluded from version control
|
|
454
|
+
- **Easy updates** - Keep reference code in sync with upstream changes
|
|
455
|
+
- **Selective loading** - Load only the files or directories you need
|
|
456
|
+
|
|
457
|
+
---
|
|
458
|
+
|
|
459
|
+
## License
|
|
460
|
+
|
|
461
|
+
This project is licensed under the MIT License - see the [LICENSE](https://github.com/haiyewei/gitreference/blob/main/LICENSE) file for details.
|
|
462
|
+
|
|
463
|
+
---
|
|
464
|
+
|
|
465
|
+
## Contributing
|
|
466
|
+
|
|
467
|
+
Contributions are welcome! Here's how you can help:
|
|
468
|
+
|
|
469
|
+
### Getting Started
|
|
470
|
+
|
|
471
|
+
1. Fork the repository
|
|
472
|
+
2. Clone your fork: `git clone https://github.com/your-username/gitreference.git`
|
|
473
|
+
3. Install dependencies: `npm install`
|
|
474
|
+
4. Create a feature branch: `git checkout -b feature/your-feature`
|
|
475
|
+
|
|
476
|
+
### Development
|
|
477
|
+
|
|
478
|
+
```bash
|
|
479
|
+
# Build the project
|
|
480
|
+
npm run build
|
|
481
|
+
|
|
482
|
+
# Run in development mode
|
|
483
|
+
npm run dev
|
|
484
|
+
|
|
485
|
+
# Run tests
|
|
486
|
+
npm test
|
|
487
|
+
|
|
488
|
+
# Lint code
|
|
489
|
+
npm run lint
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
### Submitting Changes
|
|
493
|
+
|
|
494
|
+
1. Make your changes and commit with clear, descriptive messages
|
|
495
|
+
2. Push to your fork: `git push origin feature/your-feature`
|
|
496
|
+
3. Open a Pull Request with a clear description of your changes
|
|
497
|
+
|
|
498
|
+
### Guidelines
|
|
499
|
+
|
|
500
|
+
- Follow the existing code style
|
|
501
|
+
- Add tests for new features
|
|
502
|
+
- Update documentation as needed
|
|
503
|
+
- Keep commits focused and atomic
|