1.0.1 • Published 17 days ago
vve-router-auth-cli v1.0.1
vve-router-auth-cli
通过解析路由,生成授权文件
安装
使用npm安装:
$ npm install vve-router-auth-cli
使用
在package.json添加
"scripts": {
"router-auth-cli": "vve-router-auth-cli"
}
然后 npm run vve-router-auth-cli
参数
命令行指定参数
program
.version(require('../package.json').version)
.option("--cwd <path>", "工作目录")
.option("--root-dir <path>", "项目所在的根目录")
.option(
"--config <path>",
"配置文件的路径,没有配置,默认路径是在${cwd}/vve-router-auth-cli.config.js"
)
.option("--disable-config-file", "是否取配置文件")
.parse(process.argv);
配置文件指定参数
默认配置文件在${cwd}/vve-router-auth-cli.config.js,样例内容如下所示
module.exports = {
rootDir: 'src'
}
默认值
const config = {
// 工作目录
cwd: ".",
// 根目录,项目所在
rootDir: "src",
// 路由文件规则
routerFileRules: ["router.js"],
// 不匹配的路由文件规则
ignoreRouterFileRules: [],
// 文件的alias,同webpack配置
alias: {},
// 文件的extensions,同webpack配置
extensions: ['.vue'],
//所有的路由都加上这个前缀
routerBase: '',
// 父亲路由的前缀,相对路径都加上这个
parentRouterBase: '',
// router文件扩展{ urlPath: '', componentPath: '' },
routerExtends: [],
// 忽略的路由path规则,完整的路径地址
ignoreUrlPaths: [],
// 忽略的导入的文件规则,其文件内部import文件也将被忽略
ignoreImportFileRules: [],
// auth扩展{ [urlPath]: [{ functionName: '', functionKey: '' }] },
authExtends: {},
// 不匹配的authCode规则
ignoreAuthCodeRules: [],
// authCode和名称强制映射 { code: name }
authCodeNameMap: {},
// 自定义忽略被分析的内容,需要包含三个group,前中后
customIgnoreWrap: [
],
// 忽略被包裹,需要包含三个group,前中后
ignoreWrap: [
{ name: 'singleLineComment', regex: /(\/\/)([\s\S]*?)(\n)/g },
{ name: 'multiLineComment', regex: /(\/\*)([\s\S]*?)(\*\/)/g },
{ name: 'htmlComment', regex: /(<\!--)([\s\S]*?)(-->)/g },
],
// 忽略禁用包裹,需要包含三个group,前中后
ignoreDisableWrap: [
{ name: 'disableLine', regex: /(\n|^)(.*)(\/\/(?:[^\S\r\n]*|.*[^\S\r\n]+)vve-router-auth-disable-line(?:[^\S\r\n]*|[^\S\r\n]+.*))/g },
{ name: 'disableNextLine', regex: /(\/\/(?:[^\S\r\n]*|.*[^\S\r\n]+)vve-router-auth-disable-next-line(?:[^\S\r\n]*|[^\S\r\n]+.*)\n)(.+)(\n|$)/g },
{ name: 'disableWrap', regex: /(\/\*\s*vve-router-auth-disable\s*\*\/)([\s\S]*?)((?:\/\*\s*vve-router-auth-enable\s*\*\/)|$)/g }
],
// output输出信息,根据参考的菜单文件输出对应的文件
// [{ menuFilePath: '', mergeIntoMenuFile: false, outFilePath: '', props: {} }]
// menuFilePath 参考的菜单文件,
// outFilePath 输出的文件,只生成url有值的菜单,扁平化生成,不保留菜单层级结构
// mergeIntoMenuFile 直接合并到菜单文件,默认合并到vAuthList的key中,此时outFilePath无效,当outFilePath与menuFilePath路径相同,等同次参数效果
// mergeIntoMenuChildren 是否合并到菜单的children中,此时不再合并到menuVAuthList对应的key中
// props 属性映射
// vAuthFunctionName: 'functionName',
// vAuthFunctionKey: 'functionKey',
// vAuthOperationType: 'operationType',
// vAuthList: 'vAuthList',
// menuFunctionName: 'functionName',
// menuFunctionKey: 'functionKey',
// menuChildren: 'children',
// menuUrl: 'url',
// menuVAuthList: 'vAuthList',
output: [],
// 配置文件的路径,没有配置,默认路径是在${cwd}/vve-router-auth-cli.config.js
config: undefined,
// 是否取配置文件
disableConfigFile: false,
};
开发
- node >= 10
npm i // 安装依赖
npm test // 测试
npm run release // 发布
git push --follow-tags origin master && npm publish // npm 发布
Todo
- 告警滞后提示处理
- 增加importList显示
捐赠
如果你觉得它有用,你可以给我买一杯奶茶。
1.0.1
17 days ago