Skip to content

Commit

Permalink
build: refactor copyDefinitions (element-plus#3756)
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz authored Oct 6, 2021
1 parent cced42d commit a4c6544
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ $ pnpm gen component-name

Note the `component-name` must be in `kebab-case`, combining words by replacing each space with a dash.

And component type must be added to `packages/element-plus/global.d.ts`.
And component type must be added to `typings/global.d.ts`.

## Commit template

Expand Down
16 changes: 2 additions & 14 deletions build/entry-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,8 @@ export const genEntryTypes = async () => {
export const copyEntryTypes = (() => {
const src = path.resolve(buildOutput, 'entry/types')
const copy = (module: Module) =>
parallel(
withTaskName(`copyEntryTypes:${module}`, () =>
run(`rsync -a ${src}/ ${buildConfig[module].output.path}/`)
),
withTaskName('copyEntryDefinitions', async () => {
const files = await glob('*.d.ts', {
cwd: epRoot,
absolute: true,
onlyFiles: true,
})
await run(
`rsync -a ${files.join(' ')} ${buildConfig[module].output.path}/`
)
})
withTaskName(`copyEntryTypes:${module}`, () =>
run(`rsync -a ${src}/ ${buildConfig[module].output.path}/`)
)

return parallel(copy('esm'), copy('cjs'))
Expand Down
20 changes: 13 additions & 7 deletions build/gulpfile.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
import path from 'path'
import { series, parallel } from 'gulp'

import { copyStyle } from './style'
import { copyEntryTypes } from './entry-types'
import { run } from './utils/process'
import { withTaskName } from './utils/gulp'
import { epOutput, buildOutput, epPackage } from './utils/paths'
import { epOutput, epPackage, projRoot } from './utils/paths'
import { copyFullStyle } from './full-bundle'

const runTask = (name: string) =>
withTaskName(name, () => run(`pnpm run build ${name}`))

const copySourceCode = () => async () => {
export const copySourceCode = async () => {
await run(`cp -R packages ${epOutput}`)
await run(`cp ${epPackage} ${epOutput}/package.json`)
}

const copyREADME = () => async () => {
await run(`cp README.md ${buildOutput}/element-plus`)
export const copyREADME = async () => {
await run(`cp README.md ${epOutput}`)
}

export const copyDefinitions = async () => {
const files = [path.resolve(projRoot, 'typings', 'global.d.ts')]
await run(`cp ${files.join(' ')} ${epOutput}`)
}

export default series(
Expand All @@ -36,8 +41,9 @@ export default series(
copyStyle(),
copyFullStyle,
copyEntryTypes,
copySourceCode(),
copyREADME()
copySourceCode,
copyREADME,
copyDefinitions
)
)

Expand Down
File renamed without changes.

0 comments on commit a4c6544

Please sign in to comment.