diff --git a/apps/desktop/configs/vite.electron-render.config.ts b/apps/desktop/configs/vite.electron-render.config.ts index 8dc887732..40c180c8e 100644 --- a/apps/desktop/configs/vite.electron-render.config.ts +++ b/apps/desktop/configs/vite.electron-render.config.ts @@ -1,7 +1,6 @@ -import { dirname } from "node:path" -import { resolve } from "node:path/posix" import { fileURLToPath } from "node:url" +import { dirname, resolve } from "pathe" import { tsImport } from "tsx/esm/api" import type { UserConfig } from "vite" diff --git a/apps/desktop/configs/vite.render.config.ts b/apps/desktop/configs/vite.render.config.ts index 2b53085bb..61e74acf5 100644 --- a/apps/desktop/configs/vite.render.config.ts +++ b/apps/desktop/configs/vite.render.config.ts @@ -1,10 +1,10 @@ import { readFileSync } from "node:fs" -import { dirname, resolve } from "node:path" import { fileURLToPath } from "node:url" import { sentryVitePlugin } from "@sentry/vite-plugin" import react from "@vitejs/plugin-react" import { codeInspectorPlugin } from "code-inspector-plugin" +import { dirname, resolve } from "pathe" import { prerelease } from "semver" import type { UserConfig } from "vite" diff --git a/apps/desktop/electron.vite.config.ts b/apps/desktop/electron.vite.config.ts index cf1bee1fd..56a904d7a 100644 --- a/apps/desktop/electron.vite.config.ts +++ b/apps/desktop/electron.vite.config.ts @@ -1,6 +1,5 @@ -import { resolve } from "node:path" - import { defineConfig } from "electron-vite" +import { resolve } from "pathe" import { getGitHash } from "../../scripts/lib" import rendererConfig from "./configs/vite.electron-render.config" diff --git a/apps/desktop/forge.config.cts b/apps/desktop/forge.config.cts index 4663a6caf..2392ae093 100644 --- a/apps/desktop/forge.config.cts +++ b/apps/desktop/forge.config.cts @@ -3,7 +3,6 @@ import "dotenv/config" import crypto from "node:crypto" import fs, { readdirSync } from "node:fs" import { cp, readdir } from "node:fs/promises" -import path, { resolve } from "node:path" import { FuseV1Options, FuseVersion } from "@electron/fuses" import { MakerAppX } from "@electron-forge/maker-appx" @@ -16,6 +15,7 @@ import type { ForgeConfig } from "@electron-forge/shared-types" import MakerAppImage from "@pengx17/electron-forge-maker-appimage" import setLanguages from "electron-packager-languages" import yaml from "js-yaml" +import path, { resolve } from "pathe" import { rimraf, rimrafSync } from "rimraf" const platform = process.argv.find((arg) => arg.startsWith("--platform"))?.split("=")[1] diff --git a/apps/desktop/layer/main/src/before-bootstrap.ts b/apps/desktop/layer/main/src/before-bootstrap.ts index 87a50fc7a..797f0ef36 100644 --- a/apps/desktop/layer/main/src/before-bootstrap.ts +++ b/apps/desktop/layer/main/src/before-bootstrap.ts @@ -1,6 +1,5 @@ -import path from "node:path" - import { app, protocol } from "electron" +import path from "pathe" import { initializeSentry } from "./sentry" diff --git a/apps/desktop/layer/main/src/constants/app.ts b/apps/desktop/layer/main/src/constants/app.ts index 33c1b5612..ac17dfed8 100644 --- a/apps/desktop/layer/main/src/constants/app.ts +++ b/apps/desktop/layer/main/src/constants/app.ts @@ -1,6 +1,5 @@ -import path from "node:path" - import { app } from "electron" +import path from "pathe" export const UNREAD_BACKGROUND_POLLING_INTERVAL = 1000 * 60 * 5 diff --git a/apps/desktop/layer/main/src/helper.ts b/apps/desktop/layer/main/src/helper.ts index e5387c219..db18b5e6c 100644 --- a/apps/desktop/layer/main/src/helper.ts +++ b/apps/desktop/layer/main/src/helper.ts @@ -1,7 +1,7 @@ -import path from "node:path" import { fileURLToPath, pathToFileURL } from "node:url" import { MODE, ModeEnum } from "@follow/shared/constants" +import path from "pathe" import { isMacOS, isWindows } from "./env" diff --git a/apps/desktop/layer/main/src/ipc/services/app.ts b/apps/desktop/layer/main/src/ipc/services/app.ts index 88eaf68b9..edd57ebbe 100644 --- a/apps/desktop/layer/main/src/ipc/services/app.ts +++ b/apps/desktop/layer/main/src/ipc/services/app.ts @@ -1,10 +1,10 @@ import fsp from "node:fs/promises" -import path from "node:path" import { fileURLToPath } from "node:url" import { callWindowExpose } from "@follow/shared/bridge" import { DEV } from "@follow/shared/constants" import { app, BrowserWindow, clipboard, dialog, shell } from "electron" +import path from "pathe" import { getCacheSize } from "~/lib/cleaner" import { i18n } from "~/lib/i18n" diff --git a/apps/desktop/layer/main/src/ipc/services/integration.ts b/apps/desktop/layer/main/src/ipc/services/integration.ts index 1b0e00564..ff7780ea9 100644 --- a/apps/desktop/layer/main/src/ipc/services/integration.ts +++ b/apps/desktop/layer/main/src/ipc/services/integration.ts @@ -1,8 +1,8 @@ import { existsSync } from "node:fs" import fsp from "node:fs/promises" -import path from "node:path" import slugify from "@sindresorhus/slugify" +import path from "pathe" import type { IpcContext } from "../base" import { IpcMethod, IpcService } from "../base" diff --git a/apps/desktop/layer/main/src/ipc/services/reader.ts b/apps/desktop/layer/main/src/ipc/services/reader.ts index 67233ffea..df84b8841 100644 --- a/apps/desktop/layer/main/src/ipc/services/reader.ts +++ b/apps/desktop/layer/main/src/ipc/services/reader.ts @@ -1,10 +1,10 @@ import fs from "node:fs" -import path from "node:path" import { callWindowExpose } from "@follow/shared/bridge" import { readability } from "@follow-app/readability" import { app, BrowserWindow } from "electron" import { MsEdgeTTS, OUTPUT_FORMAT } from "msedge-tts" +import path from "pathe" import type { ModelResult } from "vscode-languagedetection" import { detectCodeStringLanguage } from "../../modules/language-detection" diff --git a/apps/desktop/layer/main/src/lib/cleaner.ts b/apps/desktop/layer/main/src/lib/cleaner.ts index 6f95feda2..5e9f6cc9f 100644 --- a/apps/desktop/layer/main/src/lib/cleaner.ts +++ b/apps/desktop/layer/main/src/lib/cleaner.ts @@ -1,9 +1,9 @@ import { statSync } from "node:fs" import fsp from "node:fs/promises" -import path from "node:path" import { callWindowExpose } from "@follow/shared/bridge" import { app, dialog } from "electron" +import path from "pathe" import { getIconPath } from "~/helper" import { logger } from "~/logger" diff --git a/apps/desktop/layer/main/src/manager/app.ts b/apps/desktop/layer/main/src/manager/app.ts index c02676b03..5cab6fd74 100644 --- a/apps/desktop/layer/main/src/manager/app.ts +++ b/apps/desktop/layer/main/src/manager/app.ts @@ -1,5 +1,3 @@ -import path from "node:path" - import { PushReceiver } from "@eneris/push-receiver" import { callWindowExpose } from "@follow/shared/bridge" import { APP_PROTOCOL, DEV, LEGACY_APP_PROTOCOL } from "@follow/shared/constants" @@ -7,6 +5,7 @@ import { env } from "@follow/shared/env.desktop" import type { MessagingData } from "@follow/shared/hono" import { app, nativeTheme, Notification, shell } from "electron" import contextMenu from "electron-context-menu" +import path from "pathe" import { WindowManager } from "~/manager/window" diff --git a/apps/desktop/layer/main/src/manager/window.ts b/apps/desktop/layer/main/src/manager/window.ts index c4aa24972..286db9eb4 100644 --- a/apps/desktop/layer/main/src/manager/window.ts +++ b/apps/desktop/layer/main/src/manager/window.ts @@ -1,4 +1,3 @@ -import path from "node:path" import { fileURLToPath } from "node:url" import { is } from "@electron-toolkit/utils" @@ -8,6 +7,7 @@ import { APP_PROTOCOL, DEV } from "@follow/shared/constants" import type { BrowserWindowConstructorOptions } from "electron" import { app, BrowserWindow, screen, shell } from "electron" import type { Event } from "electron/main" +import path from "pathe" import { START_IN_TRAY_ARGS } from "~/constants/app" import { isMacOS, isWindows, isWindows11 } from "~/env" diff --git a/apps/desktop/layer/main/src/updater/configs.ts b/apps/desktop/layer/main/src/updater/configs.ts index 5de1b88bb..9432099d3 100644 --- a/apps/desktop/layer/main/src/updater/configs.ts +++ b/apps/desktop/layer/main/src/updater/configs.ts @@ -1,6 +1,5 @@ -import path from "node:path" - import { DEV, MODE, ModeEnum } from "@follow/shared/constants" +import path from "pathe" import { isWindows } from "../env" diff --git a/apps/desktop/layer/main/src/updater/hot-updater.ts b/apps/desktop/layer/main/src/updater/hot-updater.ts index d3537f875..8703209c2 100644 --- a/apps/desktop/layer/main/src/updater/hot-updater.ts +++ b/apps/desktop/layer/main/src/updater/hot-updater.ts @@ -5,12 +5,12 @@ import { createHash } from "node:crypto" import { existsSync, readFileSync } from "node:fs" import { mkdir, readdir, rename, rm, stat, writeFile } from "node:fs/promises" import os from "node:os" -import path from "node:path" import { callWindowExpose } from "@follow/shared/bridge" import { mainHash, version as appVersion } from "@pkg" import log from "electron-log" import { load } from "js-yaml" +import path from "pathe" import { x } from "tar" import { GITHUB_OWNER, GITHUB_REPO, HOTUPDATE_RENDER_ENTRY_DIR } from "~/constants/app" diff --git a/apps/desktop/layer/main/src/updater/utils.ts b/apps/desktop/layer/main/src/updater/utils.ts index 99dc8caf7..d81bf1389 100644 --- a/apps/desktop/layer/main/src/updater/utils.ts +++ b/apps/desktop/layer/main/src/updater/utils.ts @@ -1,7 +1,7 @@ import fs from "node:fs" -import path from "node:path" import { app } from "electron" +import path from "pathe" import { major, minor } from "semver" let _isSquirrelBuild: boolean | null = null diff --git a/apps/desktop/layer/renderer/vitest.config.ts b/apps/desktop/layer/renderer/vitest.config.ts index 480f82798..bb822dadf 100644 --- a/apps/desktop/layer/renderer/vitest.config.ts +++ b/apps/desktop/layer/renderer/vitest.config.ts @@ -1,7 +1,7 @@ import { readFileSync } from "node:fs" -import { resolve } from "node:path" import { fileURLToPath } from "node:url" +import { resolve } from "pathe" import tsconfigPath from "vite-tsconfig-paths" import { defineProject } from "vitest/config" diff --git a/apps/desktop/package.json b/apps/desktop/package.json index f844b9cde..ac3b7ceea 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -35,7 +35,8 @@ }, "dependencies": { "@hcaptcha/react-hcaptcha": "1.12.0", - "cookie-es": "2.0.0" + "cookie-es": "2.0.0", + "pathe": "2.0.3" }, "devDependencies": { "@clack/prompts": "0.11.0", diff --git a/apps/desktop/plugins/vite/cleanup.ts b/apps/desktop/plugins/vite/cleanup.ts index de2ca1af3..510efe31c 100644 --- a/apps/desktop/plugins/vite/cleanup.ts +++ b/apps/desktop/plugins/vite/cleanup.ts @@ -1,6 +1,6 @@ import fs from "node:fs" -import path from "node:path" +import path from "pathe" import type { Plugin, ResolvedConfig } from "vite" export function cleanupUnnecessaryFilesPlugin(files: string[]): Plugin { diff --git a/apps/desktop/plugins/vite/compress.ts b/apps/desktop/plugins/vite/compress.ts index bd81b8904..c9a6b370f 100644 --- a/apps/desktop/plugins/vite/compress.ts +++ b/apps/desktop/plugins/vite/compress.ts @@ -1,8 +1,8 @@ import { execSync } from "node:child_process" import { createHash } from "node:crypto" import fs from "node:fs/promises" -import path from "node:path" +import path from "pathe" import * as tar from "tar" import type { Plugin } from "vite" diff --git a/apps/desktop/plugins/vite/generate-main-hash.ts b/apps/desktop/plugins/vite/generate-main-hash.ts index 938f202a7..c99f4cd6a 100644 --- a/apps/desktop/plugins/vite/generate-main-hash.ts +++ b/apps/desktop/plugins/vite/generate-main-hash.ts @@ -1,8 +1,8 @@ import { createHash } from "node:crypto" import fs from "node:fs/promises" -import path from "node:path" import fg from "fast-glob" +import path from "pathe" export async function calculateMainHash(mainDir: string): Promise { // Get all TypeScript files in the main directory recursively diff --git a/apps/desktop/plugins/vite/hmr.ts b/apps/desktop/plugins/vite/hmr.ts index b5b2706d0..43b8821a9 100644 --- a/apps/desktop/plugins/vite/hmr.ts +++ b/apps/desktop/plugins/vite/hmr.ts @@ -1,6 +1,5 @@ -import path from "node:path" - import { red, yellow } from "kolorist" +import path from "pathe" import type { HmrContext, Plugin } from "vite" function isNodeWithinCircularImports( diff --git a/apps/desktop/plugins/vite/locales-json.ts b/apps/desktop/plugins/vite/locales-json.ts index 166a7795f..c16ba558d 100644 --- a/apps/desktop/plugins/vite/locales-json.ts +++ b/apps/desktop/plugins/vite/locales-json.ts @@ -1,7 +1,7 @@ -import path from "node:path" import { fileURLToPath } from "node:url" import { set } from "es-toolkit/compat" +import path from "pathe" import type { Logger, Plugin } from "vite" const __dirname = fileURLToPath(new URL(".", import.meta.url)) diff --git a/apps/desktop/plugins/vite/locales.ts b/apps/desktop/plugins/vite/locales.ts index a6b80bae3..7bb3a1409 100644 --- a/apps/desktop/plugins/vite/locales.ts +++ b/apps/desktop/plugins/vite/locales.ts @@ -1,8 +1,8 @@ import fs from "node:fs" -import path, { dirname } from "node:path" import { fileURLToPath } from "node:url" import { set } from "es-toolkit/compat" +import path, { dirname } from "pathe" import type { Plugin } from "vite" export function localesPlugin(): Plugin { diff --git a/apps/desktop/plugins/vite/manifest.ts b/apps/desktop/plugins/vite/manifest.ts index fb42a7648..6b4da6d07 100644 --- a/apps/desktop/plugins/vite/manifest.ts +++ b/apps/desktop/plugins/vite/manifest.ts @@ -1,6 +1,6 @@ import fs from "node:fs" -import path from "node:path" +import path from "pathe" import type { Plugin } from "vite" export default function manifestPlugin(): Plugin { diff --git a/apps/desktop/plugins/vite/utils/i18n-completeness.ts b/apps/desktop/plugins/vite/utils/i18n-completeness.ts index 50d566d16..3da7688fb 100644 --- a/apps/desktop/plugins/vite/utils/i18n-completeness.ts +++ b/apps/desktop/plugins/vite/utils/i18n-completeness.ts @@ -1,7 +1,8 @@ import fs from "node:fs" -import path, { dirname } from "node:path" import { fileURLToPath } from "node:url" +import path, { dirname } from "pathe" + type LanguageCompletion = Record function getLanguageFiles(dir: string): string[] { diff --git a/apps/desktop/scripts/apply-changelog.ts b/apps/desktop/scripts/apply-changelog.ts index ff252696a..ef3af6d85 100644 --- a/apps/desktop/scripts/apply-changelog.ts +++ b/apps/desktop/scripts/apply-changelog.ts @@ -1,7 +1,8 @@ import { copyFileSync, readFileSync, renameSync, writeFileSync } from "node:fs" -import { dirname, join } from "node:path" import { fileURLToPath } from "node:url" +import { dirname, join } from "pathe" + const __dirname = dirname(fileURLToPath(import.meta.url)) const changelogDir = join(__dirname, "..", "changelog") diff --git a/apps/desktop/scripts/merge-yml.ts b/apps/desktop/scripts/merge-yml.ts index 223e74a97..f28562c8c 100644 --- a/apps/desktop/scripts/merge-yml.ts +++ b/apps/desktop/scripts/merge-yml.ts @@ -1,7 +1,7 @@ import fs from "node:fs" -import path from "node:path" import yaml from "js-yaml" +import path from "pathe" const outDir = "./out/make" diff --git a/apps/desktop/vite.config.electron-render.ts b/apps/desktop/vite.config.electron-render.ts index 851093c88..f43f282cb 100644 --- a/apps/desktop/vite.config.electron-render.ts +++ b/apps/desktop/vite.config.electron-render.ts @@ -1,5 +1,4 @@ -import { resolve } from "node:path" - +import { resolve } from "pathe" import { defineConfig } from "vite" import config from "./configs/vite.electron-render.config" diff --git a/apps/desktop/vite.config.ts b/apps/desktop/vite.config.ts index b02630fcf..8aec3aba3 100644 --- a/apps/desktop/vite.config.ts +++ b/apps/desktop/vite.config.ts @@ -1,5 +1,4 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs" -import { resolve } from "node:path" import { fileURLToPath } from "node:url" import type { env as EnvType } from "@follow/shared/env.desktop" @@ -7,6 +6,7 @@ import legacy from "@vitejs/plugin-legacy" import { minify as htmlMinify } from "html-minifier-terser" import { cyan, dim, green } from "kolorist" import { parseHTML } from "linkedom" +import { resolve } from "pathe" import { tsImport } from "tsx/esm/api" import type { PluginOption, ResolvedConfig, ViteDevServer } from "vite" import { defineConfig, loadEnv } from "vite" diff --git a/apps/mobile/app.config.ts b/apps/mobile/app.config.ts index 28459bd54..598f273c4 100644 --- a/apps/mobile/app.config.ts +++ b/apps/mobile/app.config.ts @@ -1,6 +1,5 @@ -import { resolve } from "node:path" - import type { ConfigContext, ExpoConfig } from "expo/config" +import { resolve } from "pathe" import PKG from "./package.json" diff --git a/apps/mobile/metro.config.js b/apps/mobile/metro.config.js index b4934a582..59e6d60a3 100644 --- a/apps/mobile/metro.config.js +++ b/apps/mobile/metro.config.js @@ -1,6 +1,6 @@ const { getDefaultConfig } = require("expo/metro-config") const { withNativeWind } = require("nativewind/metro") -const path = require("node:path") +const path = require("pathe") const { wrapWithReanimatedMetroConfig } = require("react-native-reanimated/metro-config") const config = getDefaultConfig(__dirname, { isCSSEnabled: true }) diff --git a/apps/mobile/native/example/metro.config.js b/apps/mobile/native/example/metro.config.js index f839621f7..cf7e0e4b6 100644 --- a/apps/mobile/native/example/metro.config.js +++ b/apps/mobile/native/example/metro.config.js @@ -1,6 +1,6 @@ const { getDefaultConfig } = require("expo/metro-config") const { withNativeWind } = require("nativewind/metro") -const path = require("node:path") +const path = require("pathe") const { wrapWithReanimatedMetroConfig } = require("react-native-reanimated/metro-config") const config = getDefaultConfig(__dirname, { isCSSEnabled: true }) diff --git a/apps/mobile/plugins/android-trust-user-certs.js b/apps/mobile/plugins/android-trust-user-certs.js index 897fb6e0c..d56fb2967 100644 --- a/apps/mobile/plugins/android-trust-user-certs.js +++ b/apps/mobile/plugins/android-trust-user-certs.js @@ -1,6 +1,6 @@ const { AndroidConfig, withAndroidManifest } = require("@expo/config-plugins") const { Paths } = require("@expo/config-plugins/build/android") -const path = require("node:path") +const path = require("pathe") const fs = require("node:fs") const fsPromises = fs.promises diff --git a/apps/mobile/plugins/with-follow-assets.js b/apps/mobile/plugins/with-follow-assets.js index 63fb9fba1..2ca6026a2 100644 --- a/apps/mobile/plugins/with-follow-assets.js +++ b/apps/mobile/plugins/with-follow-assets.js @@ -9,7 +9,7 @@ const { withDangerousMod, withXcodeProject, IOSConfig } = require("@expo/config-plugins") const fs = require("node:fs") -const path = require("node:path") +const path = require("pathe") const { execSync } = require("node:child_process") const IOS_GROUP_NAME = "Assets" diff --git a/apps/mobile/scripts/apply-changelog.ts b/apps/mobile/scripts/apply-changelog.ts index fc2887ad2..da6fcfe07 100644 --- a/apps/mobile/scripts/apply-changelog.ts +++ b/apps/mobile/scripts/apply-changelog.ts @@ -1,7 +1,8 @@ import { copyFileSync, readFileSync, renameSync, writeFileSync } from "node:fs" -import { dirname, join } from "node:path" import { fileURLToPath } from "node:url" +import { dirname, join } from "pathe" + // @ts-ignore const __dirname = dirname(fileURLToPath(import.meta.url)) const changelogDir = join(__dirname, "..", "changelog") diff --git a/apps/mobile/web-app/html-renderer/tailwind.config.ts b/apps/mobile/web-app/html-renderer/tailwind.config.ts index c192bc6a3..904483c58 100644 --- a/apps/mobile/web-app/html-renderer/tailwind.config.ts +++ b/apps/mobile/web-app/html-renderer/tailwind.config.ts @@ -1,6 +1,5 @@ -import path from "node:path" - import { extendConfig } from "@follow/configs/tailwindcss/web" +import path from "pathe" const rootDir = path.resolve(__dirname, "../../../..") diff --git a/apps/mobile/web-app/html-renderer/vite.config.mts b/apps/mobile/web-app/html-renderer/vite.config.mts index f3b1c67a5..c66af5a39 100644 --- a/apps/mobile/web-app/html-renderer/vite.config.mts +++ b/apps/mobile/web-app/html-renderer/vite.config.mts @@ -1,6 +1,5 @@ -import path from "node:path" - import react from "@vitejs/plugin-react" +import path from "pathe" import { defineConfig } from "vite" import { viteRenderBaseConfig } from "../../../desktop/configs/vite.render.config" diff --git a/apps/ssr/helper/meta-map.ts b/apps/ssr/helper/meta-map.ts index 5ef86010b..00ddbff15 100644 --- a/apps/ssr/helper/meta-map.ts +++ b/apps/ssr/helper/meta-map.ts @@ -1,10 +1,10 @@ import * as fs from "node:fs/promises" -import * as path from "node:path" -import { dirname } from "node:path" import { fileURLToPath } from "node:url" import chokidar from "chokidar" import fg from "fast-glob" +import * as path from "pathe" +import { dirname } from "pathe" const __dirname = dirname(fileURLToPath(import.meta.url)) diff --git a/apps/ssr/scripts/cleanup-vercel-build.ts b/apps/ssr/scripts/cleanup-vercel-build.ts index 9c0eb1113..9dd51fda3 100644 --- a/apps/ssr/scripts/cleanup-vercel-build.ts +++ b/apps/ssr/scripts/cleanup-vercel-build.ts @@ -1,7 +1,8 @@ import { rmSync } from "node:fs" -import { dirname, resolve } from "node:path" import { fileURLToPath } from "node:url" +import { dirname, resolve } from "pathe" + const __dirname = dirname(fileURLToPath(import.meta.url)) rmSync(resolve(__dirname, "../.generated"), { recursive: true, force: true }) // restore env file diff --git a/apps/ssr/scripts/prepare-vercel-build.ts b/apps/ssr/scripts/prepare-vercel-build.ts index f45eff263..1781b1068 100644 --- a/apps/ssr/scripts/prepare-vercel-build.ts +++ b/apps/ssr/scripts/prepare-vercel-build.ts @@ -1,8 +1,9 @@ import { mkdirSync } from "node:fs" import fs from "node:fs/promises" -import path, { dirname } from "node:path" import { fileURLToPath } from "node:url" +import path, { dirname } from "pathe" + const __dirname = dirname(fileURLToPath(import.meta.url)) mkdirSync(path.join(__dirname, "../.generated"), { recursive: true }) diff --git a/apps/ssr/src/lib/dev-vite.ts b/apps/ssr/src/lib/dev-vite.ts index b961318bd..cc90e0550 100644 --- a/apps/ssr/src/lib/dev-vite.ts +++ b/apps/ssr/src/lib/dev-vite.ts @@ -1,7 +1,7 @@ -import { dirname, resolve } from "node:path" import { fileURLToPath } from "node:url" import type { FastifyInstance } from "fastify" +import { dirname, resolve } from "pathe" import type { ViteDevServer } from "vite" const __dirname = dirname(fileURLToPath(import.meta.url)) diff --git a/apps/ssr/src/lib/og/fonts.ts b/apps/ssr/src/lib/og/fonts.ts index 4b5440fba..69b5172cf 100644 --- a/apps/ssr/src/lib/og/fonts.ts +++ b/apps/ssr/src/lib/og/fonts.ts @@ -1,6 +1,7 @@ import fs from "node:fs" import { createRequire } from "node:module" -import path, { resolve } from "node:path" + +import path, { resolve } from "pathe" const require = createRequire(import.meta.url) diff --git a/apps/ssr/src/router/global.ts b/apps/ssr/src/router/global.ts index f93131db3..7407b2d53 100644 --- a/apps/ssr/src/router/global.ts +++ b/apps/ssr/src/router/global.ts @@ -1,5 +1,4 @@ import { readFileSync } from "node:fs" -import path, { dirname, resolve } from "node:path" import { fileURLToPath } from "node:url" import { env } from "@follow/shared/env.ssr" @@ -7,6 +6,7 @@ import type { FastifyInstance, FastifyReply, FastifyRequest } from "fastify" import { minify } from "html-minifier-terser" import { parseHTML } from "linkedom" import { FetchError } from "ofetch" +import path, { dirname, resolve } from "pathe" import xss from "xss" import { NotFoundError } from "~/lib/not-found" diff --git a/apps/ssr/tsdown.config.ts b/apps/ssr/tsdown.config.ts index c110d7434..ccf78b91f 100644 --- a/apps/ssr/tsdown.config.ts +++ b/apps/ssr/tsdown.config.ts @@ -1,7 +1,7 @@ import { createReadStream, createWriteStream, readdirSync, renameSync } from "node:fs" import { createRequire } from "node:module" -import { resolve } from "node:path" +import { resolve } from "pathe" import { defineConfig } from "tsdown" export default defineConfig({ diff --git a/apps/ssr/vite.config.mts b/apps/ssr/vite.config.mts index 37ec79bc7..dd7bd7038 100644 --- a/apps/ssr/vite.config.mts +++ b/apps/ssr/vite.config.mts @@ -1,8 +1,8 @@ -import { dirname, resolve } from "node:path" import { fileURLToPath } from "node:url" import react from "@vitejs/plugin-react" import { codeInspectorPlugin } from "code-inspector-plugin" +import { dirname, resolve } from "pathe" import { tsImport } from "tsx/esm/api" import { defineConfig } from "vite" diff --git a/eslint.config.mjs b/eslint.config.mjs index 3a1d20c4a..10e6c9150 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,9 +1,8 @@ // @ts-check -import path from "node:path" - import { fixupPluginRules } from "@eslint/compat" import { defineConfig } from "eslint-config-hyoban" import reactNative from "eslint-plugin-react-native" +import path from "pathe" import checkI18nJson from "./plugins/eslint/eslint-check-i18n-json.js" import noDebug from "./plugins/eslint/eslint-no-debug.js" @@ -111,6 +110,23 @@ export default defineConfig( "package-json/require-type": 0, }, }, + { + files: ["**/*.{js,ts,tsx}"], + rules: { + "no-restricted-imports": [ + "error", + { + paths: [ + { + name: "node:path", + message: + "For better cross-platform compatibility, please use 'pathe' instead of 'node:path'", + }, + ], + }, + ], + }, + }, { plugins: { // @ts-expect-error diff --git a/packages/configs/tailwindcss/web.ts b/packages/configs/tailwindcss/web.ts index e5cac32ba..1b47d6f44 100644 --- a/packages/configs/tailwindcss/web.ts +++ b/packages/configs/tailwindcss/web.ts @@ -1,12 +1,11 @@ /* @moduleResolution bundler */ import "./tw-css-plugin" -import path, { resolve } from "node:path" - import { getIconCollections, iconsPlugin } from "@egoist/tailwindcss-icons" import { cleanupSVG, importDirectorySync, isEmptyColor, parseColors, runSVGO } from "@iconify/tools" import { compareColors, stringToColor } from "@iconify/utils/lib/colors" import { merge } from "es-toolkit/compat" +import path, { resolve } from "pathe" import { theme } from "tailwindcss/defaultConfig" import type { Config } from "tailwindcss/types/config" import { withUIKit } from "tailwindcss-uikit-colors/src/macos/tailwind" diff --git a/packages/internal/legal/script/build.ts b/packages/internal/legal/script/build.ts index 1e40590d5..09dd783f6 100644 --- a/packages/internal/legal/script/build.ts +++ b/packages/internal/legal/script/build.ts @@ -1,8 +1,8 @@ import { mkdirSync, readFileSync, writeFileSync } from "node:fs" -import { resolve } from "node:path" import { fileURLToPath } from "node:url" import { marked } from "marked" +import { resolve } from "pathe" // Define paths to markdown and output files const __dirname = fileURLToPath(new URL(".", import.meta.url)) diff --git a/packages/vite-plugin-route-builder/src/__tests__/vite-plugin.test.ts b/packages/vite-plugin-route-builder/src/__tests__/vite-plugin.test.ts index 8095f77c8..c745668c2 100644 --- a/packages/vite-plugin-route-builder/src/__tests__/vite-plugin.test.ts +++ b/packages/vite-plugin-route-builder/src/__tests__/vite-plugin.test.ts @@ -23,7 +23,7 @@ vi.mock("fast-glob", () => ({ }, })) -vi.mock("node:path", () => ({ +vi.mock("pathe", () => ({ resolve: vi.fn((root: string, path: string) => `${root}/${path}`), relative: vi.fn((from: string, to: string) => to.replace(from, "")), dirname: vi.fn((path: string) => path.split("/").slice(0, -1).join("/")), diff --git a/packages/vite-plugin-route-builder/src/vite-plugin-route-builder.ts b/packages/vite-plugin-route-builder/src/vite-plugin-route-builder.ts index 28638d77e..fa734c51b 100644 --- a/packages/vite-plugin-route-builder/src/vite-plugin-route-builder.ts +++ b/packages/vite-plugin-route-builder/src/vite-plugin-route-builder.ts @@ -1,8 +1,8 @@ import { writeFileSync } from "node:fs" -import { dirname, relative, resolve } from "node:path" import { inspect } from "node:util" import glob from "fast-glob" +import { dirname, relative, resolve } from "pathe" import type { Logger, Plugin } from "vite" import { buildGlobRoutes } from "./utils/route-builder" diff --git a/plugins/eslint/eslint-check-i18n-json.js b/plugins/eslint/eslint-check-i18n-json.js index 44125fd87..7b3496c19 100644 --- a/plugins/eslint/eslint-check-i18n-json.js +++ b/plugins/eslint/eslint-check-i18n-json.js @@ -1,7 +1,8 @@ // @ts-check /** @type {import("eslint").ESLint.Plugin} */ import fs from "node:fs" -import path from "node:path" + +import path from "pathe" import { cleanJsonText } from "../utils.js" diff --git a/plugins/eslint/eslint-package-json.js b/plugins/eslint/eslint-package-json.js index bea9732ba..c5a570eb2 100644 --- a/plugins/eslint/eslint-package-json.js +++ b/plugins/eslint/eslint-package-json.js @@ -1,9 +1,9 @@ // @ts-check import fs from "node:fs" -import path from "node:path" import process from "node:process" import fg from "fast-glob" +import path from "pathe" const dependencyKeys = ["dependencies", "devDependencies"] diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e9cfd3642..5ec818048 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -167,6 +167,9 @@ importers: cookie-es: specifier: 2.0.0 version: 2.0.0 + pathe: + specifier: 2.0.3 + version: 2.0.3 devDependencies: '@clack/prompts': specifier: 0.11.0 diff --git a/scripts/copy-translation.ts b/scripts/copy-translation.ts index 0fc806008..a18f324ee 100644 --- a/scripts/copy-translation.ts +++ b/scripts/copy-translation.ts @@ -1,5 +1,6 @@ import fs from "node:fs" -import path from "node:path" + +import path from "pathe" const sourceDir = "./locales/app" const targetDir = "./locales/mobile/default" diff --git a/scripts/generate-i18n-locale.ts b/scripts/generate-i18n-locale.ts index d2f1a295d..30cb9a342 100644 --- a/scripts/generate-i18n-locale.ts +++ b/scripts/generate-i18n-locale.ts @@ -1,9 +1,9 @@ import { execSync } from "node:child_process" import { readdirSync, readFileSync, writeFileSync } from "node:fs" -import path, { dirname } from "node:path" import { fileURLToPath } from "node:url" import { intro, outro, select } from "@clack/prompts" +import path, { dirname } from "pathe" import color from "picocolors" import * as ts from "typescript" diff --git a/scripts/svg-to-rn.ts b/scripts/svg-to-rn.ts index 9c5cb6dec..fdd95c4fd 100644 --- a/scripts/svg-to-rn.ts +++ b/scripts/svg-to-rn.ts @@ -1,6 +1,6 @@ import fs from "node:fs" -import path from "node:path" +import path from "pathe" import { parse } from "svg-parser" const DIST_DIR = "apps/mobile/src/icons" diff --git a/scripts/update-icon.ts b/scripts/update-icon.ts index 4074d440e..10896ba72 100644 --- a/scripts/update-icon.ts +++ b/scripts/update-icon.ts @@ -1,5 +1,6 @@ import fs from "node:fs" -import path from "node:path" + +import path from "pathe" const PATH_TO_NEW_ICONS_FOLDER = "../SVG 1.36" const PATH_TO_PROJECT_ICONS_FOLDER = "./icons/mgc"