registry

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindToken

func FindToken(regURL string, rcs []*NpmRC) string

func NormRegURL

func NormRegURL(u string) string

NormRegURL make sure reg url has a `/` suffix

Types

type API

type API struct {
	// contains filtered or unexported fields
}

func NewAPI

func NewAPI(u string, token string) (*API, error)

func (*API) Publish

func (api *API) Publish(tarball io.Reader, packageJSON json.RawMessage) error

type DefaultNpmRc

type DefaultNpmRc struct {
	Path, URL, Token string
}

func GetDefaultNpmRC

func GetDefaultNpmRC() (*DefaultNpmRc, error)

type Integrity

type Integrity struct {
	SHASum    string `json:"shasum"`
	Integrity string `json:"integrity"`
	Base64    string `json:"base_64"`
	Length    int64  `json:"length"`
}

func MakeIntegrity

func MakeIntegrity(reader io.Reader) (*Integrity, error)

type NpmRC

type NpmRC struct {
	FilePath   string
	DefaultURL string
	Tokens     []NpmRCToken
}

func GetNpmRC

func GetNpmRC() ([]*NpmRC, error)

GetNpmRC find the .npmrc file in system and parse it will find from `pwd`, then $HOME folder

func ParseNpmRc

func ParseNpmRc(p string) (*NpmRC, error)

ParseNpmRc parse main reg url and token npmrc declares in ini format https://docs.npmjs.com/cli/v10/configuring-npm/npmrc we only get default registry and all the tokens auth scoped settings and other auth method is not yet implemented

type NpmRCToken

type NpmRCToken struct {
	URL, Token string
}

type PackageInfo

type PackageInfo struct {
	model.PackageJSON
	// contains filtered or unexported fields
}

func ParsePackageInfo

func ParsePackageInfo(packageJSON json.RawMessage) (*PackageInfo, error)

type PublishAttachments

type PublishAttachments struct {
	ContentType string `json:"content_type"` // application/octet-stream
	Data        string `json:"data"`         // b64 encoded tar
	Length      int64  `json:"length"`       // tar size
}

type PublishInfo

type PublishInfo struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	DistTags    struct {
		Latest string `json:"latest"`
	} `json:"dist-tags"`
	Versions    map[string]rawMessage         `json:"versions"`     // key is version
	Attachments map[string]PublishAttachments `json:"_attachments"` // key is tar name
}

type VersionDist

type VersionDist struct {
	Integrity string `json:"integrity"` // sha512 in b64
	SHASum    string `json:"shasum"`    // sha1 in hex
	Tarball   string `json:"tarball"`   // tar's location url in registry

} // should in "dist" key of PublishInfo.Versions

Jump to

Keyboard shortcuts

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