repos / pico

pico services mono repo
git clone https://github.com/picosh/pico.git

commit
8e4e5f5
parent
310e14b
author
Eric Bower
date
2025-01-19 13:08:22 -0500 EST
chore(pgs): prevent deleting `prose` project
1 files changed,  +11, -3
M pgs/cli.go
+11, -3
 1@@ -17,7 +17,7 @@ import (
 2 	"github.com/picosh/utils"
 3 )
 4 
 5-func projectTable(styles common.Styles, projects []*db.Project, width int) *table.Table {
 6+func projectTable(projects []*db.Project, width int) *table.Table {
 7 	headers := []string{
 8 		"Name",
 9 		"Last Updated",
10@@ -257,7 +257,7 @@ func (c *Cmd) ls() error {
11 		c.output("no projects found")
12 	}
13 
14-	t := projectTable(c.Styles, projects, c.Width)
15+	t := projectTable(projects, c.Width)
16 	c.output(t.String())
17 
18 	return nil
19@@ -374,7 +374,7 @@ func (c *Cmd) depends(projectName string) error {
20 		return nil
21 	}
22 
23-	t := projectTable(c.Styles, projects, c.Width)
24+	t := projectTable(projects, c.Width)
25 	c.output(t.String())
26 
27 	return nil
28@@ -386,6 +386,10 @@ func (c *Cmd) prune(prefix string, keepNumLatest int) error {
29 	c.Log.Info("user running `clean` command", "user", c.User.Name, "prefix", prefix)
30 	c.output(fmt.Sprintf("searching for projects that match prefix (%s) and are not linked to other projects", prefix))
31 
32+	if prefix == "prose" {
33+		return fmt.Errorf("cannot delete `prose` because it is used by prose.sh and is protected")
34+	}
35+
36 	if prefix == "" || prefix == "*" {
37 		e := fmt.Errorf("must provide valid prefix")
38 		return e
39@@ -462,6 +466,10 @@ func (c *Cmd) prune(prefix string, keepNumLatest int) error {
40 
41 func (c *Cmd) rm(projectName string) error {
42 	c.Log.Info("user running `rm` command", "user", c.User.Name, "project", projectName)
43+	if projectName == "prose" {
44+		return fmt.Errorf("cannot delete `prose` because it is used by prose.sh and is protected")
45+	}
46+
47 	project, err := c.Dbpool.FindProjectByName(c.User.ID, projectName)
48 	if err == nil {
49 		c.Log.Info("found project, checking dependencies", "project", projectName, "projectID", project.ID)