Skip to content

Commit 6281cfc

Browse files
committed
fix(ci/server): remove local CWD .json payload
1 parent 7b41cea commit 6281cfc

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

workspaces/server/src/endpoints/data.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { appCache } from "@nodesecure/cache";
88
import type { Request, Response } from "express-serve-static-core";
99

1010
// Import Internal Dependencies
11+
import { context } from "../ALS.js";
1112
import { logger } from "../logger.js";
1213

1314
// CONSTANTS
@@ -31,7 +32,10 @@ export async function get(_req: Request, res: Response) {
3132
catch {
3233
logger.error("[data|get](No cache yet. Creating one...)");
3334

34-
const payload = JSON.parse(fs.readFileSync(kDefaultPayloadPath, "utf-8"));
35+
const { dataFilePath } = context.getStore()!;
36+
37+
const payloadPath = dataFilePath || kDefaultPayloadPath;
38+
const payload = JSON.parse(fs.readFileSync(payloadPath, "utf-8"));
3539
const version = Object.keys(payload.dependencies[payload.rootDependencyName].versions)[0];
3640
const formatted = `${payload.rootDependencyName}@${version}${payload.local ? "#local" : ""}`;
3741
const payloadsList = {

workspaces/server/src/endpoints/report.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export async function post(req: Request, res: Response) {
4949
const body = await bodyParser(req);
5050
const { title, includesAllDeps, theme } = body;
5151
const { dataFilePath } = context.getStore()!;
52+
console.log({ dataFilePath });
53+
5254
const scannerPayload = dataFilePath ?
5355
JSON.parse(fs.readFileSync(dataFilePath, "utf-8")) :
5456
appCache.getPayload((await appCache.payloadsList()).current);

workspaces/server/test/httpServer.test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// Import Node.js Dependencies
2-
import fs from "node:fs";
32
import { fileURLToPath } from "node:url";
43
import { after, before, describe, test } from "node:test";
54
import { once } from "node:events";
@@ -31,7 +30,6 @@ const kConfigKey = "___config";
3130
const kGlobalDispatcher = getGlobalDispatcher();
3231
const kMockAgent = new MockAgent();
3332
const kBundlephobiaPool = kMockAgent.get("https://bundlephobia.com");
34-
const kDefaultPayloadPath = path.join(process.cwd(), "nsecure-result.json");
3533
const kProjectRootDir = path.join(import.meta.dirname, "..", "..", "..");
3634
const kComponentsDir = path.join(kProjectRootDir, "public", "components");
3735

@@ -60,12 +58,6 @@ describe("httpServer", { concurrency: 1 }, () => {
6058
await once(httpServer.server!, "listening");
6159

6260
enableDestroy(httpServer.server!);
63-
64-
if (fs.existsSync(kDefaultPayloadPath) === false) {
65-
// When running tests on CI, we need to create the nsecure-result.json file
66-
const payload = fs.readFileSync(JSON_PATH, "utf-8");
67-
fs.writeFileSync(kDefaultPayloadPath, payload);
68-
}
6961
}, { timeout: 5000 });
7062

7163
after(async() => {

0 commit comments

Comments
 (0)