Skip to content

Commit

Permalink
Merge pull request #5 from bzon/modular-pkg
Browse files Browse the repository at this point in the history
Separate internal packages
  • Loading branch information
bzon authored Apr 23, 2018
2 parents d5732ef + 8ac7681 commit 22c6caa
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 28 deletions.
15 changes: 8 additions & 7 deletions cmd/nexus.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ import (
"fmt"
"os"

"github.com/spf13/cobra"
"github.com/bzon/gota/parser"

gota "github.com/bzon/gota/pkg"
nexuspkg "github.com/bzon/gota/nexus"
"github.com/spf13/cobra"
)

var nexus gota.Nexus
var nexus nexuspkg.Nexus

// nexusCmd represents the nexus command
var nexusCmd = &cobra.Command{
Expand All @@ -35,11 +36,11 @@ var nexusCmd = &cobra.Command{
var err error
app := newApp()
switch app.(type) {
case gota.IOSIPA:
ipa := app.(gota.IOSIPA)
case parser.IOSIPA:
ipa := app.(parser.IOSIPA)
assets, err = nexus.NexusUploadIOSAssets(&ipa, destDir)
case gota.AndroidAPK:
apk := app.(gota.AndroidAPK)
case parser.AndroidAPK:
apk := app.(parser.AndroidAPK)
assets, err = nexus.NexusUploadAndroidAssets(&apk, destDir)
}
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"
"path/filepath"

gota "github.com/bzon/gota/pkg"
"github.com/bzon/gota/parser"
"github.com/spf13/cobra"
)

Expand All @@ -24,20 +24,20 @@ func missingFlagError(cmd *cobra.Command, f string) {
os.Exit(1)
}

func newApp() gota.MobileApp {
appFile := gota.AppFile{
func newApp() parser.MobileApp {
appFile := parser.AppFile{
Title: title,
BuildNumber: buildNumber,
SourceFile: srcFile,
}
if fileExt() == ".ipa" {
return gota.IOSIPA{
return parser.IOSIPA{
AppFile: appFile,
BundleID: bundleID,
BundleVersion: bundleVersion,
}
} else {
return gota.AndroidAPK{
return parser.AndroidAPK{
AppFile: appFile,
VersionCode: versionCode,
VersionName: versionName,
Expand Down
8 changes: 5 additions & 3 deletions pkg/nexus_upload.go → nexus/nexus_upload.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gota
package nexus

import (
"fmt"
Expand All @@ -7,6 +7,8 @@ import (
"net/http"
"os"
"path/filepath"

"github.com/bzon/gota/parser"
)

// Nexus contains the fields requied for accessing a nexus server
Expand Down Expand Up @@ -52,7 +54,7 @@ func (n *Nexus) getRepoURL() string {
}

// NexusUploadIOSAssets wraps NexusUpload to upload all files for iOS to nexus
func (n *Nexus) NexusUploadIOSAssets(ipa *IOSIPA, dir string) ([]string, error) {
func (n *Nexus) NexusUploadIOSAssets(ipa *parser.IOSIPA, dir string) ([]string, error) {
// Upload in directory with FullVersion() as name
ipaSitePath := ipa.FullVersion() + "/" + filepath.Base(ipa.SourceFile)
ipaPlistSitePath := ipa.FullVersion() + "/" + ipa.Title + ".plist"
Expand Down Expand Up @@ -90,7 +92,7 @@ func (n *Nexus) NexusUploadIOSAssets(ipa *IOSIPA, dir string) ([]string, error)
}

// NexusUploadAndroidAssets wraps NexusUpload to upload all files for android to nexus
func (n *Nexus) NexusUploadAndroidAssets(apk *AndroidAPK, dir string) ([]string, error) {
func (n *Nexus) NexusUploadAndroidAssets(apk *parser.AndroidAPK, dir string) ([]string, error) {
// Upload in directory with FullVersion() as name
apkSitePath := apk.FullVersion() + "/" + filepath.Base(apk.SourceFile)
apkIndexHTMLSitePath := apk.FullVersion() + "/index.html"
Expand Down
18 changes: 10 additions & 8 deletions pkg/nexus_upload_test.go → nexus/nexus_upload_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package gota
package nexus

import (
"fmt"
"testing"
"time"

"github.com/bzon/gota/parser"
)

var nexus = Nexus{
Expand All @@ -15,7 +17,7 @@ var nexus = Nexus{

func TestNexusUpload(t *testing.T) {
var testComponent = NexusComponent{
SourceFile: "resources/index.html",
SourceFile: "../resources/index.html",
Filename: "index.html",
Directory: "go_upload_test",
}
Expand All @@ -27,22 +29,22 @@ func TestNexusUpload(t *testing.T) {
}

func TestGeneratedAssetsNexusUpload(t *testing.T) {
var ipa = IOSIPA{
AppFile: AppFile{
var ipa = parser.IOSIPA{
AppFile: parser.AppFile{
Title: "DarkSouls",
BuildDate: time.Now().Format(time.RFC822),
BuildNumber: "99",
SourceFile: "resources/DarkSouls.ipa", // dummy file
SourceFile: "../resources/DarkSouls.ipa", // dummy file
},
BundleID: "com.example.dark.souls",
BundleVersion: "1.0.0",
}
var apk = AndroidAPK{
AppFile: AppFile{
var apk = parser.AndroidAPK{
AppFile: parser.AppFile{
Title: "DarkSouls Android",
BuildDate: time.Now().Format(time.RFC822),
BuildNumber: "22",
SourceFile: "resources/DarkSouls.apk", // dummy file
SourceFile: "../resources/DarkSouls.apk", // dummy file
},
VersionName: "1.0.0",
VersionCode: "100222333",
Expand Down
2 changes: 1 addition & 1 deletion pkg/create.go → parser/create.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gota
package parser

import (
"fmt"
Expand Down
6 changes: 3 additions & 3 deletions pkg/create_test.go → parser/create_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gota
package parser

import (
"testing"
Expand All @@ -12,7 +12,7 @@ func TestGenerateAssets(t *testing.T) {
BuildDate: time.Now().Format(time.RFC822),
DownloadURL: "http://s3.amazon.com/bucket/DarkSouls.ipa",
BuildNumber: "99",
SourceFile: "resources/DarkSouls.ipa", // dummy file
SourceFile: "../resources/DarkSouls.ipa", // dummy file
},
PlistURL: "http://s3.amazon.com/bucket/DarkSouls.plist",
BundleID: "com.example.dark.souls",
Expand All @@ -24,7 +24,7 @@ func TestGenerateAssets(t *testing.T) {
BuildDate: time.Now().Format(time.RFC822),
DownloadURL: "http://s3.amazon.com/bucket/DarkSouls.apk",
BuildNumber: "22",
SourceFile: "resources/DarkSouls.apk", // dummy file
SourceFile: "../resources/DarkSouls.apk", // dummy file
},
VersionName: "1.0.0",
VersionCode: "100222333",
Expand Down
2 changes: 1 addition & 1 deletion pkg/templates.go → parser/templates.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gota
package parser

const versionTemplateString = `{
"latestVersion": "{{.FullVersion}}",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.

0 comments on commit 22c6caa

Please sign in to comment.