import os

def processfile(file):
    
    version = open(file, "r")
    versionlines = version.readlines()

    version = open(file, "w")
    
    for line in versionlines:
        
        print(line)
        
        line = line.replace("const", "")
        line = line.replace("VERSION", "")
        line = line.replace("=", "")
        line = line.replace("\"", "")
        line = line.replace(";", "")
        line = line.replace(" ", "")

        versions = line.split(".")
        versions[3] = str(int(int(versions[3]) + 1))

        newline = "const VERSION = \"" + versions[0] + "." + versions[1] + "."+ versions[2] + "." + versions[3] + "\";"
        print(newline)

        version.write(newline)
    
    version.close()


# folder path

path = os.getcwd()

folders = []

for folder in os.listdir(path):
    # check if current path is a file
    if os.path.isdir(folder):
        if folder != "assets" and folder != "common":
           file = path + "\\" + folder + "\\" + "src" + "\\" + "Version.js"
           if os.path.isfile(file):
                processfile(file)
