brch 0.0.1 → 0.0.3
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/.brchignore +3 -0
- package/COMMANDS.md +8 -0
- package/README.md +195 -1
- package/dist/commands/commitCommand.d.ts +2 -0
- package/dist/commands/diffCommand.d.ts +2 -0
- package/dist/commands/logCommand.d.ts +2 -0
- package/dist/commands/statusCommand.d.ts +2 -0
- package/dist/index.js +3059 -82
- package/dist/services/commitService.d.ts +1 -0
- package/dist/services/configService.d.ts +1 -1
- package/dist/services/diffService.d.ts +1 -0
- package/dist/services/logService.d.ts +3 -0
- package/dist/services/statusService.d.ts +1 -0
- package/dist/utils/constants.d.ts +14 -4
- package/dist/utils/date.d.ts +1 -0
- package/dist/utils/hash.d.ts +1 -0
- package/dist/utils/head.d.ts +2 -0
- package/dist/utils/objectPath.d.ts +12 -0
- package/package.json +4 -2
- package/test/sample.txt +1 -0
- package/.env +0 -1
package/.brchignore
ADDED
package/COMMANDS.md
ADDED
package/README.md
CHANGED
|
@@ -1 +1,195 @@
|
|
|
1
|
-
# brch
|
|
1
|
+
# brch
|
|
2
|
+
|
|
3
|
+
A simple Version Control System (VCS) built with TypeScript.
|
|
4
|
+
|
|
5
|
+
## Description
|
|
6
|
+
|
|
7
|
+
`brch` is a lightweight version control system that provides essential VCS functionality including repository initialization, file staging, commits, history tracking, and diff visualization. It stores objects using SHA1 hashing and maintains a staging index for tracking changes.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Install globally via npm:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g brch
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Or use with npx without installing:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx brch <command>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
### Initialize a Repository
|
|
26
|
+
|
|
27
|
+
Initialize a new `brch` repository in the current directory:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
brch init
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This creates a `.brch` directory with the necessary structure for version control.
|
|
34
|
+
|
|
35
|
+
### Add Files to Staging
|
|
36
|
+
|
|
37
|
+
Add files or directories to the staging area:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Add specific files
|
|
41
|
+
brch add file1.txt file2.js
|
|
42
|
+
|
|
43
|
+
# Add entire directory
|
|
44
|
+
brch add src/
|
|
45
|
+
|
|
46
|
+
# Add current directory
|
|
47
|
+
brch add .
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The command will:
|
|
51
|
+
|
|
52
|
+
- Stage new or modified files
|
|
53
|
+
- Skip unchanged files
|
|
54
|
+
- Store file objects in `.brch/objects/` using SHA1 hashing
|
|
55
|
+
- Update the staging index
|
|
56
|
+
|
|
57
|
+
### Commit Changes
|
|
58
|
+
|
|
59
|
+
Commit staged changes to the repository:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Commit with a message
|
|
63
|
+
brch commit -m "Add new feature"
|
|
64
|
+
|
|
65
|
+
# Commit with a longer message
|
|
66
|
+
brch commit -m "Fix bug in authentication" -m "Updated login validation logic"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### View Status
|
|
70
|
+
|
|
71
|
+
Check the status of your working directory:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
brch status
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
This shows:
|
|
78
|
+
|
|
79
|
+
- Changes staged for commit
|
|
80
|
+
- Modified files not yet staged
|
|
81
|
+
- Untracked files and directories
|
|
82
|
+
|
|
83
|
+
### View Commit History
|
|
84
|
+
|
|
85
|
+
View the commit history of the current branch:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
brch log
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Displays commits with:
|
|
92
|
+
|
|
93
|
+
- Commit hash
|
|
94
|
+
- Author information
|
|
95
|
+
- Timestamp
|
|
96
|
+
- Commit message
|
|
97
|
+
|
|
98
|
+
### View Changes
|
|
99
|
+
|
|
100
|
+
See differences between your working directory and the last commit:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
brch diff
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Shows a colored unified diff of all modified files.
|
|
107
|
+
|
|
108
|
+
### Configuration
|
|
109
|
+
|
|
110
|
+
Manage repository or global configuration:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Set local repository configuration
|
|
114
|
+
brch config set user.name "Your Name"
|
|
115
|
+
brch config set user.email "your.email@example.com"
|
|
116
|
+
|
|
117
|
+
# Set global configuration
|
|
118
|
+
brch config set --global user.name "Your Name"
|
|
119
|
+
brch config set --global user.email "your.email@example.com"
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Configuration is stored in `.brchconfig` (local) or `~/.brchconfig` (global) using INI format.
|
|
123
|
+
|
|
124
|
+
## Commands
|
|
125
|
+
|
|
126
|
+
- `brch init` - Initialize a new repository
|
|
127
|
+
- `brch add <paths...>` - Add files to the staging area
|
|
128
|
+
- `brch commit -m <message>` - Commit staged changes
|
|
129
|
+
- `brch status` - Show the working tree status
|
|
130
|
+
- `brch log` - Show commit history
|
|
131
|
+
- `brch diff` - Show changes between working directory and last commit
|
|
132
|
+
- `brch config set <scopeKey> <value>` - Set configuration value
|
|
133
|
+
- `--global` - Set global configuration instead of local
|
|
134
|
+
|
|
135
|
+
## Ignore Files
|
|
136
|
+
|
|
137
|
+
Create a `.brchignore` file in your repository root to exclude files and directories from version control:
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
# Example .brchignore
|
|
141
|
+
node_modules/
|
|
142
|
+
*.log
|
|
143
|
+
dist/
|
|
144
|
+
.env
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Supports patterns:
|
|
148
|
+
|
|
149
|
+
- Exact matches: `node_modules`
|
|
150
|
+
- Glob patterns: `*.log`
|
|
151
|
+
- Directory patterns: `dist/`
|
|
152
|
+
|
|
153
|
+
## Development
|
|
154
|
+
|
|
155
|
+
### Prerequisites
|
|
156
|
+
|
|
157
|
+
- [Node.js](https://nodejs.org/) (latest version)
|
|
158
|
+
- npm (comes with Node.js)
|
|
159
|
+
|
|
160
|
+
### Build
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Build the project
|
|
164
|
+
npm run build
|
|
165
|
+
|
|
166
|
+
# Generate TypeScript types
|
|
167
|
+
npm run types
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Development
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# Run in development mode
|
|
174
|
+
npm run dev
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Project Structure
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
brch/
|
|
181
|
+
├── src/
|
|
182
|
+
│ ├── commands/ # CLI command definitions
|
|
183
|
+
│ ├── services/ # Core business logic
|
|
184
|
+
│ └── utils/ # Utility functions and constants
|
|
185
|
+
├── dist/ # Compiled output
|
|
186
|
+
└── package.json
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
MIT
|
|
192
|
+
|
|
193
|
+
## Author
|
|
194
|
+
|
|
195
|
+
vishalkrsharma
|