-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of https://gitee.com/lookforwhat/vue-devui into dev
- Loading branch information
Showing
176 changed files
with
17,457 additions
and
990 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
#!/usr/bin/env node | ||
const { Command } = require('commander') | ||
const { create, validateCreateType } = require('./commands/create') | ||
const { VERSION } = require('./shared/constant') | ||
const { VERSION, CREATE_SUPPORT_TYPES } = require('./shared/constant') | ||
|
||
const program = new Command() | ||
|
||
program | ||
.command('create') | ||
.description('创建一个组件模板或配置文件') | ||
.option('-t --type <type>', '创建类型,可选值:component, vue-devui, vitepress/sidebar', validateCreateType) | ||
.option('-t --type <type>', `创建类型,可选值:${CREATE_SUPPORT_TYPES.join(', ')}`, validateCreateType) | ||
.option('--ignore-parse-error', '忽略解析错误', false) | ||
.option('--cover', '覆盖原文件', false) | ||
.action(create) | ||
|
||
program.parse().version(VERSION) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
const { CREATE_SUPPORT_TYPES } = require('../shared/constant') | ||
|
||
exports.selectCreateType = () => ({ | ||
name: 'type', | ||
type: 'list', | ||
message: '(必填)请选择创建类型:', | ||
choices: ['component', 'vue-devui', 'vitepress/sidebar'], | ||
choices: CREATE_SUPPORT_TYPES, | ||
default: 0 | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const { kebabCase } = require('lodash') | ||
const { SITES_COMPONENTS_DIR_NAME, VITEPRESS_SIDEBAR_CATEGORY } = require('../shared/constant') | ||
const logger = require('../shared/logger') | ||
|
||
function buildComponentOptions(text, name, status) { | ||
return { text, link: `/${SITES_COMPONENTS_DIR_NAME}/${kebabCase(name)}/`, status } | ||
} | ||
|
||
function buildCategoryOptions(text, children = []) { | ||
return { text, children } | ||
} | ||
|
||
exports.createVitepressSidebarTemplate = (componentsInfo) => { | ||
const rootNav = { text: '快速开始', link: '/' } | ||
const categoryMap = VITEPRESS_SIDEBAR_CATEGORY.reduce((map, cate) => map.set(cate, []), new Map()) | ||
|
||
;(componentsInfo || []).forEach((info) => { | ||
if (categoryMap.has(info.category)) { | ||
categoryMap.get(info.category).push(buildComponentOptions(info.title, info.name, info.status)) | ||
} else { | ||
logger.warning(`组件 ${info.name} 的分类 ${info.category} 不存在!`) | ||
} | ||
}) | ||
|
||
const sidebar = [].concat( | ||
rootNav, | ||
Array.from(categoryMap).map(([k, v]) => buildCategoryOptions(k, v)) | ||
) | ||
|
||
return `\ | ||
export default { | ||
'/': ${JSON.stringify(sidebar, null, 2).replace(/\n/g, '\n\t')} | ||
} | ||
` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.