fix: MacOS MDM based Deployment (#277)

* fix: MacOS MDM deployment script

* fix: Handle shell alias for bash on macos

* fix: Code review fixes

* fix: Code review fixes

* feat: Add support for global config file

* feat: Add support for global config file

* fix: Code review fixes

* fix: Avoid blocking CLI for analytics flush
This commit is contained in:
Abhisek Datta
2026-05-21 14:32:30 +05:30
committed by GitHub
parent 875cda2e43
commit b15ce33fe4
24 changed files with 1396 additions and 374 deletions
+10 -7
View File
@@ -2,7 +2,6 @@ package setup
import (
"fmt"
"os"
"runtime"
"github.com/safedep/pmg/config"
@@ -13,9 +12,7 @@ import (
"github.com/spf13/cobra"
)
var (
setupRemoveConfigFile = false
)
var setupRemoveConfigFile = false
func NewSetupCommand() *cobra.Command {
setupCmd := &cobra.Command{
@@ -51,6 +48,11 @@ func install() error {
return fmt.Errorf("failed to write template config: %w", err)
}
if config.Get().IsManaged() {
fmt.Printf("%s %s\n", ui.Colors.Dim(""),
fmt.Sprintf("Using globally managed config: %s", config.Get().ConfigFilePath()))
}
if runtime.GOOS == "windows" {
fmt.Printf("%s %s\n", ui.Colors.Green("✓"), "PMG config written successfully")
fmt.Printf(" %s\n", ui.Colors.Dim(fmt.Sprintf("Config: %s", config.Get().ConfigDir())))
@@ -92,9 +94,10 @@ func NewRemoveCommand() *cobra.Command {
fmt.Print(ui.GeneratePMGBanner(version.Version, version.Commit))
if setupRemoveConfigFile {
config := config.Get()
if err := os.Remove(config.ConfigFilePath()); err != nil && !os.IsNotExist(err) {
return fmt.Errorf("failed to remove config file %q: %w", config.ConfigFilePath(), err)
// Only ever remove the per-user file; the globally managed
// config is not ours to delete from a per-user uninstall.
if err := config.RemoveUserConfigFile(); err != nil {
return err
}
}