parsecli

package
v0.0.0-...-e323bfb Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: BSD-3-Clause Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LegacyParseFormat = iota
	ParseFormat

	ParseLocal   = ".parse.local"
	ParseProject = ".parse.project"
	DefaultKey   = "_default"
)
View Source
const (
	Version        = "3.3.1"
	CloudDir       = "cloud"
	HostingDir     = "public"
	DefaultBaseURL = "https://parsecli.back4app.com/"
)
View Source
const (
	SampleSource = `` /* 161-byte string literal not displayed */

	SampleHTML = `` /* 779-byte string literal not displayed */

)
View Source
const ConfigDir = "config"

Variables

View Source
var LegacyConfigFile = filepath.Join(ConfigDir, "global.json")
View Source
var NewProjectFiles = []struct {
	Dirname, Filename, Content string
}{
	{"cloud", "main.js", SampleSource},
	{"public", "index.html", SampleHTML},
}
View Source
var UserAgent = fmt.Sprintf("parse-cli-%s-%s", runtime.GOOS, Version)

Functions

func CloneSampleCloudCode

func CloneSampleCloudCode(e *Env, dumpTemplate bool) error

func CreateConfigWithContent

func CreateConfigWithContent(path, content string) error

func ErrorString

func ErrorString(e *Env, err error) string

errorString returns the error string with our without the stack trace depending on the Environment variable. this exists because we want plain messages for end users, but when we're working on the CLI we want the stack trace for debugging.

func GetConfigFile

func GetConfigFile(e *Env) string

func GetLegacyProjectRoot

func GetLegacyProjectRoot(e *Env, cur string) string

func GetProjectRoot

func GetProjectRoot(e *Env, cur string) string

func IsProjectDir

func IsProjectDir(cur string) bool

func Last4

func Last4(str string) string

func MakeCorrections

func MakeCorrections(commands []string, args []string) string

MakeCorrections can be used to automatically correct the incorrect command in input args and return either an action that was taken or a suggestions message. One can also provide a map of aliases and related conversions

func NewAppHarness

func NewAppHarness(t testing.TB) (*Harness, []*App)

func PrintDefault

func PrintDefault(e *Env, defaultApp string) error

func RunNoArgs

func RunNoArgs(e *Env, f func(*Env) error) cobraRun

RunNoArgs wraps a run function that shouldn't get any arguments.

func RunWithArgs

func RunWithArgs(e *Env, f func(*Env, []string) error) cobraRun

RunWithArgs wraps a run function that can access arguments to cobraCmd

func RunWithArgsClient

func RunWithArgsClient(e *Env, f func(*Env, *Context, []string) error) cobraRun

RunWithArgsClient wraps a run function that should get an app, whee the default is picked from the config in the current working directory. It also passes args to the runner function

func RunWithClient

func RunWithClient(e *Env, f func(*Env, *Context) error) cobraRun

RunWithClient wraps a run function that should get an app, when the default is picked from the config in the current working directory.

func RunWithClientConfirm

func RunWithClientConfirm(e *Env, f func(*Env, *Context) error) cobraRun

RunWithClientConfirm wraps a run function that takes an app name or asks for confirmation to use the default app name instead

func SetDefault

func SetDefault(e *Env, newDefault, defaultApp string, c Config) error

func SetParserEmail

func SetParserEmail(e *Env, email string) error

func StoreConfig

func StoreConfig(e *Env, c Config) error

func StoreProjectConfig

func StoreProjectConfig(e *Env, c Config) error

func SuggestCommands

func SuggestCommands(given string, available []string) []string

SuggestCommands can be used to match a given word which is very similar to one among the list of available commands.

Types

type App

type App struct {
	Name                          string `json:"appName"`
	DashboardURL                  string `json:"dashboardURL"`
	ApplicationID                 string `json:"applicationId"`
	ClientKey                     string `json:"clientKey"`
	JavaScriptKey                 string `json:"javascriptKey"`
	WindowsKey                    string `json:"windowsKey"`
	WebhookKey                    string `json:"webhookKey"`
	RestKey                       string `json:"restKey"`
	MasterKey                     string `json:"masterKey"`
	ClientPushEnabled             bool   `json:"clientPushEnabled"`
	ClientClassCreationEnabled    bool   `json:"clientClassCreationEnabled"`
	RequireRevocableSessions      bool   `json:"requireRevocableSessions"`
	RevokeSessionOnPasswordChange bool   `json:"revokeSessionOnPasswordChange"`
}

func FetchAppKeys

func FetchAppKeys(e *Env, appID string) (*App, error)

type AppConfig

type AppConfig interface {
	GetApplicationID() string
	GetMasterKey(e *Env) (string, error)
	GetApplicationAuth(e *Env) (string, error)
	GetLink() string
}

type Apps

type Apps struct {
	Login Login
}

func (*Apps) CreateApp

func (a *Apps) CreateApp(e *Env, givenName string, retries int) (*App, error)

func (*Apps) PrintApp

func (a *Apps) PrintApp(e *Env, params *App) error

func (*Apps) RestFetchApps

func (a *Apps) RestFetchApps(e *Env) ([]*App, error)

func (*Apps) SelectApp

func (a *Apps) SelectApp(apps []*App, msg string, e *Env) (*App, error)

func (*Apps) ShowApps

func (a *Apps) ShowApps(e *Env, appName string) error

type Config

type Config interface {
	App(string) (AppConfig, error)
	AddAlias(string, string) error
	SetDefaultApp(string) error

	GetProjectConfig() *ProjectConfig
	GetDefaultApp() string
	GetNumApps() int
	PrettyPrintApps(*Env)
}

func ConfigFromDir

func ConfigFromDir(dir string) (Config, error)

type Context

type Context struct {
	Config    Config
	AppName   string
	AppConfig AppConfig
}

type Credentials

type Credentials struct {
	Email    string
	Password string
	Token    string
}

type Env

type Env struct {
	Root           string // project root
	Server         string // parse api server
	Type           int    // project type
	ParserEmail    string // email associated with developer parse account
	ErrorStack     bool
	Out            io.Writer
	Err            io.Writer
	In             io.Reader
	Exit           func(int)
	Clock          clock.Clock
	ParseAPIClient *ParseAPIClient
}

type Harness

type Harness struct {
	T     testing.TB
	Out   bytes.Buffer
	Err   bytes.Buffer
	Clock *clock.Mock
	Env   *Env
	// contains filtered or unexported fields
}

func NewHarness

func NewHarness(t testing.TB) *Harness

func NewTokenHarness

func NewTokenHarness(t testing.TB) *Harness

func (*Harness) MakeEmptyRoot

func (h *Harness) MakeEmptyRoot()

func (*Harness) MakeWithConfig

func (h *Harness) MakeWithConfig(global string)

func (*Harness) Stop

func (h *Harness) Stop()

type Login

type Login struct {
	Credentials Credentials
	TokenReader io.Reader
}

func (*Login) AuthToken

func (l *Login) AuthToken(e *Env, token string) (string, error)

func (*Login) AuthUser

func (l *Login) AuthUser(e *Env, strict bool) error

func (*Login) AuthUserWithToken

func (l *Login) AuthUserWithToken(e *Env, strict bool) (string, error)

func (*Login) GetTokenCredentials

func (l *Login) GetTokenCredentials(e *Env, email string) (bool, *Credentials, error)

func (*Login) HelpCreateToken

func (l *Login) HelpCreateToken(e *Env) (string, error)

func (*Login) StoreCredentials

func (l *Login) StoreCredentials(e *Env, email string, credentials *Credentials) error

type ParseAPIClient

type ParseAPIClient struct {
	APIClient *parse.Client
}

ParseAPIClient is the http client used by parse-cli

func NewParseAPIClient

func NewParseAPIClient(e *Env) (*ParseAPIClient, error)

func (*ParseAPIClient) Delete

func (c *ParseAPIClient) Delete(u *url.URL, result interface{}) (*http.Response, error)

Delete performs a DELETE method call on the given url and unmarshal response into result.

func (*ParseAPIClient) Do

func (c *ParseAPIClient) Do(req *http.Request, body, result interface{}) (*http.Response, error)

Do is a wrapper for parse.Client.Do

func (*ParseAPIClient) Get

func (c *ParseAPIClient) Get(u *url.URL, result interface{}) (*http.Response, error)

Get performs a GET method call on the given url and unmarshal response into result.

func (*ParseAPIClient) Post

func (c *ParseAPIClient) Post(u *url.URL, body, result interface{}) (*http.Response, error)

Post performs a POST method call on the given url with the given body and unmarshal response into result.

func (*ParseAPIClient) Put

func (c *ParseAPIClient) Put(u *url.URL, body, result interface{}) (*http.Response, error)

Put performs a PUT method call on the given url with the given body and unmarshal response into result.

func (*ParseAPIClient) RoundTrip

func (c *ParseAPIClient) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip is a wrapper for parse.Client.RoundTrip

func (*ParseAPIClient) WithCredentials

func (c *ParseAPIClient) WithCredentials(cr parse.Credentials) *ParseAPIClient

WithCredentials is a wrapper for parse.Client.WithCredentials

type ParseAppConfig

type ParseAppConfig struct {
	ApplicationID string `json:"applicationId,omitempty"`
	MasterKey     string `json:"masterKey,omitempty"`
	Link          string `json:"link,omitempty"`
	// contains filtered or unexported fields
}

func (*ParseAppConfig) GetApplicationAuth

func (c *ParseAppConfig) GetApplicationAuth(e *Env) (string, error)

func (*ParseAppConfig) GetApplicationID

func (c *ParseAppConfig) GetApplicationID() string
func (c *ParseAppConfig) GetLink() string

func (*ParseAppConfig) GetMasterKey

func (c *ParseAppConfig) GetMasterKey(e *Env) (string, error)

func (*ParseAppConfig) WithInternalMasterKey

func (c *ParseAppConfig) WithInternalMasterKey(masterKey string) *ParseAppConfig

type ParseConfig

type ParseConfig struct {
	Applications  map[string]*ParseAppConfig `json:"applications,omitempty"`
	ProjectConfig *ProjectConfig             `json:"-"`
}

func (*ParseConfig) AddAlias

func (c *ParseConfig) AddAlias(name, link string) error

func (*ParseConfig) App

func (c *ParseConfig) App(name string) (AppConfig, error)

func (*ParseConfig) GetDefaultApp

func (c *ParseConfig) GetDefaultApp() string

func (*ParseConfig) GetNumApps

func (c *ParseConfig) GetNumApps() int

func (*ParseConfig) GetProjectConfig

func (c *ParseConfig) GetProjectConfig() *ProjectConfig

func (*ParseConfig) PrettyPrintApps

func (c *ParseConfig) PrettyPrintApps(e *Env)

func (*ParseConfig) SetDefaultApp

func (c *ParseConfig) SetDefaultApp(name string) error

type ParseProjectConfig

type ParseProjectConfig struct {
	JSSDK string `json:"jssdk,omitempty"`
}

type ProjectConfig

type ProjectConfig struct {
	// Type indicates the type of config.
	// Some examples are legacy, parse, etc.
	Type int `json:"project_type,omitempty"`
	// Parse stores the project config for Parse type.
	// Currently jssdk version is the only
	// project level config for Parse type.
	Parse *ParseProjectConfig `json:"parse,omitempty"`
	// ParserEmail is an email id of the Parse developer.
	// It is associated with this project.
	// It is used to fetch appropriate credentials from netrc.
	ParserEmail string `json:"email,omitempty"`
}

type TransportFunc

type TransportFunc func(r *http.Request) (*http.Response, error)

func (TransportFunc) RoundTrip

func (t TransportFunc) RoundTrip(r *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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