parent
fe409baf4c
commit
9901ae7f4d
|
@ -271,15 +271,25 @@ type BundleResults struct {
|
||||||
func bundlePlugins(tmpDir string, manifest PluginManifest) (results *BundleResults, err error) {
|
func bundlePlugins(tmpDir string, manifest PluginManifest) (results *BundleResults, err error) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
|
hasAlias := manifest.Alias != ""
|
||||||
distDir := filepath.Join(tmpDir, "dist")
|
distDir := filepath.Join(tmpDir, "dist")
|
||||||
|
|
||||||
h := xxh3.New()
|
h := xxh3.New()
|
||||||
h.WriteString(manifest.Version)
|
h.WriteString(manifest.Version)
|
||||||
|
if hasAlias {
|
||||||
|
h.WriteString(manifest.Alias)
|
||||||
|
}
|
||||||
for _, plugin := range manifest.Plugins {
|
for _, plugin := range manifest.Plugins {
|
||||||
h.WriteString(plugin.Contents)
|
h.WriteString(plugin.Contents)
|
||||||
}
|
}
|
||||||
hash := h.Sum64()
|
hash := h.Sum64()
|
||||||
hashedName := fmt.Sprintf("datastar-%s-%x", toolbelt.Kebab(manifest.Version), hash)
|
var hashedName string
|
||||||
|
|
||||||
|
versionKebab := toolbelt.Kebab(manifest.Version)
|
||||||
|
if hasAlias {
|
||||||
|
hashedName = fmt.Sprintf("datastar-%s-%s-%x", toolbelt.Kebab(manifest.Alias), versionKebab, hash)
|
||||||
|
} else {
|
||||||
|
hashedName = fmt.Sprintf("datastar-%s-%x", versionKebab, hash)
|
||||||
|
}
|
||||||
|
|
||||||
bundleResultsPath := filepath.Join(distDir, hashedName+".json")
|
bundleResultsPath := filepath.Join(distDir, hashedName+".json")
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
templ PageBundler(r *http.Request, manifest PluginManifest, store *BundlerStore) {
|
templ PageBundler(r *http.Request, manifest PluginManifest, store *BundlerStore) {
|
||||||
|
@ -125,20 +126,6 @@ templ PageBundler(r *http.Request, manifest PluginManifest, store *BundlerStore)
|
||||||
}
|
}
|
||||||
|
|
||||||
templ bundlerResultsFragment(results BundleResults) {
|
templ bundlerResultsFragment(results BundleResults) {
|
||||||
<div id="results" class="flex gap-8">
|
|
||||||
<table class="table w-full">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Hash</th>
|
|
||||||
<th>Compile Time</th>
|
|
||||||
<th>Source Size Gzipped</th>
|
|
||||||
<th>Fast 4G</th>
|
|
||||||
<th>Slow 4G</th>
|
|
||||||
<th>3G</th>
|
|
||||||
<th class="text-right">Download</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{{
|
{{
|
||||||
srcBitsF := float64(8 * results.SourceSizeGzipped)
|
srcBitsF := float64(8 * results.SourceSizeGzipped)
|
||||||
srcTime := func(mbps float64) string {
|
srcTime := func(mbps float64) string {
|
||||||
|
@ -146,21 +133,31 @@ templ bundlerResultsFragment(results BundleResults) {
|
||||||
return fmt.Sprintf("%0.1fms", srcSecsF*1000)
|
return fmt.Sprintf("%0.1fms", srcSecsF*1000)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
<tr>
|
<div id="results" class="flex flex-col gap-8">
|
||||||
<td>{ results.Hash }</td>
|
<a class="btn btn-success btn-lg" href={ templ.SafeURL(results.DownloadURL) }>
|
||||||
<td>{ results.CompileTime.String() }</td>
|
|
||||||
<td>{ humanize.Comma(int64( results.SourceSizeGzipped)) } ({ humanize.IBytes(results.SourceSizeGzipped) }) </td>
|
|
||||||
<td>{ srcTime(9) }</td>
|
|
||||||
<td>{ srcTime(1.6) }</td>
|
|
||||||
<td>{ srcTime(0.5) }</td>
|
|
||||||
<td class="text-right">
|
|
||||||
<a class="btn btn-success" href={ templ.SafeURL(results.DownloadURL) }>
|
|
||||||
@icon("material-symbols:folder-zip")
|
@icon("material-symbols:folder-zip")
|
||||||
{ results.Name }.zip
|
{ results.Name }.zip
|
||||||
</a>
|
</a>
|
||||||
</td>
|
<div class="flex flex-wrap gap-4">
|
||||||
</tr>
|
<div class="stats stats-vertical shadow flex-1">
|
||||||
</tbody>
|
@bundleStat("mdi:rabbit", "Fast 4G", srcTime(9))
|
||||||
</table>
|
@bundleStat("fluent:animal-turtle-16-filled", "Slow 3G", srcTime(1.6))
|
||||||
|
@bundleStat("f7:slowmo", "3G", srcTime(0.5))
|
||||||
|
</div>
|
||||||
|
<div class="stats stats-vertical shadow flex-1">
|
||||||
|
@bundleStat("simple-icons:compilerexplorer", "Compile Time", fmt.Sprintf("%0.2fms", float64(results.CompileTime)/float64(time.Millisecond)))
|
||||||
|
@bundleStat("material-symbols:folder-zip", "Source Size", fmt.Sprintf("%d bytes %s", results.SourceSizeGzipped, humanize.IBytes(results.SourceSizeGzipped)))
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
templ bundleStat(iconName, label, value string) {
|
||||||
|
<div class="stat">
|
||||||
|
<div class="stat-figure text-success text-3xl">
|
||||||
|
@icon(iconName)
|
||||||
|
</div>
|
||||||
|
<div class="stat-title">{ label }</div>
|
||||||
|
<div class="stat-value">{ value }</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue