jekyll-theme-zer0 0.10.6 → 0.15.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +428 -0
- data/README.md +79 -31
- data/_data/README.md +419 -17
- data/_data/generate_statistics.rb +216 -9
- data/_data/generate_statistics.sh +106 -0
- data/_data/github-actions-example.yml +210 -0
- data/_data/navigation/about.yml +39 -11
- data/_data/navigation/docs.yml +53 -23
- data/_data/navigation/home.yml +27 -9
- data/_data/navigation/main.yml +27 -8
- data/_data/navigation/posts.yml +22 -6
- data/_data/navigation/quickstart.yml +19 -6
- data/_data/posts_organization.yml +153 -0
- data/_data/prerequisites.yml +112 -0
- data/_data/statistics_config.yml +203 -0
- data/_data/ui-text.yml +321 -0
- data/_data/update_statistics.sh +126 -0
- data/_includes/README.md +2 -0
- data/_includes/components/js-cdn.html +4 -1
- data/_includes/components/post-card.html +2 -11
- data/_includes/components/preview-image.html +32 -0
- data/_includes/content/intro.html +9 -10
- data/_includes/core/header.html +14 -0
- data/_includes/navigation/sidebar-categories.html +20 -9
- data/_includes/navigation/sidebar-folders.html +8 -7
- data/_includes/navigation/sidebar-right.html +16 -10
- data/_layouts/blog.html +15 -45
- data/_layouts/category.html +4 -24
- data/_layouts/collection.html +2 -12
- data/_layouts/default.html +1 -1
- data/_layouts/journals.html +2 -12
- data/_layouts/notebook.html +296 -0
- data/_sass/core/_docs.scss +1 -1
- data/_sass/custom.scss +54 -17
- data/_sass/notebooks.scss +458 -0
- data/assets/images/notebooks/test-notebook_files/test-notebook_4_0.png +0 -0
- data/assets/js/sidebar.js +511 -0
- data/scripts/README.md +131 -105
- data/scripts/analyze-commits.sh +9 -311
- data/scripts/bin/build +22 -22
- data/scripts/build +7 -111
- data/scripts/convert-notebooks.sh +415 -0
- data/scripts/features/validate_preview_urls.py +500 -0
- data/scripts/fix-markdown-format.sh +8 -262
- data/scripts/generate-preview-images.sh +7 -787
- data/scripts/install-preview-generator.sh +8 -528
- data/scripts/lib/README.md +5 -5
- data/scripts/lib/changelog.sh +89 -57
- data/scripts/lib/gem.sh +19 -7
- data/scripts/release +7 -236
- data/scripts/setup.sh +9 -153
- data/scripts/test/lib/run_tests.sh +1 -2
- data/scripts/test-auto-version.sh +7 -256
- data/scripts/test-mermaid.sh +7 -287
- data/scripts/test.sh +9 -154
- metadata +16 -10
- data/scripts/features/preview_generator.py +0 -646
- data/scripts/lib/test/run_tests.sh +0 -140
- data/scripts/lib/test/test_changelog.sh +0 -87
- data/scripts/lib/test/test_gem.sh +0 -68
- data/scripts/lib/test/test_git.sh +0 -82
- data/scripts/lib/test/test_validation.sh +0 -72
- data/scripts/lib/test/test_version.sh +0 -96
- data/scripts/version.sh +0 -178
data/scripts/README.md
CHANGED
|
@@ -2,164 +2,187 @@
|
|
|
2
2
|
|
|
3
3
|
This directory contains automation scripts for managing the `jekyll-theme-zer0` gem lifecycle and feature modules.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Directory Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
scripts/
|
|
9
|
+
├── bin/ # Entry point commands (use these!)
|
|
10
|
+
│ ├── build # Build gem without releasing
|
|
11
|
+
│ ├── release # Full release workflow
|
|
12
|
+
│ └── test # Run all test suites
|
|
13
|
+
├── lib/ # Shared libraries (sourced, not executed)
|
|
14
|
+
│ ├── common.sh # Logging, utilities, dry-run support
|
|
15
|
+
│ ├── version.sh # Version management functions
|
|
16
|
+
│ ├── validation.sh # Environment validation
|
|
17
|
+
│ ├── git.sh # Git operations
|
|
18
|
+
│ ├── changelog.sh # Changelog generation
|
|
19
|
+
│ ├── gem.sh # Gem build/publish
|
|
20
|
+
│ └── preview_generator.py # Python preview image generator
|
|
21
|
+
├── features/ # Feature-specific scripts
|
|
22
|
+
│ ├── generate-preview-images # AI preview image generator
|
|
23
|
+
│ ├── install-preview-generator # Preview generator installer
|
|
24
|
+
│ └── validate_preview_urls.py # Preview URL validator
|
|
25
|
+
├── utils/ # Utility scripts
|
|
26
|
+
│ ├── analyze-commits # Commit analyzer for version bumps
|
|
27
|
+
│ ├── fix-markdown # Markdown formatting fixer
|
|
28
|
+
│ └── setup # Development environment setup
|
|
29
|
+
├── test/ # Test suites
|
|
30
|
+
│ ├── lib/ # Library unit tests
|
|
31
|
+
│ ├── theme/ # Theme validation tests
|
|
32
|
+
│ └── integration/ # Integration tests
|
|
33
|
+
└── *.sh (wrappers) # Backward-compatible wrappers
|
|
34
|
+
```
|
|
6
35
|
|
|
7
|
-
|
|
8
|
-
AI-powered preview image generator for Jekyll posts and content.
|
|
36
|
+
## Quick Start
|
|
9
37
|
|
|
10
|
-
**Usage:**
|
|
11
38
|
```bash
|
|
12
|
-
|
|
39
|
+
# Build gem
|
|
40
|
+
./scripts/bin/build
|
|
41
|
+
|
|
42
|
+
# Full release workflow
|
|
43
|
+
./scripts/bin/release patch # or minor/major
|
|
44
|
+
|
|
45
|
+
# Run tests
|
|
46
|
+
./scripts/bin/test
|
|
13
47
|
```
|
|
14
48
|
|
|
15
|
-
|
|
49
|
+
## Scripts Overview
|
|
50
|
+
|
|
51
|
+
### Main Commands (scripts/bin/)
|
|
52
|
+
|
|
53
|
+
#### `bin/build`
|
|
54
|
+
Build the gem without the full release workflow.
|
|
55
|
+
|
|
16
56
|
```bash
|
|
17
|
-
./scripts/
|
|
18
|
-
./scripts/generate-preview-images.sh --dry-run # Preview without changes
|
|
19
|
-
./scripts/generate-preview-images.sh --collection posts # Generate for posts only
|
|
20
|
-
./scripts/generate-preview-images.sh -f path/to/file.md # Process specific file
|
|
21
|
-
./scripts/generate-preview-images.sh --provider openai # Use OpenAI DALL-E
|
|
57
|
+
./scripts/bin/build [--dry-run] [--verbose]
|
|
22
58
|
```
|
|
23
59
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
```yaml
|
|
27
|
-
preview_images:
|
|
28
|
-
enabled: true
|
|
29
|
-
provider: openai
|
|
30
|
-
model: dall-e-3
|
|
31
|
-
size: "1792x1024"
|
|
32
|
-
style: "retro pixel art, 8-bit video game aesthetic"
|
|
33
|
-
output_dir: assets/images/previews
|
|
34
|
-
```
|
|
60
|
+
#### `bin/release`
|
|
61
|
+
Full release workflow with changelog, version bump, and publishing.
|
|
35
62
|
|
|
36
|
-
|
|
63
|
+
```bash
|
|
64
|
+
./scripts/bin/release [patch|minor|major] [options]
|
|
65
|
+
|
|
66
|
+
Options:
|
|
67
|
+
--dry-run Preview without making changes
|
|
68
|
+
--skip-tests Skip test execution
|
|
69
|
+
--skip-publish Skip RubyGems publishing
|
|
70
|
+
--no-github-release Skip GitHub release creation
|
|
71
|
+
--non-interactive No confirmation prompts
|
|
72
|
+
```
|
|
37
73
|
|
|
38
|
-
|
|
39
|
-
|
|
74
|
+
#### `bin/test`
|
|
75
|
+
Unified test runner for all test suites.
|
|
40
76
|
|
|
41
|
-
**Usage:**
|
|
42
77
|
```bash
|
|
43
|
-
|
|
44
|
-
curl -fsSL https://raw.githubusercontent.com/bamr87/zer0-mistakes/main/scripts/install-preview-generator.sh | bash
|
|
45
|
-
|
|
46
|
-
# Local installation with options
|
|
47
|
-
./scripts/install-preview-generator.sh [options]
|
|
78
|
+
./scripts/bin/test [all|lib|theme|integration] [--verbose]
|
|
48
79
|
```
|
|
49
80
|
|
|
50
|
-
|
|
51
|
-
- `-d, --dry-run` - Preview what would be installed
|
|
52
|
-
- `-f, --force` - Overwrite existing files
|
|
53
|
-
- `-p, --provider PROVIDER` - Set default AI provider
|
|
54
|
-
- `--no-config` - Skip _config.yml modification
|
|
55
|
-
- `--no-tasks` - Skip VS Code tasks installation
|
|
81
|
+
### Feature Scripts (scripts/features/)
|
|
56
82
|
|
|
57
|
-
|
|
58
|
-
|
|
83
|
+
#### `generate-preview-images`
|
|
84
|
+
AI-powered preview image generator for Jekyll posts.
|
|
59
85
|
|
|
60
|
-
**Usage:**
|
|
61
86
|
```bash
|
|
62
|
-
./scripts/
|
|
87
|
+
./scripts/features/generate-preview-images [options]
|
|
88
|
+
|
|
89
|
+
Options:
|
|
90
|
+
--list-missing List files missing previews
|
|
91
|
+
--dry-run Preview without changes
|
|
92
|
+
--collection TYPE Generate for specific collection (posts, docs, etc.)
|
|
93
|
+
-f, --file PATH Process specific file
|
|
94
|
+
--provider PROVIDER Use specific AI provider (openai)
|
|
63
95
|
```
|
|
64
96
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
- Installs dependencies
|
|
68
|
-
- Makes scripts executable
|
|
69
|
-
- Validates gemspec
|
|
70
|
-
- Creates CHANGELOG.md if missing
|
|
71
|
-
- Sets up Git hooks for validation
|
|
72
|
-
- Updates .gitignore for gem development
|
|
73
|
-
|
|
74
|
-
### 📈 `version.sh`
|
|
75
|
-
Manages semantic versioning of the gem.
|
|
97
|
+
#### `install-preview-generator`
|
|
98
|
+
Install the preview image generator feature.
|
|
76
99
|
|
|
77
|
-
**Usage:**
|
|
78
100
|
```bash
|
|
79
|
-
./scripts/
|
|
101
|
+
./scripts/features/install-preview-generator [options]
|
|
80
102
|
```
|
|
81
103
|
|
|
82
|
-
|
|
104
|
+
#### `validate_preview_urls.py`
|
|
105
|
+
Validate preview image URLs in frontmatter.
|
|
106
|
+
|
|
83
107
|
```bash
|
|
84
|
-
|
|
85
|
-
./scripts/version.sh minor # 0.1.8 → 0.2.0
|
|
86
|
-
./scripts/version.sh major # 0.1.8 → 1.0.0
|
|
87
|
-
./scripts/version.sh patch --dry-run # Preview changes without applying
|
|
108
|
+
python3 scripts/features/validate_preview_urls.py [--verbose] [--suggestions]
|
|
88
109
|
```
|
|
89
110
|
|
|
90
|
-
|
|
91
|
-
- Validates working directory is clean
|
|
92
|
-
- Updates version in `package.json`
|
|
93
|
-
- Updates `CHANGELOG.md` if it exists
|
|
94
|
-
- Creates git commit with version bump
|
|
95
|
-
- Creates git tag (`v{version}`)
|
|
111
|
+
### Utility Scripts (scripts/utils/)
|
|
96
112
|
|
|
97
|
-
|
|
98
|
-
|
|
113
|
+
#### `setup`
|
|
114
|
+
Set up the development environment.
|
|
99
115
|
|
|
100
|
-
**Usage:**
|
|
101
116
|
```bash
|
|
102
|
-
./scripts/
|
|
117
|
+
./scripts/utils/setup
|
|
103
118
|
```
|
|
104
119
|
|
|
105
|
-
|
|
120
|
+
#### `analyze-commits`
|
|
121
|
+
Analyze commits to determine version bump type.
|
|
122
|
+
|
|
106
123
|
```bash
|
|
107
|
-
./scripts/
|
|
108
|
-
./scripts/build.sh --publish # Build and publish to RubyGems
|
|
109
|
-
./scripts/build.sh --publish --dry-run # Preview publish process
|
|
124
|
+
./scripts/utils/analyze-commits [range]
|
|
110
125
|
```
|
|
111
126
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
-
|
|
127
|
+
#### `fix-markdown`
|
|
128
|
+
Fix markdown formatting issues.
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
./scripts/utils/fix-markdown [files...]
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Libraries (scripts/lib/)
|
|
135
|
+
|
|
136
|
+
These are sourced by other scripts, not executed directly:
|
|
117
137
|
|
|
118
|
-
|
|
119
|
-
|
|
138
|
+
- `common.sh` - Logging utilities, colors, dry-run support
|
|
139
|
+
- `version.sh` - Version parsing, calculation, file updates
|
|
140
|
+
- `validation.sh` - Environment and dependency validation
|
|
141
|
+
- `git.sh` - Git operations (tags, commits, branches)
|
|
142
|
+
- `changelog.sh` - Changelog generation from commits
|
|
143
|
+
- `gem.sh` - Gem build/publish operations
|
|
144
|
+
- `preview_generator.py` - Python preview image generator
|
|
145
|
+
|
|
146
|
+
### Test Suites (scripts/test/)
|
|
120
147
|
|
|
121
|
-
**Usage:**
|
|
122
148
|
```bash
|
|
123
|
-
|
|
149
|
+
# Run all library unit tests
|
|
150
|
+
./scripts/test/lib/run_tests.sh
|
|
151
|
+
|
|
152
|
+
# Run theme validation
|
|
153
|
+
./scripts/test/theme/validate
|
|
154
|
+
|
|
155
|
+
# Run integration tests
|
|
156
|
+
./scripts/test/integration/auto-version
|
|
157
|
+
./scripts/test/integration/mermaid
|
|
124
158
|
```
|
|
125
159
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
- YAML front matter in layouts
|
|
131
|
-
- Jekyll dependencies
|
|
132
|
-
- Version consistency
|
|
133
|
-
- Script permissions
|
|
134
|
-
- Bundle install capability
|
|
160
|
+
## Backward Compatibility
|
|
161
|
+
|
|
162
|
+
Legacy script paths (e.g., `./scripts/build.sh`) are maintained as thin wrappers
|
|
163
|
+
that forward to the canonical locations in `bin/`, `utils/`, `features/`, or `test/`.
|
|
135
164
|
|
|
136
165
|
## Development Workflow
|
|
137
166
|
|
|
138
167
|
### Initial Setup
|
|
139
168
|
```bash
|
|
140
|
-
# Clone the repository
|
|
141
169
|
git clone https://github.com/bamr87/zer0-mistakes.git
|
|
142
170
|
cd zer0-mistakes
|
|
143
|
-
|
|
144
|
-
# Set up development environment
|
|
145
|
-
./scripts/setup.sh
|
|
171
|
+
./scripts/utils/setup
|
|
146
172
|
```
|
|
147
173
|
|
|
148
174
|
### Making Changes
|
|
149
175
|
```bash
|
|
150
|
-
# Make your changes
|
|
151
|
-
|
|
152
|
-
# Run tests to validate changes
|
|
153
|
-
./scripts/test.sh
|
|
176
|
+
# Make your changes
|
|
154
177
|
|
|
155
|
-
#
|
|
156
|
-
./scripts/
|
|
178
|
+
# Run tests
|
|
179
|
+
./scripts/bin/test
|
|
157
180
|
|
|
158
|
-
# Build
|
|
159
|
-
./scripts/build
|
|
181
|
+
# Build (without publish)
|
|
182
|
+
./scripts/bin/build
|
|
160
183
|
|
|
161
|
-
#
|
|
162
|
-
./scripts/
|
|
184
|
+
# Full release
|
|
185
|
+
./scripts/bin/release patch
|
|
163
186
|
```
|
|
164
187
|
|
|
165
188
|
### Automated Workflows
|
|
@@ -186,11 +209,14 @@ The project includes GitHub Actions workflows for automation:
|
|
|
186
209
|
## Requirements
|
|
187
210
|
|
|
188
211
|
### System Dependencies
|
|
212
|
+
- **Bash**: >= 3.2 (macOS default supported - no Homebrew Bash required!)
|
|
189
213
|
- **Ruby**: >= 2.7.0
|
|
190
214
|
- **Bundler**: For dependency management
|
|
191
215
|
- **jq**: For JSON processing
|
|
192
216
|
- **Git**: For version control
|
|
193
217
|
|
|
218
|
+
**Note on Bash Compatibility**: All scripts are compatible with Bash 3.2+ (the default version on macOS). You do NOT need to install Homebrew Bash. The release automation, changelog generation, and all CI/CD workflows work seamlessly with the system-provided Bash on macOS and standard Bash installations on Linux.
|
|
219
|
+
|
|
194
220
|
### RubyGems Publishing Setup
|
|
195
221
|
To publish gems, you need:
|
|
196
222
|
|
data/scripts/analyze-commits.sh
CHANGED
|
@@ -1,313 +1,11 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
GREEN='\033[0;32m'
|
|
13
|
-
YELLOW='\033[1;33m'
|
|
14
|
-
BLUE='\033[0;34m'
|
|
15
|
-
CYAN='\033[0;36m'
|
|
16
|
-
NC='\033[0m' # No Color
|
|
17
|
-
|
|
18
|
-
# Default values
|
|
19
|
-
COMMIT_RANGE="${1:-HEAD~1..HEAD}"
|
|
20
|
-
DEBUG=${DEBUG:-false}
|
|
21
|
-
|
|
22
|
-
# Logging functions
|
|
23
|
-
log_debug() {
|
|
24
|
-
if [[ "$DEBUG" == "true" ]]; then
|
|
25
|
-
echo -e "${CYAN}[DEBUG]${NC} $1" >&2
|
|
26
|
-
fi
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
log_info() {
|
|
30
|
-
echo -e "${BLUE}[INFO]${NC} $1" >&2
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
log_warning() {
|
|
34
|
-
echo -e "${YELLOW}[WARNING]${NC} $1" >&2
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
log_error() {
|
|
38
|
-
echo -e "${RED}[ERROR]${NC} $1" >&2
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
# Function to analyze individual commit
|
|
42
|
-
analyze_commit() {
|
|
43
|
-
local commit_hash="$1"
|
|
44
|
-
local commit_message
|
|
45
|
-
local commit_files
|
|
46
|
-
local bump_level="none"
|
|
47
|
-
|
|
48
|
-
commit_message=$(git log --format="%s%n%b" -n 1 "$commit_hash")
|
|
49
|
-
commit_files=$(git diff-tree --no-commit-id --name-only -r "$commit_hash" 2>/dev/null || echo "")
|
|
50
|
-
|
|
51
|
-
log_debug "Analyzing commit: $commit_hash"
|
|
52
|
-
log_debug "Message: $(echo "$commit_message" | head -1)"
|
|
53
|
-
|
|
54
|
-
# Check for breaking changes (MAJOR)
|
|
55
|
-
if echo "$commit_message" | grep -qi "BREAKING CHANGE\|breaking:"; then
|
|
56
|
-
echo "major"
|
|
57
|
-
return 0
|
|
58
|
-
fi
|
|
59
|
-
|
|
60
|
-
# Check for major version indicators in commit message
|
|
61
|
-
if echo "$commit_message" | grep -qE "^(major|MAJOR|breaking|BREAKING)[\s:]"; then
|
|
62
|
-
echo "major"
|
|
63
|
-
return 0
|
|
64
|
-
fi
|
|
65
|
-
|
|
66
|
-
# Check commit message patterns for conventional commits
|
|
67
|
-
local subject_line=$(echo "$commit_message" | head -1)
|
|
68
|
-
|
|
69
|
-
# MAJOR changes
|
|
70
|
-
if echo "$subject_line" | grep -qE "^(revert|remove|delete)[\s:].*[Bb]reaking"; then
|
|
71
|
-
echo "major"
|
|
72
|
-
return 0
|
|
73
|
-
fi
|
|
74
|
-
|
|
75
|
-
# MINOR changes (new features)
|
|
76
|
-
if echo "$subject_line" | grep -qE "^(feat|feature|add|new)[\s:]"; then
|
|
77
|
-
echo "minor"
|
|
78
|
-
return 0
|
|
79
|
-
fi
|
|
80
|
-
|
|
81
|
-
# MINOR changes - significant additions
|
|
82
|
-
if echo "$subject_line" | grep -qE "^(enhance|improve|update)[\s:].*[Ff]eature"; then
|
|
83
|
-
echo "minor"
|
|
84
|
-
return 0
|
|
85
|
-
fi
|
|
86
|
-
|
|
87
|
-
# PATCH changes (bug fixes, small improvements)
|
|
88
|
-
if echo "$subject_line" | grep -qE "^(fix|bug|patch|hotfix|chore|docs|style|refactor|test|perf)[\s:]"; then
|
|
89
|
-
echo "patch"
|
|
90
|
-
return 0
|
|
91
|
-
fi
|
|
92
|
-
|
|
93
|
-
# PATCH changes - maintenance and small improvements
|
|
94
|
-
if echo "$subject_line" | grep -qE "^(update|improve|enhance|optimize|clean)[\s:]"; then
|
|
95
|
-
echo "patch"
|
|
96
|
-
return 0
|
|
97
|
-
fi
|
|
98
|
-
|
|
99
|
-
# File-based analysis for changes without conventional commit messages
|
|
100
|
-
if [[ -n "$commit_files" ]]; then
|
|
101
|
-
local critical_files=0
|
|
102
|
-
local feature_files=0
|
|
103
|
-
local patch_files=0
|
|
104
|
-
|
|
105
|
-
while IFS= read -r file; do
|
|
106
|
-
[[ -z "$file" ]] && continue
|
|
107
|
-
|
|
108
|
-
log_debug "Analyzing file: $file"
|
|
109
|
-
|
|
110
|
-
# Critical/breaking change files (MAJOR)
|
|
111
|
-
if echo "$file" | grep -qE "(Gemfile|gemspec|_config\.yml|docker-compose\.yml|Dockerfile)$"; then
|
|
112
|
-
((critical_files++))
|
|
113
|
-
log_debug "Critical file detected: $file"
|
|
114
|
-
|
|
115
|
-
# Feature files (MINOR)
|
|
116
|
-
elif echo "$file" | grep -qE "(_layouts/|_includes/|assets/|pages/.*\.md$|\.rb$|\.js$)"; then
|
|
117
|
-
((feature_files++))
|
|
118
|
-
log_debug "Feature file detected: $file"
|
|
119
|
-
|
|
120
|
-
# Documentation and minor files (PATCH)
|
|
121
|
-
elif echo "$file" | grep -qE "(README|CHANGELOG|\.md$|\.txt$|\.yml$|\.yaml$|test/)"; then
|
|
122
|
-
((patch_files++))
|
|
123
|
-
log_debug "Patch file detected: $file"
|
|
124
|
-
fi
|
|
125
|
-
done <<< "$commit_files"
|
|
126
|
-
|
|
127
|
-
# Determine bump level based on file analysis
|
|
128
|
-
if [[ $critical_files -gt 0 ]]; then
|
|
129
|
-
# But only if there are significant changes to critical files
|
|
130
|
-
local lines_changed=$(git diff --shortstat "$commit_hash^" "$commit_hash" 2>/dev/null | grep -oE '[0-9]+ insertion|[0-9]+ deletion' | grep -oE '[0-9]+' | paste -sd+ | bc 2>/dev/null || echo "0")
|
|
131
|
-
if [[ $lines_changed -gt 10 ]]; then
|
|
132
|
-
echo "minor" # Significant changes to critical files = minor
|
|
133
|
-
return 0
|
|
134
|
-
else
|
|
135
|
-
echo "patch" # Small changes to critical files = patch
|
|
136
|
-
return 0
|
|
137
|
-
fi
|
|
138
|
-
elif [[ $feature_files -gt 0 ]]; then
|
|
139
|
-
echo "patch" # Changes to feature files without explicit feat: = patch
|
|
140
|
-
return 0
|
|
141
|
-
elif [[ $patch_files -gt 0 ]]; then
|
|
142
|
-
echo "patch"
|
|
143
|
-
return 0
|
|
144
|
-
fi
|
|
145
|
-
fi
|
|
146
|
-
|
|
147
|
-
# If we reach here, no clear classification - default to patch for any real changes
|
|
148
|
-
if [[ -n "$commit_files" ]]; then
|
|
149
|
-
echo "patch"
|
|
150
|
-
else
|
|
151
|
-
echo "none"
|
|
152
|
-
fi
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
# Function to determine highest bump level from multiple commits
|
|
156
|
-
determine_overall_bump() {
|
|
157
|
-
local commits=("$@")
|
|
158
|
-
local highest_bump="none"
|
|
159
|
-
local patch_count=0
|
|
160
|
-
local minor_count=0
|
|
161
|
-
local major_count=0
|
|
162
|
-
|
|
163
|
-
log_info "Analyzing ${#commits[@]} commits for version bump determination"
|
|
164
|
-
|
|
165
|
-
for commit in "${commits[@]}"; do
|
|
166
|
-
local bump_level
|
|
167
|
-
bump_level=$(analyze_commit "$commit")
|
|
168
|
-
|
|
169
|
-
log_debug "Commit $commit: $bump_level"
|
|
170
|
-
|
|
171
|
-
case "$bump_level" in
|
|
172
|
-
"major")
|
|
173
|
-
((major_count++))
|
|
174
|
-
highest_bump="major"
|
|
175
|
-
;;
|
|
176
|
-
"minor")
|
|
177
|
-
((minor_count++))
|
|
178
|
-
if [[ "$highest_bump" != "major" ]]; then
|
|
179
|
-
highest_bump="minor"
|
|
180
|
-
fi
|
|
181
|
-
;;
|
|
182
|
-
"patch")
|
|
183
|
-
((patch_count++))
|
|
184
|
-
if [[ "$highest_bump" == "none" ]]; then
|
|
185
|
-
highest_bump="patch"
|
|
186
|
-
fi
|
|
187
|
-
;;
|
|
188
|
-
esac
|
|
189
|
-
done
|
|
190
|
-
|
|
191
|
-
log_info "Bump analysis summary:"
|
|
192
|
-
log_info " - Major changes: $major_count"
|
|
193
|
-
log_info " - Minor changes: $minor_count"
|
|
194
|
-
log_info " - Patch changes: $patch_count"
|
|
195
|
-
log_info " - Overall recommendation: $highest_bump"
|
|
196
|
-
|
|
197
|
-
echo "$highest_bump"
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
# Main execution
|
|
201
|
-
main() {
|
|
202
|
-
local commit_range="$COMMIT_RANGE"
|
|
203
|
-
|
|
204
|
-
log_info "Analyzing commits in range: $commit_range"
|
|
205
|
-
|
|
206
|
-
# Validate git repository
|
|
207
|
-
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
|
208
|
-
log_error "Not in a git repository"
|
|
209
|
-
exit 1
|
|
210
|
-
fi
|
|
211
|
-
|
|
212
|
-
# Get list of commits in range
|
|
213
|
-
local commits
|
|
214
|
-
if ! commits=($(git rev-list --reverse "$commit_range" 2>/dev/null)); then
|
|
215
|
-
log_warning "No commits found in range: $commit_range"
|
|
216
|
-
echo "none"
|
|
217
|
-
exit 0
|
|
218
|
-
fi
|
|
219
|
-
|
|
220
|
-
if [[ ${#commits[@]} -eq 0 ]]; then
|
|
221
|
-
log_warning "No commits to analyze"
|
|
222
|
-
echo "none"
|
|
223
|
-
exit 0
|
|
224
|
-
fi
|
|
225
|
-
|
|
226
|
-
# Filter out merge commits and automated commits
|
|
227
|
-
local filtered_commits=()
|
|
228
|
-
for commit in "${commits[@]}"; do
|
|
229
|
-
local commit_subject
|
|
230
|
-
commit_subject=$(git log --format="%s" -n 1 "$commit")
|
|
231
|
-
|
|
232
|
-
# Skip merge commits
|
|
233
|
-
if echo "$commit_subject" | grep -qE "^Merge (branch|pull request|remote-tracking branch)"; then
|
|
234
|
-
log_debug "Skipping merge commit: $commit"
|
|
235
|
-
continue
|
|
236
|
-
fi
|
|
237
|
-
|
|
238
|
-
# Skip automated commits (version bumps, changelog updates)
|
|
239
|
-
if echo "$commit_subject" | grep -qE "^(chore: bump version|chore: update changelog|Automated|Auto-update)"; then
|
|
240
|
-
log_debug "Skipping automated commit: $commit"
|
|
241
|
-
continue
|
|
242
|
-
fi
|
|
243
|
-
|
|
244
|
-
# Skip commits that only modify ignored files
|
|
245
|
-
local commit_files
|
|
246
|
-
commit_files=$(git diff-tree --no-commit-id --name-only -r "$commit" 2>/dev/null || echo "")
|
|
247
|
-
|
|
248
|
-
local has_significant_files=false
|
|
249
|
-
while IFS= read -r file; do
|
|
250
|
-
[[ -z "$file" ]] && continue
|
|
251
|
-
|
|
252
|
-
# Skip if only changelog, version files, or workflow files changed
|
|
253
|
-
if ! echo "$file" | grep -qE "^(CHANGELOG\.md|lib/.*version\.rb|package\.json|\.github/workflows/)$"; then
|
|
254
|
-
has_significant_files=true
|
|
255
|
-
break
|
|
256
|
-
fi
|
|
257
|
-
done <<< "$commit_files"
|
|
258
|
-
|
|
259
|
-
if [[ "$has_significant_files" == "true" ]]; then
|
|
260
|
-
filtered_commits+=("$commit")
|
|
261
|
-
else
|
|
262
|
-
log_debug "Skipping commit with only version/changelog files: $commit"
|
|
263
|
-
fi
|
|
264
|
-
done
|
|
265
|
-
|
|
266
|
-
if [[ ${#filtered_commits[@]} -eq 0 ]]; then
|
|
267
|
-
log_info "No significant commits found after filtering"
|
|
268
|
-
echo "none"
|
|
269
|
-
exit 0
|
|
270
|
-
fi
|
|
271
|
-
|
|
272
|
-
log_info "Analyzing ${#filtered_commits[@]} significant commits (filtered from ${#commits[@]} total)"
|
|
273
|
-
|
|
274
|
-
# Determine the appropriate version bump
|
|
275
|
-
determine_overall_bump "${filtered_commits[@]}"
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
# Show usage if requested
|
|
279
|
-
if [[ "${1:-}" == "--help" ]] || [[ "${1:-}" == "-h" ]]; then
|
|
280
|
-
cat << EOF
|
|
281
|
-
Commit Analysis Script for Automated Version Bumping
|
|
282
|
-
|
|
283
|
-
USAGE:
|
|
284
|
-
$0 [commit-range]
|
|
285
|
-
|
|
286
|
-
ARGUMENTS:
|
|
287
|
-
commit-range Git commit range to analyze (default: HEAD~1..HEAD)
|
|
288
|
-
|
|
289
|
-
OUTPUT:
|
|
290
|
-
patch Bug fixes, documentation, small improvements
|
|
291
|
-
minor New features, enhancements
|
|
292
|
-
major Breaking changes, major refactors
|
|
293
|
-
none No version bump needed
|
|
294
|
-
|
|
295
|
-
EXAMPLES:
|
|
296
|
-
$0 # Analyze last commit
|
|
297
|
-
$0 HEAD~5..HEAD # Analyze last 5 commits
|
|
298
|
-
$0 v1.0.0..HEAD # Analyze since last tag
|
|
299
|
-
|
|
300
|
-
ENVIRONMENT:
|
|
301
|
-
DEBUG=true # Enable debug output
|
|
302
|
-
|
|
303
|
-
CONVENTIONAL COMMIT PATTERNS:
|
|
304
|
-
feat:, feature:, add: → minor
|
|
305
|
-
fix:, bug:, patch: → patch
|
|
306
|
-
BREAKING CHANGE, breaking: → major
|
|
307
|
-
chore:, docs:, style: → patch
|
|
308
|
-
EOF
|
|
309
|
-
exit 0
|
|
310
|
-
fi
|
|
311
|
-
|
|
312
|
-
# Execute main function
|
|
313
|
-
main "$@"
|
|
3
|
+
# ============================================================================
|
|
4
|
+
# WRAPPER: This script forwards to scripts/utils/analyze-commits
|
|
5
|
+
#
|
|
6
|
+
# The canonical location is scripts/utils/analyze-commits. This wrapper exists
|
|
7
|
+
# for backward compatibility with existing workflows.
|
|
8
|
+
# ============================================================================
|
|
9
|
+
|
|
10
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
11
|
+
exec "$SCRIPT_DIR/utils/analyze-commits" "$@"
|
data/scripts/bin/build
CHANGED
|
@@ -17,27 +17,6 @@ source "$LIB_DIR/validation.sh"
|
|
|
17
17
|
source "$LIB_DIR/version.sh"
|
|
18
18
|
source "$LIB_DIR/gem.sh"
|
|
19
19
|
|
|
20
|
-
# Parse arguments
|
|
21
|
-
while [[ $# -gt 0 ]]; do
|
|
22
|
-
case $1 in
|
|
23
|
-
--dry-run)
|
|
24
|
-
export DRY_RUN=true
|
|
25
|
-
shift
|
|
26
|
-
;;
|
|
27
|
-
--verbose)
|
|
28
|
-
export VERBOSE=true
|
|
29
|
-
shift
|
|
30
|
-
;;
|
|
31
|
-
--help|-h)
|
|
32
|
-
show_usage
|
|
33
|
-
exit 0
|
|
34
|
-
;;
|
|
35
|
-
*)
|
|
36
|
-
error "Unknown option: $1 (use --help for usage)"
|
|
37
|
-
;;
|
|
38
|
-
esac
|
|
39
|
-
done
|
|
40
|
-
|
|
41
20
|
# Show usage
|
|
42
21
|
show_usage() {
|
|
43
22
|
cat << EOF
|
|
@@ -58,7 +37,7 @@ OPTIONS:
|
|
|
58
37
|
EXAMPLES:
|
|
59
38
|
./scripts/bin/build # Build gem with current version
|
|
60
39
|
./scripts/bin/build --dry-run # Preview what would be built
|
|
61
|
-
./scripts/build --verbose # Build with debug output
|
|
40
|
+
./scripts/bin/build --verbose # Build with debug output
|
|
62
41
|
|
|
63
42
|
ENVIRONMENT VARIABLES:
|
|
64
43
|
DRY_RUN=true Enable dry run mode
|
|
@@ -71,6 +50,27 @@ For full release workflow, use: ./scripts/release
|
|
|
71
50
|
EOF
|
|
72
51
|
}
|
|
73
52
|
|
|
53
|
+
# Parse arguments
|
|
54
|
+
while [[ $# -gt 0 ]]; do
|
|
55
|
+
case $1 in
|
|
56
|
+
--dry-run)
|
|
57
|
+
export DRY_RUN=true
|
|
58
|
+
shift
|
|
59
|
+
;;
|
|
60
|
+
--verbose)
|
|
61
|
+
export VERBOSE=true
|
|
62
|
+
shift
|
|
63
|
+
;;
|
|
64
|
+
--help|-h)
|
|
65
|
+
show_usage
|
|
66
|
+
exit 0
|
|
67
|
+
;;
|
|
68
|
+
*)
|
|
69
|
+
error "Unknown option: $1 (use --help for usage)"
|
|
70
|
+
;;
|
|
71
|
+
esac
|
|
72
|
+
done
|
|
73
|
+
|
|
74
74
|
# Main build workflow
|
|
75
75
|
main() {
|
|
76
76
|
print_header "🔨 Gem Build"
|