safe-push 0.1.0 → 0.1.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 +102 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# safe-push
|
|
2
|
+
|
|
3
|
+
A Bun CLI tool for safe Git push operations. Detects changes to forbidden areas (default: `.github/`) and blocks pushes based on configurable conditions.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun install
|
|
9
|
+
bun run build
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Global installation:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
bun link
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### Check Push Permission
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
safe-push check # Display result in human-readable format
|
|
24
|
+
safe-push check --json # Output result as JSON
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Execute Push
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
safe-push push # Check and push if allowed
|
|
31
|
+
safe-push push --force # Bypass safety checks
|
|
32
|
+
safe-push push --dry-run # Show result without actually pushing
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Configuration Management
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
safe-push config init # Initialize configuration file
|
|
39
|
+
safe-push config init -f # Overwrite existing configuration
|
|
40
|
+
safe-push config show # Show current configuration
|
|
41
|
+
safe-push config path # Show configuration file path
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Push Permission Rules
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
Push Allowed = (No forbidden changes) AND (New branch OR Last commit is yours)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
| Forbidden Changes | New Branch | Last Commit Yours | Result |
|
|
51
|
+
|-------------------|------------|-------------------|---------|
|
|
52
|
+
| No | Yes | - | Allowed |
|
|
53
|
+
| No | No | Yes | Allowed |
|
|
54
|
+
| No | No | No | Blocked |
|
|
55
|
+
| Yes | - | - | Blocked |
|
|
56
|
+
|
|
57
|
+
## Configuration
|
|
58
|
+
|
|
59
|
+
**Path**: `~/.config/safe-push/config.jsonc`
|
|
60
|
+
|
|
61
|
+
```jsonc
|
|
62
|
+
{
|
|
63
|
+
// Forbidden paths (glob patterns)
|
|
64
|
+
"forbiddenPaths": [".github/"],
|
|
65
|
+
// Behavior on forbidden changes: "error" | "prompt"
|
|
66
|
+
"onForbidden": "error"
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Options
|
|
71
|
+
|
|
72
|
+
| Key | Type | Default | Description |
|
|
73
|
+
|-----|------|---------|-------------|
|
|
74
|
+
| `forbiddenPaths` | `string[]` | `[".github/"]` | Paths to block changes (glob patterns) |
|
|
75
|
+
| `onForbidden` | `"error" \| "prompt"` | `"error"` | Behavior when forbidden changes detected |
|
|
76
|
+
|
|
77
|
+
- `error`: Display error and exit
|
|
78
|
+
- `prompt`: Ask user for confirmation
|
|
79
|
+
|
|
80
|
+
## Author Detection
|
|
81
|
+
|
|
82
|
+
Local email is determined by the following priority:
|
|
83
|
+
|
|
84
|
+
1. Environment variable `SAFE_PUSH_EMAIL`
|
|
85
|
+
2. `git config user.email`
|
|
86
|
+
|
|
87
|
+
## Development
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Run in development
|
|
91
|
+
bun run dev -- check
|
|
92
|
+
|
|
93
|
+
# Type check
|
|
94
|
+
bun run typecheck
|
|
95
|
+
|
|
96
|
+
# Build
|
|
97
|
+
bun run build
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
MIT
|