Skip to content
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
6 changes: 1 addition & 5 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ catch {
// Import Node.js Dependencies
import { createRequire } from "node:module";
import path from "node:path";
import { fileURLToPath } from "node:url";

// Import Third-party Dependencies
import * as i18n from "@nodesecure/i18n";
Expand All @@ -24,16 +23,13 @@ import semver from "semver";
import * as commands from "../src/commands/index.js";
import kleur from "../src/utils/styleText.js";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));

// TODO: replace with await import() when available
const require = createRequire(import.meta.url);
const manifest = require("../package.json");

await i18n.getLocalLang();
await i18n.extendFromSystemPath(
path.join(__dirname, "..", "i18n")
path.join(import.meta.dirname, "..", "i18n")
);

console.log(kleur.grey().bold(`\n > ${i18n.getTokenSync("cli.executing_at")}: ${kleur.yellow().bold(process.cwd())}\n`));
Expand Down
9 changes: 3 additions & 6 deletions esbuild.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
// Import Node.js Dependencies
import path from "node:path";
import fs from "node:fs/promises";
import { fileURLToPath } from "node:url";

// Import Third-party Dependencies
import esbuild from "esbuild";
import { getBuildConfiguration } from "@nodesecure/documentation-ui/node";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));

const kPublicDir = path.join(__dirname, "public");
const kOutDir = path.join(__dirname, "dist");
const kPublicDir = path.join(import.meta.dirname, "public");
const kOutDir = path.join(import.meta.dirname, "dist");
const kImagesDir = path.join(kPublicDir, "img");
const kNodeModulesDir = path.join(__dirname, "node_modules");
const kNodeModulesDir = path.join(import.meta.dirname, "node_modules");

await esbuild.build({
entryPoints: [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"devDependencies": {
"@nodesecure/size-satisfies": "^1.1.0",
"@nodesecure/vis-network": "^1.4.0",
"@openally/config.eslint": "^2.1.0",
"@openally/config.eslint": "^2.4.2",
"@openally/config.typescript": "1.2.1",
"@openally/httpie": "^1.0.0",
"@types/node": "^25.0.3",
Expand Down
6 changes: 1 addition & 5 deletions test/commands/cache.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import childProcess from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import { after, before, describe, it } from "node:test";
import url from "node:url";

// Import Third-party Dependencies
import { DEFAULT_PAYLOAD_PATH } from "@nodesecure/cache";
Expand All @@ -23,9 +22,6 @@ import { cache } from "@nodesecure/server";
import { main } from "../../src/commands/cache.js";
import { arrayFromAsync } from "../helpers/utils.js";

// CONSTANTS
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

describe("CLI Commands: cache", { concurrency: 1 }, () => {
let lang;
let actualCache;
Expand All @@ -51,7 +47,7 @@ describe("CLI Commands: cache", { concurrency: 1 }, () => {
}
await i18n.setLocalLang("english");
await i18n.extendFromSystemPath(
path.join(__dirname, "..", "..", "i18n")
path.join(import.meta.dirname, "..", "..", "i18n")
);
lang = await i18n.getLocalLang();

Expand Down
4 changes: 1 addition & 3 deletions test/commands/extract-integrity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ catch {
import assert from "node:assert";
import path from "node:path";
import { describe, test } from "node:test";
import { fileURLToPath } from "node:url";

// Import Internal Dependencies
import { runProcess } from "../helpers/cliCommandRunner.js";
import { arrayFromAsync } from "../helpers/utils.js";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const kProcessDir = path.join(__dirname, "..", "process");
const kProcessDir = path.join(import.meta.dirname, "..", "process");

describe("CLI Commands: extract integrity", () => {
test("should not find an integrity diff", async() => {
Expand Down
4 changes: 1 addition & 3 deletions test/commands/scorecard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import assert from "node:assert";
import fs from "node:fs";
import path from "node:path";
import { describe, test } from "node:test";
import { fileURLToPath } from "node:url";

// Import Third-party Dependencies
import { API_URL } from "@nodesecure/ossf-scorecard-sdk";
Expand All @@ -15,8 +14,7 @@ import { runProcess } from "../helpers/cliCommandRunner.js";
import { arrayFromAsync, getExpectedScorecardLines } from "../helpers/utils.js";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const kProcessDir = path.join(__dirname, "..", "process");
const kProcessDir = path.join(import.meta.dirname, "..", "process");
const kProcessPath = path.join(kProcessDir, "scorecard.js");

describe("CLI Commands: scorecard", () => {
Expand Down
8 changes: 3 additions & 5 deletions test/commands/summary.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ catch {
}

// Import Node.js Dependencies
import { fileURLToPath } from "node:url";
import path from "node:path";
import { describe, it } from "node:test";
import { stripVTControlCharacters } from "node:util";
Expand All @@ -19,8 +18,7 @@ import * as i18n from "@nodesecure/i18n";
import { runProcess } from "../helpers/cliCommandRunner.js";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const kProcessDir = path.join(__dirname, "..", "process");
const kProcessDir = path.join(import.meta.dirname, "..", "process");
const kProcessPath = path.join(kProcessDir, "summary.js");

describe("CLI Commands: summary", () => {
Expand All @@ -46,7 +44,7 @@ describe("CLI Commands: summary", () => {

const processOptions = {
path: kProcessPath,
cwd: path.join(__dirname, "..", "fixtures")
cwd: path.join(import.meta.dirname, "..", "fixtures")
};

for await (const line of runProcess(processOptions)) {
Expand All @@ -66,7 +64,7 @@ describe("CLI Commands: summary", () => {
t.plan(expectedLines.length * 2);
const processOptions = {
path: kProcessPath.replace("summary.js", "summary-zero-dependencies.js"),
cwd: path.join(__dirname, "..", "fixtures")
cwd: path.join(import.meta.dirname, "..", "fixtures")
};

for await (const line of runProcess(processOptions)) {
Expand Down
4 changes: 1 addition & 3 deletions test/commands/verify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ catch {
import assert from "node:assert";
import path from "node:path";
import { describe, test } from "node:test";
import { fileURLToPath } from "node:url";

// Import Internal Dependencies
import { VERIFY_EXPECTED_LINES } from "../fixtures/verifyExpectedStdout.js";
import { runProcess } from "../helpers/cliCommandRunner.js";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const kProcessDir = path.join(__dirname, "..", "process");
const kProcessDir = path.join(import.meta.dirname, "..", "process");
const kExpectVerifyJson = `{
"foo": "bar"
}`.split("\n");
Expand Down
6 changes: 1 addition & 5 deletions test/process/extract-integrity/invalid-spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Import Node.js Dependencies
import path from "node:path";
import { fileURLToPath } from "node:url";

// Import Third-party Dependencies
import * as i18n from "@nodesecure/i18n";
Expand All @@ -9,12 +8,9 @@ import * as i18n from "@nodesecure/i18n";
import * as extractIntegrity from "../../../src/commands/extract-integrity.js";
import { prepareProcess } from "../../helpers/cliCommandRunner.js";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));

await i18n.getLocalLang();
await i18n.extendFromSystemPath(
path.join(__dirname, "..", "..", "..", "i18n")
path.join(import.meta.dirname, "..", "..", "..", "i18n")
);

prepareProcess(extractIntegrity.main, [""]);
6 changes: 1 addition & 5 deletions test/process/extract-integrity/missing-version.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Import Node.js Dependencies
import path from "node:path";
import { fileURLToPath } from "node:url";

// Import Third-party Dependencies
import * as i18n from "@nodesecure/i18n";
Expand All @@ -9,12 +8,9 @@ import * as i18n from "@nodesecure/i18n";
import * as extractIntegrity from "../../../src/commands/extract-integrity.js";
import { prepareProcess } from "../../helpers/cliCommandRunner.js";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));

await i18n.getLocalLang();
await i18n.extendFromSystemPath(
path.join(__dirname, "..", "..", "..", "i18n")
path.join(import.meta.dirname, "..", "..", "..", "i18n")
);

prepareProcess(extractIntegrity.main, ["express"]);
6 changes: 1 addition & 5 deletions test/process/extract-integrity/not-found.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Import Node.js Dependencies
import path from "node:path";
import { fileURLToPath } from "node:url";

// Import Third-party Dependencies
import * as i18n from "@nodesecure/i18n";
Expand All @@ -9,12 +8,9 @@ import * as i18n from "@nodesecure/i18n";
import * as extractIntegrity from "../../../src/commands/extract-integrity.js";
import { prepareProcess } from "../../helpers/cliCommandRunner.js";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));

await i18n.getLocalLang();
await i18n.extendFromSystemPath(
path.join(__dirname, "..", "..", "..", "i18n")
path.join(import.meta.dirname, "..", "..", "..", "i18n")
);

prepareProcess(extractIntegrity.main, ["express@not-found"]);
6 changes: 1 addition & 5 deletions test/process/extract-integrity/valid-spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Import Node.js Dependencies
import path from "node:path";
import { fileURLToPath } from "node:url";

// Import Third-party Dependencies
import * as i18n from "@nodesecure/i18n";
Expand All @@ -9,12 +8,9 @@ import * as i18n from "@nodesecure/i18n";
import * as extractIntegrity from "../../../src/commands/extract-integrity.js";
import { prepareProcess } from "../../helpers/cliCommandRunner.js";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));

await i18n.getLocalLang();
await i18n.extendFromSystemPath(
path.join(__dirname, "..", "..", "..", "i18n")
path.join(import.meta.dirname, "..", "..", "..", "i18n")
);

prepareProcess(extractIntegrity.main, ["express@4.17.1"]);
6 changes: 1 addition & 5 deletions test/process/summary-zero-dependencies.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Import Node.js Dependencies
import path from "node:path";
import url from "node:url";

// Import Third-party Dependencies
import * as i18n from "@nodesecure/i18n";
Expand All @@ -9,12 +8,9 @@ import * as i18n from "@nodesecure/i18n";
import * as summary from "../../src/commands/summary.js";
import { prepareProcess } from "../helpers/cliCommandRunner.js";

// CONSTANTS
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

await i18n.getLocalLang();
await i18n.extendFromSystemPath(
path.join(__dirname, "..", "..", "i18n")
path.join(import.meta.dirname, "..", "..", "i18n")
);

prepareProcess(summary.main, ["result-test2.json"]);
6 changes: 1 addition & 5 deletions test/process/summary.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Import Node.js Dependencies
import path from "node:path";
import url from "node:url";

// Import Third-party Dependencies
import * as i18n from "@nodesecure/i18n";
Expand All @@ -9,12 +8,9 @@ import * as i18n from "@nodesecure/i18n";
import * as summary from "../../src/commands/summary.js";
import { prepareProcess } from "../helpers/cliCommandRunner.js";

// CONSTANTS
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

await i18n.getLocalLang();
await i18n.extendFromSystemPath(
path.join(__dirname, "..", "..", "i18n")
path.join(import.meta.dirname, "..", "..", "i18n")
);

prepareProcess(summary.main, ["result-test1.json"]);
9 changes: 3 additions & 6 deletions workspaces/documentation-ui/esbuild.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
// Import Node.js Dependencies
import path from "node:path";
import fs from "node:fs";
import { fileURLToPath } from "node:url";

// Import Third-party Dependencies
import esbuild from "esbuild";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));

const kMainDir = path.join(__dirname, "example");
const kOutDir = path.join(__dirname, "dist");
const kMainDir = path.join(import.meta.dirname, "example");
const kOutDir = path.join(import.meta.dirname, "dist");

await esbuild.build({
entryPoints: [
path.join(kMainDir, "master.js"),
path.join(__dirname, "src", "css", "main.css")
path.join(import.meta.dirname, "src", "css", "main.css")
],
platform: "browser",
bundle: true,
Expand Down
6 changes: 1 addition & 5 deletions workspaces/documentation-ui/src/nodejs/esm.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
// Import Node.js Dependencies
import { fileURLToPath } from "node:url";
import path from "node:path";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));

export function getBuildConfiguration() {
return {
entryPoints: [
path.join(__dirname, "..", "css", "main.css")
path.join(import.meta.dirname, "..", "css", "main.css")
]
};
}
12 changes: 4 additions & 8 deletions workspaces/server/test/httpServer.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Import Node.js Dependencies
import { fileURLToPath } from "node:url";
import { after, before, describe, test } from "node:test";
import { once } from "node:events";
import type { Server } from "node:http";
Expand All @@ -21,10 +20,7 @@ import * as flagsEndpoint from "../src/endpoints/flags.ts";
// CONSTANTS
const kHttpPort = 17049;
const kHttpURL = new URL(`http://localhost:${kHttpPort}`);
const __dirname = path.dirname(fileURLToPath(import.meta.url));

const JSON_PATH = path.join(__dirname, "fixtures", "httpServer.json");

const kJsonPath = path.join(import.meta.dirname, "fixtures", "httpServer.json");
const kGlobalDispatcher = getGlobalDispatcher();
const kMockAgent = new MockAgent();
const kBundlephobiaPool = kMockAgent.get("https://bundlephobia.com");
Expand All @@ -37,10 +33,10 @@ describe("httpServer", { concurrency: 1 }, () => {
before(async() => {
setGlobalDispatcher(kMockAgent);
await i18n.extendFromSystemPath(
path.join(__dirname, "..", "..", "..", "i18n")
path.join(import.meta.dirname, "..", "..", "..", "i18n")
);

httpServer = buildServer(JSON_PATH, {
httpServer = buildServer(kJsonPath, {
projectRootDir: kProjectRootDir,
componentsDir: kComponentsDir,
i18n: {
Expand Down Expand Up @@ -314,7 +310,7 @@ describe("httpServer without options", () => {
let httpServer: Server;

before(async() => {
httpServer = buildServer(JSON_PATH, {
httpServer = buildServer(kJsonPath, {
projectRootDir: kProjectRootDir,
componentsDir: kComponentsDir,
i18n: {
Expand Down
7 changes: 2 additions & 5 deletions workspaces/vis-network/esbuild.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
// Import Node.js Dependencies
import path from "node:path";
import fs from "node:fs";
import { fileURLToPath } from "node:url";

// Import Third-party Dependencies
import esbuild from "esbuild";
import { getManifest } from "@nodesecure/flags";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));

const kMainDir = path.join(__dirname, "example");
const kOutDir = path.join(__dirname, "dist");
const kMainDir = path.join(import.meta.dirname, "example");
const kOutDir = path.join(import.meta.dirname, "dist");

await esbuild.build({
entryPoints: [
Expand Down
Loading
Loading