Files
element-plus/internal/build-utils/src/pkg.ts
一只前端汪 7c16480bcd refactor(style): Update Eslint to V9 and Prettier to V3 (#21949)
* refactor(style): Update Eslint to V9 and Prettier to V3

* fix: vscode color

* fix: vscode color

* chore: remove Useless dependence and old config file

* chore: format

* Merge branch 'dev' into eslintV9

* fix: fix

* fix: ssr test

* fix: ssr test

* fix: use defineConfig

* fix: prettier format and ignore docs dist

* fix: index.mjs => index.js

* fix: Vscode color

* fix: prettier ignore global.d.ts

* fix: format

---------

Co-authored-by: 2586740555 <15972343+CYJ090915@user.noreply.gitee.com>
2025-09-29 14:14:30 +08:00

39 lines
1.3 KiB
TypeScript

import findWorkspacePackages from '@pnpm/find-workspace-packages'
import { normalizePath, projRoot } from './paths'
import type { ProjectManifest } from '@pnpm/types'
export const getWorkspacePackages = () => findWorkspacePackages(projRoot)
export const getWorkspaceNames = async (dir = projRoot) => {
const pkgs = await findWorkspacePackages(projRoot)
return pkgs
.filter((pkg) => pkg.dir.startsWith(dir))
.map((pkg) => pkg.manifest.name)
.filter((name): name is string => !!name)
}
export const getPackageManifest = (pkgPath: string) => {
return require(pkgPath) as ProjectManifest
}
export const getPackageDependencies = (
pkgPath: string
): Record<'dependencies' | 'peerDependencies', string[]> => {
const manifest = getPackageManifest(pkgPath)
const { dependencies = {}, peerDependencies = {} } = manifest
return {
dependencies: Object.keys(dependencies),
peerDependencies: Object.keys(peerDependencies),
}
}
export const excludeFiles = (files: string[]) => {
const excludes = ['node_modules', 'test', 'mock', 'gulpfile', 'dist']
const projRootPath = normalizePath(projRoot)
return files.filter((file) => {
const position = file.startsWith(projRootPath) ? projRootPath.length : 0
return !excludes.some((exclude) => file.includes(exclude, position))
})
}