mirror of
https://github.com/142vip/408CSFamily.git
synced 2026-04-26 03:30:02 +08:00
feat: 升级vuepress到最新版本,改造整个项目结构、配置 (#108)
* feat: 升级`vuepress`到最新版本,改造整个项目结构、配置 * chore: update * chore: update * fix: update
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
import * as fs from 'node:fs'
|
||||
import * as path from 'node:path'
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* 将思维导图的md格式转化为html,提供在线预览
|
||||
* 链接:https://www.npmjs.com/package/markmap-cli
|
||||
*/
|
||||
|
||||
import * as fs from 'node:fs'
|
||||
import * as path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { commandStandardExecutor } from '@142vip/utils'
|
||||
|
||||
const markMapSourcePath = path.join(__dirname, '../', 'docs/manuscripts/mark-map')
|
||||
const markMapTargetPath = path.join(__dirname, '../', 'docs/.vuepress/public/mark-map')
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
const markMapSourcePath = path.join(__dirname, '../', 'docs/mark-map')
|
||||
const markMapTargetPath = path.join(__dirname, '../', 'docs/.vuepress/public/mind-map')
|
||||
|
||||
/**
|
||||
* 扫面目录
|
||||
* 扫描目录
|
||||
*/
|
||||
function scanDirectory(directory, fileType) {
|
||||
const fileList = fs.readdirSync(directory)
|
||||
@@ -31,7 +34,6 @@ function scanDirectory(directory, fileType) {
|
||||
}
|
||||
|
||||
(async () => {
|
||||
console.log(1111, markMapSourcePath)
|
||||
/**
|
||||
* 第一步: 清空站点思维导图文件存放目录
|
||||
*/
|
||||
@@ -41,45 +43,31 @@ function scanDirectory(directory, fileType) {
|
||||
* 第二步: 将md文档转化为思维导图网页
|
||||
*/
|
||||
const mdList = scanDirectory(markMapSourcePath, 'md')
|
||||
const mdToHtmlCmdStr = mdList.map(md => `markmap --no-open ${md}`).join(' && ')
|
||||
const mdToHtmlCmdStr = mdList.map(md => `npx markmap --no-open ${md}`).join(' && ')
|
||||
|
||||
/**
|
||||
* 第三步: 根据文件类型将思维导图网页文件移动到站点指定目录
|
||||
*
|
||||
*/
|
||||
const mdHtmlByFileType = path.join(markMapSourcePath, '*.html')
|
||||
const moveHtmlCmdStr = `mv -f ${mdHtmlByFileType} ${markMapTargetPath}`
|
||||
|
||||
/**
|
||||
* 第四步: 将xmind思维导图原件复制到指定目录
|
||||
*
|
||||
*/
|
||||
const xmindByFileType = path.join(markMapSourcePath, '*.xmind')
|
||||
const cpXmindCmdStr = `cp -f ${xmindByFileType} ${markMapTargetPath}`
|
||||
|
||||
/**
|
||||
* 第五步: 复制mark-map对应的json文件
|
||||
*/
|
||||
const cpIndexJsonCmdStr = `cp -f ${path.join(markMapSourcePath, 'index.json')} ${markMapTargetPath}`
|
||||
|
||||
// 脚本执行
|
||||
await commandStandardExecutor([
|
||||
delHtmlDir,
|
||||
mdToHtmlCmdStr,
|
||||
moveHtmlCmdStr,
|
||||
cpXmindCmdStr,
|
||||
cpIndexJsonCmdStr,
|
||||
])
|
||||
|
||||
/**
|
||||
* 第六步: 对mark-map中的xmind文件重命名
|
||||
*
|
||||
*/
|
||||
const markMapData = require(path.join(markMapTargetPath, 'index.json'))
|
||||
for (const { originXmindFileName, targetXmindFileName } of markMapData) {
|
||||
const originPath = path.join(markMapTargetPath, originXmindFileName)
|
||||
const targetPath = path.join(markMapTargetPath, targetXmindFileName)
|
||||
|
||||
await fs.renameSync(originPath, targetPath)
|
||||
}
|
||||
// /**
|
||||
// * 第四步: 对mind-map中的xmind文件重命名
|
||||
// */
|
||||
// console.log(markMapSourcePath, import.meta.url)
|
||||
// const markMapData = createRequire(import.meta.url)('../../docs/mark-map/index.json')
|
||||
// console.log(111, markMapData)
|
||||
// for (const { originXmindFileName, targetXmindFileName } of markMapData) {
|
||||
// const originPath = path.join(markMapTargetPath, originXmindFileName)
|
||||
// const targetPath = path.join(markMapTargetPath, targetXmindFileName)
|
||||
//
|
||||
// // html文件
|
||||
// await fs.renameSync(originPath, targetPath)
|
||||
// }
|
||||
})()
|
||||
Reference in New Issue
Block a user