From 0d7a0057142c69289762cb4de2271c1f3893ee6c Mon Sep 17 00:00:00 2001 From: shadcn Date: Mon, 16 Mar 2026 16:53:59 +0400 Subject: [PATCH] fix --- .../shadcn/src/preflights/preflight-init.test.ts | 13 ++++++------- packages/shadcn/src/utils/alias.test.ts | 3 +-- packages/shadcn/src/utils/alias.ts | 5 +---- packages/shadcn/src/utils/package-imports.ts | 6 ++---- packages/shadcn/src/utils/workspace.ts | 9 +++------ 5 files changed, 13 insertions(+), 23 deletions(-) diff --git a/packages/shadcn/src/preflights/preflight-init.test.ts b/packages/shadcn/src/preflights/preflight-init.test.ts index f0614d7af..b8e8da471 100644 --- a/packages/shadcn/src/preflights/preflight-init.test.ts +++ b/packages/shadcn/src/preflights/preflight-init.test.ts @@ -1,3 +1,4 @@ +import { preFlightInit } from "@/src/preflights/preflight-init" import { afterEach, describe, expect, test, vi } from "vitest" import { z } from "zod" @@ -58,8 +59,6 @@ vi.mock("fs-extra", () => ({ }, })) -import { preFlightInit } from "@/src/preflights/preflight-init" - const baseProjectInfo = { framework: { name: "next-app", @@ -118,11 +117,11 @@ describe("preFlightInit", () => { aliasPrefix: null, }) - const exitSpy = vi - .spyOn(process, "exit") - .mockImplementation(((code?: string | number | null) => { - throw new Error(`process.exit:${code ?? ""}`) - }) as never) + const exitSpy = vi.spyOn(process, "exit").mockImplementation((( + code?: string | number | null + ) => { + throw new Error(`process.exit:${code ?? ""}`) + }) as never) await expect(preFlightInit(baseOptions)).rejects.toThrow("process.exit:1") diff --git a/packages/shadcn/src/utils/alias.test.ts b/packages/shadcn/src/utils/alias.test.ts index 7f4054dd0..72133716c 100644 --- a/packages/shadcn/src/utils/alias.test.ts +++ b/packages/shadcn/src/utils/alias.test.ts @@ -1,9 +1,8 @@ -import { describe, expect, test } from "vitest" - import { deriveAliasFromComponents, getInitAliasDefaults, } from "@/src/utils/alias" +import { describe, expect, test } from "vitest" describe("deriveAliasFromComponents", () => { test("derives ui aliases from components", () => { diff --git a/packages/shadcn/src/utils/alias.ts b/packages/shadcn/src/utils/alias.ts index 02185ede9..eb4b5c65a 100644 --- a/packages/shadcn/src/utils/alias.ts +++ b/packages/shadcn/src/utils/alias.ts @@ -43,10 +43,7 @@ export function deriveAliasFromComponents( return replaceComponentsAliasTail(alias, kind) } -function replaceComponentsAliasTail( - alias: string, - kind: "lib" | "hooks" -) { +function replaceComponentsAliasTail(alias: string, kind: "lib" | "hooks") { // Handles the common `@/components` and `#custom/components` forms by // swapping the trailing `components` segment for a sibling alias root. if (alias === "components") { diff --git a/packages/shadcn/src/utils/package-imports.ts b/packages/shadcn/src/utils/package-imports.ts index 6fb8c728a..f6d3dbe41 100644 --- a/packages/shadcn/src/utils/package-imports.ts +++ b/packages/shadcn/src/utils/package-imports.ts @@ -8,6 +8,7 @@ import { type ImportResolutionEntry, type ImportResolutionMatch, } from "@/src/utils/import-matcher" + export type { ImportEmitMode } from "@/src/utils/import-matcher" export type PackageImportEntry = ImportResolutionEntry export type PackageImportMatch = ImportResolutionMatch @@ -67,10 +68,7 @@ export function getPackageImportPrefix(cwd: string) { return getSharedPackageImportPrefix(aliases) } -export function resolvePackageImport( - importPath: string, - cwd: string -) { +export function resolvePackageImport(importPath: string, cwd: string) { return resolveImportEntryMatch(importPath, getPackageImportEntries(cwd)) } diff --git a/packages/shadcn/src/utils/workspace.ts b/packages/shadcn/src/utils/workspace.ts index b04fcc4dc..04d357d8d 100644 --- a/packages/shadcn/src/utils/workspace.ts +++ b/packages/shadcn/src/utils/workspace.ts @@ -1,8 +1,6 @@ import path from "path" import { getWorkspacePatterns } from "@/src/utils/get-monorepo-info" import { getPackageInfo } from "@/src/utils/get-package-info" -import fg from "fast-glob" -import fs from "fs-extra" import { getImportTargetEmitMode, resolveImportEntryMatch, @@ -11,6 +9,8 @@ import { type ImportResolutionEntry, type ImportResolutionMatch, } from "@/src/utils/import-matcher" +import fg from "fast-glob" +import fs from "fs-extra" type WorkspacePackageInfo = { packageName: string @@ -106,10 +106,7 @@ function getWorkspacePackageExportEntries( return entries } -async function findWorkspacePackage( - cwd: string, - packageName: string -) { +async function findWorkspacePackage(cwd: string, packageName: string) { const workspaceRoot = await findWorkspaceRoot(cwd) if (!workspaceRoot) {