mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-07 22:18:39 +00:00
fix
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
@@ -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") {
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user