refactor: Use node protocol when importing builtins

This commit is contained in:
Joachim Van Herwegen 2023-10-30 15:53:29 +01:00
parent def0b5c732
commit 990184dbb5
127 changed files with 170 additions and 172 deletions

View File

@ -166,7 +166,6 @@ const configs = antfu(
'jsdoc/no-multi-asterisks': [ 'error', { allowWhitespace: true }],
// Might want to enable these
'node/prefer-global/buffer': 'off',
'node/prefer-global/process': 'off',
@ -273,7 +272,6 @@ const configs = antfu(
'unicorn/no-await-expression-member': 'off',
'unicorn/no-negated-condition': 'off',
'unicorn/no-object-as-default-parameter': 'off',
'unicorn/prefer-node-protocol': 'off',
'unused-imports/no-unused-vars': [
'error',

View File

@ -1,5 +1,5 @@
const os = require('os');
const v8 = require('v8');
const os = require('node:os');
const v8 = require('node:v8');
// Several parts inspired by https://github.com/renovatebot/renovate/blob/main/package.json

View File

@ -1,6 +1,6 @@
#!/usr/bin/env ts-node
/* eslint-disable import/extensions, no-console */
import * as readline from 'readline';
import * as readline from 'node:readline';
import simpleGit from 'simple-git';
import { version } from '../package.json';

View File

@ -1,4 +1,4 @@
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import type { IAccessControlledResource, IContext, IPolicy } from '@solid/access-control-policy';
import { allowAccessModes } from '@solid/access-control-policy';
import type { Store } from 'n3';

View File

@ -1,5 +1,5 @@
import type { IncomingMessage } from 'http';
import type { TLSSocket } from 'tls';
import type { IncomingMessage } from 'node:http';
import type { TLSSocket } from 'node:tls';
import type { WebSocket } from 'ws';
import type { SingleThreaded } from '../init/cluster/SingleThreaded';
import { getLoggerFor } from '../logging/LogUtil';

View File

@ -1,4 +1,4 @@
import type { TLSSocket } from 'tls';
import type { TLSSocket } from 'node:tls';
import type { HttpRequest } from '../../../server/HttpRequest';
import { BadRequestHttpError } from '../../../util/errors/BadRequestHttpError';
import { errorTermsToMetadata } from '../../../util/errors/HttpErrorUtil';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import type { Guarded } from '../../../util/GuardedStream';
import { SOLID_HTTP } from '../../../util/Vocabularies';
import type { RepresentationMetadata } from '../../representation/RepresentationMetadata';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import type { Guarded } from '../../../util/GuardedStream';
import type { RepresentationMetadata } from '../../representation/RepresentationMetadata';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import { INTERNAL_QUADS } from '../../util/ContentTypes';
import type { Guarded } from '../../util/GuardedStream';
import { guardStream } from '../../util/GuardedStream';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import type { Guarded } from '../../util/GuardedStream';
import type { RepresentationMetadata } from './RepresentationMetadata';

View File

@ -1,5 +1,5 @@
import { createPublicKey } from 'crypto';
import type { KeyObject } from 'crypto';
import { createPublicKey } from 'node:crypto';
import type { KeyObject } from 'node:crypto';
import { exportJWK, generateKeyPair, importJWK } from 'jose';
import type { AsymmetricSigningAlgorithm, JWKS } from '../../../templates/types/oidc-provider';
import type { KeyValueStorage } from '../../storage/keyvalue/KeyValueStorage';

View File

@ -1,5 +1,5 @@
/* eslint-disable ts/naming-convention */
import { randomBytes } from 'crypto';
import { randomBytes } from 'node:crypto';
import type {
Account,
Adapter,

View File

@ -1,4 +1,4 @@
import { randomBytes } from 'crypto';
import { randomBytes } from 'node:crypto';
import { Initializer } from '../../../../init/Initializer';
import { getLoggerFor } from '../../../../logging/LogUtil';
import { createErrorMessage } from '../../../../util/errors/ErrorUtil';

View File

@ -1,6 +1,6 @@
/* eslint-disable unicorn/no-process-exit */
import { existsSync } from 'fs';
import type { WriteStream } from 'tty';
import { existsSync } from 'node:fs';
import type { WriteStream } from 'node:tty';
import type { IComponentsManagerBuilderOptions } from 'componentsjs';
import { ComponentsManager } from 'componentsjs';
import { readJSON } from 'fs-extra';

View File

@ -1,6 +1,6 @@
import type { Server } from 'http';
import { URL } from 'url';
import { promisify } from 'util';
import type { Server } from 'node:http';
import { URL } from 'node:url';
import { promisify } from 'node:util';
import { getLoggerFor } from '../logging/LogUtil';
import { isHttpsServer } from '../server/HttpServerFactory';
import type { HttpServerFactory } from '../server/HttpServerFactory';

View File

@ -1,6 +1,6 @@
import type { Worker } from 'cluster';
import cluster from 'cluster';
import { cpus } from 'os';
import type { Worker } from 'node:cluster';
import cluster from 'node:cluster';
import { cpus } from 'node:os';
import { getLoggerFor } from '../../logging/LogUtil';
import { InternalServerError } from '../../util/errors/InternalServerError';

View File

@ -1,4 +1,4 @@
import { createInterface } from 'readline';
import { createInterface } from 'node:readline';
import { ACCOUNT_STORAGE_DESCRIPTION } from '../../identity/interaction/account/util/BaseAccountStore';
import type { AccountLoginStorage } from '../../identity/interaction/account/util/LoginStorage';
import { ACCOUNT_TYPE } from '../../identity/interaction/account/util/LoginStorage';

View File

@ -1,4 +1,4 @@
import cluster from 'cluster';
import cluster from 'node:cluster';
import { WrappingLogger } from './Logger';
import type { Logger } from './Logger';
import type { LoggerFactory } from './LoggerFactory';

View File

@ -1,5 +1,5 @@
import cluster from 'cluster';
import process from 'process';
import cluster from 'node:cluster';
import process from 'node:process';
import type { LogLevel } from './LogLevel';
export interface LogMetadata {

View File

@ -1,5 +1,5 @@
import { createReadStream, promises as fsPromises } from 'fs';
import type { Readable } from 'stream';
import { createReadStream, promises as fsPromises } from 'node:fs';
import type { Readable } from 'node:stream';
import { pathExists } from 'fs-extra';
import { Parser } from 'n3';
import type { AuxiliaryStrategy } from '../../http/auxiliary/AuxiliaryStrategy';

View File

@ -1,4 +1,4 @@
import { promises as fsPromises } from 'fs';
import { promises as fsPromises } from 'node:fs';
import type { ResourceIdentifier } from '../../../http/representation/ResourceIdentifier';
import type { FileIdentifierMapper } from '../../../storage/mapping/FileIdentifierMapper';
import { ConflictHttpError } from '../../../util/errors/ConflictHttpError';

View File

@ -1,8 +1,8 @@
import { readFileSync } from 'fs';
import type { Server } from 'http';
import { createServer as createHttpServer } from 'http';
import type { ServerOptions } from 'https';
import { createServer as createHttpsServer } from 'https';
import { readFileSync } from 'node:fs';
import type { Server } from 'node:http';
import { createServer as createHttpServer } from 'node:http';
import type { ServerOptions } from 'node:https';
import { createServer as createHttpsServer } from 'node:https';
import { getLoggerFor } from '../logging/LogUtil';
import type { HttpServerFactory } from './HttpServerFactory';
import type { ServerConfigurator } from './ServerConfigurator';

View File

@ -1,4 +1,4 @@
import type { IncomingMessage, Server, ServerResponse } from 'http';
import type { IncomingMessage, Server, ServerResponse } from 'node:http';
import { getLoggerFor } from '../logging/LogUtil';
import { isError } from '../util/errors/ErrorUtil';
import { guardStream } from '../util/GuardedStream';

View File

@ -1,4 +1,4 @@
import type { IncomingMessage } from 'http';
import type { IncomingMessage } from 'node:http';
import type { Guarded } from '../util/GuardedStream';
/**

View File

@ -1,4 +1,4 @@
import type { ServerResponse } from 'http';
import type { ServerResponse } from 'node:http';
/**
* An outgoing HTTP response;

View File

@ -1,5 +1,5 @@
import type { Server } from 'http';
import { Server as HttpsServer } from 'https';
import type { Server } from 'node:http';
import { Server as HttpsServer } from 'node:https';
/**
* Returns `true` if the server is an HTTPS server.

View File

@ -1,4 +1,4 @@
import type { Server } from 'http';
import type { Server } from 'node:http';
import { AsyncHandler } from '../util/handlers/AsyncHandler';
/**

View File

@ -1,5 +1,5 @@
import type { IncomingMessage, Server } from 'http';
import type { Socket } from 'net';
import type { IncomingMessage, Server } from 'node:http';
import type { Socket } from 'node:net';
import type { WebSocket } from 'ws';
import { WebSocketServer } from 'ws';
import { getLoggerFor } from '../logging/LogUtil';

View File

@ -1,4 +1,4 @@
import { createReadStream } from 'fs';
import { createReadStream } from 'node:fs';
import escapeStringRegexp from 'escape-string-regexp';
import * as mime from 'mime-types';
import { getLoggerFor } from '../../logging/LogUtil';

View File

@ -1,4 +1,4 @@
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import { KeysRdfParseJsonLd } from '@comunica/context-entries';
import { parse, toSeconds } from 'iso8601-duration';
import { DataFactory } from 'n3';

View File

@ -1,4 +1,4 @@
import type { IncomingMessage } from 'http';
import type { IncomingMessage } from 'node:http';
import { BadRequestHttpError } from '../../../util/errors/BadRequestHttpError';
/**

View File

@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import type { Representation } from '../http/representation/Representation';
import type { RepresentationPreferences } from '../http/representation/RepresentationPreferences';
import type { ResourceIdentifier } from '../http/representation/ResourceIdentifier';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import type { AuxiliaryIdentifierStrategy } from '../http/auxiliary/AuxiliaryIdentifierStrategy';
import { BasicRepresentation } from '../http/representation/BasicRepresentation';
import type { Patch } from '../http/representation/Patch';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import { ensureDirSync, rename, unlink } from 'fs-extra';
import { v4 } from 'uuid';
import type { RepresentationMetadata } from '../../http/representation/RepresentationMetadata';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import type { Representation } from '../../http/representation/Representation';
import type { RepresentationMetadata } from '../../http/representation/RepresentationMetadata';
import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import type { Stats } from 'fs-extra';
import { createReadStream, createWriteStream, ensureDir, lstat, opendir, remove, stat } from 'fs-extra';
import type { Quad } from 'rdf-js';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import type { RepresentationMetadata } from '../../http/representation/RepresentationMetadata';
import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier';
import type { Guarded } from '../../util/GuardedStream';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import arrayifyStream from 'arrayify-stream';
import { RepresentationMetadata } from '../../http/representation/RepresentationMetadata';
import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import type { Representation } from '../../http/representation/Representation';
import type { RepresentationMetadata } from '../../http/representation/RepresentationMetadata';
import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import arrayifyStream from 'arrayify-stream';
import { SparqlEndpointFetcher } from 'fetch-sparql-endpoint';
import { DataFactory } from 'n3';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import type { Validator } from '../../http/auxiliary/Validator';
import { BasicRepresentation } from '../../http/representation/BasicRepresentation';
import type { RepresentationMetadata } from '../../http/representation/RepresentationMetadata';

View File

@ -1,4 +1,4 @@
import { createReadStream } from 'fs';
import { createReadStream } from 'node:fs';
import { BasicRepresentation } from '../../http/representation/BasicRepresentation';
import type { Representation } from '../../http/representation/Representation';
import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import orderBy from 'lodash.orderby';
import type { Quad } from 'rdf-js';
import { BasicRepresentation } from '../../http/representation/BasicRepresentation';

View File

@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import { BasicRepresentation } from '../../http/representation/BasicRepresentation';
import type { Representation } from '../../http/representation/Representation';
import { INTERNAL_ERROR } from '../../util/ContentTypes';

View File

@ -1,4 +1,4 @@
import { parse } from 'querystring';
import { parse } from 'node:querystring';
import { BasicRepresentation } from '../../http/representation/BasicRepresentation';
import type { Representation } from '../../http/representation/Representation';
import { RepresentationMetadata } from '../../http/representation/RepresentationMetadata';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import { DataFactory, StreamWriter } from 'n3';
import type { Quad } from 'rdf-js';
import rdfSerializer from 'rdf-serialize';

View File

@ -1,4 +1,4 @@
import { PassThrough } from 'stream';
import { PassThrough } from 'node:stream';
import { KeysRdfParseJsonLd } from '@comunica/context-entries';
import type { NamedNode } from '@rdfjs/types';
import rdfParser from 'rdf-parse';

View File

@ -1,4 +1,4 @@
import { createHash } from 'crypto';
import { createHash } from 'node:crypto';
import { getLoggerFor } from '../../logging/LogUtil';
import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError';
import type { KeyValueStorage } from './KeyValueStorage';

View File

@ -1,4 +1,4 @@
import { createHash } from 'crypto';
import { createHash } from 'node:crypto';
import { getLoggerFor } from '../../logging/LogUtil';
import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError';
import type { KeyValueStorage } from './KeyValueStorage';

View File

@ -1,4 +1,4 @@
import { promises as fsPromises } from 'fs';
import { promises as fsPromises } from 'node:fs';
import * as mime from 'mime-types';
import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier';
import { DEFAULT_CUSTOM_TYPES } from '../../util/ContentTypes';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import { Store } from 'n3';
import { BasicRepresentation } from '../../http/representation/BasicRepresentation';
import type { RdfDatasetRepresentation } from '../../http/representation/RdfDatasetRepresentation';

View File

@ -1,7 +1,7 @@
// These two eslint lines are needed to store 'this' in a variable so it can be used
// in the PassThrough of createQuotaGuard
/* eslint-disable ts/no-this-alias */
import { PassThrough } from 'stream';
import { PassThrough } from 'node:stream';
import type { RepresentationMetadata } from '../../http/representation/RepresentationMetadata';
import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier';
import { PayloadHttpError } from '../../util/errors/PayloadHttpError';

View File

@ -1,5 +1,5 @@
import type { Stats } from 'fs';
import { promises as fsPromises } from 'fs';
import type { Stats } from 'node:fs';
import { promises as fsPromises } from 'node:fs';
import type { RepresentationMetadata } from '../../http/representation/RepresentationMetadata';
import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier';
import { joinFilePath, normalizeFilePath, trimTrailingSlashes } from '../../util/PathUtil';

View File

@ -1,4 +1,4 @@
import { PassThrough, Readable } from 'stream';
import { PassThrough, Readable } from 'node:stream';
import { Validator } from '../../http/auxiliary/Validator';
import type { ValidatorInput } from '../../http/auxiliary/Validator';
import type { Representation } from '../../http/representation/Representation';

View File

@ -1,4 +1,4 @@
import { EventEmitter } from 'events';
import { EventEmitter } from 'node:events';
/**
* A typed interface of {@link EventEmitter}.

View File

@ -1,4 +1,4 @@
import type { IncomingHttpHeaders } from 'http';
import type { IncomingHttpHeaders } from 'node:http';
import escapeStringRegexp from 'escape-string-regexp';
import { getLoggerFor } from '../logging/LogUtil';
import type { HttpResponse } from '../server/HttpResponse';

View File

@ -1,4 +1,4 @@
import { posix, win32 } from 'path';
import { posix, win32 } from 'node:path';
import { readJson } from 'fs-extra';
import urljoin from 'url-join';
import type { TargetExtractor } from '../http/input/identifier/TargetExtractor';

View File

@ -1,4 +1,4 @@
import { types } from 'util';
import { types } from 'node:util';
import { createAggregateError } from './errors/HttpErrorUtil';
export type PromiseOrValue<T> = T | Promise<T>;

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import type { NamedNode } from '@rdfjs/types';
import arrayifyStream from 'arrayify-stream';
import type { ParserOptions } from 'n3';

View File

@ -1,5 +1,5 @@
import type { Readable, TransformCallback, TransformOptions } from 'stream';
import { Transform } from 'stream';
import type { Readable, TransformCallback, TransformOptions } from 'node:stream';
import { Transform } from 'node:stream';
import { RangeNotSatisfiedHttpError } from './errors/RangeNotSatisfiedHttpError';
import { pipeSafely } from './StreamUtil';

View File

@ -1,6 +1,6 @@
import type { DuplexOptions, ReadableOptions, Writable } from 'stream';
import { Readable, Transform } from 'stream';
import { promisify } from 'util';
import type { DuplexOptions, ReadableOptions, Writable } from 'node:stream';
import { Readable, Transform } from 'node:stream';
import { promisify } from 'node:util';
import arrayifyStream from 'arrayify-stream';
import eos from 'end-of-stream';
import { Store } from 'n3';

View File

@ -1,4 +1,4 @@
import { types } from 'util';
import { types } from 'node:util';
/**
* Checks if the input is an {@link Error}.

View File

@ -1,4 +1,4 @@
import { URL } from 'url';
import { URL } from 'node:url';
import type { ResourceIdentifier } from '../../http/representation/ResourceIdentifier';
import { errorTermsToMetadata } from '../errors/HttpErrorUtil';
import { InternalServerError } from '../errors/InternalServerError';

View File

@ -1,4 +1,4 @@
import { createHash } from 'crypto';
import { createHash } from 'node:crypto';
import { ensureDir, remove } from 'fs-extra';
import type { LockOptions, UnlockOptions } from 'proper-lockfile';
import { lock, unlock } from 'proper-lockfile';

View File

@ -1,4 +1,4 @@
import { promises as fsPromises } from 'fs';
import { promises as fsPromises } from 'node:fs';
import { joinFilePath, resolveAssetPath } from '../PathUtil';
import type { Template } from './TemplateEngine';

View File

@ -1,4 +1,4 @@
import assert from 'assert';
import assert from 'node:assert';
import fetch from 'cross-fetch';
import type { App } from '../../src/init/App';
import { getPort } from '../util/Util';

View File

@ -1,4 +1,4 @@
import { mkdirSync } from 'fs';
import { mkdirSync } from 'node:fs';
import fetch from 'cross-fetch';
import type { App } from '../../src/init/App';
import { joinFilePath } from '../../src/util/PathUtil';

View File

@ -1,4 +1,4 @@
import { promises as fsPromises } from 'fs';
import { promises as fsPromises } from 'node:fs';
import fetch from 'cross-fetch';
import type { App, ResourceStore } from '../../src/';
import { BasicRepresentation, isSystemError, joinFilePath, joinUrl } from '../../src/';

View File

@ -1,4 +1,4 @@
import { createReadStream } from 'fs';
import { createReadStream } from 'node:fs';
import fetch from 'cross-fetch';
import type { Quad } from 'n3';
import { DataFactory, Parser, Store } from 'n3';

View File

@ -1,4 +1,4 @@
import type { Server } from 'http';
import type { Server } from 'node:http';
import request from 'supertest';
import type { App } from '../../src/init/App';
import type { HttpServerFactory } from '../../src/server/HttpServerFactory';

View File

@ -1,4 +1,4 @@
import type { Stats } from 'fs';
import type { Stats } from 'node:fs';
import fetch from 'cross-fetch';
import type { Response } from 'cross-fetch';
import { ensureDir, pathExists, stat } from 'fs-extra';

View File

@ -1,4 +1,4 @@
import EventEmitter from 'events';
import EventEmitter from 'node:events';
import fetch from 'cross-fetch';
import Redis, { ReplyError } from 'ioredis';
import type { App } from '../../src';

View File

@ -1,4 +1,4 @@
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import arrayifyStream from 'arrayify-stream';
import { BasicETagHandler, SingleRootIdentifierStrategy } from '../../src';
import { BasicRequestParser } from '../../src/http/input/BasicRequestParser';

View File

@ -1,4 +1,4 @@
import { promises as fs } from 'fs';
import { promises as fs } from 'node:fs';
import { joinFilePath } from '../../src/';
import type { App } from '../../src/';
import { putResource } from '../util/FetchUtil';

View File

@ -1,5 +1,5 @@
import { createServer } from 'http';
import type { IncomingMessage, Server, ServerResponse } from 'http';
import { createServer } from 'node:http';
import type { IncomingMessage, Server, ServerResponse } from 'node:http';
import { fetch } from 'cross-fetch';
import { createRemoteJWKSet, jwtVerify } from 'jose';
import type { NamedNode } from 'n3';

View File

@ -1,4 +1,4 @@
import { EventEmitter } from 'events';
import { EventEmitter } from 'node:events';
import type { WebSocket } from 'ws';
import { RepresentationMetadata } from '../../../src/http/representation/RepresentationMetadata';
import { UnsecureWebSocketsProtocol } from '../../../src/http/UnsecureWebSocketsProtocol';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import { GetOperationHandler } from '../../../../src/http/ldp/GetOperationHandler';
import type { Operation } from '../../../../src/http/Operation';
import { BasicRepresentation } from '../../../../src/http/representation/BasicRepresentation';

View File

@ -1,4 +1,4 @@
import type { Readable } from 'stream';
import type { Readable } from 'node:stream';
import { HeadOperationHandler } from '../../../../src/http/ldp/HeadOperationHandler';
import type { Operation } from '../../../../src/http/Operation';
import { BasicRepresentation } from '../../../../src/http/representation/BasicRepresentation';

View File

@ -1,5 +1,5 @@
import { EventEmitter } from 'events';
import { PassThrough } from 'stream';
import { EventEmitter } from 'node:events';
import { PassThrough } from 'node:stream';
import type { MockResponse } from 'node-mocks-http';
import { createResponse } from 'node-mocks-http';
import { BasicResponseWriter } from '../../../../src/http/output/BasicResponseWriter';

View File

@ -1,5 +1,5 @@
import 'jest-rdf';
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import arrayifyStream from 'arrayify-stream';
import { DataFactory } from 'n3';
import { BasicRepresentation } from '../../../../src/http/representation/BasicRepresentation';

View File

@ -1,4 +1,4 @@
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import { exportJWK, generateKeyPair } from 'jose';
import type * as Koa from 'koa';
import type { ErrorHandler } from '../../../../src/http/output/error/ErrorHandler';

View File

@ -14,7 +14,7 @@ import { InternalServerError } from '../../../../../../src/util/errors/InternalS
const STORAGE_TYPE = 'clientCredentials';
const secret = 'verylongstringof64bytes';
jest.mock('crypto', (): any => ({ randomBytes: (): string => secret }));
jest.mock('node:crypto', (): any => ({ randomBytes: (): string => secret }));
describe('A BaseClientCredentialsStore', (): void => {
const webId = 'http://example.com/card#me';

View File

@ -1,4 +1,4 @@
import type { ServerResponse } from 'http';
import type { ServerResponse } from 'node:http';
import { createResponse } from 'node-mocks-http';
import { RepresentationMetadata } from '../../../../../../src/http/representation/RepresentationMetadata';
import { OwnerMetadataWriter } from '../../../../../../src/identity/interaction/pod/util/OwnerMetadataWriter';

View File

@ -1,4 +1,4 @@
import { Readable } from 'stream';
import { Readable } from 'node:stream';
import { DataFactory } from 'n3';
import type { Quad } from 'n3';
import rdfDereferencer from 'rdf-dereference';

View File

@ -115,7 +115,7 @@ const packageJSON = {
},
};
jest.mock('fs', (): Partial<Record<string, jest.Mock>> => ({
jest.mock('node:fs', (): Partial<Record<string, jest.Mock>> => ({
cwd: jest.fn((): string => __dirname),
existsSync: jest.fn((pth: string): boolean => typeof pth === 'string' && pth in files),
}));

View File

@ -5,7 +5,7 @@ import type { PodCreator } from '../../../src/identity/interaction/pod/util/PodC
import { SeededAccountInitializer } from '../../../src/init/SeededAccountInitializer';
import { mockFileSystem } from '../../util/Util';
jest.mock('fs');
jest.mock('node:fs');
jest.mock('fs-extra');
describe('A SeededAccountInitializer', (): void => {

View File

@ -1,12 +1,12 @@
import type { Server } from 'http';
import { Server as HttpsServer } from 'https';
import type { Server } from 'node:http';
import { Server as HttpsServer } from 'node:https';
import { ServerInitializer } from '../../../src/init/ServerInitializer';
import type { Logger } from '../../../src/logging/Logger';
import { getLoggerFor } from '../../../src/logging/LogUtil';
import type { HttpServerFactory } from '../../../src/server/HttpServerFactory';
// Mock so we don't create an actual HTTPS server in the test below
jest.mock('https');
jest.mock('node:https');
jest.mock('../../../src/logging/LogUtil');
describe('ServerInitializer', (): void => {

View File

@ -1,12 +1,12 @@
import cluster from 'cluster';
import EventEmitter from 'events';
import { cpus } from 'os';
import cluster from 'node:cluster';
import EventEmitter from 'node:events';
import { cpus } from 'node:os';
import { ClusterManager } from '../../../../src';
import * as LogUtil from '../../../../src/logging/LogUtil';
jest.mock('cluster');
jest.mock('os', (): any => ({
...jest.requireActual('os'),
jest.mock('node:cluster');
jest.mock('node:os', (): any => ({
...jest.requireActual('node:os'),
cpus: jest.fn().mockImplementation((): any => [{}, {}, {}, {}, {}, {}]),
}));
@ -15,7 +15,7 @@ mockWorker.process = { pid: 666 };
describe('A ClusterManager', (): void => {
const emitter = new EventEmitter();
const mockCluster = jest.requireMock('cluster');
const mockCluster = jest.requireMock('node:cluster');
const mockLogger = { info: jest.fn(), warn: jest.fn() };
jest.spyOn(LogUtil, 'getLoggerFor').mockImplementation((): any => mockLogger);

View File

@ -29,7 +29,7 @@ type ClientCredentials = {
const questionMock = jest.fn().mockImplementation((input, callback): void => callback('y'));
const closeMock = jest.fn();
jest.mock('readline', (): any => ({
jest.mock('node:readline', (): any => ({
createInterface: jest.fn().mockImplementation((): any => ({
question: questionMock,
close: closeMock,

View File

@ -1,4 +1,4 @@
import process from 'process';
import process from 'node:process';
import { BaseLogger, WrappingLogger } from '../../../src/logging/Logger';
import type { LogMetadata, SimpleLogger } from '../../../src/logging/Logger';

View File

@ -1,4 +1,4 @@
import { PassThrough } from 'stream';
import { PassThrough } from 'node:stream';
import type { Logger } from 'winston';
import type * as Transport from 'winston-transport';
import { WinstonLogger } from '../../../src/logging/WinstonLogger';

View File

@ -13,7 +13,7 @@ import { HandlebarsTemplateEngine } from '../../../../src/util/templates/Handleb
import { SimpleSuffixStrategy } from '../../../util/SimpleSuffixStrategy';
import { mockFileSystem } from '../../../util/Util';
jest.mock('fs');
jest.mock('node:fs');
jest.mock('fs-extra');
class DummyFactory implements FileIdentifierMapperFactory {

View File

@ -1,4 +1,4 @@
import fs from 'fs';
import fs from 'node:fs';
import { RootFilePathHandler } from '../../../../../src/pods/generate/variables/RootFilePathHandler';
import { TEMPLATE_VARIABLE } from '../../../../../src/pods/generate/variables/Variables';
import type { PodSettings } from '../../../../../src/pods/settings/PodSettings';
@ -6,7 +6,7 @@ import type { ResourceLink } from '../../../../../src/storage/mapping/FileIdenti
import { ConflictHttpError } from '../../../../../src/util/errors/ConflictHttpError';
import { joinFilePath } from '../../../../../src/util/PathUtil';
jest.mock('fs');
jest.mock('node:fs');
describe('A RootFilePathHandler', (): void => {
const rootFilePath = 'files/';

View File

@ -11,7 +11,7 @@ import { SingleRootIdentifierStrategy } from '../../../src/util/identifiers/Sing
import { PIM, RDF } from '../../../src/util/Vocabularies';
import { mockFileSystem } from '../../util/Util';
jest.mock('fs');
jest.mock('node:fs');
describe('PodQuotaStrategy', (): void => {
let strategy: PodQuotaStrategy;

View File

@ -6,7 +6,7 @@ import type { SizeReporter } from '../../../src/storage/size-reporter/SizeReport
import { guardedStreamFrom, pipeSafely } from '../../../src/util/StreamUtil';
import { mockFileSystem } from '../../util/Util';
jest.mock('fs');
jest.mock('node:fs');
class QuotaStrategyWrapper extends QuotaStrategy {
public constructor(reporter: SizeReporter<any>, limit: Size) {

View File

@ -1,4 +1,4 @@
import type { RequestListener, Server } from 'http';
import type { RequestListener, Server } from 'node:http';
import request from 'supertest';
import type { BaseServerFactoryOptions } from '../../../src/server/BaseServerFactory';
import { BaseServerFactory } from '../../../src/server/BaseServerFactory';

View File

@ -1,6 +1,6 @@
import { EventEmitter } from 'events';
import type { IncomingMessage, Server, ServerResponse } from 'http';
import { Readable } from 'stream';
import { EventEmitter } from 'node:events';
import type { IncomingMessage, Server, ServerResponse } from 'node:http';
import { Readable } from 'node:stream';
import type { Logger } from '../../../src/logging/Logger';
import { getLoggerFor } from '../../../src/logging/LogUtil';
import { HandlerServerConfigurator } from '../../../src/server/HandlerServerConfigurator';

View File

@ -1,5 +1,5 @@
import { EventEmitter } from 'events';
import type { Server } from 'http';
import { EventEmitter } from 'node:events';
import type { Server } from 'node:http';
import type { WebSocket } from 'ws';
import type { Logger } from '../../../src/logging/Logger';
import { getLoggerFor } from '../../../src/logging/LogUtil';

View File

@ -1,6 +1,6 @@
import { EventEmitter } from 'events';
import fs from 'fs';
import { PassThrough, Readable } from 'stream';
import { EventEmitter } from 'node:events';
import fs from 'node:fs';
import { PassThrough, Readable } from 'node:stream';
import { createResponse } from 'node-mocks-http';
import { StaticAssetEntry, StaticAssetHandler } from '../../../../src/server/middleware/StaticAssetHandler';
import { InternalServerError } from '../../../../src/util/errors/InternalServerError';

View File

@ -1,4 +1,4 @@
import { EventEmitter } from 'events';
import { EventEmitter } from 'node:events';
import { RepresentationMetadata } from '../../../../src/http/representation/RepresentationMetadata';
import type { ResourceIdentifier } from '../../../../src/http/representation/ResourceIdentifier';
import type { Logger } from '../../../../src/logging/Logger';

Some files were not shown because too many files have changed in this diff Show More