Documentation ¶
Overview ¶
Package utils is the uncategorized utils for zbpack.
Index ¶
- func ConstraintToVersion(constraints string, defaultVersion string) string
- func Copy(src, dst string) error
- func ExtractErlangEntryFromGleamEntrypointShell(gleamEntryShell string) string
- func GetExplicitServerlessConfig(config plan.ImmutableProjectConfiguration) optional.Option[bool]
- func HasFile(src afero.Fs, fileNames ...string) bool
- func ReadFileToUTF8(fs afero.Fs, path string) ([]byte, error)
- func ReadToUTF8(content []byte) ([]byte, error)
- func WeakContains(a, b string) bool
- type IntOrBool
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstraintToVersion ¶
ConstraintToVersion converts the Semver version constraint to a minor-only version.
func ExtractErlangEntryFromGleamEntrypointShell ¶
ExtractErlangEntryFromGleamEntrypointShell extracts the Erlang entrypoint from the Gleam entrypoint shell script
func GetExplicitServerlessConfig ¶
func GetExplicitServerlessConfig(config plan.ImmutableProjectConfiguration) optional.Option[bool]
GetExplicitServerlessConfig gets the serverless flag from the project configuration.
When the serverless flag is not set, it will be determined by the FORCE_CONTAINERIZED and ZBPACK_SERVERLESS environment variables. If all of them are not set, it returns None for consumers to determine the default value.
func ReadFileToUTF8 ¶
ReadFileToUTF8 reads a file from the filesystem and decode it to UTF-8.
It is basically the wrapper of afero.ReadFile.
func ReadToUTF8 ¶
ReadToUTF8 accepts a byte slice and check if it is a UTF-8, UTF-16 LE or UTF-16 BE encoded string by BOM and decode it to UTF-8 byte string.
func WeakContains ¶
WeakContains is just like strings.Contains, but it's case-insensitive.
Types ¶
type IntOrBool ¶
IntOrBool is a type that can be either an int or a bool
func (*IntOrBool) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type Version ¶
type Version struct { // Major version. Major uint32 // Minor version. Minor uint32 // MinorSet indicates if the minor version is set. MinorSet bool // Patch version. Patch uint32 // PatchSet indicates if the patch version is set. PatchSet bool // Prerelease version. Empty = not set. Prerelease string }
Version represents a semver version.
func SplitVersion ¶
SplitVersion splits the version string into major, minor, patch, and prerelease.
If the version string is "8.0.0-beta1", the result will be 8, 0, 0, "beta1". If the version is a wildcard, the field will be -1.