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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@arethetypeswrong/cli": "^0.18.2",
"@changesets/changelog-github": "^0.6.0",
"@changesets/cli": "^2.29.4",
"@openally/config.eslint": "^2.1.0",
"@openally/config.eslint": "^2.4.2",
"@openally/config.typescript": "1.2.1",
"@slimio/is": "^2.0.0",
"@types/node": "^25.3.3",
Expand Down
4 changes: 1 addition & 3 deletions workspaces/conformance/test/extract.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Import Node.js Dependencies
import path from "node:path";
import assert from "node:assert";
import { fileURLToPath } from "node:url";
import { describe, it } from "node:test";

// Import Third-party Dependencies
Expand All @@ -15,8 +14,7 @@ import {
import expectedParsedLicense from "./fixtures/parseLicense.snap.ts";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const kFixturePath = path.join(__dirname, "fixtures");
const kFixturePath = path.join(import.meta.dirname, "fixtures");
const kFixtureProjectOne = path.join(kFixturePath, "project1");
const kFixtureProjectTwo = path.join(kFixturePath, "project2");

Expand Down
8 changes: 3 additions & 5 deletions workspaces/contact/test/ContactExtractor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Import Node.js Dependencies
import assert from "node:assert";
import { describe, test } from "node:test";
import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { join } from "node:path";
import { readFileSync } from "node:fs";

// Import Third-party Dependencies
Expand All @@ -16,9 +15,8 @@ import {
} from "../src/index.ts";

// CONSTANTS
const __dirname = dirname(fileURLToPath(import.meta.url));
const kManifestFixturePath = join(__dirname, "fixtures", "manifest");
const kPackumentFixturePath = join(__dirname, "fixtures", "packument");
const kManifestFixturePath = join(import.meta.dirname, "fixtures", "manifest");
const kPackumentFixturePath = join(import.meta.dirname, "fixtures", "packument");
const kManifest: PackumentVersion = JSON.parse(readFileSync(join(kManifestFixturePath, "/manifest.json"), "utf8"));
const kPackument: Packument = JSON.parse(readFileSync(join(kPackumentFixturePath, "/packument.json"), "utf8"));

Expand Down
6 changes: 2 additions & 4 deletions workspaces/flags/scripts/generateFlags.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// 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 TurndownService from "turndown";

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

const turndownService = new TurndownService();

Expand All @@ -35,7 +33,7 @@ async function loadHTMLs() {

const [headerTemplate, ...HTMLFlagsFiles] = await Promise.all([
fs.readFile(
path.join(__dirname, "template", "flagDocHeader.md"),
path.join(import.meta.dirname, "template", "flagDocHeader.md"),
"utf-8"
),
...HTMLFlagsEntries.map(
Expand Down
4 changes: 1 addition & 3 deletions workspaces/flags/src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
import fs from "node:fs";
import path from "node:path";
import * as consumers from "node:stream/consumers";
import { fileURLToPath } from "node:url";
import { Readable } from "node:stream";

// Import Internal Dependencies
import { getFlags } from "./web.ts";

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

/**
* @description lazy read a flag file by getting a Node.js Readable Stream
Expand Down
2 changes: 1 addition & 1 deletion workspaces/fs-walk/src/walk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { WalkOptions, WalkEntry } from "./types.ts";
* @example
* import { walk } from "@nodesecure/fs-walk";
*
* for await (const [dirent, location] of walk(__dirname) {
* for await (const [dirent, location] of walk(import.meta.dirname)) {
* if (dirent.isFile()) {
* console.log(location);
* }
Expand Down
2 changes: 1 addition & 1 deletion workspaces/fs-walk/src/walkSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { WalkOptions, WalkEntry } from "./types.ts";
* @example
* import { walkSync, FILE } from "@nodesecure/fs-walk";
*
* for (const [type, location] of walkSync(__dirname) {
* for (const [type, location] of walkSync(import.meta.dirname)) {
* if (type === FILE) {
* console.log(location);
* }
Expand Down
7 changes: 2 additions & 5 deletions workspaces/fs-walk/test/walk.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
import { describe, it } from "node:test";
import assert from "node:assert";
import path from "node:path";
import { fileURLToPath } from "node:url";

// Import Internal Dependencies
import { walk, walkSync } from "../src/index.ts";

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

const kRootLocation = path.join(__dirname, "..");
const kFixturesDir = path.join(__dirname, "fixtures");
const kRootLocation = path.join(import.meta.dirname, "..");
const kFixturesDir = path.join(import.meta.dirname, "fixtures");

const kExpectedJSFiles = [
"src/index.ts",
Expand Down
2 changes: 1 addition & 1 deletion workspaces/github/src/functions/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export interface DownloadResult {
/**
* @example
* const { location } = await github.download("NodeSecure.utils", {
* dest: __dirname
* dest: import.meta.dirname
* });
* console.log(location);
*/
Expand Down
5 changes: 2 additions & 3 deletions workspaces/i18n/scripts/buildDocumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import path from "node:path";
import fs from "node:fs";
import os from "node:os";
import { fileURLToPath, pathToFileURL } from "node:url";
import { pathToFileURL } from "node:url";

// Import Third-party Dependencies
import zup from "zup";
Expand All @@ -12,8 +12,7 @@ import { english } from "../src/languages/english.ts";
import { french } from "../src/languages/french.ts";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const kProjectRootDir = path.join(__dirname, "..");
const kProjectRootDir = path.join(import.meta.dirname, "..");
const kTokens = {
english,
french
Expand Down
6 changes: 1 addition & 5 deletions workspaces/rc/test/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Import Node.js Dependencies
import path from "node:path";
import { readdirSync } from "node:fs";
import { fileURLToPath } from "node:url";
import assert from "node:assert";
import { describe, it } from "node:test";

Expand All @@ -14,9 +13,6 @@ import * as RC from "../src/index.ts";
import { readJSONSync } from "../src/utils/readJSON.ts";
import { generateDefaultRC } from "../src/rc.ts";

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

describe("CONSTANTS", () => {
it("should export a CONSTANTS variable", () => {
assert("CONSTANTS" in RC);
Expand Down Expand Up @@ -86,7 +82,7 @@ describe("JSON Schema", () => {
const ajv = new Ajv();
const validate = ajv.compile(RC.JSONSchema);

const configurationPath = path.join(__dirname, "fixtures", "configuration");
const configurationPath = path.join(import.meta.dirname, "fixtures", "configuration");
const configurationFiles = readdirSync(configurationPath, { withFileTypes: true })
.filter((dirent) => dirent.isFile() && path.extname(dirent.name) === ".json")
.map((dirent) => path.join(configurationPath, dirent.name));
Expand Down
6 changes: 1 addition & 5 deletions workspaces/rc/test/read.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import * as fs from "node:fs/promises";
import path from "node:path";
import os from "node:os";
import { fileURLToPath } from "node:url";
import assert from "node:assert";
import { describe, before, beforeEach, it, after } from "node:test";

Expand All @@ -16,12 +15,9 @@ import {
} from "../src/index.ts";
import { generateDefaultRC } from "../src/rc.ts";

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

describe("read .nodesecurerc", () => {
const location = path.join(os.tmpdir(), "rcread");
const fixtures = path.join(__dirname, "fixtures");
const fixtures = path.join(import.meta.dirname, "fixtures");

before(async() => {
await fs.mkdir(location);
Expand Down
8 changes: 1 addition & 7 deletions workspaces/scanner/src/class/TopPackages.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import fs from "node:fs/promises";
// Import Third-party Dependencies
import { distance } from "fastest-levenshtein";

// Import Internal Dependencies
import { getDirNameFromUrl } from "../utils/index.ts";

// CONSTANTS
const __dirname = getDirNameFromUrl(import.meta.url);

/**
* This implementation take inspiration from npq
* @see https://github.com/lirantal/npq/blob/c11e5425707ae992fcd6fb0878abe01ccd77399b/lib/marshalls/typosquatting.marshall.js#L23
Expand All @@ -20,7 +14,7 @@ export class TopPackages {

async loadJSON() {
const rawPackageStr = await fs.readFile(
path.join(__dirname, "..", "data", "top-packages.json"),
path.join(import.meta.dirname, "..", "data", "top-packages.json"),
"utf-8"
);

Expand Down
2 changes: 1 addition & 1 deletion workspaces/scanner/src/extractors/payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { isNodesecurePayload } from "../utils/isNodesecurePayload.ts";
const kFastMerge = deepmerge({ all: true });

type MergeDeep<T extends unknown[]> =
T extends [a: infer A, ...rest: infer R] ? A & MergeDeep<R> : {};
T extends [a: infer A, ...rest: infer R] ? A & MergeDeep<R> : {};

export type ExtractProbeResult<
T extends ProbeExtractor<any>[]
Expand Down
4 changes: 2 additions & 2 deletions workspaces/scanner/src/utils/dirname.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fileURLToPath } from "node:url";
import { dirname } from "node:path";

export function getDirNameFromUrl(url: string | URL): string {
const __filename = fileURLToPath(url);
const filename = fileURLToPath(url);

return dirname(__filename);
return dirname(filename);
}
6 changes: 2 additions & 4 deletions workspaces/scanner/test/comparePayloads.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
// Import Node.js Dependencies
import { it } from "node:test";
import assert from "node:assert";
import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { join } from "node:path";
import { readFileSync } from "node:fs";

// Import Internal Dependencies
import { comparePayloads } from "../src/index.ts";

// CONSTANTS
const __dirname = dirname(fileURLToPath(import.meta.url));
const kFixturePath = join(__dirname, "fixtures", "scannerPayloads");
const kFixturePath = join(import.meta.dirname, "fixtures", "scannerPayloads");
const kPayload = JSON.parse(readFileSync(join(kFixturePath, "/payload.json"), "utf8"));

it("should throw an error if compared payloads have the same id", () => {
Expand Down
4 changes: 1 addition & 3 deletions workspaces/scanner/test/depWalker.spec.ts
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 { readFileSync } from "node:fs";
import { test, describe } from "node:test";
import assert from "node:assert";
Expand All @@ -24,8 +23,7 @@ import {
const skip = false;

// CONSTANTS
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
const kFixturePath = path.join(__dirname, "fixtures", "depWalker");
const kFixturePath = path.join(import.meta.dirname, "fixtures", "depWalker");
const kDefaultWalkerOptions = {
registry: getLocalRegistryURL()
};
Expand Down
4 changes: 1 addition & 3 deletions workspaces/scanner/test/verify.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
import path from "node:path";
import fs from "node:fs";
import assert from "node:assert";
import { fileURLToPath } from "node:url";
import { test } from "node:test";

// Import Internal Dependencies
import { verify } from "../src/index.ts";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const kFixturePath = path.join(__dirname, "fixtures", "verify");
const kFixturePath = path.join(import.meta.dirname, "fixtures", "verify");

test("verify 'express' package", async() => {
const data = await verify("express@4.17.0");
Expand Down
6 changes: 2 additions & 4 deletions workspaces/tarball/test/NpmTarball.spec.ts
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 { describe, test } from "node:test";
import assert from "node:assert";

Expand All @@ -14,8 +13,7 @@ type SourceArrayLocation = [[number, number], [number, number]];
import { NpmTarball } from "../src/class/NpmTarball.class.ts";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const kFixturePath = path.join(__dirname, "fixtures", "npmTarball");
const kFixturePath = path.join(import.meta.dirname, "fixtures", "npmTarball");
const kShadyLinkPath = path.join(kFixturePath, "shady-link");

type Metadata = {
Expand All @@ -24,7 +22,7 @@ type Metadata = {

describe("NpmTarball", () => {
test("it should exclude files matching glob patterns via the exclude option", async() => {
const fixturePath = path.join(__dirname, "fixtures", "exclude-test");
const fixturePath = path.join(import.meta.dirname, "fixtures", "exclude-test");
const mama = await ManifestManager.fromPackageJSON(
path.join(fixturePath, "package.json")
);
Expand Down
4 changes: 1 addition & 3 deletions workspaces/tarball/test/SourceCodeReport.spec.ts
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 { test } from "node:test";
import assert from "node:assert";

Expand All @@ -11,8 +10,7 @@ import { AstAnalyser, DefaultCollectableSet } from "@nodesecure/js-x-ray";
import { SourceCodeScanner } from "../src/class/SourceCodeScanner.class.ts";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const kFixturePath = path.join(__dirname, "fixtures", "scanJavascriptFile");
const kFixturePath = path.join(import.meta.dirname, "fixtures", "scanJavascriptFile");

test("should have no warning and no minified file", async() => {
const thirdPartyDependencies = ["mocha", "yolo"];
Expand Down
4 changes: 1 addition & 3 deletions workspaces/tarball/test/SourceCodeScanner.spec.ts
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 assert from "node:assert";
import { describe, test } from "node:test";

Expand All @@ -22,8 +21,7 @@ import {
} from "../src/class/SourceCodeScanner.class.ts";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const kFixturePath = path.join(__dirname, "fixtures", "scanPackage");
const kFixturePath = path.join(import.meta.dirname, "fixtures", "scanPackage");

describe("SourceCodeScanner", () => {
test("iterate() should return empty report if we provide no files", async() => {
Expand Down
4 changes: 1 addition & 3 deletions workspaces/tarball/test/tarball/scanPackage.spec.ts
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 { test } from "node:test";
import assert from "node:assert";

Expand All @@ -9,8 +8,7 @@ import { scanPackage } from "../../src/index.ts";
import { getEmptyPackageWarning } from "../../src/warnings.ts";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const kFixturePath = path.join(__dirname, "..", "fixtures", "scanPackage");
const kFixturePath = path.join(import.meta.dirname, "..", "fixtures", "scanPackage");

test("scanPackage (caseone)", async() => {
const result = await scanPackage(
Expand Down
4 changes: 1 addition & 3 deletions workspaces/tarball/test/utils/getTarballComposition.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Import Node.js Dependencies
import path from "node:path";
import assert from "node:assert";
import { fileURLToPath } from "node:url";
import { test } from "node:test";

// Import Third-party Dependencies
Expand All @@ -11,8 +10,7 @@ import getSize from "get-folder-size";
import { getTarballComposition } from "../../src/utils/index.ts";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const kFixturePath = path.join(__dirname, "..", "fixtures", "getTarballComposition");
const kFixturePath = path.join(import.meta.dirname, "..", "fixtures", "getTarballComposition");

test("should return the composition of a directory", async() => {
const composition = await getTarballComposition(kFixturePath);
Expand Down
Loading
Loading