Merge pull request #214 from overleaf/em-upgrade-node-12

Upgrade to Node 12
This commit is contained in:
Eric Mc Sween 2021-03-16 08:37:26 -04:00 committed by GitHub
commit 0e1da3fd0d
33 changed files with 39 additions and 87 deletions

View file

@ -8,3 +8,4 @@ nodemon.json
cache/ cache/
compiles/ compiles/
db/ db/
output/

View file

@ -0,0 +1,3 @@
{
"require": "test/setup.js"
}

View file

@ -1 +1 @@
10.23.1 12.21.0

View file

@ -2,7 +2,7 @@
# Instead run bin/update_build_scripts from # Instead run bin/update_build_scripts from
# https://github.com/sharelatex/sharelatex-dev-environment # https://github.com/sharelatex/sharelatex-dev-environment
FROM node:10.23.1 as base FROM node:12.21.0 as base
WORKDIR /app WORKDIR /app
COPY install_deps.sh /app COPY install_deps.sh /app
@ -23,6 +23,6 @@ FROM base
COPY --from=app /app /app COPY --from=app /app /app
RUN mkdir -p cache compiles db output \ RUN mkdir -p cache compiles db output \
&& chown node:node cache compiles db output && chown node:node cache compiles db output
CMD ["node", "--expose-gc", "app.js"] CMD ["node", "--expose-gc", "app.js"]

View file

@ -21,8 +21,10 @@ DOCKER_COMPOSE_TEST_UNIT = \
COMPOSE_PROJECT_NAME=test_unit_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) COMPOSE_PROJECT_NAME=test_unit_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE)
clean: clean:
docker rmi ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) -docker rmi ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
docker rmi gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) -docker rmi gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
-$(DOCKER_COMPOSE_TEST_UNIT) down --rmi local
-$(DOCKER_COMPOSE_TEST_ACCEPTANCE) down --rmi local
format: format:
$(DOCKER_COMPOSE) run --rm test_unit npm run --silent format $(DOCKER_COMPOSE) run --rm test_unit npm run --silent format

View file

@ -1,9 +1,9 @@
clsi clsi
--data-dirs=cache,compiles,db --data-dirs=cache,compiles,db,output
--dependencies= --dependencies=
--docker-repos=gcr.io/overleaf-ops --docker-repos=gcr.io/overleaf-ops
--env-add= --env-add=
--env-pass-through=TEXLIVE_IMAGE --env-pass-through=TEXLIVE_IMAGE
--node-version=10.23.1 --node-version=12.21.0
--public-repo=True --public-repo=True
--script-version=3.4.0 --script-version=3.7.0

View file

@ -10,7 +10,6 @@
*/ */
const Client = require('./helpers/Client') const Client = require('./helpers/Client')
const request = require('request') const request = require('request')
require('chai').should()
const ClsiApp = require('./helpers/ClsiApp') const ClsiApp = require('./helpers/ClsiApp')
describe('Broken LaTeX file', function () { describe('Broken LaTeX file', function () {

View file

@ -10,7 +10,6 @@
*/ */
const Client = require('./helpers/Client') const Client = require('./helpers/Client')
const request = require('request') const request = require('request')
require('chai').should()
const ClsiApp = require('./helpers/ClsiApp') const ClsiApp = require('./helpers/ClsiApp')
describe('Deleting Old Files', function () { describe('Deleting Old Files', function () {

View file

@ -17,7 +17,6 @@
*/ */
const Client = require('./helpers/Client') const Client = require('./helpers/Client')
const request = require('request') const request = require('request')
require('chai').should()
const fs = require('fs') const fs = require('fs')
const fsExtra = require('fs-extra') const fsExtra = require('fs-extra')
const ChildProcess = require('child_process') const ChildProcess = require('child_process')

View file

@ -10,7 +10,6 @@
*/ */
const Client = require('./helpers/Client') const Client = require('./helpers/Client')
const request = require('request') const request = require('request')
require('chai').should()
const ClsiApp = require('./helpers/ClsiApp') const ClsiApp = require('./helpers/ClsiApp')
describe('Simple LaTeX file', function () { describe('Simple LaTeX file', function () {

View file

@ -11,7 +11,6 @@
*/ */
const Client = require('./helpers/Client') const Client = require('./helpers/Client')
const request = require('request') const request = require('request')
require('chai').should()
const { expect } = require('chai') const { expect } = require('chai')
const ClsiApp = require('./helpers/ClsiApp') const ClsiApp = require('./helpers/ClsiApp')
const crypto = require('crypto') const crypto = require('crypto')

View file

@ -10,7 +10,6 @@
*/ */
const Client = require('./helpers/Client') const Client = require('./helpers/Client')
const request = require('request') const request = require('request')
require('chai').should()
const ClsiApp = require('./helpers/ClsiApp') const ClsiApp = require('./helpers/ClsiApp')
describe('Timed out compile', function () { describe('Timed out compile', function () {

View file

@ -11,7 +11,6 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/ */
const Client = require('./helpers/Client') const Client = require('./helpers/Client')
require('chai').should()
const sinon = require('sinon') const sinon = require('sinon')
const ClsiApp = require('./helpers/ClsiApp') const ClsiApp = require('./helpers/ClsiApp')

View file

@ -11,7 +11,6 @@
*/ */
const Client = require('./helpers/Client') const Client = require('./helpers/Client')
const request = require('request') const request = require('request')
require('chai').should()
const { expect } = require('chai') const { expect } = require('chai')
const path = require('path') const path = require('path')
const fs = require('fs') const fs = require('fs')

View file

@ -0,0 +1,19 @@
const chai = require('chai')
const SandboxedModule = require('sandboxed-module')
// Setup should interface
chai.should()
// Global SandboxedModule settings
SandboxedModule.configure({
requires: {
'logger-sharelatex': {
log() {},
info() {},
warn() {},
error() {},
err() {}
}
},
globals: { Buffer, console, process }
})

View file

@ -11,7 +11,6 @@
*/ */
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon') const sinon = require('sinon')
require('chai').should()
const { expect } = require('chai') const { expect } = require('chai')
const modulePath = require('path').join( const modulePath = require('path').join(
__dirname, __dirname,
@ -32,13 +31,7 @@ describe('CompileController', function () {
} }
} }
}), }),
'./ProjectPersistenceManager': (this.ProjectPersistenceManager = {}), './ProjectPersistenceManager': (this.ProjectPersistenceManager = {})
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
error: sinon.stub(),
err: sinon.stub(),
warn: sinon.stub()
})
} }
}) })
this.Settings.externalUrl = 'http://www.example.com' this.Settings.externalUrl = 'http://www.example.com'

View file

@ -15,7 +15,6 @@
*/ */
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon') const sinon = require('sinon')
require('chai').should()
const modulePath = require('path').join( const modulePath = require('path').join(
__dirname, __dirname,
'../../../app/js/CompileManager' '../../../app/js/CompileManager'
@ -47,7 +46,6 @@ describe('CompileManager', function () {
} }
}), }),
'logger-sharelatex': (this.logger = { log: sinon.stub(), info() {} }),
child_process: (this.child_process = {}), child_process: (this.child_process = {}),
'./CommandRunner': (this.CommandRunner = {}), './CommandRunner': (this.CommandRunner = {}),
'./DraftModeManager': (this.DraftModeManager = {}), './DraftModeManager': (this.DraftModeManager = {}),

View file

@ -12,7 +12,6 @@
*/ */
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon') const sinon = require('sinon')
require('chai').should()
const modulePath = require('path').join( const modulePath = require('path').join(
__dirname, __dirname,
'../../../app/js/ContentTypeMapper' '../../../app/js/ContentTypeMapper'

View file

@ -11,7 +11,6 @@
*/ */
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon') const sinon = require('sinon')
require('chai').should()
const modulePath = require('path').join( const modulePath = require('path').join(
__dirname, __dirname,
'../../../app/js/DockerLockManager' '../../../app/js/DockerLockManager'
@ -21,11 +20,7 @@ describe('LockManager', function () {
beforeEach(function () { beforeEach(function () {
return (this.LockManager = SandboxedModule.require(modulePath, { return (this.LockManager = SandboxedModule.require(modulePath, {
requires: { requires: {
'settings-sharelatex': (this.Settings = { clsi: { docker: {} } }), 'settings-sharelatex': (this.Settings = { clsi: { docker: {} } })
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
error: sinon.stub()
})
} }
})) }))
}) })

View file

@ -15,7 +15,6 @@
*/ */
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon') const sinon = require('sinon')
require('chai').should()
const { expect } = require('chai') const { expect } = require('chai')
const modulePath = require('path').join( const modulePath = require('path').join(
__dirname, __dirname,
@ -33,12 +32,6 @@ describe('DockerRunner', function () {
clsi: { docker: {} }, clsi: { docker: {} },
path: {} path: {}
}), }),
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
error: sinon.stub(),
info: sinon.stub(),
warn: sinon.stub()
}),
dockerode: (Docker = (function () { dockerode: (Docker = (function () {
Docker = class Docker { Docker = class Docker {
static initClass() { static initClass() {

View file

@ -10,7 +10,6 @@
*/ */
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon') const sinon = require('sinon')
require('chai').should()
const modulePath = require('path').join( const modulePath = require('path').join(
__dirname, __dirname,
'../../../app/js/DraftModeManager' '../../../app/js/DraftModeManager'
@ -20,8 +19,7 @@ describe('DraftModeManager', function () {
beforeEach(function () { beforeEach(function () {
return (this.DraftModeManager = SandboxedModule.require(modulePath, { return (this.DraftModeManager = SandboxedModule.require(modulePath, {
requires: { requires: {
fs: (this.fs = {}), fs: (this.fs = {})
'logger-sharelatex': (this.logger = { log() {} })
} }
})) }))
}) })

View file

@ -11,7 +11,6 @@
*/ */
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon') const sinon = require('sinon')
require('chai').should()
const modulePath = require('path').join( const modulePath = require('path').join(
__dirname, __dirname,
'../../../app/js/LatexRunner' '../../../app/js/LatexRunner'
@ -28,10 +27,6 @@ describe('LatexRunner', function () {
socketPath: '/var/run/docker.sock' socketPath: '/var/run/docker.sock'
} }
}), }),
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
error: sinon.stub()
}),
'./Metrics': { './Metrics': {
Timer: (Timer = class Timer { Timer: (Timer = class Timer {
done() {} done() {}

View file

@ -11,7 +11,6 @@
*/ */
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon') const sinon = require('sinon')
require('chai').should()
const modulePath = require('path').join( const modulePath = require('path').join(
__dirname, __dirname,
'../../../app/js/LockManager' '../../../app/js/LockManager'
@ -24,11 +23,6 @@ describe('DockerLockManager', function () {
this.LockManager = SandboxedModule.require(modulePath, { this.LockManager = SandboxedModule.require(modulePath, {
requires: { requires: {
'settings-sharelatex': {}, 'settings-sharelatex': {},
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
error: sinon.stub(),
err() {}
}),
fs: { fs: {
lstat: sinon.stub().callsArgWith(1), lstat: sinon.stub().callsArgWith(1),
readdir: sinon.stub().callsArgWith(1) readdir: sinon.stub().callsArgWith(1)

View file

@ -12,7 +12,6 @@
*/ */
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon') const sinon = require('sinon')
require('chai').should()
const modulePath = require('path').join( const modulePath = require('path').join(
__dirname, __dirname,
'../../../app/js/OutputFileFinder' '../../../app/js/OutputFileFinder'
@ -26,8 +25,7 @@ describe('OutputFileFinder', function () {
this.OutputFileFinder = SandboxedModule.require(modulePath, { this.OutputFileFinder = SandboxedModule.require(modulePath, {
requires: { requires: {
fs: (this.fs = {}), fs: (this.fs = {}),
child_process: { spawn: (this.spawn = sinon.stub()) }, child_process: { spawn: (this.spawn = sinon.stub()) }
'logger-sharelatex': { log: sinon.stub(), warn: sinon.stub() }
}, },
globals: { globals: {
Math // used by lodash Math // used by lodash

View file

@ -12,7 +12,6 @@
*/ */
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon') const sinon = require('sinon')
require('chai').should()
const modulePath = require('path').join( const modulePath = require('path').join(
__dirname, __dirname,
'../../../app/js/OutputFileOptimiser' '../../../app/js/OutputFileOptimiser'
@ -28,7 +27,6 @@ describe('OutputFileOptimiser', function () {
fs: (this.fs = {}), fs: (this.fs = {}),
path: (this.Path = {}), path: (this.Path = {}),
child_process: { spawn: (this.spawn = sinon.stub()) }, child_process: { spawn: (this.spawn = sinon.stub()) },
'logger-sharelatex': { log: sinon.stub(), warn: sinon.stub() },
'./Metrics': {} './Metrics': {}
}, },
globals: { Math } // used by lodash globals: { Math } // used by lodash

View file

@ -13,7 +13,6 @@
*/ */
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon') const sinon = require('sinon')
require('chai').should()
const assert = require('chai').assert const assert = require('chai').assert
const modulePath = require('path').join( const modulePath = require('path').join(
__dirname, __dirname,
@ -28,11 +27,6 @@ describe('ProjectPersistenceManager', function () {
'./UrlCache': (this.UrlCache = {}), './UrlCache': (this.UrlCache = {}),
'./CompileManager': (this.CompileManager = {}), './CompileManager': (this.CompileManager = {}),
diskusage: (this.diskusage = { check: sinon.stub() }), diskusage: (this.diskusage = { check: sinon.stub() }),
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
warn: sinon.stub(),
err: sinon.stub()
}),
'settings-sharelatex': (this.settings = { 'settings-sharelatex': (this.settings = {
project_cache_length_ms: 1000 project_cache_length_ms: 1000
}), }),

View file

@ -11,7 +11,6 @@
*/ */
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon') const sinon = require('sinon')
require('chai').should()
const { expect } = require('chai') const { expect } = require('chai')
const modulePath = require('path').join( const modulePath = require('path').join(
__dirname, __dirname,

View file

@ -12,7 +12,6 @@
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon') const sinon = require('sinon')
const { expect } = require('chai') const { expect } = require('chai')
const should = require('chai').should()
const modulePath = require('path').join( const modulePath = require('path').join(
__dirname, __dirname,
'../../../app/js/ResourceStateManager' '../../../app/js/ResourceStateManager'
@ -26,7 +25,6 @@ describe('ResourceStateManager', function () {
singleOnly: true, singleOnly: true,
requires: { requires: {
fs: (this.fs = {}), fs: (this.fs = {}),
'logger-sharelatex': { log: sinon.stub(), err: sinon.stub() },
'./SafeReader': (this.SafeReader = {}) './SafeReader': (this.SafeReader = {})
} }
}) })

View file

@ -13,7 +13,6 @@
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon') const sinon = require('sinon')
const { expect } = require('chai') const { expect } = require('chai')
const should = require('chai').should()
const modulePath = require('path').join( const modulePath = require('path').join(
__dirname, __dirname,
'../../../app/js/ResourceWriter' '../../../app/js/ResourceWriter'
@ -34,7 +33,6 @@ describe('ResourceWriter', function () {
wrench: (this.wrench = {}), wrench: (this.wrench = {}),
'./UrlCache': (this.UrlCache = {}), './UrlCache': (this.UrlCache = {}),
'./OutputFileFinder': (this.OutputFileFinder = {}), './OutputFileFinder': (this.OutputFileFinder = {}),
'logger-sharelatex': { log: sinon.stub(), err: sinon.stub() },
'./Metrics': (this.Metrics = { './Metrics': (this.Metrics = {
inc: sinon.stub(), inc: sinon.stub(),
Timer: (Timer = (function () { Timer: (Timer = (function () {
@ -407,7 +405,7 @@ describe('ResourceWriter', function () {
}) })
return it('should not return an error if the resource writer errored', function () { return it('should not return an error if the resource writer errored', function () {
return should.not.exist(this.callback.args[0][0]) return expect(this.callback.args[0][0]).not.to.exist
}) })
}) })

View file

@ -9,7 +9,6 @@
* DS102: Remove unnecessary code created because of implicit returns * DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/ */
const should = require('chai').should()
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const assert = require('assert') const assert = require('assert')
const path = require('path') const path = require('path')
@ -32,11 +31,6 @@ describe('StaticServerForbidSymlinks', function () {
this.ForbidSymlinks = SandboxedModule.require(modulePath, { this.ForbidSymlinks = SandboxedModule.require(modulePath, {
requires: { requires: {
'settings-sharelatex': this.settings, 'settings-sharelatex': this.settings,
'logger-sharelatex': {
log() {},
warn() {},
error() {}
},
fs: this.fs fs: this.fs
} }
}) })

View file

@ -10,7 +10,6 @@
*/ */
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon') const sinon = require('sinon')
require('chai').should()
const modulePath = require('path').join( const modulePath = require('path').join(
__dirname, __dirname,
'../../../app/js/TikzManager' '../../../app/js/TikzManager'
@ -22,8 +21,7 @@ describe('TikzManager', function () {
requires: { requires: {
'./ResourceWriter': (this.ResourceWriter = {}), './ResourceWriter': (this.ResourceWriter = {}),
'./SafeReader': (this.SafeReader = {}), './SafeReader': (this.SafeReader = {}),
fs: (this.fs = {}), fs: (this.fs = {})
'logger-sharelatex': (this.logger = { log() {} })
} }
})) }))
}) })

View file

@ -12,7 +12,6 @@
*/ */
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon') const sinon = require('sinon')
require('chai').should()
const modulePath = require('path').join(__dirname, '../../../app/js/UrlCache') const modulePath = require('path').join(__dirname, '../../../app/js/UrlCache')
const { EventEmitter } = require('events') const { EventEmitter } = require('events')
@ -25,7 +24,6 @@ describe('UrlCache', function () {
requires: { requires: {
'./db': {}, './db': {},
'./UrlFetcher': (this.UrlFetcher = {}), './UrlFetcher': (this.UrlFetcher = {}),
'logger-sharelatex': (this.logger = { log: sinon.stub() }),
'settings-sharelatex': (this.Settings = { 'settings-sharelatex': (this.Settings = {
path: { clsiCacheDir: '/cache/dir' } path: { clsiCacheDir: '/cache/dir' }
}), }),

View file

@ -11,7 +11,6 @@
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon') const sinon = require('sinon')
const { expect } = require('chai') const { expect } = require('chai')
require('chai').should()
const modulePath = require('path').join(__dirname, '../../../app/js/UrlFetcher') const modulePath = require('path').join(__dirname, '../../../app/js/UrlFetcher')
const { EventEmitter } = require('events') const { EventEmitter } = require('events')
@ -25,10 +24,6 @@ describe('UrlFetcher', function () {
defaults: (this.defaults = sinon.stub().returns((this.request = {}))) defaults: (this.defaults = sinon.stub().returns((this.request = {})))
}, },
fs: (this.fs = {}), fs: (this.fs = {}),
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
error: sinon.stub()
}),
'settings-sharelatex': (this.settings = {}) 'settings-sharelatex': (this.settings = {})
} }
})) }))