Skip to content

Commit b1ace85

Browse files
committed
fix: use direct git clone instead of node desktop.js add
The previous approach ran 'node desktop.js add <pkg> --from <url>' which internally called 'pnpm add @owdproject/pkg@workspace:*' inside desktop/. This caused pnpm to print 'Preparing...' and block the progress bar. Since bridge.WriteChanges already writes both package.json and desktop.config.ts before RunSetupTask is called, we only need to git clone the repo into the correct directory (apps/, packages/, themes/). New flow per package: - npm: skip clone, pnpm install will handle it - local: skip, folder already present - git-https / git-ssh: git clone directly into apps|packages|themes/<shortName> (inferred from catalog entry kind or shortname prefix) Skip if package.json already exists in target (already cloned) Then: pnpm install + prepare:modules as before.
1 parent 81145d9 commit b1ace85

1 file changed

Lines changed: 70 additions & 29 deletions

File tree

go/tui/tasks.go

Lines changed: 70 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -105,57 +105,98 @@ func (m *TuiModel) RunSetupTask(adds map[string]string) {
105105
}
106106

107107
go func() {
108-
desktopJs := filepath.Join(workspaceRoot, "packages", "cli", "bin", "desktop.js")
109-
110108
totalSteps := len(adds) + 2
111109
step := 0
112-
msgChan <- setupProgressMsg{Step: step, Total: totalSteps, Label: "Initializing setup task…"}
110+
msgChan <- setupProgressMsg{Step: step, Total: totalSteps, Label: "Initializing…"}
113111

114-
// 1. Process all additions
112+
// 1. Clone each package via git directly (bridge.WriteChanges already updated
113+
// package.json and desktop.config.ts, so we just need the git clone)
115114
for pkgName, method := range adds {
116115
step++
117116
shortName := pkgName
118117
if idx := strings.LastIndex(pkgName, "/"); idx >= 0 {
119118
shortName = pkgName[idx+1:]
120119
}
121-
msgChan <- setupProgressMsg{Step: step, Total: totalSteps, Label: fmt.Sprintf("Installing %s via %s…", shortName, method)}
122120

123-
args := []string{desktopJs, "add", shortName}
121+
msgChan <- setupProgressMsg{Step: step, Total: totalSteps, Label: fmt.Sprintf("Cloning %s…", shortName)}
122+
124123
if method == "npm" {
125-
args = append(args, "--npm")
126-
} else if method == "local" {
127-
args = append(args, "--dev")
128-
} else {
129-
owner := "owdproject"
130-
if githubUser != "" {
131-
owner = githubUser
132-
} else {
133-
for _, e := range catalogEntries {
134-
if e.Name == pkgName && e.Org != "" {
135-
owner = e.Org
136-
break
137-
}
124+
// npm install: will be handled by pnpm install below; nothing to clone
125+
msgChan <- logLineMsg(fmt.Sprintf(">>> %s will be installed via npm (pnpm install)", shortName))
126+
continue
127+
}
128+
129+
if method == "local" {
130+
// local workspace folder already present; nothing to clone
131+
msgChan <- logLineMsg(fmt.Sprintf(">>> %s already available as local workspace package", shortName))
132+
continue
133+
}
134+
135+
// Determine target directory based on package kind
136+
kindDir := ""
137+
for _, e := range catalogEntries {
138+
if e.Name == pkgName {
139+
switch e.Kind {
140+
case "app":
141+
kindDir = "apps"
142+
case "module":
143+
kindDir = "packages"
144+
case "theme":
145+
kindDir = "themes"
138146
}
147+
break
148+
}
149+
}
150+
if kindDir == "" {
151+
// Infer from shortname prefix
152+
switch {
153+
case strings.HasPrefix(shortName, "app-"):
154+
kindDir = "apps"
155+
case strings.HasPrefix(shortName, "theme-"):
156+
kindDir = "themes"
157+
default:
158+
kindDir = "packages"
139159
}
160+
}
140161

141-
var fromVal string
142-
if method == "git-ssh" {
143-
fromVal = fmt.Sprintf("git@github.com:%s/%s.git", owner, shortName)
144-
} else {
145-
fromVal = fmt.Sprintf("https://github.com/%s/%s.git", owner, shortName)
162+
targetDir := filepath.Join(workspaceRoot, kindDir, shortName)
163+
164+
// Skip if already cloned
165+
if _, err := os.Stat(filepath.Join(targetDir, "package.json")); err == nil {
166+
msgChan <- logLineMsg(fmt.Sprintf(">>> %s already cloned — skipping", shortName))
167+
continue
168+
}
169+
170+
// Resolve git URL
171+
owner := "owdproject"
172+
if githubUser != "" {
173+
owner = githubUser
174+
} else {
175+
for _, e := range catalogEntries {
176+
if e.Name == pkgName && e.Org != "" {
177+
owner = e.Org
178+
break
179+
}
146180
}
147-
args = append(args, "--from", fromVal)
148181
}
149182

150-
msgChan <- logLineMsg(fmt.Sprintf(">>> Executing: node desktop.js add %s via %s", shortName, method))
151-
if err := runtime.runProcessAndStreamLogsSilent(workspaceRoot, "node", args); err != nil {
152-
msgChan <- logLineMsg(fmt.Sprintf(">>> Add %s failed: %v", shortName, err))
183+
var gitURL string
184+
if method == "git-ssh" {
185+
gitURL = fmt.Sprintf("git@github.com:%s/%s.git", owner, shortName)
186+
} else {
187+
gitURL = fmt.Sprintf("https://github.com/%s/%s.git", owner, shortName)
188+
}
189+
190+
msgChan <- logLineMsg(fmt.Sprintf(">>> Cloning %s from %s", shortName, gitURL))
191+
if err := runtime.runProcessAndStreamLogsSilent(workspaceRoot, "git", []string{"clone", gitURL, targetDir}); err != nil {
192+
msgChan <- logLineMsg(fmt.Sprintf(">>> Clone failed for %s: %v", shortName, err))
153193
msgChan <- taskFinishedMsg{Success: false, Err: err}
154194
return
155195
}
196+
msgChan <- logLineMsg(fmt.Sprintf(">>> ✓ %s cloned successfully", shortName))
156197
}
157198

158-
// 2. Run pnpm install for cleanup/removal sync
199+
// 2. Sync workspace with pnpm install
159200
step++
160201
msgChan <- setupProgressMsg{Step: step, Total: totalSteps, Label: "Installing dependencies (pnpm install)…"}
161202
msgChan <- logLineMsg(">>> Running pnpm install (syncing workspace)…")

0 commit comments

Comments
 (0)