mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-12 10:45:10 +08:00
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import findWorkspacePackages from '@pnpm/find-workspace-packages'
|
|
import { projRoot } from './paths'
|
|
import type { ProjectManifest } from '@pnpm/types'
|
|
|
|
export const getWorkspacePackages = () => findWorkspacePackages(projRoot)
|
|
export const getWorkspaceNames = async () => {
|
|
const pkgs = await findWorkspacePackages(projRoot)
|
|
return pkgs
|
|
.map((pkg) => pkg.manifest.name)
|
|
.filter((name): name is string => !!name)
|
|
}
|
|
export const getWorkspacePackageManifest = async (
|
|
name: string
|
|
): Promise<ProjectManifest> => {
|
|
const packages = await getWorkspacePackages()
|
|
const { manifest } = packages.find((pkg) => pkg.manifest.name === name)!
|
|
return manifest
|
|
}
|
|
|
|
export const getPackageManifest = (pkgPath: string) => {
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
return require(pkgPath) as ProjectManifest
|
|
}
|
|
|
|
export const getPackageDependencies = (pkgPath: string): string[] => {
|
|
const manifest = getPackageManifest(pkgPath)
|
|
const { dependencies } = manifest
|
|
return Object.keys(dependencies ?? {})
|
|
}
|