mirror of
https://github.com/kjanat/articulate-parser.git
synced 2026-10-12 23:35:27 +02:00
chore: adopt remote dprint config, tidy examples
Extend dprint from a shared remote config and add the prettier and exec plugins, formatting TOML via a new tombi.toml instead of golangci-lint fmt. Taskfile.yml, scripts/build.sh, and html_styles.css pick up the resulting reformat. Exporter examples now write to a temp dir and clean up after themselves instead of leaving output.md/.docx/.html in the repo. Drop the stray internal/exporters/output.docx and ignore internal/exporters/output.* going forward.
This commit is contained in:
+13
-37
@@ -1,43 +1,19 @@
|
||||
{
|
||||
"$schema": "https://dprint.dev/schemas/v0.json",
|
||||
|
||||
"useTabs": true,
|
||||
|
||||
"typescript": {},
|
||||
"json": {},
|
||||
"markdown": {},
|
||||
"toml": {},
|
||||
"dockerfile": {},
|
||||
"oxc": {},
|
||||
"ruff": {},
|
||||
"jupyter": {},
|
||||
"malva": {},
|
||||
"markup": {},
|
||||
"yaml": {},
|
||||
"extends": "https://github.com/kjanat/kjanat/raw/8cb7b67/configs/dprint.remote.json",
|
||||
"excludes": ["**/node_modules", "**/.venv", "**/bun.lock*"],
|
||||
"plugins": [
|
||||
"npm:@dprint/prettier@0.70.0/plugin.json@97c0dccf54ed5b7343e7a3f6418e77bd80afcd2b74beed3a632689d47e392ddc",
|
||||
"npm:@dprint/exec@0.7.3/plugin.json@704701df449dd7e942a71144773778ac529d68c2e4657bfc236d393b898b9a67",
|
||||
],
|
||||
"markdown": { "associations": ["!README.md"] },
|
||||
"prettier": { "associations": ["README.md"], "useTabs": false },
|
||||
"exec": {
|
||||
"cwd": "${configDir}",
|
||||
"commands": [
|
||||
{
|
||||
"command": "golangci-lint fmt --config .golangci.yml --color never --stdin {{file_path}}",
|
||||
"exts": ["go"],
|
||||
"cacheKeyFiles": [".golangci.yml"],
|
||||
"stdin": true,
|
||||
},
|
||||
],
|
||||
"commands": [{
|
||||
"command": "bunx tombi format - --stdin-filename {{file_path}}",
|
||||
"exts": ["toml"],
|
||||
"cacheKeyFiles": ["tombi.toml"],
|
||||
}],
|
||||
},
|
||||
"excludes": ["**/node_modules", "**/*-lock.json"],
|
||||
"plugins": [
|
||||
"https://plugins.dprint.dev/typescript-0.95.13.wasm",
|
||||
"https://plugins.dprint.dev/json-0.21.1.wasm",
|
||||
"https://plugins.dprint.dev/markdown-0.20.0.wasm",
|
||||
"https://plugins.dprint.dev/toml-0.7.0.wasm",
|
||||
"https://plugins.dprint.dev/dockerfile-0.3.3.wasm",
|
||||
"https://plugins.dprint.dev/oxc-0.1.0.wasm",
|
||||
"https://plugins.dprint.dev/ruff-0.6.11.wasm",
|
||||
"https://plugins.dprint.dev/jupyter-0.2.1.wasm",
|
||||
"https://plugins.dprint.dev/g-plane/malva-v0.15.1.wasm",
|
||||
"https://plugins.dprint.dev/g-plane/markup_fmt-v0.25.3.wasm",
|
||||
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.1.wasm",
|
||||
"https://plugins.dprint.dev/exec-0.6.0.json@a054130d458f124f9b5c91484833828950723a5af3f8ff2bd1523bd47b83b364",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ output/
|
||||
outputs/
|
||||
articulate-sample.json
|
||||
test-output.*
|
||||
# Example test exports (defensive; tests now write to a temp dir)
|
||||
internal/exporters/output.*
|
||||
go-os-arch-matrix.csv
|
||||
test_godocx.go
|
||||
test_input.json
|
||||
|
||||
+17
-17
@@ -210,13 +210,13 @@ tasks:
|
||||
sh: gofmt -s -l .
|
||||
cmds:
|
||||
- |
|
||||
{{if ne .UNFORMATTED ""}}
|
||||
echo "❌ The following files need formatting:"
|
||||
echo "{{.UNFORMATTED}}"
|
||||
exit 1
|
||||
{{else}}
|
||||
echo "All files are properly formatted"
|
||||
{{end}}
|
||||
{{if ne .UNFORMATTED ""}}
|
||||
echo "❌ The following files need formatting:"
|
||||
echo "{{.UNFORMATTED}}"
|
||||
exit 1
|
||||
{{else}}
|
||||
echo "All files are properly formatted"
|
||||
{{end}}
|
||||
|
||||
lint:staticcheck:
|
||||
desc: Run staticcheck (install if needed)
|
||||
@@ -304,22 +304,22 @@ tasks:
|
||||
aliases: [db]
|
||||
cmds:
|
||||
- |
|
||||
docker build \
|
||||
--build-arg VERSION={{.VERSION}} \
|
||||
--build-arg BUILD_TIME={{.BUILD_TIME}} \
|
||||
--build-arg GIT_COMMIT={{.GIT_COMMIT}} \
|
||||
-t {{.APP_NAME}}:{{.VERSION}} \
|
||||
-t {{.APP_NAME}}:latest \
|
||||
.
|
||||
docker build \
|
||||
--build-arg VERSION={{.VERSION}} \
|
||||
--build-arg BUILD_TIME={{.BUILD_TIME}} \
|
||||
--build-arg GIT_COMMIT={{.GIT_COMMIT}} \
|
||||
-t {{.APP_NAME}}:{{.VERSION}} \
|
||||
-t {{.APP_NAME}}:latest \
|
||||
.
|
||||
- >
|
||||
echo "Docker image built: {{.APP_NAME}}:{{.VERSION}}"
|
||||
echo "Docker image built: {{.APP_NAME}}:{{.VERSION}}"
|
||||
|
||||
docker:build:dev:
|
||||
desc: Build development Docker image
|
||||
cmds:
|
||||
- docker build -f Dockerfile.dev -t {{.APP_NAME}}:dev .
|
||||
- >
|
||||
echo "Development Docker image built: {{.APP_NAME}}:dev"
|
||||
echo "Development Docker image built: {{.APP_NAME}}:dev"
|
||||
|
||||
docker:run:
|
||||
desc: Run Docker container
|
||||
@@ -426,7 +426,7 @@ tasks:
|
||||
- git tag -a v{{.VERSION}} -m "Release v{{.VERSION}}"
|
||||
- echo "Tagged v{{.VERSION}}"
|
||||
- >
|
||||
echo "Push with: git push origin v{{.VERSION}}"
|
||||
echo "Push with: git push origin v{{.VERSION}}"
|
||||
|
||||
# Documentation tasks
|
||||
docs:serve:
|
||||
|
||||
@@ -4,12 +4,25 @@ package exporters_test
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/kjanat/articulate-parser/internal/exporters"
|
||||
"github.com/kjanat/articulate-parser/internal/models"
|
||||
"github.com/kjanat/articulate-parser/internal/services"
|
||||
)
|
||||
|
||||
// tempOutput returns a path inside a fresh temp dir plus a cleanup func, so
|
||||
// example exports don't pollute the package source tree. Example functions
|
||||
// can't take *testing.T, so t.TempDir is unavailable here.
|
||||
func tempOutput(name string) (path string, cleanup func()) {
|
||||
dir, err := os.MkdirTemp("", "exporters-example-*")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
return filepath.Join(dir, name), func() { _ = os.RemoveAll(dir) }
|
||||
}
|
||||
|
||||
// ExampleNewFactory demonstrates creating an exporter factory.
|
||||
func ExampleNewFactory() {
|
||||
htmlCleaner := services.NewHTMLCleaner()
|
||||
@@ -69,7 +82,9 @@ func ExampleMarkdownExporter_Export() {
|
||||
}
|
||||
|
||||
// Export to markdown file
|
||||
err := exporter.Export(course, "output.md")
|
||||
out, cleanup := tempOutput("output.md")
|
||||
defer cleanup()
|
||||
err := exporter.Export(course, out)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -91,7 +106,9 @@ func ExampleDocxExporter_Export() {
|
||||
}
|
||||
|
||||
// Export to Word document
|
||||
err := exporter.Export(course, "output.docx")
|
||||
out, cleanup := tempOutput("output.docx")
|
||||
defer cleanup()
|
||||
err := exporter.Export(course, out)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -121,7 +138,9 @@ func ExampleHTMLExporter_Export() {
|
||||
}
|
||||
|
||||
// Export to HTML file
|
||||
err := exporter.Export(course, "output.html")
|
||||
out, cleanup := tempOutput("output.html")
|
||||
defer cleanup()
|
||||
err := exporter.Export(course, out)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
body {
|
||||
font-family:
|
||||
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
|
||||
Cantarell, sans-serif;
|
||||
-apple-system,
|
||||
BlinkMacSystemFont,
|
||||
"Segoe UI",
|
||||
Roboto,
|
||||
Oxygen,
|
||||
Ubuntu,
|
||||
Cantarell,
|
||||
sans-serif;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
max-width: 800px;
|
||||
|
||||
Binary file not shown.
+174
-174
@@ -20,7 +20,7 @@ DEFAULT_LDFLAGS="-s -w"
|
||||
|
||||
# Function to show help
|
||||
show_help() {
|
||||
cat <<'EOF'
|
||||
cat <<'EOF'
|
||||
articulate-parser Build Script (Bash)
|
||||
=====================================
|
||||
|
||||
@@ -106,129 +106,129 @@ EOF
|
||||
|
||||
# Function to show available Go build targets
|
||||
show_targets() {
|
||||
echo "Available Go Build Targets:"
|
||||
echo "=========================="
|
||||
echo
|
||||
if command -v go >/dev/null 2>&1; then
|
||||
echo "Getting targets from 'go tool dist list'..."
|
||||
echo
|
||||
echo "Available Go Build Targets:"
|
||||
echo "=========================="
|
||||
echo
|
||||
if command -v go >/dev/null 2>&1; then
|
||||
echo "Getting targets from 'go tool dist list'..."
|
||||
echo
|
||||
|
||||
# Get all targets and format them nicely
|
||||
local targets
|
||||
targets=$(go tool dist list 2>/dev/null)
|
||||
# Get all targets and format them nicely
|
||||
local targets
|
||||
targets=$(go tool dist list 2>/dev/null)
|
||||
|
||||
if [ $? -eq 0 ] && [ -n "$targets" ]; then
|
||||
# Show formatted output
|
||||
printf "%-15s %-10s %s\n" "OS" "ARCH" "STATUS"
|
||||
printf "%-15s %-10s %s\n" "---------------" "----------" "------"
|
||||
if [ $? -eq 0 ] && [ -n "$targets" ]; then
|
||||
# Show formatted output
|
||||
printf "%-15s %-10s %s\n" "OS" "ARCH" "STATUS"
|
||||
printf "%-15s %-10s %s\n" "---------------" "----------" "------"
|
||||
|
||||
# Track our default targets
|
||||
local default_targets=()
|
||||
for os in "${OS[@]}"; do
|
||||
for arch in "${ARCH[@]}"; do
|
||||
default_targets+=("$os/$arch")
|
||||
done
|
||||
done
|
||||
# Track our default targets
|
||||
local default_targets=()
|
||||
for os in "${OS[@]}"; do
|
||||
for arch in "${ARCH[@]}"; do
|
||||
default_targets+=("$os/$arch")
|
||||
done
|
||||
done
|
||||
|
||||
# Display all targets with status
|
||||
echo "$targets" | sort | while IFS='/' read -r os arch; do
|
||||
local status="available"
|
||||
if printf '%s\n' "${default_targets[@]}" | grep -q "^$os/$arch$"; then
|
||||
status="default"
|
||||
fi
|
||||
printf "%-15s %-10s %s\n" "$os" "$arch" "$status"
|
||||
done
|
||||
# Display all targets with status
|
||||
echo "$targets" | sort | while IFS='/' read -r os arch; do
|
||||
local status="available"
|
||||
if printf '%s\n' "${default_targets[@]}" | grep -q "^$os/$arch$"; then
|
||||
status="default"
|
||||
fi
|
||||
printf "%-15s %-10s %s\n" "$os" "$arch" "$status"
|
||||
done
|
||||
|
||||
echo
|
||||
echo "Summary:"
|
||||
echo " Total available targets: $(echo "$targets" | wc -l)"
|
||||
echo " Default targets used by this script: ${#default_targets[@]}"
|
||||
echo
|
||||
echo "Default script targets:"
|
||||
for target in "${default_targets[@]}"; do
|
||||
echo " - $target"
|
||||
done
|
||||
else
|
||||
echo "Error: Failed to get target list from 'go tool dist list'"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Error: Go is not installed or not in PATH"
|
||||
exit 1
|
||||
fi
|
||||
echo
|
||||
echo "Summary:"
|
||||
echo " Total available targets: $(echo "$targets" | wc -l)"
|
||||
echo " Default targets used by this script: ${#default_targets[@]}"
|
||||
echo
|
||||
echo "Default script targets:"
|
||||
for target in "${default_targets[@]}"; do
|
||||
echo " - $target"
|
||||
done
|
||||
else
|
||||
echo "Error: Failed to get target list from 'go tool dist list'"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Error: Go is not installed or not in PATH"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Parse parameters
|
||||
while (("$#")); do
|
||||
case $1 in
|
||||
-h | --help)
|
||||
SHOW_HELP=true
|
||||
shift
|
||||
;;
|
||||
--show-targets)
|
||||
SHOW_TARGETS=true
|
||||
shift
|
||||
;;
|
||||
-v | --verbose)
|
||||
VERBOSE=true
|
||||
shift
|
||||
;;
|
||||
-j)
|
||||
if [[ ${2-} =~ ^[0-9]+$ ]]; then
|
||||
JOBS=$2
|
||||
shift 2
|
||||
else
|
||||
echo "Error: Missing number of jobs after -j"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
-o)
|
||||
if [ -n "${2-}" ]; then
|
||||
OUTDIR=$2
|
||||
shift 2
|
||||
else
|
||||
echo "Error: Missing output directory after -o"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
-e)
|
||||
if [ -n "${2-}" ]; then
|
||||
ENTRYPOINT=$2
|
||||
shift 2
|
||||
else
|
||||
echo "Error: Missing entry point file after -e"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
case $1 in
|
||||
-h | --help)
|
||||
SHOW_HELP=true
|
||||
shift
|
||||
;;
|
||||
--show-targets)
|
||||
SHOW_TARGETS=true
|
||||
shift
|
||||
;;
|
||||
-v | --verbose)
|
||||
VERBOSE=true
|
||||
shift
|
||||
;;
|
||||
-j)
|
||||
if [[ ${2-} =~ ^[0-9]+$ ]]; then
|
||||
JOBS=$2
|
||||
shift 2
|
||||
else
|
||||
echo "Error: Missing number of jobs after -j"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
-o)
|
||||
if [ -n "${2-}" ]; then
|
||||
OUTDIR=$2
|
||||
shift 2
|
||||
else
|
||||
echo "Error: Missing output directory after -o"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
-e)
|
||||
if [ -n "${2-}" ]; then
|
||||
ENTRYPOINT=$2
|
||||
shift 2
|
||||
else
|
||||
echo "Error: Missing entry point file after -e"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Handle help and show-targets early
|
||||
if [ "$SHOW_HELP" = true ]; then
|
||||
show_help
|
||||
exit 0
|
||||
show_help
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$SHOW_TARGETS" = true ]; then
|
||||
show_targets
|
||||
exit 0
|
||||
show_targets
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Validate Go installation
|
||||
if ! command -v go >/dev/null 2>&1; then
|
||||
echo "Error: Go is not installed or not in PATH"
|
||||
echo "Please install Go from https://golang.org/dl/"
|
||||
echo "Or if running on Windows, use the PowerShell script: scripts\\build.ps1"
|
||||
exit 1
|
||||
echo "Error: Go is not installed or not in PATH"
|
||||
echo "Please install Go from https://golang.org/dl/"
|
||||
echo "Or if running on Windows, use the PowerShell script: scripts\\build.ps1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate entry point exists
|
||||
if [ ! -f "$ENTRYPOINT" ]; then
|
||||
echo "Error: Entry point file '$ENTRYPOINT' does not exist"
|
||||
exit 1
|
||||
echo "Error: Entry point file '$ENTRYPOINT' does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Store remaining arguments as an array to preserve argument boundaries
|
||||
@@ -237,30 +237,30 @@ GO_BUILD_FLAGS_ARRAY=("$@")
|
||||
# Apply default ldflags if no custom ldflags were provided
|
||||
HAS_CUSTOM_LDFLAGS=false
|
||||
for arg in "${GO_BUILD_FLAGS_ARRAY[@]}"; do
|
||||
if [[ "$arg" == "-ldflags" ]]; then
|
||||
HAS_CUSTOM_LDFLAGS=true
|
||||
break
|
||||
fi
|
||||
if [[ "$arg" == "-ldflags" ]]; then
|
||||
HAS_CUSTOM_LDFLAGS=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "$HAS_CUSTOM_LDFLAGS" == false ]] && [[ -n "$DEFAULT_LDFLAGS" ]]; then
|
||||
# Add default ldflags at the beginning
|
||||
GO_BUILD_FLAGS_ARRAY=("-ldflags" "$DEFAULT_LDFLAGS" "${GO_BUILD_FLAGS_ARRAY[@]}")
|
||||
# Add default ldflags at the beginning
|
||||
GO_BUILD_FLAGS_ARRAY=("-ldflags" "$DEFAULT_LDFLAGS" "${GO_BUILD_FLAGS_ARRAY[@]}")
|
||||
fi
|
||||
|
||||
# Verbose output
|
||||
if [ "$VERBOSE" = true ]; then
|
||||
echo "Build Configuration:"
|
||||
echo " Entry Point: $ENTRYPOINT"
|
||||
echo " Output Dir: $OUTDIR"
|
||||
echo " Parallel Jobs: $JOBS"
|
||||
if [ ${#GO_BUILD_FLAGS_ARRAY[@]} -gt 0 ]; then
|
||||
echo " Go Build Flags: ${GO_BUILD_FLAGS_ARRAY[*]}"
|
||||
else
|
||||
echo " Go Build Flags: none"
|
||||
fi
|
||||
echo " Targets: ${#OS[@]}×${#ARCH[@]} = $((${#OS[@]} * ${#ARCH[@]})) total"
|
||||
echo
|
||||
echo "Build Configuration:"
|
||||
echo " Entry Point: $ENTRYPOINT"
|
||||
echo " Output Dir: $OUTDIR"
|
||||
echo " Parallel Jobs: $JOBS"
|
||||
if [ ${#GO_BUILD_FLAGS_ARRAY[@]} -gt 0 ]; then
|
||||
echo " Go Build Flags: ${GO_BUILD_FLAGS_ARRAY[*]}"
|
||||
else
|
||||
echo " Go Build Flags: none"
|
||||
fi
|
||||
echo " Targets: ${#OS[@]}×${#ARCH[@]} = $((${#OS[@]} * ${#ARCH[@]})) total"
|
||||
echo
|
||||
fi
|
||||
|
||||
rm -rf "$OUTDIR"
|
||||
@@ -272,27 +272,27 @@ BUILD_START=$(date +%s)
|
||||
# Compose all targets in an array
|
||||
TARGETS=()
|
||||
for os in "${OS[@]}"; do
|
||||
for arch in "${ARCH[@]}"; do
|
||||
BIN="articulate-parser-$os-$arch"
|
||||
[[ "$os" == "windows" ]] && BIN="$BIN.exe"
|
||||
TARGETS+=("$BIN|$os|$arch")
|
||||
done
|
||||
for arch in "${ARCH[@]}"; do
|
||||
BIN="articulate-parser-$os-$arch"
|
||||
[[ "$os" == "windows" ]] && BIN="$BIN.exe"
|
||||
TARGETS+=("$BIN|$os|$arch")
|
||||
done
|
||||
done
|
||||
|
||||
# Show targets info if verbose
|
||||
if [ "$VERBOSE" = true ]; then
|
||||
echo "Building targets:"
|
||||
for target in "${TARGETS[@]}"; do
|
||||
BIN="${target%%|*}"
|
||||
echo " - $BIN"
|
||||
done
|
||||
echo
|
||||
echo "Building targets:"
|
||||
for target in "${TARGETS[@]}"; do
|
||||
BIN="${target%%|*}"
|
||||
echo " - $BIN"
|
||||
done
|
||||
echo
|
||||
fi
|
||||
|
||||
# Print pending statuses and save line numbers
|
||||
for idx in "${!TARGETS[@]}"; do
|
||||
BIN="${TARGETS[$idx]%%|*}"
|
||||
printf "[ ] %-35s ... pending\n" "$BIN"
|
||||
BIN="${TARGETS[$idx]%%|*}"
|
||||
printf "[ ] %-35s ... pending\n" "$BIN"
|
||||
done
|
||||
|
||||
# Make sure output isn't buffered
|
||||
@@ -300,36 +300,36 @@ export PYTHONUNBUFFERED=1
|
||||
|
||||
# Function to update a line in-place (1-based index)
|
||||
update_status() {
|
||||
local idx=$1
|
||||
local symbol=$2
|
||||
local msg=$3
|
||||
# Move cursor up to the correct line
|
||||
printf "\0337" # Save cursor position
|
||||
printf "\033[%dA" $((${#TARGETS[@]} - idx + 1)) # Move up
|
||||
printf "\r\033[K[%s] %-35s\n" "$symbol" "$msg" # Clear & update line
|
||||
printf "\0338" # Restore cursor position
|
||||
local idx=$1
|
||||
local symbol=$2
|
||||
local msg=$3
|
||||
# Move cursor up to the correct line
|
||||
printf "\0337" # Save cursor position
|
||||
printf "\033[%dA" $((${#TARGETS[@]} - idx + 1)) # Move up
|
||||
printf "\r\033[K[%s] %-35s\n" "$symbol" "$msg" # Clear & update line
|
||||
printf "\0338" # Restore cursor position
|
||||
}
|
||||
|
||||
for idx in "${!TARGETS[@]}"; do
|
||||
while (($(jobs -rp | wc -l) >= JOBS)); do sleep 0.2; done
|
||||
(
|
||||
IFS='|' read -r BIN os arch <<<"${TARGETS[$idx]}"
|
||||
update_status $((idx + 1)) '>' "$BIN ... building"
|
||||
while (($(jobs -rp | wc -l) >= JOBS)); do sleep 0.2; done
|
||||
(
|
||||
IFS='|' read -r BIN os arch <<<"${TARGETS[$idx]}"
|
||||
update_status $((idx + 1)) '>' "$BIN ... building"
|
||||
|
||||
# Prepare build command as an array to properly handle arguments with spaces
|
||||
build_cmd=(go build)
|
||||
if [ "$VERBOSE" = true ]; then
|
||||
build_cmd+=(-v)
|
||||
fi
|
||||
build_cmd+=("${GO_BUILD_FLAGS_ARRAY[@]}" -o "$OUTDIR/$BIN" "$ENTRYPOINT")
|
||||
# Prepare build command as an array to properly handle arguments with spaces
|
||||
build_cmd=(go build)
|
||||
if [ "$VERBOSE" = true ]; then
|
||||
build_cmd+=(-v)
|
||||
fi
|
||||
build_cmd+=("${GO_BUILD_FLAGS_ARRAY[@]}" -o "$OUTDIR/$BIN" "$ENTRYPOINT")
|
||||
|
||||
if CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" "${build_cmd[@]}" 2>"$OUTDIR/$BIN.log"; then
|
||||
update_status $((idx + 1)) '✔' "$BIN done"
|
||||
rm -f "$OUTDIR/$BIN.log"
|
||||
else
|
||||
update_status $((idx + 1)) '✖' "$BIN FAILED (see $OUTDIR/$BIN.log)"
|
||||
fi
|
||||
) &
|
||||
if CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" "${build_cmd[@]}" 2>"$OUTDIR/$BIN.log"; then
|
||||
update_status $((idx + 1)) '✔' "$BIN done"
|
||||
rm -f "$OUTDIR/$BIN.log"
|
||||
else
|
||||
update_status $((idx + 1)) '✖' "$BIN FAILED (see $OUTDIR/$BIN.log)"
|
||||
fi
|
||||
) &
|
||||
done
|
||||
|
||||
wait
|
||||
@@ -342,27 +342,27 @@ echo -e "\nAll builds completed in ${BUILD_DURATION}s. Find them in $OUTDIR/"
|
||||
|
||||
# Show build summary if verbose
|
||||
if [ "$VERBOSE" = true ]; then
|
||||
echo
|
||||
echo "Build Summary:"
|
||||
echo "=============="
|
||||
success_count=0
|
||||
total_size=0
|
||||
echo
|
||||
echo "Build Summary:"
|
||||
echo "=============="
|
||||
success_count=0
|
||||
total_size=0
|
||||
|
||||
for target in "${TARGETS[@]}"; do
|
||||
BIN="${target%%|*}"
|
||||
if [ -f "$OUTDIR/$BIN" ]; then
|
||||
success_count=$((success_count + 1))
|
||||
size=$(stat -f%z "$OUTDIR/$BIN" 2>/dev/null || stat -c%s "$OUTDIR/$BIN" 2>/dev/null || echo "0")
|
||||
total_size=$((total_size + size))
|
||||
rm -f "$OUTDIR/$BIN.log"
|
||||
printf " ✔ %-42s %s\n" "$OUTDIR/$BIN" "$(numfmt --to=iec-i --suffix=B $size 2>/dev/null || echo "${size} bytes")"
|
||||
else
|
||||
printf " ✖ %-42s %s\n" "$OUTDIR/$BIN" "FAILED"
|
||||
fi
|
||||
done
|
||||
for target in "${TARGETS[@]}"; do
|
||||
BIN="${target%%|*}"
|
||||
if [ -f "$OUTDIR/$BIN" ]; then
|
||||
success_count=$((success_count + 1))
|
||||
size=$(stat -f%z "$OUTDIR/$BIN" 2>/dev/null || stat -c%s "$OUTDIR/$BIN" 2>/dev/null || echo "0")
|
||||
total_size=$((total_size + size))
|
||||
rm -f "$OUTDIR/$BIN.log"
|
||||
printf " ✔ %-42s %s\n" "$OUTDIR/$BIN" "$(numfmt --to=iec-i --suffix=B $size 2>/dev/null || echo "${size} bytes")"
|
||||
else
|
||||
printf " ✖ %-42s %s\n" "$OUTDIR/$BIN" "FAILED"
|
||||
fi
|
||||
done
|
||||
|
||||
echo " ────────────────────────────────────────────────"
|
||||
printf " Total: %d/%d successful, %s total size\n" "$success_count" "${#TARGETS[@]}" "$(numfmt --to=iec-i --suffix=B $total_size 2>/dev/null || echo "${total_size} bytes")"
|
||||
echo " ────────────────────────────────────────────────"
|
||||
printf " Total: %d/%d successful, %s total size\n" "$success_count" "${#TARGETS[@]}" "$(numfmt --to=iec-i --suffix=B $total_size 2>/dev/null || echo "${total_size} bytes")"
|
||||
fi
|
||||
|
||||
# Clean up environment variables to avoid contaminating future builds
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
# :schema tombi://www.schemastore.org/tombi.json
|
||||
# :tombi toml-version = "v1.1.0"
|
||||
|
||||
toml-version = "v1.1.0"
|
||||
|
||||
[files]
|
||||
include = ["**/*.toml", "**/.*.toml"]
|
||||
exclude = ["**/fixtures"]
|
||||
|
||||
[format]
|
||||
[format.rules]
|
||||
array-bracket-space-width = 0
|
||||
array-comma-space-width = 1
|
||||
date-time-delimiter = "T"
|
||||
indent-style = "space"
|
||||
indent-sub-tables = false
|
||||
indent-table-key-value-pairs = false
|
||||
indent-width = 2
|
||||
inline-table-brace-space-width = 1
|
||||
inline-table-comma-space-width = 1
|
||||
key-value-equals-sign-alignment = true
|
||||
key-value-equals-sign-space-width = 1
|
||||
line-ending = "lf"
|
||||
line-width = 140
|
||||
string-quote-style = "double"
|
||||
trailing-comment-alignment = true
|
||||
trailing-comment-space-width = 2
|
||||
|
||||
[lint]
|
||||
[lint.rules]
|
||||
dotted-keys-out-of-order = "warn"
|
||||
key-empty = "warn"
|
||||
tables-out-of-order = "error"
|
||||
|
||||
[lsp]
|
||||
code-action.enabled = true
|
||||
completion.enabled = true
|
||||
diagnostic.enabled = true
|
||||
document-link.enabled = true
|
||||
formatting.enabled = true
|
||||
goto-declaration.enabled = true
|
||||
goto-definition.enabled = true
|
||||
goto-type-definition.enabled = true
|
||||
hover.enabled = true
|
||||
workspace-diagnostic.enabled = true
|
||||
|
||||
[schema]
|
||||
enabled = true
|
||||
strict = true
|
||||
Reference in New Issue
Block a user