mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 02:13:35 -05:00
Support different versions of sharelatex repos
This commit is contained in:
parent
ea9d056e0e
commit
790fc06b31
1 changed files with 33 additions and 15 deletions
|
@ -11,30 +11,39 @@ async = require "async"
|
||||||
SERVICES = [{
|
SERVICES = [{
|
||||||
name: "web"
|
name: "web"
|
||||||
repo: "https://github.com/sharelatex/web-sharelatex.git"
|
repo: "https://github.com/sharelatex/web-sharelatex.git"
|
||||||
|
version: "master"
|
||||||
}, {
|
}, {
|
||||||
name: "document-updater"
|
name: "document-updater"
|
||||||
repo: "https://github.com/sharelatex/document-updater-sharelatex.git"
|
repo: "https://github.com/sharelatex/document-updater-sharelatex.git"
|
||||||
|
version: "master"
|
||||||
}, {
|
}, {
|
||||||
name: "clsi"
|
name: "clsi"
|
||||||
repo: "https://github.com/sharelatex/clsi-sharelatex.git"
|
repo: "https://github.com/sharelatex/clsi-sharelatex.git"
|
||||||
|
version: "master"
|
||||||
}, {
|
}, {
|
||||||
name: "filestore"
|
name: "filestore"
|
||||||
repo: "https://github.com/sharelatex/filestore-sharelatex.git"
|
repo: "https://github.com/sharelatex/filestore-sharelatex.git"
|
||||||
|
version: "master"
|
||||||
}, {
|
}, {
|
||||||
name: "track-changes"
|
name: "track-changes"
|
||||||
repo: "https://github.com/sharelatex/track-changes-sharelatex.git"
|
repo: "https://github.com/sharelatex/track-changes-sharelatex.git"
|
||||||
|
version: "master"
|
||||||
}, {
|
}, {
|
||||||
name: "docstore"
|
name: "docstore"
|
||||||
repo: "https://github.com/sharelatex/docstore-sharelatex.git"
|
repo: "https://github.com/sharelatex/docstore-sharelatex.git"
|
||||||
|
version: "master"
|
||||||
}, {
|
}, {
|
||||||
name: "chat"
|
name: "chat"
|
||||||
repo: "https://github.com/sharelatex/chat-sharelatex.git"
|
repo: "https://github.com/sharelatex/chat-sharelatex.git"
|
||||||
|
version: "master"
|
||||||
}, {
|
}, {
|
||||||
name: "tags"
|
name: "tags"
|
||||||
repo: "https://github.com/sharelatex/tags-sharelatex.git"
|
repo: "https://github.com/sharelatex/tags-sharelatex.git"
|
||||||
|
version: "master"
|
||||||
}, {
|
}, {
|
||||||
name: "spelling"
|
name: "spelling"
|
||||||
repo: "https://github.com/sharelatex/spelling-sharelatex.git"
|
repo: "https://github.com/sharelatex/spelling-sharelatex.git"
|
||||||
|
version: "master"
|
||||||
}]
|
}]
|
||||||
|
|
||||||
module.exports = (grunt) ->
|
module.exports = (grunt) ->
|
||||||
|
@ -86,10 +95,10 @@ module.exports = (grunt) ->
|
||||||
do (service) ->
|
do (service) ->
|
||||||
grunt.registerTask "install:#{service.name}", "Download and set up the #{service.name} service", () ->
|
grunt.registerTask "install:#{service.name}", "Download and set up the #{service.name} service", () ->
|
||||||
done = @async()
|
done = @async()
|
||||||
Helpers.installService(service.repo, service.name, done)
|
Helpers.installService(service, done)
|
||||||
grunt.registerTask "update:#{service.name}", "Checkout and update the #{service.name} service", () ->
|
grunt.registerTask "update:#{service.name}", "Checkout and update the #{service.name} service", () ->
|
||||||
done = @async()
|
done = @async()
|
||||||
Helpers.updateService(service.name, done)
|
Helpers.updateService(service, done)
|
||||||
grunt.registerTask "run:#{service.name}", "Run the ShareLaTeX #{service.name} service", ["bunyan", "execute:#{service.name}"]
|
grunt.registerTask "run:#{service.name}", "Run the ShareLaTeX #{service.name} service", ["bunyan", "execute:#{service.name}"]
|
||||||
|
|
||||||
grunt.registerTask 'install:config', "Copy the example config into the real config", () ->
|
grunt.registerTask 'install:config', "Copy the example config into the real config", () ->
|
||||||
|
@ -133,41 +142,50 @@ module.exports = (grunt) ->
|
||||||
|
|
||||||
|
|
||||||
Helpers =
|
Helpers =
|
||||||
installService: (repo_src, dir, callback = (error) ->) ->
|
installService: (service, callback = (error) ->) ->
|
||||||
Helpers.cloneGitRepo repo_src, dir, (error) ->
|
Helpers.cloneGitRepo service, (error) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
Helpers.installNpmModules dir, (error) ->
|
Helpers.installNpmModules service, (error) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
Helpers.runGruntInstall dir, (error) ->
|
Helpers.runGruntInstall service, (error) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
callback()
|
callback()
|
||||||
|
|
||||||
updateService: (dir, callback = (error) ->) ->
|
updateService: (service, callback = (error) ->) ->
|
||||||
Helpers.updateGitRepo dir, (error) ->
|
Helpers.updateGitRepo service, (error) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
Helpers.installNpmModules dir, (error) ->
|
Helpers.installNpmModules service, (error) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
Helpers.runGruntInstall dir, (error) ->
|
Helpers.runGruntInstall service, (error) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
callback()
|
callback()
|
||||||
|
|
||||||
cloneGitRepo: (repo_src, dir, callback = (error) ->) ->
|
cloneGitRepo: (service, callback = (error) ->) ->
|
||||||
|
repo_src = service.repo
|
||||||
|
dir = service.name
|
||||||
if !fs.existsSync(dir)
|
if !fs.existsSync(dir)
|
||||||
proc = spawn "git", ["clone", repo_src, dir], stdio: "inherit"
|
proc = spawn "git", [
|
||||||
|
"clone",
|
||||||
|
"-b", service.version,
|
||||||
|
repo_src,
|
||||||
|
dir
|
||||||
|
], stdio: "inherit"
|
||||||
proc.on "close", () ->
|
proc.on "close", () ->
|
||||||
callback()
|
callback()
|
||||||
else
|
else
|
||||||
console.log "#{dir} already installed, skipping."
|
console.log "#{dir} already installed, skipping."
|
||||||
callback()
|
callback()
|
||||||
|
|
||||||
updateGitRepo: (dir, callback = (error) ->) ->
|
updateGitRepo: (service, callback = (error) ->) ->
|
||||||
proc = spawn "git", ["checkout", "master"], cwd: dir, stdio: "inherit"
|
dir = service.name
|
||||||
|
proc = spawn "git", ["checkout", service.version], cwd: dir, stdio: "inherit"
|
||||||
proc.on "close", () ->
|
proc.on "close", () ->
|
||||||
proc = spawn "git", ["pull"], cwd: dir, stdio: "inherit"
|
proc = spawn "git", ["pull"], cwd: dir, stdio: "inherit"
|
||||||
proc.on "close", () ->
|
proc.on "close", () ->
|
||||||
callback()
|
callback()
|
||||||
|
|
||||||
installNpmModules: (dir, callback = (error) ->) ->
|
installNpmModules: (service, callback = (error) ->) ->
|
||||||
|
dir = service.name
|
||||||
proc = spawn "npm", ["install"], stdio: "inherit", cwd: dir
|
proc = spawn "npm", ["install"], stdio: "inherit", cwd: dir
|
||||||
proc.on "close", () ->
|
proc.on "close", () ->
|
||||||
callback()
|
callback()
|
||||||
|
|
Loading…
Reference in a new issue