-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from bzon/issue-3-use-ipapk-analyzer
Issue 3 use ipapk analyzer Closes #3
- Loading branch information
Showing
13 changed files
with
272 additions
and
437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,22 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"log" | ||
"time" | ||
|
||
"github.com/bzon/ipapk" | ||
|
||
"github.com/bzon/gota/parser" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// common | ||
var title, srcFile, buildNumber, destDir string | ||
|
||
// ios specific | ||
var bundleID, bundleVersion string | ||
|
||
// android specific | ||
var versionName, versionCode string | ||
|
||
func missingFlagError(cmd *cobra.Command, f string) { | ||
fmt.Printf("Error: required flag(s) \"%s\" not set\n", f) | ||
cmd.Usage() | ||
os.Exit(1) | ||
} | ||
|
||
func newApp() parser.MobileApp { | ||
appFile := parser.AppFile{ | ||
Title: title, | ||
BuildNumber: buildNumber, | ||
SourceFile: srcFile, | ||
} | ||
if fileExt() == ".ipa" { | ||
return parser.IOSIPA{ | ||
AppFile: appFile, | ||
BundleID: bundleID, | ||
BundleVersion: bundleVersion, | ||
} | ||
} else { | ||
return parser.AndroidAPK{ | ||
AppFile: appFile, | ||
VersionCode: versionCode, | ||
VersionName: versionName, | ||
} | ||
} | ||
} | ||
|
||
func fileExt() string { | ||
return filepath.Ext(srcFile) | ||
} | ||
|
||
// This function must be called before executing any commands function! | ||
func validateAndParseArgs(cmd *cobra.Command) { | ||
if fileExt() == ".ipa" { | ||
if bundleVersion == "" { | ||
missingFlagError(cmd, "bundleVersion") | ||
} | ||
if bundleID == "" { | ||
missingFlagError(cmd, "bundleID") | ||
} | ||
} else if fileExt() == ".apk" { | ||
if versionName == "" { | ||
missingFlagError(cmd, "versionName") | ||
} | ||
if versionCode == "" { | ||
missingFlagError(cmd, "versionCode") | ||
} | ||
} else { | ||
fmt.Printf("Error: srcFile %s does not have a file extension of .apk or .ipa\n", srcFile) | ||
cmd.Usage() | ||
os.Exit(1) | ||
} | ||
if _, err := os.Stat(srcFile); os.IsNotExist(err) { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
func NewMobileAppParser() *parser.MobileApp { | ||
appInfo, err := ipapk.NewAppParser(srcFile) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
var app parser.MobileApp | ||
app.UploadDate = time.Now().Format(time.RFC1123) | ||
app.AppInfo = appInfo | ||
app.File = srcFile | ||
return &app | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.