Compare commits
3 Commits
b010d63351
...
e65633a85a
| Author | SHA1 | Date | |
|---|---|---|---|
| e65633a85a | |||
| d53ad8993c | |||
| 7b7fdc0113 |
19
Makefile
19
Makefile
@@ -24,6 +24,8 @@ endif
|
|||||||
# Variables
|
# Variables
|
||||||
#----------------------------------------------------------------
|
#----------------------------------------------------------------
|
||||||
progName = scaffold
|
progName = scaffold
|
||||||
|
arch = amd64
|
||||||
|
winbinName = $(progName).exe
|
||||||
|
|
||||||
#----------------------------------------------------------------
|
#----------------------------------------------------------------
|
||||||
# Helpers
|
# Helpers
|
||||||
@@ -57,11 +59,18 @@ prep: clean
|
|||||||
> date +"%F %a %T %Z" > buildTime.txt
|
> date +"%F %a %T %Z" > buildTime.txt
|
||||||
> git describe --always --tags --dirty --long > buildVersion.txt
|
> git describe --always --tags --dirty --long > buildVersion.txt
|
||||||
|
|
||||||
build: prep
|
build: prep linux windows
|
||||||
> @go build -o build/$(progName) . && echo "Build success" || echo "[FAILED] go build"
|
|
||||||
|
|
||||||
build-production: prep
|
linux:
|
||||||
> @go build -ldflags=${linkerflags} -o build/$(progName) . && echo "production build success" || echo "[FAILED] production build"
|
> @GOOS=$@ GOARCH=$(arch) go build -o build/$@/$(progName) . && echo $@ "Build success" || echo $@ "[FAILED] go build"
|
||||||
|
|
||||||
|
windows:
|
||||||
|
> @GOOS=$@ GOARCH=$(arch) go build -o build/$@/$(winbinName) . && echo $@ "Build success" || echo $@ "[FAILED] go build"
|
||||||
|
|
||||||
|
build-production: prep linx-production
|
||||||
|
|
||||||
|
linux-production:
|
||||||
|
> @GOOS=linx GOARCH=$(arch) go build -ldflags=${linkerflags} -o build/$@/$(progName) . && echo "production build success" || echo "[FAILED] production build"
|
||||||
|
|
||||||
#-------------------------------------------------------------
|
#-------------------------------------------------------------
|
||||||
# Install - same as build, but places binary on system path
|
# Install - same as build, but places binary on system path
|
||||||
@@ -74,4 +83,4 @@ install-production: prep
|
|||||||
> @go install -ldflags=${linkerflags} . && echo "Production build and install success" || echo "[FAILED] Production install"
|
> @go install -ldflags=${linkerflags} . && echo "Production build and install success" || echo "[FAILED] Production install"
|
||||||
|
|
||||||
## Commands that don't relate to a specific file
|
## Commands that don't relate to a specific file
|
||||||
.PHONY: help confirm clean prep build build-production
|
.PHONY: help confirm clean prep build build-production linux windows amd64
|
||||||
@@ -11,85 +11,6 @@ scaffold go NewGoProject
|
|||||||
scaffold py aPythonProject
|
scaffold py aPythonProject
|
||||||
`
|
`
|
||||||
|
|
||||||
// var gi_template = `%s
|
|
||||||
// .env
|
|
||||||
// *.env
|
|
||||||
// .env.toml
|
|
||||||
|
|
||||||
// cfg/*.toml
|
|
||||||
// cfg/.env
|
|
||||||
// cfg/*.env
|
|
||||||
// cfg/.env*
|
|
||||||
// *.toml
|
|
||||||
|
|
||||||
// build/
|
|
||||||
// buildTime.txt
|
|
||||||
// buildVersion.txt
|
|
||||||
// `
|
|
||||||
|
|
||||||
// var gi_py_template = `%s
|
|
||||||
// .env
|
|
||||||
// *.env
|
|
||||||
// .env.toml
|
|
||||||
|
|
||||||
// cfg/*.toml
|
|
||||||
// cfg/.env
|
|
||||||
// cfg/*.env
|
|
||||||
// cfg/.env*
|
|
||||||
// *.toml
|
|
||||||
|
|
||||||
// bin/
|
|
||||||
// `
|
|
||||||
|
|
||||||
// var cfg_content = `# New Go Project configuration file
|
|
||||||
|
|
||||||
// # Format: TOML - see https://toml.io for details
|
|
||||||
|
|
||||||
// # Go specific
|
|
||||||
// # Go module path is of the form basePath/projectName
|
|
||||||
// # must be addressable if you are going to publish
|
|
||||||
// module_basepath = "officallygood.com"
|
|
||||||
|
|
||||||
// # where to put new project directories
|
|
||||||
// # within the user's home directory
|
|
||||||
// projects_basedir = "devel/GoMyApps"
|
|
||||||
// #def_project_name = "new-go-project"
|
|
||||||
|
|
||||||
// # Must be string, will be parsed to correct type
|
|
||||||
// # Remember perms are in octal
|
|
||||||
// project_dir_permissions = "0700"
|
|
||||||
// file_permissions = "0660"
|
|
||||||
|
|
||||||
// # Git
|
|
||||||
// setup_git = true
|
|
||||||
|
|
||||||
// # Do you have a remote location?
|
|
||||||
// # Do you have autologins setup correctly with ssh keys?
|
|
||||||
// # Using your .ssh/config file might be helpful
|
|
||||||
|
|
||||||
// # setup remote repo?
|
|
||||||
// create_remote_repo = false
|
|
||||||
|
|
||||||
// # remote repo user@location
|
|
||||||
// remote_user = "user@server"
|
|
||||||
|
|
||||||
// # remote repo base dir
|
|
||||||
// # relative to remote user home dir
|
|
||||||
// # eg unix/linux server
|
|
||||||
// # for user@server:/home/user/git -- absolute path
|
|
||||||
// user@server:git -- relative to home dir
|
|
||||||
// # eg windows server
|
|
||||||
// # ???
|
|
||||||
|
|
||||||
// ############################
|
|
||||||
// # remote location MUST already exist on remote server
|
|
||||||
// ############################
|
|
||||||
// remote_location = "git"
|
|
||||||
|
|
||||||
// # default remote short name
|
|
||||||
// remote_shortname = "origin"
|
|
||||||
//`
|
|
||||||
|
|
||||||
var cfg_content = `# Scaffold program configuration
|
var cfg_content = `# Scaffold program configuration
|
||||||
|
|
||||||
# Format: TOML - see https://toml.io for details
|
# Format: TOML - see https://toml.io for details
|
||||||
|
|||||||
11
main.go
11
main.go
@@ -10,6 +10,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
@@ -60,6 +61,15 @@ func main() {
|
|||||||
if *infoFlag || *infoFlag2 {
|
if *infoFlag || *infoFlag2 {
|
||||||
fmt.Printf("Scaffold version: %s", buildVersion)
|
fmt.Printf("Scaffold version: %s", buildVersion)
|
||||||
fmt.Printf("Built: %s\n", buildTime)
|
fmt.Printf("Built: %s\n", buildTime)
|
||||||
|
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
fmt.Println("It's a windows system")
|
||||||
|
}
|
||||||
|
|
||||||
|
ucfgd, err := os.UserConfigDir()
|
||||||
|
ifFerr("Unable to determine user config directory", err)
|
||||||
|
fmt.Println("System says -- user config directory: ", ucfgd)
|
||||||
|
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,6 +94,7 @@ func main() {
|
|||||||
_, err = cfgfd.WriteString(cfg_content)
|
_, err = cfgfd.WriteString(cfg_content)
|
||||||
ifFerr("Unable to write scaffold configuration file content", err)
|
ifFerr("Unable to write scaffold configuration file content", err)
|
||||||
fmt.Println("Wrote new scaffold configuration file")
|
fmt.Println("Wrote new scaffold configuration file")
|
||||||
|
|
||||||
_, err = toml.Decode(cfg_content, &setup)
|
_, err = toml.Decode(cfg_content, &setup)
|
||||||
ifFerr("[Failed] to parse config file", err)
|
ifFerr("[Failed] to parse config file", err)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user