source

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package source parses the source-reference vocabulary shared by package installation and Pig piglet resource origins. It preserves upstream Pi's npm/git/local grammar while allowing Pig products to contribute explicit lowercase schemes without teaching generic code their transport semantics.

pig additive (D18): product-neutral typed source and contributed schemes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidNPMPackageName

func ValidNPMPackageName(name string) bool

ValidNPMPackageName reports whether name is a name npm accepts for a package that is about to be published. It does not check npm's length limit; npm reports that when it publishes.

pig additive (D18): npm publication of Packages and Piglet source.

func ValidNPMVersion

func ValidNPMVersion(version string) bool

ValidNPMVersion reports whether version is a version npm publishes: a full MAJOR.MINOR.PATCH semantic version with an optional prerelease and build, and no leading `v`. Go's semver also accepts the shorthand `1` and `1.2`, which npm rejects as an invalid version.

pig additive (D18): npm publication of Packages and Piglet source.

Types

type BarePolicy

type BarePolicy uint8

BarePolicy controls how a source without an explicit scheme/path marker is interpreted. Each caller selects local, npm, or rejection semantics.

const (
	BareReject BarePolicy = iota
	BareLocal
	BareNPM
)

type Kind

type Kind string

Kind is the transport-independent source category.

const (
	KindLocal       Kind = "local"
	KindNPM         Kind = "npm"
	KindGit         Kind = "git"
	KindContributed Kind = "contributed"
)

type Options

type Options struct {
	BaseDir          string
	Bare             BarePolicy
	AllowContributed bool
}

Options defines boundary-specific parsing behavior.

type Ref

type Ref struct {
	Raw     string
	Kind    Kind
	Scheme  string
	Locator string

	NPMName     string
	NPMVer      string
	NPMRegistry string

	GitHost   string
	GitPath   string
	GitRef    string
	GitRepo   string
	GitSubdir string
}

Ref is a parsed source. Raw is retained for settings/piglet serialization; identity fields exclude mutable version/ref selectors where upstream package de-duplication does.

func Parse

func Parse(input string, opts Options) (Ref, error)

Parse validates and classifies input without materializing it. npm selectors retain spaces and tabs used by comparator sets, hyphen ranges, and unions.

func (Ref) Identity

func (r Ref) Identity(baseDir string) (string, error)

Identity returns the stable de-duplication identity. npm versions and Git refs are deliberately excluded to match upstream package identity semantics.

type SourceInfo

type SourceInfo struct {
	Path    string `json:"path"`
	Source  string `json:"source"`
	Scope   string `json:"scope"`
	Origin  string `json:"origin"`
	BaseDir string `json:"baseDir,omitempty"`
}

SourceInfo mirrors core/source-info.ts SourceInfo: where a resource, tool or command came from.

Jump to

Keyboard shortcuts

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