Skip to content

Commit

Permalink
close #22: add --force,-f flags to set-guid sub command
Browse files Browse the repository at this point in the history
  • Loading branch information
mh-cbon committed Aug 23, 2017
1 parent 549a52a commit 3c324b0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ USAGE:

OPTIONS:
--path value, -p value Path to the wix manifest file (default: "wix.json")
--force, -f Force update the guids
```

###### $ go-msi make -h
Expand All @@ -189,7 +190,7 @@ USAGE:
OPTIONS:
--path value, -p value Path to the wix manifest file (default: "wix.json")
--src value, -s value Directory path to the wix templates files (default: "/home/mh-cbon/gow/bin/templates")
--out value, -o value Directory path to the generated wix cmd file (default: "/tmp/go-msi907793490")
--out value, -o value Directory path to the generated wix cmd file (default: "/tmp/go-msi688242155")
--arch value, -a value A target architecture, amd64 or 386 (ia64 is not handled)
--msi value, -m value Path to write resulting msi file to
--version value The version of your program
Expand All @@ -209,7 +210,7 @@ OPTIONS:
--path value, -p value Path to the wix manifest file (default: "wix.json")
--src value, -s value Directory path to the wix templates files (default: "/home/mh-cbon/gow/bin/templates/choco")
--version value The version of your program
--out value, -o value Directory path to the generated chocolatey build file (default: "/tmp/go-msi391536363")
--out value, -o value Directory path to the generated chocolatey build file (default: "/tmp/go-msi878237147")
--input value, -i value Path to the msi file to package into the chocolatey package
--changelog-cmd value, -c value A command to generate the content of the changlog in the package
--keep, -k Keep output directory containing build files (useful for debug)
Expand All @@ -226,7 +227,7 @@ USAGE:
OPTIONS:
--path value, -p value Path to the wix manifest file (default: "wix.json")
--src value, -s value Directory path to the wix templates files (default: "/home/mh-cbon/gow/bin/templates")
--out value, -o value Directory path to the generated wix templates files (default: "/tmp/go-msi457443442")
--out value, -o value Directory path to the generated wix templates files (default: "/tmp/go-msi884232757")
--version value The version of your program
--license value, -l value Path to the license file
```
Expand Down Expand Up @@ -269,7 +270,7 @@ USAGE:
OPTIONS:
--path value, -p value Path to the wix manifest file (default: "wix.json")
--src value, -s value Directory path to the wix templates files (default: "/home/mh-cbon/gow/bin/templates")
--out value, -o value Directory path to the generated wix cmd file (default: "/tmp/go-msi364346502")
--out value, -o value Directory path to the generated wix cmd file (default: "/tmp/go-msi653778439")
--arch value, -a value A target architecture, amd64 or 386 (ia64 is not handled)
--msi value, -m value Path to write resulting msi file to
```
Expand All @@ -283,7 +284,7 @@ USAGE:
go-msi run-wix-cmd [command options] [arguments...]

OPTIONS:
--out value, -o value Directory path to the generated wix cmd file (default: "/tmp/go-msi949078727")
--out value, -o value Directory path to the generated wix cmd file (default: "/tmp/go-msi050462587")
```

# Recipes
Expand Down
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ func main() {
Value: "wix.json",
Usage: "Path to the wix manifest file",
},
cli.BoolFlag{
Name: "force, f",
Usage: "Force update the guids",
},
},
},
{
Expand Down Expand Up @@ -361,14 +365,15 @@ func checkJSON(c *cli.Context) error {

func setGUID(c *cli.Context) error {
path := c.String("path")
force := c.Bool("force")

wixFile := manifest.WixManifest{}
err := wixFile.Load(path)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}

updated, err := wixFile.SetGuids()
updated, err := wixFile.SetGuids(force)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
Expand Down Expand Up @@ -609,7 +614,7 @@ func quickMake(c *cli.Context) error {
}

if wixFile.NeedGUID() {
if _, err := wixFile.SetGuids(); err != nil {
if _, err := wixFile.SetGuids(false); err != nil {
return cli.NewExitError(err.Error(), 1)
}
}
Expand Down
10 changes: 5 additions & 5 deletions manifest/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,21 +146,21 @@ func (wixFile *WixManifest) Load(p string) error {
}

//SetGuids generates and apply guid values appropriately
func (wixFile *WixManifest) SetGuids() (bool, error) {
func (wixFile *WixManifest) SetGuids(force bool) (bool, error) {
updated := false
if wixFile.UpgradeCode == "" {
if wixFile.UpgradeCode == "" || force {
wixFile.UpgradeCode = uuid.NewV4().String()
updated = true
}
if wixFile.Files.GUID == "" {
if wixFile.Files.GUID == "" || force {
wixFile.Files.GUID = uuid.NewV4().String()
updated = true
}
if wixFile.Env.GUID == "" && len(wixFile.Env.Vars) > 0 {
if (wixFile.Env.GUID == "" || force) && len(wixFile.Env.Vars) > 0 {
wixFile.Env.GUID = uuid.NewV4().String()
updated = true
}
if wixFile.Shortcuts.GUID == "" && len(wixFile.Shortcuts.Items) > 0 {
if (wixFile.Shortcuts.GUID == "" || force) && len(wixFile.Shortcuts.Items) > 0 {
wixFile.Shortcuts.GUID = uuid.NewV4().String()
updated = true
}
Expand Down

0 comments on commit 3c324b0

Please sign in to comment.