Skip to content

Commit

Permalink
Upgrade all JavaScript dependencies (#9844)
Browse files Browse the repository at this point in the history
* Upgrade all JavaScript dependencies

* Add changeset

* Fix type issues

* Fix ajv imports

* One more fix

* Fix tests
  • Loading branch information
nwalters512 committed May 11, 2024
1 parent fc91cfc commit 901fce8
Show file tree
Hide file tree
Showing 41 changed files with 1,273 additions and 1,137 deletions.
27 changes: 27 additions & 0 deletions .changeset/chilled-dancers-fix.md
@@ -0,0 +1,27 @@
---
'@prairielearn/eslint-plugin': patch
'@prairielearn/prettier-plugin-sql': patch
'@prairielearn/compiled-assets': patch
'@prairielearn/postgres-tools': patch
'@prairielearn/browser-utils': patch
'@prairielearn/opentelemetry': patch
'@prairielearn/signed-token': patch
'@prairielearn/named-locks': patch
'@prairielearn/migrations': patch
'@prairielearn/aws-imds': patch
'@prairielearn/html-ejs': patch
'@prairielearn/postgres': patch
'@prairielearn/sanitize': patch
'@prairielearn/session': patch
'@prairielearn/config': patch
'@prairielearn/logger': patch
'@prairielearn/sentry': patch
'@prairielearn/cache': patch
'@prairielearn/error': patch
'@prairielearn/flash': patch
'@prairielearn/html': patch
'@prairielearn/aws': patch
'@prairielearn/csv': patch
---

Upgrade all JavaScript dependencies
26 changes: 13 additions & 13 deletions apps/grader-host/package.json
Expand Up @@ -11,19 +11,19 @@
"test": "mocha src/**/*.test.{js,ts}"
},
"dependencies": {
"@aws-sdk/client-auto-scaling": "^3.565.0",
"@aws-sdk/client-ecr": "^3.565.0",
"@aws-sdk/client-s3": "^3.565.0",
"@aws-sdk/client-sqs": "^3.565.0",
"@aws-sdk/credential-providers": "^3.565.0",
"@aws-sdk/lib-storage": "^3.565.0",
"@aws-sdk/client-auto-scaling": "^3.574.0",
"@aws-sdk/client-ecr": "^3.574.0",
"@aws-sdk/client-s3": "^3.574.0",
"@aws-sdk/client-sqs": "^3.574.0",
"@aws-sdk/credential-providers": "^3.574.0",
"@aws-sdk/lib-storage": "^3.574.0",
"@prairielearn/aws": "workspace:^",
"@prairielearn/config": "workspace:^",
"@prairielearn/docker-utils": "workspace:^",
"@prairielearn/postgres": "workspace:^",
"@prairielearn/sanitize": "workspace:^",
"@prairielearn/sentry": "workspace:^",
"ajv": "^8.12.0",
"ajv": "^8.13.0",
"async": "^3.2.5",
"async-stacktrace": "^0.0.2",
"byline": "^5.0.0",
Expand All @@ -34,21 +34,21 @@
"tmp": "^0.2.3",
"winston": "^3.13.0",
"winston-transport": "^4.7.0",
"zod": "^3.22.4"
"zod": "^3.23.8"
},
"devDependencies": {
"@types/async": "^3.2.24",
"@types/chai": "^4.3.14",
"@types/chai": "^4.3.16",
"@types/dockerode": "^3.3.29",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.12.2",
"@types/node": "^20.12.11",
"@types/sinon": "^17.0.3",
"@types/tmp": "^0.2.6",
"mocha": "^10.4.0",
"nodemon": "^3.1.0",
"sinon": "^17.0.1",
"tsx": "^4.9.3",
"typescript": "^5.4.3",
"sinon": "^17.0.2",
"tsx": "^4.9.4",
"typescript": "^5.4.5",
"typescript-cp": "^0.1.9"
}
}
5 changes: 2 additions & 3 deletions apps/grader-host/src/lib/receiveFromQueue.js
Expand Up @@ -3,7 +3,7 @@ import ERR from 'async-stacktrace';
import * as async from 'async';
import fs from 'fs-extra';
import * as path from 'path';
import Ajv from 'ajv';
import { Ajv } from 'ajv';
import {
ReceiveMessageCommand,
ChangeMessageVisibilityCommand,
Expand Down Expand Up @@ -115,8 +115,7 @@ export default function (sqs, queueUrl, receiveCallback, doneCallback) {
globalLogger.error('Failed to read message schema; exiting process.');
process.exit(1);
}
// https://github.com/ajv-validator/ajv/issues/2132
const ajv = new Ajv.default();
const ajv = new Ajv();
messageSchema = ajv.compile(data);
return callback(null);
});
Expand Down
66 changes: 33 additions & 33 deletions apps/prairielearn/package.json
Expand Up @@ -13,17 +13,17 @@
"test:dist": "mocha --parallel dist/**/*.test.js"
},
"dependencies": {
"@aws-sdk/client-auto-scaling": "^3.565.0",
"@aws-sdk/client-cloudwatch": "^3.565.0",
"@aws-sdk/client-ec2": "^3.565.0",
"@aws-sdk/client-ecr": "^3.565.0",
"@aws-sdk/client-s3": "^3.565.0",
"@aws-sdk/client-sqs": "^3.565.0",
"@aws-sdk/credential-providers": "^3.565.0",
"@aws-sdk/lib-storage": "^3.565.0",
"@fortawesome/fontawesome-free": "^6.5.1",
"@aws-sdk/client-auto-scaling": "^3.574.0",
"@aws-sdk/client-cloudwatch": "^3.574.0",
"@aws-sdk/client-ec2": "^3.574.0",
"@aws-sdk/client-ecr": "^3.574.0",
"@aws-sdk/client-s3": "^3.574.0",
"@aws-sdk/client-sqs": "^3.574.0",
"@aws-sdk/credential-providers": "^3.574.0",
"@aws-sdk/lib-storage": "^3.574.0",
"@fortawesome/fontawesome-free": "^6.5.2",
"@node-saml/passport-saml": "^4.0.4",
"@octokit/rest": "^20.0.2",
"@octokit/rest": "^20.1.1",
"@prairielearn/aws": "workspace:^",
"@prairielearn/bind-mount": "workspace:^",
"@prairielearn/browser-utils": "workspace:^",
Expand All @@ -50,13 +50,13 @@
"@prairielearn/signed-token": "workspace:^",
"@prairielearn/tsconfig": "workspace:^",
"@prairielearn/workspace-utils": "workspace:^",
"@sentry/profiling-node": "^7.109.0",
"@sentry/tracing": "^7.109.0",
"@sentry/profiling-node": "^7.114.0",
"@sentry/tracing": "^7.114.0",
"@socket.io/redis-adapter": "^8.3.0",
"@viz-js/viz": "^3.4.0",
"@viz-js/viz": "^3.5.0",
"ace-builds": "^1.33.1",
"ace-code": "^1.33.1",
"ajv": "^8.12.0",
"ajv": "^8.13.0",
"ansi_up": "^6.0.2",
"archiver": "^7.0.1",
"async": "^3.2.5",
Expand Down Expand Up @@ -86,7 +86,7 @@
"debug": "^4.3.4",
"delegated-events": "^1.1.2",
"dockerode": "^4.0.2",
"dompurify": "^3.0.11",
"dompurify": "^3.1.2",
"dropzone": "^5.9.3",
"ejs": "^3.1.10",
"es-main": "^1.3.0",
Expand All @@ -102,16 +102,16 @@
"folder-hash": "^4.0.4",
"fs-extra": "^11.2.0",
"generic-pool": "^3.9.0",
"google-auth-library": "^9.7.0",
"google-auth-library": "^9.9.0",
"he": "^1.2.0",
"highlight.js": "^11.9.0",
"htmx.org": "^1.9.11",
"htmx.org": "^1.9.12",
"http-proxy-middleware": "^2.0.6",
"http-status": "^1.7.4",
"ioredis": "^5.3.2",
"ioredis": "^5.4.1",
"isbinaryfile": "^5.0.2",
"jju": "^1.4.0",
"jose": "^5.2.3",
"jose": "^5.3.0",
"jquery": "^3.7.1",
"jquery-ui-dist": "^1.13.2",
"jquery-ui-touch-punch": "^0.2.3",
Expand All @@ -120,7 +120,7 @@
"klaw": "^4.1.0",
"lodash": "^4.17.21",
"loopbench": "^2.0.0",
"lru-cache": "^10.2.0",
"lru-cache": "^10.2.2",
"mathjax": "^3.2.2",
"memorystream": "^0.3.1",
"mersenne": "0.0.4",
Expand All @@ -140,12 +140,12 @@
"passport": "^0.7.0",
"passport-azure-ad": "^4.3.5",
"pem": "^1.14.8",
"pg": "^8.11.4",
"pg": "^8.11.5",
"plist": "^3.1.0",
"popper.js": "^1.16.1",
"postgres-interval": "^4.0.2",
"qrcode-svg": "^1.1.0",
"qs": "^6.12.0",
"qs": "^6.12.1",
"quill": "^1.3.7",
"quilljs-markdown": "^1.2.0",
"rehype-raw": "^5.1.0",
Expand All @@ -165,7 +165,7 @@
"socket.io-client": "^4.7.5",
"streamifier": "^0.1.1",
"strip-ansi": "^6.0.1",
"stripe": "^14.23.0",
"stripe": "^14.25.0",
"tablesorter": "^2.31.3",
"tar": "^6.2.1",
"three": "0.160.1",
Expand All @@ -180,19 +180,19 @@
"xml-formatter": "^3.6.2",
"xml2js": "^0.6.2",
"yargs-parser": "^21.1.1",
"zod": "^3.22.4"
"zod": "^3.23.8"
},
"devDependencies": {
"@prairielearn/tsconfig": "workspace:^",
"@sa11y/format": "^6.6.1",
"@sa11y/format": "^6.7.0",
"@types/archiver": "^6.0.2",
"@types/async": "^3.2.24",
"@types/blocked": "^1.3.4",
"@types/blocked-at": "^1.0.4",
"@types/body-parser": "^1.19.5",
"@types/bootstrap": "^4.6.6",
"@types/byline": "^4.2.36",
"@types/chai": "^4.3.14",
"@types/chai": "^4.3.16",
"@types/chai-as-promised": "^7.1.8",
"@types/cookie-parser": "^1.4.7",
"@types/crypto-js": "^4.2.2",
Expand All @@ -203,20 +203,20 @@
"@types/folder-hash": "^4.0.4",
"@types/fs-extra": "^11.0.4",
"@types/jju": "^1.4.5",
"@types/jquery": "^3.5.29",
"@types/jquery": "^3.5.30",
"@types/js-cookie": "^3.0.6",
"@types/jsdom": "^21.1.6",
"@types/json-stable-stringify": "^1.0.36",
"@types/json-stringify-safe": "^5.0.3",
"@types/klaw": "^3.0.6",
"@types/lodash": "^4.17.0",
"@types/lodash": "^4.17.1",
"@types/loopbench": "^1.2.4",
"@types/memorystream": "^0.3.4",
"@types/mime": "^3.0.4",
"@types/mocha": "^10.0.6",
"@types/multer": "^1.4.11",
"@types/mustache": "^4.2.5",
"@types/node": "^20.12.2",
"@types/node": "^20.12.11",
"@types/node-fetch": "^2.6.11",
"@types/node-jose": "^1.1.13",
"@types/oauth-signature": "^1.5.2",
Expand All @@ -225,12 +225,12 @@
"@types/passport": "^1.0.16",
"@types/passport-azure-ad": "^4.3.6",
"@types/pem": "^1.14.4",
"@types/pg": "^8.11.4",
"@types/pg": "^8.11.6",
"@types/qrcode-svg": "^1.1.4",
"@types/request": "^2.48.12",
"@types/serve-favicon": "^2.5.7",
"@types/streamifier": "^0.1.2",
"@types/tar": "^6.1.11",
"@types/tar": "^6.1.13",
"@types/tmp": "^0.2.6",
"@types/unzipper": "^0.10.9",
"@types/uuid": "^9.0.8",
Expand All @@ -245,8 +245,8 @@
"mocha": "^10.4.0",
"mocha-steps": "^1.3.0",
"set-cookie-parser": "^2.6.0",
"tsx": "^4.9.3",
"typescript": "^5.4.3",
"tsx": "^4.9.4",
"typescript": "^5.4.5",
"typescript-cp": "^0.1.9"
},
"nodemonConfig": {
Expand Down
4 changes: 2 additions & 2 deletions apps/prairielearn/src/lib/json-load.js
@@ -1,11 +1,11 @@
// @ts-check
import * as fs from 'fs/promises';
import jju from 'jju';
import Ajv from 'ajv';
import { Ajv } from 'ajv';

// We use a single global instance so that schemas aren't recompiled every time they're used
// https://github.com/ajv-validator/ajv/issues/2132
const ajv = new Ajv.default();
const ajv = new Ajv();

/**
* Asynchronously reads the specified JSON file.
Expand Down
2 changes: 1 addition & 1 deletion apps/prairielearn/src/lib/load.js
Expand Up @@ -148,7 +148,7 @@ export function startJob(jobType, id, maxJobCount) {

export function endJob(jobType, id) {
debug(`endJob(): jobType = ${jobType}, id = ${id}`);
if (!_.has(estimators, jobType)) throw new Error(`endJob(): no such estimator: ${jobType}`);
if (!(jobType in estimators)) throw new Error(`endJob(): no such estimator: ${jobType}`);
estimators[jobType].endJob(id);
}

Expand Down
6 changes: 3 additions & 3 deletions apps/prairielearn/src/question-servers/freeform.js
Expand Up @@ -1345,7 +1345,7 @@ export async function render(
};

for (let type in question.dependencies) {
if (!_.has(dependencies, type)) continue;
if (!(type in dependencies)) continue;

for (let dep of question.dependencies[type]) {
if (!_.includes(dependencies[type], dep)) {
Expand Down Expand Up @@ -1412,7 +1412,7 @@ export async function render(
}

for (const type in elementDependencies) {
if (!_.has(dependencies, type)) continue;
if (!(type in dependencies)) continue;

for (const dep of elementDependencies[type]) {
if (!_.includes(dependencies[type], dep)) {
Expand Down Expand Up @@ -1471,7 +1471,7 @@ export async function render(
}

for (const type in extension) {
if (!_.has(dependencies, type)) continue;
if (!(type in dependencies)) continue;

for (const dep of extension[type]) {
if (!_.includes(dependencies[type], dep)) {
Expand Down
5 changes: 2 additions & 3 deletions apps/prairielearn/src/sync/course-db.ts
Expand Up @@ -3,7 +3,7 @@ import _ from 'lodash';
import fs from 'fs-extra';
import * as async from 'async';
import jju from 'jju';
import Ajv, { type JSONSchemaType } from 'ajv';
import { Ajv, type JSONSchemaType } from 'ajv';
import betterAjvErrors from 'better-ajv-errors';
import { parseISO, isValid, isAfter, isFuture } from 'date-fns';

Expand All @@ -19,8 +19,7 @@ import { features } from '../lib/features/index.js';
const perf = makePerformance('course-db');

// We use a single global instance so that schemas aren't recompiled every time they're used
// https://github.com/ajv-validator/ajv/issues/2132
const ajv = new Ajv.default({ allErrors: true });
const ajv = new Ajv({ allErrors: true });

const DEFAULT_QUESTION_INFO = {
type: 'Calculation',
Expand Down
8 changes: 3 additions & 5 deletions apps/prairielearn/src/tests/schemas.test.ts
@@ -1,4 +1,4 @@
import Ajv from 'ajv';
import { Ajv } from 'ajv';
import { assert } from 'chai';
import * as schemas from '../schemas/index.js';

Expand Down Expand Up @@ -37,15 +37,13 @@ for (const schemaName of Object.keys(schemas)) {
describe(`${schemaName} schema`, () => {
const schema = schemas[schemaName];
it('compiles', () => {
// https://github.com/ajv-validator/ajv/issues/2132
const ajv = new Ajv.default();
const ajv = new Ajv();
const validate = ajv.compile(schema);
assert.isFunction(validate);
});

it('validates', () => {
// https://github.com/ajv-validator/ajv/issues/2132
const ajv = new Ajv.default();
const ajv = new Ajv();
const valid = ajv.validateSchema(schema);
if (ajv.errors) {
console.error(ajv.errors);
Expand Down

0 comments on commit 901fce8

Please sign in to comment.