mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
feat: publish eslint config and metadata (#7063)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { buildRoot } from '@element-plus/build-utils'
|
||||
import { run } from './process'
|
||||
import { buildRoot } from './paths'
|
||||
|
||||
import type { TaskFunction } from 'gulp'
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
export * from './gulp'
|
||||
export * from './log'
|
||||
export * from './paths'
|
||||
export * from './pkg'
|
||||
export * from './process'
|
||||
export * from './rollup'
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
import process from 'process'
|
||||
import consola from 'consola'
|
||||
|
||||
export function errorAndExit(err: Error): never {
|
||||
consola.error(err)
|
||||
process.exit(1)
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import { resolve } from 'path'
|
||||
|
||||
export const projRoot = resolve(__dirname, '..', '..', '..', '..')
|
||||
export const pkgRoot = resolve(projRoot, 'packages')
|
||||
export const compRoot = resolve(pkgRoot, 'components')
|
||||
export const themeRoot = resolve(pkgRoot, 'theme-chalk')
|
||||
export const hookRoot = resolve(pkgRoot, 'hooks')
|
||||
export const localeRoot = resolve(pkgRoot, 'locale')
|
||||
export const directiveRoot = resolve(pkgRoot, 'directives')
|
||||
export const epRoot = resolve(pkgRoot, 'element-plus')
|
||||
export const utilRoot = resolve(pkgRoot, 'utils')
|
||||
export const buildRoot = resolve(projRoot, 'internal', 'build')
|
||||
|
||||
// Docs
|
||||
export const docsDirName = 'docs'
|
||||
export const docRoot = resolve(projRoot, docsDirName)
|
||||
export const vpRoot = resolve(docRoot, '.vitepress')
|
||||
|
||||
/** `/dist` */
|
||||
export const buildOutput = resolve(projRoot, 'dist')
|
||||
/** `/dist/element-plus` */
|
||||
export const epOutput = resolve(buildOutput, 'element-plus')
|
||||
|
||||
export const projPackage = resolve(projRoot, 'package.json')
|
||||
export const compPackage = resolve(compRoot, 'package.json')
|
||||
export const themePackage = resolve(themeRoot, 'package.json')
|
||||
export const hookPackage = resolve(hookRoot, 'package.json')
|
||||
export const localePackage = resolve(localeRoot, 'package.json')
|
||||
export const directivePackage = resolve(directiveRoot, 'package.json')
|
||||
export const epPackage = resolve(epRoot, 'package.json')
|
||||
export const utilPackage = resolve(utilRoot, 'package.json')
|
||||
export const docPackage = resolve(docRoot, 'package.json')
|
||||
@@ -1,36 +1,7 @@
|
||||
import findWorkspacePackages from '@pnpm/find-workspace-packages'
|
||||
import { PKG_PREFIX } from '@element-plus/build-constants'
|
||||
import { buildConfig } from '../build-info'
|
||||
import { projRoot } from './paths'
|
||||
|
||||
import type { Module } from '../build-info'
|
||||
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) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
||||
/** used for type generator */
|
||||
export const pathRewriter = (module: Module) => {
|
||||
@@ -42,10 +13,3 @@ export const pathRewriter = (module: Module) => {
|
||||
return id
|
||||
}
|
||||
}
|
||||
|
||||
export const excludeFiles = (files: string[]) => {
|
||||
const excludes = ['node_modules', 'test', 'mock', 'gulpfile', 'dist']
|
||||
return files.filter(
|
||||
(path) => !excludes.some((exclude) => path.includes(exclude))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { spawn } from 'child_process'
|
||||
import chalk from 'chalk'
|
||||
import consola from 'consola'
|
||||
import { projRoot } from './paths'
|
||||
import { projRoot } from '@element-plus/build-utils'
|
||||
|
||||
export const run = async (command: string, cwd: string = projRoot) =>
|
||||
new Promise<void>((resolve, reject) => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { epPackage } from './paths'
|
||||
import { getPackageDependencies } from './pkg'
|
||||
import { epPackage, getPackageDependencies } from '@element-plus/build-utils'
|
||||
|
||||
import type { OutputOptions, RollupBuild } from 'rollup'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user