Skip to content

Commit

Permalink
fix(deps): upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sargreal committed Feb 4, 2024
1 parent 35c55dd commit 75f4b91
Show file tree
Hide file tree
Showing 15 changed files with 4,884 additions and 2,934 deletions.
5 changes: 2 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ module.exports = {
{
files: ['plugin/admin/src/**/*.js', 'playground/src/admin/**/*.js'],
parser: '@babel/eslint-parser',
extends: ['eslint:recommended', 'plugin:react/recommended', 'prettier'],
plugins: ['react', 'react-hooks', 'import', 'jsx-a11y'],
extends: ['eslint:recommended', 'plugin:react/recommended', 'prettier', 'plugin:jsx-a11y/recommended'],
plugins: ['react', 'react-hooks', 'import'],
env: {
browser: true,
commonjs: true,
Expand Down Expand Up @@ -120,7 +120,6 @@ module.exports = {
'import/no-named-as-default': 0,
'import/order': 2,
'import/prefer-default-export': 'off',
'jsx-a11y/click-events-have-key-events': 1,
'max-len': [
2,
{
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
strategy:
matrix:
node: [18, 20]
strapi: [4.14, 4.15]
strapi: [4.14, 4.15, 4.19]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@
"release": "multi-semantic-release --ignore-private-packages"
},
"devDependencies": {
"@babel/eslint-parser": "^7.19.1",
"@babel/preset-react": "^7.18.6",
"@commitlint/cli": "^17.4.2",
"@commitlint/config-conventional": "^17.4.2",
"@babel/eslint-parser": "^7.23.10",
"@babel/preset-react": "^7.23.3",
"@commitlint/cli": "^18.6.0",
"@commitlint/config-conventional": "^18.6.0",
"@semantic-release/git": "^10.0.1",
"@feki.de/semantic-release-yarn": "^1.0.1",
"cz-conventional-changelog": "3.3.0",
"eslint": "^8.35.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.1",
"jest": "^29.4.1",
"lint-staged": "^13.2.0",
"husky": "^9.0.10",
"jest": "^29.7.0",
"lint-staged": "^15.2.1",
"multi-semantic-release": "^3.0.2",
"semantic-release": "^19.0.5"
"semantic-release": "^23.0.0"
},
"config": {
"commitizen": {
Expand Down
1 change: 1 addition & 0 deletions playground/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,4 @@ dist
build
.strapi-updater.json
types
.strapi
22 changes: 11 additions & 11 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@
"test": "echo no unittests"
},
"dependencies": {
"@strapi/plugin-i18n": "4.15.0",
"@strapi/plugin-users-permissions": "4.15.0",
"@strapi/strapi": "4.15.0",
"better-sqlite3": "8.2.0",
"dotenv": "^16.0.3",
"lodash.set": "^4.3.2",
"mime-types": "^2.1.27",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"@strapi/plugin-i18n": "4.19.1",
"@strapi/plugin-users-permissions": "4.19.1",
"@strapi/strapi": "4.19.1",
"better-sqlite3": "9.4.0",
"dotenv": "^16.4.1",
"lodash": "^4.17.21",
"mime-types": "^2.1.35",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^5.2.0",
"styled-components": "^5.2.1"
},
"devDependencies": {
"cypress": "^12.7.0",
"start-server-and-test": "^2.0.0"
"cypress": "^13.6.4",
"start-server-and-test": "^2.0.3"
},
"engines": {
"node": ">=14.19.1 <=20.x.x",
Expand Down
2 changes: 1 addition & 1 deletion playground/src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const fs = require('fs')
const path = require('path')
const mime = require('mime-types')
const set = require('lodash.set')
const set = require('lodash/set')
const {
categories,
homepage,
Expand Down
8 changes: 4 additions & 4 deletions plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
},
"dependencies": {
"@strapi/helper-plugin": "^4.15.0",
"axios": "^1.2.2",
"axios": "^1.6.7",
"bottleneck": "^2.19.5",
"jsdom": "^21.1.1",
"jsdom": "^24.0.0",
"showdown": "^2.1.0"
},
"devDependencies": {
"@faker-js/faker": "^7.6.0",
"@faker-js/faker": "^8.4.0",
"@strapi/plugin-i18n": "^4.15.0",
"axios-mock-adapter": "^1.21.2",
"axios-mock-adapter": "^1.22.0",
"lodash": "^4.17.21"
},
"peerDependencies": {
Expand Down
20 changes: 10 additions & 10 deletions providers/deepl/__mocks__/server.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
'use strict'

const { setupServer } = require('msw/node')
const { rest } = require('msw')
const { http, HttpResponse } = require('msw')

function createJsonEndpoint(path, response) {
return rest.get(path, (request, restResponse, context) =>
restResponse(context.status(200), context.json(response(request)))
return http.get(path, (info) =>
HttpResponse.json(response(info), {status: 200})
)
}

function createQueryJsonEndpoint(path, queryResponseMap) {
return rest.get(path, (request, restResponse, context) => {
return http.get(path, ({request}) => {
const response = queryResponseMap[request.url.search]
if (!response) {
console.warn(
`API call ${request.url.toString()} doesn't have a query handler.`
)
return restResponse(context.status(404))
return new HttpResponse(null, {status: 404})
}

return restResponse(context.status(200), context.json(response))
return HttpResponse.json(response,{status: 200})
})
}

function createTextEndpoint(path, response) {
return rest.get(path, (_request, restResponse, context) =>
restResponse(context.status(200), context.text(response))
return http.get(path, () =>
HttpResponse.text(response, {status: 200})
)
}

const notFoundByDefault = rest.get(/.*/, (request, response, context) => {
const notFoundByDefault = http.get(/.*/, ({request}) => {
console.warn(
`API call ${request.url.toString()} doesn't have a query handler.`
)
response(context.status(404))
return new HttpResponse(null, {status: 404})
})

function getServer(...handlers) {
Expand Down
93 changes: 48 additions & 45 deletions providers/deepl/lib/__tests__/deepl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { faker } = require('@faker-js/faker')
const {
stringByteLength,
} = require('strapi-plugin-translate/server/utils/byte-length')
const { rest } = require('msw')
const { http, HttpResponse } = require('msw')

const {
DEEPL_FREE_API,
Expand Down Expand Up @@ -40,41 +40,39 @@ describe('deepl provider', () => {
return matchAuthKey === passedAuthKey
}

const usageHandler = async (req, res, ctx) => {
if (isAuthenticated(req)) {
return res(ctx.json(usage_result))
const usageHandler = async ({ request }) => {
if (isAuthenticated(request)) {
return HttpResponse.json(usage_result, { status: 200 })
}
return res(ctx.status(403))
return new HttpResponse(null, { status: 403 })
}
const translateHandler = async (req, res, ctx) => {
const body = await req.text()
const translateHandler = async ({ request }) => {
const body = await request.text()
if (stringByteLength(body || '') > DEEPL_API_MAX_REQUEST_SIZE) {
console.log({ length: stringByteLength(body || '') })
return res(ctx.status(413))
return new HttpResponse(null, { status: 413 })
}
const params = new URLSearchParams(body)
if (isAuthenticated(req)) {
if (isAuthenticated(request)) {
let text = params.getAll('text')
if (text.length == 0) {
return res(ctx.status(400))
return new HttpResponse(null, { status: 400 })
}
if (text.length > 50) {
return res(ctx.status(413))
return new HttpResponse(null, { status: 413 })
}
let targetLang = params.get('target_lang')
if (!targetLang) {
return res(ctx.status(400))
return new HttpResponse(null, { status: 400 })
}
return res(
ctx.json({
translations: text.map((t) => ({
detected_source_language: 'EN',
text: t,
})),
})
)
return HttpResponse.json({
translations: text.map((t) => ({
detected_source_language: 'EN',
text: t,
})),
})
}
return res(ctx.status(403))
return new HttpResponse(null, { status: 403 })
}
beforeAll(() => {
server = getServer()
Expand Down Expand Up @@ -109,8 +107,8 @@ describe('deepl provider', () => {
})
beforeEach(() => {
server.use(
rest.post(`${DEEPL_FREE_API}/usage`, usageHandler),
rest.post(`${DEEPL_PAID_API}/usage`, usageHandler)
http.get(`${DEEPL_FREE_API}/usage`, usageHandler),
http.get(`${DEEPL_PAID_API}/usage`, usageHandler)
)
})
if (validKey) {
Expand Down Expand Up @@ -141,8 +139,8 @@ describe('deepl provider', () => {
describe('translate', () => {
beforeEach(() => {
server.use(
rest.post(`${DEEPL_FREE_API}/translate`, translateHandler),
rest.post(`${DEEPL_PAID_API}/translate`, translateHandler)
http.post(`${DEEPL_FREE_API}/translate`, translateHandler),
http.post(`${DEEPL_PAID_API}/translate`, translateHandler)
)
})
describe.each([
Expand Down Expand Up @@ -317,7 +315,7 @@ describe('deepl provider', () => {
text: faker.helpers.uniqueArray(
() =>
faker.lorem.paragraphs(
faker.datatype.number({
faker.number.int({
min: DEEPL_API_MAX_REQUEST_SIZE / 2000,
max: DEEPL_API_MAX_REQUEST_SIZE / 200,
})
Expand Down Expand Up @@ -374,17 +372,17 @@ describe('deepl provider', () => {
describe('setup', () => {
beforeEach(() => {
server.use(
rest.post(`${DEEPL_FREE_API}/usage`, usageHandler),
rest.post(`${DEEPL_PAID_API}/usage`, usageHandler),
rest.post(`${deeplTestApi}/v2/usage`, usageHandler)
http.get(`${DEEPL_FREE_API}/usage`, usageHandler),
http.get(`${DEEPL_PAID_API}/usage`, usageHandler),
http.get(`${deeplTestApi}/v2/usage`, usageHandler)
)
})
describe('provider options', () => {
it('key used', async () => {
const deeplProvider = provider.init({
apiKey: authKey,
})

deeplProvider.usage().catch((e) => console.error(e))
await expect(deeplProvider.usage()).resolves.toBeTruthy()
})

Expand All @@ -402,39 +400,44 @@ describe('deepl provider', () => {
requiredParams,
forbiddenParams = []
) => {
const handler = async (req, res, ctx) => {
const body = await req.text()
const handler = async ({ request }) => {
const body = await request.text()
const params = new URLSearchParams(body)

for (const key of forbiddenParams) {
if (params.has(key)) {
res.networkError(`Server should not have received param ${key}`)
return new HttpResponse.text(
`Server should not have received param ${key}`,
{ status: 400 }
)
}
}
for (const key of Object.keys(requiredParams)) {
if (!params.has(key)) {
res.networkError(`Server did not receive required param ${key}`)
return new HttpResponse.text(
`Server did not receive required param ${key}`,
{ status: 400 }
)
} else if (params.get(key) !== requiredParams[key]) {
res.networkError(
return new HttpResponse.text(
`Required param ${key}=${
requiredParams[key]
} did not match received ${key}=${params.get(key)}`
} did not match received ${key}=${params.get(key)}`,
{ status: 400 }
)
}
}

// skip authentication and validation
let text = params.getAll('text')
return res(
ctx.json({
translations: text.map((t) => ({
detected_source_language: 'EN',
text: t,
})),
})
)
return HttpResponse.json({
translations: text.map((t) => ({
detected_source_language: 'EN',
text: t,
})),
})
}
server.use(rest.post(`${DEEPL_PAID_API}/translate`, handler))
server.use(http.post(`${DEEPL_PAID_API}/translate`, handler))
}

it('uses formality when provided', async () => {
Expand Down
8 changes: 4 additions & 4 deletions providers/deepl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
},
"dependencies": {
"bottleneck": "^2.19.5",
"deepl-node": "^1.8.0"
"deepl-node": "^1.11.1"
},
"devDependencies": {
"@faker-js/faker": "^7.6.0",
"@faker-js/faker": "^8.4.0",
"@strapi/plugin-i18n": "^4.15.0",
"jest": "^29.4.1",
"msw": "^1.0.0"
"jest": "^29.7.0",
"msw": "^2.1.5"
},
"peerDependencies": {
"lodash": "*",
Expand Down
Loading

0 comments on commit 75f4b91

Please sign in to comment.