|
|
@ -1,5 +1,6 @@ |
|
|
|
const { resolve } = require("path"); |
|
|
|
const { resolve, relative, join } = require("path"); |
|
|
|
const { writeFileSync } = require("fs"); |
|
|
|
const { writeFileSync, readdirSync, statSync } = require("fs"); |
|
|
|
|
|
|
|
const { spawnSync } = require('child_process'); |
|
|
|
|
|
|
|
|
|
|
|
function pad2(n) {// always returns a string
|
|
|
|
function pad2(n) {// always returns a string
|
|
|
|
return (n < 10 ? "0" : "") + n; |
|
|
|
return (n < 10 ? "0" : "") + n; |
|
|
@ -27,3 +28,48 @@ packageJSON.publishConfig.registry = 'https://npm.fineres.com/'; |
|
|
|
packageJSON.name = "@fui/core"; |
|
|
|
packageJSON.name = "@fui/core"; |
|
|
|
|
|
|
|
|
|
|
|
writeFileSync(resolve(__dirname, "../../package.json"), JSON.stringify(packageJSON, null, 2)); |
|
|
|
writeFileSync(resolve(__dirname, "../../package.json"), JSON.stringify(packageJSON, null, 2)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将less打包成fineui.less发布到npm以供用户定制主题
|
|
|
|
|
|
|
|
const lessPath = join(process.cwd(), '/src/less'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function copyFiles(from, to) { |
|
|
|
|
|
|
|
spawnSync('cp', ['-r', from, to]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function removeFiles(src) { |
|
|
|
|
|
|
|
spawnSync('rm', ['-rf', src]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function readDirSync(directoryPath) { |
|
|
|
|
|
|
|
let content = ''; |
|
|
|
|
|
|
|
const pa = readdirSync(directoryPath); |
|
|
|
|
|
|
|
pa.forEach(file => { |
|
|
|
|
|
|
|
const filePath = `${directoryPath}/${file}`; |
|
|
|
|
|
|
|
const info = statSync(filePath); |
|
|
|
|
|
|
|
if (info.isDirectory()) { |
|
|
|
|
|
|
|
content += readDirSync(filePath); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
content += `@import "./${relative(lessPath, filePath)}";\n`; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return content; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function finalizeCompile() { |
|
|
|
|
|
|
|
const componentsLessContent = readDirSync(lessPath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
writeFileSync( |
|
|
|
|
|
|
|
join(lessPath, 'fineui.less'), |
|
|
|
|
|
|
|
componentsLessContent, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
removeFiles(`${lessPath}/images`); |
|
|
|
|
|
|
|
removeFiles(`${lessPath}/font`); |
|
|
|
|
|
|
|
removeFiles(`${lessPath}/fineui.less`); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
finalizeCompile(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
copyFiles(`${process.cwd()}/dist/images`, lessPath); |
|
|
|
|
|
|
|
copyFiles(`${process.cwd()}/dist/font`, lessPath); |
|
|
|