CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/update_version
Views: 804
#!/usr/bin/env python

'''
This updates the version file, which bakes this data into the webapp.

To force an update for users (showing them an information box that they have to update)
wait until deployed and set the "version" in the database.

Goto account -> admin site settings -> required browser version
'''

import argparse, os, time

ROOT = os.path.dirname(os.path.realpath(__file__))
TARGET = os.path.join(ROOT, "packages/util/smc-version.js")

def write_version_file():
    # Create version file, based on the current time
    now = int(time.time())
    v = []
    v.append("/* autogenerated by the update_version script */")
    v.append("exports.version=%s;"%now)
    open(TARGET,'w').write('\n'.join(v) + '\n')
    os.chdir(os.path.join(ROOT, "packages/util"))
    os.system("npm run build")

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Update CoCalc frontend version number')
    args = parser.parse_args()
    write_version_file()