jekyll-theme-zer0 0.8.1 โ†’ 0.10.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.
@@ -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/bin/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/bin/release # Patch release (0.6.0 โ†’ 0.6.1)
46
+ ./scripts/bin/release minor # Minor release (0.6.0 โ†’ 0.7.0)
47
+ ./scripts/bin/release major --dry-run # Preview major release
48
+ ./scripts/bin/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 "$@"
data/scripts/bin/test ADDED
@@ -0,0 +1,203 @@
1
+ #!/bin/bash
2
+
3
+ # Unified test runner for zer0-mistakes Jekyll theme
4
+ # Usage: ./scripts/bin/test [options]
5
+ #
6
+ # Runs all test suites: library tests, theme tests, and integration tests.
7
+
8
+ set -euo pipefail
9
+
10
+ # Get script and library directories
11
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12
+ SCRIPTS_ROOT="$SCRIPT_DIR/.."
13
+ LIB_DIR="$SCRIPTS_ROOT/lib"
14
+ TEST_DIR="$SCRIPTS_ROOT/test"
15
+
16
+ # Source common library for logging
17
+ source "$LIB_DIR/common.sh"
18
+
19
+ # Aliases for consistent function naming
20
+ log_info() { info "$@"; }
21
+ log_success() { success "$@"; }
22
+ log_warning() { warn "$@"; }
23
+ log_error() { echo -e "${RED}[ERROR]${NC} $@" >&2; }
24
+
25
+ # Show usage
26
+ show_usage() {
27
+ cat << EOF
28
+ ๐Ÿงช Unified Test Runner for zer0-mistakes
29
+
30
+ USAGE:
31
+ ./scripts/bin/test [OPTIONS] [TEST_SUITE]
32
+
33
+ TEST SUITES:
34
+ all Run all tests (default)
35
+ lib Run library unit tests only
36
+ theme Run theme validation tests only
37
+ integration Run integration tests only
38
+
39
+ OPTIONS:
40
+ --verbose, -v Show detailed test output
41
+ --dry-run Preview what tests would run
42
+ --help, -h Show this help message
43
+
44
+ EXAMPLES:
45
+ ./scripts/bin/test # Run all tests
46
+ ./scripts/bin/test lib # Run library tests only
47
+ ./scripts/bin/test --verbose # Run all tests with verbose output
48
+
49
+ TEST LOCATIONS:
50
+ Library tests: scripts/test/lib/
51
+ Theme tests: scripts/test/theme/
52
+ Integration tests: scripts/test/integration/
53
+ EOF
54
+ }
55
+
56
+ # Parse arguments
57
+ TEST_SUITE="all"
58
+ for arg in "$@"; do
59
+ case $arg in
60
+ --help|-h)
61
+ show_usage
62
+ exit 0
63
+ ;;
64
+ --verbose|-v)
65
+ export VERBOSE=true
66
+ ;;
67
+ --dry-run)
68
+ export DRY_RUN=true
69
+ ;;
70
+ all|lib|theme|integration)
71
+ TEST_SUITE="$arg"
72
+ ;;
73
+ *)
74
+ error "Unknown option: $arg (use --help for usage)"
75
+ ;;
76
+ esac
77
+ done
78
+
79
+ # Track test results
80
+ TOTAL_TESTS=0
81
+ TOTAL_PASSED=0
82
+ TOTAL_FAILED=0
83
+
84
+ # Run library tests
85
+ run_lib_tests() {
86
+ log_info "Running library unit tests..."
87
+
88
+ if [[ -f "$TEST_DIR/lib/run_tests.sh" ]]; then
89
+ # Use current bash interpreter to ensure bash 4+ features work
90
+ if "$BASH" "$TEST_DIR/lib/run_tests.sh"; then
91
+ log_success "Library tests passed"
92
+ ((TOTAL_PASSED++)) || true
93
+ else
94
+ log_error "Library tests failed"
95
+ ((TOTAL_FAILED++)) || true
96
+ fi
97
+ ((TOTAL_TESTS++)) || true
98
+ else
99
+ log_warning "Library test runner not found at $TEST_DIR/lib/run_tests.sh"
100
+ fi
101
+ }
102
+
103
+ # Run theme validation tests
104
+ run_theme_tests() {
105
+ log_info "Running theme validation tests..."
106
+
107
+ # Check for theme test script (will be migrated here)
108
+ if [[ -f "$TEST_DIR/theme/validate" ]]; then
109
+ if "$TEST_DIR/theme/validate"; then
110
+ log_success "Theme tests passed"
111
+ ((TOTAL_PASSED++)) || true
112
+ else
113
+ log_error "Theme tests failed"
114
+ ((TOTAL_FAILED++)) || true
115
+ fi
116
+ ((TOTAL_TESTS++)) || true
117
+ else
118
+ # Fall back to legacy test.sh in scripts root
119
+ if [[ -f "$SCRIPTS_ROOT/test.sh" ]]; then
120
+ log_warning "Using legacy test.sh (will be migrated to test/theme/)"
121
+ if "$SCRIPTS_ROOT/test.sh"; then
122
+ log_success "Theme tests passed"
123
+ ((TOTAL_PASSED++)) || true
124
+ else
125
+ log_error "Theme tests failed"
126
+ ((TOTAL_FAILED++)) || true
127
+ fi
128
+ ((TOTAL_TESTS++)) || true
129
+ else
130
+ log_warning "Theme tests not found"
131
+ fi
132
+ fi
133
+ }
134
+
135
+ # Run integration tests
136
+ run_integration_tests() {
137
+ log_info "Running integration tests..."
138
+
139
+ local found_tests=false
140
+
141
+ for test_file in "$TEST_DIR/integration"/*; do
142
+ if [[ -f "$test_file" && -x "$test_file" ]]; then
143
+ found_tests=true
144
+ local test_name
145
+ test_name=$(basename "$test_file")
146
+ log_info "Running integration test: $test_name"
147
+
148
+ if "$test_file"; then
149
+ log_success "$test_name passed"
150
+ ((TOTAL_PASSED++)) || true
151
+ else
152
+ log_error "$test_name failed"
153
+ ((TOTAL_FAILED++)) || true
154
+ fi
155
+ ((TOTAL_TESTS++)) || true
156
+ fi
157
+ done
158
+
159
+ if [[ "$found_tests" == "false" ]]; then
160
+ log_warning "No integration tests found in $TEST_DIR/integration/"
161
+ fi
162
+ }
163
+
164
+ # Main execution
165
+ log_info "๐Ÿงช Starting test suite: $TEST_SUITE"
166
+ echo ""
167
+
168
+ case $TEST_SUITE in
169
+ all)
170
+ run_lib_tests
171
+ echo ""
172
+ run_theme_tests
173
+ echo ""
174
+ run_integration_tests
175
+ ;;
176
+ lib)
177
+ run_lib_tests
178
+ ;;
179
+ theme)
180
+ run_theme_tests
181
+ ;;
182
+ integration)
183
+ run_integration_tests
184
+ ;;
185
+ esac
186
+
187
+ # Summary
188
+ echo ""
189
+ echo "โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”"
190
+ log_info "Test Summary"
191
+ echo "โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”"
192
+ echo " Total test suites: $TOTAL_TESTS"
193
+ echo " Passed: $TOTAL_PASSED"
194
+ echo " Failed: $TOTAL_FAILED"
195
+ echo "โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”"
196
+
197
+ if [[ $TOTAL_FAILED -gt 0 ]]; then
198
+ log_error "Some tests failed!"
199
+ exit 1
200
+ else
201
+ log_success "All tests passed!"
202
+ exit 0
203
+ fi