1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-28 07:22:50 -05:00

feat/matugen3 (#771)

* added matugen 3 terminal templates and logic

fixed version check and light terminal check

refactored json generation

fixed syntax

keep tmp debug

fixed file outputs

fixed syntax issues and implicit passing

added debug stderr output

* moved calls to matugen after template is built correctly

added --json hex

disabled debug message

cleaned up code into modular functions, re-added second full matugen call

fixed args

added shift

commented vs code section

debug changes

* arg format fixes

fixed json import flag

fixed string quotation

fix arg order

* cleaned up

fix cfg naming

* removed mt2.0 templates and refactored worker

removed/replaced matugen 2 templates

fix formatter diffs + consistent styling

* fixed last json output

* fixed syntax error

* vs code templates

* matugen: inject all stock/custom theme colors as overrides
- also some general architectural changes

* dank16: remove vscode enrich option

---------

Co-authored-by: bbedward
This commit is contained in:
Saurabh
2025-11-27 08:34:53 +11:00
committed by GitHub
parent 85704e3947
commit de8f2e6a68
19 changed files with 1187 additions and 929 deletions

View File

@@ -18,28 +18,27 @@ type VersionInfo struct {
HasUpdate bool
}
func GetCurrentDMSVersion() (string, error) {
homeDir, err := os.UserHomeDir()
if err != nil {
return "", fmt.Errorf("failed to get home directory: %w", err)
}
// VersionFetcher is an interface for fetching version information
type VersionFetcher interface {
GetCurrentVersion(dmsPath string) (string, error)
GetLatestVersion(dmsPath string) (string, error)
}
dmsPath := filepath.Join(homeDir, ".config", "quickshell", "dms")
if _, err := os.Stat(dmsPath); os.IsNotExist(err) {
return "", fmt.Errorf("DMS not installed")
}
originalDir, err := os.Getwd()
if err != nil {
return "", err
}
defer os.Chdir(originalDir)
if err := os.Chdir(dmsPath); err != nil {
return "", fmt.Errorf("failed to change to DMS directory: %w", err)
}
// DefaultVersionFetcher is the default implementation that uses git/curl
type DefaultVersionFetcher struct{}
func (d *DefaultVersionFetcher) GetCurrentVersion(dmsPath string) (string, error) {
if _, err := os.Stat(filepath.Join(dmsPath, ".git")); err == nil {
originalDir, err := os.Getwd()
if err != nil {
return "", err
}
defer os.Chdir(originalDir)
if err := os.Chdir(dmsPath); err != nil {
return "", fmt.Errorf("failed to change to DMS directory: %w", err)
}
tagCmd := exec.Command("git", "describe", "--exact-match", "--tags", "HEAD")
if tagOutput, err := tagCmd.Output(); err == nil {
return strings.TrimSpace(string(tagOutput)), nil
@@ -65,21 +64,14 @@ func GetCurrentDMSVersion() (string, error) {
return "unknown", nil
}
func GetLatestDMSVersion() (string, error) {
homeDir, err := os.UserHomeDir()
if err != nil {
return "", fmt.Errorf("failed to get home directory: %w", err)
}
dmsPath := filepath.Join(homeDir, ".config", "quickshell", "dms")
originalDir, err := os.Getwd()
if err != nil {
return "", err
}
defer os.Chdir(originalDir)
func (d *DefaultVersionFetcher) GetLatestVersion(dmsPath string) (string, error) {
if _, err := os.Stat(filepath.Join(dmsPath, ".git")); err == nil {
originalDir, err := os.Getwd()
if err != nil {
return "", err
}
defer os.Chdir(originalDir)
if err := os.Chdir(dmsPath); err != nil {
return "", fmt.Errorf("failed to change to DMS directory: %w", err)
}
@@ -154,13 +146,54 @@ func GetLatestDMSVersion() (string, error) {
return result.TagName, nil
}
// defaultFetcher is used by the public functions
var defaultFetcher VersionFetcher = &DefaultVersionFetcher{}
func GetCurrentDMSVersion() (string, error) {
homeDir, err := os.UserHomeDir()
if err != nil {
return "", fmt.Errorf("failed to get home directory: %w", err)
}
dmsPath := filepath.Join(homeDir, ".config", "quickshell", "dms")
if _, err := os.Stat(dmsPath); os.IsNotExist(err) {
return "", fmt.Errorf("DMS not installed")
}
return defaultFetcher.GetCurrentVersion(dmsPath)
}
func GetLatestDMSVersion() (string, error) {
homeDir, err := os.UserHomeDir()
if err != nil {
return "", fmt.Errorf("failed to get home directory: %w", err)
}
dmsPath := filepath.Join(homeDir, ".config", "quickshell", "dms")
return defaultFetcher.GetLatestVersion(dmsPath)
}
func GetDMSVersionInfo() (*VersionInfo, error) {
current, err := GetCurrentDMSVersion()
return GetDMSVersionInfoWithFetcher(defaultFetcher)
}
func GetDMSVersionInfoWithFetcher(fetcher VersionFetcher) (*VersionInfo, error) {
homeDir, err := os.UserHomeDir()
if err != nil {
return nil, fmt.Errorf("failed to get home directory: %w", err)
}
dmsPath := filepath.Join(homeDir, ".config", "quickshell", "dms")
if _, err := os.Stat(dmsPath); os.IsNotExist(err) {
return nil, fmt.Errorf("DMS not installed")
}
current, err := fetcher.GetCurrentVersion(dmsPath)
if err != nil {
return nil, err
}
latest, err := GetLatestDMSVersion()
latest, err := fetcher.GetLatestVersion(dmsPath)
if err != nil {
return nil, fmt.Errorf("failed to get latest version: %w", err)
}