• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang descriptors.AppDescriptor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/giancosta86/moondeploy/v3/descriptors.AppDescriptor的典型用法代码示例。如果您正苦于以下问题:Golang AppDescriptor类的具体用法?Golang AppDescriptor怎么用?Golang AppDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AppDescriptor类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: resolveAppDir

func (appGallery *AppGallery) resolveAppDir(bootDescriptor descriptors.AppDescriptor) (appDir string) {
	baseURL := bootDescriptor.GetDeclaredBaseURL()

	hostComponent := strings.Replace(baseURL.Host, ":", "_", -1)

	appDirComponents := []string{
		appGallery.Directory,
		hostComponent}

	trimmedBasePath := strings.Trim(baseURL.Path, "/")
	baseComponents := strings.Split(trimmedBasePath, "/")

	appDirComponents = append(appDirComponents, baseComponents...)

	if hostComponent == "github.com" &&
		len(appDirComponents) > 2 &&
		appDirComponents[len(appDirComponents)-2] == "releases" &&
		appDirComponents[len(appDirComponents)-1] == "latest" {
		appDirComponents = appDirComponents[0 : len(appDirComponents)-2]
	}

	appDir = filepath.Join(appDirComponents...)

	return appDir
}
开发者ID:giancosta86,项目名称:moondeploy,代码行数:25,代码来源:appGallery.go


示例2: GetApp

func (appGallery *AppGallery) GetApp(bootDescriptor descriptors.AppDescriptor) (app *App, err error) {
	appDir := appGallery.resolveAppDir(bootDescriptor)

	return &App{
		Directory:           appDir,
		bootDescriptor:      bootDescriptor,
		filesDirectory:      filepath.Join(appDir, filesDirName),
		localDescriptorPath: filepath.Join(appDir, bootDescriptor.GetDescriptorFileName()),
	}, nil
}
开发者ID:giancosta86,项目名称:moondeploy,代码行数:10,代码来源:appGallery.go


示例3: CreateDesktopShortcut

func (app *App) CreateDesktopShortcut(launcher launchers.Launcher, referenceDescriptor descriptors.AppDescriptor) (err error) {
	desktopDir, err := caravel.GetUserDesktop()
	if err != nil {
		return err
	}

	if !caravel.DirectoryExists(desktopDir) {
		return fmt.Errorf("Expected desktop dir '%v' not found", desktopDir)
	}

	scriptFileName := caravel.FormatFileName(referenceDescriptor.GetName())
	log.Debug("Bash shortcut name: '%v'", scriptFileName)

	scriptFilePath := filepath.Join(desktopDir, scriptFileName)
	log.Info("Creating Bash shortcut: '%v'...", scriptFilePath)

	scriptFile, err := os.OpenFile(scriptFilePath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0700)
	if err != nil {
		return err
	}
	defer func() {
		scriptFile.Close()

		if err != nil {
			os.Remove(scriptFilePath)
		}
	}()

	scriptContent := fmt.Sprintf(macScriptContentFormat,
		launcher.GetExecutable(),
		app.localDescriptorPath)

	_, err = scriptFile.Write([]byte(scriptContent))
	if err != nil {
		return err
	}

	log.Notice("Bash shortcut script created")

	return nil
}
开发者ID:giancosta86,项目名称:moondeploy,代码行数:41,代码来源:desktop_darwin.go


示例4: FormatSecureFirstRunPrompt

func FormatSecureFirstRunPrompt(bootDescriptor descriptors.AppDescriptor) string {
	const basicFirstRunTemplate = "You are running an application for the first time." +
		"\n\n\nTitle:   %v" +
		"\n\nPublisher:   %v" +
		"\n\nAddress:   %v\n\n\nDo you wish to proceed?"

	return fmt.Sprintf(basicFirstRunTemplate,

		bootDescriptor.GetTitle(),
		bootDescriptor.GetPublisher(),
		bootDescriptor.GetDeclaredBaseURL())
}
开发者ID:giancosta86,项目名称:moondeploy,代码行数:12,代码来源:prompts.go


示例5: CreateDesktopShortcut

func (app *App) CreateDesktopShortcut(launcher launchers.Launcher, referenceDescriptor descriptors.AppDescriptor) (err error) {
	desktopDir, err := caravel.GetUserDesktop()
	if err != nil {
		return err
	}

	if !caravel.DirectoryExists(desktopDir) {
		return fmt.Errorf("Expected desktop dir '%v' not found", desktopDir)
	}

	shortcutFileName := caravel.FormatFileName(referenceDescriptor.GetName()) + ".desktop"
	log.Debug("Shortcut file name: '%v'", shortcutFileName)

	shortcutFilePath := filepath.Join(desktopDir, shortcutFileName)

	log.Info("Creating desktop shortcut: '%v'...", shortcutFilePath)

	shortcutFile, err := os.OpenFile(shortcutFilePath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0700)
	if err != nil {
		return err
	}
	defer func() {
		shortcutFile.Close()
		if err != nil {
			os.Remove(shortcutFilePath)
		}
	}()

	actualIconPath := app.GetActualIconPath(launcher)

	shortcutContent := fmt.Sprintf(linuxShortcutContent,
		referenceDescriptor.GetName(),
		referenceDescriptor.GetDescription(),
		launcher.GetExecutable(),
		app.GetLocalDescriptorPath(),
		actualIconPath)

	_, err = shortcutFile.Write([]byte(shortcutContent))
	if err != nil {
		return err
	}

	log.Notice("Desktop shortcut created")

	return nil
}
开发者ID:giancosta86,项目名称:moondeploy,代码行数:46,代码来源:desktop_linux.go


示例6: CreateDesktopShortcut

func (app *App) CreateDesktopShortcut(launcher launchers.Launcher, referenceDescriptor descriptors.AppDescriptor) (err error) {
	desktopDir, err := caravel.GetUserDesktop()
	if err != nil {
		return err
	}

	shortcutName := caravel.FormatFileName(referenceDescriptor.GetName()) + ".lnk"
	log.Debug("Shortcut file name: '%v'", shortcutName)

	shortcutFilePath := filepath.Join(desktopDir, shortcutName)
	log.Debug("Shortcut path: '%v'", shortcutFilePath)

	log.Info("Creating desktop shortcut: '%v'...", shortcutFilePath)

	log.Debug("Creating temp file for script...")

	salt := rand.Int63()
	tempFileName := fmt.Sprintf("shortcutScript_%v_%v.vbs", time.Now().Unix(), salt)
	tempFilePath := filepath.Join(os.TempDir(), tempFileName)
	tempFile, err := os.Create(tempFilePath)

	if err != nil {
		return err
	}
	defer func() {
		tempFile.Close()

		tempRemovalErr := os.Remove(tempFilePath)
		if tempRemovalErr != nil {
			log.Warning("Cannot remove the temp script: %v", tempFilePath)
		} else {
			log.Debug("Temp script successfully removed")
		}

		if err != nil {
			os.Remove(shortcutFilePath)
		}
	}()

	log.Debug("Temp script file created: %v", tempFilePath)
	actualIconPath := app.GetActualIconPath(launcher)
	log.Debug("Actual icon path: '%v'", actualIconPath)

	workingDirectory := filepath.Dir(app.GetLocalDescriptorPath())
	log.Debug("Working directory: '%v'", workingDirectory)

	shortcutScript := fmt.Sprintf(windowsShortcutContent,
		shortcutFilePath,
		app.GetLocalDescriptorPath(),
		referenceDescriptor.GetDescription(),
		actualIconPath,
		workingDirectory)

	log.Debug("Writing script temp file...")
	tempFile.Write([]byte(shortcutScript))
	tempFile.Close()
	log.Debug("Temp script ready")

	log.Debug("Now executing the temp script...")

	shortcutCreationCommand := exec.Command("wscript", "/b", "/nologo", tempFilePath)

	err = shortcutCreationCommand.Run()
	if err != nil {
		return err
	}

	if !shortcutCreationCommand.ProcessState.Success() {
		return fmt.Errorf("The script did not run successfully")
	}

	log.Debug("The script was successful")

	return nil
}
开发者ID:giancosta86,项目名称:moondeploy,代码行数:75,代码来源:desktop_windows.go


示例7: Run

/*
Run is the entry point you must employ to create a custom installer, for example to
employ custom settings or a brand-new user interface, based on any technology
*/
func Run(
	launcher launchers.Launcher,
	userInterface ui.UserInterface,
	bootDescriptor descriptors.AppDescriptor) (err error) {

	settings := launcher.GetSettings()

	//----------------------------------------------------------------------------

	setupUserInterface(launcher, userInterface)
	defer dismissUserInterface(userInterface)

	//----------------------------------------------------------------------------

	userInterface.SetHeader("Performing startup operations")

	log.Debug("The boot descriptor is: %#v", bootDescriptor)

	//----------------------------------------------------------------------------

	userInterface.SetApp(bootDescriptor.GetName())

	//----------------------------------------------------------------------------

	appGallery := apps.NewAppGallery(settings.GetGalleryDirectory())
	log.Debug("The app gallery is: %#v", appGallery)

	//----------------------------------------------------------------------------

	log.Info("Resolving the app...")
	app, err := appGallery.GetApp(bootDescriptor)
	if err != nil {
		return err
	}
	log.Notice("The app directory is: '%v'", app.Directory)

	log.Debug("App is: %#v", app)

	firstRun := !app.DirectoryExists()
	log.Debug("Is this a first run for the app? %v", firstRun)

	//----------------------------------------------------------------------------

	if firstRun {
		log.Info("Now asking the user if the app can run...")

		canRun := app.CanPerformFirstRun(userInterface)
		if !canRun {
			return &ExecutionCanceled{}
		}

		log.Debug("The user agreed to proceed")

		log.Info("Ensuring the app dir is available...")
		err = app.EnsureDirectory()
		if err != nil {
			return err
		}
		log.Notice("App dir available")
	}

	//----------------------------------------------------------------------------

	log.Info("Locking the app dir...")
	err = app.LockDirectory()
	if err != nil {
		return err
	}
	defer func() {
		unlockErr := app.UnlockDirectory()
		if unlockErr != nil {
			log.Warning(unlockErr.Error())
		}
	}()

	log.Notice("App dir locked")

	//----------------------------------------------------------------------------

	log.Info("Checking for conflicting local descriptors...")
	err = app.CheckForConflictingLocalDescriptors()
	if err != nil {
		return err
	}
	log.Notice("No conflicting local descriptors found")

	//----------------------------------------------------------------------------

	log.Info("Resolving the local descriptor...")
	localDescriptor := app.GetLocalDescriptor()

	startedWithLocalDescriptor := localDescriptor != nil
	log.Debug("Started with local descriptor? %v", startedWithLocalDescriptor)

	if startedWithLocalDescriptor {
		log.Info("Checking that local descriptor and boot descriptor actually match...")
//.........这里部分代码省略.........
开发者ID:giancosta86,项目名称:moondeploy,代码行数:101,代码来源:run.go



注:本文中的github.com/giancosta86/moondeploy/v3/descriptors.AppDescriptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang launchers.Launcher类代码示例发布时间:2022-05-23
下一篇:
Golang store.IsNotFound函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap