You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

60 lines
2.7 KiB

import chalk from "chalk"
import _ from "lodash"
import rimraf from "rimraf"
import fs from "fs-extra"
import * as util from "./util"
import buildComponent from "./buildComponent"
import buildAll from "./buildAll"
import { getOutput, getPath, getPkgs } from "@princess-ui/share"
import * as dts from "dts-bundle"
import pkg from "../princess-ui/package.json"
console.log(chalk.yellow(`当前工作目录:${process.cwd()}`))
const oldCwdFn = process.cwd
process.cwd = ()=>{
return getPkgs()
}
console.log(chalk.yellow(`修改后工作目录:${process.cwd()}`))
console.log(chalk.yellow("正在清除lib文件夹"))
rimraf(getOutput("lib"), async err => {
if (err) throw err
console.log(chalk.green("已清除lib文件夹"))
const components = await util.getComponents()
for (let i = 0; i < components.length; i++) {
const component = components[i]
const beginDate = new Date().getTime()
console.log(chalk.yellow(`开始构建${component}组件`))
await buildComponent("ps", component, "ps" + _.upperFirst(_.kebabCase(component)))
console.log(chalk.green(`构建${component}组件完成, 其耗时:${(new Date().getTime() - beginDate) / 1000}s`))
}
const beginDate = new Date().getTime()
console.log(chalk.yellow("构建组件结构"))
await util.generateComponents(components)
console.log(chalk.green("构建组件结构完成"))
console.log(chalk.yellow("构建全量包"))
await buildAll("ps")
console.log(chalk.green(`构建全量包完成, 其耗时:${(new Date().getTime() - beginDate) / 1000}s`))
console.log(chalk.red("构建完成,开始生成d.ts"))
// const dtsOptions = {
// name: pkg.name,
// main: `princess-ui/lib/packages/all.d.ts`,
// out: `../index.d.ts`,
// outputAsModuleFolder: true
// }
// dts.bundle(dtsOptions)
// console.log(chalk.red("生成完毕,开始清理残余"))
fs.moveSync(getOutput("lib/components/components.d.ts"), getOutput("lib/components.d.ts"), { overwrite: true })
fs.moveSync(getOutput("lib/all.d.ts"), getOutput("lib/index.d.ts"), { overwrite: true })
rimraf.sync(getOutput('lib/components'))
// fs.moveSync(getOutput("lib/packages/components/components.d.ts"), getOutput("lib/components.d.ts"), { overwrite: true })
// fs.moveSync(getOutput("lib/packages/hooks"), getOutput("lib/hooks"), { overwrite: true })
// fs.moveSync(getOutput("lib/packages/all.d.ts"), getOutput("lib/index.d.ts"), { overwrite: true })
// rimraf.sync(getOutput('lib/packages'))
// console.log(chalk.green("残余清理完毕"))
console.log(chalk.green("d.ts生成完毕"))
process.cwd = oldCwdFn
console.log(chalk.yellow(`工作目录重置为:${process.cwd()}`))
})