mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-14 05:14:57 +01:00
add initial git support
This commit is contained in:
73
internal/assets/diff/themes/dark.json
Normal file
73
internal/assets/diff/themes/dark.json
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"SYNTAX_HIGHLIGHTING_THEME": "dark-plus",
|
||||
"DEFAULT_COLOR": {
|
||||
"color": "#ffffff",
|
||||
"backgroundColor": "#212121"
|
||||
},
|
||||
"COMMIT_HEADER_COLOR": {
|
||||
"color": "#cccccc"
|
||||
},
|
||||
"COMMIT_HEADER_LABEL_COLOR": {
|
||||
"color": "#00000022"
|
||||
},
|
||||
"COMMIT_SHA_COLOR": {
|
||||
"color": "#00eeaa"
|
||||
},
|
||||
"COMMIT_AUTHOR_COLOR": {
|
||||
"color": "#00aaee"
|
||||
},
|
||||
"COMMIT_DATE_COLOR": {
|
||||
"color": "#cccccc"
|
||||
},
|
||||
"COMMIT_MESSAGE_COLOR": {
|
||||
"color": "#cccccc"
|
||||
},
|
||||
"COMMIT_TITLE_COLOR": {
|
||||
"modifiers": [
|
||||
"bold"
|
||||
]
|
||||
},
|
||||
"FILE_NAME_COLOR": {
|
||||
"color": "#ffdd99"
|
||||
},
|
||||
"BORDER_COLOR": {
|
||||
"color": "#ffdd9966",
|
||||
"modifiers": [
|
||||
"dim"
|
||||
]
|
||||
},
|
||||
"HUNK_HEADER_COLOR": {
|
||||
"modifiers": [
|
||||
"dim"
|
||||
]
|
||||
},
|
||||
"DELETED_WORD_COLOR": {
|
||||
"color": "#ffcccc",
|
||||
"backgroundColor": "#ff000033"
|
||||
},
|
||||
"INSERTED_WORD_COLOR": {
|
||||
"color": "#ccffcc",
|
||||
"backgroundColor": "#00ff0033"
|
||||
},
|
||||
"DELETED_LINE_NO_COLOR": {
|
||||
"color": "#00000022",
|
||||
"backgroundColor": "#00000022"
|
||||
},
|
||||
"INSERTED_LINE_NO_COLOR": {
|
||||
"color": "#00000022",
|
||||
"backgroundColor": "#00000022"
|
||||
},
|
||||
"UNMODIFIED_LINE_NO_COLOR": {
|
||||
"color": "#666666"
|
||||
},
|
||||
"DELETED_LINE_COLOR": {
|
||||
"color": "#cc6666",
|
||||
"backgroundColor": "#3a3030"
|
||||
},
|
||||
"INSERTED_LINE_COLOR": {
|
||||
"color": "#66cc66",
|
||||
"backgroundColor": "#303a30"
|
||||
},
|
||||
"UNMODIFIED_LINE_COLOR": {},
|
||||
"MISSING_LINE_COLOR": {}
|
||||
}
|
||||
6
internal/assets/embed.go
Normal file
6
internal/assets/embed.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package assets
|
||||
|
||||
import "embed"
|
||||
|
||||
//go:embed diff
|
||||
var FS embed.FS
|
||||
60
internal/assets/write.go
Normal file
60
internal/assets/write.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package assets
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/kujtimiihoxha/termai/internal/config"
|
||||
)
|
||||
|
||||
func WriteAssets() error {
|
||||
appCfg := config.Get()
|
||||
appWd := config.WorkingDirectory()
|
||||
scriptDir := filepath.Join(
|
||||
appWd,
|
||||
appCfg.Data.Directory,
|
||||
"diff",
|
||||
)
|
||||
scriptPath := filepath.Join(scriptDir, "index.mjs")
|
||||
// Before, run the script in cmd/diff/main.go to build this file
|
||||
if _, err := os.Stat(scriptPath); err != nil {
|
||||
scriptData, err := FS.ReadFile("diff/index.mjs")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = os.MkdirAll(scriptDir, 0o755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.WriteFile(scriptPath, scriptData, 0o755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
themeDir := filepath.Join(
|
||||
appWd,
|
||||
appCfg.Data.Directory,
|
||||
"themes",
|
||||
)
|
||||
|
||||
themePath := filepath.Join(themeDir, "dark.json")
|
||||
|
||||
if _, err := os.Stat(themePath); err != nil {
|
||||
themeData, err := FS.ReadFile("diff/themes/dark.json")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = os.MkdirAll(themeDir, 0o755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.WriteFile(themePath, themeData, 0o755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user