util

package
v0.0.72 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2025 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version = "dev"
	Commit  = "unknown"
)
View Source
var ErrTimeout = errors.New("timeout")
View Source
var PackageJsonKeysOrder = []string{
	"name",
	"description",
	"version",
	"main",
	"type",
	"scripts",
	"keywords",
	"author",
	"license",
	"engines",
	"private",
	"devDependencies",
	"peerDependencies",
	"dependencies",
}

these are the keys that will be written in order to the package.json file if a key is not present, it will be added to the end of the file

View Source
var TypeScriptConfigJsonKeysOrder = []string{
	"compilerOptions",
	"include",
	"exclude",
}

these are the keys that will be written in order to the package.json file if a key is not present, it will be added to the end of the file

Functions

func BrowserFlow

func BrowserFlow(opts BrowserFlowOptions) error

BrowserFlow will open a browser and wait for the user to finish the flow. It will return an error if the flow times out with an ErrTimeout error. It will return an error if the callback fails or any other error occurs.

func CheckLatestRelease added in v0.0.70

func CheckLatestRelease(ctx context.Context) error

func CopyDir

func CopyDir(src string, dst string) error

CopyDir will copy all files recursively from src to dst

func CopyFile

func CopyFile(src, dst string) (int64, error)

CopyFile will copy src to dst

func EnsureLoggedIn added in v0.0.42

func EnsureLoggedIn() (string, string)

func EnsureLoggedInWithOnlyAPIKey added in v0.0.43

func EnsureLoggedInWithOnlyAPIKey() string

func Exists

func Exists(fn string) bool

Exists returns true if the filename or directory specified by fn exists.

func GetLatestRelease added in v0.0.70

func GetLatestRelease(ctx context.Context) (string, error)

GetLatestRelease returns the latest release tag name from the GitHub API

func GetURLs added in v0.0.42

func GetURLs(logger logger.Logger) (string, string, string)

func ListDir

func ListDir(dir string) ([]string, error)

ListDir will return an array of files recursively walking into sub directories

func NewOrderedMap added in v0.0.26

func NewOrderedMap(keys []string, data map[string]any) *orderedMap

func NewOrderedMapFromFile added in v0.0.26

func NewOrderedMapFromFile(keys []string, filename string) (*orderedMap, error)

func NewOrderedMapFromJSON added in v0.0.26

func NewOrderedMapFromJSON(keys []string, buf []byte) (*orderedMap, error)

func Pluralize added in v0.0.23

func Pluralize(count int, singular string, plural string) string

func RandStringBytes

func RandStringBytes(n int) string

RandStringBytes will generate a random string of length n using the alphaNumChars string.

func SafeFilename added in v0.0.23

func SafeFilename(name string) string

func ShowLogin added in v0.0.42

func ShowLogin()

func TransformUrl added in v0.0.47

func TransformUrl(urlString string) string

func UserAgent added in v0.0.70

func UserAgent() string

func ZipDir

func ZipDir(dir string, outfilename string, opts ...ZipDirCallbackMatcher) error

ZipDir will zip up a directory into the outfilename and return an error if it fails

Types

type APIClient

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

func NewAPIClient

func NewAPIClient(ctx context.Context, logger logger.Logger, baseURL, token string) *APIClient

func (*APIClient) Do

func (c *APIClient) Do(method, path string, payload interface{}, response interface{}) error

type APIError added in v0.0.51

type APIError struct {
	URL      string
	Method   string
	Status   int
	Body     string
	TheError error
	TraceID  string
}

func NewAPIError added in v0.0.51

func NewAPIError(url, method string, status int, body string, err error, traceID string) *APIError

func (*APIError) Error added in v0.0.51

func (e *APIError) Error() string

type APIResponse added in v0.0.52

type APIResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Error   struct {
		Issues []struct {
			Code    string   `json:"code"`
			Message string   `json:"message"`
			Path    []string `json:"path"`
		} `json:"issues"`
	} `json:"error"`
}

type BrowserFlowOptions

type BrowserFlowOptions struct {
	Logger      logger.Logger
	BaseUrl     string
	StartPath   string
	WaitMessage string
	AuthToken   string
	Query       map[string]string
	Callback    browserCallback
}

type ZipDirCallbackMatcher

type ZipDirCallbackMatcher func(fn string, fi os.FileInfo) bool

ZipDirCallbackMatcher is a function that returns true if the file should be included in the zip

Jump to

Keyboard shortcuts

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