const { copyDir, fileForEach, readFile, writeFile, unlinkDirFileByExtname, dirForEach } = require('./plugin/fs') const print = require('./plugin/print') const path = require('path') const doExec = require('./plugin/exec') const PACKAGE_SRC = './src' const COMPILE_SRC = './lib' const COMPONENTS_DIR = '/components' const ENTRANCE = '/index.js' async function start () { const copyPackage = await copyDir(PACKAGE_SRC, COMPILE_SRC) if (!copyPackage) { print.error('Exception in file copy!') return false } print.success('Complete file copy!') const abstract = await abstractLessFromVue() if (!abstract) { print.error('Exception in less file extraction!') return false } print.success('Complete less file extraction!') await compileLessToCss() print.success('Complete less compilation to css!') const unlink = await unlinkDirFileByExtname(COMPILE_SRC, ['.less']) if (!unlink) { print.error('Exception in less file deletion!') return false } print.success('Complete less file deletion!') const addImport = await addCssImport() if (!addImport) { print.error('Exception in adding css import statement!') return false } print.success('Finish adding css import statement!') const componentsExport = await addComponentsExport() if (!componentsExport) { print.error('Exception in adding components export statement!') return false } print.success('Finish adding components export statement!') print.yellow('-------------------------------------') print.success(' DataV Lib Compile Success! ') print.yellow('-------------------------------------') return true } async function abstractLessFromVue () { let abstractSuccess = true await fileForEach(COMPILE_SRC, async src => { if (path.extname(src) !== '.vue') return let template = await readFile(src) let style = template.match(/