Skip to content

Commit 1b0ab7f

Browse files
committed
fix: lint and update release flow
1 parent e2ee3ca commit 1b0ab7f

6 files changed

Lines changed: 78 additions & 75 deletions

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,12 @@ jobs:
4747
node-version: '24'
4848
registry-url: 'https://registry.npmjs.org'
4949

50+
- name: Extract version from tag
51+
id: version
52+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
53+
54+
- name: Update package.json version
55+
run: npm version ${{ steps.version.outputs.VERSION }} --no-git-tag-version
56+
5057
- name: Publish to npm
5158
run: npm publish

.goreleaser.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ changelog:
8787

8888

8989
release:
90-
draft: true
91-
replace_existing_draft: true
92-
target_commitish: '{{ .Commit }}'
9390
prerelease: auto
9491
mode: replace
9592
header: |

cmd/version.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,3 @@ var versionCmd = &cobra.Command{
2626
}
2727
},
2828
}
29-

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/betterdiscord/cli
22

3-
go 1.24.0
3+
go 1.26
44

55
require (
66
github.com/shirou/gopsutil/v3 v3.24.5

internal/wsl/wsl.go

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ var once sync.Once
1212
var info *WSLInfo
1313

1414
type WSLInfo struct {
15-
IsWSL bool // True if running under WSL1 or WSL2
16-
DistroName string // Value of WSL_DISTRO_NAME
17-
KernelVersion string // Contents of /proc/version
18-
InteropPath string // Value of WSL_INTEROP
19-
WindowsHome string // Windows home directory as a WSL path
15+
IsWSL bool // True if running under WSL1 or WSL2
16+
DistroName string // Value of WSL_DISTRO_NAME
17+
KernelVersion string // Contents of /proc/version
18+
InteropPath string // Value of WSL_INTEROP
19+
WindowsHome string // Windows home directory as a WSL path
2020
}
2121

2222
// loadWSLInfo detects WSL environment details and caches them in the info variable.
@@ -27,100 +27,100 @@ type WSLInfo struct {
2727
// This is called lazily by public helper functions to avoid unnecessary overhead
2828
// of init() in non-WSL environments.
2929
func loadWSLInfo() {
30-
once.Do(func() {
31-
i := &WSLInfo{}
30+
once.Do(func() {
31+
i := &WSLInfo{}
3232

33-
// Detect WSL via environment variable
34-
if dn := os.Getenv("WSL_DISTRO_NAME"); dn != "" {
35-
i.IsWSL = true
36-
i.DistroName = dn
37-
}
33+
// Detect WSL via environment variable
34+
if dn := os.Getenv("WSL_DISTRO_NAME"); dn != "" {
35+
i.IsWSL = true
36+
i.DistroName = dn
37+
}
3838

39-
// Kernel signature fallback
40-
if data, err := os.ReadFile("/proc/version"); err == nil {
41-
ver := strings.ToLower(string(data))
42-
i.KernelVersion = ver
39+
// Kernel signature fallback
40+
if data, err := os.ReadFile("/proc/version"); err == nil {
41+
ver := strings.ToLower(string(data))
42+
i.KernelVersion = ver
4343

4444
// Check for "microsoft" in kernel version to detect WSL if env var is missing
45-
if strings.Contains(ver, "microsoft") {
46-
i.IsWSL = true
47-
}
48-
}
49-
50-
// Interop path (could be useful someday)
51-
i.InteropPath = os.Getenv("WSL_INTEROP")
52-
53-
// Windows home directory (only if WSL)
54-
if i.IsWSL {
55-
home, err := getWindowsHomePath()
56-
if err == nil {
57-
i.WindowsHome = home
58-
}
59-
}
60-
61-
info = i
62-
})
45+
if strings.Contains(ver, "microsoft") {
46+
i.IsWSL = true
47+
}
48+
}
49+
50+
// Interop path (could be useful someday)
51+
i.InteropPath = os.Getenv("WSL_INTEROP")
52+
53+
// Windows home directory (only if WSL)
54+
if i.IsWSL {
55+
home, err := getWindowsHomePath()
56+
if err == nil {
57+
i.WindowsHome = home
58+
}
59+
}
60+
61+
info = i
62+
})
6363
}
6464

6565
// Info returns cached WSL environment information.
6666
func Info() *WSLInfo {
67-
loadWSLInfo()
68-
return info
67+
loadWSLInfo()
68+
return info
6969
}
7070

7171
// IsWSL returns true if running under WSL.
7272
func IsWSL() bool {
73-
loadWSLInfo()
74-
return info.IsWSL
73+
loadWSLInfo()
74+
return info.IsWSL
7575
}
7676

7777
// WindowsHome returns the Windows user's home directory as a WSL path.
7878
func WindowsHome() (string, error) {
79-
loadWSLInfo()
80-
if info.WindowsHome == "" {
81-
return "", fmt.Errorf("unable to determine Windows home directory")
82-
}
83-
return info.WindowsHome, nil
79+
loadWSLInfo()
80+
if info.WindowsHome == "" {
81+
return "", fmt.Errorf("unable to determine Windows home directory")
82+
}
83+
return info.WindowsHome, nil
8484
}
8585

8686
// ToWSLPath converts a Windows path (C:\Users\Me) → /mnt/c/Users/Me.
8787
func ToWSLPath(winPath string) (string, error) {
88-
out, err := exec.Command("wslpath", "-u", winPath).Output()
89-
if err != nil {
90-
return "", fmt.Errorf("wslpath failed: %w", err)
91-
}
92-
return strings.TrimSpace(string(out)), nil
88+
out, err := exec.Command("wslpath", "-u", winPath).Output()
89+
if err != nil {
90+
return "", fmt.Errorf("wslpath failed: %w", err)
91+
}
92+
return strings.TrimSpace(string(out)), nil
9393
}
9494

9595
// ToWindowsPath converts a WSL path (/mnt/c/Users/Me) → C:\Users\Me.
9696
func ToWindowsPath(wslPath string) (string, error) {
97-
out, err := exec.Command("wslpath", "-w", wslPath).Output()
98-
if err != nil {
99-
return "", fmt.Errorf("wslpath failed: %w", err)
100-
}
101-
return strings.TrimSpace(string(out)), nil
97+
out, err := exec.Command("wslpath", "-w", wslPath).Output()
98+
if err != nil {
99+
return "", fmt.Errorf("wslpath failed: %w", err)
100+
}
101+
return strings.TrimSpace(string(out)), nil
102102
}
103103

104104
// ExecWindows runs a Windows command and returns stdout.
105105
func ExecWindows(command string) (string, error) {
106106
// Use cmd.exe to run the command
107-
cmd := exec.Command("cmd.exe", "/c", command)
108-
out, err := cmd.Output()
109-
if err != nil {
110-
return "", fmt.Errorf("cmd.exe failed: %w", err)
111-
}
107+
cmd := exec.Command("cmd.exe", "/c", command)
108+
out, err := cmd.Output()
109+
if err != nil {
110+
return "", fmt.Errorf("cmd.exe failed: %w", err)
111+
}
112112

113113
// Clean CRLF from Windows output
114-
return strings.TrimSpace(strings.ReplaceAll(string(out), "\r", "")), nil
114+
return strings.TrimSpace(strings.ReplaceAll(string(out), "\r", "")), nil
115115
}
116116

117117
func getWindowsHomePath() (string, error) {
118-
// Use ExecWindows helper
119-
winPath, err := ExecWindows("echo %USERPROFILE%")
120-
if err != nil {
121-
return "", err
122-
}
123-
124-
// Convert to WSL path
125-
return ToWSLPath(winPath)
118+
// Use ExecWindows helper
119+
winPath, err := ExecWindows("echo %USERPROFILE%")
120+
if err != nil {
121+
return "", err
122+
}
123+
124+
// Convert to WSL path
125+
return ToWSLPath(winPath)
126126
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "@betterdiscord/cli",
3-
"version": "0.1.0",
3+
"version": "0.0.0",
44
"description": "A cross-platform CLI for managing BetterDiscord",
55
"main": "index.js",
6+
"keywords": ["discord", "betterdiscord", "cli", "tool", "installer"],
67
"publishConfig": {
78
"access": "public"
89
},
9-
"files": [],
1010
"scripts": {
1111
"postinstall": "go-npm install",
1212
"preuninstall": "go-npm uninstall"
@@ -27,6 +27,6 @@
2727
"goBinary": {
2828
"name": "bdcli",
2929
"path": "./bin",
30-
"url": "https://github.com/BetterDiscord/cli/releases/download/v{{version}}/bdcli_{{platform}}_{{arch}}{{archive_ext}}"
30+
"url": "https://github.com/BetterDiscord/cli/releases/download/v{{version}}/bdcli_{{version}}_{{platform}}_{{arch}}{{archive_ext}}"
3131
}
3232
}

0 commit comments

Comments
 (0)