widgetpkg

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package widgetpkg is the package of the widgets of an app for a host: the check of the contract against the last published baseline (REQ-ISL-13), and the npm tarball and its publish (REQ-ISL-14).

Index

Constants

View Source
const DefaultRegistry = "https://registry.npmjs.org"

DefaultRegistry is the public npm registry.

View Source
const ManifestFile = "custom-elements.json"

ManifestFile is the name of the custom elements manifest in the package.

Variables

This section is empty.

Functions

func BaselinePath

func BaselinePath(root string) string

BaselinePath returns the file of the baseline under the app root. The scaffold keeps .gx/base/ in git.

func CheckBump

func CheckBump(baseline, now Version, level Level) error

CheckBump returns an error when the version of now does not have the bump that the level needs from the version of the baseline.

func NameProblem

func NameProblem(name string) string

NameProblem says why a name is not a name of an npm package, or "".

func Publish

func Publish(ctx context.Context, p Package, opt PublishOptions) error

Publish sends one version of the package to an npm registry through its HTTP API (REQ-ISL-14). It runs no node and no npm.

func TarballName

func TarballName(name, version string) string

TarballName returns the file name that npm gives the tarball of a version: "@acme/widgets" at 1.0.0 gives "acme-widgets-1.0.0.tgz".

func WriteBaseline

func WriteBaseline(root string, b Baseline) error

WriteBaseline records the manifest of a version as the baseline.

Types

type Baseline

type Baseline struct {
	Name     string          `json:"name"`
	Version  string          `json:"version"`
	Manifest json.RawMessage `json:"manifest"`
}

Baseline is the contract of the last published version. The app commits the file.

func ReadBaseline

func ReadBaseline(root string) (*Baseline, error)

ReadBaseline reads the baseline of the app. An app with no baseline gives nil.

type Change

type Change struct {
	Level Level
	Text  string
}

Change is one difference between the baseline and the manifest of now.

func Compare

func Compare(baseline, now []byte) ([]Change, error)

Compare returns the changes from the manifest of the baseline to the manifest of now (REQ-ISL-13). A removed or retyped attribute, event, event detail field or CSS variable is a major change, and so is a removed widget. An addition is a minor change.

type File

type File struct {
	Name string
	Data []byte
}

File is one file of the package.

type Level

type Level int

Level is the version bump that a change of the contract needs.

const (
	// None is a contract with no change.
	None Level = iota
	// Minor is an addition.
	Minor
	// Major is a breaking change: a host that uses the old contract fails.
	Major
)

func Needed

func Needed(changes []Change) Level

Needed returns the highest level of the changes.

func (Level) String

func (l Level) String() string

type Package

type Package struct {
	Name    string
	Version string
	// Tags are the element names of the widgets. Files holds <tag>.js,
	// <tag>.d.ts and <tag>.react.d.ts for each one.
	Tags  []string
	Files []File
}

Package is the npm package of the widgets of an app (REQ-ISL-14): for each widget the element file and its type files, and one manifest.

func (Package) PackageJSON

func (p Package) PackageJSON() ([]byte, error)

PackageJSON returns the package.json of the package.

func (Package) Tarball

func (p Package) Tarball() ([]byte, error)

Tarball returns the npm tarball of the package: each file below package/, in the order of the names, with no time and no owner. The same files give the same bytes, so the integrity of a version does not change with the machine or the day.

type PublishOptions

type PublishOptions struct {
	// Registry is the URL of the npm registry.
	Registry string
	// Token is the token of the registry. It goes into the Authorization
	// header only.
	Token string
	// Tag is the dist-tag of the version, for example latest.
	Tag string
	// Access is public or restricted, or "" for the rule of the registry.
	Access string
	Client *http.Client
}

PublishOptions says where and how a package is published.

type Version

type Version struct{ Major, Minor, Patch int }

Version is a semver version with no pre-release part.

func ParseVersion

func ParseVersion(s string) (Version, error)

ParseVersion reads a version such as 1.4.0.

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL