npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vve-router-auth-cli

v1.1.2

Published

generate an auth file by router

Downloads

13

Readme

vve-router-auth-cli

Build Status

通过解析路由,生成授权文件

安装

使用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', '.js'],
  //所有的路由都加上这个前缀
  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 }
  ],
  // 路由菜单key映射扩展
  routerMenuExtends: {
    data: [], // [{ url: '', functionKey: '' }]
    urlKey: 'url',
    menuFunctionKey: 'functionKey'
  },
  // output输出信息,根据参考的菜单文件输出对应的文件 
  // [{ menuFilePath: '', mergeIntoMenuFile: false, unKeepEmptyVAuthListKey: false, outFilePath: '', props: {} }]
  // menuFilePath 参考的菜单文件,
  // outFilePath 输出的文件,只生成url有值的菜单,扁平化生成,不保留菜单层级结构
  // mergeIntoMenuFile 直接合并到菜单文件,默认合并到vAuthList的key中,此时outFilePath无效,当outFilePath与menuFilePath路径相同,等同次参数效果
  // mergeIntoMenuChildren 是否合并到菜单的children中,此时不再合并到menuVAuthList对应的key中
  // unKeepMenuWhenAuthIsEmpty 当是否vAuthList为空是否保留菜单,默认保留,当mergeIntoMenuFile为true时,此参数无效
  // shouldParentKeyAsPrefix 是否将父级菜单的key作为前缀,默认false
  // separatorBetweenParentKeyAndChildKey 父级菜单的key和子级菜单的key之间的分隔符,默认为'_',当shouldParentKeyAsPrefix为false时,此参数无效
  // 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,
  // 解析脚本中的authCode
  parseAuthInScript: false,
  // 解析vAuth用到参数
  vAuthParams: {
    authAttrList: [
      'v-auth',
      'v-permission'
    ],
    vAuthValueAttrList: [
      'data-v-auth-value'
    ],
    vAuthNameAttrList: [
      'data-auth-name'
    ],
    vEffectiveKeyList: [
      'effective-key'
    ],
    vAuthOperationTypeAttrList: [
      'data-auth-operation-type'
    ],
    vAuthValueRegList: [
      /^'([a-zA-Z0-9_$]+)'/,
      /^"([a-zA-Z0-9_$]+)"/,
    ],
    // 属性valueStr的正则
    attrValueRegList: [
      /^'(.+)'/,
      /^"(.+)"/,
      /\$t\('(.+)'\)/,
      /\$t\("(.+)"\)/
    ],
    // 属性valueStr的正则
    innerTextValueRegList: [
      /\$t\('(.+)'\)/,
      /\$t\("(.+)"\)/,
      /([a-zA-Z0-9_\u4e00-\u9fa5]+)/,
    ],
    // 属性authCode的正则
    authCodeRegList: [
      /authCode\s*:\s*'(.+)'/,
      /authCode\s*:\s*"(.+)"/,
    ],
    // 属性authCode的正则
    authCodeNameRegList: [
      /vAuthTitle\s*:\s*'(.+)'/,
      /vAuthTitle\s*:\s*"(.+)"/,
      /vAuthTitle\s*:.+\$t\("(.+)"\)/,
      /vAuthTitle\s*:.+\$t\('(.+)'\)/,
      /text\s*:\s*'(.+)'/,
      /text\s*:\s*"(.+)"/,
      /text\s*:.+\$t\("(.+)"\)/,
      /text\s*:.+\$t\('(.+)'\)/,
      /label\s*:\s*'(.+)'/,
      /label\s*:\s*"(.+)"/,
      /label\s*:.+\$t\("(.+)"\)/,
      /label\s*:.+\$t\('(.+)'\)/,
      /name\s*:\s*'(.+)'/,
      /name\s*:\s*"(.+)"/,
      /name\s*:.+\$t\("(.+)"\)/,
      /name\s*:.+\$t\('(.+)'\)/,
      /title\s*:\s*'(.+)'/,
      /title\s*:\s*"(.+)"/,
      /title\s*:.+\$t\("(.+)"\)/,
      /title\s*:.+\$t\('(.+)'\)/,
      /originTitle\s*:\s*'(.+)'/,
      /originTitle\s*:\s*"(.+)"/,
      /originTitle\s*:.+\$t\("(.+)"\)/,
      /originTitle\s*:.+\$t\('(.+)'\)/,
    ],
    effectiveKeyRegList: [
      /effectiveKey\s*:\s*'(.+)'/,
      /effectiveKey\s*:\s*"(.+)"/,
    ],
    // 属性operationType的正则
    operationTypeRegList: [
      /operationType\s*:\s*'(.+)'/,
      /operationType\s*:\s*"(.+)"/,
    ]
  }
};

开发

  • node >= 10
npm i // 安装依赖
npm test // 测试
npm run release // 发布
git push --follow-tags origin master && npm publish // npm 发布

Todo

  • [X] 告警滞后提示处理
  • [X] 增加importList显示

捐赠

如果你觉得它有用,你可以给我买一杯奶茶。