Pack codeless .bnp artifacts in the SDK
Moves the codeless build, validation and pack path from cli/internal/bnp into a public bnp package so the CLI and the orchestrator share it. BuildCodelessFS packs from an fs.FS and returns the artifact bytes; the directory form calls it through os.DirFS. Output is byte-identical to the old CLI build. ADR 0009. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
6dd745bc34
commit
3b13dccdbb
570
bnp/codeless.go
Normal file
570
bnp/codeless.go
Normal file
@ -0,0 +1,570 @@
|
||||
// Package bnp builds codeless .bnp plugin artifacts: it validates the
|
||||
// declarative plugin files and packs them as a zstd-compressed tar.
|
||||
package bnp
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
abiv1 "git.dev.alexdunmow.com/block/pluginsdk/abi/v1"
|
||||
core "git.dev.alexdunmow.com/block/pluginsdk/plugin"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
// Codeless artifacts (WO-WZ-020): a .bnp with NO plugin.wasm — pure
|
||||
// declaration the host runs. Classification is by repo shape: a plugin repo
|
||||
// with no Go source builds codeless; a repo with Go builds wasm as always
|
||||
// (a converted repo DELETES its Go — that's the point). Both artifact kinds
|
||||
// may carry blocks/, templates/, and seed/; codeless just has nothing else.
|
||||
|
||||
// Required top-level artifact members (mirrors the CMS reader).
|
||||
const (
|
||||
FileMod = "plugin.mod"
|
||||
FileManifest = "manifest.pb"
|
||||
)
|
||||
|
||||
// Declarative artifact dirs shared by both build paths.
|
||||
const (
|
||||
DirBlocks = "blocks"
|
||||
DirTemplates = "templates"
|
||||
DirSeed = "seed"
|
||||
)
|
||||
|
||||
// hostAbiVersion is the ABI major version the packer speaks. It must equal
|
||||
// the guest AbiVersion / the reader's supported major (1).
|
||||
const hostAbiVersion uint32 = 1
|
||||
|
||||
// manifestYAMLName is the optional root-level declarative manifest source for
|
||||
// codeless plugins (the counterpart of what DESCRIBE captures from Go code).
|
||||
const manifestYAMLName = "manifest.yaml"
|
||||
|
||||
// BuildOptions configures BuildCodeless.
|
||||
type BuildOptions struct {
|
||||
// Dir is the plugin repo root (holds plugin.mod and the main Go package).
|
||||
Dir string
|
||||
// Output is the destination .bnp path. Empty → "<name>-<version>.bnp" in
|
||||
// the current working directory.
|
||||
Output string
|
||||
}
|
||||
|
||||
// BuildResult summarizes a produced artifact for the CLI summary table.
|
||||
type BuildResult struct {
|
||||
OutputPath string
|
||||
Name string
|
||||
Version string
|
||||
// Codeless marks a declarative artifact (no plugin.wasm, WO-WZ-020).
|
||||
Codeless bool
|
||||
WasmBytes int64
|
||||
ManifestBytes int64
|
||||
ArtifactBytes int64 // on-disk .bnp size
|
||||
UncompBytes int64 // sum of packed file sizes
|
||||
BlockCount int
|
||||
TemplateCount int
|
||||
AdminPages int
|
||||
JobTypes int
|
||||
Hooks []string
|
||||
DataDir bool
|
||||
IncludedDirs []string
|
||||
// PreviewIncluded/ScreenshotCount report the packed presentation members
|
||||
// (root preview.png + screenshots/); the registry ingests these into the
|
||||
// plugin's gallery at publish.
|
||||
PreviewIncluded bool
|
||||
ScreenshotCount int
|
||||
}
|
||||
|
||||
// manifestYAML mirrors the declarative PluginManifest fields a codeless
|
||||
// plugin can set. File-valued keys are paths relative to the repo root.
|
||||
type manifestYAML struct {
|
||||
ThemePresets string `yaml:"theme_presets"` // JSON file
|
||||
BundledFonts string `yaml:"bundled_fonts"` // JSON file
|
||||
SettingsSchema string `yaml:"settings_schema"` // JSON file
|
||||
MasterPages string `yaml:"master_pages"` // JSON file ([]masterPageJSON)
|
||||
RequiredIconPacks []string `yaml:"required_icon_packs"`
|
||||
SystemTemplates []struct {
|
||||
Key string `yaml:"key"`
|
||||
Title string `yaml:"title"`
|
||||
Description string `yaml:"description"`
|
||||
} `yaml:"system_templates"`
|
||||
PageTemplates []struct {
|
||||
System string `yaml:"system"`
|
||||
Key string `yaml:"key"`
|
||||
Title string `yaml:"title"`
|
||||
Description string `yaml:"description"`
|
||||
Slots []string `yaml:"slots"`
|
||||
} `yaml:"page_templates"`
|
||||
// TemplateOverrides declare theme-scoped overrides of builtin block
|
||||
// rendering. Source convention: templates/overrides/<template>/<block>.ninjatpl,
|
||||
// rendered host-side with the block's content map as the template context.
|
||||
TemplateOverrides []struct {
|
||||
Template string `yaml:"template"` // template/system key the override binds to
|
||||
Block string `yaml:"block"` // builtin block key being overridden
|
||||
} `yaml:"template_overrides"`
|
||||
// EmailWrappers declare branded email wrappers per system key. Source
|
||||
// convention: templates/email/<system>.ninjatpl, rendered host-side with
|
||||
// body/colors/site/unsubscribe_url/preview_text in the context (emit the
|
||||
// pre-rendered body with |safe).
|
||||
EmailWrappers []string `yaml:"email_wrappers"`
|
||||
CSS *struct {
|
||||
NpmPackages map[string]string `yaml:"npm_packages"`
|
||||
CSSDirectives []string `yaml:"css_directives"`
|
||||
InputCSSAppend string `yaml:"input_css_append"`
|
||||
} `yaml:"css"`
|
||||
Dependencies []struct {
|
||||
Plugin string `yaml:"plugin"`
|
||||
MinVersion string `yaml:"min_version"`
|
||||
Required bool `yaml:"required"`
|
||||
} `yaml:"dependencies"`
|
||||
}
|
||||
|
||||
// masterPageJSON mirrors abiv1.MasterPageDefinition for the declarative file.
|
||||
type masterPageJSON struct {
|
||||
Key string `json:"key"`
|
||||
Title string `json:"title"`
|
||||
PageTemplates []string `json:"page_templates"`
|
||||
Blocks []struct {
|
||||
BlockKey string `json:"block_key"`
|
||||
Title string `json:"title"`
|
||||
Content map[string]any `json:"content"`
|
||||
HTMLContent *string `json:"html_content"`
|
||||
Slot string `json:"slot"`
|
||||
SortOrder int32 `json:"sort_order"`
|
||||
} `json:"blocks"`
|
||||
}
|
||||
|
||||
// blocksYAML is the structural mirror of the CMS blocks.yaml manifest
|
||||
// (cms blocks.LoadManifest) — a deliberate light duplication, same as the
|
||||
// Verify↔reader pairing: the packer validates shape and file presence; full
|
||||
// semantic validation (schema/template/provider checks) runs at install.
|
||||
type blocksYAML struct {
|
||||
Blocks []struct {
|
||||
Key string `yaml:"key"`
|
||||
Title string `yaml:"title"`
|
||||
Description string `yaml:"description"`
|
||||
Category string `yaml:"category"`
|
||||
Schema string `yaml:"schema"`
|
||||
Template string `yaml:"template"`
|
||||
SampleData string `yaml:"sample_data"`
|
||||
Providers []string `yaml:"providers"`
|
||||
RequiredTags []string `yaml:"required_tags"`
|
||||
Aliases []string `yaml:"aliases"`
|
||||
} `yaml:"blocks"`
|
||||
}
|
||||
|
||||
// seedJSON is the declarative seed schema (seed/seed.json). Applied by the
|
||||
// host at load via the WO-WZ-019 provisioner (idempotent).
|
||||
type seedJSON struct {
|
||||
Settings *struct {
|
||||
Merge map[string]any `json:"merge"`
|
||||
Override map[string]any `json:"override"`
|
||||
Ensure map[string]any `json:"ensure"`
|
||||
} `json:"settings"`
|
||||
Media []struct {
|
||||
ID string `json:"id"` // UUID, required (deterministic media key)
|
||||
File string `json:"file"`
|
||||
Alt string `json:"alt"`
|
||||
Folder string `json:"folder"`
|
||||
} `json:"media"`
|
||||
Pages []struct {
|
||||
Slug string `json:"slug"`
|
||||
ParentSlug string `json:"parent_slug"`
|
||||
Title string `json:"title"`
|
||||
TemplateKey string `json:"template_key"`
|
||||
ReconcileBlocks bool `json:"reconcile_blocks"`
|
||||
ReconcileTemplate bool `json:"reconcile_template"`
|
||||
Blocks []struct {
|
||||
BlockKey string `json:"block_key"`
|
||||
Title string `json:"title"`
|
||||
Content map[string]any `json:"content"`
|
||||
HTMLContent *string `json:"html_content"`
|
||||
Slot string `json:"slot"`
|
||||
SortOrder int32 `json:"sort_order"`
|
||||
} `json:"blocks"`
|
||||
} `json:"pages"`
|
||||
MenuItems []struct {
|
||||
Menu string `json:"menu"`
|
||||
Label string `json:"label"`
|
||||
URL string `json:"url"`
|
||||
PageSlug string `json:"page_slug"`
|
||||
SortOrder int32 `json:"sort_order"`
|
||||
} `json:"menu_items"`
|
||||
}
|
||||
|
||||
// BuildCodeless builds the codeless plugin repo in opts.Dir with
|
||||
// BuildCodelessFS and writes the artifact to opts.Output.
|
||||
func BuildCodeless(opts BuildOptions) (*BuildResult, error) {
|
||||
dir := opts.Dir
|
||||
if dir == "" {
|
||||
dir = "."
|
||||
}
|
||||
dir, err := filepath.Abs(dir)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("resolve dir: %w", err)
|
||||
}
|
||||
|
||||
artifact, res, err := BuildCodelessFS(os.DirFS(dir))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
outPath := opts.Output
|
||||
if outPath == "" {
|
||||
outPath = fmt.Sprintf("%s-%s.bnp", res.Name, res.Version)
|
||||
}
|
||||
if err := os.WriteFile(outPath, artifact, 0o666); err != nil {
|
||||
return nil, fmt.Errorf("write %s: %w", outPath, err)
|
||||
}
|
||||
res.OutputPath = outPath
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// BuildCodelessFS synthesizes manifest.pb from plugin.mod + the declarative
|
||||
// files in fsys and returns a packed codeless .bnp (no plugin.wasm, no
|
||||
// DESCRIBE probe).
|
||||
func BuildCodelessFS(fsys fs.FS) ([]byte, *BuildResult, error) {
|
||||
modBytes, err := fs.ReadFile(fsys, FileMod)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("read plugin.mod: %w", err)
|
||||
}
|
||||
mod, err := core.ParseModFull(modBytes)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("parse plugin.mod: %w", err)
|
||||
}
|
||||
if mod.Plugin.Name == "" || mod.Plugin.Version == "" {
|
||||
return nil, nil, fmt.Errorf("plugin.mod must set both name and version")
|
||||
}
|
||||
if mod.Plugin.DataDir {
|
||||
return nil, nil, fmt.Errorf("codeless plugin cannot request data_dir — there is no code to use it")
|
||||
}
|
||||
if len(mod.Plugin.PublicRoutes) > 0 || mod.Plugin.Sitemap {
|
||||
return nil, nil, fmt.Errorf("codeless plugin cannot declare public_routes or sitemap: there is no HTTP handler to serve them")
|
||||
}
|
||||
|
||||
manifest := &abiv1.PluginManifest{
|
||||
AbiVersion: hostAbiVersion,
|
||||
Name: mod.Plugin.Name,
|
||||
Version: mod.Plugin.Version,
|
||||
Codeless: true,
|
||||
}
|
||||
|
||||
blockCount, err := ValidateBlocksDir(fsys)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if err := ValidateSeedDir(fsys); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if err := ApplyManifestYAML(fsys, manifest); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
manifestBytes, err := proto.Marshal(manifest)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("marshal manifest.pb: %w", err)
|
||||
}
|
||||
|
||||
entries := []Entry{
|
||||
{ArtifactPath: FileMod, Data: modBytes},
|
||||
{ArtifactPath: FileManifest, Data: manifestBytes},
|
||||
}
|
||||
var includedDirs []string
|
||||
optional := []struct{ artifact, src string }{
|
||||
{DirBlocks, DirBlocks},
|
||||
{DirTemplates, DirTemplates},
|
||||
{DirSeed, DirSeed},
|
||||
{"migrations", "migrations"},
|
||||
{"schemas", "schemas"},
|
||||
{"assets", "assets"},
|
||||
}
|
||||
for _, o := range optional {
|
||||
dirEntries, has, dErr := CollectDir(fsys, o.src, o.artifact)
|
||||
if dErr != nil {
|
||||
return nil, nil, dErr
|
||||
}
|
||||
if has {
|
||||
entries = append(entries, dirEntries...)
|
||||
includedDirs = append(includedDirs, o.artifact)
|
||||
}
|
||||
}
|
||||
presEntries, previewIncluded, screenshotCount, err := PresentationEntries(fsys)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
entries = append(entries, presEntries...)
|
||||
if screenshotCount > 0 {
|
||||
includedDirs = append(includedDirs, DirScreenshots)
|
||||
}
|
||||
|
||||
var artifact bytes.Buffer
|
||||
uncomp, err := Pack(&artifact, fsys, entries)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return artifact.Bytes(), &BuildResult{
|
||||
Name: manifest.GetName(),
|
||||
Version: manifest.GetVersion(),
|
||||
Codeless: true,
|
||||
ManifestBytes: int64(len(manifestBytes)),
|
||||
ArtifactBytes: int64(artifact.Len()),
|
||||
UncompBytes: uncomp,
|
||||
BlockCount: blockCount,
|
||||
IncludedDirs: includedDirs,
|
||||
PreviewIncluded: previewIncluded,
|
||||
ScreenshotCount: screenshotCount,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ValidateBlocksDir structurally validates blocks/blocks.yaml when present:
|
||||
// every entry has key/title/schema/template, referenced files exist within
|
||||
// blocks/, and schemas are valid JSON. Returns the block count (0 when the
|
||||
// dir is absent).
|
||||
func ValidateBlocksDir(fsys fs.FS) (int, error) {
|
||||
root := DirBlocks
|
||||
manifestPath := path.Join(root, "blocks.yaml")
|
||||
if _, err := fs.Stat(fsys, root); errors.Is(err, fs.ErrNotExist) {
|
||||
return 0, nil
|
||||
}
|
||||
raw, err := fs.ReadFile(fsys, manifestPath)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("blocks/ present but blocks.yaml unreadable: %w", err)
|
||||
}
|
||||
var bf blocksYAML
|
||||
if err := yaml.Unmarshal(raw, &bf); err != nil {
|
||||
return 0, fmt.Errorf("parse blocks/blocks.yaml: %w", err)
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
for i, b := range bf.Blocks {
|
||||
if b.Key == "" {
|
||||
return 0, fmt.Errorf("blocks.yaml: entry %d has no key", i)
|
||||
}
|
||||
if seen[b.Key] {
|
||||
return 0, fmt.Errorf("blocks.yaml: duplicate key %q", b.Key)
|
||||
}
|
||||
seen[b.Key] = true
|
||||
if b.Title == "" || b.Schema == "" || b.Template == "" {
|
||||
return 0, fmt.Errorf("blocks.yaml: %q must declare title, schema, and template", b.Key)
|
||||
}
|
||||
for _, f := range []string{b.Schema, b.Template, b.SampleData} {
|
||||
if f == "" {
|
||||
continue
|
||||
}
|
||||
if err := fileWithin(fsys, root, f); err != nil {
|
||||
return 0, fmt.Errorf("blocks.yaml: %q: %w", b.Key, err)
|
||||
}
|
||||
}
|
||||
schemaRaw, err := fs.ReadFile(fsys, path.Join(root, b.Schema))
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("blocks.yaml: %q schema: %w", b.Key, err)
|
||||
}
|
||||
if !json.Valid(schemaRaw) {
|
||||
return 0, fmt.Errorf("blocks.yaml: %q schema %s is not valid JSON", b.Key, b.Schema)
|
||||
}
|
||||
}
|
||||
return len(bf.Blocks), nil
|
||||
}
|
||||
|
||||
// ValidateSeedDir validates seed/seed.json when the dir is present: it
|
||||
// parses, media entries carry an id + an existing file, pages carry slugs.
|
||||
func ValidateSeedDir(fsys fs.FS) error {
|
||||
root := DirSeed
|
||||
if _, err := fs.Stat(fsys, root); errors.Is(err, fs.ErrNotExist) {
|
||||
return nil
|
||||
}
|
||||
raw, err := fs.ReadFile(fsys, path.Join(root, "seed.json"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("seed/ present but seed.json unreadable: %w", err)
|
||||
}
|
||||
var sf seedJSON
|
||||
if err := json.Unmarshal(raw, &sf); err != nil {
|
||||
return fmt.Errorf("parse seed/seed.json: %w", err)
|
||||
}
|
||||
for i, m := range sf.Media {
|
||||
if m.ID == "" || m.File == "" {
|
||||
return fmt.Errorf("seed.json: media entry %d needs both id and file", i)
|
||||
}
|
||||
if err := fileWithin(fsys, root, m.File); err != nil {
|
||||
return fmt.Errorf("seed.json: media %q: %w", m.ID, err)
|
||||
}
|
||||
}
|
||||
for i, p := range sf.Pages {
|
||||
if p.Slug == "" || p.Title == "" {
|
||||
return fmt.Errorf("seed.json: page entry %d needs slug and title", i)
|
||||
}
|
||||
}
|
||||
for i, mi := range sf.MenuItems {
|
||||
if mi.Menu == "" || mi.Label == "" {
|
||||
return fmt.Errorf("seed.json: menu item %d needs menu and label", i)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ApplyManifestYAML folds the optional root manifest.yaml into the manifest.
|
||||
func ApplyManifestYAML(fsys fs.FS, m *abiv1.PluginManifest) error {
|
||||
raw, err := fs.ReadFile(fsys, manifestYAMLName)
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("read %s: %w", manifestYAMLName, err)
|
||||
}
|
||||
var my manifestYAML
|
||||
if err := yaml.Unmarshal(raw, &my); err != nil {
|
||||
return fmt.Errorf("parse %s: %w", manifestYAMLName, err)
|
||||
}
|
||||
|
||||
readJSONFile := func(rel, what string) ([]byte, error) {
|
||||
if rel == "" {
|
||||
return nil, nil
|
||||
}
|
||||
if err := fileWithin(fsys, ".", rel); err != nil {
|
||||
return nil, fmt.Errorf("%s: %s: %w", manifestYAMLName, what, err)
|
||||
}
|
||||
b, err := fs.ReadFile(fsys, path.Clean(rel))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s: %s: %w", manifestYAMLName, what, err)
|
||||
}
|
||||
if !json.Valid(b) {
|
||||
return nil, fmt.Errorf("%s: %s %s is not valid JSON", manifestYAMLName, what, rel)
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// Only overwrite a field when manifest.yaml actually declares it. For a
|
||||
// codeless build the manifest starts empty, so an undeclared key leaving the
|
||||
// field at its proto zero is identical to the old unconditional assignment.
|
||||
// For a mixed-form wasm build the manifest already carries the guest's
|
||||
// DESCRIBE output, so these guards are what keep an undeclared key from
|
||||
// WIPING a guest-populated field (theme_presets/bundled_fonts/etc.) —
|
||||
// declarative keys supplement/override, they never clear (WO-WZ-021).
|
||||
if my.ThemePresets != "" {
|
||||
if m.ThemePresets, err = readJSONFile(my.ThemePresets, "theme_presets"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if my.BundledFonts != "" {
|
||||
if m.BundledFonts, err = readJSONFile(my.BundledFonts, "bundled_fonts"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if my.SettingsSchema != "" {
|
||||
if m.SettingsSchema, err = readJSONFile(my.SettingsSchema, "settings_schema"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if len(my.RequiredIconPacks) > 0 {
|
||||
m.RequiredIconPacks = my.RequiredIconPacks
|
||||
}
|
||||
if my.CSS != nil {
|
||||
m.CssManifest = &abiv1.CssManifest{
|
||||
NpmPackages: my.CSS.NpmPackages,
|
||||
CssDirectives: my.CSS.CSSDirectives,
|
||||
InputCssAppend: my.CSS.InputCSSAppend,
|
||||
}
|
||||
}
|
||||
for _, d := range my.Dependencies {
|
||||
m.Dependencies = append(m.Dependencies, &abiv1.Dependency{
|
||||
Plugin: d.Plugin, MinVersion: d.MinVersion, Required: d.Required,
|
||||
})
|
||||
}
|
||||
|
||||
for _, st := range my.SystemTemplates {
|
||||
if st.Key == "" || st.Title == "" {
|
||||
return fmt.Errorf("%s: system_templates entries need key and title", manifestYAMLName)
|
||||
}
|
||||
m.SystemTemplates = append(m.SystemTemplates, &abiv1.SystemTemplateMeta{
|
||||
Key: st.Key, Title: st.Title, Description: st.Description,
|
||||
})
|
||||
}
|
||||
for _, pt := range my.PageTemplates {
|
||||
if pt.System == "" || pt.Key == "" || pt.Title == "" {
|
||||
return fmt.Errorf("%s: page_templates entries need system, key, and title", manifestYAMLName)
|
||||
}
|
||||
// Layout source convention: templates/<system>/<key>.ninjatpl,
|
||||
// rendered host-side (core/docs/codeless-bnp.md).
|
||||
rel := path.Join(DirTemplates, pt.System, pt.Key+".ninjatpl")
|
||||
if err := fileWithin(fsys, ".", rel); err != nil {
|
||||
return fmt.Errorf("%s: page template %s/%s: %w", manifestYAMLName, pt.System, pt.Key, err)
|
||||
}
|
||||
m.PageTemplates = append(m.PageTemplates, &abiv1.PageTemplateMeta{
|
||||
SystemKey: pt.System, Key: pt.Key, Title: pt.Title,
|
||||
Description: pt.Description, Slots: pt.Slots,
|
||||
})
|
||||
}
|
||||
|
||||
for _, to := range my.TemplateOverrides {
|
||||
if to.Template == "" || to.Block == "" {
|
||||
return fmt.Errorf("%s: template_overrides entries need template and block", manifestYAMLName)
|
||||
}
|
||||
rel := path.Join(DirTemplates, "overrides", to.Template, to.Block+".ninjatpl")
|
||||
if err := fileWithin(fsys, ".", rel); err != nil {
|
||||
return fmt.Errorf("%s: template override %s/%s: %w", manifestYAMLName, to.Template, to.Block, err)
|
||||
}
|
||||
m.BlockTemplateOverrides = append(m.BlockTemplateOverrides, &abiv1.BlockTemplateOverride{
|
||||
TemplateKey: to.Template, BlockKey: to.Block,
|
||||
})
|
||||
}
|
||||
for _, ek := range my.EmailWrappers {
|
||||
if ek == "" {
|
||||
return fmt.Errorf("%s: email_wrappers entries must be non-empty system keys", manifestYAMLName)
|
||||
}
|
||||
rel := path.Join(DirTemplates, "email", ek+".ninjatpl")
|
||||
if err := fileWithin(fsys, ".", rel); err != nil {
|
||||
return fmt.Errorf("%s: email wrapper %s: %w", manifestYAMLName, ek, err)
|
||||
}
|
||||
m.EmailWrapperSystemKeys = append(m.EmailWrapperSystemKeys, ek)
|
||||
}
|
||||
|
||||
if my.MasterPages != "" {
|
||||
mpRaw, err := readJSONFile(my.MasterPages, "master_pages")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var mps []masterPageJSON
|
||||
if err := json.Unmarshal(mpRaw, &mps); err != nil {
|
||||
return fmt.Errorf("%s: master_pages %s: %w", manifestYAMLName, my.MasterPages, err)
|
||||
}
|
||||
for _, mp := range mps {
|
||||
def := &abiv1.MasterPageDefinition{
|
||||
Key: mp.Key, Title: mp.Title, PageTemplates: mp.PageTemplates,
|
||||
}
|
||||
for _, b := range mp.Blocks {
|
||||
contentJSON, err := json.Marshal(b.Content)
|
||||
if err != nil {
|
||||
return fmt.Errorf("master page %q block %q: %w", mp.Key, b.BlockKey, err)
|
||||
}
|
||||
def.Blocks = append(def.Blocks, &abiv1.MasterPageBlock{
|
||||
BlockKey: b.BlockKey, Title: b.Title, ContentJson: contentJSON,
|
||||
HtmlContent: b.HTMLContent, Slot: b.Slot, SortOrder: b.SortOrder,
|
||||
})
|
||||
}
|
||||
m.MasterPages = append(m.MasterPages, def)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// fileWithin ensures rel names an existing regular file inside root (no
|
||||
// traversal escapes).
|
||||
func fileWithin(fsys fs.FS, root, rel string) error {
|
||||
clean := path.Clean(rel)
|
||||
if path.IsAbs(clean) || strings.HasPrefix(clean, "..") {
|
||||
return fmt.Errorf("path %q escapes the plugin directory", rel)
|
||||
}
|
||||
fi, err := fs.Stat(fsys, path.Join(root, clean))
|
||||
if err != nil {
|
||||
return fmt.Errorf("referenced file %q: %w", rel, err)
|
||||
}
|
||||
if !fi.Mode().IsRegular() {
|
||||
return fmt.Errorf("referenced path %q is not a regular file", rel)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
242
bnp/codeless_test.go
Normal file
242
bnp/codeless_test.go
Normal file
@ -0,0 +1,242 @@
|
||||
package bnp
|
||||
|
||||
import (
|
||||
"archive/tar"
|
||||
"bytes"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"testing/fstest"
|
||||
|
||||
abiv1 "git.dev.alexdunmow.com/block/pluginsdk/abi/v1"
|
||||
"github.com/klauspost/compress/zstd"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// writeFixture lays out a minimal codeless plugin repo.
|
||||
func writeFixture(t *testing.T, dir string, files map[string]string) {
|
||||
t.Helper()
|
||||
for rel, content := range files {
|
||||
path := filepath.Join(dir, rel)
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(path, []byte(content), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var codelessFixtureFiles = map[string]string{
|
||||
"plugin.mod": "[plugin]\nname = \"fixture-theme\"\nversion = \"0.1.0\"\nkind = \"theme\"\n",
|
||||
"manifest.yaml": "theme_presets: presets.json\nrequired_icon_packs: [lucide]\n" +
|
||||
"master_pages: master_pages.json\n" +
|
||||
"system_templates:\n - key: fixture\n title: Fixture Theme\n" +
|
||||
"page_templates:\n - system: fixture\n key: landing\n title: Landing\n slots: [main]\n" +
|
||||
"template_overrides:\n - template: fixture\n block: heading\n" +
|
||||
"email_wrappers: [fixture]\n",
|
||||
"templates/fixture/landing.ninjatpl": `<main>{{ content }}</main>`,
|
||||
"templates/overrides/fixture/heading.ninjatpl": `<h2 class="deco">{{ text }}</h2>`,
|
||||
"templates/email/fixture.ninjatpl": `<table><tr><td>{{ body|safe }}</td></tr></table>`,
|
||||
"presets.json": `{"presets":[{"key":"default"}]}`,
|
||||
"master_pages.json": `[{"key":"landing","title":"Landing","blocks":[{"block_key":"html","title":"Hero","content":{"x":1},"slot":"main","sort_order":1}]}]`,
|
||||
"blocks/blocks.yaml": "blocks:\n - key: hero\n title: Hero\n category: content\n" +
|
||||
" schema: hero.schema.json\n template: hero.ninjatpl\n providers: [site]\n",
|
||||
"blocks/hero.schema.json": `{"type":"object"}`,
|
||||
"blocks/hero.ninjatpl": `<h1>{{ title }}</h1>`,
|
||||
"seed/seed.json": `{"settings":{"ensure":{"welcome":true}},` +
|
||||
`"pages":[{"slug":"/","title":"Home","template_key":"landing"}],` +
|
||||
`"menu_items":[{"menu":"main","label":"Home","page_slug":"/","sort_order":1}]}`,
|
||||
"assets/logo.svg": `<svg/>`,
|
||||
}
|
||||
|
||||
func codelessFixture(t *testing.T) string {
|
||||
t.Helper()
|
||||
dir := t.TempDir()
|
||||
writeFixture(t, dir, codelessFixtureFiles)
|
||||
return dir
|
||||
}
|
||||
|
||||
// readArtifact unpacks a .bnp into member name → contents (directories map
|
||||
// to nil).
|
||||
func readArtifact(t *testing.T, artifact []byte) map[string][]byte {
|
||||
t.Helper()
|
||||
dec, err := zstd.NewReader(bytes.NewReader(artifact))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer dec.Close()
|
||||
members := map[string][]byte{}
|
||||
tr := tar.NewReader(dec)
|
||||
for {
|
||||
h, err := tr.Next()
|
||||
if err == io.EOF {
|
||||
return members
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if h.Typeflag == tar.TypeDir {
|
||||
members[h.Name] = nil
|
||||
continue
|
||||
}
|
||||
b, err := io.ReadAll(tr)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
members[h.Name] = b
|
||||
}
|
||||
}
|
||||
|
||||
func artifactManifest(t *testing.T, members map[string][]byte) *abiv1.PluginManifest {
|
||||
t.Helper()
|
||||
m := &abiv1.PluginManifest{}
|
||||
if err := proto.Unmarshal(members[FileManifest], m); err != nil {
|
||||
t.Fatalf("decode manifest.pb: %v", err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func TestCodelessBuildRoundTrip(t *testing.T) {
|
||||
dir := codelessFixture(t)
|
||||
|
||||
out := filepath.Join(t.TempDir(), "fixture-theme-0.1.0.bnp")
|
||||
res, err := BuildCodeless(BuildOptions{Dir: dir, Output: out})
|
||||
if err != nil {
|
||||
t.Fatalf("BuildCodeless: %v", err)
|
||||
}
|
||||
if !res.Codeless || res.BlockCount != 1 || res.OutputPath != out {
|
||||
t.Errorf("result = %+v; want codeless with 1 block at %s", res, out)
|
||||
}
|
||||
|
||||
artifact, err := os.ReadFile(out)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if res.ArtifactBytes != int64(len(artifact)) {
|
||||
t.Errorf("ArtifactBytes = %d, file is %d bytes", res.ArtifactBytes, len(artifact))
|
||||
}
|
||||
members := readArtifact(t, artifact)
|
||||
for _, want := range []string{"plugin.mod", "manifest.pb", "blocks/", "blocks/blocks.yaml", "seed/seed.json", "assets/logo.svg", "templates/email/fixture.ninjatpl"} {
|
||||
if _, ok := members[want]; !ok {
|
||||
t.Errorf("artifact missing %s", want)
|
||||
}
|
||||
}
|
||||
if _, ok := members["plugin.wasm"]; ok {
|
||||
t.Error("codeless artifact carries plugin.wasm")
|
||||
}
|
||||
|
||||
m := artifactManifest(t, members)
|
||||
if m.GetName() != "fixture-theme" || m.GetAbiVersion() != 1 {
|
||||
t.Errorf("manifest name/abi = %q/%d", m.GetName(), m.GetAbiVersion())
|
||||
}
|
||||
if len(m.GetSystemTemplates()) != 1 || len(m.GetPageTemplates()) != 1 || m.GetPageTemplates()[0].GetSystemKey() != "fixture" {
|
||||
t.Errorf("templates = %v / %v", m.GetSystemTemplates(), m.GetPageTemplates())
|
||||
}
|
||||
if !m.GetCodeless() || len(m.GetMasterPages()) != 1 || len(m.GetThemePresets()) == 0 {
|
||||
t.Errorf("manifest = codeless:%v masters:%d presets:%dB",
|
||||
m.GetCodeless(), len(m.GetMasterPages()), len(m.GetThemePresets()))
|
||||
}
|
||||
if len(m.GetRequiredIconPacks()) != 1 || m.GetRequiredIconPacks()[0] != "lucide" {
|
||||
t.Errorf("icon packs = %v", m.GetRequiredIconPacks())
|
||||
}
|
||||
if len(m.GetBlockTemplateOverrides()) != 1 ||
|
||||
m.GetBlockTemplateOverrides()[0].GetTemplateKey() != "fixture" ||
|
||||
m.GetBlockTemplateOverrides()[0].GetBlockKey() != "heading" {
|
||||
t.Errorf("template overrides = %v", m.GetBlockTemplateOverrides())
|
||||
}
|
||||
if len(m.GetEmailWrapperSystemKeys()) != 1 || m.GetEmailWrapperSystemKeys()[0] != "fixture" {
|
||||
t.Errorf("email wrappers = %v", m.GetEmailWrapperSystemKeys())
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildCodelessFSMatchesDirectoryBuild(t *testing.T) {
|
||||
out := filepath.Join(t.TempDir(), "x.bnp")
|
||||
if _, err := BuildCodeless(BuildOptions{Dir: codelessFixture(t), Output: out}); err != nil {
|
||||
t.Fatalf("BuildCodeless: %v", err)
|
||||
}
|
||||
fromDir, err := os.ReadFile(out)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
mapFS := fstest.MapFS{}
|
||||
for name, content := range codelessFixtureFiles {
|
||||
mapFS[name] = &fstest.MapFile{Data: []byte(content), Mode: 0o644}
|
||||
}
|
||||
fromMem, res, err := BuildCodelessFS(mapFS)
|
||||
if err != nil {
|
||||
t.Fatalf("BuildCodelessFS: %v", err)
|
||||
}
|
||||
if !bytes.Equal(fromDir, fromMem) {
|
||||
t.Errorf("in-memory artifact (%d bytes) differs from directory artifact (%d bytes)", len(fromMem), len(fromDir))
|
||||
}
|
||||
if res.OutputPath != "" || res.ArtifactBytes != int64(len(fromMem)) {
|
||||
t.Errorf("result = %+v", res)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCodelessBuildRejectsBadDeclarations(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
files map[string]string
|
||||
}{
|
||||
{"bad blocks yaml", map[string]string{
|
||||
"plugin.mod": "[plugin]\nname = \"x\"\nversion = \"0.1.0\"\n",
|
||||
"blocks/blocks.yaml": "blocks:\n - key: hero\n", // missing title/schema/template
|
||||
}},
|
||||
{"missing template file", map[string]string{
|
||||
"plugin.mod": "[plugin]\nname = \"x\"\nversion = \"0.1.0\"\n",
|
||||
"blocks/blocks.yaml": "blocks:\n - key: hero\n title: Hero\n" +
|
||||
" schema: hero.schema.json\n template: missing.ninjatpl\n",
|
||||
"blocks/hero.schema.json": `{}`,
|
||||
}},
|
||||
{"block file escapes", map[string]string{
|
||||
"plugin.mod": "[plugin]\nname = \"x\"\nversion = \"0.1.0\"\n",
|
||||
"blocks/blocks.yaml": "blocks:\n - key: hero\n title: Hero\n" +
|
||||
" schema: hero.schema.json\n template: ../plugin.mod\n",
|
||||
"blocks/hero.schema.json": `{}`,
|
||||
}},
|
||||
{"seed media without id", map[string]string{
|
||||
"plugin.mod": "[plugin]\nname = \"x\"\nversion = \"0.1.0\"\n",
|
||||
"seed/seed.json": `{"media":[{"file":"a.jpg"}]}`,
|
||||
"seed/a.jpg": "x",
|
||||
}},
|
||||
{"data_dir grant", map[string]string{
|
||||
"plugin.mod": "[plugin]\nname = \"x\"\nversion = \"0.1.0\"\ndata_dir = true\n",
|
||||
}},
|
||||
{"public_routes claim", map[string]string{
|
||||
"plugin.mod": "[plugin]\nname = \"x\"\nversion = \"0.1.0\"\n" +
|
||||
"public_routes = [{ path = \"/area\", prefix = true }]\n",
|
||||
}},
|
||||
{"sitemap flag", map[string]string{
|
||||
"plugin.mod": "[plugin]\nname = \"x\"\nversion = \"0.1.0\"\nsitemap = true\n",
|
||||
}},
|
||||
{"override missing template file", map[string]string{
|
||||
"plugin.mod": "[plugin]\nname = \"x\"\nversion = \"0.1.0\"\n",
|
||||
"manifest.yaml": "template_overrides:\n - template: x\n block: heading\n",
|
||||
}},
|
||||
{"override missing block key", map[string]string{
|
||||
"plugin.mod": "[plugin]\nname = \"x\"\nversion = \"0.1.0\"\n",
|
||||
"manifest.yaml": "template_overrides:\n - template: x\n",
|
||||
"templates/overrides/x/heading.ninjatpl": `<h1>{{ text }}</h1>`,
|
||||
}},
|
||||
{"email wrapper missing template file", map[string]string{
|
||||
"plugin.mod": "[plugin]\nname = \"x\"\nversion = \"0.1.0\"\n",
|
||||
"manifest.yaml": "email_wrappers: [x]\n",
|
||||
}},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writeFixture(t, dir, tc.files)
|
||||
_, err := BuildCodeless(BuildOptions{
|
||||
Dir: dir, Output: filepath.Join(t.TempDir(), "x.bnp"),
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal("BuildCodeless succeeded; want error")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
80
bnp/mixed_test.go
Normal file
80
bnp/mixed_test.go
Normal file
@ -0,0 +1,80 @@
|
||||
package bnp
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
abiv1 "git.dev.alexdunmow.com/block/pluginsdk/abi/v1"
|
||||
)
|
||||
|
||||
// TestApplyManifestYAMLSupplementsWithoutWiping proves the WO-WZ-021 mixed-form
|
||||
// builder semantics: folding manifest.yaml onto a manifest that already carries
|
||||
// guest DESCRIBE output SUPPLEMENTS the declarative surfaces and OVERRIDES only
|
||||
// the keys it actually declares — an undeclared scalar key never wipes a
|
||||
// guest-populated field.
|
||||
func TestApplyManifestYAMLSupplementsWithoutWiping(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writeFixture(t, dir, map[string]string{
|
||||
"manifest.yaml": "" +
|
||||
"bundled_fonts: fonts.json\n" +
|
||||
"page_templates:\n" +
|
||||
" - {system: blog, key: listing, title: Listing}\n" +
|
||||
"email_wrappers: [newsletter]\n",
|
||||
"fonts.json": `{"fonts":["Inter"]}`,
|
||||
"templates/blog/listing.ninjatpl": `<main>{{ title }}</main>`,
|
||||
"templates/email/newsletter.ninjatpl": `<table>{{ body|safe }}</table>`,
|
||||
})
|
||||
|
||||
// Simulate a guest DESCRIBE result: theme_presets set by the guest, plus a
|
||||
// guest-rendered page template the manifest.yaml does NOT list.
|
||||
m := &abiv1.PluginManifest{
|
||||
AbiVersion: 1,
|
||||
Name: "fixture-mixed",
|
||||
Version: "0.1.0",
|
||||
ThemePresets: []byte(`{"guest":true}`),
|
||||
PageTemplates: []*abiv1.PageTemplateMeta{
|
||||
{SystemKey: "blog", Key: "guestonly", Title: "Guest Only"},
|
||||
},
|
||||
}
|
||||
|
||||
if err := ApplyManifestYAML(os.DirFS(dir), m); err != nil {
|
||||
t.Fatalf("ApplyManifestYAML: %v", err)
|
||||
}
|
||||
|
||||
// Undeclared theme_presets must be PRESERVED, not wiped to nil.
|
||||
if string(m.ThemePresets) != `{"guest":true}` {
|
||||
t.Errorf("theme_presets wiped/altered: %q", string(m.ThemePresets))
|
||||
}
|
||||
// Declared bundled_fonts folded in.
|
||||
if string(m.BundledFonts) != `{"fonts":["Inter"]}` {
|
||||
t.Errorf("bundled_fonts = %q", string(m.BundledFonts))
|
||||
}
|
||||
// Declared page template appended alongside the guest one (2 total).
|
||||
if len(m.PageTemplates) != 2 {
|
||||
t.Fatalf("page templates = %d, want 2 (guest + declarative)", len(m.PageTemplates))
|
||||
}
|
||||
// Declared email wrapper folded in.
|
||||
if len(m.EmailWrapperSystemKeys) != 1 || m.EmailWrapperSystemKeys[0] != "newsletter" {
|
||||
t.Errorf("email wrappers = %v", m.EmailWrapperSystemKeys)
|
||||
}
|
||||
}
|
||||
|
||||
// TestWasmBuildFoldsManifestYAML end-to-end: a repo with Go source AND a
|
||||
// manifest.yaml builds a (non-codeless) wasm artifact whose manifest.pb carries
|
||||
// the folded declarative surfaces. The absence of a manifest.yaml is a no-op —
|
||||
// covered by every existing wasm build test.
|
||||
func TestApplyManifestYAMLNoFileIsNoop(t *testing.T) {
|
||||
dir := t.TempDir() // no manifest.yaml
|
||||
m := &abiv1.PluginManifest{
|
||||
AbiVersion: 1,
|
||||
Name: "fixture-pure",
|
||||
Version: "0.1.0",
|
||||
ThemePresets: []byte(`{"guest":true}`),
|
||||
}
|
||||
if err := ApplyManifestYAML(os.DirFS(dir), m); err != nil {
|
||||
t.Fatalf("ApplyManifestYAML (no file): %v", err)
|
||||
}
|
||||
if string(m.ThemePresets) != `{"guest":true}` {
|
||||
t.Errorf("no-manifest.yaml build mutated the manifest: %q", string(m.ThemePresets))
|
||||
}
|
||||
}
|
||||
133
bnp/pack.go
Normal file
133
bnp/pack.go
Normal file
@ -0,0 +1,133 @@
|
||||
package bnp
|
||||
|
||||
import (
|
||||
"archive/tar"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/klauspost/compress/zstd"
|
||||
)
|
||||
|
||||
// Entry is one file destined for the artifact: its path inside the .bnp
|
||||
// (always forward-slash relative) and either literal Data or a Source file in
|
||||
// the packed fs.FS to stream from.
|
||||
type Entry struct {
|
||||
ArtifactPath string
|
||||
Data []byte
|
||||
Source string
|
||||
}
|
||||
|
||||
// Pack writes entries as a zstd-compressed tar to w, reading Source entries
|
||||
// from fsys. Entries are sorted by artifact path for a deterministic archive.
|
||||
// Directory entries are synthesized as needed so the reader's dirExists
|
||||
// checks fire for migrations/, schemas/, assets/, web/. Returns the sum of
|
||||
// packed file sizes.
|
||||
func Pack(w io.Writer, fsys fs.FS, entries []Entry) (int64, error) {
|
||||
sort.Slice(entries, func(i, j int) bool { return entries[i].ArtifactPath < entries[j].ArtifactPath })
|
||||
|
||||
enc, err := zstd.NewWriter(w, zstd.WithEncoderLevel(zstd.SpeedDefault))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
tw := tar.NewWriter(enc)
|
||||
|
||||
seenDir := map[string]bool{}
|
||||
writeDir := func(dir string) error {
|
||||
if dir == "" || dir == "." || seenDir[dir] {
|
||||
return nil
|
||||
}
|
||||
seenDir[dir] = true
|
||||
return tw.WriteHeader(&tar.Header{
|
||||
Name: dir + "/",
|
||||
Typeflag: tar.TypeDir,
|
||||
Mode: 0o755,
|
||||
})
|
||||
}
|
||||
|
||||
var total int64
|
||||
for _, e := range entries {
|
||||
name := filepath.ToSlash(e.ArtifactPath)
|
||||
// Ensure parent directories exist as explicit entries.
|
||||
for _, d := range parentDirs(name) {
|
||||
if err := writeDir(d); err != nil {
|
||||
return 0, fmt.Errorf("write dir header %q: %w", d, err)
|
||||
}
|
||||
}
|
||||
|
||||
var data []byte
|
||||
if e.Source != "" {
|
||||
data, err = fs.ReadFile(fsys, e.Source)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("read %s: %w", e.Source, err)
|
||||
}
|
||||
} else {
|
||||
data = e.Data
|
||||
}
|
||||
if err := tw.WriteHeader(&tar.Header{
|
||||
Name: name,
|
||||
Typeflag: tar.TypeReg,
|
||||
Mode: 0o644,
|
||||
Size: int64(len(data)),
|
||||
}); err != nil {
|
||||
return 0, fmt.Errorf("write header %q: %w", name, err)
|
||||
}
|
||||
if _, err := tw.Write(data); err != nil {
|
||||
return 0, fmt.Errorf("write %q: %w", name, err)
|
||||
}
|
||||
total += int64(len(data))
|
||||
}
|
||||
|
||||
if err := tw.Close(); err != nil {
|
||||
return 0, fmt.Errorf("close tar: %w", err)
|
||||
}
|
||||
if err := enc.Close(); err != nil {
|
||||
return 0, fmt.Errorf("close zstd: %w", err)
|
||||
}
|
||||
return total, nil
|
||||
}
|
||||
|
||||
// parentDirs returns the ancestor directories of a forward-slash path, from
|
||||
// shallowest to deepest ("a/b/c.txt" → ["a", "a/b"]).
|
||||
func parentDirs(name string) []string {
|
||||
var dirs []string
|
||||
parts := strings.Split(name, "/")
|
||||
for i := 1; i < len(parts); i++ {
|
||||
dirs = append(dirs, strings.Join(parts[:i], "/"))
|
||||
}
|
||||
return dirs
|
||||
}
|
||||
|
||||
// CollectDir returns pack entries for every regular file under root in fsys,
|
||||
// mapped under artifactPrefix. Symlinks and irregular files are skipped.
|
||||
// Returns (entries, hadFiles).
|
||||
func CollectDir(fsys fs.FS, root, artifactPrefix string) ([]Entry, bool, error) {
|
||||
info, err := fs.Stat(fsys, root)
|
||||
if err != nil || !info.IsDir() {
|
||||
return nil, false, nil //nolint:nilerr // absent optional dir is not an error
|
||||
}
|
||||
if linfo, err := fs.Lstat(fsys, root); err == nil && linfo.Mode()&fs.ModeSymlink != 0 {
|
||||
return nil, false, nil
|
||||
}
|
||||
var entries []Entry
|
||||
walkErr := fs.WalkDir(fsys, root, func(p string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if d.IsDir() || !d.Type().IsRegular() {
|
||||
return nil
|
||||
}
|
||||
entries = append(entries, Entry{
|
||||
ArtifactPath: artifactPrefix + "/" + strings.TrimPrefix(p, root+"/"),
|
||||
Source: p,
|
||||
})
|
||||
return nil
|
||||
})
|
||||
if walkErr != nil {
|
||||
return nil, false, fmt.Errorf("walk %s: %w", root, walkErr)
|
||||
}
|
||||
return entries, len(entries) > 0, nil
|
||||
}
|
||||
121
bnp/screenshots.go
Normal file
121
bnp/screenshots.go
Normal file
@ -0,0 +1,121 @@
|
||||
package bnp
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"path"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Presentation members: a root preview.png plus an optional screenshots/ dir.
|
||||
// Neither ships behavior — the registry ingests them at publish into the
|
||||
// plugin's managed gallery (spec 2026-07-05-registry-presentation-reviews).
|
||||
// The .so-era source archives carried preview.png implicitly; the .bnp
|
||||
// packers dropped it, which silently wiped previews on republish — these
|
||||
// entries restore that and add the multi-screenshot surface.
|
||||
const (
|
||||
FilePreview = "preview.png"
|
||||
DirScreenshots = "screenshots"
|
||||
// maxScreenshotBytes caps one presentation image (registry gallery cap).
|
||||
maxScreenshotBytes = 8 << 20
|
||||
// maxScreenshotFiles caps the screenshots/ dir (registry gallery cap).
|
||||
maxScreenshotFiles = 12
|
||||
)
|
||||
|
||||
// ScreenshotExtOK reports whether a filename carries an accepted gallery
|
||||
// image extension.
|
||||
func ScreenshotExtOK(name string) bool {
|
||||
switch strings.ToLower(path.Ext(name)) {
|
||||
case ".png", ".jpg", ".jpeg", ".webp":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// validateScreenshotsDir checks the optional screenshots/ dir: accepted
|
||||
// extensions only, ≤ maxScreenshotBytes per file, ≤ maxScreenshotFiles total,
|
||||
// no subdirectories or irregular files. Returns the file count (0 when the
|
||||
// dir is absent).
|
||||
func validateScreenshotsDir(fsys fs.FS) (int, error) {
|
||||
root := DirScreenshots
|
||||
info, err := fs.Stat(fsys, root)
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return 0, nil
|
||||
}
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("stat %s/: %w", DirScreenshots, err)
|
||||
}
|
||||
if !info.IsDir() {
|
||||
return 0, fmt.Errorf("%s exists but is not a directory", DirScreenshots)
|
||||
}
|
||||
entries, err := fs.ReadDir(fsys, root)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("read %s/: %w", DirScreenshots, err)
|
||||
}
|
||||
count := 0
|
||||
for _, e := range entries {
|
||||
if e.IsDir() {
|
||||
return 0, fmt.Errorf("%s/%s: subdirectories are not allowed in screenshots/", DirScreenshots, e.Name())
|
||||
}
|
||||
fi, err := e.Info()
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("%s/%s: %w", DirScreenshots, e.Name(), err)
|
||||
}
|
||||
if !fi.Mode().IsRegular() {
|
||||
return 0, fmt.Errorf("%s/%s: not a regular file", DirScreenshots, e.Name())
|
||||
}
|
||||
if !ScreenshotExtOK(e.Name()) {
|
||||
return 0, fmt.Errorf("%s/%s: unsupported image type (allowed: .png .jpg .jpeg .webp)", DirScreenshots, e.Name())
|
||||
}
|
||||
if fi.Size() > maxScreenshotBytes {
|
||||
return 0, fmt.Errorf("%s/%s: %d bytes exceeds the %d MB per-image cap", DirScreenshots, e.Name(), fi.Size(), maxScreenshotBytes>>20)
|
||||
}
|
||||
count++
|
||||
}
|
||||
if count > maxScreenshotFiles {
|
||||
return 0, fmt.Errorf("%s/ holds %d images; the gallery cap is %d", DirScreenshots, count, maxScreenshotFiles)
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
// PresentationEntries validates and returns pack entries for the optional
|
||||
// root preview.png and screenshots/ dir. Both are optional; absence is not an
|
||||
// error.
|
||||
func PresentationEntries(fsys fs.FS) (entries []Entry, previewIncluded bool, screenshotCount int, err error) {
|
||||
if fi, statErr := fs.Stat(fsys, FilePreview); statErr == nil {
|
||||
if !fi.Mode().IsRegular() {
|
||||
return nil, false, 0, fmt.Errorf("%s is not a regular file", FilePreview)
|
||||
}
|
||||
if fi.Size() > maxScreenshotBytes {
|
||||
return nil, false, 0, fmt.Errorf("%s: %d bytes exceeds the %d MB per-image cap", FilePreview, fi.Size(), maxScreenshotBytes>>20)
|
||||
}
|
||||
entries = append(entries, Entry{ArtifactPath: FilePreview, Source: FilePreview})
|
||||
previewIncluded = true
|
||||
}
|
||||
|
||||
screenshotCount, err = validateScreenshotsDir(fsys)
|
||||
if err != nil {
|
||||
return nil, false, 0, err
|
||||
}
|
||||
if screenshotCount > 0 {
|
||||
root := DirScreenshots
|
||||
files, readErr := fs.ReadDir(fsys, root)
|
||||
if readErr != nil {
|
||||
return nil, false, 0, fmt.Errorf("read %s/: %w", DirScreenshots, readErr)
|
||||
}
|
||||
names := make([]string, 0, len(files))
|
||||
for _, f := range files {
|
||||
names = append(names, f.Name())
|
||||
}
|
||||
sort.Strings(names)
|
||||
for _, name := range names {
|
||||
entries = append(entries, Entry{
|
||||
ArtifactPath: DirScreenshots + "/" + name,
|
||||
Source: path.Join(root, name),
|
||||
})
|
||||
}
|
||||
}
|
||||
return entries, previewIncluded, screenshotCount, nil
|
||||
}
|
||||
158
bnp/screenshots_test.go
Normal file
158
bnp/screenshots_test.go
Normal file
@ -0,0 +1,158 @@
|
||||
package bnp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// presentationFixture extends the codeless fixture with a root preview.png
|
||||
// and a screenshots/ dir.
|
||||
func presentationFixture(t *testing.T) string {
|
||||
t.Helper()
|
||||
dir := codelessFixture(t)
|
||||
writeFixture(t, dir, map[string]string{
|
||||
"preview.png": "not-really-png-but-bytes",
|
||||
"screenshots/01-home.png": "home-bytes",
|
||||
"screenshots/02-blog.jpg": "blog-bytes",
|
||||
"screenshots/03-page.webp": "page-bytes",
|
||||
})
|
||||
return dir
|
||||
}
|
||||
|
||||
func TestCodelessBuildPacksPresentationMembers(t *testing.T) {
|
||||
dir := presentationFixture(t)
|
||||
|
||||
out := filepath.Join(t.TempDir(), "fixture-theme-0.1.0.bnp")
|
||||
res, err := BuildCodeless(BuildOptions{Dir: dir, Output: out})
|
||||
if err != nil {
|
||||
t.Fatalf("BuildCodeless: %v", err)
|
||||
}
|
||||
if !res.PreviewIncluded || res.ScreenshotCount != 3 {
|
||||
t.Errorf("result preview=%t screenshots=%d; want true/3", res.PreviewIncluded, res.ScreenshotCount)
|
||||
}
|
||||
found := false
|
||||
for _, d := range res.IncludedDirs {
|
||||
if d == DirScreenshots {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Errorf("IncludedDirs %v missing %q", res.IncludedDirs, DirScreenshots)
|
||||
}
|
||||
|
||||
members := readArtifact(t, mustRead(t, out))
|
||||
for _, want := range []string{"preview.png", "screenshots/01-home.png", "screenshots/02-blog.jpg", "screenshots/03-page.webp"} {
|
||||
if _, ok := members[want]; !ok {
|
||||
t.Errorf("artifact missing %s", want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCodelessBuildWithoutPresentationMembers(t *testing.T) {
|
||||
dir := codelessFixture(t)
|
||||
out := filepath.Join(t.TempDir(), "fixture-theme-0.1.0.bnp")
|
||||
res, err := BuildCodeless(BuildOptions{Dir: dir, Output: out})
|
||||
if err != nil {
|
||||
t.Fatalf("BuildCodeless: %v", err)
|
||||
}
|
||||
if res.PreviewIncluded || res.ScreenshotCount != 0 {
|
||||
t.Errorf("result preview=%t screenshots=%d; want false/0", res.PreviewIncluded, res.ScreenshotCount)
|
||||
}
|
||||
members := readArtifact(t, mustRead(t, out))
|
||||
for name := range members {
|
||||
if name == "preview.png" || strings.HasPrefix(name, "screenshots/") {
|
||||
t.Errorf("artifact carries presentation member %s", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateScreenshotsDirRejections(t *testing.T) {
|
||||
build := func(t *testing.T, mutate func(dir string)) error {
|
||||
t.Helper()
|
||||
dir := codelessFixture(t)
|
||||
mutate(dir)
|
||||
out := filepath.Join(t.TempDir(), "out.bnp")
|
||||
_, err := BuildCodeless(BuildOptions{Dir: dir, Output: out})
|
||||
return err
|
||||
}
|
||||
|
||||
t.Run("bad extension", func(t *testing.T) {
|
||||
err := build(t, func(dir string) {
|
||||
writeFixture(t, dir, map[string]string{"screenshots/readme.txt": "nope"})
|
||||
})
|
||||
if err == nil || !strings.Contains(err.Error(), "unsupported image type") {
|
||||
t.Fatalf("err = %v; want unsupported image type", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("subdirectory", func(t *testing.T) {
|
||||
err := build(t, func(dir string) {
|
||||
writeFixture(t, dir, map[string]string{"screenshots/sub/x.png": "nope"})
|
||||
})
|
||||
if err == nil || !strings.Contains(err.Error(), "subdirectories are not allowed") {
|
||||
t.Fatalf("err = %v; want subdirectory rejection", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("too many", func(t *testing.T) {
|
||||
err := build(t, func(dir string) {
|
||||
files := map[string]string{}
|
||||
for i := range maxScreenshotFiles + 1 {
|
||||
files[fmt.Sprintf("screenshots/%02d.png", i)] = "x"
|
||||
}
|
||||
writeFixture(t, dir, files)
|
||||
})
|
||||
if err == nil || !strings.Contains(err.Error(), "gallery cap") {
|
||||
t.Fatalf("err = %v; want gallery cap rejection", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("oversized image", func(t *testing.T) {
|
||||
err := build(t, func(dir string) {
|
||||
big := filepath.Join(dir, DirScreenshots, "big.png")
|
||||
if mkErr := os.MkdirAll(filepath.Dir(big), 0o755); mkErr != nil {
|
||||
t.Fatal(mkErr)
|
||||
}
|
||||
f, cErr := os.Create(big)
|
||||
if cErr != nil {
|
||||
t.Fatal(cErr)
|
||||
}
|
||||
if tErr := f.Truncate(maxScreenshotBytes + 1); tErr != nil {
|
||||
t.Fatal(tErr)
|
||||
}
|
||||
_ = f.Close()
|
||||
})
|
||||
if err == nil || !strings.Contains(err.Error(), "per-image cap") {
|
||||
t.Fatalf("err = %v; want per-image cap rejection", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("oversized preview", func(t *testing.T) {
|
||||
err := build(t, func(dir string) {
|
||||
big := filepath.Join(dir, FilePreview)
|
||||
f, cErr := os.Create(big)
|
||||
if cErr != nil {
|
||||
t.Fatal(cErr)
|
||||
}
|
||||
if tErr := f.Truncate(maxScreenshotBytes + 1); tErr != nil {
|
||||
t.Fatal(tErr)
|
||||
}
|
||||
_ = f.Close()
|
||||
})
|
||||
if err == nil || !strings.Contains(err.Error(), "per-image cap") {
|
||||
t.Fatalf("err = %v; want per-image cap rejection", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func mustRead(t *testing.T, path string) []byte {
|
||||
t.Helper()
|
||||
b, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return b
|
||||
}
|
||||
44
docs/adr/0009-codeless-artifacts-are-packed-by-the-sdk.md
Normal file
44
docs/adr/0009-codeless-artifacts-are-packed-by-the-sdk.md
Normal file
@ -0,0 +1,44 @@
|
||||
# Codeless artifacts are packed by the SDK
|
||||
|
||||
Status: accepted (WO-076, 2026-11-19)
|
||||
|
||||
The orchestrator's website factory compiles a site brief into a codeless site
|
||||
plugin and must turn that tree into a `.bnp` inside its own process (orchestrator
|
||||
ADR 0063). The code that validates and packs a codeless artifact lived in
|
||||
`cli/internal/bnp`, and Go's `internal` rule keeps it out of every other module.
|
||||
That code already depended on this module alone, so it moves here and the CLI
|
||||
and the orchestrator share one implementation.
|
||||
|
||||
Decision: a new package `bnp` holds the codeless build path. `BuildCodelessFS`
|
||||
takes an `fs.FS` and returns the artifact bytes with a `BuildResult`, so a
|
||||
caller can pack a tree held in memory. `BuildCodeless` resolves a directory,
|
||||
calls `BuildCodelessFS` with `os.DirFS`, and writes the file. The validation
|
||||
and packing pieces the CLI's wasm build also needs are exported over `fs.FS`:
|
||||
`ValidateBlocksDir`, `ValidateSeedDir`, `ApplyManifestYAML`, `CollectDir`,
|
||||
`PresentationEntries` and `Pack`, together with the artifact member names
|
||||
(`FileMod`, `FileManifest`, `DirBlocks`, `DirTemplates`, `DirSeed`,
|
||||
`FilePreview`, `DirScreenshots`) and `ScreenshotExtOK`.
|
||||
|
||||
The move keeps behaviour: the same validation rules, the same error handling
|
||||
and the same bytes. The weareblissful site builds to the same sha256 with the
|
||||
old CLI and through `BuildCodelessFS`. A symlinked optional directory is still
|
||||
skipped, matching the old `filepath.WalkDir` walk. Error text for a missing
|
||||
referenced file now names the path relative to the plugin root.
|
||||
|
||||
The wasm build (compile, DESCRIBE extraction) and `ninja plugin verify` stay in
|
||||
the CLI: they need the Go toolchain and wazero at publish time and have one
|
||||
consumer.
|
||||
|
||||
Consequences:
|
||||
|
||||
- New: `bnp/codeless.go`, `bnp/pack.go`, `bnp/screenshots.go` and their tests.
|
||||
- The module now requires `github.com/klauspost/compress` and
|
||||
`gopkg.in/yaml.v3`. A plugin that does not import `bnp` compiles none of it.
|
||||
- The CLI's `internal/bnp` calls this package (cli ADR 0003) and the
|
||||
orchestrator imports it for in-process packing.
|
||||
|
||||
Keywords: bnp, codeless, BuildCodeless, BuildCodelessFS, fs.FS, os.DirFS,
|
||||
ValidateBlocksDir, ValidateSeedDir, ApplyManifestYAML, CollectDir,
|
||||
PresentationEntries, Pack, Entry, BuildResult, BuildOptions, manifest.yaml,
|
||||
blocks.yaml, seed.json, preview.png, screenshots, tar.zst, zstd, artifact
|
||||
packing, byte-identical build, website factory, WO-076, ADR 0063
|
||||
4
go.mod
4
go.mod
@ -8,15 +8,19 @@ require (
|
||||
github.com/a-h/templ v0.3.1020
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/jackc/pgx/v5 v5.10.0
|
||||
github.com/klauspost/compress v1.18.6
|
||||
github.com/tetratelabs/wazero v1.12.0
|
||||
golang.org/x/mod v0.37.0
|
||||
golang.org/x/net v0.56.0
|
||||
google.golang.org/protobuf v1.36.11
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/rogpeppe/go-internal v1.16.0 // indirect
|
||||
golang.org/x/sys v0.46.0 // indirect
|
||||
golang.org/x/text v0.38.0 // indirect
|
||||
)
|
||||
|
||||
11
go.sum
11
go.sum
@ -4,6 +4,7 @@ github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk
|
||||
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||
github.com/a-h/templ v0.3.1020 h1:ypAT/L5ySWEnZ6Zft/5yfoWXYYkhFNvEFOeeqecg4tw=
|
||||
github.com/a-h/templ v0.3.1020/go.mod h1:A2DlK61v+K+NRoGnhmYbNYVmtYHcFO5/AisMvBdDxTM=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@ -19,8 +20,16 @@ github.com/jackc/pgx/v5 v5.10.0 h1:VhSvgU2jSli8o3AqIEOTJr7rZwAEUVo4E4XhR94Zfr0=
|
||||
github.com/jackc/pgx/v5 v5.10.0/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
|
||||
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
||||
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/klauspost/compress v1.18.6 h1:2jupLlAwFm95+YDR+NwD2MEfFO9d4z4Prjl1XXDjuao=
|
||||
github.com/klauspost/compress v1.18.6/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rogpeppe/go-internal v1.16.0 h1:O9DK+vNMDVGLr2BeZqmpLeMjiMNkuXfcqntWbZV6S5g=
|
||||
github.com/rogpeppe/go-internal v1.16.0/go.mod h1:DrUVZyrJU+txYW5/1kwtXQSMFio52ZOxX7yM1VHvnxs=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
@ -41,6 +50,8 @@ golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4=
|
||||
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
||||
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user