Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade CARTS to Node 18 #139609

Merged
merged 9 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env_example
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fmapTableArn=local_nonsense_if_unset_we_search_CF_for
uploadsTableName=local-uploads
uploadsTableArn=local_nonsense_if_unset_we_search_CF_for
stateTableName=local-state
stateStatusTableArn=local_nonsense_if_unset_we_search_CF_for
stateTableArn=local_nonsense_if_unset_we_search_CF_for
stateStatusTableName=local-state-status
stateStatusTableArn=local_nonsense_if_unset_we_search_CF_for
sectionBaseTableName=local-section-base
Expand All @@ -27,7 +27,7 @@ API_URL=http://localhost:3030/local
S3_LOCAL_ENDPOINT=http://localhost:4569
S3_ATTACHMENTS_BUCKET_NAME=local-uploads
URL=http://localhost/3000
docraptorApiKey=YOUR_API_KEY_HERE
docraptorApiKey=YOUR_API_KEY_HERE #pragma: allowlist secret
warmupSchedule="60 minutes"
warmupConcurrency=5
iamPath=/
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.19.1
v18.17.0
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
},
"homepage": "https://github.com/Enterprise-CMCS/macpro-mdct-carts#readme",
"devDependencies": {
"@types/dotenv": "^8.2.0",
gmrabian marked this conversation as resolved.
Show resolved Hide resolved
"@types/flat": "^5.0.2",
"@types/node": "^14.14.6",
"@types/node": "^18.17.0",
"@types/yargs": "^15.0.10",
"@typescript-eslint/eslint-plugin": "5.18.0",
"@typescript-eslint/parser": "5.18.0",
"dotenv": "^8.2.0",
"dotenv": "^16.4.5",
"eslint": "8.12.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-cypress": "^2.12.1",
Expand All @@ -45,11 +44,10 @@
"serverless-dotenv-plugin": "^3.0.0",
"serverless-iam-helper": "github:Enterprise-CMCS/serverless-iam-helper",
"serverless-idempotency-helper": "github:Enterprise-CMCS/serverless-idempotency-helper",
"serverless-offline": "^8.8.0",
"serverless-offline": "^12.0.4",
"serverless-offline-ssm": "^6.2.0",
"serverless-online": "Enterprise-CMCS/macpro-serverless-online",
"serverless-plugin-scripts": "^1.0.2",
"serverless-plugin-warmup": "^7.1.0",
"serverless-s3-bucket-helper": "github:Enterprise-CMCS/serverless-s3-bucket-helper#master",
"serverless-s3-sync": "2.0.0",
"serverless-stack-termination-protection": "^2.0.0",
Expand Down
1 change: 0 additions & 1 deletion services/app-api/handlers/printing/printPdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import handler from "../../libs/handler-lib";
import * as logger from "../../libs/debug-lib";
import createDOMPurify from "dompurify";
import { JSDOM } from "jsdom";
import { fetch } from "cross-fetch"; // TODO delete this line and uninstall this package, once CARTS is running on Nodejs 18+

const windowEmulator: any = new JSDOM("").window;
const DOMPurify = createDOMPurify(windowEmulator);
Expand Down
28 changes: 14 additions & 14 deletions services/app-api/handlers/printing/tests/printPdf.test.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { testEvent } from "../../../test-util/testEvents";
import { APIGatewayProxyEvent } from "../../../types";
import { print } from "../printPdf";
import { fetch } from "cross-fetch";

jest.spyOn(console, "error").mockImplementation();
jest.spyOn(console, "warn").mockImplementation();
global.fetch = jest.fn().mockImplementationOnce(() => {
return new Promise((resolve) => {
resolve({
status: 200,
headers: {
get: jest.fn().mockResolvedValue("3"),
},
arrayBuffer: jest.fn().mockResolvedValue(
// An ArrayBuffer containing `%PDF-1.7`
new Uint8Array([37, 80, 68, 70, 45, 49, 46, 55]).buffer
),
});
});
});

jest.mock("../../../libs/authorization", () => ({
isAuthorized: jest.fn().mockReturnValue(true),
}));

jest.mock("cross-fetch", () => ({
fetch: jest.fn().mockResolvedValue({
status: 200,
headers: {
get: jest.fn().mockResolvedValue("3"),
},
arrayBuffer: jest.fn().mockResolvedValue(
// An ArrayBuffer containing `%PDF-1.7`
new Uint8Array([37, 80, 68, 70, 45, 49, 46, 55]).buffer
),
}),
}));

const html = "<p>abc</p>";
const base64EncodedHtml = Buffer.from(html).toString("base64");

Expand Down
1 change: 0 additions & 1 deletion services/app-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"@aws-sdk/lib-dynamodb": "^3.540.0",
"@aws-sdk/s3-request-presigner": "^3.521.0",
"aws-jwt-verify": "^3.1.0",
"cross-fetch": "^4.0.0",
gmrabian marked this conversation as resolved.
Show resolved Hide resolved
"dompurify": "^3.0.10",
"jsdom": "^22.1.0",
"jsonpath-plus": "^5.1.0",
Expand Down
6 changes: 4 additions & 2 deletions services/app-api/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ frameworkVersion: "3"
package:
individually: true

useDotenv: true
plugins:
- serverless-plugin-typescript
- serverless-dotenv-plugin
- serverless-plugin-warmup
- serverless-associate-waf
- serverless-offline
Expand Down Expand Up @@ -39,6 +39,8 @@ custom:
- main
- val
- production
dotenv:
path: ../../.env
gmrabian marked this conversation as resolved.
Show resolved Hide resolved
accountId: ${AWS::AccountId}
acsTableName: ${env:acsTableName, cf:database-${self:custom.stage}.AcsTableName}
acsTableArn: ${env:acsTableArn, cf:database-${self:custom.stage}.AcsTableArn}
Expand Down Expand Up @@ -84,7 +86,7 @@ custom:
prod: aws_iam
provider:
name: aws
runtime: nodejs16.x
runtime: nodejs18.x
region: us-east-1
tracing:
apiGateway: true
Expand Down
32 changes: 0 additions & 32 deletions services/app-api/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2414,13 +2414,6 @@ convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0:
dependencies:
safe-buffer "~5.1.1"

cross-fetch@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-4.0.0.tgz#f037aef1580bb3a1a35164ea2a848ba81b445983"
integrity sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==
dependencies:
node-fetch "^2.6.12"

cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
Expand Down Expand Up @@ -3677,13 +3670,6 @@ nise@^5.1.2:
just-extend "^4.0.2"
path-to-regexp "^1.7.0"

node-fetch@^2.6.12:
version "2.7.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d"
integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==
dependencies:
whatwg-url "^5.0.0"

node-int64@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
Expand Down Expand Up @@ -4216,11 +4202,6 @@ tr46@^4.1.1:
dependencies:
punycode "^2.3.0"

tr46@~0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==

ts-jest@^27.1.3:
version "27.1.3"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-27.1.3.tgz#1f723e7e74027c4da92c0ffbd73287e8af2b2957"
Expand Down Expand Up @@ -4344,11 +4325,6 @@ walker@^1.0.7:
dependencies:
makeerror "1.0.12"

webidl-conversions@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==

webidl-conversions@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff"
Expand Down Expand Up @@ -4396,14 +4372,6 @@ whatwg-url@^12.0.0, whatwg-url@^12.0.1:
tr46 "^4.1.1"
webidl-conversions "^7.0.0"

whatwg-url@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==
dependencies:
tr46 "~0.0.3"
webidl-conversions "^3.0.0"

whatwg-url@^8.0.0, whatwg-url@^8.5.0:
version "8.7.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-8.7.0.tgz#656a78e510ff8f3937bc0bcbe9f5c0ac35941b77"
Expand Down
2 changes: 1 addition & 1 deletion services/carts-bigmac-streams/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ custom:

provider:
name: aws
runtime: nodejs16.x
runtime: nodejs18.x
region: us-east-1
iam:
role:
Expand Down
7 changes: 5 additions & 2 deletions services/database/handlers/seed/services/seedRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ const buildSeedRunner = () => {
const endpoint = process.env.DYNAMODB_URL;
if (endpoint) {
dynamoConfig.endpoint = endpoint;
dynamoConfig.accessKeyId = "LOCALFAKEKEY"; // pragma: allowlist secret
dynamoConfig.secretAccessKey = "LOCALFAKESECRET"; // pragma: allowlist secret
dynamoConfig.region = "localhost";
dynamoConfig.credentials = {
accessKeyId: "LOCALFAKEKEY", // pragma: allowlist secret
secretAccessKey: "LOCALFAKESECRET", // pragma: allowlist secret
};
dynamoPrefix = "local";
} else {
dynamoConfig["region"] = "us-east-1";
Expand Down
7 changes: 5 additions & 2 deletions services/database/scripts/utils/dynamodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ const buildDynamoClient = () => {
const endpoint = process.env.DYNAMODB_URL;
if (endpoint) {
dynamoConfig.endpoint = endpoint;
dynamoConfig.accessKeyId = "LOCALFAKEKEY"; // pragma: allowlist secret
dynamoConfig.secretAccessKey = "LOCALFAKESECRET"; // pragma: allowlist secret
dynamoConfig.region = "localhost";
dynamoConfig.credentials = {
accessKeyId: "LOCALFAKEKEY", // pragma: allowlist secret
secretAccessKey: "LOCALFAKESECRET", // pragma: allowlist secret
};
} else {
dynamoConfig["region"] = "us-east-1";
}
Expand Down
2 changes: 1 addition & 1 deletion services/database/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ custom:
seed: ${self:custom.seedOptions.${self:custom.stage}, self:custom.seedOptions.default}
provider:
name: aws
runtime: nodejs16.x
runtime: nodejs18.x
region: us-east-1
iam:
role:
Expand Down
2 changes: 1 addition & 1 deletion services/ui-auth/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package:

provider:
name: aws
runtime: nodejs16.x
runtime: nodejs18.x
region: us-east-1
iam:
role:
Expand Down
2 changes: 1 addition & 1 deletion services/ui-src/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins:

provider:
name: aws
runtime: nodejs16.x
runtime: nodejs18.x
region: us-east-1

s3BucketHelper:
Expand Down
2 changes: 1 addition & 1 deletion services/ui/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ frameworkVersion: "3"

provider:
name: aws
runtime: nodejs16.x
runtime: nodejs18.x
region: us-east-1
iam:
role:
Expand Down
2 changes: 1 addition & 1 deletion services/uploads/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins:

provider:
name: aws
runtime: nodejs16.x
runtime: nodejs18.x
region: us-east-1
iam:
role:
Expand Down
Loading
Loading