func (cmd *CommandDiff) Handler(profile *user.Profile, ui terminal.UI, clients cli.Clients) error {
	app, err := local.LoadApp(cmd.inputs.LocalPath)
	if err != nil {
		return err
	}

	appToDiff, err := cli.ResolveApp(ui, clients.Realm, cli.AppOptions{
		Filter:  realm.AppFilter{GroupID: cmd.inputs.Project, App: cmd.inputs.RemoteApp},
		AppMeta: app.Meta,
	})
	if err != nil {
		return err
	}

	diffs, err := clients.Realm.Diff(appToDiff.GroupID, appToDiff.ID, app.AppData)
	if err != nil {
		return err
	}

	if cmd.inputs.IncludeNodeModules || cmd.inputs.IncludePackageJSON || cmd.inputs.IncludeDependencies {
		appDependencies, err := cmd.inputs.resolveAppDependencies(app.RootDir)
		if err != nil {
			return err
		}

		uploadPath, cleanup, err := appDependencies.PrepareUpload()
		if err != nil {
			return err
		}
		defer cleanup()

		dependenciesDiff, err := clients.Realm.DiffDependencies(appToDiff.GroupID, appToDiff.ID, uploadPath)
		if err != nil {
			return err
		}
		diffs = append(diffs, dependenciesDiff.Strings()...)
	}

	if cmd.inputs.IncludeHosting {
		hosting, err := local.FindAppHosting(app.RootDir)
		if err != nil {
			return err
		}

		appAssets, err := clients.Realm.HostingAssets(appToDiff.GroupID, appToDiff.ID)
		if err != nil {
			return err
		}

		hostingDiffs, err := hosting.Diffs(profile.HostingAssetCachePath(), appToDiff.ID, appAssets)
		if err != nil {
			return err
		}

		diffs = append(diffs, hostingDiffs.Strings()...)
	}

	if len(diffs) == 0 {
		// there are no diffs
		ui.Print(terminal.NewTextLog("Deployed app is identical to proposed version"))
		return nil
	}

	ui.Print(terminal.NewTextLog(
		"The following reflects the proposed changes to your Realm app\n%s",
		strings.Join(diffs, "\n"),
	))

	return nil
}
// Handler is the command handler
Handler is the command handler
// Handler is the command handler
func (cmd *CommandDiff) Handler(profile *user.Profile, ui terminal.UI, clients cli.Clients) error {
	app, err := local.LoadApp(cmd.inputs.LocalPath)
	if err != nil {
		return err
	}
	appToDiff, err := cli.ResolveApp(ui, clients.Realm, cli.AppOptions{
		Filter:  realm.AppFilter{GroupID: cmd.inputs.Project, App: cmd.inputs.RemoteApp},
		AppMeta: app.Meta,
	})
	if err != nil {
		return err
	}
	diffs, err := clients.Realm.Diff(appToDiff.GroupID, appToDiff.ID, app.AppData)
	if err != nil {
		return err
	}
	if cmd.inputs.IncludeNodeModules || cmd.inputs.IncludePackageJSON || cmd.inputs.IncludeDependencies {
		appDependencies, err := cmd.inputs.resolveAppDependencies(app.RootDir)
		if err != nil {
			return err
		}
		uploadPath, cleanup, err := appDependencies.PrepareUpload()
		if err != nil {
			return err
		}
		defer cleanup()
		dependenciesDiff, err := clients.Realm.DiffDependencies(appToDiff.GroupID, appToDiff.ID, uploadPath)
		if err != nil {
			return err
		}
		diffs = append(diffs, dependenciesDiff.Strings()...)
	}
	if cmd.inputs.IncludeHosting {
		hosting, err := local.FindAppHosting(app.RootDir)
		if err != nil {
			return err
		}
		appAssets, err := clients.Realm.HostingAssets(appToDiff.GroupID, appToDiff.ID)
		if err != nil {
			return err
		}
		hostingDiffs, err := hosting.Diffs(profile.HostingAssetCachePath(), appToDiff.ID, appAssets)
		if err != nil {
			return err
		}
		diffs = append(diffs, hostingDiffs.Strings()...)
	}
	if len(diffs) == 0 {
		ui.Print(terminal.NewTextLog("Deployed app is identical to proposed version"))
		return nil
	}
	ui.Print(terminal.NewTextLog(
		"The following reflects the proposed changes to your Realm app\n%s",
		strings.Join(diffs, "\n"),
	))
	return nil
}
func ( cmd * CommandDiff ) Handler ( profile * user . Profile , ui terminal . UI , clients cli . Clients ) error { app , err := local . LoadApp ( cmd . inputs . LocalPath ) if err != nil { return err } appToDiff , err := cli . ResolveApp ( ui , clients . Realm , cli . AppOptions { Filter : realm . AppFilter { GroupID : cmd . inputs . Project , App : cmd . inputs . RemoteApp } , AppMeta : app . Meta , } ) if err != nil { return err } diffs , err := clients . Realm . Diff ( appToDiff . GroupID , appToDiff . ID , app . AppData ) if err != nil { return err } if cmd . inputs . IncludeNodeModules || cmd . inputs . IncludePackageJSON || cmd . inputs . IncludeDependencies { appDependencies , err := cmd . inputs . resolveAppDependencies ( app . RootDir ) if err != nil { return err } uploadPath , cleanup , err := appDependencies . PrepareUpload ( ) if err != nil { return err } defer cleanup ( ) dependenciesDiff , err := clients . Realm . DiffDependencies ( appToDiff . GroupID , appToDiff . ID , uploadPath ) if err != nil { return err } diffs = append ( diffs , dependenciesDiff . Strings ( ) ... ) } if cmd . inputs . IncludeHosting { hosting , err := local . FindAppHosting ( app . RootDir ) if err != nil { return err } appAssets , err := clients . Realm . HostingAssets ( appToDiff . GroupID , appToDiff . ID ) if err != nil { return err } hostingDiffs , err := hosting . Diffs ( profile . HostingAssetCachePath ( ) , appToDiff . ID , appAssets ) if err != nil { return err } diffs = append ( diffs , hostingDiffs . Strings ( ) ... ) } if len ( diffs ) == 0 { ui . Print ( terminal . NewTextLog ( " " ) ) return nil } ui . Print ( terminal . NewTextLog ( " \n " , strings . Join ( diffs , " \n " ) , ) ) return nil }
Handler is the command handler
Handler is the command handler
// there are no diffs