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

Upgrade to Node 12
This commit is contained in:
Eric Mc Sween 2021-03-25 07:55:05 -04:00 committed by GitHub
commit 08043a4aa0
29 changed files with 767 additions and 312 deletions

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

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

@ -3,6 +3,6 @@ real-time
--docker-repos=gcr.io/overleaf-ops --docker-repos=gcr.io/overleaf-ops
--env-add= --env-add=
--env-pass-through= --env-pass-through=
--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

@ -6,7 +6,7 @@ version: "2.3"
services: services:
test_unit: test_unit:
image: node:10.23.1 image: node:12.21.0
volumes: volumes:
- .:/app - .:/app
working_dir: /app working_dir: /app
@ -18,7 +18,7 @@ services:
user: node user: node
test_acceptance: test_acceptance:
image: node:10.23.1 image: node:12.21.0
volumes: volumes:
- .:/app - .:/app
working_dir: /app working_dir: /app

File diff suppressed because it is too large Load diff

View file

@ -54,11 +54,11 @@
"eslint-plugin-prettier": "^3.1.2", "eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-promise": "^4.2.1", "eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1", "eslint-plugin-standard": "^4.0.1",
"mocha": "^4.0.1", "mocha": "^8.3.2",
"prettier": "^2.0.0", "prettier": "^2.0.0",
"prettier-eslint-cli": "^5.0.0", "prettier-eslint-cli": "^5.0.0",
"sandboxed-module": "~0.3.0", "sandboxed-module": "~0.3.0",
"sinon": "^2.4.1", "sinon": "^9.2.4",
"timekeeper": "0.0.4", "timekeeper": "0.0.4",
"uid-safe": "^2.1.5" "uid-safe": "^2.1.5"
} }

View file

@ -13,9 +13,7 @@
* 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 async = require('async') const async = require('async')
const chai = require('chai') const { expect } = require('chai')
const { expect } = chai
chai.should()
const RealTimeClient = require('./helpers/RealTimeClient') const RealTimeClient = require('./helpers/RealTimeClient')
const FixturesManager = require('./helpers/FixturesManager') const FixturesManager = require('./helpers/FixturesManager')

View file

@ -12,9 +12,7 @@
* DS207: Consider shorter variations of null checks * DS207: Consider shorter variations of null checks
* 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 chai = require('chai') const { expect } = require('chai')
const { expect } = chai
chai.should()
const RealTimeClient = require('./helpers/RealTimeClient') const RealTimeClient = require('./helpers/RealTimeClient')
const MockWebServer = require('./helpers/MockWebServer') const MockWebServer = require('./helpers/MockWebServer')

View file

@ -11,9 +11,7 @@
* 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 chai = require('chai') const { expect } = require('chai')
const { expect } = chai
chai.should()
const RealTimeClient = require('./helpers/RealTimeClient') const RealTimeClient = require('./helpers/RealTimeClient')
const MockDocUpdaterServer = require('./helpers/MockDocUpdaterServer') const MockDocUpdaterServer = require('./helpers/MockDocUpdaterServer')

View file

@ -10,9 +10,7 @@
* 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 chai = require('chai') const { expect } = require('chai')
const { expect } = chai
chai.should()
const RealTimeClient = require('./helpers/RealTimeClient') const RealTimeClient = require('./helpers/RealTimeClient')
const MockWebServer = require('./helpers/MockWebServer') const MockWebServer = require('./helpers/MockWebServer')

View file

@ -13,9 +13,7 @@
* DS207: Consider shorter variations of null checks * DS207: Consider shorter variations of null checks
* 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 chai = require('chai') const { expect } = require('chai')
const { expect } = chai
chai.should()
const sinon = require('sinon') const sinon = require('sinon')
const RealTimeClient = require('./helpers/RealTimeClient') const RealTimeClient = require('./helpers/RealTimeClient')

View file

@ -47,8 +47,7 @@ There is additional meta-data that UserItems and SessionItems may use to skip
/* eslint-disable /* eslint-disable
camelcase, camelcase,
*/ */
const chai = require('chai') const { expect } = require('chai')
const { expect } = chai
const async = require('async') const async = require('async')
const RealTimeClient = require('./helpers/RealTimeClient') const RealTimeClient = require('./helpers/RealTimeClient')

View file

@ -11,9 +11,7 @@
* DS207: Consider shorter variations of null checks * DS207: Consider shorter variations of null checks
* 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 chai = require('chai') const { expect } = require('chai')
const { expect } = chai
chai.should()
const RealTimeClient = require('./helpers/RealTimeClient') const RealTimeClient = require('./helpers/RealTimeClient')
const MockWebServer = require('./helpers/MockWebServer') const MockWebServer = require('./helpers/MockWebServer')

View file

@ -11,8 +11,7 @@
* DS207: Consider shorter variations of null checks * DS207: Consider shorter variations of null checks
* 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 chai = require('chai') const { expect } = require('chai')
const { expect } = chai
const RealTimeClient = require('./helpers/RealTimeClient') const RealTimeClient = require('./helpers/RealTimeClient')

View file

@ -0,0 +1,38 @@
const chai = require('chai')
const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon')
// Chai configuration
chai.should()
// Global stubs
const sandbox = sinon.createSandbox()
const stubs = {
logger: {
debug: sandbox.stub(),
log: sandbox.stub(),
info: sandbox.stub(),
warn: sandbox.stub(),
err: sandbox.stub(),
error: sandbox.stub()
}
}
// SandboxedModule configuration
SandboxedModule.configure({
requires: {
'logger-sharelatex': stubs.logger
},
globals: { Buffer, JSON, console, process }
})
// Mocha hooks
exports.mochaHooks = {
beforeEach() {
this.logger = stubs.logger
},
afterEach() {
sandbox.reset()
}
}

View file

@ -9,9 +9,7 @@
* 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 chai = require('chai') const { expect } = require('chai')
chai.should()
const { expect } = chai
const sinon = require('sinon') const sinon = require('sinon')
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const path = require('path') const path = require('path')

View file

@ -9,9 +9,7 @@
* 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 chai = require('chai') const { expect } = require('chai')
const should = chai.should()
const { expect } = chai
const sinon = require('sinon') const sinon = require('sinon')
const modulePath = '../../../app/js/ChannelManager.js' const modulePath = '../../../app/js/ChannelManager.js'
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
@ -26,11 +24,6 @@ describe('ChannelManager', function () {
'@overleaf/metrics': (this.metrics = { '@overleaf/metrics': (this.metrics = {
inc: sinon.stub(), inc: sinon.stub(),
summary: sinon.stub() summary: sinon.stub()
}),
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
warn: sinon.stub(),
error: sinon.stub()
}) })
} }
})) }))

View file

@ -12,7 +12,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 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')
@ -58,7 +57,6 @@ describe('ConnectedUsersManager', function () {
this.ConnectedUsersManager = SandboxedModule.require(modulePath, { this.ConnectedUsersManager = SandboxedModule.require(modulePath, {
requires: { requires: {
'settings-sharelatex': this.settings, 'settings-sharelatex': this.settings,
'logger-sharelatex': { log() {} },
'@overleaf/redis-wrapper': { '@overleaf/redis-wrapper': {
createClient: () => { createClient: () => {
return this.rClient return this.rClient

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/DocumentUpdaterController' '../../../app/js/DocumentUpdaterController'
@ -29,11 +28,6 @@ describe('DocumentUpdaterController', function () {
this.RoomEvents = { on: sinon.stub() } this.RoomEvents = { on: sinon.stub() }
this.EditorUpdatesController = SandboxedModule.require(modulePath, { this.EditorUpdatesController = SandboxedModule.require(modulePath, {
requires: { requires: {
'logger-sharelatex': (this.logger = {
error: sinon.stub(),
log: sinon.stub(),
warn: sinon.stub()
}),
'settings-sharelatex': (this.settings = { 'settings-sharelatex': (this.settings = {
redis: { redis: {
documentupdater: { documentupdater: {

View file

@ -10,7 +10,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
*/ */
require('chai').should()
const sinon = require('sinon') const sinon = require('sinon')
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const path = require('path') const path = require('path')
@ -43,11 +42,6 @@ describe('DocumentUpdaterManager', function () {
return (this.DocumentUpdaterManager = SandboxedModule.require(modulePath, { return (this.DocumentUpdaterManager = SandboxedModule.require(modulePath, {
requires: { requires: {
'settings-sharelatex': this.settings, 'settings-sharelatex': this.settings,
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
error: sinon.stub(),
warn: sinon.stub()
}),
request: (this.request = {}), request: (this.request = {}),
'@overleaf/redis-wrapper': { createClient: () => this.rclient }, '@overleaf/redis-wrapper': { createClient: () => this.rclient },
'@overleaf/metrics': (this.Metrics = { '@overleaf/metrics': (this.Metrics = {
@ -56,9 +50,6 @@ describe('DocumentUpdaterManager', function () {
done() {} done() {}
}) })
}) })
},
globals: {
JSON: (this.JSON = Object.create(JSON))
} }
})) }))
}) // avoid modifying JSON object directly }) // avoid modifying JSON object directly
@ -325,7 +316,9 @@ describe('DocumentUpdaterManager', function () {
describe('with null byte corruption', function () { describe('with null byte corruption', function () {
beforeEach(function () { beforeEach(function () {
this.JSON.stringify = () => '["bad bytes! \u0000 <- here"]' this.stringifyStub = sinon
.stub(JSON, 'stringify')
.callsFake(() => '["bad bytes! \u0000 <- here"]')
return this.DocumentUpdaterManager.queueChange( return this.DocumentUpdaterManager.queueChange(
this.project_id, this.project_id,
this.doc_id, this.doc_id,
@ -334,6 +327,10 @@ describe('DocumentUpdaterManager', function () {
) )
}) })
afterEach(function () {
this.stringifyStub.restore()
})
it('should return an error', function () { it('should return an error', function () {
return this.callback return this.callback
.calledWithExactly(sinon.match(Error)) .calledWithExactly(sinon.match(Error))

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 sinon = require('sinon') const sinon = require('sinon')
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const path = require('path') const path = require('path')
@ -17,11 +16,7 @@ const modulePath = path.join(__dirname, '../../../app/js/DrainManager')
describe('DrainManager', function () { describe('DrainManager', function () {
beforeEach(function () { beforeEach(function () {
this.DrainManager = SandboxedModule.require(modulePath, { this.DrainManager = SandboxedModule.require(modulePath, {})
requires: {
'logger-sharelatex': (this.logger = { log: sinon.stub() })
}
})
return (this.io = { return (this.io = {
sockets: { sockets: {
clients: sinon.stub() clients: sinon.stub()

View file

@ -8,7 +8,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
*/ */
require('chai').should()
const { expect } = require('chai') const { expect } = require('chai')
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const modulePath = '../../../app/js/EventLogger' const modulePath = '../../../app/js/EventLogger'
@ -21,10 +20,6 @@ describe('EventLogger', function () {
tk.freeze(new Date(this.start)) tk.freeze(new Date(this.start))
this.EventLogger = SandboxedModule.require(modulePath, { this.EventLogger = SandboxedModule.require(modulePath, {
requires: { requires: {
'logger-sharelatex': (this.logger = {
error: sinon.stub(),
warn: sinon.stub()
}),
'@overleaf/metrics': (this.metrics = { inc: sinon.stub() }) '@overleaf/metrics': (this.metrics = { inc: sinon.stub() })
} }
}) })

View file

@ -10,9 +10,7 @@
* 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 chai = require('chai') const { expect } = require('chai')
const { expect } = chai
const should = chai.should()
const sinon = require('sinon') const sinon = require('sinon')
const modulePath = '../../../app/js/RoomManager.js' const modulePath = '../../../app/js/RoomManager.js'
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
@ -26,11 +24,6 @@ describe('RoomManager', function () {
this.RoomManager = SandboxedModule.require(modulePath, { this.RoomManager = SandboxedModule.require(modulePath, {
requires: { requires: {
'settings-sharelatex': (this.settings = {}), 'settings-sharelatex': (this.settings = {}),
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
warn: sinon.stub(),
error: sinon.stub()
}),
'@overleaf/metrics': (this.metrics = { gauge: sinon.stub() }) '@overleaf/metrics': (this.metrics = { gauge: sinon.stub() })
} }
}) })

View file

@ -11,11 +11,9 @@
* 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
*/ */
require('chai').should()
const { expect } = require('chai') const { expect } = require('chai')
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const modulePath = '../../../app/js/SafeJsonParse' const modulePath = '../../../app/js/SafeJsonParse'
const sinon = require('sinon')
describe('SafeJsonParse', function () { describe('SafeJsonParse', function () {
beforeEach(function () { beforeEach(function () {
@ -23,8 +21,7 @@ describe('SafeJsonParse', function () {
requires: { requires: {
'settings-sharelatex': (this.Settings = { 'settings-sharelatex': (this.Settings = {
maxUpdateSize: 16 * 1024 maxUpdateSize: 16 * 1024
}), })
'logger-sharelatex': (this.logger = { error: sinon.stub() })
} }
})) }))
}) })

View file

@ -9,8 +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 chai = require('chai')
const should = chai.should()
const sinon = require('sinon') const sinon = require('sinon')
const modulePath = '../../../app/js/WebApiManager.js' const modulePath = '../../../app/js/WebApiManager.js'
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
@ -33,10 +31,6 @@ describe('WebApiManager', function () {
pass: 'password' pass: 'password'
} }
} }
}),
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
error: sinon.stub()
}) })
} }
})) }))

View file

@ -12,10 +12,8 @@
* 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 chai = require('chai')
const should = chai.should()
const sinon = require('sinon') const sinon = require('sinon')
const { expect } = chai const { expect } = require('chai')
const modulePath = '../../../app/js/WebsocketController.js' const modulePath = '../../../app/js/WebsocketController.js'
const SandboxedModule = require('sandboxed-module') const SandboxedModule = require('sandboxed-module')
const tk = require('timekeeper') const tk = require('timekeeper')
@ -50,11 +48,6 @@ describe('WebsocketController', function () {
'./DocumentUpdaterManager': (this.DocumentUpdaterManager = {}), './DocumentUpdaterManager': (this.DocumentUpdaterManager = {}),
'./ConnectedUsersManager': (this.ConnectedUsersManager = {}), './ConnectedUsersManager': (this.ConnectedUsersManager = {}),
'./WebsocketLoadBalancer': (this.WebsocketLoadBalancer = {}), './WebsocketLoadBalancer': (this.WebsocketLoadBalancer = {}),
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
error: sinon.stub(),
warn: sinon.stub()
}),
'@overleaf/metrics': (this.metrics = { '@overleaf/metrics': (this.metrics = {
inc: sinon.stub(), inc: sinon.stub(),
set: sinon.stub() set: sinon.stub()

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/WebsocketLoadBalancer' '../../../app/js/WebsocketLoadBalancer'
@ -26,10 +25,6 @@ describe('WebsocketLoadBalancer', function () {
'./RedisClientManager': { './RedisClientManager': {
createClientList: () => [] createClientList: () => []
}, },
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
error: sinon.stub()
}),
'./SafeJsonParse': (this.SafeJsonParse = { './SafeJsonParse': (this.SafeJsonParse = {
parse: (data, cb) => cb(null, JSON.parse(data)) parse: (data, cb) => cb(null, JSON.parse(data))
}), }),