Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
be39a79
feat xcode: scan the directory for project files
BirmacherAkos Jan 21, 2019
f50d1ab
typo
BirmacherAkos Jan 21, 2019
9a2efe4
moved the scanForProjectFiles() to cmd/utils.go
BirmacherAkos Jan 21, 2019
f53835b
project dir scan for the project files like in the scanner
BirmacherAkos Feb 4, 2019
6ff2fe7
clean
BirmacherAkos Feb 4, 2019
6fd9ac4
deps: scanner/xamarin & scanner/ios
BirmacherAkos Feb 4, 2019
611174f
xamarin option for auto scan
BirmacherAkos Feb 4, 2019
fc75337
warning message added about the --file flag usage
BirmacherAkos Feb 4, 2019
2026e70
PR: IDEType enum renamed to ProjectType; and changed from String to Int;
BirmacherAkos Feb 8, 2019
5311596
PR: fix some log typo: solution => workspace / project
BirmacherAkos Feb 8, 2019
2ab734e
ref: scanXamarinProject: move the "search for the soulition file" blo…
BirmacherAkos Feb 8, 2019
f8b95ca
ref: scanXcodeProject: move the "search for the project file" block i…
BirmacherAkos Feb 8, 2019
431b352
Merge branch 'master' into project-scan-xcode
BirmacherAkos Feb 11, 2019
d97fd76
dep ensure
BirmacherAkos Feb 11, 2019
a8188d9
PR clean
BirmacherAkos Feb 11, 2019
3198ad5
PR: make ProjectType private
BirmacherAkos Feb 11, 2019
bd8d11d
Merge branch 'master' into project-scan-xcode
BirmacherAkos Feb 14, 2019
0917f25
move the findXcodeProject & findXamarinProject methods to cmd/utils.g…
BirmacherAkos Feb 14, 2019
f16a378
PR: fix return
BirmacherAkos Feb 15, 2019
2eb23e2
clean the findXamarinSolution() just like the findXcodeProject()
BirmacherAkos Feb 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ package cmd
import (
"fmt"
"os"
"path"

"github.com/bitrise-core/bitrise-init/scanners/ios"
"github.com/bitrise-core/bitrise-init/scanners/xamarin"
"github.com/bitrise-core/bitrise-init/utility"
"github.com/bitrise-io/go-utils/colorstring"
"github.com/bitrise-io/go-utils/log"
"github.com/bitrise-io/goinp/goinp"
)

// projectType enum.
Expand Down Expand Up @@ -60,3 +64,73 @@ func scanForProjectFiles(projType projectType) ([]string, error) {
}
return paths, nil
}

// findProject scans the directory for Xcode Project (.xcworkspace / .xcodeproject) file first
// If can't find any, ask the user to drag-and-drop the file
func findXcodeProject() (string, error) {
var projpth string

projPaths, err := scanForProjectFiles(iOSProjectType)
if err != nil {
log.Printf("Failed: %s", err)
fmt.Println()

log.Infof("Provide the project file manually")
askText := `Please drag-and-drop your Xcode Project (` + colorstring.Green(".xcodeproj") + `) or Workspace (` + colorstring.Green(".xcworkspace") + `) file,
the one you usually open in Xcode, then hit Enter.
(Note: if you have a Workspace file you should most likely use that)`
projpth, err = goinp.AskForPath(askText)
if err != nil {
return "", fmt.Errorf("failed to read input: %s", err)
}

return projpth, nil
}

if len(projPaths) == 1 {
log.Printf("Found one project file: %s.", path.Base(projPaths[0]))
return projPaths[0], nil
}

log.Printf("Found multiple project file: %s.", path.Base(projpth))
projpth, err = goinp.SelectFromStringsWithDefault("Select the project file you want to scan", 1, projPaths)
if err != nil {
return "", fmt.Errorf("failed to select project file: %s", err)
}

return projpth, nil
}

// findSolution scans the directory for Xamarin.Solution file first
// If can't find any, ask the user to drag-and-drop the file
func findXamarinSolution() (string, error) {
var solutionPth string
solPaths, err := scanForProjectFiles(xamarinProjectType)
if err != nil {
log.Printf("Failed: %s", err)
fmt.Println()

log.Infof("Provide the solution file manually")
askText := `Please drag-and-drop your Xamarin Solution (` + colorstring.Green(".sln") + `) file,
and then hit Enter`
solutionPth, err = goinp.AskForPath(askText)
if err != nil {
return "", fmt.Errorf("failed to read input: %s", err)
}

return solutionPth, nil
}

if len(solPaths) == 1 {
log.Printf("Found one solution file: %s.", path.Base(solPaths[0]))
return solPaths[0], nil
}

log.Printf("Found multiple solution file: %s.", path.Base(solutionPth))
solutionPth, err = goinp.SelectFromStringsWithDefault("Select the solution file you want to scan", 1, solPaths)
if err != nil {
return "", fmt.Errorf("failed to select solution file: %s", err)
}

return solutionPth, nil
}
35 changes: 1 addition & 34 deletions cmd/xamarin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"encoding/json"
"fmt"
"path"
"path/filepath"
"sort"

Expand Down Expand Up @@ -76,38 +75,6 @@ func archivableSolutionConfigNames(projectsByID map[string]project.Model) []stri
return archivableSolutionConfigNames
}

// findSolution scans the directory for Xamarin.Solution file first
// If can't find any, ask the user to drag-and-drop the file
func findSolution() (string, error) {
var solutionPth string
solPaths, err := scanForProjectFiles(xamarinProjectType)
if err != nil {
log.Printf("Failed: %s", err)
fmt.Println()

log.Infof("Provide the solution file manually")
askText := `Please drag-and-drop your Xamarin Solution (` + colorstring.Green(".sln") + `) file,
and then hit Enter`
solutionPth, err = goinp.AskForPath(askText)
if err != nil {
return "", fmt.Errorf("failed to read input: %s", err)
}
} else {
if len(solPaths) == 1 {
log.Printf("Found one solution file: %s.", path.Base(solPaths[0]))
solutionPth = solPaths[0]
} else {
log.Printf("Found multiple solution file: %s.", path.Base(solutionPth))
solutionPth, err = goinp.SelectFromStringsWithDefault("Select the solution file you want to scan", 1, solPaths)
if err != nil {
return "", fmt.Errorf("failed to select solution file: %s", err)
}
}
}

return solutionPth, nil
}

func scanXamarinProject(cmd *cobra.Command, args []string) error {
absExportOutputDirPath, err := initExportOutputDir()
if err != nil {
Expand All @@ -127,7 +94,7 @@ func scanXamarinProject(cmd *cobra.Command, args []string) error {
//
// Scan the directory for Xamarin.Solution file first
// If can't find any, ask the user to drag-and-drop the file
xamarinCmd.SolutionFilePath, err = findSolution()
xamarinCmd.SolutionFilePath, err = findXamarinSolution()
if err != nil {
return err
}
Expand Down
44 changes: 4 additions & 40 deletions cmd/xcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"fmt"
"os"
"path"
"path/filepath"
"strings"

Expand Down Expand Up @@ -62,41 +61,6 @@ func initExportOutputDir() (string, error) {
return absExportOutputDirPath, nil
}

// findProject scans the directory for Xcode Project (.xcworkspace / .xcodeproject) file first
// If can't find any, ask the user to drag-and-drop the file
func findProject() (string, error) {
var projpth string

projPaths, err := scanForProjectFiles(iOSProjectType)
if err != nil {
log.Printf("Failed: %s", err)
fmt.Println()

log.Infof("Provide the project file manually")
askText := `Please drag-and-drop your Xcode Project (` + colorstring.Green(".xcodeproj") + `) or Workspace (` + colorstring.Green(".xcworkspace") + `) file,
the one you usually open in Xcode, then hit Enter.
(Note: if you have a Workspace file you should most likely use that)`
projpth, err = goinp.AskForPath(askText)
if err != nil {
return "", fmt.Errorf("failed to read input: %s", err)
}
return projpth, err
}

if len(projPaths) == 1 {
log.Printf("Found one project file: %s.", path.Base(projPaths[0]))
return projPaths[0], nil
}

log.Printf("Found multiple project file: %s.", path.Base(projpth))
projpth, err = goinp.SelectFromStringsWithDefault("Select the project file you want to scan", 1, projPaths)
if err != nil {
return "", fmt.Errorf("failed to select project file: %s", err)
}

return projpth, nil
}

func scanXcodeProject(cmd *cobra.Command, args []string) error {
absExportOutputDirPath, err := initExportOutputDir()
if err != nil {
Expand All @@ -120,14 +84,14 @@ func scanXcodeProject(cmd *cobra.Command, args []string) error {
log.Infof("Scan the directory for project files")
log.Warnf("You can specify the Xcode project/workscape file to scan with the --file flag.")

projpth, err := findProject()
//
// Scan the directory for Xcode Project (.xcworkspace / .xcodeproject) file first
// If can't find any, ask the user to drag-and-drop the file
projpth, err := findXcodeProject()
if err != nil {
return err
}

//
// Scan the directory for Xcode Project (.xcworkspace / .xcodeproject) file first
// If can't find any, ask the user to drag-and-drop the file
projectPath = strings.Trim(strings.TrimSpace(projpth), "'\"")
}
log.Debugf("projectPath: %s", projectPath)
Expand Down
14 changes: 8 additions & 6 deletions cmd/xcodeUITests.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,20 @@ func scanXcodeUITestsProject(cmd *cobra.Command, args []string) error {

projectPath := paramXcodeProjectFilePath
if projectPath == "" {
askText := `Please drag-and-drop your Xcode Project (` + colorstring.Green(".xcodeproj") + `) or Workspace (` + colorstring.Green(".xcworkspace") + `) file,
the one you usually open in Xcode, then hit Enter.
(Note: if you have a Workspace file you should most likely use that)`
projpth, err := goinp.AskForPath(askText)
log.Infof("Scan the directory for project files")
log.Warnf("You can specify the Xcode project/workscape file to scan with the --file flag.")

//
// Scan the directory for Xcode Project (.xcworkspace / .xcodeproject) file first
// If can't find any, ask the user to drag-and-drop the file
projpth, err := findXcodeProject()
if err != nil {
return fmt.Errorf("failed to read input: %s", err)
return err
}

projectPath = strings.Trim(strings.TrimSpace(projpth), "'\"")
}
log.Debugf("projectPath: %s", projectPath)

xcodeUITestsCmd := xcodeuitest.CommandModel{ProjectFilePath: projectPath}

schemeToUse := paramXcodeScheme
Expand Down