install

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Copyright 2025 PRAS

Index

Constants

This section is empty.

Variables

View Source
var InstallCmd = &cobra.Command{
	Use:   "install",
	Short: "Install plasmoid system-wide",
	Long:  "Install the plasmoid to the system directories for production use.",
	Run: func(cmd *cobra.Command, args []string) {
		if !utilsIsValidPlasmoid() {
			color.Red("Current directory is not a valid plasmoid.")
			return
		}
		if err := InstallPlasmoid(); err != nil {
			color.Red("Failed to install plasmoid:", err)
			return
		}

		dest, _ := utilsGetDevDest()
		color.Green("Plasmoid installed successfully in %s", color.BlueString(dest))
		color.Cyan("\n- Please restart plasmashell to apply changes.")
	},
}

InstallCmd represents the production command

View Source
var InstallPlasmoid = func() error {
	isInstalled, where, err := utilsIsInstalled()
	if err != nil {
		return err
	}
	if isInstalled {
		if err := osRemoveAll(where); err != nil {
			fmt.Printf("Warning: Failed to remove existing installation at %s: %v\n", where, err)
		}
	}

	if err := osMkdirAll(where, 0755); err != nil {
		return fmt.Errorf("failed to create installation directory %s: %w", where, err)
	}

	srcMeta := "metadata.json"
	destMeta := filepath.Join(where, "metadata.json")
	metaData, err := osReadFile(srcMeta)
	if err != nil {
		return fmt.Errorf("failed to read metadata.json: %v", err)
	}
	err = osWriteFile(destMeta, metaData, 0644)
	if err != nil {
		return fmt.Errorf("failed to write metadata.json: %v", err)
	}

	srcContents := "contents"
	destContents := filepath.Join(where, "contents")
	err = copyDir(srcContents, destContents)
	if err != nil {
		return fmt.Errorf("failed to copy contents directory: %v", err)
	}
	return nil
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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