diff --git a/.gitignore b/.gitignore index a8b670e583..2d01c63836 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ +config +config-local node_modules web document-updater + diff --git a/Gruntfile.coffee b/Gruntfile.coffee index f517e166fc..bb35b07b5c 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -1,6 +1,6 @@ fs = require "fs" -exec = require("child_process").exec spawn = require("child_process").spawn +rimraf = require "rimraf" SERVICES = [{ name: "web" @@ -51,8 +51,9 @@ module.exports = (grunt) -> "Misc": [ "help" ] - "Install tasks": ("install:#{service.name}" for service in SERVICES).concat("install:all") - "Update tasks": ("update:#{service.name}" for service in SERVICES).concat("update:all") + "Install tasks": ("install:#{service.name}" for service in SERVICES).concat(["install:all", "install"]) + "Update tasks": ("update:#{service.name}" for service in SERVICES).concat(["update:all", "update"]) + "Config tasks": ["install:config"] for service in SERVICES do (service) -> @@ -62,7 +63,7 @@ module.exports = (grunt) -> grunt.registerTask "update:#{service.name}", "Checkout and update the #{service.name} service", () -> done = @async() Helpers.updateService(service.name, done) - grunt.registerTask 'run:#{service.name}', "Run the ShareLaTeX #{service.name} service", ["bunyan", "execute:web"] + grunt.registerTask "run:#{service.name}", "Run the ShareLaTeX #{service.name} service", ["bunyan", "execute:web"] grunt.registerTask 'install:all', "Download and set up all ShareLaTeX services", ("install:#{service.name}" for service in SERVICES) grunt.registerTask 'install', 'install:all' @@ -71,6 +72,9 @@ module.exports = (grunt) -> grunt.registerTask 'run', "Run all of the sharelatex processes", ['concurrent:all'] grunt.registerTask 'run:all', 'run' + grunt.registerTask 'install:config', "Install a custom config from a git repository (set SHARELATEX_CONFIG_REPO to the repository location)", () -> + Helpers.installCustomConfig @async() + grunt.registerTask 'help', 'Display this help list', 'availabletasks' grunt.registerTask 'default', 'run' @@ -118,3 +122,15 @@ Helpers = proc = spawn "grunt", ["install"], stdio: "inherit", cwd: dir proc.on "close", () -> callback() + + installCustomConfig: (callback = (error) ->) -> + if !process.env.SHARELATEX_CONFIG_REPO? + return callback(new Error("Please set the SHARELATEX_CONFIG_REPO enviroment variable to point to a git repository.")) + + rimraf "config-local", (error) -> + Helpers.cloneGitRepo process.env.SHARELATEX_CONFIG_REPO, "config-local", (error) -> + return callback(error) if error? + for file in fs.readdirSync("config-local") + unless file == ".git" + fs.symlinkSync("config-local/#{file}", "config/#{file}") + callback() diff --git a/package.json b/package.json index bb2ab4e1aa..29813532b2 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "dependencies": { "logger-sharelatex": "git+ssh://git@bitbucket.org:sharelatex/logger-sharelatex.git#bunyan", "settings-sharelatex": "git+ssh://git@bitbucket.org:sharelatex/settings-sharelatex.git#master", - "coffee-script": "~1.7.1" + "coffee-script": "~1.7.1", + "rimraf": "~2.2.6" }, "devDependencies": { "grunt": "~0.4.2",