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
- func BaselinePath(root string) string
- func CheckBump(baseline, now Version, level Level) error
- func NameProblem(name string) string
- func Publish(ctx context.Context, p Package, opt PublishOptions) error
- func TarballName(name, version string) string
- func WriteBaseline(root string, b Baseline) error
- type Baseline
- type Change
- type File
- type Level
- type Package
- type PublishOptions
- type Version
Constants ¶
const DefaultRegistry = "https://registry.npmjs.org"
DefaultRegistry is the public npm registry.
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 ¶
BaselinePath returns the file of the baseline under the app root. The scaffold keeps .gx/base/ in git.
func CheckBump ¶
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 ¶
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 ¶
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 ¶
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 ¶
ReadBaseline reads the baseline of the app. An app with no baseline gives nil.
type Change ¶
Change is one difference between the baseline and the manifest of now.
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 ¶
PackageJSON returns the package.json of the package.
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.