jekyll-theme-zer0 0.7.2 → 0.8.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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +72 -0
  3. data/README.md +33 -4
  4. data/_plugins/preview_image_generator.rb +258 -0
  5. data/_plugins/theme_version.rb +88 -0
  6. data/assets/images/previews/git-workflow-best-practices-for-modern-teams.png +0 -0
  7. data/scripts/README.md +443 -0
  8. data/scripts/analyze-commits.sh +313 -0
  9. data/scripts/build +115 -0
  10. data/scripts/build.sh +33 -0
  11. data/scripts/build.sh.legacy +174 -0
  12. data/scripts/example-usage.sh +102 -0
  13. data/scripts/fix-markdown-format.sh +265 -0
  14. data/scripts/gem-publish.sh +42 -0
  15. data/scripts/gem-publish.sh.legacy +700 -0
  16. data/scripts/generate-preview-images.sh +846 -0
  17. data/scripts/install-preview-generator.sh +531 -0
  18. data/scripts/lib/README.md +263 -0
  19. data/scripts/lib/changelog.sh +313 -0
  20. data/scripts/lib/common.sh +154 -0
  21. data/scripts/lib/gem.sh +226 -0
  22. data/scripts/lib/git.sh +205 -0
  23. data/scripts/lib/preview_generator.py +646 -0
  24. data/scripts/lib/test/run_tests.sh +140 -0
  25. data/scripts/lib/test/test_changelog.sh +87 -0
  26. data/scripts/lib/test/test_gem.sh +68 -0
  27. data/scripts/lib/test/test_git.sh +82 -0
  28. data/scripts/lib/test/test_validation.sh +72 -0
  29. data/scripts/lib/test/test_version.sh +96 -0
  30. data/scripts/lib/validation.sh +139 -0
  31. data/scripts/lib/version.sh +178 -0
  32. data/scripts/release +240 -0
  33. data/scripts/release.sh +33 -0
  34. data/scripts/release.sh.legacy +342 -0
  35. data/scripts/setup.sh +155 -0
  36. data/scripts/test-auto-version.sh +260 -0
  37. data/scripts/test-mermaid.sh +251 -0
  38. data/scripts/test.sh +156 -0
  39. data/scripts/version.sh +152 -0
  40. metadata +37 -1
@@ -0,0 +1,178 @@
1
+ #!/bin/bash
2
+
3
+ # Version management library for zer0-mistakes release scripts
4
+ # Provides version reading, calculation, and update functions
5
+
6
+ # Source common utilities
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ source "$SCRIPT_DIR/common.sh"
9
+
10
+ # Version file paths (check if already defined)
11
+ if [[ -z "${VERSION_FILE:-}" ]]; then
12
+ readonly VERSION_FILE="lib/jekyll-theme-zer0/version.rb"
13
+ fi
14
+ if [[ -z "${PACKAGE_JSON:-}" ]]; then
15
+ readonly PACKAGE_JSON="package.json"
16
+ fi
17
+
18
+ # Get current version from version.rb
19
+ get_current_version() {
20
+ debug "Reading current version from $VERSION_FILE..."
21
+
22
+ local version
23
+ version=$(grep -o 'VERSION = "[^"]*"' "$VERSION_FILE" | sed 's/VERSION = "\(.*\)"/\1/')
24
+
25
+ if [[ -z "$version" ]]; then
26
+ error "Could not read version from $VERSION_FILE"
27
+ fi
28
+
29
+ debug "Current version: $version"
30
+ echo "$version"
31
+ }
32
+
33
+ # Validate version format (semantic versioning)
34
+ validate_version_format() {
35
+ local version="$1"
36
+
37
+ if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
38
+ error "Invalid version format: $version (expected: X.Y.Z)"
39
+ fi
40
+
41
+ debug "✓ Version format valid: $version"
42
+ }
43
+
44
+ # Calculate new version based on bump type
45
+ calculate_new_version() {
46
+ local current_version="$1"
47
+ local bump_type="$2"
48
+
49
+ debug "Calculating new version: $current_version → $bump_type bump"
50
+
51
+ validate_version_format "$current_version"
52
+
53
+ IFS='.' read -ra VERSION_PARTS <<< "$current_version"
54
+ local major=${VERSION_PARTS[0]}
55
+ local minor=${VERSION_PARTS[1]}
56
+ local patch=${VERSION_PARTS[2]}
57
+
58
+ case "$bump_type" in
59
+ major)
60
+ major=$((major + 1))
61
+ minor=0
62
+ patch=0
63
+ ;;
64
+ minor)
65
+ minor=$((minor + 1))
66
+ patch=0
67
+ ;;
68
+ patch)
69
+ patch=$((patch + 1))
70
+ ;;
71
+ *)
72
+ error "Invalid bump type: $bump_type (expected: major, minor, or patch)"
73
+ ;;
74
+ esac
75
+
76
+ local new_version="$major.$minor.$patch"
77
+ debug "New version: $new_version"
78
+ echo "$new_version"
79
+ }
80
+
81
+ # Update version in version.rb
82
+ update_version_rb() {
83
+ local new_version="$1"
84
+
85
+ debug "Updating $VERSION_FILE to $new_version..."
86
+
87
+ if [[ "$DRY_RUN" == "true" ]]; then
88
+ info "[DRY RUN] Would update $VERSION_FILE to $new_version"
89
+ return 0
90
+ fi
91
+
92
+ # Create backup
93
+ cp "$VERSION_FILE" "${VERSION_FILE}.bak"
94
+
95
+ # Update version
96
+ sed -i.tmp "s/VERSION = \".*\"/VERSION = \"$new_version\"/" "$VERSION_FILE"
97
+ rm -f "${VERSION_FILE}.tmp"
98
+
99
+ # Verify update
100
+ local updated_version
101
+ updated_version=$(get_current_version)
102
+
103
+ if [[ "$updated_version" != "$new_version" ]]; then
104
+ # Restore backup
105
+ mv "${VERSION_FILE}.bak" "$VERSION_FILE"
106
+ error "Failed to update version in $VERSION_FILE"
107
+ fi
108
+
109
+ rm -f "${VERSION_FILE}.bak"
110
+ debug "✓ Updated $VERSION_FILE"
111
+ }
112
+
113
+ # Update version in package.json
114
+ update_package_json() {
115
+ local new_version="$1"
116
+
117
+ if [[ ! -f "$PACKAGE_JSON" ]]; then
118
+ debug "package.json not found, skipping"
119
+ return 0
120
+ fi
121
+
122
+ debug "Updating $PACKAGE_JSON to $new_version..."
123
+
124
+ if [[ "$DRY_RUN" == "true" ]]; then
125
+ info "[DRY RUN] Would update $PACKAGE_JSON to $new_version"
126
+ return 0
127
+ fi
128
+
129
+ # Update using jq
130
+ jq ".version = \"$new_version\"" "$PACKAGE_JSON" > "${PACKAGE_JSON}.tmp"
131
+ mv "${PACKAGE_JSON}.tmp" "$PACKAGE_JSON"
132
+
133
+ debug "✓ Updated $PACKAGE_JSON"
134
+ }
135
+
136
+ # Update version in all files
137
+ update_version_files() {
138
+ local new_version="$1"
139
+
140
+ step "Updating version to $new_version..."
141
+
142
+ validate_version_format "$new_version"
143
+
144
+ update_version_rb "$new_version"
145
+ update_package_json "$new_version"
146
+
147
+ success "Version files updated to $new_version"
148
+ }
149
+
150
+ # Compare two versions (returns 0 if v1 < v2, 1 if v1 >= v2)
151
+ version_less_than() {
152
+ local v1="$1"
153
+ local v2="$2"
154
+
155
+ # Convert versions to comparable format
156
+ local v1_comparable=$(echo "$v1" | awk -F. '{ printf("%d%03d%03d\n", $1,$2,$3); }')
157
+ local v2_comparable=$(echo "$v2" | awk -F. '{ printf("%d%03d%03d\n", $1,$2,$3); }')
158
+
159
+ [[ $v1_comparable -lt $v2_comparable ]]
160
+ }
161
+
162
+ # Get version from git tag
163
+ get_version_from_tag() {
164
+ local tag="$1"
165
+
166
+ # Remove 'v' prefix if present
167
+ echo "$tag" | sed 's/^v//'
168
+ }
169
+
170
+ # Export functions
171
+ export -f get_current_version
172
+ export -f validate_version_format
173
+ export -f calculate_new_version
174
+ export -f update_version_rb
175
+ export -f update_package_json
176
+ export -f update_version_files
177
+ export -f version_less_than
178
+ export -f get_version_from_tag
data/scripts/release ADDED
@@ -0,0 +1,240 @@
1
+ #!/bin/bash
2
+
3
+ # Simplified release command for zer0-mistakes Jekyll theme
4
+ # Usage: ./scripts/release [patch|minor|major] [options]
5
+ #
6
+ # This replaces the complex gem-publish.sh with a clean, library-based approach.
7
+
8
+ set -euo pipefail
9
+
10
+ # Get script and library directories
11
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12
+ LIB_DIR="$SCRIPT_DIR/lib"
13
+
14
+ # Source all required libraries
15
+ source "$LIB_DIR/common.sh"
16
+ source "$LIB_DIR/validation.sh"
17
+ source "$LIB_DIR/version.sh"
18
+ source "$LIB_DIR/git.sh"
19
+ source "$LIB_DIR/changelog.sh"
20
+ source "$LIB_DIR/gem.sh"
21
+
22
+ # Show usage function
23
+ show_usage() {
24
+ cat << EOF
25
+ 🚀 Simplified Release Command for zer0-mistakes
26
+
27
+ USAGE:
28
+ ./scripts/release [VERSION_TYPE] [OPTIONS]
29
+
30
+ VERSION TYPES:
31
+ patch Bump patch version (0.0.X) - Bug fixes (default)
32
+ minor Bump minor version (0.X.0) - New features
33
+ major Bump major version (X.0.0) - Breaking changes
34
+
35
+ OPTIONS:
36
+ --dry-run Preview changes without executing
37
+ --skip-tests Skip running test suite
38
+ --skip-publish Build but don't publish to RubyGems
39
+ --no-github-release Skip creating GitHub release
40
+ --non-interactive Run without confirmation prompts
41
+ --verbose Show detailed debug output
42
+ --help, -h Show this help message
43
+
44
+ EXAMPLES:
45
+ ./scripts/release # Patch release (0.6.0 → 0.6.1)
46
+ ./scripts/release minor # Minor release (0.6.0 → 0.7.0)
47
+ ./scripts/release major --dry-run # Preview major release
48
+ ./scripts/release patch --skip-tests # Quick release without tests
49
+
50
+ ENVIRONMENT VARIABLES:
51
+ DRY_RUN=true Enable dry run mode
52
+ INTERACTIVE=false Disable confirmation prompts
53
+ VERBOSE=true Enable debug output
54
+
55
+ WORKFLOW:
56
+ 1. Validate environment
57
+ 2. Calculate new version
58
+ 3. Generate changelog from commits
59
+ 4. Update version files
60
+ 5. Run tests (unless --skip-tests)
61
+ 6. Build gem
62
+ 7. Commit and tag
63
+ 8. Publish to RubyGems (unless --skip-publish)
64
+ 9. Create GitHub release (unless --no-github-release)
65
+ 10. Push changes to repository
66
+
67
+ For more information, see: scripts/lib/README.md
68
+ EOF
69
+ }
70
+
71
+ # Default configuration
72
+ VERSION_TYPE="patch"
73
+ SKIP_TESTS=false
74
+ SKIP_PUBLISH=false
75
+ SKIP_GITHUB_RELEASE=false
76
+ SHOW_HELP=false
77
+
78
+ # Parse arguments
79
+ for arg in "$@"; do
80
+ case $arg in
81
+ --help|-h)
82
+ SHOW_HELP=true
83
+ ;;
84
+ patch|minor|major)
85
+ VERSION_TYPE="$arg"
86
+ ;;
87
+ esac
88
+ done
89
+
90
+ # Show help if requested
91
+ if [[ "$SHOW_HELP" == "true" ]]; then
92
+ show_usage
93
+ exit 0
94
+ fi
95
+
96
+ # Parse remaining arguments
97
+ while [[ $# -gt 0 ]]; do
98
+ case $1 in
99
+ patch|minor|major)
100
+ # Already handled above
101
+ shift
102
+ ;;
103
+ --help|-h)
104
+ # Already handled above
105
+ shift
106
+ ;;
107
+ --dry-run)
108
+ export DRY_RUN=true
109
+ shift
110
+ ;;
111
+ --skip-tests)
112
+ SKIP_TESTS=true
113
+ shift
114
+ ;;
115
+ --skip-publish)
116
+ SKIP_PUBLISH=true
117
+ shift
118
+ ;;
119
+ --no-github-release)
120
+ SKIP_GITHUB_RELEASE=true
121
+ shift
122
+ ;;
123
+ --non-interactive)
124
+ export INTERACTIVE=false
125
+ shift
126
+ ;;
127
+ --verbose)
128
+ export VERBOSE=true
129
+ shift
130
+ ;;
131
+ *)
132
+ error "Unknown option: $1 (use --help for usage)"
133
+ ;;
134
+ esac
135
+ done
136
+
137
+ # Main release workflow
138
+ main() {
139
+ print_header "🚀 Release Automation"
140
+
141
+ # Show configuration
142
+ info "Version type: $VERSION_TYPE"
143
+ info "Dry run: ${DRY_RUN:-false}"
144
+ info "Interactive: ${INTERACTIVE:-true}"
145
+ echo ""
146
+
147
+ # Step 1: Validate environment
148
+ validate_environment "$SKIP_PUBLISH" "$SKIP_GITHUB_RELEASE"
149
+
150
+ # Step 2: Version calculation
151
+ step "Calculating new version..."
152
+ local current_version
153
+ current_version=$(get_current_version)
154
+ info "Current version: $current_version"
155
+
156
+ local new_version
157
+ new_version=$(calculate_new_version "$current_version" "$VERSION_TYPE")
158
+ info "New version: $new_version"
159
+
160
+ # Confirm before proceeding
161
+ if [[ "$INTERACTIVE" == "true" ]] && [[ "$DRY_RUN" != "true" ]]; then
162
+ echo ""
163
+ if ! confirm "Proceed with release $current_version → $new_version?"; then
164
+ warn "Release cancelled by user"
165
+ exit 0
166
+ fi
167
+ fi
168
+ echo ""
169
+
170
+ # Step 3: Generate changelog
171
+ step "Generating changelog..."
172
+ local last_tag
173
+ last_tag=$(get_last_version_tag)
174
+ generate_changelog "$new_version" "$last_tag" "HEAD"
175
+ echo ""
176
+
177
+ # Step 4: Update version files
178
+ update_version_files "$new_version"
179
+ echo ""
180
+
181
+ # Step 5: Run tests
182
+ if [[ "$SKIP_TESTS" != "true" ]]; then
183
+ run_tests
184
+ echo ""
185
+ else
186
+ warn "Skipping tests (--skip-tests specified)"
187
+ echo ""
188
+ fi
189
+
190
+ # Step 6: Build gem
191
+ build_gem "$new_version"
192
+ echo ""
193
+
194
+ # Step 7: Commit and tag
195
+ commit_and_tag "$new_version"
196
+ echo ""
197
+
198
+ # Step 8: Publish gem
199
+ if [[ "$SKIP_PUBLISH" != "true" ]]; then
200
+ publish_gem "$new_version"
201
+ echo ""
202
+ else
203
+ warn "Skipping RubyGems publication (--skip-publish specified)"
204
+ echo ""
205
+ fi
206
+
207
+ # Step 9: Create GitHub release
208
+ if [[ "$SKIP_GITHUB_RELEASE" != "true" ]]; then
209
+ create_github_release "$new_version"
210
+ echo ""
211
+ else
212
+ warn "Skipping GitHub release (--no-github-release specified)"
213
+ echo ""
214
+ fi
215
+
216
+ # Step 10: Push changes
217
+ push_changes
218
+ echo ""
219
+
220
+ # Step 11: Cleanup
221
+ cleanup_gem_files "$new_version"
222
+ echo ""
223
+
224
+ # Success summary
225
+ print_header "✅ Release Complete!"
226
+
227
+ print_summary "Release $new_version" \
228
+ "Version: $current_version → $new_version" \
229
+ "Type: $VERSION_TYPE bump" \
230
+ "Tag: v$new_version" \
231
+ "" \
232
+ "📦 RubyGems: https://rubygems.org/gems/jekyll-theme-zer0/versions/$new_version" \
233
+ "🏷️ GitHub: https://github.com/bamr87/zer0-mistakes/releases/tag/v$new_version" \
234
+ "📂 Repository: https://github.com/bamr87/zer0-mistakes"
235
+
236
+ success "Release workflow completed successfully!"
237
+ }
238
+
239
+ # Run main function
240
+ main "$@"
@@ -0,0 +1,33 @@
1
+ #!/bin/bash
2
+
3
+ # DEPRECATED: This script is deprecated and will be removed in v0.8.0
4
+ # Please use the new simplified release command instead.
5
+
6
+ set -e
7
+
8
+ # Colors
9
+ YELLOW='\033[1;33m'
10
+ CYAN='\033[0;36m'
11
+ NC='\033[0m'
12
+
13
+ echo -e "${YELLOW}╔════════════════════════════════════════════════════════════╗${NC}"
14
+ echo -e "${YELLOW}║ ⚠️ DEPRECATION WARNING ║${NC}"
15
+ echo -e "${YELLOW}╚════════════════════════════════════════════════════════════╝${NC}"
16
+ echo ""
17
+ echo -e "${YELLOW}This script (release.sh) is deprecated and will be removed in v0.8.0${NC}"
18
+ echo ""
19
+ echo -e "Please use the new simplified command instead:"
20
+ echo -e " ${CYAN}./scripts/release${NC} [patch|minor|major] [options]"
21
+ echo ""
22
+ echo -e "The new command provides the same functionality with:"
23
+ echo -e " ✅ Simpler interface"
24
+ echo -e " ✅ Better documentation"
25
+ echo -e " ✅ Modular architecture"
26
+ echo -e " ✅ Full test coverage"
27
+ echo ""
28
+ echo -e "${YELLOW}Redirecting to new command in 3 seconds...${NC}"
29
+ sleep 3
30
+ echo ""
31
+
32
+ # Redirect to new command
33
+ exec "$(dirname "$0")/release" "$@"