UninstallFromApp removes the entity's installation for app and reports whether anything was removed.
(entityName string, kind Kind, app string)
| 464 | // UninstallFromApp removes the entity's installation for app and reports |
| 465 | // whether anything was removed. |
| 466 | func UninstallFromApp(entityName string, kind Kind, app string) (string, bool, error) { |
| 467 | apps := AppPathsFor(kind) |
| 468 | dest, ok := apps[app] |
| 469 | if !ok { |
| 470 | return "", false, fmt.Errorf("entities: app %s does not support %s", app, kind) |
| 471 | } |
| 472 | resolved := pathutil.Expand(dest) |
| 473 | switch kind { |
| 474 | case KindPrompt, KindInstruction: |
| 475 | if !pathutil.Exists(resolved) { |
| 476 | return resolved, false, nil |
| 477 | } |
| 478 | // Prompts/instructions are app-wide files; removing the file is opt-in only when |
| 479 | // the file matches the entity's content marker. We don't truncate |
| 480 | // arbitrary user data — instead report "found" if the file exists. |
| 481 | return resolved, false, nil |
| 482 | default: |
| 483 | dir := filepath.Join(resolved, entityName) |
| 484 | if !pathutil.Exists(dir) { |
| 485 | return dir, false, nil |
| 486 | } |
| 487 | if err := os.RemoveAll(dir); err != nil { |
| 488 | return dir, false, err |
| 489 | } |
| 490 | return dir, true, nil |
| 491 | } |
| 492 | } |
| 493 | |
| 494 | func writeFile(path string, data []byte, mode os.FileMode) error { |
| 495 | if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { |