Compare commits

..

11 Commits
1.0 ... main

Author SHA1 Message Date
KZacharski 2b5ee11af0 add an option to disable commiting after initializing in the config file or with an argument 2023-09-02 03:19:39 +02:00
KZacharski 39598ad4db Make the default gitignore modifiable with a file in the config folder 2023-09-02 03:03:07 +02:00
KZacharski b4696f63bb deprecated debug mode 2023-09-01 01:00:55 +02:00
KZacharski a17a27d74d Add an ability to disable adding a favicon with a config.txt line or an argument 2023-08-31 22:59:47 +02:00
KZacharski 5b55424b7f diji-build: Created a script for automatic building 2023-08-31 02:38:24 +02:00
KZacharski 00720e8842 Merge remote-tracking branch 'refs/remotes/origin/main' 2023-08-31 01:55:33 +02:00
KZacharski c9574be651 started working on diji-build 2023-08-31 01:53:39 +02:00
KZacharski 5b565b4803 1.2 2023-08-20 22:34:13 +02:00
KZacharski dcec5f3b1c add release to gitignore 2023-08-18 19:15:06 +02:00
KZacharski 3eb0963b97 1.1 2023-08-18 18:58:49 +02:00
KZacharski dd027f777b Made the config folder visible 2023-08-18 18:57:43 +02:00
8 changed files with 159 additions and 100 deletions

View File

@ -1,5 +0,0 @@
// Quick mode skips all the questions besides project name and always uses the default option.
quick-mode = false
// Debug mode - prints all variables at the end of a run.
debug = false

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.DS_Store
*.test
diji
release

47
diji-build.sh Executable file
View File

@ -0,0 +1,47 @@
#!/bin/bash
echo "diji-build 1.0"
version=$(go run . -- --buildversion)
echo "Building diji $version"
rldir="release"
if [ -f "$rldir" ] ; then
rm -rf "$rldir"
echo "Removed files from the previous build"
fi
mkdir release
mkdir release/diji
cp -r diji-config release/diji
echo "diji-config prepared"
GOOS=linux GOARCH=amd64 go build -o release/diji/diji
(cd release; zip -r diji-$version-linux-amd64.zip diji; rm -rf diji/diji)
echo "linux/amd64 built"
GOOS=linux GOARCH=386 go build -o release/diji/diji
(cd release; zip -r diji-$version-linux-i386.zip diji; rm -rf diji/diji)
echo "linux/386 built"
GOOS=linux GOARCH=arm64 go build -o release/diji/diji
(cd release; zip -r diji-$version-linux-arm64.zip diji; rm -rf diji/diji)
echo "linux/arm64 built"
GOOS=linux GOARCH=arm go build -o release/diji/diji
(cd release; zip -r diji-$version-linux-arm.zip diji; rm -rf diji/diji)
echo "linux/arm built"
GOOS=darwin GOARCH=amd64 go build -o release/diji/diji
(cd release; zip -r diji-$version-macos-amd64.zip diji; rm -rf diji/diji)
echo "darwin/amd64 built"
GOOS=darwin GOARCH=arm64 go build -o release/diji/diji
(cd release; zip -r diji-$version-macos-arm64.zip diji; rm -rf diji/diji)
echo "darwin/arm64 built"
GOOS=windows GOARCH=amd64 go build -o release/diji/diji.exe
(cd release; zip -r diji-$version-windows-amd64.zip diji; rm -rf diji/diji.exe)
echo "windows/amd64 built"
GOOS=windows GOARCH=386 go build -o release/diji/diji.exe
(cd release; zip -r diji-$version-windows-i386.zip diji; rm -rf diji/diji.exe)
echo "windows/386 built"
GOOS=windows GOARCH=arm64 go build -o release/diji/diji.exe
(cd release; zip -r diji-$version-windows-arm64.zip diji; rm -rf diji/diji.exe)
echo "windows/arm64 built"
GOOS=windows GOARCH=arm go build -o release/diji/diji.exe
(cd release; zip -r diji-$version-windows-arm.zip diji; rm -rf diji/diji.exe)
echo "windows/arm built"
rm -rf release/diji
echo "Cleaned up"
echo "Done, the zips are ready in the release directory"

8
diji-config/config.txt Normal file
View File

@ -0,0 +1,8 @@
// Quick mode skips all the questions besides project name and always uses the default option.
quick-mode = false
// Should a favicon be added by default
favicon = true
// Create a commit after initializing the repo
commit = true

View File

Before

Width:  |  Height:  |  Size: 177 KiB

After

Width:  |  Height:  |  Size: 177 KiB

View File

@ -0,0 +1 @@
.DS_Store

197
diji.go
View File

@ -43,23 +43,18 @@ func copy(src, dst string) (int64, error) {
}
func main() {
var ver string = "1.0"
var version int = 1
var ver string = "1.3"
// var version int = 4
argsar := os.Args[1:]
var debugelement string = "-d"
var quickelement string = "-q"
var debugargument bool = false
var buildelement string = "--buildversion"
var addfavelement string = "-f"
var commitelement string = "-c"
var quickargument bool = false
for i := 0; i < len(argsar); i++ {
// checking if the array contains the given value
if argsar[i] == debugelement {
// changing the boolean variable
debugargument = true
break
}
}
var buildargument bool = false
var addfavargument bool = false
var commitargument bool = false
for i := 0; i < len(argsar); i++ {
// checking if the array contains the given value
@ -70,6 +65,38 @@ func main() {
}
}
for i := 0; i < len(argsar); i++ {
// checking if the array contains the given value
if argsar[i] == buildelement {
// changing the boolean variable
buildargument = true
break
}
}
for i := 0; i < len(argsar); i++ {
// checking if the array contains the given value
if argsar[i] == addfavelement {
// changing the boolean variable
addfavargument = true
break
}
}
if buildargument == true {
fmt.Print(ver)
os.Exit(0)
}
for i := 0; i < len(argsar); i++ {
// checking if the array contains the given value
if argsar[i] == commitelement {
// changing the boolean variable
commitargument = true
break
}
}
var projname string
fmt.Println("地基")
@ -84,9 +111,10 @@ func main() {
var creategitignore bool = true
var configlocation string
var configfile string
var exPath string
if _, err := os.Stat(".diji-config/config.txt"); err == nil {
configlocation = ".diji-config/config.txt"
if _, err := os.Stat("diji-config"); err == nil {
configlocation = "diji-config"
} else if errors.Is(err, os.ErrNotExist) {
ex, err := os.Executable()
@ -94,24 +122,28 @@ func main() {
panic(err)
}
exPath = filepath.Dir(ex)
configlocation = exPath + "/.diji-config/config.txt"
configlocation = exPath + "/diji-config"
}
configbytes, err := os.ReadFile(configlocation)
configfile = configlocation + "/config.txt"
configbytes, err := os.ReadFile(configfile)
if err != nil {
fmt.Print(err)
}
configtext := string(configbytes)
var quickmode bool = strings.Contains(configtext, "quick-mode = true")
var debug bool = strings.Contains(configtext, "debug = true")
if debugargument == true {
if debug == true {
debug = false
} else if debug == false {
debug = true
}
var gitemplatelocation string
gitemplatelocation = configlocation + "/gitignore.txt"
gibytes, err := os.ReadFile(gitemplatelocation)
if err != nil {
fmt.Print(err)
}
gitemplatetext := string(gibytes)
var quickmode bool = strings.Contains(configtext, "quick-mode = true")
var addfav bool = strings.Contains(configtext, "favicon = true")
var commitinit bool = strings.Contains(configtext, "commit = true")
if quickargument == true {
if quickmode == true {
@ -121,6 +153,22 @@ func main() {
}
}
if addfavargument == true {
if addfav == true {
addfav = false
} else if addfav == false {
addfav = true
}
}
if commitargument == true {
if commitinit == true {
commitinit = false
} else if commitinit == false {
commitinit = true
}
}
var cssstr string
var jsstr string
var samplestr string
@ -179,13 +227,17 @@ func main() {
if err != nil {
log.Fatal(err)
}
var assetspath string = projname + "/assets"
if err := os.Mkdir(assetspath, os.ModePerm); err != nil {
log.Fatal(err)
if addfav == true {
var assetspath string = projname + "/assets"
if err := os.Mkdir(assetspath, os.ModePerm); err != nil {
log.Fatal(err)
}
var favpath string = assetspath + "/favicon.png"
copy(configlocation+"/defaultfav.png", favpath)
fmt.Println(favpath + " created.")
}
var favpath string = assetspath + "/favicon.png"
copy(".diji-config/defaultfav.png", favpath)
fmt.Println(favpath + " created.")
var indexcontent1 string = `<!DOCTYPE html>
<html lang="` + langstr + `">
<head>
@ -193,7 +245,6 @@ func main() {
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>` + projname + `</title>
<link rel="icon" type="image" href="./assets/favicon.png">
`
var csstag string = `<link rel="stylesheet" type="text/css" href="style.css">
`
@ -212,6 +263,11 @@ func main() {
` + samplecontent + `
</body>`
}
var favtag string = `<link rel="icon" type="image" href="./assets/favicon.png">
`
if addfav == true {
indexcontent1 = indexcontent1 + favtag
}
if createcss == true {
indexcontent1 = indexcontent1 + csstag
}
@ -258,7 +314,7 @@ font-family: sans-serif;
if creategitignore == true {
giname = projname + "/.gitignore"
gicontent = ".DS_Store " + gifiles
gicontent = gitemplatetext + gifiles
gignore, err := os.Create(giname)
if err != nil {
log.Fatal(err)
@ -275,73 +331,24 @@ font-family: sans-serif;
if err := cmd.Run(); err != nil {
log.Fatal(err)
}
cmd1 := exec.Command("git", "add", ".")
cmd1.Dir = "./" + projname
if err := cmd1.Run(); err != nil {
log.Fatal(err)
}
cmd2 := exec.Command("git", "commit", "-a", "-m", `"Initial commit"`)
cmd2.Dir = "./" + projname
if err := cmd2.Run(); err != nil {
log.Fatal(err)
if commitinit == true {
cmd1 := exec.Command("git", "add", ".")
cmd1.Dir = "./" + projname
if err := cmd1.Run(); err != nil {
log.Fatal(err)
}
cmd2 := exec.Command("git", "commit", "-a", "-m", `"Initial commit"`)
cmd2.Dir = "./" + projname
if err := cmd2.Run(); err != nil {
log.Fatal(err)
}
}
fmt.Println("Git repo initialized.")
}
if debug == true {
fmt.Println(version)
fmt.Println("projname(string): " + projname)
fmt.Print("createcss(bool): ")
fmt.Println(createcss)
fmt.Print("createjs(bool): ")
fmt.Println(createjs)
fmt.Print("configbytes([]byte]): ")
fmt.Println(configbytes)
fmt.Println("configtext(string): " + configtext)
fmt.Print("quickmode(bool): ")
fmt.Println(quickmode)
fmt.Print("debug(bool): ")
fmt.Println(debug)
fmt.Println("cssstr(string): " + cssstr)
fmt.Println("jsstr(string): " + jsstr)
fmt.Println("indname(string): " + indname)
fmt.Println("assetspath(string): " + assetspath)
fmt.Println("favpath(string): " + favpath)
fmt.Println("indexcontent1(string): " + indexcontent1)
fmt.Println("csstag(string): " + csstag)
fmt.Println("jstag(string): " + jstag)
fmt.Println("indexcontent2(string): " + indexcontent2)
fmt.Println("indexcontent(string): " + indexcontent)
fmt.Println("cssname(string): " + cssname)
fmt.Println("csscontent(string): " + csscontent)
fmt.Println("jsname(string): " + jsname)
fmt.Print("argsar(array): ")
fmt.Println(argsar)
fmt.Println("debugelement(string): " + debugelement)
fmt.Println("quickelement(string): " + quickelement)
fmt.Print("debugargument(bool): ")
fmt.Println(debugargument)
fmt.Print("quickargument(bool): ")
fmt.Println(quickargument)
fmt.Println("configlocation(string): " + configlocation)
fmt.Println("exPath(string): " + exPath)
fmt.Println("samplestr(string): " + samplestr)
fmt.Println("langstr(string): " + langstr)
fmt.Println("gitstr(string): " + gitstr)
fmt.Println("gitignorestr(string): " + gitignorestr)
fmt.Println("gifiles(string): " + gifiles)
fmt.Print("createsample(bool): ")
fmt.Println(createsample)
fmt.Print("initgit(bool): ")
fmt.Println(initgit)
fmt.Print("creategitignore(bool): ")
fmt.Println(creategitignore)
fmt.Println("samplecontent(string)" + samplecontent)
fmt.Println("giname(string)" + giname)
fmt.Println("gicontent(string)" + gicontent)
}
fmt.Println("Project created in ./" + projname + ".")
fmt.Println("Thanks for using diji.")