github.com/LGUG2Z/story@v0.4.1/cli/pin.go (about) 1 package cli 2 3 import ( 4 "github.com/LGUG2Z/story/manifest" 5 "github.com/LGUG2Z/story/node" 6 "github.com/spf13/afero" 7 "github.com/urfave/cli" 8 ) 9 10 func PinCmd(fs afero.Fs) cli.Command { 11 return cli.Command{ 12 Name: "pin", 13 Usage: "Pins code in the current story", 14 Action: cli.ActionFunc(func(c *cli.Context) error { 15 if !isStory { 16 return ErrNotWorkingOnAStory 17 } 18 19 if c.Args().Present() { 20 return ErrCommandTakesNoArguments 21 } 22 23 story, err := manifest.LoadStory(fs) 24 if err != nil { 25 return err 26 } 27 28 var projectList []string 29 for project := range story.Projects { 30 projectList = append(projectList, project) 31 } 32 33 // Update all of the package.json files where any other added project is used 34 for project := range story.Projects { 35 if ignore[project] { 36 continue 37 } 38 39 p := node.PackageJSON{} 40 if err := p.Load(fs, project); err != nil { 41 return err 42 } 43 44 p.SetPrivateDependencyBranchesToCommitHashes(story, projectList...) 45 if err := p.Write(fs, project); err != nil { 46 return err 47 } 48 49 printGitOutput("package.json updated", project) 50 } 51 52 return nil 53 }), 54 } 55 }