2021-10-06 19:40:44 +08:00
|
|
|
import path from 'path'
|
2022-03-25 15:35:56 +08:00
|
|
|
import { copyFile, mkdir } from 'fs/promises'
|
2021-12-10 18:18:16 +08:00
|
|
|
import { copy } from 'fs-extra'
|
2022-03-25 15:35:56 +08:00
|
|
|
import { parallel, series } from 'gulp'
|
2022-03-15 19:23:38 +08:00
|
|
|
import {
|
2022-03-25 15:35:56 +08:00
|
|
|
buildConfig,
|
2022-03-15 19:23:38 +08:00
|
|
|
buildOutput,
|
|
|
|
epOutput,
|
|
|
|
epPackage,
|
|
|
|
projRoot,
|
2022-03-25 15:35:56 +08:00
|
|
|
run,
|
|
|
|
runTask,
|
|
|
|
withTaskName,
|
2022-03-15 19:23:38 +08:00
|
|
|
} from './src'
|
2021-10-25 17:07:48 +08:00
|
|
|
import type { TaskFunction } from 'gulp'
|
2022-03-15 19:23:38 +08:00
|
|
|
import type { Module } from './src'
|
2021-08-24 13:36:48 +08:00
|
|
|
|
2021-12-10 23:48:21 +08:00
|
|
|
export const copyFiles = () =>
|
|
|
|
Promise.all([
|
2021-12-10 18:18:16 +08:00
|
|
|
copyFile(epPackage, path.join(epOutput, 'package.json')),
|
|
|
|
copyFile(
|
2021-12-10 23:48:21 +08:00
|
|
|
path.resolve(projRoot, 'README.md'),
|
2021-12-10 18:18:16 +08:00
|
|
|
path.resolve(epOutput, 'README.md')
|
|
|
|
),
|
2021-12-10 23:48:21 +08:00
|
|
|
copyFile(
|
2022-02-15 14:45:50 +08:00
|
|
|
path.resolve(projRoot, 'global.d.ts'),
|
2021-12-10 23:48:21 +08:00
|
|
|
path.resolve(epOutput, 'global.d.ts')
|
|
|
|
),
|
2021-10-25 17:07:48 +08:00
|
|
|
])
|
2021-08-24 13:36:48 +08:00
|
|
|
|
2021-10-25 17:07:48 +08:00
|
|
|
export const copyTypesDefinitions: TaskFunction = (done) => {
|
2021-12-10 18:18:16 +08:00
|
|
|
const src = path.resolve(buildOutput, 'types')
|
|
|
|
const copyTypes = (module: Module) =>
|
2021-10-25 17:07:48 +08:00
|
|
|
withTaskName(`copyTypes:${module}`, () =>
|
2021-12-10 18:18:16 +08:00
|
|
|
copy(src, buildConfig[module].output.path, { recursive: true })
|
2021-10-25 17:07:48 +08:00
|
|
|
)
|
|
|
|
|
2021-12-10 18:18:16 +08:00
|
|
|
return parallel(copyTypes('esm'), copyTypes('cjs'))(done)
|
2021-10-06 19:40:44 +08:00
|
|
|
}
|
|
|
|
|
2021-10-25 17:07:48 +08:00
|
|
|
export const copyFullStyle = async () => {
|
2021-12-10 18:18:16 +08:00
|
|
|
await mkdir(path.resolve(epOutput, 'dist'), { recursive: true })
|
|
|
|
await copyFile(
|
|
|
|
path.resolve(epOutput, 'theme-chalk/index.css'),
|
|
|
|
path.resolve(epOutput, 'dist/index.css')
|
|
|
|
)
|
2021-08-24 13:36:48 +08:00
|
|
|
}
|
|
|
|
|
2021-09-26 01:29:07 +08:00
|
|
|
export default series(
|
|
|
|
withTaskName('clean', () => run('pnpm run clean')),
|
2021-12-10 18:18:16 +08:00
|
|
|
withTaskName('createOutput', () => mkdir(epOutput, { recursive: true })),
|
2021-08-24 13:36:48 +08:00
|
|
|
|
2021-09-26 01:29:07 +08:00
|
|
|
parallel(
|
2021-10-25 17:07:48 +08:00
|
|
|
runTask('buildModules'),
|
2021-09-26 01:29:07 +08:00
|
|
|
runTask('buildFullBundle'),
|
2021-10-25 17:07:48 +08:00
|
|
|
runTask('generateTypesDefinitions'),
|
2021-09-26 01:29:07 +08:00
|
|
|
runTask('buildHelper'),
|
2021-10-25 17:07:48 +08:00
|
|
|
series(
|
|
|
|
withTaskName('buildThemeChalk', () =>
|
2022-03-15 19:23:38 +08:00
|
|
|
run('pnpm run --filter ./packages/ build --parallel')
|
2021-10-25 17:07:48 +08:00
|
|
|
),
|
|
|
|
copyFullStyle
|
2021-09-26 01:29:07 +08:00
|
|
|
)
|
|
|
|
),
|
|
|
|
|
2021-10-25 17:07:48 +08:00
|
|
|
parallel(copyTypesDefinitions, copyFiles)
|
2021-09-26 01:29:07 +08:00
|
|
|
)
|
|
|
|
|
2022-03-15 19:23:38 +08:00
|
|
|
export * from './src'
|