Skip to content

Commit 3ff9665

Browse files
author
imranp
committed
.
1 parent dd6415a commit 3ff9665

4 files changed

Lines changed: 481 additions & 1003 deletions

File tree

backend/cmd/wede/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func main() {
8080

8181
addr := ":" + cfg.Port
8282
log.Printf("wede IDE running on http://localhost%s", addr)
83+
log.Printf("password: %s", cfg.Password)
8384
if ws.HasWorkspace() {
8485
log.Printf("workspace: %s", ws.Current())
8586
} else {

backend/internal/config/config.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,18 @@ func Load() *Config {
3636
}
3737
}
3838

39-
// 2. Next to executable
39+
// 2. ~/.config/wede/
40+
if data == nil {
41+
if home, err := os.UserHomeDir(); err == nil {
42+
p := filepath.Join(home, ".config", "wede", configName)
43+
if d, err := os.ReadFile(p); err == nil {
44+
data = d
45+
found = p
46+
}
47+
}
48+
}
49+
50+
// 3. Next to executable
4051
if data == nil {
4152
if exe, err := os.Executable(); err == nil {
4253
p := filepath.Join(filepath.Dir(exe), configName)
@@ -48,7 +59,7 @@ func Load() *Config {
4859
}
4960

5061
if data == nil {
51-
log.Fatal("wede.config.json not found (searched cwd, parent dirs, and next to executable)")
62+
log.Fatal("wede.config.json not found (searched cwd, parent dirs, ~/.config/wede/, and next to executable)")
5263
}
5364

5465
log.Printf("loaded config from %s", found)

install.sh

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,24 @@ BINARY="wede"
66
echo "Installing wede..."
77
echo ""
88

9+
# Check dependencies
10+
if ! command -v curl &> /dev/null; then
11+
echo "Error: curl is required but not installed."
12+
echo " Install it with your package manager:"
13+
echo " Ubuntu/Debian: sudo apt install curl"
14+
echo " macOS: brew install curl"
15+
echo " Fedora: sudo dnf install curl"
16+
exit 1
17+
fi
18+
919
# Detect OS and set install directory
1020
OS="$(uname -s)"
1121
case "$OS" in
1222
Linux*)
1323
OS="linux"
1424
INSTALL_DIR="${HOME}/.local/bin"
1525
;;
26+
1627
Darwin*)
1728
OS="darwin"
1829
INSTALL_DIR="${HOME}/.local/bin"
@@ -91,19 +102,33 @@ if ! echo "$PATH" | tr ':' '\n' | grep -q "^${INSTALL_DIR}$"; then
91102
esac
92103
fi
93104

94-
# Create default config if none exists
95-
CONFIG_FILE="wede.config.json"
96-
if [ ! -f "$CONFIG_FILE" ]; then
97-
DEFAULT_PASSWORD=$(LC_ALL=C tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 16 || true)
105+
# Create default config
106+
CONFIG_DIR="${HOME}/.config/wede"
107+
CONFIG_FILE="${CONFIG_DIR}/wede.config.json"
108+
mkdir -p "$CONFIG_DIR"
109+
110+
DEFAULT_PASSWORD=$(LC_ALL=C tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 16 || true)
111+
112+
if [ -f "$CONFIG_FILE" ]; then
113+
echo ""
114+
echo " Config already exists at ${CONFIG_FILE}"
115+
echo " Skipping config creation."
116+
else
98117
cat > "$CONFIG_FILE" <<CONF
99118
{
100119
"password": "${DEFAULT_PASSWORD}",
101120
"port": "9090"
102121
}
103122
CONF
104123
echo ""
105-
echo " Created ${CONFIG_FILE} with a random password."
106-
echo " Password: ${DEFAULT_PASSWORD}"
124+
echo " Config created at: ${CONFIG_FILE}"
125+
echo ""
126+
echo " ┌─────────────────────────────────────────────┐"
127+
echo " │ Admin password: ${DEFAULT_PASSWORD}"
128+
echo " │ Port: 9090 │"
129+
echo " │ │"
130+
echo " │ To change, edit: ${CONFIG_FILE}"
131+
echo " └─────────────────────────────────────────────┘"
107132
fi
108133

109134
echo ""

0 commit comments

Comments
 (0)