1
mirror of https://github.com/jakejarvis/rdapper.git synced 2025-10-18 20:14:27 -04:00

Replaced tsconfig.build.json with tsdown configuration for simplified builds.

This commit is contained in:
2025-09-28 21:30:57 -04:00
parent d09d8e4ffd
commit c76da2bf5c
20 changed files with 826 additions and 868 deletions

17
.vscode/settings.json vendored
View File

@@ -1,17 +0,0 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"emmet.showExpandedAbbreviation": "never",
"editor.codeActionsOnSave": {
"source.fixAll.biome": "explicit",
"source.organizeImports.biome": "explicit"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
}
}

1520
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -7,6 +7,9 @@
"type": "git",
"url": "git+https://github.com/jakejarvis/rdapper.git"
},
"bugs": {
"url": "https://github.com/jakejarvis/rdapper/issues"
},
"author": {
"name": "Jake Jarvis",
"email": "jake@jarv.is",
@@ -14,6 +17,7 @@
},
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
@@ -26,13 +30,12 @@
"dist"
],
"scripts": {
"clean": "rm -rf dist",
"build": "npm run clean && tsc -p tsconfig.build.json",
"test": "npm run clean && tsc -p tsconfig.json && vitest run",
"test:watch": "npm run clean && tsc -p tsconfig.json && vitest",
"test:coverage": "npm run clean && tsc -p tsconfig.json && vitest run --coverage",
"test:smoke": "SMOKE=1 npm run test",
"lint": "biome check --write",
"build": "tsdown",
"dev": "tsdown --watch",
"typecheck": "tsc --noEmit",
"test": "vitest",
"test:run": "vitest run",
"lint": "biome check",
"prepublishOnly": "npm run build"
},
"dependencies": {
@@ -42,7 +45,7 @@
"@biomejs/biome": "2.2.4",
"@types/node": "24.5.2",
"@types/psl": "1.1.3",
"@vitest/coverage-v8": "^3.2.4",
"tsdown": "0.15.5",
"typescript": "5.9.2",
"vitest": "^3.2.4"
},

View File

@@ -1,7 +1,7 @@
/** biome-ignore-all lint/style/noNonNullAssertion: this is fine for tests */
import { expect, test } from "vitest";
import { isAvailable, isRegistered, lookupDomain } from "./index.js";
import { isAvailable, isRegistered, lookupDomain } from ".";
// Run only when SMOKE=1 to avoid flakiness and network in CI by default
const shouldRun = process.env.SMOKE === "1";

View File

@@ -37,12 +37,12 @@ vi.mock("./lib/domain.js", async () => {
};
});
import { lookupDomain } from "./index.js";
import * as domain from "./lib/domain.js";
import * as rdapClient from "./rdap/client.js";
import type { WhoisQueryResult } from "./whois/client.js";
import * as whoisClient from "./whois/client.js";
import * as discovery from "./whois/discovery.js";
import { lookupDomain } from ".";
import * as domain from "./lib/domain";
import * as rdapClient from "./rdap/client";
import type { WhoisQueryResult } from "./whois/client";
import * as whoisClient from "./whois/client";
import * as discovery from "./whois/discovery";
// 1) Orchestration tests (RDAP path, fallback, whoisOnly)
describe("lookupDomain orchestration", () => {

View File

@@ -1,18 +1,18 @@
import { toISO } from "./lib/dates.js";
import { getDomainParts, isLikelyDomain } from "./lib/domain.js";
import { getRdapBaseUrlsForTld } from "./rdap/bootstrap.js";
import { fetchRdapDomain } from "./rdap/client.js";
import { normalizeRdap } from "./rdap/normalize.js";
import type { DomainRecord, LookupOptions, LookupResult } from "./types.js";
import { whoisQuery } from "./whois/client.js";
import { toISO } from "./lib/dates";
import { getDomainParts, isLikelyDomain } from "./lib/domain";
import { getRdapBaseUrlsForTld } from "./rdap/bootstrap";
import { fetchRdapDomain } from "./rdap/client";
import { normalizeRdap } from "./rdap/normalize";
import type { DomainRecord, LookupOptions, LookupResult } from "./types";
import { whoisQuery } from "./whois/client";
import {
extractWhoisReferral,
ianaWhoisServerForTld,
getIanaWhoisTextForTld,
ianaWhoisServerForTld,
parseIanaRegistrationInfoUrl,
} from "./whois/discovery.js";
import { normalizeWhois } from "./whois/normalize.js";
import { WHOIS_TLD_EXCEPTIONS } from "./whois/servers.js";
} from "./whois/discovery";
import { normalizeWhois } from "./whois/normalize";
import { WHOIS_TLD_EXCEPTIONS } from "./whois/servers";
/**
* High-level lookup that prefers RDAP and falls back to WHOIS.
@@ -69,9 +69,7 @@ export async function lookupDomain(
const regUrl = ianaText
? parseIanaRegistrationInfoUrl(ianaText)
: undefined;
const hint = regUrl
? ` See registration info at ${regUrl}.`
: "";
const hint = regUrl ? ` See registration info at ${regUrl}.` : "";
return {
ok: false,
error: `No WHOIS server discovered for TLD '${tld}'. This registry may not publish public WHOIS over port 43.${hint}`,
@@ -150,4 +148,4 @@ export async function isRegistered(
return res.record.isRegistered === true;
}
export type * from "./types.js";
export type * from "./types";

View File

@@ -1,7 +1,7 @@
/** biome-ignore-all lint/style/noNonNullAssertion: this is fine for tests */
import { expect, test } from "vitest";
import { toISO } from "./dates.js";
import { toISO } from "./dates";
test("toISO parses ISO and common whois formats", () => {
const iso = toISO("2023-01-02T03:04:05Z");

View File

@@ -1,5 +1,5 @@
import { expect, test } from "vitest";
import { extractTld, isLikelyDomain } from "./domain.js";
import { extractTld, isLikelyDomain } from "./domain";
test("extractTld basic", () => {
expect(extractTld("example.com")).toBe("com");

View File

@@ -1,6 +1,6 @@
import { withTimeout } from "../lib/async.js";
import { DEFAULT_TIMEOUT_MS } from "../lib/constants.js";
import type { LookupOptions } from "../types.js";
import { withTimeout } from "../lib/async";
import { DEFAULT_TIMEOUT_MS } from "../lib/constants";
import type { LookupOptions } from "../types";
// Use global fetch (Node 18+). For large JSON we keep it simple.

View File

@@ -1,6 +1,6 @@
import { withTimeout } from "../lib/async.js";
import { DEFAULT_TIMEOUT_MS } from "../lib/constants.js";
import type { LookupOptions } from "../types.js";
import { withTimeout } from "../lib/async";
import { DEFAULT_TIMEOUT_MS } from "../lib/constants";
import type { LookupOptions } from "../types";
// Use global fetch (Node 18+). For large JSON we keep it simple.

View File

@@ -1,5 +1,5 @@
import { expect, test } from "vitest";
import { normalizeRdap } from "./normalize.js";
import { normalizeRdap } from "./normalize";
test("normalizeRdap maps registrar, contacts, nameservers, events, dnssec", () => {
const rdap = {

View File

@@ -1,11 +1,11 @@
import { toISO } from "../lib/dates.js";
import { asDateLike, asString, asStringArray, uniq } from "../lib/text.js";
import { toISO } from "../lib/dates";
import { asDateLike, asString, asStringArray, uniq } from "../lib/text";
import type {
Contact,
DomainRecord,
Nameserver,
RegistrarInfo,
} from "../types.js";
} from "../types";
type RdapDoc = Record<string, unknown>;
@@ -22,12 +22,6 @@ export function normalizeRdap(
includeRaw = false,
): DomainRecord {
const doc = (rdap ?? {}) as RdapDoc;
// Safe helpers for optional fields
const _get = (obj: unknown, path: string[]): unknown =>
path.reduce<unknown>(
(o, k) => ((o as RdapDoc)?.[k] as unknown) ?? undefined,
obj,
);
// Prefer ldhName (punycode) and unicodeName if provided
const ldhName: string | undefined =
@@ -254,7 +248,6 @@ function parseVcard(vcardArray: unknown): ParsedVCard {
const out: ParsedVCard = {};
for (const e of entries) {
const key = e?.[0];
const _valueType = e?.[2];
const value = e?.[3];
if (!key) continue;
switch (String(key).toLowerCase()) {

View File

@@ -1,7 +1,7 @@
import { createConnection } from "node:net";
import { withTimeout } from "../lib/async.js";
import { DEFAULT_TIMEOUT_MS } from "../lib/constants.js";
import type { LookupOptions } from "../types.js";
import { withTimeout } from "../lib/async";
import { DEFAULT_TIMEOUT_MS } from "../lib/constants";
import type { LookupOptions } from "../types";
export interface WhoisQueryResult {
serverQueried: string;

View File

@@ -1,6 +1,6 @@
import type { LookupOptions } from "../types.js";
import { whoisQuery } from "./client.js";
import { WHOIS_TLD_EXCEPTIONS } from "./servers.js";
import type { LookupOptions } from "../types";
import { whoisQuery } from "./client";
import { WHOIS_TLD_EXCEPTIONS } from "./servers";
/**
* Parse the IANA WHOIS response for a TLD and extract the WHOIS server
@@ -32,9 +32,7 @@ export function parseIanaWhoisServer(text: string): string | undefined {
* remarks: Registration information: http://example.tld
* url: https://registry.example
*/
export function parseIanaRegistrationInfoUrl(
text: string,
): string | undefined {
export function parseIanaRegistrationInfoUrl(text: string): string | undefined {
const lines = String(text).split(/\r?\n/);
for (const raw of lines) {
const line = raw.trim();

View File

@@ -1,5 +1,5 @@
import { expect, test } from "vitest";
import { normalizeWhois } from "./normalize.js";
import { normalizeWhois } from "./normalize";
test("WHOIS .de (DENIC-like) nserver lines", () => {
const text = `

View File

@@ -1,12 +1,12 @@
import { toISO } from "../lib/dates.js";
import { isWhoisAvailable } from "../lib/domain.js";
import { parseKeyValueLines, uniq } from "../lib/text.js";
import { toISO } from "../lib/dates";
import { isWhoisAvailable } from "../lib/domain";
import { parseKeyValueLines, uniq } from "../lib/text";
import type {
Contact,
DomainRecord,
Nameserver,
RegistrarInfo,
} from "../types.js";
} from "../types";
/**
* Convert raw WHOIS text into our normalized DomainRecord.

View File

@@ -1,6 +0,0 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.json",
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "src/**/*.test.ts", "src/**/__tests__/**"]
}

View File

@@ -1,17 +1,19 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "esnext",
"moduleDetection": "force",
"module": "preserve",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"outDir": "dist",
"rootDir": "src",
"declaration": true
"noUnusedLocals": true,
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"isolatedModules": true,
"verbatimModuleSyntax": true,
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]

8
tsdown.config.ts Normal file
View File

@@ -0,0 +1,8 @@
import { defineConfig } from "tsdown";
export default defineConfig({
entry: ["src/index.ts"],
platform: "node",
dts: true,
external: ["psl"],
});

View File

@@ -8,10 +8,5 @@ export default defineConfig({
sequence: { hooks: "list" },
globals: false,
testTimeout: process.env.SMOKE === "1" ? 30000 : 5000,
coverage: {
provider: "v8",
reportsDirectory: "coverage",
reporter: ["text", "lcov"],
},
},
});