Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 87a045cbea | |||
| 38c3a87dd2 |
@@ -2,4 +2,10 @@
|
|||||||
|
|
||||||
## Intro
|
## Intro
|
||||||
|
|
||||||
blah blah blah
|
## Git
|
||||||
|
|
||||||
|
Git is available to be used as the version control system for new projects. Select/Deselect within the `scaffold-<PROJECTTYPE>.toml` file.
|
||||||
|
|
||||||
|
***Please Note** that if you also use it for your configuration files and sample directories, then a .gitignore file within your sample directory will interfere with git's ability to track your skeletons/templates properly. So, to allow for this, put what you normally would in a .gitignore file into a GITIGNORE file in your sample directory. And scaffold will convert it to a .gitignore file within your newProject directory.
|
||||||
|
|
||||||
|
If you are NOT using git to track your project types and samples/skeletons/templates, then no problem, just place a .gitignore file within the sample directory as you would any other file.
|
||||||
|
|||||||
@@ -10,3 +10,33 @@ Usage examples:
|
|||||||
scaffold go NewGoProject
|
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/
|
||||||
|
// `
|
||||||
|
|||||||
31
main.go
31
main.go
@@ -160,6 +160,8 @@ func main() {
|
|||||||
|
|
||||||
// run init commands
|
// run init commands
|
||||||
|
|
||||||
|
switch projType {
|
||||||
|
case "go":
|
||||||
// make mod file
|
// make mod file
|
||||||
modpath := npsetup.Module_basepath + sep + newProjectName
|
modpath := npsetup.Module_basepath + sep + newProjectName
|
||||||
_, err = exec.Command("go", "mod", "init", modpath).Output()
|
_, err = exec.Command("go", "mod", "init", modpath).Output()
|
||||||
@@ -169,6 +171,8 @@ func main() {
|
|||||||
_, err = exec.Command("go", "mod", "tidy").Output()
|
_, err = exec.Command("go", "mod", "tidy").Output()
|
||||||
ifFerr("Unable to update the mod file with a tidy", err)
|
ifFerr("Unable to update the mod file with a tidy", err)
|
||||||
fmt.Println("Updated go.mod")
|
fmt.Println("Updated go.mod")
|
||||||
|
case "py":
|
||||||
|
}
|
||||||
|
|
||||||
// setup git
|
// setup git
|
||||||
if npsetup.Setup_git {
|
if npsetup.Setup_git {
|
||||||
@@ -176,6 +180,33 @@ func main() {
|
|||||||
_, err = exec.Command("git", "init").Output()
|
_, err = exec.Command("git", "init").Output()
|
||||||
ifFerr("Unable to initialize git repository", err)
|
ifFerr("Unable to initialize git repository", err)
|
||||||
|
|
||||||
|
nifd, err := os.Create(".gitignore")
|
||||||
|
ifFerr("Unable to create .gitignore file", err)
|
||||||
|
defer nifd.Close()
|
||||||
|
|
||||||
|
var gi_content string
|
||||||
|
var gi_in []byte = []byte("bin/")
|
||||||
|
|
||||||
|
gisrc, err := os.Open("GITIGNORE")
|
||||||
|
if err == nil { // assume error means there is no source file
|
||||||
|
gi_in, err = io.ReadAll(gisrc)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Unable to read GITIGNORE, using default content")
|
||||||
|
}
|
||||||
|
gi_content = fmt.Sprintf("%s\n\n%s", newProjectName, string(gi_in))
|
||||||
|
|
||||||
|
_, err = nifd.WriteString(gi_content)
|
||||||
|
ifFerr("Unable to write .gitignore content", err)
|
||||||
|
fmt.Println("Wrote .gitignore content")
|
||||||
|
|
||||||
|
// remove GITIGNORE
|
||||||
|
err = os.Remove("GITIGNORE")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Unable to remove GITIGNORE file")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defer gisrc.Close()
|
||||||
|
|
||||||
// stage files
|
// stage files
|
||||||
_, err = exec.Command("git", "add", ".").Output()
|
_, err = exec.Command("git", "add", ".").Output()
|
||||||
ifFerr("Unable to stage files prior to first commit", err)
|
ifFerr("Unable to stage files prior to first commit", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user