mirror of
https://github.com/kjanat/articulate-parser.git
synced 2026-10-13 00:15:28 +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",
|
"$schema": "https://dprint.dev/schemas/v0.json",
|
||||||
|
"extends": "https://github.com/kjanat/kjanat/raw/8cb7b67/configs/dprint.remote.json",
|
||||||
"useTabs": true,
|
"excludes": ["**/node_modules", "**/.venv", "**/bun.lock*"],
|
||||||
|
"plugins": [
|
||||||
"typescript": {},
|
"npm:@dprint/prettier@0.70.0/plugin.json@97c0dccf54ed5b7343e7a3f6418e77bd80afcd2b74beed3a632689d47e392ddc",
|
||||||
"json": {},
|
"npm:@dprint/exec@0.7.3/plugin.json@704701df449dd7e942a71144773778ac529d68c2e4657bfc236d393b898b9a67",
|
||||||
"markdown": {},
|
],
|
||||||
"toml": {},
|
"markdown": { "associations": ["!README.md"] },
|
||||||
"dockerfile": {},
|
"prettier": { "associations": ["README.md"], "useTabs": false },
|
||||||
"oxc": {},
|
|
||||||
"ruff": {},
|
|
||||||
"jupyter": {},
|
|
||||||
"malva": {},
|
|
||||||
"markup": {},
|
|
||||||
"yaml": {},
|
|
||||||
"exec": {
|
"exec": {
|
||||||
"cwd": "${configDir}",
|
"cwd": "${configDir}",
|
||||||
"commands": [
|
"commands": [{
|
||||||
{
|
"command": "bunx tombi format - --stdin-filename {{file_path}}",
|
||||||
"command": "golangci-lint fmt --config .golangci.yml --color never --stdin {{file_path}}",
|
"exts": ["toml"],
|
||||||
"exts": ["go"],
|
"cacheKeyFiles": ["tombi.toml"],
|
||||||
"cacheKeyFiles": [".golangci.yml"],
|
}],
|
||||||
"stdin": true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
"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/
|
outputs/
|
||||||
articulate-sample.json
|
articulate-sample.json
|
||||||
test-output.*
|
test-output.*
|
||||||
|
# Example test exports (defensive; tests now write to a temp dir)
|
||||||
|
internal/exporters/output.*
|
||||||
go-os-arch-matrix.csv
|
go-os-arch-matrix.csv
|
||||||
test_godocx.go
|
test_godocx.go
|
||||||
test_input.json
|
test_input.json
|
||||||
|
|||||||
+17
-17
@@ -210,13 +210,13 @@ tasks:
|
|||||||
sh: gofmt -s -l .
|
sh: gofmt -s -l .
|
||||||
cmds:
|
cmds:
|
||||||
- |
|
- |
|
||||||
{{if ne .UNFORMATTED ""}}
|
{{if ne .UNFORMATTED ""}}
|
||||||
echo "❌ The following files need formatting:"
|
echo "❌ The following files need formatting:"
|
||||||
echo "{{.UNFORMATTED}}"
|
echo "{{.UNFORMATTED}}"
|
||||||
exit 1
|
exit 1
|
||||||
{{else}}
|
{{else}}
|
||||||
echo "All files are properly formatted"
|
echo "All files are properly formatted"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
lint:staticcheck:
|
lint:staticcheck:
|
||||||
desc: Run staticcheck (install if needed)
|
desc: Run staticcheck (install if needed)
|
||||||
@@ -304,22 +304,22 @@ tasks:
|
|||||||
aliases: [db]
|
aliases: [db]
|
||||||
cmds:
|
cmds:
|
||||||
- |
|
- |
|
||||||
docker build \
|
docker build \
|
||||||
--build-arg VERSION={{.VERSION}} \
|
--build-arg VERSION={{.VERSION}} \
|
||||||
--build-arg BUILD_TIME={{.BUILD_TIME}} \
|
--build-arg BUILD_TIME={{.BUILD_TIME}} \
|
||||||
--build-arg GIT_COMMIT={{.GIT_COMMIT}} \
|
--build-arg GIT_COMMIT={{.GIT_COMMIT}} \
|
||||||
-t {{.APP_NAME}}:{{.VERSION}} \
|
-t {{.APP_NAME}}:{{.VERSION}} \
|
||||||
-t {{.APP_NAME}}:latest \
|
-t {{.APP_NAME}}:latest \
|
||||||
.
|
.
|
||||||
- >
|
- >
|
||||||
echo "Docker image built: {{.APP_NAME}}:{{.VERSION}}"
|
echo "Docker image built: {{.APP_NAME}}:{{.VERSION}}"
|
||||||
|
|
||||||
docker:build:dev:
|
docker:build:dev:
|
||||||
desc: Build development Docker image
|
desc: Build development Docker image
|
||||||
cmds:
|
cmds:
|
||||||
- docker build -f Dockerfile.dev -t {{.APP_NAME}}:dev .
|
- 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:
|
docker:run:
|
||||||
desc: Run Docker container
|
desc: Run Docker container
|
||||||
@@ -426,7 +426,7 @@ tasks:
|
|||||||
- git tag -a v{{.VERSION}} -m "Release v{{.VERSION}}"
|
- git tag -a v{{.VERSION}} -m "Release v{{.VERSION}}"
|
||||||
- echo "Tagged v{{.VERSION}}"
|
- echo "Tagged v{{.VERSION}}"
|
||||||
- >
|
- >
|
||||||
echo "Push with: git push origin v{{.VERSION}}"
|
echo "Push with: git push origin v{{.VERSION}}"
|
||||||
|
|
||||||
# Documentation tasks
|
# Documentation tasks
|
||||||
docs:serve:
|
docs:serve:
|
||||||
|
|||||||
@@ -4,12 +4,25 @@ package exporters_test
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/kjanat/articulate-parser/internal/exporters"
|
"github.com/kjanat/articulate-parser/internal/exporters"
|
||||||
"github.com/kjanat/articulate-parser/internal/models"
|
"github.com/kjanat/articulate-parser/internal/models"
|
||||||
"github.com/kjanat/articulate-parser/internal/services"
|
"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.
|
// ExampleNewFactory demonstrates creating an exporter factory.
|
||||||
func ExampleNewFactory() {
|
func ExampleNewFactory() {
|
||||||
htmlCleaner := services.NewHTMLCleaner()
|
htmlCleaner := services.NewHTMLCleaner()
|
||||||
@@ -69,7 +82,9 @@ func ExampleMarkdownExporter_Export() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Export to markdown file
|
// 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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -91,7 +106,9 @@ func ExampleDocxExporter_Export() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Export to Word document
|
// 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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -121,7 +138,9 @@ func ExampleHTMLExporter_Export() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Export to HTML file
|
// 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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
body {
|
body {
|
||||||
font-family:
|
font-family:
|
||||||
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
|
-apple-system,
|
||||||
Cantarell, sans-serif;
|
BlinkMacSystemFont,
|
||||||
|
"Segoe UI",
|
||||||
|
Roboto,
|
||||||
|
Oxygen,
|
||||||
|
Ubuntu,
|
||||||
|
Cantarell,
|
||||||
|
sans-serif;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
color: #333;
|
color: #333;
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
|
|||||||
Binary file not shown.
+174
-174
@@ -20,7 +20,7 @@ DEFAULT_LDFLAGS="-s -w"
|
|||||||
|
|
||||||
# Function to show help
|
# Function to show help
|
||||||
show_help() {
|
show_help() {
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
articulate-parser Build Script (Bash)
|
articulate-parser Build Script (Bash)
|
||||||
=====================================
|
=====================================
|
||||||
|
|
||||||
@@ -106,129 +106,129 @@ EOF
|
|||||||
|
|
||||||
# Function to show available Go build targets
|
# Function to show available Go build targets
|
||||||
show_targets() {
|
show_targets() {
|
||||||
echo "Available Go Build Targets:"
|
echo "Available Go Build Targets:"
|
||||||
echo "=========================="
|
echo "=========================="
|
||||||
echo
|
echo
|
||||||
if command -v go >/dev/null 2>&1; then
|
if command -v go >/dev/null 2>&1; then
|
||||||
echo "Getting targets from 'go tool dist list'..."
|
echo "Getting targets from 'go tool dist list'..."
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# Get all targets and format them nicely
|
# Get all targets and format them nicely
|
||||||
local targets
|
local targets
|
||||||
targets=$(go tool dist list 2>/dev/null)
|
targets=$(go tool dist list 2>/dev/null)
|
||||||
|
|
||||||
if [ $? -eq 0 ] && [ -n "$targets" ]; then
|
if [ $? -eq 0 ] && [ -n "$targets" ]; then
|
||||||
# Show formatted output
|
# Show formatted output
|
||||||
printf "%-15s %-10s %s\n" "OS" "ARCH" "STATUS"
|
printf "%-15s %-10s %s\n" "OS" "ARCH" "STATUS"
|
||||||
printf "%-15s %-10s %s\n" "---------------" "----------" "------"
|
printf "%-15s %-10s %s\n" "---------------" "----------" "------"
|
||||||
|
|
||||||
# Track our default targets
|
# Track our default targets
|
||||||
local default_targets=()
|
local default_targets=()
|
||||||
for os in "${OS[@]}"; do
|
for os in "${OS[@]}"; do
|
||||||
for arch in "${ARCH[@]}"; do
|
for arch in "${ARCH[@]}"; do
|
||||||
default_targets+=("$os/$arch")
|
default_targets+=("$os/$arch")
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
# Display all targets with status
|
# Display all targets with status
|
||||||
echo "$targets" | sort | while IFS='/' read -r os arch; do
|
echo "$targets" | sort | while IFS='/' read -r os arch; do
|
||||||
local status="available"
|
local status="available"
|
||||||
if printf '%s\n' "${default_targets[@]}" | grep -q "^$os/$arch$"; then
|
if printf '%s\n' "${default_targets[@]}" | grep -q "^$os/$arch$"; then
|
||||||
status="default"
|
status="default"
|
||||||
fi
|
fi
|
||||||
printf "%-15s %-10s %s\n" "$os" "$arch" "$status"
|
printf "%-15s %-10s %s\n" "$os" "$arch" "$status"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Summary:"
|
echo "Summary:"
|
||||||
echo " Total available targets: $(echo "$targets" | wc -l)"
|
echo " Total available targets: $(echo "$targets" | wc -l)"
|
||||||
echo " Default targets used by this script: ${#default_targets[@]}"
|
echo " Default targets used by this script: ${#default_targets[@]}"
|
||||||
echo
|
echo
|
||||||
echo "Default script targets:"
|
echo "Default script targets:"
|
||||||
for target in "${default_targets[@]}"; do
|
for target in "${default_targets[@]}"; do
|
||||||
echo " - $target"
|
echo " - $target"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo "Error: Failed to get target list from 'go tool dist list'"
|
echo "Error: Failed to get target list from 'go tool dist list'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Error: Go is not installed or not in PATH"
|
echo "Error: Go is not installed or not in PATH"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Parse parameters
|
# Parse parameters
|
||||||
while (("$#")); do
|
while (("$#")); do
|
||||||
case $1 in
|
case $1 in
|
||||||
-h | --help)
|
-h | --help)
|
||||||
SHOW_HELP=true
|
SHOW_HELP=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--show-targets)
|
--show-targets)
|
||||||
SHOW_TARGETS=true
|
SHOW_TARGETS=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-v | --verbose)
|
-v | --verbose)
|
||||||
VERBOSE=true
|
VERBOSE=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-j)
|
-j)
|
||||||
if [[ ${2-} =~ ^[0-9]+$ ]]; then
|
if [[ ${2-} =~ ^[0-9]+$ ]]; then
|
||||||
JOBS=$2
|
JOBS=$2
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
echo "Error: Missing number of jobs after -j"
|
echo "Error: Missing number of jobs after -j"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
-o)
|
-o)
|
||||||
if [ -n "${2-}" ]; then
|
if [ -n "${2-}" ]; then
|
||||||
OUTDIR=$2
|
OUTDIR=$2
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
echo "Error: Missing output directory after -o"
|
echo "Error: Missing output directory after -o"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
-e)
|
-e)
|
||||||
if [ -n "${2-}" ]; then
|
if [ -n "${2-}" ]; then
|
||||||
ENTRYPOINT=$2
|
ENTRYPOINT=$2
|
||||||
shift 2
|
shift 2
|
||||||
else
|
else
|
||||||
echo "Error: Missing entry point file after -e"
|
echo "Error: Missing entry point file after -e"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Handle help and show-targets early
|
# Handle help and show-targets early
|
||||||
if [ "$SHOW_HELP" = true ]; then
|
if [ "$SHOW_HELP" = true ]; then
|
||||||
show_help
|
show_help
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$SHOW_TARGETS" = true ]; then
|
if [ "$SHOW_TARGETS" = true ]; then
|
||||||
show_targets
|
show_targets
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Validate Go installation
|
# Validate Go installation
|
||||||
if ! command -v go >/dev/null 2>&1; then
|
if ! command -v go >/dev/null 2>&1; then
|
||||||
echo "Error: Go is not installed or not in PATH"
|
echo "Error: Go is not installed or not in PATH"
|
||||||
echo "Please install Go from https://golang.org/dl/"
|
echo "Please install Go from https://golang.org/dl/"
|
||||||
echo "Or if running on Windows, use the PowerShell script: scripts\\build.ps1"
|
echo "Or if running on Windows, use the PowerShell script: scripts\\build.ps1"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Validate entry point exists
|
# Validate entry point exists
|
||||||
if [ ! -f "$ENTRYPOINT" ]; then
|
if [ ! -f "$ENTRYPOINT" ]; then
|
||||||
echo "Error: Entry point file '$ENTRYPOINT' does not exist"
|
echo "Error: Entry point file '$ENTRYPOINT' does not exist"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Store remaining arguments as an array to preserve argument boundaries
|
# 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
|
# Apply default ldflags if no custom ldflags were provided
|
||||||
HAS_CUSTOM_LDFLAGS=false
|
HAS_CUSTOM_LDFLAGS=false
|
||||||
for arg in "${GO_BUILD_FLAGS_ARRAY[@]}"; do
|
for arg in "${GO_BUILD_FLAGS_ARRAY[@]}"; do
|
||||||
if [[ "$arg" == "-ldflags" ]]; then
|
if [[ "$arg" == "-ldflags" ]]; then
|
||||||
HAS_CUSTOM_LDFLAGS=true
|
HAS_CUSTOM_LDFLAGS=true
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ "$HAS_CUSTOM_LDFLAGS" == false ]] && [[ -n "$DEFAULT_LDFLAGS" ]]; then
|
if [[ "$HAS_CUSTOM_LDFLAGS" == false ]] && [[ -n "$DEFAULT_LDFLAGS" ]]; then
|
||||||
# Add default ldflags at the beginning
|
# Add default ldflags at the beginning
|
||||||
GO_BUILD_FLAGS_ARRAY=("-ldflags" "$DEFAULT_LDFLAGS" "${GO_BUILD_FLAGS_ARRAY[@]}")
|
GO_BUILD_FLAGS_ARRAY=("-ldflags" "$DEFAULT_LDFLAGS" "${GO_BUILD_FLAGS_ARRAY[@]}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Verbose output
|
# Verbose output
|
||||||
if [ "$VERBOSE" = true ]; then
|
if [ "$VERBOSE" = true ]; then
|
||||||
echo "Build Configuration:"
|
echo "Build Configuration:"
|
||||||
echo " Entry Point: $ENTRYPOINT"
|
echo " Entry Point: $ENTRYPOINT"
|
||||||
echo " Output Dir: $OUTDIR"
|
echo " Output Dir: $OUTDIR"
|
||||||
echo " Parallel Jobs: $JOBS"
|
echo " Parallel Jobs: $JOBS"
|
||||||
if [ ${#GO_BUILD_FLAGS_ARRAY[@]} -gt 0 ]; then
|
if [ ${#GO_BUILD_FLAGS_ARRAY[@]} -gt 0 ]; then
|
||||||
echo " Go Build Flags: ${GO_BUILD_FLAGS_ARRAY[*]}"
|
echo " Go Build Flags: ${GO_BUILD_FLAGS_ARRAY[*]}"
|
||||||
else
|
else
|
||||||
echo " Go Build Flags: none"
|
echo " Go Build Flags: none"
|
||||||
fi
|
fi
|
||||||
echo " Targets: ${#OS[@]}×${#ARCH[@]} = $((${#OS[@]} * ${#ARCH[@]})) total"
|
echo " Targets: ${#OS[@]}×${#ARCH[@]} = $((${#OS[@]} * ${#ARCH[@]})) total"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf "$OUTDIR"
|
rm -rf "$OUTDIR"
|
||||||
@@ -272,27 +272,27 @@ BUILD_START=$(date +%s)
|
|||||||
# Compose all targets in an array
|
# Compose all targets in an array
|
||||||
TARGETS=()
|
TARGETS=()
|
||||||
for os in "${OS[@]}"; do
|
for os in "${OS[@]}"; do
|
||||||
for arch in "${ARCH[@]}"; do
|
for arch in "${ARCH[@]}"; do
|
||||||
BIN="articulate-parser-$os-$arch"
|
BIN="articulate-parser-$os-$arch"
|
||||||
[[ "$os" == "windows" ]] && BIN="$BIN.exe"
|
[[ "$os" == "windows" ]] && BIN="$BIN.exe"
|
||||||
TARGETS+=("$BIN|$os|$arch")
|
TARGETS+=("$BIN|$os|$arch")
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
# Show targets info if verbose
|
# Show targets info if verbose
|
||||||
if [ "$VERBOSE" = true ]; then
|
if [ "$VERBOSE" = true ]; then
|
||||||
echo "Building targets:"
|
echo "Building targets:"
|
||||||
for target in "${TARGETS[@]}"; do
|
for target in "${TARGETS[@]}"; do
|
||||||
BIN="${target%%|*}"
|
BIN="${target%%|*}"
|
||||||
echo " - $BIN"
|
echo " - $BIN"
|
||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Print pending statuses and save line numbers
|
# Print pending statuses and save line numbers
|
||||||
for idx in "${!TARGETS[@]}"; do
|
for idx in "${!TARGETS[@]}"; do
|
||||||
BIN="${TARGETS[$idx]%%|*}"
|
BIN="${TARGETS[$idx]%%|*}"
|
||||||
printf "[ ] %-35s ... pending\n" "$BIN"
|
printf "[ ] %-35s ... pending\n" "$BIN"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Make sure output isn't buffered
|
# Make sure output isn't buffered
|
||||||
@@ -300,36 +300,36 @@ export PYTHONUNBUFFERED=1
|
|||||||
|
|
||||||
# Function to update a line in-place (1-based index)
|
# Function to update a line in-place (1-based index)
|
||||||
update_status() {
|
update_status() {
|
||||||
local idx=$1
|
local idx=$1
|
||||||
local symbol=$2
|
local symbol=$2
|
||||||
local msg=$3
|
local msg=$3
|
||||||
# Move cursor up to the correct line
|
# Move cursor up to the correct line
|
||||||
printf "\0337" # Save cursor position
|
printf "\0337" # Save cursor position
|
||||||
printf "\033[%dA" $((${#TARGETS[@]} - idx + 1)) # Move up
|
printf "\033[%dA" $((${#TARGETS[@]} - idx + 1)) # Move up
|
||||||
printf "\r\033[K[%s] %-35s\n" "$symbol" "$msg" # Clear & update line
|
printf "\r\033[K[%s] %-35s\n" "$symbol" "$msg" # Clear & update line
|
||||||
printf "\0338" # Restore cursor position
|
printf "\0338" # Restore cursor position
|
||||||
}
|
}
|
||||||
|
|
||||||
for idx in "${!TARGETS[@]}"; do
|
for idx in "${!TARGETS[@]}"; do
|
||||||
while (($(jobs -rp | wc -l) >= JOBS)); do sleep 0.2; done
|
while (($(jobs -rp | wc -l) >= JOBS)); do sleep 0.2; done
|
||||||
(
|
(
|
||||||
IFS='|' read -r BIN os arch <<<"${TARGETS[$idx]}"
|
IFS='|' read -r BIN os arch <<<"${TARGETS[$idx]}"
|
||||||
update_status $((idx + 1)) '>' "$BIN ... building"
|
update_status $((idx + 1)) '>' "$BIN ... building"
|
||||||
|
|
||||||
# Prepare build command as an array to properly handle arguments with spaces
|
# Prepare build command as an array to properly handle arguments with spaces
|
||||||
build_cmd=(go build)
|
build_cmd=(go build)
|
||||||
if [ "$VERBOSE" = true ]; then
|
if [ "$VERBOSE" = true ]; then
|
||||||
build_cmd+=(-v)
|
build_cmd+=(-v)
|
||||||
fi
|
fi
|
||||||
build_cmd+=("${GO_BUILD_FLAGS_ARRAY[@]}" -o "$OUTDIR/$BIN" "$ENTRYPOINT")
|
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
|
if CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" "${build_cmd[@]}" 2>"$OUTDIR/$BIN.log"; then
|
||||||
update_status $((idx + 1)) '✔' "$BIN done"
|
update_status $((idx + 1)) '✔' "$BIN done"
|
||||||
rm -f "$OUTDIR/$BIN.log"
|
rm -f "$OUTDIR/$BIN.log"
|
||||||
else
|
else
|
||||||
update_status $((idx + 1)) '✖' "$BIN FAILED (see $OUTDIR/$BIN.log)"
|
update_status $((idx + 1)) '✖' "$BIN FAILED (see $OUTDIR/$BIN.log)"
|
||||||
fi
|
fi
|
||||||
) &
|
) &
|
||||||
done
|
done
|
||||||
|
|
||||||
wait
|
wait
|
||||||
@@ -342,27 +342,27 @@ echo -e "\nAll builds completed in ${BUILD_DURATION}s. Find them in $OUTDIR/"
|
|||||||
|
|
||||||
# Show build summary if verbose
|
# Show build summary if verbose
|
||||||
if [ "$VERBOSE" = true ]; then
|
if [ "$VERBOSE" = true ]; then
|
||||||
echo
|
echo
|
||||||
echo "Build Summary:"
|
echo "Build Summary:"
|
||||||
echo "=============="
|
echo "=============="
|
||||||
success_count=0
|
success_count=0
|
||||||
total_size=0
|
total_size=0
|
||||||
|
|
||||||
for target in "${TARGETS[@]}"; do
|
for target in "${TARGETS[@]}"; do
|
||||||
BIN="${target%%|*}"
|
BIN="${target%%|*}"
|
||||||
if [ -f "$OUTDIR/$BIN" ]; then
|
if [ -f "$OUTDIR/$BIN" ]; then
|
||||||
success_count=$((success_count + 1))
|
success_count=$((success_count + 1))
|
||||||
size=$(stat -f%z "$OUTDIR/$BIN" 2>/dev/null || stat -c%s "$OUTDIR/$BIN" 2>/dev/null || echo "0")
|
size=$(stat -f%z "$OUTDIR/$BIN" 2>/dev/null || stat -c%s "$OUTDIR/$BIN" 2>/dev/null || echo "0")
|
||||||
total_size=$((total_size + size))
|
total_size=$((total_size + size))
|
||||||
rm -f "$OUTDIR/$BIN.log"
|
rm -f "$OUTDIR/$BIN.log"
|
||||||
printf " ✔ %-42s %s\n" "$OUTDIR/$BIN" "$(numfmt --to=iec-i --suffix=B $size 2>/dev/null || echo "${size} bytes")"
|
printf " ✔ %-42s %s\n" "$OUTDIR/$BIN" "$(numfmt --to=iec-i --suffix=B $size 2>/dev/null || echo "${size} bytes")"
|
||||||
else
|
else
|
||||||
printf " ✖ %-42s %s\n" "$OUTDIR/$BIN" "FAILED"
|
printf " ✖ %-42s %s\n" "$OUTDIR/$BIN" "FAILED"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo " ────────────────────────────────────────────────"
|
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")"
|
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
|
fi
|
||||||
|
|
||||||
# Clean up environment variables to avoid contaminating future builds
|
# 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