Skip to content

Commit 381e839

Browse files
authored
Merge pull request #24 from iskandervdh/project-view-layout
Project view layout
2 parents 1c7c1be + c10123d commit 381e839

20 files changed

Lines changed: 2134 additions & 1130 deletions

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,56 +14,60 @@ Quickly spin up your multi command projects.
1414
### Debian based systems
1515

1616
To install the required packages on a debian based system you can use the following command:
17+
1718
```bash
1819
sudo apt install libgtk-3-0 libwebkit2gtk-4.0-dev nginx dnsmasq
1920
```
2021

21-
> **Note**
22-
>
22+
> [!NOTE]
2323
> For Ubuntu 24.04 and up, you should install `libwebkit2gtk-4.1-dev` instead of `libwebkit2gtk-4.0-dev`.
2424
2525
Download the `.deb` package from the releases. There is a separate version for Ubuntu 24.04 due to the different `libwebkit2gtk` package version being used.
2626

2727
To install the package run the following command where `{{version}}` is the version of the package:
28+
2829
```bash
2930
sudo dpkg -i spinup-{{version}}.deb
3031
```
3132

3233
### RPM based systems
3334

34-
> **Warning**
35-
>
35+
> [!WARNING]
3636
> This has not been tested
3737
3838
To install the required packages on a rpm based system you can use the following command:
39+
3940
```bash
4041
sudo dnf install nginx dnsmasq
4142
```
4243

4344
Download the `.rpm` package from the releases.
4445

4546
To install the package run the following command where `{{version}}` is the version of the package:
47+
4648
```bash
4749
sudo rpm -i spinup-{{version}}.rpm
4850
```
4951

5052
### MacOS
5153

52-
> **Warning**
53-
>
54+
> [!WARNING]
5455
> This has not been tested
5556
5657
Install the required packages:
58+
5759
```bash
5860
brew install nginx dnsmasq
5961
```
6062

6163
Download the `spinup-{{version}}-macos.zip` archive from the releases and unzip the archive:
64+
6265
```bash
6366
unzip spinup-{{version}}-macos.zip
6467
```
6568

6669
Run the installation script:
70+
6771
```bash
6872
sudo ./spinup-{{version}}-macos/install.sh
6973
```

app/settings.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package app
2+
3+
func (a *App) GetSettings() (map[string]interface{}, error) {
4+
return a.core.GetConfig().GetSettings()
5+
}
6+
7+
func (a *App) GetSetting(settingKey string) (interface{}, error) {
8+
return a.core.GetConfig().GetSetting(settingKey)
9+
}
10+
11+
func (a *App) SetSetting(settingKey string, value interface{}) error {
12+
return a.core.GetConfig().SetSetting(settingKey, value)
13+
}

config/settings.go

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package config
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
"os"
7+
"path"
8+
)
9+
10+
const settingsFileName = "settings.json"
11+
12+
func (c *Config) writeSettings(settings map[string]interface{}) error {
13+
settingFilePath := path.Join(c.configDir, settingsFileName)
14+
15+
data, err := json.MarshalIndent(settings, "", " ")
16+
17+
if err != nil {
18+
return fmt.Errorf("could not marshal settings: %w", err)
19+
}
20+
21+
err = os.WriteFile(settingFilePath, data, 0644)
22+
23+
if err != nil {
24+
return fmt.Errorf("could not write settings file: %w", err)
25+
}
26+
27+
return nil
28+
}
29+
30+
func (c *Config) GetSettings() (map[string]interface{}, error) {
31+
settingFilePath := path.Join(c.configDir, settingsFileName)
32+
settings := make(map[string]interface{})
33+
34+
data, err := os.ReadFile(settingFilePath)
35+
36+
if os.IsNotExist(err) {
37+
// If the settings file does not exist we should create it.
38+
err = c.writeSettings(settings)
39+
40+
if err != nil {
41+
return nil, fmt.Errorf("could not create settings file: %w", err)
42+
}
43+
44+
// Initialize settings data with an empty JSON object
45+
data = []byte("{}")
46+
}
47+
48+
if err != nil {
49+
return nil, fmt.Errorf("could not read settings file: %w", err)
50+
}
51+
52+
err = json.Unmarshal(data, &settings)
53+
54+
if err != nil {
55+
return nil, fmt.Errorf("could not unmarshal settings: %w", err)
56+
}
57+
58+
return settings, nil
59+
}
60+
61+
func (c *Config) GetSetting(settingKey string) (interface{}, error) {
62+
settings, err := c.GetSettings()
63+
if err != nil {
64+
return nil, fmt.Errorf("could not read settings: %w", err)
65+
}
66+
67+
value, exists := settings[settingKey]
68+
if !exists {
69+
return nil, fmt.Errorf("setting %s does not exist", settingKey)
70+
}
71+
72+
return value, nil
73+
}
74+
75+
func (c *Config) SetSetting(settingKey string, value interface{}) error {
76+
settings, err := c.GetSettings()
77+
78+
if err != nil {
79+
return fmt.Errorf("could not read settings: %w", err)
80+
}
81+
82+
settings[settingKey] = value
83+
err = c.writeSettings(settings)
84+
85+
if err != nil {
86+
return fmt.Errorf("could not write settings: %w", err)
87+
}
88+
return nil
89+
}

frontend/.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://json.schemastore.org/prettierrc",
3+
"singleQuote": true,
4+
"printWidth": 120,
5+
"trailingComma": "es5"
6+
}

frontend/package.json

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,35 @@
66
"scripts": {
77
"dev": "vite",
88
"build": "tsc && vite build",
9-
"preview": "vite preview"
9+
"preview": "vite preview",
10+
"format": "prettier --write ."
1011
},
1112
"dependencies": {
1213
"@heroicons/react": "^2.2.0",
13-
"@radix-ui/react-slot": "^1.1.1",
14-
"@tanstack/react-router": "^1.95.3",
14+
"@radix-ui/react-slot": "^1.2.3",
15+
"@tanstack/react-router": "^1.129.8",
1516
"ansi-to-html": "^0.7.2",
1617
"class-variance-authority": "^0.7.1",
1718
"clsx": "^2.1.1",
18-
"react": "^19.0.0",
19-
"react-dom": "^19.0.0",
20-
"react-hot-toast": "^2.5.1",
19+
"react": "^19.1.0",
20+
"react-dom": "^19.1.0",
21+
"react-hot-toast": "^2.5.2",
2122
"tailwind-merge": "^2.6.0",
22-
"zustand": "^5.0.3"
23+
"zustand": "^5.0.6"
2324
},
2425
"devDependencies": {
25-
"@tanstack/router-devtools": "^1.95.3",
26-
"@tanstack/router-plugin": "^1.95.3",
27-
"@types/node": "^22.10.10",
28-
"@types/react": "^19.0.4",
29-
"@types/react-dom": "^19.0.2",
30-
"@vitejs/plugin-react": "^4.3.4",
31-
"autoprefixer": "^10.4.20",
32-
"postcss": "^8.4.49",
26+
"@tanstack/router-devtools": "^1.129.8",
27+
"@tanstack/router-plugin": "^1.129.8",
28+
"@types/node": "^24.1.0",
29+
"@types/react": "^19.1.8",
30+
"@types/react-dom": "^19.1.6",
31+
"@vitejs/plugin-react": "^4.7.0",
32+
"autoprefixer": "^10.4.21",
33+
"postcss": "^8.5.6",
34+
"prettier": "^3.6.2",
3335
"tailwindcss": "^3.4.17",
34-
"typescript": "^5.3.0",
35-
"vite": "^6.0.7"
36+
"typescript": "^5.8.3",
37+
"vite": "^7.0.6"
3638
},
37-
"packageManager": "pnpm@9.15.3"
39+
"packageManager": "pnpm@10.13.1"
3840
}

frontend/package.json.md5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
621b27dc8aeeef054fb3a519be6af474
1+
e3c57baa7302a52609ea4be5cb3ac460

0 commit comments

Comments
 (0)