Просмотр исходного кода

Merge pull request #69 from overleaf/jpa-bulk-dependency-upgrades

[misc] bulk dependency upgrades
Jakob Ackermann 5 лет назад
Родитель
Сommit
d571daaaa2

+ 15 - 2
services/contacts/.eslintrc

@@ -3,9 +3,9 @@
 // https://github.com/sharelatex/sharelatex-dev-environment
 {
   "extends": [
+    "eslint:recommended",
     "standard",
-    "prettier",
-    "prettier/standard"
+    "prettier"
   ],
   "parserOptions": {
     "ecmaVersion": 2018
@@ -20,6 +20,19 @@
     "mocha": true
   },
   "rules": {
+    // TODO(das7pad): remove overrides after fixing all the violations manually (https://github.com/overleaf/issues/issues/3882#issuecomment-878999671)
+    // START of temporary overrides
+    "array-callback-return": "off",
+    "no-dupe-else-if": "off",
+    "no-var": "off",
+    "no-empty": "off",
+    "node/handle-callback-err": "off",
+    "no-loss-of-precision": "off",
+    "node/no-callback-literal": "off",
+    "node/no-path-concat": "off",
+    "prefer-regex-literals": "off",
+    // END of temporary overrides
+
     // Swap the no-unused-expressions rule with a more chai-friendly one
     "no-unused-expressions": 0,
     "chai-friendly/no-unused-expressions": "error",

+ 1 - 1
services/contacts/.github/dependabot.yml

@@ -20,4 +20,4 @@ updates:
     # future if we reorganise teams
     labels:
       - "dependencies"
-      - "Team-Magma"
+      - "type:maintenance"

+ 1 - 1
services/contacts/.nvmrc

@@ -1 +1 @@
-12.21.0
+12.22.3

+ 5 - 1
services/contacts/.prettierrc

@@ -2,6 +2,10 @@
 # Instead run bin/update_build_scripts from
 # https://github.com/sharelatex/sharelatex-dev-environment
 {
+  "arrowParens": "avoid",
   "semi": false,
-  "singleQuote": true
+  "singleQuote": true,
+  "trailingComma": "es5",
+  "tabWidth": 2,
+  "useTabs": false
 }

+ 1 - 1
services/contacts/Dockerfile

@@ -2,7 +2,7 @@
 # Instead run bin/update_build_scripts from
 # https://github.com/sharelatex/sharelatex-dev-environment
 
-FROM node:12.21.0 as base
+FROM node:12.22.3 as base
 
 WORKDIR /app
 

+ 2 - 2
services/contacts/app.js

@@ -7,7 +7,7 @@
 const Metrics = require('@overleaf/metrics')
 Metrics.initialize('contacts')
 
-const Settings = require('settings-sharelatex')
+const Settings = require('@overleaf/settings')
 const logger = require('logger-sharelatex')
 const express = require('express')
 const bodyParser = require('body-parser')
@@ -60,7 +60,7 @@ if (!module.parent) {
         return logger.info(`contacts starting up, listening on ${host}:${port}`)
       })
     })
-    .catch((err) => {
+    .catch(err => {
       logger.fatal({ err }, 'Cannot connect to mongo. Exiting.')
       process.exit(1)
     })

+ 5 - 5
services/contacts/app/js/ContactManager.js

@@ -33,11 +33,11 @@ module.exports = ContactManager = {
 
     db.contacts.updateOne(
       {
-        user_id
+        user_id,
       },
       update,
       {
-        upsert: true
+        upsert: true,
       },
       callback
     )
@@ -56,7 +56,7 @@ module.exports = ContactManager = {
 
     return db.contacts.findOne(
       {
-        user_id
+        user_id,
       },
       function (error, user) {
         if (error != null) {
@@ -65,9 +65,9 @@ module.exports = ContactManager = {
         return callback(null, user != null ? user.contacts : undefined)
       }
     )
-  }
+  },
 }
-;['touchContact', 'getContacts'].map((method) =>
+;['touchContact', 'getContacts'].map(method =>
   metrics.timeAsyncMethod(
     ContactManager,
     method,

+ 4 - 4
services/contacts/app/js/HttpController.js

@@ -64,16 +64,16 @@ module.exports = HttpController = {
         contacts.push({
           user_id,
           n: data.n,
-          ts: data.ts
+          ts: data.ts,
         })
       }
 
       HttpController._sortContacts(contacts)
       contacts = contacts.slice(0, limit)
-      const contact_ids = contacts.map((contact) => contact.user_id)
+      const contact_ids = contacts.map(contact => contact.user_id)
 
       return res.status(200).send({
-        contact_ids
+        contact_ids,
       })
     })
   },
@@ -96,5 +96,5 @@ module.exports = HttpController = {
         }
       }
     })
-  }
+  },
 }

+ 2 - 2
services/contacts/app/js/mongodb.js

@@ -1,4 +1,4 @@
-const Settings = require('settings-sharelatex')
+const Settings = require('@overleaf/settings')
 const { MongoClient, ObjectId } = require('mongodb')
 
 const clientPromise = MongoClient.connect(
@@ -24,5 +24,5 @@ async function setupDb() {
 module.exports = {
   db,
   ObjectId,
-  waitForDb
+  waitForDb,
 }

+ 2 - 2
services/contacts/buildscript.txt

@@ -3,6 +3,6 @@ contacts
 --docker-repos=gcr.io/overleaf-ops
 --env-add=
 --env-pass-through=
---node-version=12.21.0
+--node-version=12.22.3
 --public-repo=False
---script-version=3.8.0
+--script-version=3.11.0

+ 5 - 5
services/contacts/config/settings.defaults.js

@@ -5,17 +5,17 @@ module.exports = {
   internal: {
     contacts: {
       port: 3036,
-      host: process.env.LISTEN_ADDRESS || 'localhost'
-    }
+      host: process.env.LISTEN_ADDRESS || 'localhost',
+    },
   },
 
   mongo: {
     options: {
       useUnifiedTopology:
-        (process.env.MONGO_USE_UNIFIED_TOPOLOGY || 'true') === 'true'
+        (process.env.MONGO_USE_UNIFIED_TOPOLOGY || 'true') === 'true',
     },
     url:
       process.env.MONGO_CONNECTION_STRING ||
-      `mongodb://${process.env.MONGO_HOST || 'localhost'}/sharelatex`
-  }
+      `mongodb://${process.env.MONGO_HOST || 'localhost'}/sharelatex`,
+  },
 }

+ 2 - 2
services/contacts/docker-compose.yml

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

Разница между файлами не показана из-за своего большого размера
+ 339 - 504
services/contacts/package-lock.json


+ 18 - 23
services/contacts/package.json

@@ -14,43 +14,38 @@
     "test:unit:_run": "mocha --recursive --reporter spec $@ test/unit/js",
     "test:unit": "npm run test:unit:_run -- --grep=$MOCHA_GREP",
     "nodemon": "nodemon --config nodemon.json",
-    "lint": "node_modules/.bin/eslint --max-warnings 0 .",
-    "format": "node_modules/.bin/prettier-eslint $PWD'/**/*.js' --list-different",
-    "format:fix": "node_modules/.bin/prettier-eslint $PWD'/**/*.js' --write"
+    "lint": "eslint --max-warnings 0 --format unix .",
+    "format": "prettier --list-different $PWD/'**/*.js'",
+    "format:fix": "prettier --write $PWD/'**/*.js'",
+    "lint:fix": "eslint --fix ."
   },
   "dependencies": {
     "@overleaf/metrics": "^3.5.1",
+    "@overleaf/settings": "^2.1.1",
     "async": "^2.6.3",
     "body-parser": "^1.19.0",
+    "bunyan": "^1.8.15",
     "express": "^4.17.1",
     "logger-sharelatex": "^2.2.0",
     "mongodb": "^3.6.0",
     "request": "~2.88.2",
-    "settings-sharelatex": "^1.1.0",
     "underscore": "~1.13.1"
   },
   "devDependencies": {
-    "babel-eslint": "^10.1.0",
-    "bunyan": "~1.8.12",
-    "chai": "~4.2.0",
-    "eslint": "^6.8.0",
-    "eslint-config-prettier": "^6.10.0",
-    "eslint-config-standard": "^14.1.0",
-    "eslint-config-standard-jsx": "^8.1.0",
-    "eslint-config-standard-react": "^9.2.0",
-    "eslint-plugin-chai-expect": "^2.1.0",
-    "eslint-plugin-chai-friendly": "^0.5.0",
-    "eslint-plugin-import": "^2.20.1",
-    "eslint-plugin-jsx-a11y": "^6.2.3",
-    "eslint-plugin-mocha": "^6.3.0",
-    "eslint-plugin-node": "^11.0.0",
+    "chai": "^4.2.0",
+    "chai-as-promised": "^7.1.1",
+    "eslint": "^7.21.0",
+    "eslint-config-prettier": "^8.1.0",
+    "eslint-config-standard": "^16.0.2",
+    "eslint-plugin-chai-expect": "^2.2.0",
+    "eslint-plugin-chai-friendly": "^0.6.0",
+    "eslint-plugin-import": "^2.22.1",
+    "eslint-plugin-mocha": "^8.0.0",
+    "eslint-plugin-node": "^11.1.0",
     "eslint-plugin-prettier": "^3.1.2",
     "eslint-plugin-promise": "^4.2.1",
-    "eslint-plugin-react": "^7.19.0",
-    "eslint-plugin-standard": "^4.0.1",
-    "mocha": "^7.1.1",
-    "prettier": "^2.0.0",
-    "prettier-eslint-cli": "^5.0.0",
+    "mocha": "^8.3.2",
+    "prettier": "^2.2.1",
     "sandboxed-module": "~2.0.3",
     "sinon": "~9.0.1",
     "timekeeper": "2.2.0"

+ 2 - 2
services/contacts/test/acceptance/js/ContactsApp.js

@@ -31,7 +31,7 @@ module.exports = {
     this.initing = true
     this.callbacks.push(callback)
     waitForDb().then(() => {
-      return app.listen(3036, 'localhost', (error) => {
+      return app.listen(3036, 'localhost', error => {
         if (error != null) {
           throw error
         }
@@ -45,5 +45,5 @@ module.exports = {
         })()
       })
     })
-  }
+  },
 }

+ 12 - 12
services/contacts/test/acceptance/js/GettingContactsTests.js

@@ -33,7 +33,7 @@ describe('Getting Contacts', function () {
         {
           method: 'GET',
           url: `${HOST}/user/${this.user_id}/contacts`,
-          json: true
+          json: true,
         },
         (error, response, body) => {
           response.statusCode.should.equal(200)
@@ -57,8 +57,8 @@ describe('Getting Contacts', function () {
             method: 'POST',
             url: `${HOST}/user/${user_id}/contacts`,
             json: {
-              contact_id
-            }
+              contact_id,
+            },
           },
           cb
         )
@@ -66,11 +66,11 @@ describe('Getting Contacts', function () {
       return async.series(
         [
           // 2 is preferred since touched twice, then 3 since most recent, then 1
-          (cb) => ContactsApp.ensureRunning(cb),
-          (cb) => touchContact(this.user_id, this.contact_id_1, cb),
-          (cb) => touchContact(this.user_id, this.contact_id_2, cb),
-          (cb) => touchContact(this.user_id, this.contact_id_2, cb),
-          (cb) => touchContact(this.user_id, this.contact_id_3, cb)
+          cb => ContactsApp.ensureRunning(cb),
+          cb => touchContact(this.user_id, this.contact_id_1, cb),
+          cb => touchContact(this.user_id, this.contact_id_2, cb),
+          cb => touchContact(this.user_id, this.contact_id_2, cb),
+          cb => touchContact(this.user_id, this.contact_id_3, cb),
         ],
         done
       )
@@ -81,14 +81,14 @@ describe('Getting Contacts', function () {
         {
           method: 'GET',
           url: `${HOST}/user/${this.user_id}/contacts`,
-          json: true
+          json: true,
         },
         (error, response, body) => {
           response.statusCode.should.equal(200)
           body.contact_ids.should.deep.equal([
             this.contact_id_2,
             this.contact_id_3,
-            this.contact_id_1
+            this.contact_id_1,
           ])
           return done()
         }
@@ -100,13 +100,13 @@ describe('Getting Contacts', function () {
         {
           method: 'GET',
           url: `${HOST}/user/${this.user_id}/contacts?limit=2`,
-          json: true
+          json: true,
         },
         (error, response, body) => {
           response.statusCode.should.equal(200)
           body.contact_ids.should.deep.equal([
             this.contact_id_2,
-            this.contact_id_3
+            this.contact_id_3,
           ])
           return done()
         }

+ 2 - 2
services/contacts/test/setup.js

@@ -3,7 +3,7 @@ const SandboxedModule = require('sandboxed-module')
 SandboxedModule.configure({
   requires: {
     'logger-sharelatex': { log() {} },
-    '@overleaf/metrics': { timeAsyncMethod() {} }
+    '@overleaf/metrics': { timeAsyncMethod() {} },
   },
-  globals: { Buffer, console, process }
+  globals: { Buffer, console, process },
 })

+ 11 - 13
services/contacts/test/unit/js/ContactsManagerTests.js

@@ -25,9 +25,9 @@ describe('ContactManager', function () {
       requires: {
         './mongodb': {
           db: (this.db = { contacts: {} }),
-          ObjectId
-        }
-      }
+          ObjectId,
+        },
+      },
     })
     this.user_id = ObjectId().toString()
     this.contact_id = ObjectId().toString()
@@ -57,19 +57,19 @@ describe('ContactManager', function () {
           .calledWith(
             {
               user_id: sinon.match(
-                (o) => o.toString() === this.user_id.toString()
-              )
+                o => o.toString() === this.user_id.toString()
+              ),
             },
             {
               $inc: {
-                'contacts.mock_contact.n': 1
+                'contacts.mock_contact.n': 1,
               },
               $set: {
-                'contacts.mock_contact.ts': new Date()
-              }
+                'contacts.mock_contact.ts': new Date(),
+              },
             },
             {
-              upsert: true
+              upsert: true,
             }
           )
           .should.equal(true)
@@ -98,7 +98,7 @@ describe('ContactManager', function () {
   return describe('getContacts', function () {
     beforeEach(function () {
       this.user = {
-        contacts: ['mock', 'contacts']
+        contacts: ['mock', 'contacts'],
       }
       return (this.db.contacts.findOne = sinon
         .stub()
@@ -113,9 +113,7 @@ describe('ContactManager', function () {
       it("should find the user's contacts", function () {
         return this.db.contacts.findOne
           .calledWith({
-            user_id: sinon.match(
-              (o) => o.toString() === this.user_id.toString()
-            )
+            user_id: sinon.match(o => o.toString() === this.user_id.toString()),
           })
           .should.equal(true)
       })

+ 6 - 6
services/contacts/test/unit/js/HttpControllerTests.js

@@ -21,8 +21,8 @@ describe('HttpController', function () {
   beforeEach(function () {
     this.HttpController = SandboxedModule.require(modulePath, {
       requires: {
-        './ContactManager': (this.ContactManager = {})
-      }
+        './ContactManager': (this.ContactManager = {}),
+      },
     })
     this.user_id = 'mock-user-id'
     this.contact_id = 'mock-contact-id'
@@ -87,7 +87,7 @@ describe('HttpController', function () {
       this.contacts = {
         'user-id-1': { n: 2, ts: new Date(now) },
         'user-id-2': { n: 4, ts: new Date(now) },
-        'user-id-3': { n: 2, ts: new Date(now - 1000) }
+        'user-id-3': { n: 2, ts: new Date(now - 1000) },
       }
       return (this.ContactManager.getContacts = sinon
         .stub()
@@ -108,7 +108,7 @@ describe('HttpController', function () {
       return it('should return a sorted list of contacts by count and timestamp', function () {
         return this.res.send
           .calledWith({
-            contact_ids: ['user-id-2', 'user-id-1', 'user-id-3']
+            contact_ids: ['user-id-2', 'user-id-1', 'user-id-3'],
           })
           .should.equal(true)
       })
@@ -123,7 +123,7 @@ describe('HttpController', function () {
       return it('should return the most commonly used contacts up to the limit', function () {
         return this.res.send
           .calledWith({
-            contact_ids: ['user-id-2', 'user-id-1']
+            contact_ids: ['user-id-2', 'user-id-1'],
           })
           .should.equal(true)
       })
@@ -140,7 +140,7 @@ describe('HttpController', function () {
       return it('should return an empty list', function () {
         return this.res.send
           .calledWith({
-            contact_ids: []
+            contact_ids: [],
           })
           .should.equal(true)
       })

Некоторые файлы не были показаны из-за большого количества измененных файлов