From 2f0604355988a421690bb275375c3df280af7ee6 Mon Sep 17 00:00:00 2001 From: undergroundwires Date: Thu, 28 Dec 2023 11:57:38 +0100 Subject: [PATCH] Bump Node.js environment to 18.x - Bump Node.js to version 18. This change is necessary as Node.js v16 will reach end-of-life on 2023-09-11. It also ensure compatibility with dependencies requiring minimum of Node.js v18, such as `vite`, `@vitejs`plugin-legacy` and `icon-gen`. - Bump `setup-node` action to v4. - Recommend using the `nvm` tool for managing Node.js versions in the documentation. - Update documentation to point to code reference for required Node.js version. This removes duplication of information, and keeps the code as single source of truth for required Node.js version. - Refactor code to adopt the `node:` protocol for Node API imports as per Node.js 18 standards. This change addresses ambiguities and aligns with Node.js best practices (nodejs/node#38343). Currently, there is no ESLint rule to enforce this protocol, as noted in import-js/eslint-plugin-import#2717. - Replace `cross-fetch` dependency with the native Node.js fetch API introduced in Node.js 18. Adjust type casting for async iterable read streams to align with the latest Node.js APIs, based on discussions in DefinitelyTyped/DefinitelyTyped#65542. --- .github/actions/setup-node/action.yml | 4 +- docs/development.md | 4 +- electron-builder.cjs | 2 +- electron.vite.config.ts | 2 +- package-lock.json | 86 +------------------ package.json | 1 - scripts/logo-update.js | 8 +- scripts/npm-install.js | 8 +- scripts/print-dist-dir.js | 4 +- scripts/verify-build-artifacts.js | 6 +- .../electron/main/ElectronConfig.ts | 2 +- .../main/Update/ManualUpdater/Downloader.ts | 27 +++--- .../main/Update/ManualUpdater/Integrity.ts | 4 +- .../app/app-logs.ts | 4 +- .../extractors/common/app-artifact-locator.ts | 4 +- .../app/extractors/linux.ts | 4 +- .../app/extractors/windows.ts | 6 +- .../app/runner.ts | 3 +- .../app/system-capture/screen-capture.ts | 2 +- .../check-desktop-runtime-errors/config.ts | 2 +- .../check-desktop-runtime-errors/utils/io.ts | 4 +- .../check-desktop-runtime-errors/utils/npm.ts | 4 +- .../utils/platform.ts | 2 +- .../utils/run-command.ts | 3 +- .../StatusChecker/FetchWithTimeout.ts | 2 - .../collections/NoUnintentedInlining.spec.ts | 4 +- vite-config-helper.ts | 4 +- vite.config.ts | 2 +- 28 files changed, 60 insertions(+), 148 deletions(-) diff --git a/.github/actions/setup-node/action.yml b/.github/actions/setup-node/action.yml index 10b2672a..d1e5d07f 100644 --- a/.github/actions/setup-node/action.yml +++ b/.github/actions/setup-node/action.yml @@ -3,6 +3,6 @@ runs: steps: - name: Setup node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 16.x + node-version: 18.x diff --git a/docs/development.md b/docs/development.md index 0709ccd1..22a3aa9b 100644 --- a/docs/development.md +++ b/docs/development.md @@ -13,7 +13,9 @@ See [ci-cd.md](./ci-cd.md) for more information. ### Prerequisites -- Install Node >16.x. +- Install Node.js: + - Refer to [action.yml](./../.github/actions/setup-node/action.yml) for the minimum required version compatible with the automated workflows. + - 💡 Recommended: Use [`nvm`](https://github.com/nvm-sh/nvm) CLI to install and switch between Node.js versions. - Install dependencies using `npm install` (or [`npm run install-deps`](#utility-scripts) for more options). ### Testing diff --git a/electron-builder.cjs b/electron-builder.cjs index 8b8f4c11..e08e8c21 100644 --- a/electron-builder.cjs +++ b/electron-builder.cjs @@ -1,6 +1,6 @@ /* eslint-disable no-template-curly-in-string */ -const { join } = require('path'); +const { join } = require('node:path'); const { electronBundled, electronUnbundled } = require('./dist-dirs.json'); module.exports = { diff --git a/electron.vite.config.ts b/electron.vite.config.ts index 02f397b5..ae657c01 100644 --- a/electron.vite.config.ts +++ b/electron.vite.config.ts @@ -1,4 +1,4 @@ -import { resolve } from 'path'; +import { resolve } from 'node:path'; import { mergeConfig, UserConfig } from 'vite'; import { defineConfig, externalizeDepsPlugin } from 'electron-vite'; import { getAliasesFromTsConfig, getClientEnvironmentVariables } from './vite-config-helper'; diff --git a/package-lock.json b/package-lock.json index e753883b..caa4cc7b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,13 +6,12 @@ "packages": { "": { "name": "privacy.sexy", - "version": "0.12.8", + "version": "0.12.9", "hasInstallScript": true, "dependencies": { "@floating-ui/vue": "^1.0.2", "@juggle/resize-observer": "^3.4.0", "ace-builds": "^1.30.0", - "cross-fetch": "^4.0.0", "electron-log": "^5.0.1", "electron-progressbar": "^2.1.0", "electron-updater": "^6.1.4", @@ -5819,14 +5818,6 @@ "buffer": "^5.1.0" } }, - "node_modules/cross-fetch": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz", - "integrity": "sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==", - "dependencies": { - "node-fetch": "^2.6.12" - } - }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -12128,44 +12119,6 @@ "integrity": "sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==", "optional": true }, - "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, - "node_modules/node-fetch/node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" - }, - "node_modules/node-fetch/node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" - }, - "node_modules/node-fetch/node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, "node_modules/node-releases": { "version": "2.0.13", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz", @@ -23815,14 +23768,6 @@ "buffer": "^5.1.0" } }, - "cross-fetch": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz", - "integrity": "sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==", - "requires": { - "node-fetch": "^2.6.12" - } - }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -28498,35 +28443,6 @@ "integrity": "sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==", "optional": true }, - "node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "requires": { - "whatwg-url": "^5.0.0" - }, - "dependencies": { - "tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" - }, - "webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" - }, - "whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "requires": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - } - } - }, "node-releases": { "version": "2.0.13", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz", diff --git a/package.json b/package.json index f75abdf7..9260f5d0 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,6 @@ "@floating-ui/vue": "^1.0.2", "@juggle/resize-observer": "^3.4.0", "ace-builds": "^1.30.0", - "cross-fetch": "^4.0.0", "electron-log": "^5.0.1", "electron-progressbar": "^2.1.0", "electron-updater": "^6.1.4", diff --git a/scripts/logo-update.js b/scripts/logo-update.js index f460ef7e..59964544 100644 --- a/scripts/logo-update.js +++ b/scripts/logo-update.js @@ -1,8 +1,8 @@ #!/usr/bin/env bash -import { resolve, join } from 'path'; -import { rm, mkdtemp, stat } from 'fs/promises'; -import { spawn } from 'child_process'; -import { URL, fileURLToPath } from 'url'; +import { resolve, join } from 'node:path'; +import { rm, mkdtemp, stat } from 'node:fs/promises'; +import { spawn } from 'node:child_process'; +import { URL, fileURLToPath } from 'node:url'; class Paths { constructor(selfDirectory) { diff --git a/scripts/npm-install.js b/scripts/npm-install.js index 9b346ac9..2438822b 100644 --- a/scripts/npm-install.js +++ b/scripts/npm-install.js @@ -35,10 +35,10 @@ Note: Example: npm run install-deps -- --fresh --non-deterministic */ -import { exec } from 'child_process'; -import { resolve } from 'path'; -import { access, rm, unlink } from 'fs/promises'; -import { constants } from 'fs'; +import { exec } from 'node:child_process'; +import { resolve } from 'node:path'; +import { access, rm, unlink } from 'node:fs/promises'; +import { constants } from 'node:fs'; const MAX_RETRIES = 5; const RETRY_DELAY_IN_MS = 5 /* seconds */ * 1000; diff --git a/scripts/print-dist-dir.js b/scripts/print-dist-dir.js index 2f837945..858204d9 100644 --- a/scripts/print-dist-dir.js +++ b/scripts/print-dist-dir.js @@ -12,8 +12,8 @@ * --web Path for the web application */ -import { resolve } from 'path'; -import { readFile } from 'fs/promises'; +import { resolve } from 'node:path'; +import { readFile } from 'node:fs/promises'; const DIST_DIRS_JSON_FILE_PATH = resolve(process.cwd(), 'dist-dirs.json'); // cannot statically import because ESLint does not support it https://github.com/eslint/eslint/discussions/15305 const CLI_ARGUMENTS = process.argv.slice(2); diff --git a/scripts/verify-build-artifacts.js b/scripts/verify-build-artifacts.js index 947476ca..1ca9d77f 100644 --- a/scripts/verify-build-artifacts.js +++ b/scripts/verify-build-artifacts.js @@ -13,9 +13,9 @@ * --web Verify artifacts for the web application. */ -import { access, readdir } from 'fs/promises'; -import { exec } from 'child_process'; -import { resolve } from 'path'; +import { access, readdir } from 'node:fs/promises'; +import { exec } from 'node:child_process'; +import { resolve } from 'node:path'; const PROCESS_ARGUMENTS = process.argv.slice(2); const PRINT_DIST_DIR_SCRIPT_BASE_COMMAND = 'node scripts/print-dist-dir'; diff --git a/src/presentation/electron/main/ElectronConfig.ts b/src/presentation/electron/main/ElectronConfig.ts index d9a8e4c0..a8b3604c 100644 --- a/src/presentation/electron/main/ElectronConfig.ts +++ b/src/presentation/electron/main/ElectronConfig.ts @@ -4,7 +4,7 @@ */ /// -import { join } from 'path'; +import { join } from 'node:path'; import appIcon from '@/presentation/public/icon.png?asset'; export const APP_ICON_PATH = appIcon; diff --git a/src/presentation/electron/main/Update/ManualUpdater/Downloader.ts b/src/presentation/electron/main/Update/ManualUpdater/Downloader.ts index 323d9211..7c1f0e6f 100644 --- a/src/presentation/electron/main/Update/ManualUpdater/Downloader.ts +++ b/src/presentation/electron/main/Update/ManualUpdater/Downloader.ts @@ -1,14 +1,12 @@ -import { existsSync, createWriteStream } from 'fs'; -import { unlink, mkdir } from 'fs/promises'; -import path from 'path'; +import { existsSync, createWriteStream, type WriteStream } from 'node:fs'; +import { unlink, mkdir } from 'node:fs/promises'; +import path from 'node:path'; import { app } from 'electron'; import { UpdateInfo } from 'electron-updater'; -import fetch from 'cross-fetch'; import { ElectronLogger } from '@/infrastructure/Log/ElectronLogger'; import { UpdateProgressBar } from '../UpdateProgressBar'; import { retryFileSystemAccess } from './RetryFileSystemAccess'; -import type { WriteStream } from 'fs'; -import type { Readable } from 'stream'; +import type { ReadableStream } from 'node:stream/web'; const MAX_PROGRESS_LOG_ENTRIES = 10; const UNKNOWN_SIZE_LOG_INTERVAL_BYTES = 10 * 1024 * 1024; // 10 MB @@ -128,13 +126,13 @@ function getContentLengthFromResponse(response: Response): ResponseContentLength async function withReadableStream( response: Response, - handler: (readStream: Readable) => Promise, + handler: (readStream: ReadableStream) => Promise, ) { const reader = createReader(response); try { await handler(reader); } finally { - reader.destroy(); + reader.cancel(); } } @@ -152,7 +150,7 @@ async function withWriteStream( async function streamWithProgress( contentLength: ResponseContentLength, - readStream: Readable, + readStream: ReadableStream, writeStream: WriteStream, progressHandler: ProgressCallback, ): Promise { @@ -212,12 +210,13 @@ function shouldLogProgress( return { shouldLog: false, nextLogThreshold: previousLogThreshold }; } -function createReader(response: Response): Readable { +function createReader(response: Response): ReadableStream { if (!response.body) { throw new Error('Response body is empty, cannot proceed with download.'); } - // On browser, we could use browser API response.body.getReader() - // But here, we use cross-fetch that gets node-fetch on a node application - // This API is node-fetch specific, see https://github.com/node-fetch/node-fetch#streams - return response.body as unknown as Readable; + // TypeScript has removed the async iterator type definition for ReadableStream due to + // limited browser support. Node.js, however, supports async iterable streams, allowing + // type casting to function properly in this context. + // https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/65542#discussioncomment-6071004 + return response.body as ReadableStream; } diff --git a/src/presentation/electron/main/Update/ManualUpdater/Integrity.ts b/src/presentation/electron/main/Update/ManualUpdater/Integrity.ts index 22a63ca4..599eaf01 100644 --- a/src/presentation/electron/main/Update/ManualUpdater/Integrity.ts +++ b/src/presentation/electron/main/Update/ManualUpdater/Integrity.ts @@ -1,5 +1,5 @@ -import { createHash } from 'crypto'; -import { createReadStream } from 'fs'; +import { createHash } from 'node:crypto'; +import { createReadStream } from 'node:fs'; import { ElectronLogger } from '@/infrastructure/Log/ElectronLogger'; import { retryFileSystemAccess } from './RetryFileSystemAccess'; diff --git a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/app-logs.ts b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/app-logs.ts index bbd20e4a..d225ba50 100644 --- a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/app-logs.ts +++ b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/app-logs.ts @@ -1,5 +1,5 @@ -import { unlink, readFile } from 'fs/promises'; -import { join } from 'path'; +import { unlink, readFile } from 'node:fs/promises'; +import { join } from 'node:path'; import { log, die, LogLevel } from '../utils/log'; import { exists } from '../utils/io'; import { SupportedPlatform, CURRENT_PLATFORM } from '../utils/platform'; diff --git a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/extractors/common/app-artifact-locator.ts b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/extractors/common/app-artifact-locator.ts index 7c6bec64..698b2aa0 100644 --- a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/extractors/common/app-artifact-locator.ts +++ b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/extractors/common/app-artifact-locator.ts @@ -1,5 +1,5 @@ -import { join } from 'path'; -import { readdir } from 'fs/promises'; +import { join } from 'node:path'; +import { readdir } from 'node:fs/promises'; import { die } from '../../../utils/log'; import { exists } from '../../../utils/io'; import { getAppName } from '../../../utils/npm'; diff --git a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/extractors/linux.ts b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/extractors/linux.ts index cfdd250e..3d77f515 100644 --- a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/extractors/linux.ts +++ b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/extractors/linux.ts @@ -1,5 +1,5 @@ -import { access, chmod } from 'fs/promises'; -import { constants } from 'fs'; +import { access, chmod } from 'node:fs/promises'; +import { constants } from 'node:fs'; import { log } from '../../utils/log'; import { ExtractionResult } from './common/extraction-result'; import { findByFilePattern } from './common/app-artifact-locator'; diff --git a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/extractors/windows.ts b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/extractors/windows.ts index e93ae96c..9accc130 100644 --- a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/extractors/windows.ts +++ b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/extractors/windows.ts @@ -1,6 +1,6 @@ -import { mkdtemp, rm } from 'fs/promises'; -import { join } from 'path'; -import { tmpdir } from 'os'; +import { mkdtemp, rm } from 'node:fs/promises'; +import { join } from 'node:path'; +import { tmpdir } from 'node:os'; import { exists } from '../../utils/io'; import { log, die, LogLevel } from '../../utils/log'; import { runCommand } from '../../utils/run-command'; diff --git a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/runner.ts b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/runner.ts index bd792aac..8c7b8b28 100644 --- a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/runner.ts +++ b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/runner.ts @@ -1,8 +1,7 @@ -import { spawn } from 'child_process'; +import { spawn, type ChildProcess } from 'node:child_process'; import { log, LogLevel, die } from '../utils/log'; import { captureScreen } from './system-capture/screen-capture'; import { captureWindowTitles } from './system-capture/window-title-capture'; -import type { ChildProcess } from 'child_process'; const TERMINATION_GRACE_PERIOD_IN_SECONDS = 20; const TERMINATION_CHECK_INTERVAL_IN_MS = 1000; diff --git a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/system-capture/screen-capture.ts b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/system-capture/screen-capture.ts index f09b5334..b8655231 100644 --- a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/system-capture/screen-capture.ts +++ b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/app/system-capture/screen-capture.ts @@ -1,4 +1,4 @@ -import { unlink } from 'fs/promises'; +import { unlink } from 'node:fs/promises'; import { runCommand } from '../../utils/run-command'; import { log, LogLevel } from '../../utils/log'; import { CURRENT_PLATFORM, SupportedPlatform } from '../../utils/platform'; diff --git a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/config.ts b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/config.ts index ff437fda..f68fc3c3 100644 --- a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/config.ts +++ b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/config.ts @@ -1,4 +1,4 @@ -import { join } from 'path'; +import { join } from 'node:path'; import distDirs from '@/../dist-dirs.json' assert { type: 'json' }; export const DESKTOP_BUILD_COMMAND = [ diff --git a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/utils/io.ts b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/utils/io.ts index de7b18dd..9599301a 100644 --- a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/utils/io.ts +++ b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/utils/io.ts @@ -1,5 +1,5 @@ -import { readdir, access } from 'fs/promises'; -import { constants } from 'fs'; +import { readdir, access } from 'node:fs/promises'; +import { constants } from 'node:fs'; export async function exists(path: string): Promise { if (!path) { throw new Error('Missing path'); } diff --git a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/utils/npm.ts b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/utils/npm.ts index 414a6c9f..0fe27357 100644 --- a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/utils/npm.ts +++ b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/utils/npm.ts @@ -1,5 +1,5 @@ -import { join } from 'path'; -import { rm, readFile } from 'fs/promises'; +import { join } from 'node:path'; +import { rm, readFile } from 'node:fs/promises'; import { exists, isDirMissingOrEmpty } from './io'; import { runCommand } from './run-command'; import { LogLevel, die, log } from './log'; diff --git a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/utils/platform.ts b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/utils/platform.ts index 45241d40..d638204a 100644 --- a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/utils/platform.ts +++ b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/utils/platform.ts @@ -1,4 +1,4 @@ -import { platform } from 'os'; +import { platform } from 'node:os'; import { die } from './log'; export enum SupportedPlatform { diff --git a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/utils/run-command.ts b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/utils/run-command.ts index 1eb38dd8..fe3c96f1 100644 --- a/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/utils/run-command.ts +++ b/tests/checks/desktop-runtime-errors/check-desktop-runtime-errors/utils/run-command.ts @@ -1,6 +1,5 @@ -import { exec } from 'child_process'; +import { exec, type ExecOptions, type ExecException } from 'node:child_process'; import { indentText } from './text'; -import type { ExecOptions, ExecException } from 'child_process'; const TIMEOUT_IN_SECONDS = 180; const MAX_OUTPUT_BUFFER_SIZE = 1024 * 1024; // 1 MB diff --git a/tests/checks/external-urls/StatusChecker/FetchWithTimeout.ts b/tests/checks/external-urls/StatusChecker/FetchWithTimeout.ts index f4d480f3..f5144df9 100644 --- a/tests/checks/external-urls/StatusChecker/FetchWithTimeout.ts +++ b/tests/checks/external-urls/StatusChecker/FetchWithTimeout.ts @@ -1,5 +1,3 @@ -import fetch from 'cross-fetch'; - export async function fetchWithTimeout( url: string, timeoutInMs: number, diff --git a/tests/unit/application/collections/NoUnintentedInlining.spec.ts b/tests/unit/application/collections/NoUnintentedInlining.spec.ts index ba402c7e..179ca633 100644 --- a/tests/unit/application/collections/NoUnintentedInlining.spec.ts +++ b/tests/unit/application/collections/NoUnintentedInlining.spec.ts @@ -1,5 +1,5 @@ -import { readdirSync, readFileSync } from 'fs'; -import { resolve, join, basename } from 'path'; +import { readdirSync, readFileSync } from 'node:fs'; +import { resolve, join, basename } from 'node:path'; import { describe, it, expect } from 'vitest'; import { formatAssertionMessage } from '@tests/shared/FormatAssertionMessage'; diff --git a/vite-config-helper.ts b/vite-config-helper.ts index 7e765156..6a55452b 100644 --- a/vite-config-helper.ts +++ b/vite-config-helper.ts @@ -1,5 +1,5 @@ -import { resolve, dirname } from 'path'; -import { fileURLToPath } from 'url'; +import { resolve, dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; import { VITE_USER_DEFINED_ENVIRONMENT_KEYS } from './src/infrastructure/EnvironmentVariables/Vite/ViteEnvironmentKeys'; import tsconfigJson from './tsconfig.json' assert { type: 'json' }; import packageJson from './package.json' assert { type: 'json' }; diff --git a/vite.config.ts b/vite.config.ts index c288de43..eea83a66 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,5 +1,5 @@ /// -import { resolve } from 'path'; +import { resolve } from 'node:path'; import { defineConfig, UserConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; import legacy from '@vitejs/plugin-legacy';