From 80a9a2d436bdc2cd47115b178f16dd68a54589f6 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sun, 12 Jan 2025 02:12:44 +0700 Subject: all: update all dependencies --- go.mod | 23 ++++----- go.sum | 34 +++++++------- internal/internal.go | 129 +++++++++++++++++++++++++++------------------------ 3 files changed, 96 insertions(+), 90 deletions(-) diff --git a/go.mod b/go.mod index 0a24cea..9ce78aa 100644 --- a/go.mod +++ b/go.mod @@ -3,29 +3,26 @@ module git.sr.ht/~shulhan/awwan -go 1.22.0 +go 1.23.4 require ( - git.sr.ht/~shulhan/ciigo v0.14.0 - git.sr.ht/~shulhan/pakakeh.go v0.58.2-0.20241212161141-3361472cc3d4 - github.com/evanw/esbuild v0.24.0 + git.sr.ht/~shulhan/ciigo v0.15.0 + git.sr.ht/~shulhan/pakakeh.go v0.59.0 + github.com/evanw/esbuild v0.24.2 ) require ( - git.sr.ht/~shulhan/asciidoctor-go v0.6.1 // indirect + git.sr.ht/~shulhan/asciidoctor-go v0.6.2-0.20250106025231-ed20fc1c23e8 // indirect github.com/yuin/goldmark v1.7.8 // indirect github.com/yuin/goldmark-meta v1.1.0 // indirect - golang.org/x/crypto v0.31.0 // indirect - golang.org/x/net v0.32.0 // indirect - golang.org/x/sys v0.28.0 // indirect - golang.org/x/term v0.27.0 // indirect + golang.org/x/crypto v0.32.0 // indirect + golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect + golang.org/x/net v0.34.0 // indirect + golang.org/x/sys v0.29.0 // indirect + golang.org/x/term v0.28.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) -//replace github.com/evanw/esbuild => github.com/shuLhan/esbuild v0.19.9-0.20231209212032-2dc984ffc5f1 - -//replace golang.org/x/crypto => git.sr.ht/~shulhan/go-x-crypto v0.31.1-0.20241211185416-2a1055da2107 - //replace git.sr.ht/~shulhan/pakakeh.go => ../pakakeh.go //replace git.sr.ht/~shulhan/ciigo => ../ciigo diff --git a/go.sum b/go.sum index 157891c..b515dcc 100644 --- a/go.sum +++ b/go.sum @@ -1,24 +1,26 @@ -git.sr.ht/~shulhan/asciidoctor-go v0.6.1 h1:uXRFNYV+iiI8XLo8Bp1ZZM/orULkAqD2lfYtra/PzhU= -git.sr.ht/~shulhan/asciidoctor-go v0.6.1/go.mod h1:QeBhtZf4GjRgENlX2Xe/TXIupqZJUtH6U89YtOvZ08Q= -git.sr.ht/~shulhan/ciigo v0.14.0 h1:A1bKoKlOs0ZF8dUEH+m6N+c18Yhhv9fjrYD/Qt+X45s= -git.sr.ht/~shulhan/ciigo v0.14.0/go.mod h1:CuWoeaHXIf/w+YdN72M1IDiiGJF4r6qLB/A+ue2Xc8I= -git.sr.ht/~shulhan/pakakeh.go v0.58.2-0.20241212161141-3361472cc3d4 h1:GJuzSB1DntXGLZzhGhwMIuI66wsBIYXF5kfEvDh0qiQ= -git.sr.ht/~shulhan/pakakeh.go v0.58.2-0.20241212161141-3361472cc3d4/go.mod h1:andCp7SiIOiomrITys+AuhviJn/o2ASLQNrQjTlRkS4= -github.com/evanw/esbuild v0.24.0 h1:GZ78naTLp7FKr+K7eNuM/SLs5maeiHYRPsTg6kmdsSE= -github.com/evanw/esbuild v0.24.0/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48= +git.sr.ht/~shulhan/asciidoctor-go v0.6.2-0.20250106025231-ed20fc1c23e8 h1:8qzcug5hnyz1QPVxCf9J3JhIzPSnc+zUK5VQachVQf0= +git.sr.ht/~shulhan/asciidoctor-go v0.6.2-0.20250106025231-ed20fc1c23e8/go.mod h1:QOHiOctWAPcVlTMOKnnwmpnLrobkv7oNAPAf4gZjtWs= +git.sr.ht/~shulhan/ciigo v0.15.0 h1:wUtCLNCkUg+he0qtu4Sass9cp7g9eSRivywwFxUe5bs= +git.sr.ht/~shulhan/ciigo v0.15.0/go.mod h1:JsCkrOX3WKssLWGEaxMhXm1NMXdVi/J6cQEfp8fIEV8= +git.sr.ht/~shulhan/pakakeh.go v0.59.0 h1:haUyuusXQ0YVgHbbhi46Nkl/CEPhRe+cIJz22kQFGuM= +git.sr.ht/~shulhan/pakakeh.go v0.59.0/go.mod h1:UsrvzhSUJZpm1Aub99RI/XwtNnbBlJmaNoWWd9++VyI= +github.com/evanw/esbuild v0.24.2 h1:PQExybVBrjHjN6/JJiShRGIXh1hWVm6NepVnhZhrt0A= +github.com/evanw/esbuild v0.24.2/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48= github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic= github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc= github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0= -golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= -golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= +golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= +golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 h1:yqrTHse8TCMW1M1ZCP+VAR/l0kKxwaAIqN/il7x4voA= +golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU= +golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= +golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= -golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= +golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= +golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg= +golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/internal/internal.go b/internal/internal.go index 755dab0..c40696d 100644 --- a/internal/internal.go +++ b/internal/internal.go @@ -7,12 +7,15 @@ package internal import ( "fmt" + "os" + "path/filepath" "strings" "time" "git.sr.ht/~shulhan/ciigo" "git.sr.ht/~shulhan/pakakeh.go/lib/memfs" "git.sr.ht/~shulhan/pakakeh.go/lib/mlog" + "git.sr.ht/~shulhan/pakakeh.go/lib/watchfs/v2" "github.com/evanw/esbuild/pkg/api" esapi "github.com/evanw/esbuild/pkg/api" ) @@ -120,24 +123,24 @@ func Watch() { } } - var ( - dw = memfs.DirWatcher{ - Options: memfs.Options{ - Root: MemfsWui.Opts.Root, - Includes: []string{ - `.*\.(adoc|html|js|md|ts)$`, - }, - Excludes: []string{ - `node_modules`, - }, - }, - Delay: 200 * time.Millisecond, - } - ) + var dwOpts = watchfs.DirWatcherOptions{ + Root: MemfsWui.Opts.Root, + Includes: []string{ + `.*\.(adoc|html|js|md|ts)$`, + }, + Excludes: []string{ + `node_modules`, + }, + FileWatcherOptions: watchfs.FileWatcherOptions{ + File: filepath.Join(MemfsWui.Opts.Root, `.rescan`), + Interval: 200 * time.Millisecond, + }, + } + var dw *watchfs.DirWatcher - err = dw.Start() + dw, err = watchfs.WatchDir(dwOpts) if err != nil { - mlog.Fatalf(`%s: %s`, logp, err) + mlog.Fatalf(`%s: %w`, logp, err) } defer dw.Stop() @@ -145,63 +148,67 @@ func Watch() { var ( buildTicker = time.NewTicker(200 * time.Millisecond) - ns memfs.NodeState node *memfs.Node fmarkup *ciigo.FileMarkup + listfi []os.FileInfo tsCount int embedCount int ) for { select { - case ns = <-dw.C: - mlog.Outf(`%s: update on Path=%q SysPath=%q`, logp, ns.Node.Path, ns.Node.SysPath) - - switch { - case strings.HasSuffix(ns.Node.Path, `.adoc`), - strings.HasSuffix(ns.Node.Path, `.md`): - - fmarkup, err = ciigo.NewFileMarkup(ns.Node.SysPath, nil) - if err != nil { - mlog.Errf(`%s %q: %s`, logp, ns.Node.SysPath, err) - continue - } + case listfi = <-dw.C: + for _, fi := range listfi { + var name = fi.Name() + mlog.Outf(`%s: update on %q`, logp, name) + + switch { + case strings.HasSuffix(name, `.adoc`), + strings.HasSuffix(name, `.md`): + + var pathMarkup = filepath.Join(MemfsWui.Opts.Root, name) + fmarkup, err = ciigo.NewFileMarkup(pathMarkup, nil) + if err != nil { + mlog.Errf(`%s %q: %s`, logp, name, err) + continue + } + + err = ciigoConv.ToHTMLFile(fmarkup) + if err != nil { + mlog.Errf(`%s %q: %s`, logp, name, err) + continue + } - err = ciigoConv.ToHTMLFile(fmarkup) - if err != nil { - mlog.Errf(`%s %q: %s`, logp, ns.Node.Path, err) - continue - } - - embedCount++ - - case strings.HasSuffix(ns.Node.Path, `.ts`), - strings.HasSuffix(ns.Node.Path, `tsconfig.json`): - - tsCount++ - - case strings.HasSuffix(ns.Node.Path, `.css`), - strings.HasSuffix(ns.Node.Path, `.js`), - strings.HasSuffix(ns.Node.Path, `.html`): + embedCount++ - node, err = MemfsWui.Get(ns.Node.Path) - if err != nil { - mlog.Errf(`%s %q: %s`, logp, ns.Node.Path, err) - continue - } - err = node.Update(&ns.Node, 0) - if err != nil { - mlog.Errf(`%s %q: %s`, logp, ns.Node.Path, err) - continue - } - embedCount++ + case strings.HasSuffix(name, `.ts`), + strings.HasSuffix(name, `tsconfig.json`): + + tsCount++ + + case strings.HasSuffix(name, `.css`), + strings.HasSuffix(name, `.js`), + strings.HasSuffix(name, `.html`): + + node, err = MemfsWui.Get(name) + if err != nil { + mlog.Errf(`%s %q: %s`, logp, name, err) + continue + } + err = node.Update(node, 0) + if err != nil { + mlog.Errf(`%s %q: %s`, logp, name, err) + continue + } + embedCount++ - case strings.HasSuffix(ns.Node.SysPath, DocConvertOpts.HTMLTemplate): - err = ciigo.Convert(DocConvertOpts) - if err != nil { - mlog.Errf(`%s: %s`, logp, err) + case strings.HasSuffix(name, DocConvertOpts.HTMLTemplate): + err = ciigo.Convert(DocConvertOpts) + if err != nil { + mlog.Errf(`%s: %s`, logp, err) + } + embedCount++ } - embedCount++ } case <-buildTicker.C: -- cgit v1.3