Skip to content
Snippets Groups Projects
Verified Commit 3e81f2cf authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

feat: new javascript generation #9

parent 0e66a23b
No related branches found
No related tags found
No related merge requests found
Showing
with 9928 additions and 12 deletions
...@@ -12,6 +12,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 ...@@ -12,6 +12,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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=
github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
...@@ -50,22 +52,33 @@ github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52/go.mod h1:6DAvZli ...@@ -50,22 +52,33 @@ github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52/go.mod h1:6DAvZli
github.com/volker-schukai/tokenizer v1.0.0 h1:wF4haFoCodq7lgAk8c+th/DZmpFpL2WVD8wDzAGU1mA= github.com/volker-schukai/tokenizer v1.0.0 h1:wF4haFoCodq7lgAk8c+th/DZmpFpL2WVD8wDzAGU1mA=
github.com/volker-schukai/tokenizer v1.0.0/go.mod h1:LPw7lLIxUnZgeg96818N7IvwLE1x8ya31J/Aa0aCq9M= github.com/volker-schukai/tokenizer v1.0.0/go.mod h1:LPw7lLIxUnZgeg96818N7IvwLE1x8ya31J/Aa0aCq9M=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
gitlab.schukai.com/oss/libraries/go/application/configuration.git v1.22.9/go.mod h1:pZ+8vTAodhn3BfWMXMe18q3Ys0Dc9v3MPHY4jY4vClk=
gitlab.schukai.com/oss/libraries/go/application/xflags v1.16.3 h1:IWRCQOsZZPkoh/vIzjsF8BnqT4VVbOlCtfeuaYV5qEQ= gitlab.schukai.com/oss/libraries/go/application/xflags v1.16.3 h1:IWRCQOsZZPkoh/vIzjsF8BnqT4VVbOlCtfeuaYV5qEQ=
gitlab.schukai.com/oss/libraries/go/application/xflags v1.16.3/go.mod h1:e+uFr/73kXoSozlAewBBqKsAUCIichlcvNDyj/0fj9Q= gitlab.schukai.com/oss/libraries/go/application/xflags v1.16.3/go.mod h1:e+uFr/73kXoSozlAewBBqKsAUCIichlcvNDyj/0fj9Q=
gitlab.schukai.com/oss/libraries/go/application/xflags v1.16.5 h1:lghTHrRwlF7YSXkG/KRlJvnZuK3Z8HeM7aEiEbFXIEQ=
gitlab.schukai.com/oss/libraries/go/application/xflags v1.16.5/go.mod h1:6477TWP2W0vWWJ6Ctu/Mdh5SsjKUVVPFDgFfM4YdtcU=
gitlab.schukai.com/oss/libraries/go/application/xflags.git v1.16.5 h1:YD1skbZRu3iUHafIhGIEcZqPHJXA65Zj0AcSgsTQJAk=
gitlab.schukai.com/oss/libraries/go/application/xflags.git v1.16.5/go.mod h1:6477TWP2W0vWWJ6Ctu/Mdh5SsjKUVVPFDgFfM4YdtcU=
gitlab.schukai.com/oss/libraries/go/markup/html v0.4.6 h1:eMold9Nl6ZkygVF1K1lTA3ROGz/mlEIcPt9aUUJC33c= gitlab.schukai.com/oss/libraries/go/markup/html v0.4.6 h1:eMold9Nl6ZkygVF1K1lTA3ROGz/mlEIcPt9aUUJC33c=
gitlab.schukai.com/oss/libraries/go/markup/html v0.4.6/go.mod h1:FAzz3QWPCqQG54ou0zLnF6j3/ZQgGSTGsTHLShc3UFU= gitlab.schukai.com/oss/libraries/go/markup/html v0.4.6/go.mod h1:FAzz3QWPCqQG54ou0zLnF6j3/ZQgGSTGsTHLShc3UFU=
gitlab.schukai.com/oss/libraries/go/markup/html.git v0.4.7 h1:LxNtSNRXV9Ay3rKDH/KaVLORd0IpUClbfHo9tXG3Y4Q=
gitlab.schukai.com/oss/libraries/go/markup/html.git v0.4.7/go.mod h1:vlqd5glmCGm0rdM/QXWq/ifGdIM/wq7ynSzHFnl4LzU=
gitlab.schukai.com/oss/libraries/go/services/job-queues.git v1.20.2/go.mod h1:SZmOS4cms25c9UIOq9S2qTKHrPLmKYk0GqqtVCt4dxk=
gitlab.schukai.com/oss/libraries/go/utilities/data.git v0.2.0 h1:JVxMHiA8zFVjJDhNl65XeYrhdMkzB+5dyrBUEZ982WU=
gitlab.schukai.com/oss/libraries/go/utilities/data.git v0.2.0/go.mod h1:BsR4Y9jsvISplkW6UoLFRGxQX69/AUmP1SXRwWhx31o=
gitlab.schukai.com/oss/libraries/go/utilities/data.git v0.2.2 h1:jRlVTikl73AL1y9OfYxdZ4OYG8Hkbl/8ezbwd9r5l44= gitlab.schukai.com/oss/libraries/go/utilities/data.git v0.2.2 h1:jRlVTikl73AL1y9OfYxdZ4OYG8Hkbl/8ezbwd9r5l44=
gitlab.schukai.com/oss/libraries/go/utilities/data.git v0.2.2/go.mod h1:Vl5kzzMjpy1LGe+RUi2pTnZvZFP53Th4JChP9dbkOVk= gitlab.schukai.com/oss/libraries/go/utilities/data.git v0.2.2/go.mod h1:Vl5kzzMjpy1LGe+RUi2pTnZvZFP53Th4JChP9dbkOVk=
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.9.4 h1:/+fgcPeXqz5tRrT+EZXA2vGV+OWV9R+5hEBpRJUpp80= gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.9.4 h1:/+fgcPeXqz5tRrT+EZXA2vGV+OWV9R+5hEBpRJUpp80=
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.9.4/go.mod h1:36psT3WHelpcXWXVp8D33IXvUIpaAXEtrQYYOODUbjE= gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.9.4/go.mod h1:36psT3WHelpcXWXVp8D33IXvUIpaAXEtrQYYOODUbjE=
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder.git v0.9.5 h1:PiDmw3O3UDubKILC+t7fKs+m9670a+b8SkrHq5Rkk9M= gitlab.schukai.com/oss/libraries/go/utilities/pathfinder.git v0.9.5 h1:PiDmw3O3UDubKILC+t7fKs+m9670a+b8SkrHq5Rkk9M=
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder.git v0.9.5/go.mod h1:HwXjaFUAxLv+qTN63xrPBO5DEVGuZNF859t29bhTsFQ= gitlab.schukai.com/oss/libraries/go/utilities/pathfinder.git v0.9.5/go.mod h1:HwXjaFUAxLv+qTN63xrPBO5DEVGuZNF859t29bhTsFQ=
gitlab.schukai.com/oss/libraries/go/utilities/watch.git v0.4.2/go.mod h1:7Rv8r5eVw5FDRp/K3KlDmjNMrdj7JA7eC3o6s7JBcHU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY= golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8= golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
...@@ -73,8 +86,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v ...@@ -73,8 +86,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
...@@ -82,12 +95,13 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h ...@@ -82,12 +95,13 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 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= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
......
...@@ -3,7 +3,7 @@ package html ...@@ -3,7 +3,7 @@ package html
import ( import (
"github.com/andybalholm/cascadia" "github.com/andybalholm/cascadia"
"gitlab.schukai.com/oss/bob/types" "gitlab.schukai.com/oss/bob/types"
"gitlab.schukai.com/oss/libraries/go/markup/html/engine" engine "gitlab.schukai.com/oss/libraries/go/markup/html.git/engine"
"golang.org/x/net/html" "golang.org/x/net/html"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"os" "os"
......
...@@ -5,7 +5,7 @@ import ( ...@@ -5,7 +5,7 @@ import (
"github.com/andybalholm/cascadia" "github.com/andybalholm/cascadia"
"github.com/charmbracelet/log" "github.com/charmbracelet/log"
"gitlab.schukai.com/oss/bob/types" "gitlab.schukai.com/oss/bob/types"
"gitlab.schukai.com/oss/libraries/go/markup/html/engine" "gitlab.schukai.com/oss/libraries/go/markup/html.git/engine"
"golang.org/x/net/html" "golang.org/x/net/html"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"os" "os"
......
...@@ -4,7 +4,7 @@ import ( ...@@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"github.com/andybalholm/cascadia" "github.com/andybalholm/cascadia"
"gitlab.schukai.com/oss/bob/types" "gitlab.schukai.com/oss/bob/types"
"gitlab.schukai.com/oss/libraries/go/markup/html/engine" engine "gitlab.schukai.com/oss/libraries/go/markup/html.git/engine"
"golang.org/x/net/html" "golang.org/x/net/html"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"os" "os"
......
package javascript
import (
"github.com/charmbracelet/log"
"golang.org/x/net/html"
"os"
"path"
"strings"
"github.com/evanw/esbuild/pkg/api"
)
func ParseHTMLFile(p string, development bool) error {
data, err := os.ReadFile(p)
if err != nil {
return err
}
doc, err := html.Parse(strings.NewReader(string(data)))
if err != nil {
return err
}
var f func(*html.Node)
f = func(n *html.Node) {
var src, source, scriptDist, styleDist, target string
if n.Type == html.ElementNode && n.Data == "script" {
for _, attr := range n.Attr {
if attr.Key == "data-bob-source" {
source = attr.Val
} else if attr.Key == "data-bob-script-dist" {
scriptDist = attr.Val
} else if attr.Key == "data-bob-style-dist" {
styleDist = attr.Val
} else if attr.Key == "data-bob-target" {
target = attr.Val
} else if attr.Key == "src" {
src = attr.Val
}
}
if src != "" {
if !path.IsAbs(source) {
source = path.Dir(p) + "/" + source
if _, err := os.Stat(source); os.IsNotExist(err) {
log.Error("File does not exist: " + source)
return
}
}
if !path.IsAbs(scriptDist) {
scriptDist = path.Dir(p) + "/" + scriptDist
}
if !path.IsAbs(styleDist) {
styleDist = path.Dir(p) + "/" + styleDist
}
log.Info("Script: " + src + " " + source + " " + scriptDist + " " + styleDist)
runESBuild(source, path.Dir(p), scriptDist, styleDist, development, target)
}
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
f(c)
}
}
f(doc)
return nil
}
func runESBuild(source, dist, scriptDist, styleDist string, development bool, target string) {
// get temporary directory
//tempDir, err := os.MkdirTemp("", "build-bob")
//if err != nil {
// fmt.Println("Fehler beim Erstellen des temporären Verzeichnisses:", err)
// return
//}
//
//defer func() {
// err := os.RemoveAll(tempDir)
// if err != nil {
// fmt.Println("Fehler beim Löschen des temporären Verzeichnisses:", err)
// }
//
//}()
var treeShaking = api.TreeShakingTrue
if development {
treeShaking = api.TreeShakingFalse
}
keepNames := development
esbuildTarget := api.ESNext
if target != "" {
switch {
case target == "es5" || target == "es2015":
esbuildTarget = api.ES5
keepNames = false
case target == "es6" || target == "es2016":
esbuildTarget = api.ES2016
case target == "es7" || target == "es2017":
esbuildTarget = api.ES2017
case target == "es8" || target == "es2018":
esbuildTarget = api.ES2018
case target == "es9" || target == "es2019":
esbuildTarget = api.ES2019
case target == "es10" || target == "es2020":
esbuildTarget = api.ES2020
case target == "es11" || target == "es2021":
esbuildTarget = api.ES2021
case target == "es12" || target == "es2022":
esbuildTarget = api.ES2022
case target == "es13" || target == "es2023":
esbuildTarget = api.ES2023
case target == "es14" || target == "es2024":
esbuildTarget = api.ES2024
default:
log.Error("Unknown target: " + target + ". Using ESNext")
}
}
footer := map[string]string{
"js": `
/*
* Copyright protects this code. Use, reproduction, or
* modification of this code without prior written permission from the copyright holder
* is strictly prohibited. For inquiries regarding licenses or usage rights,
* please contact schukai GmbH.
*/`,
"css": `
/*
* Copyright protects this code. Use, reproduction, or
* modification of this code without prior written permission from the copyright holder
* is strictly prohibited. For inquiries regarding licenses or usage rights,
* please contact schukai GmbH.
*/
`,
}
var sourceMap = api.SourceMapNone
if development {
sourceMap = api.SourceMapInline
}
result := api.Build(api.BuildOptions{
EntryPoints: []string{source},
Outfile: path.Join(path.Base(scriptDist)),
Bundle: true,
Write: false,
LogLevel: api.LogLevelInfo,
Target: esbuildTarget,
MinifySyntax: !development,
MinifyWhitespace: !development,
MinifyIdentifiers: !development,
TreeShaking: treeShaking,
KeepNames: keepNames,
Sourcemap: sourceMap,
LegalComments: api.LegalCommentsExternal,
Footer: footer,
})
if len(result.Errors) > 0 {
for _, err := range result.Errors {
log.Error(err.Text)
}
}
for _, warning := range result.Warnings {
log.Warn(warning.Text)
}
for _, file := range result.OutputFiles {
switch path.Ext(file.Path) {
case ".mjs":
err := os.WriteFile(scriptDist, file.Contents, os.ModePerm)
if err != nil {
log.Error(err.Error())
} else {
log.Info("Saved " + scriptDist)
}
case ".js":
err := os.WriteFile(scriptDist, file.Contents, os.ModePerm)
if err != nil {
log.Error(err.Error())
} else {
log.Info("Saved " + scriptDist)
}
case ".css":
err := os.WriteFile(styleDist, file.Contents, os.ModePerm)
if err != nil {
log.Error(err.Error())
} else {
log.Info("Saved " + styleDist)
}
case ".txt":
content := file.Contents
if strings.TrimSpace(string(content)) == "" {
continue
}
if strings.Contains(file.Path, "LEGAL") {
if development {
log.Info("Legal information not saved in development mode")
continue
}
if strings.Contains(file.Path, "js") {
out := path.Join(path.Dir(scriptDist), path.Base(file.Path))
err := os.WriteFile(out, file.Contents, os.ModePerm)
if err != nil {
log.Error(err.Error())
} else {
log.Info("Saved " + out)
}
} else {
out := path.Join(path.Dir(styleDist), path.Base(file.Path))
err := os.WriteFile(out, file.Contents, os.ModePerm)
if err != nil {
log.Error(err.Error())
} else {
log.Info("Saved " + out)
}
}
}
}
}
}
...@@ -2,7 +2,8 @@ package main ...@@ -2,7 +2,8 @@ package main
import ( import (
"fmt" "fmt"
"gitlab.schukai.com/oss/libraries/go/application/xflags" xflags "gitlab.schukai.com/oss/libraries/go/application/xflags.git"
"os" "os"
) )
......
MIT License
Copyright (c) 2020 Evan Wallace
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
package api_helpers
// This flag is set by the CLI to activate the timer. It's put here instead of
// by the timer to discourage code from checking this flag. Only the code that
// creates the root timer should check this flag. Other code should check that
// the timer is not null to detect if the timer is being used or not.
var UseTimer bool
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
package cache
import (
"sync"
"github.com/evanw/esbuild/internal/fs"
)
// This cache uses information from the "stat" syscall to try to avoid re-
// reading files from the file system during subsequent builds if the file
// hasn't changed. The assumption is reading the file metadata is faster than
// reading the file contents.
type FSCache struct {
entries map[string]*fsEntry
mutex sync.Mutex
}
type fsEntry struct {
contents string
modKey fs.ModKey
isModKeyUsable bool
}
func (c *FSCache) ReadFile(fs fs.FS, path string) (contents string, canonicalError error, originalError error) {
entry := func() *fsEntry {
c.mutex.Lock()
defer c.mutex.Unlock()
return c.entries[path]
}()
// If the file's modification key hasn't changed since it was cached, assume
// the contents of the file are also the same and skip reading the file.
modKey, modKeyErr := fs.ModKey(path)
if entry != nil && entry.isModKeyUsable && modKeyErr == nil && entry.modKey == modKey {
return entry.contents, nil, nil
}
contents, err, originalError := fs.ReadFile(path)
if err != nil {
return "", err, originalError
}
c.mutex.Lock()
defer c.mutex.Unlock()
c.entries[path] = &fsEntry{
contents: contents,
modKey: modKey,
isModKeyUsable: modKeyErr == nil,
}
return contents, nil, nil
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment