예제 #1
0
func (n *newCmd) configureSample(
	add *addCmd,
	name string,
	appConfig parsecli.AppConfig,
	args []string,
	e *parsecli.Env,
) error {
	if err := add.addSelectedApp(name, appConfig, args, e); err != nil {
		return err
	}

	masterKey, err := appConfig.GetMasterKey(e)
	if err != nil {
		return err
	}
	e.ParseAPIClient = e.ParseAPIClient.WithCredentials(
		parse.MasterKey{
			ApplicationID: appConfig.GetApplicationID(),
			MasterKey:     masterKey,
		},
	)

	if e.Type == parsecli.ParseFormat {
		return parsecmd.UseLatestJSSDK(e)
	}
	return nil
}
예제 #2
0
파일: new.go 프로젝트: swhitley/parse-cli
func CloneNodeCode(e *parsecli.Env, isNew, onlyConfig bool, appConfig parsecli.AppConfig) (bool, error) {
	cloneTemplate := false
	if !isNew && !onlyConfig {
		authToken, err := appConfig.GetApplicationAuth(e)
		if err != nil {
			return false, err
		}
		herokuAppConfig, ok := appConfig.(*parsecli.HerokuAppConfig)
		if !ok {
			return false, stackerr.New("invalid heroku app config")
		}

		var gitURL string
		g := &gitInfo{}

		herokuAppName, err := parsecli.FetchHerokuAppName(herokuAppConfig.HerokuAppID, e)
		if err != nil {
			return false, err
		}
		gitURL = fmt.Sprintf("https://:%[email protected]/%s.git", authToken, herokuAppName)
		err = g.clone(gitURL, e.Root)
		if err != nil {
			fmt.Fprintf(e.Err, `Failed to fetch the latest deployed code from Heroku.
Please try "git clone %s %s".
Currently cloning the template project.
`,
				gitURL,
				e.Root,
			)
			cloneTemplate = true
		} else {
			isEmpty, err := g.isEmptyRepository(e.Root)
			if err != nil {
				return false, err
			}
			if isEmpty {
				if err := os.RemoveAll(e.Root); err != nil {
					return false, stackerr.Wrap(err)
				}
				cloneTemplate = true
			}
		}
	}
	cloneTemplate = (isNew || cloneTemplate) && !onlyConfig
	return cloneTemplate, setupNodeSample(e, cloneTemplate)
}
예제 #3
0
파일: new.go 프로젝트: swhitley/parse-cli
func CloneSampleCloudCode(
	e *parsecli.Env,
	isNew, configOnly bool,
	appConfig parsecli.AppConfig) (bool, error) {
	dumpTemplate := false
	if !isNew && !configOnly {
		// if parse app was already created try to fetch Cloud Code and populate dir
		masterKey, err := appConfig.GetMasterKey(e)
		if err != nil {
			return false, err
		}
		e.ParseAPIClient = e.ParseAPIClient.WithCredentials(
			parse.MasterKey{
				ApplicationID: appConfig.GetApplicationID(),
				MasterKey:     masterKey,
			},
		)

		d := &downloadCmd{destination: e.Root}
		err = d.run(e, nil)
		if err != nil {
			if err == errNoFiles {
				dumpTemplate = true
			} else {
				fmt.Fprintln(
					e.Out,
					`
NOTE: If you like to fetch the latest deployed Cloud Code from Parse, 
you can use the "parse download" command after finishing the set up.
This will download Cloud Code to a temporary location.
`,
				)
			}
		}
	}
	dumpTemplate = (isNew || dumpTemplate) && !configOnly
	return dumpTemplate, parsecli.CloneSampleCloudCode(e, dumpTemplate)
}