helpers

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDir

func CopyDir(src, dest string) error

CopyDir recursively copies a directory

func DeepCopyObject

func DeepCopyObject(obj map[string]*shared.RuntimeValue) map[string]*shared.RuntimeValue

DeepCopyObject creates a deep copy of a map of RuntimeValue objects

func DeepCopyRuntimeValue

func DeepCopyRuntimeValue(rtv *shared.RuntimeValue) *shared.RuntimeValue

DeepCopyRuntimeValue creates a deep copy of a single RuntimeValue

func DownloadFromTarball

func DownloadFromTarball(url, algorithm, hash, name, version string) (string, *shared.ProjectManifest, error)

func DownloadModule

func DownloadModule(moduleName string, version string, lockfile *shared.Lockfile) (string, *shared.ProjectManifest, error)

func DownloadModuleGit

func DownloadModuleGit(url string, constraint string) (string, *shared.ProjectManifest, error)

DownloadModuleGit takes a module git url and attempts to fetch and download a version satisfying the constraint

func DownloadModuleOnline

func DownloadModuleOnline(moduleName string, constraint string) (string, *shared.ProjectManifest, string, string, string, error)

func DownloadTemplate

func DownloadTemplate(templateURL, templateName string) error

DownloadTemplate downloads a template from a given URL to the templates directory Supports: - Local file paths - HTTP/HTTPS URLs for zip files - Git repository URLs

func EqualRuntimeValues

func EqualRuntimeValues(a, b *shared.RuntimeValue) bool

EqualRuntimeValues compares two VirtLang RuntimeValue objects for equality. It performs deep comparison based on the type and value of each RuntimeValue.

Equality rules: - Nil: Two nil values are equal - Number: Two numbers are equal if their float64 values are equal - Boolean: Two booleans are equal if they have the same boolean value - String: Two strings are equal if they have the same string content - Object: Two objects are equal if they have the same properties with equal values - Array: Two arrays are equal if they have the same length and equal elements in the same order - Function/NativeFN: Functions are compared by reference (only equal if they are the same function)

func ExtractTarGz

func ExtractTarGz(tarGzPath, targetDir string) error

func FetchManifest

func FetchManifest(pwd string, initialPwd string) (*shared.ProjectManifest, string, error)

FetchManifest locates and parses the xel.json manifest file by searching upward from the specified directory.

Parameters:

  • pwd: The current working directory to start searching from
  • initialPwd: The original directory where the search was initiated (for error reporting)

Returns:

  • *shared.ProjectManifest: The parsed manifest object if found
  • string: The absolute path to the manifest file if found
  • error: An error if the manifest cannot be found or parsed

func GenerateStackTrace

func GenerateStackTrace(stack debugger.CallStack, cwd string) string

func GetVersions

func GetVersions(moduleName string) map[*semver.Version]VersionData

GetVersions takes a module name and returns a map of versions to their manifests

func PosToLineCol

func PosToLineCol(input []byte, pos int) (line int, col int)

func ResolveModuleLocal

func ResolveModuleLocal(moduleName string, constraint string) (string, *shared.ProjectManifest, error)

ResolveModuleLocal takes a module name and attempts to find it in the configured module paths It returns the path to the module's manifest, the manifest itself and an error if the module is not found

func Stringify

func Stringify(value shared.RuntimeValue, internal bool) string

Stringify converts a RuntimeValue to its string representation. The internal parameter controls whether strings should be quoted (true) or not (false). When called internally (from within the interpreter), internal should be true to get quoted strings. When called for user output (like in print statements), internal should be false to get unquoted strings.

func SyntaxHighlighting

func SyntaxHighlighting(input string) string

func VerifyTarballIntegrity

func VerifyTarballIntegrity(tarballPath, algo, expectedHash string) error

Types

type RegistryPackageResp

type RegistryPackageResp struct {
	ID                int      `json:"id"`
	GID               int      `json:"gid"`
	Name              string   `json:"name"`
	Latest            int      `json:"latest"`
	Description       string   `json:"description"`
	Author            string   `json:"author"`
	RepoName          string   `json:"repo_name"`
	RepoURL           string   `json:"url"`
	MirrorURL         string   `json:"mirror"`
	Tags              []string `json:"tags"`
	IsDeprecated      bool     `json:"isDeprecated"`
	DeprecationReason string   `json:"deprecatedReason"`
}

type RegistryPackageVersionResp

type RegistryPackageVersionResp struct {
	Versions []RegistryPackageVersionRespMetadata
	Total    int `json:"total"`
	Limit    int `json:"limit"`
	Offset   int `json:"offset"`
}

type RegistryPackageVersionRespMetadata

type RegistryPackageVersionRespMetadata struct {
	Semver struct {
		Major int `json:"major"`
		Minor int `json:"minor"`
		Patch int `json:"patch"`
	} `json:"semver"`
	Version   string `json:"version"`
	Package   int    `json:"package"`
	Downloads int    `json:"downloads"`
	License   string `json:"license"`
	DistMode  string `json:"dist_mode"`
	Xel       string `json:"xel"`
	Engine    string `json:"engine"`
	ID        int    `json:"id"`
	GID       int    `json:"gid"`
}

type RegistryTarballMetadataResp

type RegistryTarballMetadataResp struct {
	Tarballs []struct {
		Integrity struct {
			Algorithm string `json:"algorithm"`
			Hash      string `json:"hash"`
		} `json:"integrity"`
		Package   int    `json:"package"`
		Version   int    `json:"version"`
		URL       string `json:"url"`
		SizeBytes int    `json:"size_bytes"`
		ID        int    `json:"id"`
		GID       int    `json:"gid"`
		Downloads int    `json:"downloads"`
	} `json:"tarballs"`
	Total  int `json:"total"`
	Limit  int `json:"limit"`
	Offset int `json:"offset"`
}

type VersionData

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

Jump to

Keyboard shortcuts

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