<commit_before>package main

import (
	"fmt"
	"os"
	"os/exec"
)

func main() {
	// TODO: check if git binary present
	// TODO: load args from CLI
	// TODO: read config
	newAppName := "migrations"

	createAppDir(newAppName)
	addAppToGitIgnore(newAppName)
	commitToMasterRepo(newAppName)
	//fmt.Println("Add container to docker-compose.apps.yml")
	goToAppDir(newAppName)
	createReadme(newAppName)
	createDockerfile(newAppName)
	initializeGitRepo(newAppName)
}

func createAppDir(newAppName string) {
	err := os.Mkdir(newAppName, 0755)
	if err != nil {
		// Check if directory exists
		fmt.Println("Can't create dir")
	}
}

func addAppToGitIgnore(newAppName string) {
	//TODO: check if this line exists in file
	wd, _ := os.Getwd()
	f, err := os.OpenFile(wd + "/.gitignore", os.O_APPEND|os.O_WRONLY, os.ModeAppend)
	if err != nil {
		fmt.Println(err)
	}
	_, err = f.WriteString(newAppName + "\n")
	if err != nil {
		fmt.Println(err)
	}
	f.Close()
}

func commitToMasterRepo(newAppName string) {
	cmd := exec.Command("git", "add", ".gitignore")
	err := cmd.Run()
	if err != nil {
		fmt.Println(err)
	}

	cmd = exec.Command("git", "commit", "-am", "\"Add " + newAppName + " app\"")
	err = cmd.Run()
	if err != nil {
		fmt.Println(err)
	}
}

func goToAppDir(newAppName string) {
	err := os.Chdir(newAppName)
	if err != nil {
		fmt.Println(err)
	}
}

func createReadme(newAppName string) {
	readmeFile, err := os.Create("README.md")
	if err != nil {
		fmt.Println(err)
	}
	readmeFile.Close()
}

func initializeGitRepo(newAppName string) {
	cmd := exec.Command("git", "init")
	err := cmd.Run()
	if err != nil {
		fmt.Println(err)
	}

	cmd = exec.Command("git", "add", ".")
	err = cmd.Run()
	if err != nil {
		fmt.Println(err)
	}

	cmd = exec.Command("git", "commit", "-am", "\"Initial commit\"")
	err = cmd.Run()
	if err != nil {
		fmt.Println(err)
	}
}

func createDockerfile(newAppName string) {
	dockerfile, err := os.Create("Dockerfile")
	if err != nil {
		fmt.Println(err)
	}
	dockerfile.Close()
}

func createBuildScript(newAppName string) {
	buildScript, err := os.Create("build.sh")
	if err != nil {
		fmt.Println(err)
	}
	buildScript.Chmod(0755)
	buildScript.Close()
}
<commit_msg>Add todos<commit_after>package main

import (
	"fmt"
	"os"
	"os/exec"
)

// TODO: implement the following features
// fres init [project name]
// fres create [app name] --lang ruby
// fres remove [app name]
// fres deploy [app name]
// fres deploy

func main() {
	// TODO: check if git binary present
	// TODO: load args from CLI
	// TODO: read config
	newAppName := "migrations"

	createAppDir(newAppName)
	addAppToGitIgnore(newAppName)
	commitToMasterRepo(newAppName)
	//fmt.Println("Add container to docker-compose.apps.yml")
	goToAppDir(newAppName)
	createReadme(newAppName)
	createDockerfile(newAppName)
	initializeGitRepo(newAppName)
	// TODO: create remote repo and push
}

func createAppDir(newAppName string) {
	err := os.Mkdir(newAppName, 0755)
	if err != nil {
		// Check if directory exists
		fmt.Println("Can't create dir")
	}
}

func addAppToGitIgnore(newAppName string) {
	//TODO: check if this line exists in file
	wd, _ := os.Getwd()
	f, err := os.OpenFile(wd + "/.gitignore", os.O_APPEND|os.O_WRONLY, os.ModeAppend)
	if err != nil {
		fmt.Println(err)
	}
	_, err = f.WriteString(newAppName + "\n")
	if err != nil {
		fmt.Println(err)
	}
	f.Close()
}

func commitToMasterRepo(newAppName string) {
	// TODO: use git lib for dealing with repos
	cmd := exec.Command("git", "add", ".gitignore")
	err := cmd.Run()
	if err != nil {
		fmt.Println(err)
	}

	cmd = exec.Command("git", "commit", "-am", "\"Add " + newAppName + " app\"")
	err = cmd.Run()
	if err != nil {
		fmt.Println(err)
	}
}

func goToAppDir(newAppName string) {
	err := os.Chdir(newAppName)
	if err != nil {
		fmt.Println(err)
	}
}

func createReadme(newAppName string) {
	readmeFile, err := os.Create("README.md")
	if err != nil {
		fmt.Println(err)
	}
	readmeFile.Close()
}

func initializeGitRepo(newAppName string) {
	cmd := exec.Command("git", "init")
	err := cmd.Run()
	if err != nil {
		fmt.Println(err)
	}

	cmd = exec.Command("git", "add", ".")
	err = cmd.Run()
	if err != nil {
		fmt.Println(err)
	}

	cmd = exec.Command("git", "commit", "-am", "\"Initial commit\"")
	err = cmd.Run()
	if err != nil {
		fmt.Println(err)
	}
}

func createDockerfile(newAppName string) {
	dockerfile, err := os.Create("Dockerfile")
	if err != nil {
		fmt.Println(err)
	}
	dockerfile.Close()
}

func createBuildScript(newAppName string) {
	buildScript, err := os.Create("build.sh")
	if err != nil {
		fmt.Println(err)
	}
	buildScript.Chmod(0755)
	buildScript.Close()
}

{'fraction_non_alphanumeric': 0.16388828750811865, 'fraction_numerical': 0.0034639532366313053, 'mean_word_length': 3.8326359832635983, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3028276', 'n_tokens_mistral': 1870, 'n_tokens_neox': 1813, 'n_words': 408}