util

package
v0.0.30 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

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 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 Exists

func Exists(fn string) bool

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

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 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(logger logger.Logger, baseURL, token string) *APIClient

func (*APIClient) Do

func (c *APIClient) Do(method, path string, payload interface{}, response interface{}) 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