10 Commits
Author SHA1 Message Date
pk 49c88da564 Add config extends and entry point exclusion
Profiles may inherit from another config file (extends: <path>): the
first profile of the referenced file is merged underneath (scalars from
the overlay win, slices concatenate base-first and de-duplicate, chains
resolve recursively, cycles are detected).

esbuild.excludeEntryPoints removes merged entry points by glob (** spans
path separators, * stays within a segment), applied after path
resolution so patterns and entries match in the same shape.

Lets product editions/flavors (e.g. the wmd4x Range Trader Pro edition)
build only their own entry set on top of a shared, merge-clean base
config. Includes unit tests and template docs.
2026-10-11 15:58:56 +02:00
pk dca493bfdc Allow different source folder when serving 2025-10-07 15:56:35 +02:00
pk faadc3eb6f bump version 2025-08-25 11:56:59 +02:00
pk 51be76d4ad Find a free port for livereload by default. 2025-08-25 11:56:41 +02:00
pk 2efa8b43a3 Make sure build errors let the build command exit with a error code. 2025-08-06 20:43:38 +02:00
pk 64b594c4ac Allow different port 2025-08-06 12:46:00 +02:00
pk 7de6aab73d Bump version 2025-07-16 23:32:07 +02:00
pk d5319e18e2 Add swap content option 2025-07-16 23:31:50 +02:00
pk 84bdc73900 Bump version 2025-06-05 21:30:49 +02:00
pk 71bfa980df Improve efficency of the watcher by leaving out all node_modules and .git folders. 2025-06-05 21:29:25 +02:00
12 changed files with 600 additions and 74 deletions

No files matched your search

+1 -1
View File
@@ -10,7 +10,7 @@
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"args": ["generate"]
"args": ["watch", "-c", "/home/pk/golang/plusev/terminal/.gowebbuild.yaml"]
}
]
}
+7 -1
View File
@@ -33,7 +33,13 @@ func buildAction(ctx *cli.Context) error {
esBuildCfg.Sourcemap = api.SourceMapNone
}
api.Build(esBuildCfg)
esBuildCfg.Plugins = append(esBuildCfg.Plugins, contentSwapPlugin(o))
result := api.Build(esBuildCfg)
if len(result.Errors) > 0 {
os.Exit(1)
}
replace(o)
if ctx.Bool("p") && o.ProductionBuildOptions.CmdPostBuild != "" {
+92 -15
View File
@@ -13,7 +13,7 @@ import (
)
func cfgToESBuildCfg(cfg options) api.BuildOptions {
return api.BuildOptions{
buildOptions := api.BuildOptions{
EntryPoints: cfg.ESBuild.EntryPoints,
Outdir: cfg.ESBuild.Outdir,
Outfile: cfg.ESBuild.Outfile,
@@ -26,27 +26,40 @@ func cfgToESBuildCfg(cfg options) api.BuildOptions {
Write: cfg.ESBuild.Write,
LogLevel: api.LogLevel(cfg.ESBuild.LogLevel),
}
// Set target if specified, otherwise default to modern ES for decorator support
if cfg.ESBuild.Target > 0 {
buildOptions.Target = api.Target(cfg.ESBuild.Target)
} else {
buildOptions.Target = api.ES2022
}
return buildOptions
}
type options struct {
Extends string `yaml:"extends"` // inherit from the first profile of the referenced config file
ESBuild struct {
EntryPoints []string `yaml:"entryPoints"`
Outdir string `yaml:"outdir"`
Outbase string `yaml:"outbase"`
Outfile string `yaml:"outfile"`
Sourcemap int `yaml:"sourcemap"`
Format int `yaml:"format"`
Splitting bool `yaml:"splitting"`
Platform int `yaml:"platform"`
Bundle bool `yaml:"bundle"`
Write bool `yaml:"write"`
LogLevel int `yaml:"logLevel"`
PurgeBeforeBuild bool `yaml:"purgeBeforeBuild"`
EntryPoints []string `yaml:"entryPoints"`
ExcludeEntryPoints []string `yaml:"excludeEntryPoints"`
Outdir string `yaml:"outdir"`
Outbase string `yaml:"outbase"`
Outfile string `yaml:"outfile"`
Sourcemap int `yaml:"sourcemap"`
Format int `yaml:"format"`
Splitting bool `yaml:"splitting"`
Platform int `yaml:"platform"`
Bundle bool `yaml:"bundle"`
Write bool `yaml:"write"`
LogLevel int `yaml:"logLevel"`
Target int `yaml:"target"`
PurgeBeforeBuild bool `yaml:"purgeBeforeBuild"`
} `yaml:"esbuild"`
Watch struct {
Paths []string `yaml:"paths"`
Exclude []string `yaml:"exclude"`
InjectLiveReload string `yaml:"injectLiveReload"`
SkipCSPInject bool `yaml:"skipCSPInject"`
}
Serve struct {
Path string `yaml:"path"`
@@ -65,6 +78,10 @@ type options struct {
Search string `yaml:"search"`
Replace string `yaml:"replace"`
} `yaml:"replace"`
ContentSwap []struct {
File string `yaml:"file"`
ReplaceWith string `yaml:"replaceWith"`
} `yaml:"contentSwap"`
Link struct {
From string `yaml:"from"`
To string `yaml:"to"`
@@ -104,6 +121,38 @@ func readCfg(cfgPath string) []options {
cfgPath = yamlPath
}
profiles := readCfgFile(cfgPath, map[string]bool{})
// Path resolution and entry point filtering run once, after all extends
// chains are merged, so de-duplication compares like with like and
// patterns match the same shape as the entries.
for i := range profiles {
processPaths(&profiles[i])
filterEntryPoints(&profiles[i])
}
return profiles
}
// readCfgFile loads a config file and resolves `extends` chains. A profile
// may declare `extends: <path>`; the first profile of the referenced file is
// merged underneath it (scalars: overlay wins when set, slices: concatenated
// base-first and de-duplicated). Chains are resolved recursively; visiting
// guards against inheritance cycles.
func readCfgFile(cfgPath string, visiting map[string]bool) []options {
absPath, err := filepath.Abs(cfgPath)
if err != nil {
fmt.Printf("%+v\n", err)
os.Exit(1)
}
if visiting[absPath] {
fmt.Printf("extends cycle detected at %s\n", absPath)
os.Exit(1)
}
visiting[absPath] = true
defer delete(visiting, absPath)
cfgContent, err := os.ReadFile(cfgPath)
if err != nil {
@@ -125,9 +174,27 @@ func readCfg(cfgPath string) []options {
optsSetups = append(optsSetups, opt)
}
// Process all paths in each options setup
cfgDir := filepath.Dir(cfgPath)
for i := range optsSetups {
processPaths(&optsSetups[i])
base := strings.TrimSpace(optsSetups[i].Extends)
if base == "" {
continue
}
if !filepath.IsAbs(base) {
base = filepath.Join(cfgDir, base)
}
baseProfiles := readCfgFile(base, visiting)
if len(baseProfiles) == 0 {
fmt.Printf("extends target %s contains no profiles\n", base)
os.Exit(1)
}
optsSetups[i] = mergeOptions(baseProfiles[0], optsSetups[i])
}
return optsSetups
@@ -163,6 +230,10 @@ func processPaths(opts *options) {
for i, entry := range opts.ESBuild.EntryPoints {
opts.ESBuild.EntryPoints[i] = fsutils.ResolvePath(entry)
}
for i, entry := range opts.ESBuild.ExcludeEntryPoints {
opts.ESBuild.ExcludeEntryPoints[i] = fsutils.ResolvePath(entry)
}
opts.ESBuild.Outdir = fsutils.ResolvePath(opts.ESBuild.Outdir)
opts.ESBuild.Outfile = fsutils.ResolvePath(opts.ESBuild.Outfile)
@@ -191,6 +262,12 @@ func processPaths(opts *options) {
opts.Download[i].Dest = fsutils.ResolvePath(opts.Download[i].Dest)
}
// Content swap paths
for i := range opts.ContentSwap {
opts.ContentSwap[i].File = fsutils.ResolvePath(opts.ContentSwap[i].File)
opts.ContentSwap[i].ReplaceWith = fsutils.ResolvePath(opts.ContentSwap[i].ReplaceWith)
}
// Link paths
opts.Link.From = fsutils.ResolvePath(opts.Link.From)
opts.Link.To = fsutils.ResolvePath(opts.Link.To)
+156
View File
@@ -0,0 +1,156 @@
package main
import (
"os"
"path/filepath"
"reflect"
"regexp"
"testing"
)
func TestMergeOptions(t *testing.T) {
base := options{}
base.ESBuild.EntryPoints = []string{"a.js", "b.js"}
base.ESBuild.LogLevel = 3
base.ESBuild.Splitting = true
base.Copy = []struct {
Src string `yaml:"src"`
Dest string `yaml:"dest"`
}{{Src: "index.html", Dest: "dist"}}
overlay := options{}
overlay.ESBuild.EntryPoints = []string{"b.js", "c.js"} // b.js duplicates the base
overlay.ESBuild.LogLevel = 2 // scalar override
overlay.Copy = []struct {
Src string `yaml:"src"`
Dest string `yaml:"dest"`
}{{Src: "index.html", Dest: "dist"}} // exact duplicate of the base entry
merged := mergeOptions(base, overlay)
want := []string{"a.js", "b.js", "c.js"}
if !reflect.DeepEqual(merged.ESBuild.EntryPoints, want) {
t.Fatalf("entryPoints = %v, want %v", merged.ESBuild.EntryPoints, want)
}
if merged.ESBuild.LogLevel != 2 {
t.Fatalf("logLevel = %d, want overlay value 2", merged.ESBuild.LogLevel)
}
if !merged.ESBuild.Splitting {
t.Fatal("splitting = false, want inherited true")
}
if len(merged.Copy) != 1 {
t.Fatalf("copy = %d entries, want de-duplicated 1", len(merged.Copy))
}
if merged.Extends != "" {
t.Fatalf("extends = %q, want cleared after merge", merged.Extends)
}
}
func TestPatternToRegexp(t *testing.T) {
cases := []struct {
pattern string
path string
match bool
}{
// Production shape: processPaths absolutizes patterns and entries
// alike, so matching happens between absolute forward-slash paths.
{"/proj/apps/taxes/**", "/proj/apps/taxes/taxes-app.js", true},
{"/proj/apps/taxes/**", "/proj/apps/taxes/elements/tax-script.js", true},
{"/proj/apps/taxes/**", "/proj/apps/journal/journal-app.js", false},
{"/proj/apps/vault/**", "/proj/apps/vaultx/vaultx-app.js", false},
{"/proj/src/*.js", "/proj/src/the-app.js", true},
{"/proj/src/*.js", "/proj/src/admin/the-admin.js", false},
{"/proj/src/the-?.js", "/proj/src/the-a.js", true},
{"/proj/src/the-?.js", "/proj/src/the-ab.js", false},
}
for _, c := range cases {
re := regexp.MustCompile(patternToRegexp(c.pattern))
if re.MatchString(c.path) != c.match {
t.Errorf("pattern %q vs %q: got %v, want %v", c.pattern, c.path, re.MatchString(c.path), c.match)
}
}
}
func TestFilterEntryPoints(t *testing.T) {
opts := options{}
opts.ESBuild.EntryPoints = []string{
"/proj/apps/taxes/taxes-app.js",
"/proj/apps/chat/chat-app.js",
"/proj/the-terminal.js",
}
opts.ESBuild.ExcludeEntryPoints = []string{"/proj/apps/taxes/**"}
filterEntryPoints(&opts)
want := []string{"/proj/apps/chat/chat-app.js", "/proj/the-terminal.js"}
if !reflect.DeepEqual(opts.ESBuild.EntryPoints, want) {
t.Fatalf("entryPoints = %v, want %v", opts.ESBuild.EntryPoints, want)
}
}
func TestReadCfgExtends(t *testing.T) {
dir := t.TempDir()
prevWd, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { os.Chdir(prevWd) })
writeFile := func(name, content string) {
if err := os.WriteFile(filepath.Join(dir, name), []byte(content), 0644); err != nil {
t.Fatal(err)
}
}
writeFile("base.yaml", `- esbuild:
entryPoints:
- ./src/base-one.js
- ./src/base-two.js
outdir: ./dist
logLevel: 3
copy:
- src: ./index.html
dest: ./dist
`)
writeFile("overlay.yaml", `- extends: ./base.yaml
esbuild:
entryPoints:
- ./src/base-two.js
- ./src/overlay.js
excludeEntryPoints:
- ./src/base-one.js
`)
if err := os.Chdir(dir); err != nil {
t.Fatal(err)
}
profiles := readCfg("./overlay.yaml")
if len(profiles) != 1 {
t.Fatalf("profiles = %d, want 1", len(profiles))
}
p := profiles[0]
want := []string{
filepath.Join(dir, "src/base-two.js"),
filepath.Join(dir, "src/overlay.js"),
}
if !reflect.DeepEqual(p.ESBuild.EntryPoints, want) {
t.Fatalf("entryPoints = %v, want %v", p.ESBuild.EntryPoints, want)
}
if p.ESBuild.LogLevel != 3 {
t.Fatalf("logLevel = %d, want inherited 3", p.ESBuild.LogLevel)
}
if len(p.Copy) != 1 {
t.Fatalf("copy = %d entries, want inherited 1", len(p.Copy))
}
}
+37 -34
View File
@@ -3,40 +3,40 @@ module github.com/trading-peter/gowebbuild
go 1.24
require (
github.com/Iilun/survey/v2 v2.5.2
github.com/Masterminds/semver/v3 v3.3.1
github.com/PuerkitoBio/goquery v1.10.2
github.com/evanw/esbuild v0.25.0
github.com/Iilun/survey/v2 v2.5.3
github.com/Masterminds/semver/v3 v3.4.0
github.com/PuerkitoBio/goquery v1.10.3
github.com/evanw/esbuild v0.25.5
github.com/jaschaephraim/lrserver v0.0.0-20240306232639-afed386b3640
github.com/kataras/golog v0.1.12
github.com/kataras/golog v0.1.13
github.com/kataras/iris/v12 v12.2.11
github.com/mholt/archives v0.1.0
github.com/mholt/archives v0.1.3
github.com/otiai10/copy v1.14.1
github.com/radovskyb/watcher v1.0.7
github.com/tidwall/gjson v1.18.0
github.com/urfave/cli/v2 v2.27.5
github.com/urfave/cli/v2 v2.27.7
gopkg.in/yaml.v3 v3.0.1
)
require (
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/BurntSushi/toml v1.5.0 // indirect
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect
github.com/CloudyKit/jet/v6 v6.3.1 // indirect
github.com/Joker/jade v1.1.3 // indirect
github.com/STARRY-S/zip v0.2.2 // indirect
github.com/Shopify/goreferrer v0.0.0-20240724165105-aceaa0259138 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/STARRY-S/zip v0.2.3 // indirect
github.com/Shopify/goreferrer v0.0.0-20250617153402-88c1d9a79b05 // indirect
github.com/andybalholm/brotli v1.2.0 // indirect
github.com/andybalholm/cascadia v1.3.3 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/bodgit/plumbing v1.3.0 // indirect
github.com/bodgit/sevenzip v1.6.0 // indirect
github.com/bodgit/sevenzip v1.6.1 // indirect
github.com/bodgit/windows v1.0.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/flosch/pongo2/v4 v4.0.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gomarkdown/markdown v0.0.0-20250207164621-7a1f277a159e // indirect
github.com/golang/snappy v1.0.0 // indirect
github.com/gomarkdown/markdown v0.0.0-20250311123330-531bef5e742b // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
@@ -46,7 +46,7 @@ require (
github.com/iris-contrib/schema v0.0.6 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/kataras/blocks v0.0.11 // indirect
github.com/kataras/pio v0.0.13 // indirect
github.com/kataras/pio v0.0.14 // indirect
github.com/kataras/sitemap v0.0.6 // indirect
github.com/kataras/tunnel v0.0.4 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
@@ -59,15 +59,18 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
github.com/nwaples/rardecode/v2 v2.1.0 // indirect
github.com/mikelolasagasti/xz v1.0.1 // indirect
github.com/minio/minlz v1.0.1 // indirect
github.com/nwaples/rardecode/v2 v2.1.1 // indirect
github.com/otiai10/mint v1.6.3 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/schollz/closestmatch v2.1.0+incompatible // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sorairolake/lzip-go v0.3.5 // indirect
github.com/tdewolff/minify/v2 v2.21.3 // indirect
github.com/tdewolff/parse/v2 v2.7.20 // indirect
github.com/sorairolake/lzip-go v0.3.7 // indirect
github.com/spf13/afero v1.14.0 // indirect
github.com/tdewolff/minify/v2 v2.23.8 // indirect
github.com/tdewolff/parse/v2 v2.8.1 // indirect
github.com/therootcompany/xz v1.0.1 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
@@ -75,21 +78,21 @@ require (
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 // indirect
github.com/yosssi/ace v0.0.5 // indirect
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
golang.design/x/clipboard v0.7.0 // indirect
golang.org/x/crypto v0.35.0 // indirect
golang.org/x/exp v0.0.0-20250228200357-dead58393ab7 // indirect
golang.org/x/exp/shiny v0.0.0-20250228200357-dead58393ab7 // indirect
golang.org/x/image v0.24.0 // indirect
golang.org/x/mobile v0.0.0-20250218173827-cd096645fcd3 // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/term v0.29.0 // indirect
golang.org/x/text v0.22.0 // indirect
golang.org/x/time v0.10.0 // indirect
google.golang.org/protobuf v1.36.5 // indirect
golang.design/x/clipboard v0.7.1 // indirect
golang.org/x/crypto v0.39.0 // indirect
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
golang.org/x/exp/shiny v0.0.0-20250620022241-b7579e27df2b // indirect
golang.org/x/image v0.28.0 // indirect
golang.org/x/mobile v0.0.0-20250606033058-a2a15c67f36f // indirect
golang.org/x/net v0.41.0 // indirect
golang.org/x/sync v0.15.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/term v0.32.0 // indirect
golang.org/x/text v0.26.0 // indirect
golang.org/x/time v0.12.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)
+76
View File
@@ -18,6 +18,8 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 h1:sR+/8Yb4slttB4vD+b9btVEnWgL3Q00OBTzVT8B9C0c=
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno=
@@ -25,24 +27,36 @@ github.com/CloudyKit/jet/v6 v6.3.1 h1:6IAo5Cx21xrHVaR8zzXN5gJatKV/wO7Nf6bfCnCSbU
github.com/CloudyKit/jet/v6 v6.3.1/go.mod h1:lf8ksdNsxZt7/yH/3n4vJQWA9RUq4wpaHtArHhGVMOw=
github.com/Iilun/survey/v2 v2.5.2 h1:LaidRUryJVuwPMLQIhIiYcX3P1KVxtkJh1q+RMGX97s=
github.com/Iilun/survey/v2 v2.5.2/go.mod h1:IgwKxozHo0Gf8pnof+IDSDcieRtD2jtB4nTpj1+Oz7E=
github.com/Iilun/survey/v2 v2.5.3 h1:pjtbpj0gVrmyWAhx5hHVgX9zkcIeRnSi2+KZMTLsbME=
github.com/Iilun/survey/v2 v2.5.3/go.mod h1:pr7DbMjtOeJtqB/B/bGxgHIDm7FUc+9MpKKVLZKW3vU=
github.com/Joker/hpp v1.0.0 h1:65+iuJYdRXv/XyN62C1uEmmOx3432rNG/rKlX6V7Kkc=
github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY=
github.com/Joker/jade v1.1.3 h1:Qbeh12Vq6BxURXT1qZBRHsDxeURB8ztcL6f3EXSGeHk=
github.com/Joker/jade v1.1.3/go.mod h1:T+2WLyt7VH6Lp0TRxQrUYEs64nRc83wkMQrfeIQKduM=
github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4=
github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s=
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
github.com/PuerkitoBio/goquery v1.10.2 h1:7fh2BdHcG6VFZsK7toXBT/Bh1z5Wmy8Q9MV9HqT2AM8=
github.com/PuerkitoBio/goquery v1.10.2/go.mod h1:0guWGjcLu9AYC7C1GHnpysHy056u9aEkUHwhdnePMCU=
github.com/PuerkitoBio/goquery v1.10.3 h1:pFYcNSqHxBD06Fpj/KsbStFRsgRATgnf3LeXiUkhzPo=
github.com/PuerkitoBio/goquery v1.10.3/go.mod h1:tMUX0zDMHXYlAQk6p35XxQMqMweEKB7iK7iLNd4RH4Y=
github.com/STARRY-S/zip v0.2.2 h1:8QeCbIi1Z9U5MgoDARJR1ClbBo9RD46SmVy+dl0woCk=
github.com/STARRY-S/zip v0.2.2/go.mod h1:lqJ9JdeRipyOQJrYSOtpNAiaesFO6zVDsE8GIGFaoSk=
github.com/STARRY-S/zip v0.2.3 h1:luE4dMvRPDOWQdeDdUxUoZkzUIpTccdKdhHHsQJ1fm4=
github.com/STARRY-S/zip v0.2.3/go.mod h1:lqJ9JdeRipyOQJrYSOtpNAiaesFO6zVDsE8GIGFaoSk=
github.com/Shopify/goreferrer v0.0.0-20240724165105-aceaa0259138 h1:gjbp60h8IZQbN/TpDaYJedWbbD1h1aDPEwWnYWaDaUY=
github.com/Shopify/goreferrer v0.0.0-20240724165105-aceaa0259138/go.mod h1:NYezi6wtnJtBm5btoprXc5SvAdqH0XTXWnUup0MptAI=
github.com/Shopify/goreferrer v0.0.0-20250617153402-88c1d9a79b05 h1:dG7/gLroJGht/jSQtHiLvT48Hxn+crbmvyItZC8cWOs=
github.com/Shopify/goreferrer v0.0.0-20250617153402-88c1d9a79b05/go.mod h1:NYezi6wtnJtBm5btoprXc5SvAdqH0XTXWnUup0MptAI=
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA=
github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA=
github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ=
github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA=
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
@@ -51,6 +65,8 @@ github.com/bodgit/plumbing v1.3.0 h1:pf9Itz1JOQgn7vEOE7v7nlEfBykYqvUYioC61TwWCFU
github.com/bodgit/plumbing v1.3.0/go.mod h1:JOTb4XiRu5xfnmdnDJo6GmSbSbtSyufrsyZFByMtKEs=
github.com/bodgit/sevenzip v1.6.0 h1:a4R0Wu6/P1o1pP/3VV++aEOcyeBxeO/xE2Y9NSTrr6A=
github.com/bodgit/sevenzip v1.6.0/go.mod h1:zOBh9nJUof7tcrlqJFv1koWRrhz3LbDbUNngkuZxLMc=
github.com/bodgit/sevenzip v1.6.1 h1:kikg2pUMYC9ljU7W9SaqHXhym5HyKm8/M/jd31fYan4=
github.com/bodgit/sevenzip v1.6.1/go.mod h1:GVoYQbEVbOGT8n2pfqCIMRUaRjQ8F9oSqoBEqZh5fQ8=
github.com/bodgit/windows v1.0.1 h1:tF7K6KOluPYygXa3Z2594zxlkbKPAOvqr97etrGNIz4=
github.com/bodgit/windows v1.0.1/go.mod h1:a6JLwrB4KrTR5hBpp8FI9/9W9jJfeQ2h4XDXU74ZCdM=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
@@ -60,6 +76,8 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
@@ -73,6 +91,8 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/evanw/esbuild v0.25.0 h1:jRR9D1pfdb669VzdN4w0jwsDfrKE098nKMaDMKvMPyU=
github.com/evanw/esbuild v0.25.0/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48=
github.com/evanw/esbuild v0.25.5 h1:E+JpeY5S/1LFmnX1vtuZqUKT7qDVcfXdhzMhM3uIKFs=
github.com/evanw/esbuild v0.25.5/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
@@ -99,8 +119,12 @@ github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs=
github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/gomarkdown/markdown v0.0.0-20250207164621-7a1f277a159e h1:ESHlT0RVZphh4JGBz49I5R6nTdC8Qyc08vU25GQHzzQ=
github.com/gomarkdown/markdown v0.0.0-20250207164621-7a1f277a159e/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
github.com/gomarkdown/markdown v0.0.0-20250311123330-531bef5e742b h1:EY/KpStFl60qA17CptGXhwfZ+k1sFNJIUNR8DdbcuUk=
github.com/gomarkdown/markdown v0.0.0-20250311123330-531bef5e742b/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
@@ -157,10 +181,14 @@ github.com/kataras/blocks v0.0.11 h1:JJdYW0AUaJKLx5kEWs/oRVCvKVXo+6CAAeaVAiJf7wE
github.com/kataras/blocks v0.0.11/go.mod h1:b4UySrJySEOq6drKH9U3bOpMI+dRH148mayYfS3RFb8=
github.com/kataras/golog v0.1.12 h1:Bu7I/G4ilJlbfzjmU39O9N+2uO1pBcMK045fzZ4ytNg=
github.com/kataras/golog v0.1.12/go.mod h1:wrGSbOiBqbQSQznleVNX4epWM8rl9SJ/rmEacl0yqy4=
github.com/kataras/golog v0.1.13 h1:bGbPglTdCutekqwOUf8L1jq3tZ5ADG9gfPBd5p5SzKA=
github.com/kataras/golog v0.1.13/go.mod h1:oQmzBTCv/35TetBosjJl/k+LPdlJEblaTupkNwJlwj8=
github.com/kataras/iris/v12 v12.2.11 h1:sGgo43rMPfzDft8rjVhPs6L3qDJy3TbBrMD/zGL1pzk=
github.com/kataras/iris/v12 v12.2.11/go.mod h1:uMAeX8OqG9vqdhyrIPv8Lajo/wXTtAF43wchP9WHt2w=
github.com/kataras/pio v0.0.13 h1:x0rXVX0fviDTXOOLOmr4MUxOabu1InVSTu5itF8CXCM=
github.com/kataras/pio v0.0.13/go.mod h1:k3HNuSw+eJ8Pm2lA4lRhg3DiCjVgHlP8hmXApSej3oM=
github.com/kataras/pio v0.0.14 h1:VGBHOmhwrMMrZeuRqoSfOrFwG+v1JxQge8N50DhmRYQ=
github.com/kataras/pio v0.0.14/go.mod h1:ZIlcw5+5Zyb/kOlU7X4uosZ8dbnXmA4GcGKt1XyyTY0=
github.com/kataras/sitemap v0.0.6 h1:w71CRMMKYMJh6LR2wTgnk5hSgjVNB9KL60n5e2KHvLY=
github.com/kataras/sitemap v0.0.6/go.mod h1:dW4dOCNs896OR1HmG+dMLdT7JjDk7mYBzoIRwuj5jA4=
github.com/kataras/tunnel v0.0.4 h1:sCAqWuJV7nPzGrlb0os3j49lk2JhILT0rID38NHNLpA=
@@ -194,14 +222,22 @@ github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQ
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/mholt/archives v0.1.0 h1:FacgJyrjiuyomTuNA92X5GyRBRZjE43Y/lrzKIlF35Q=
github.com/mholt/archives v0.1.0/go.mod h1:j/Ire/jm42GN7h90F5kzj6hf6ZFzEH66de+hmjEKu+I=
github.com/mholt/archives v0.1.3 h1:aEAaOtNra78G+TvV5ohmXrJOAzf++dIlYeDW3N9q458=
github.com/mholt/archives v0.1.3/go.mod h1:LUCGp++/IbV/I0Xq4SzcIR6uwgeh2yjnQWamjRQfLTU=
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
github.com/mikelolasagasti/xz v1.0.1 h1:Q2F2jX0RYJUG3+WsM+FJknv+6eVjsjXNDV0KJXZzkD0=
github.com/mikelolasagasti/xz v1.0.1/go.mod h1:muAirjiOUxPRXwm9HdDtB3uoRPrGnL85XHtokL9Hcgc=
github.com/minio/minlz v1.0.1 h1:OUZUzXcib8diiX+JYxyRLIdomyZYzHct6EShOKtQY2A=
github.com/minio/minlz v1.0.1/go.mod h1:qT0aEB35q79LLornSzeDH75LBf3aH1MV+jB5w9Wasec=
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nwaples/rardecode/v2 v2.1.0 h1:JQl9ZoBPDy+nIZGb1mx8+anfHp/LV3NE2MjMiv0ct/U=
github.com/nwaples/rardecode/v2 v2.1.0/go.mod h1:7uz379lSxPe6j9nvzxUZ+n7mnJNgjsRNb6IbvGVHRmw=
github.com/nwaples/rardecode/v2 v2.1.1 h1:OJaYalXdliBUXPmC8CZGQ7oZDxzX1/5mQmgn0/GASew=
github.com/nwaples/rardecode/v2 v2.1.1/go.mod h1:7uz379lSxPe6j9nvzxUZ+n7mnJNgjsRNb6IbvGVHRmw=
github.com/otiai10/copy v1.14.1 h1:5/7E6qsUMBaH5AnQ0sSLzzTg1oTECmcCmT6lvF45Na8=
github.com/otiai10/copy v1.14.1/go.mod h1:oQwrEDDOci3IM8dJF0d8+jnbfPDllW6vUjNc3DoZm9I=
github.com/otiai10/mint v1.6.3 h1:87qsV/aw1F5as1eH1zS/yqHY85ANKVMgkDrf9rcxbQs=
@@ -232,6 +268,10 @@ github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sS
github.com/smartystreets/goconvey v1.8.1/go.mod h1:+/u4qLyY6x1jReYOp7GOM2FSt8aP9CzCZL03bI28W60=
github.com/sorairolake/lzip-go v0.3.5 h1:ms5Xri9o1JBIWvOFAorYtUNik6HI3HgBTkISiqu0Cwg=
github.com/sorairolake/lzip-go v0.3.5/go.mod h1:N0KYq5iWrMXI0ZEXKXaS9hCyOjZUQdBDEIbXfoUwbdk=
github.com/sorairolake/lzip-go v0.3.7 h1:vP2uiD/NoklLyzYMdgOWkZME0ulkSfVTTE4MNRKCwNs=
github.com/sorairolake/lzip-go v0.3.7/go.mod h1:THOHr0FlNVCw2eOIEE9shFJAG1QxQg/pf2XUPAmNIqg=
github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA=
github.com/spf13/afero v1.14.0/go.mod h1:acJQ8t0ohCGuMN3O+Pv0V0hgMxNYDlvdk+VTfyZmbYo=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
@@ -246,11 +286,17 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tdewolff/minify/v2 v2.21.3 h1:KmhKNGrN/dGcvb2WDdB5yA49bo37s+hcD8RiF+lioV8=
github.com/tdewolff/minify/v2 v2.21.3/go.mod h1:iGxHaGiONAnsYuo8CRyf8iPUcqRJVB/RhtEcTpqS7xw=
github.com/tdewolff/minify/v2 v2.23.8 h1:tvjHzRer46kwOfpdCBCWsDblCw3QtnLJRd61pTVkyZ8=
github.com/tdewolff/minify/v2 v2.23.8/go.mod h1:VW3ISUd3gDOZuQ/jwZr4sCzsuX+Qvsx87FDMjk6Rvno=
github.com/tdewolff/parse/v2 v2.7.20 h1:Y33JmRLjyGhX5JRvYh+CO6Sk6pGMw3iO5eKGhUhx8JE=
github.com/tdewolff/parse/v2 v2.7.20/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA=
github.com/tdewolff/parse/v2 v2.8.1 h1:J5GSHru6o3jF1uLlEKVXkDxxcVx6yzOlIVIotK4w2po=
github.com/tdewolff/parse/v2 v2.8.1/go.mod h1:Hwlni2tiVNKyzR1o6nUs4FOF07URA+JLBLd6dlIXYqo=
github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739 h1:IkjBCtQOOjIn03u/dMQK9g+Iw9ewps4mCl1nB8Sscbo=
github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8=
github.com/tdewolff/test v1.0.11 h1:FdLbwQVHxqG16SlkGveC0JVyrJN62COWTRyUFzfbtBE=
github.com/tdewolff/test v1.0.11/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8=
github.com/therootcompany/xz v1.0.1 h1:CmOtsn1CbtmyYiusbfmhmkpAAETj0wBIH6kCYaX+xzw=
github.com/therootcompany/xz v1.0.1/go.mod h1:3K3UH1yCKgBneZYhuQUvJ9HPD19UEXEI0BWbMn8qNMY=
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
@@ -265,6 +311,8 @@ github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc=
github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w=
github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU=
github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
@@ -279,6 +327,8 @@ github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 h1:FnBeRrxr7OU4VvAzt5X7s6266i6cSVkkFPS0TuXWbIg=
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY=
@@ -301,6 +351,8 @@ go4.org v0.0.0-20230225012048-214862532bf5/go.mod h1:F57wTi5Lrj6WLyswp5EYV1ncrEb
golang.design/x/clipboard v0.6.3/go.mod h1:kqBSweBP0/im4SZGGjLrppH0D400Hnfo5WbFKSNK8N4=
golang.design/x/clipboard v0.7.0 h1:4Je8M/ys9AJumVnl8m+rZnIvstSnYj1fvzqYrU3TXvo=
golang.design/x/clipboard v0.7.0/go.mod h1:PQIvqYO9GP29yINEfsEn5zSQKAz3UgXmZKzDA6dnq2E=
golang.design/x/clipboard v0.7.1 h1:OEG3CmcYRBNnRwpDp7+uWLiZi3hrMRJpE9JkkkYtz2c=
golang.design/x/clipboard v0.7.1/go.mod h1:i5SiIqj0wLFw9P/1D7vfILFK0KHMk7ydE72HRrUIgkg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
@@ -312,6 +364,8 @@ golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -323,13 +377,19 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20250228200357-dead58393ab7 h1:aWwlzYV971S4BXRS9AmqwDLAD85ouC6X+pocatKY58c=
golang.org/x/exp v0.0.0-20250228200357-dead58393ab7/go.mod h1:BHOTPb3L19zxehTsLoJXVaTktb06DFgmdW6Wb9s8jqk=
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
golang.org/x/exp/shiny v0.0.0-20250228200357-dead58393ab7 h1:VxTRg3kpOpYQ+S2PlDH9x2j/ZOQMxVsPgdYYRvkErNY=
golang.org/x/exp/shiny v0.0.0-20250228200357-dead58393ab7/go.mod h1:ygj7T6vSGhhm/9yTpOQQNvuAUFziTH7RUiH74EoE2C8=
golang.org/x/exp/shiny v0.0.0-20250620022241-b7579e27df2b h1:zELBzk+7ERc6m8BxhzU2VYjp03wlEvi+cIgYQR5H3CI=
golang.org/x/exp/shiny v0.0.0-20250620022241-b7579e27df2b/go.mod h1:ygj7T6vSGhhm/9yTpOQQNvuAUFziTH7RUiH74EoE2C8=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/image v0.24.0 h1:AN7zRgVsbvmTfNyqIbbOraYL8mSwcKncEj8ofjgzcMQ=
golang.org/x/image v0.24.0/go.mod h1:4b/ITuLfqYq1hqZcjofwctIhi7sZh2WaCjvsBNjjya8=
golang.org/x/image v0.28.0 h1:gdem5JW1OLS4FbkWgLO+7ZeFzYtL3xClb97GaUzYMFE=
golang.org/x/image v0.28.0/go.mod h1:GUJYXtnGKEUgggyzh+Vxt+AviiCcyiwpsl8iQ8MvwGY=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@@ -344,6 +404,8 @@ golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCc
golang.org/x/mobile v0.0.0-20210716004757-34ab1303b554/go.mod h1:jFTmtFYCV0MFtXBU+J5V/+5AUeVS0ON/0WkE/KSrl6E=
golang.org/x/mobile v0.0.0-20250218173827-cd096645fcd3 h1:0V/7Y1FEaFdAzb9DkVDh4QFp4vL4yYCiJ5cjk80lZyA=
golang.org/x/mobile v0.0.0-20250218173827-cd096645fcd3/go.mod h1:j5VYNgQ6lZYZlzHFjdgS2UeqRSZunDk+/zXVTAIA3z4=
golang.org/x/mobile v0.0.0-20250606033058-a2a15c67f36f h1:/n+PL2HlfqeSiDCuhdBbRNlGS/g2fM4OHufalHaTVG8=
golang.org/x/mobile v0.0.0-20250606033058-a2a15c67f36f/go.mod h1:ESkJ836Z6LpG6mTVAhA48LpfW/8fNR0ifStlH2axyfg=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
@@ -382,6 +444,8 @@ golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -402,6 +466,8 @@ golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -434,6 +500,8 @@ golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -445,6 +513,8 @@ golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg=
golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -461,10 +531,14 @@ golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.10.0 h1:3usCWA8tQn0L8+hFJQNgzpWbd89begxN66o1Ojdn5L4=
golang.org/x/time v0.10.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
@@ -534,6 +608,8 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U=
+43 -11
View File
@@ -148,7 +148,7 @@ func replace(opts options) {
}
}
func injectLR(opts options) {
func injectLR(lrport uint, opts options) {
if opts.Watch.InjectLiveReload == "" {
return
}
@@ -162,15 +162,17 @@ func injectLR(opts options) {
htmlContent := string(contents)
// First modify CSP
cspModified, err := updateContentPolicyTag(htmlContent)
if err != nil {
fmt.Println("Error modifying CSP:", err)
return
if !opts.Watch.SkipCSPInject {
// First modify CSP
htmlContent, err = updateContentPolicyTag(lrport, htmlContent)
if err != nil {
fmt.Println("Error modifying CSP:", err)
return
}
}
// Then inject script
finalHTML, err := injectLiveReloadScript(cspModified)
finalHTML, err := injectLiveReloadScript(lrport, htmlContent)
if err != nil {
fmt.Println("Error injecting script:", err)
return
@@ -185,7 +187,7 @@ func injectLR(opts options) {
fmt.Printf("Injected live reload script reference into %s\n", opts.Watch.InjectLiveReload)
}
func injectLiveReloadScript(html string) (string, error) {
func injectLiveReloadScript(lrport uint, html string) (string, error) {
// Check if script is already present
if strings.Contains(html, "livereload.js") {
return html, nil
@@ -197,19 +199,19 @@ func injectLiveReloadScript(html string) (string, error) {
return html, nil // Return unchanged if no body tag found
}
scriptTag := `<script src="http://localhost:35729/livereload.js" type="text/javascript"></script>`
scriptTag := fmt.Sprintf(`<script src="http://localhost:%d/livereload.js" type="text/javascript"></script>`, lrport)
newHTML := bodyCloseRegex.ReplaceAllString(html, scriptTag+"</body>")
return newHTML, nil
}
func updateContentPolicyTag(html string) (string, error) {
func updateContentPolicyTag(lrport uint, html string) (string, error) {
doc, err := goquery.NewDocumentFromReader(strings.NewReader(html))
if err != nil {
return html, err
}
liveReloadHost := "localhost:35729"
liveReloadHost := fmt.Sprintf("localhost:%d", lrport)
liveReloadURL := "http://" + liveReloadHost
liveReloadWS := "ws://" + liveReloadHost
@@ -277,6 +279,9 @@ func updateContentPolicyTag(html string) (string, error) {
func build(opts options) {
esBuildOpts := cfgToESBuildCfg(opts)
esBuildOpts.Plugins = append(esBuildOpts.Plugins, contentSwapPlugin(opts))
result := api.Build(esBuildOpts)
if len(result.Errors) == 0 {
@@ -284,6 +289,33 @@ func build(opts options) {
}
}
func contentSwapPlugin(opts options) api.Plugin {
return api.Plugin{
Name: "content-swap",
Setup: func(build api.PluginBuild) {
build.OnLoad(api.OnLoadOptions{Filter: `.*`},
func(args api.OnLoadArgs) (api.OnLoadResult, error) {
for _, swap := range opts.ContentSwap {
if strings.HasSuffix(args.Path, swap.File) {
fmt.Printf("Swapping content of %s with %s\n", args.Path, swap.ReplaceWith)
text, err := os.ReadFile(swap.ReplaceWith)
if err != nil {
return api.OnLoadResult{}, err
}
contents := string(text)
return api.OnLoadResult{
Contents: &contents,
Loader: api.LoaderJS,
}, nil
}
}
return api.OnLoadResult{}, nil
})
},
}
}
func getGoModuleName(root string) (string, error) {
modFile := filepath.Join(root, "go.mod")
+30 -3
View File
@@ -48,9 +48,36 @@ func link(from, to string) chan struct{} {
w.FilterOps(watcher.Write, watcher.Rename, watcher.Move, watcher.Create, watcher.Remove)
w.IgnoreHiddenFiles(true)
if err := w.AddRecursive(from); err != nil {
fmt.Println(err.Error())
os.Exit(1)
// Instead of watching the entire directory tree, only watch the package directories
// that we need to monitor
for _, packagePath := range packages {
err := filepath.Walk(packagePath, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
// Skip excluded directories completely
if info.IsDir() && isExcludedPath(path, "node_modules", ".git") {
return filepath.SkipDir
}
// Only add directories and relevant files that aren't in excluded paths
if !isExcludedPath(path, "node_modules", ".git") {
if info.IsDir() {
return w.Add(path)
}
// Only watch JavaScript and TypeScript files
if isIncludedExt(info.Name(), "*.js", "*.ts") {
return w.Add(path)
}
}
return nil
})
if err != nil {
fmt.Printf("Error setting up watcher for %s: %v\n", packagePath, err)
}
}
go func() {
+13 -4
View File
@@ -26,7 +26,7 @@ func main() {
app := &cli.App{
Name: "gowebbuild",
Usage: "All in one tool to build web frontend projects.",
Version: "7.1.1",
Version: "7.7.0",
Authors: []*cli.Author{{
Name: "trading-peter (https://github.com/trading-peter)",
}},
@@ -85,8 +85,11 @@ $ gowebbuild replace *.go foo bar
Flags: []cli.Flag{
cfgParam,
&cli.UintFlag{
Name: "lr-port",
Value: uint(lrserver.DefaultPort),
Name: "lr-port",
Value: (func() uint {
port := findFreePort(int(lrserver.DefaultPort), int(lrserver.DefaultPort)+100)
return uint(port)
}()),
Usage: "port for the live reload server",
},
},
@@ -102,6 +105,11 @@ $ gowebbuild replace *.go foo bar
Value: "./",
Usage: "folder to serve",
},
&cli.StringFlag{
Name: "src",
Value: "./",
Usage: "folder to watch for changes and trigger live reload",
},
&cli.UintFlag{
Name: "port",
Value: uint(8080),
@@ -116,6 +124,7 @@ $ gowebbuild replace *.go foo bar
Action: func(ctx *cli.Context) error {
port := ctx.Uint("port")
root := ctx.String("root")
src := ctx.String("src")
lrPort := ctx.Uint("lr-port")
if lrPort != 0 {
@@ -124,7 +133,7 @@ $ gowebbuild replace *.go foo bar
w.SetMaxEvents(1)
w.FilterOps(watcher.Write, watcher.Rename, watcher.Move, watcher.Create, watcher.Remove)
if err := w.AddRecursive(root); err != nil {
if err := w.AddRecursive(src); err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
+129
View File
@@ -0,0 +1,129 @@
package main
import (
"fmt"
"os"
"path/filepath"
"reflect"
"regexp"
"strings"
)
// mergeOptions layers an extending profile on top of the profile it extends:
// scalar fields from the overlay win when set, slices are concatenated
// (base first, de-duplicated), nested structs merge recursively.
func mergeOptions(base, overlay options) options {
merged := mergeValue(reflect.ValueOf(base), reflect.ValueOf(overlay)).Interface().(options)
merged.Extends = "" // already resolved; must not re-trigger
return merged
}
func mergeValue(base, overlay reflect.Value) reflect.Value {
switch base.Kind() {
case reflect.Struct:
out := reflect.New(base.Type()).Elem()
for i := range base.NumField() {
out.Field(i).Set(mergeValue(base.Field(i), overlay.Field(i)))
}
return out
case reflect.Slice:
if base.Len() == 0 {
return overlay
}
if overlay.Len() == 0 {
return base
}
return concatDedupe(base, overlay)
default:
if overlay.IsZero() {
return base
}
return overlay
}
}
func concatDedupe(base, overlay reflect.Value) reflect.Value {
out := reflect.MakeSlice(base.Type(), 0, base.Len()+overlay.Len())
for _, src := range []reflect.Value{base, overlay} {
for i := range src.Len() {
v := src.Index(i)
dup := false
for j := range out.Len() {
if reflect.DeepEqual(out.Index(j).Interface(), v.Interface()) {
dup = true
break
}
}
if !dup {
out = reflect.Append(out, v)
}
}
}
return out
}
// filterEntryPoints removes entry points matched by any excludeEntryPoints
// pattern. Patterns are matched against the resolved (absolute, forward-slash)
// entry paths and support ** (any characters, including path separators),
// * (anything except a path separator) and ? (a single character).
func filterEntryPoints(opts *options) {
if len(opts.ESBuild.ExcludeEntryPoints) == 0 || len(opts.ESBuild.EntryPoints) == 0 {
return
}
patterns := make([]*regexp.Regexp, 0, len(opts.ESBuild.ExcludeEntryPoints))
for _, p := range opts.ESBuild.ExcludeEntryPoints {
re, err := regexp.Compile(patternToRegexp(filepath.ToSlash(p)))
if err != nil {
fmt.Printf("invalid excludeEntryPoints pattern %q: %+v\n", p, err)
os.Exit(1)
}
patterns = append(patterns, re)
}
kept := make([]string, 0, len(opts.ESBuild.EntryPoints))
for _, e := range opts.ESBuild.EntryPoints {
excluded := false
for _, re := range patterns {
if re.MatchString(filepath.ToSlash(e)) {
excluded = true
break
}
}
if !excluded {
kept = append(kept, e)
}
}
opts.ESBuild.EntryPoints = kept
}
func patternToRegexp(pattern string) string {
var b strings.Builder
b.WriteString("^")
// Classic loop: the body advances i to consume the second '*' of '**'.
for i := 0; i < len(pattern); i++ {
switch c := pattern[i]; c {
case '*':
if i+1 < len(pattern) && pattern[i+1] == '*' {
b.WriteString(".*")
i++
} else {
b.WriteString("[^/]*")
}
case '?':
b.WriteString("[^/]")
default:
b.WriteString(regexp.QuoteMeta(string(c)))
}
}
b.WriteString("$")
return b.String()
}
+8
View File
@@ -1,6 +1,14 @@
# A profile may inherit from another config file: the first profile of the
# referenced file is merged underneath this one (slices concatenate base-first,
# scalars from this profile win when set). Chains resolve recursively.
# extends: ./.gowebbuild.base.yaml
- esbuild:
entryPoints:
- frontend/the-app.js
# Entry points matching any of these patterns are removed after the
# merge. ** spans path separators, * stays within one segment.
# excludeEntryPoints:
# - ./frontend/src/apps/experimental/**
outdir: ./frontend-dist
sourcemap: 1
format: 3
+8 -5
View File
@@ -13,11 +13,13 @@ import (
func watchAction(ctx *cli.Context) error {
cfgPath, err := filepath.Abs(ctx.String("c"))
if err != nil {
return err
}
lrport := ctx.Uint("lr-port")
fmt.Printf("Live reload is running on port %d\n", lrport)
os.Chdir(filepath.Dir(cfgPath))
optsSetups := readCfg(cfgPath)
@@ -25,7 +27,7 @@ func watchAction(ctx *cli.Context) error {
purge(opts)
cp(opts)
build(opts)
injectLR(opts)
injectLR(lrport, opts)
replace(opts)
}
@@ -46,6 +48,8 @@ func watchAction(ctx *cli.Context) error {
}
for _, p := range opts.Watch.Paths {
w.Ignore(filepath.Join(p, ".git"))
if err := w.AddRecursive(p); err != nil {
fmt.Println(err.Error())
os.Exit(1)
@@ -56,7 +60,7 @@ func watchAction(ctx *cli.Context) error {
for {
select {
case event := <-w.Event:
fmt.Printf("File %s changed\n", event.Name())
fmt.Printf("File %s changed\n", event.Path)
pipeline(opts)
case err := <-w.Error:
fmt.Println(err.Error())
@@ -104,8 +108,7 @@ func watchAction(ctx *cli.Context) error {
go func() {
fmt.Println("Starting live reload server.")
port := ctx.Uint("lr-port")
lr := lrserver.New(lrserver.DefaultName, uint16(port))
lr := lrserver.New(lrserver.DefaultName, uint16(lrport))
go func() {
for {