Skip to content

Commit 96e7d22

Browse files
committed
autogen package.lambda.json
1 parent 0bd695c commit 96e7d22

File tree

6 files changed

+54
-25
lines changed

6 files changed

+54
-25
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,4 @@ __pycache__
143143
/playwright/.cache/
144144
dist_devel/
145145
!src/ui/pages/logs
146+
src/api/package.lambda.json

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"postinstall": "npm run setup",
1313
"setup": "git config blame.ignoreRevsFile .git-blame-ignore-revs",
1414
"build": "concurrently --names 'api,ui' 'yarn workspace infra-core-api run build' 'yarn workspace infra-core-ui run build'",
15-
"postbuild": "yarn lockfile-manage",
15+
"postbuild": "tsx src/api/createLambdaPackage.ts && yarn lockfile-manage",
1616
"dev": "cross-env DISABLE_AUDIT_LOG=true concurrently --names 'api,ui' 'yarn workspace infra-core-api run dev' 'yarn workspace infra-core-ui run dev'",
1717
"lockfile-manage": "synp --with-workspace --source-file yarn.lock",
1818
"postlockfile-manage": "cp package-lock.json dist/lambda/ && cp package-lock.json dist/sqsConsumer/ && cp src/api/package.lambda.json dist/lambda/package.json && cp src/api/package.lambda.json dist/sqsConsumer/package.json && rm package-lock.json",

src/api/createLambdaPackage.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { readFile, writeFile } from "node:fs/promises";
2+
function getPath(url: string) {
3+
const result = new URL(import.meta.url);
4+
const pathname = result.pathname;
5+
const pathArray = pathname.split("/");
6+
const basename = pathArray.pop();
7+
const dirname = pathArray.join("/");
8+
9+
return { pathname, dirname, basename };
10+
}
11+
const packagesToTransfer = [
12+
"moment-timezone",
13+
"passkit-generator",
14+
"fastify",
15+
"@fastify/swagger",
16+
"@fastify/swagger-ui",
17+
"zod",
18+
"argon2",
19+
"ioredis",
20+
];
21+
const filePath = `${getPath("package.json").dirname}/package.json`;
22+
const writeFilePath = `${getPath("package.json").dirname}/package.lambda.json`;
23+
const packageJson = JSON.parse((await readFile(filePath)).toString());
24+
const basePackageJson = {
25+
name: "",
26+
version: "",
27+
description: "",
28+
main: "index.js",
29+
author: "ACM@UIUC",
30+
license: "BSD-3-Clause",
31+
type: "module",
32+
dependencies: {} as Record<string, string>,
33+
devDependencies: {},
34+
};
35+
for (const key in packageJson.dependencies) {
36+
if (packagesToTransfer.includes(key)) {
37+
const version = packageJson.dependencies[key];
38+
basePackageJson.dependencies[key] = version;
39+
}
40+
}
41+
const str = JSON.stringify(basePackageJson);
42+
await writeFile(writeFilePath, str);

src/api/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"jwks-rsa": "^3.2.0",
5353
"lambda-warmer": "^2.3.0",
5454
"moment": "^2.30.1",
55-
"moment-timezone": "^0.5.48",
55+
"moment-timezone": "^0.6.0",
5656
"node-cache": "^5.1.2",
5757
"passkit-generator": "^3.3.1",
5858
"pino": "^9.6.0",
@@ -71,4 +71,4 @@
7171
"nodemon": "^3.1.10",
7272
"pino-pretty": "^13.0.0"
7373
}
74-
}
74+
}

src/api/package.lambda.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

yarn.lock

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7457,13 +7457,20 @@ [email protected]:
74577457
dependencies:
74587458
obliterator "^1.6.1"
74597459

7460-
moment-timezone@^0.5.45, moment-timezone@^0.5.48:
7460+
moment-timezone@^0.5.45:
74617461
version "0.5.48"
74627462
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.48.tgz#111727bb274734a518ae154b5ca589283f058967"
74637463
integrity sha512-f22b8LV1gbTO2ms2j2z13MuPogNoh5UzxL3nzNAYKGraILnbGc9NEE6dyiiiLv46DGRb8A4kg8UKWLjPthxBHw==
74647464
dependencies:
74657465
moment "^2.29.4"
74667466

7467+
moment-timezone@^0.6.0:
7468+
version "0.6.0"
7469+
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.6.0.tgz#c5a6519171f31a64739ea75d33f5c136c08ff608"
7470+
integrity sha512-ldA5lRNm3iJCWZcBCab4pnNL3HSZYXVb/3TYr75/1WCTWYuTqYUb5f/S384pncYjJ88lbO8Z4uPDvmoluHJc8Q==
7471+
dependencies:
7472+
moment "^2.29.4"
7473+
74677474
moment@^2.29.4, moment@^2.30.1:
74687475
version "2.30.1"
74697476
resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae"

0 commit comments

Comments
 (0)